aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/kernel-doc-nano-HOWTO.txt7
-rw-r--r--Documentation/x86/boot.txt13
-rw-r--r--MAINTAINERS12
-rw-r--r--arch/arm/kernel/machine_kexec.c4
-rw-r--r--arch/arm/mach-pxa/dma.c18
-rw-r--r--arch/arm/mach-pxa/include/mach/regs-ac97.h2
-rw-r--r--arch/arm/mach-pxa/include/mach/regs-ssp.h3
-rw-r--r--arch/arm/mach-pxa/pxa300.c4
-rw-r--r--arch/arm/mach-pxa/pxa320.c2
-rw-r--r--arch/frv/mm/dma-alloc.c2
-rw-r--r--arch/mips/include/asm/spinlock.h1
-rw-r--r--arch/powerpc/boot/dts/mpc8313erdb.dts11
-rw-r--r--arch/powerpc/configs/83xx/mpc8313_rdb_defconfig2
-rw-r--r--arch/powerpc/kernel/ftrace.c5
-rw-r--r--arch/powerpc/kernel/pci-common.c17
-rw-r--r--arch/powerpc/lib/sstep.c2
-rw-r--r--arch/powerpc/mm/fsl_booke_mmu.c4
-rw-r--r--arch/powerpc/mm/hash_low_32.S2
-rw-r--r--arch/powerpc/mm/pgtable_32.c4
-rw-r--r--arch/powerpc/oprofile/cell/spu_profiler.c1
-rw-r--r--arch/powerpc/platforms/82xx/pq2ads-pci-pic.c2
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-memory.c1
-rw-r--r--arch/powerpc/sysdev/cpm2_pic.c2
-rw-r--r--arch/powerpc/sysdev/ipic.c2
-rw-r--r--arch/s390/defconfig87
-rw-r--r--arch/s390/include/asm/lowcore.h4
-rw-r--r--arch/s390/kernel/irq.c2
-rw-r--r--arch/sparc/kernel/head_64.S31
-rw-r--r--arch/sparc/kernel/nmi.c1
-rw-r--r--arch/sparc/kernel/pcr.c7
-rw-r--r--arch/sparc/lib/GENbzero.S6
-rw-r--r--arch/sparc/lib/GENcopy_from_user.S8
-rw-r--r--arch/sparc/lib/GENcopy_to_user.S8
-rw-r--r--arch/sparc/lib/NG2copy_from_user.S9
-rw-r--r--arch/sparc/lib/NG2copy_to_user.S9
-rw-r--r--arch/sparc/lib/NGbzero.S6
-rw-r--r--arch/sparc/lib/NGcopy_from_user.S9
-rw-r--r--arch/sparc/lib/NGcopy_to_user.S9
-rw-r--r--arch/sparc/lib/U1copy_from_user.S8
-rw-r--r--arch/sparc/lib/U1copy_to_user.S8
-rw-r--r--arch/sparc/lib/U3copy_from_user.S6
-rw-r--r--arch/sparc/lib/U3copy_to_user.S8
-rw-r--r--arch/sparc/lib/bzero.S6
-rw-r--r--arch/sparc/lib/copy_in_user.S61
-rw-r--r--arch/x86/Kconfig602
-rw-r--r--arch/x86/Kconfig.cpu70
-rw-r--r--arch/x86/Kconfig.debug49
-rw-r--r--arch/x86/Makefile26
-rw-r--r--arch/x86/configs/i386_defconfig1
-rw-r--r--arch/x86/configs/x86_64_defconfig1
-rw-r--r--arch/x86/include/asm/apic.h74
-rw-r--r--arch/x86/include/asm/apm.h (renamed from arch/x86/include/asm/mach-default/apm.h)0
-rw-r--r--arch/x86/include/asm/bigsmp/apic.h155
-rw-r--r--arch/x86/include/asm/bigsmp/apicdef.h13
-rw-r--r--arch/x86/include/asm/bigsmp/ipi.h22
-rw-r--r--arch/x86/include/asm/cpu.h6
-rw-r--r--arch/x86/include/asm/do_timer.h (renamed from arch/x86/include/asm/mach-default/do_timer.h)0
-rw-r--r--arch/x86/include/asm/entry_arch.h (renamed from arch/x86/include/asm/mach-default/entry_arch.h)7
-rw-r--r--arch/x86/include/asm/es7000/apic.h242
-rw-r--r--arch/x86/include/asm/es7000/apicdef.h13
-rw-r--r--arch/x86/include/asm/es7000/ipi.h22
-rw-r--r--arch/x86/include/asm/es7000/mpparse.h29
-rw-r--r--arch/x86/include/asm/es7000/wakecpu.h37
-rw-r--r--arch/x86/include/asm/genapic.h262
-rw-r--r--arch/x86/include/asm/genapic_32.h141
-rw-r--r--arch/x86/include/asm/genapic_64.h60
-rw-r--r--arch/x86/include/asm/hw_irq.h24
-rw-r--r--arch/x86/include/asm/io.h2
-rw-r--r--arch/x86/include/asm/io_apic.h15
-rw-r--r--arch/x86/include/asm/ipi.h77
-rw-r--r--arch/x86/include/asm/irq.h4
-rw-r--r--arch/x86/include/asm/irq_vectors.h218
-rw-r--r--arch/x86/include/asm/mach-default/mach_apic.h168
-rw-r--r--arch/x86/include/asm/mach-default/mach_apicdef.h24
-rw-r--r--arch/x86/include/asm/mach-default/mach_ipi.h64
-rw-r--r--arch/x86/include/asm/mach-default/mach_mpparse.h17
-rw-r--r--arch/x86/include/asm/mach-default/mach_mpspec.h12
-rw-r--r--arch/x86/include/asm/mach-default/mach_wakecpu.h41
-rw-r--r--arch/x86/include/asm/mach-generic/gpio.h15
-rw-r--r--arch/x86/include/asm/mach-generic/mach_apic.h35
-rw-r--r--arch/x86/include/asm/mach-generic/mach_apicdef.h11
-rw-r--r--arch/x86/include/asm/mach-generic/mach_ipi.h10
-rw-r--r--arch/x86/include/asm/mach-generic/mach_mpparse.h9
-rw-r--r--arch/x86/include/asm/mach-generic/mach_mpspec.h12
-rw-r--r--arch/x86/include/asm/mach-generic/mach_wakecpu.h12
-rw-r--r--arch/x86/include/asm/mach-rdc321x/gpio.h60
-rw-r--r--arch/x86/include/asm/mach_timer.h (renamed from arch/x86/include/asm/mach-default/mach_timer.h)0
-rw-r--r--arch/x86/include/asm/mach_traps.h (renamed from arch/x86/include/asm/mach-default/mach_traps.h)0
-rw-r--r--arch/x86/include/asm/mpspec.h35
-rw-r--r--arch/x86/include/asm/numaq.h2
-rw-r--r--arch/x86/include/asm/numaq/apic.h142
-rw-r--r--arch/x86/include/asm/numaq/apicdef.h14
-rw-r--r--arch/x86/include/asm/numaq/ipi.h22
-rw-r--r--arch/x86/include/asm/numaq/mpparse.h6
-rw-r--r--arch/x86/include/asm/numaq/wakecpu.h45
-rw-r--r--arch/x86/include/asm/paravirt.h1
-rw-r--r--arch/x86/include/asm/pat.h4
-rw-r--r--arch/x86/include/asm/pci-functions.h (renamed from arch/x86/include/asm/mach-default/pci-functions.h)0
-rw-r--r--arch/x86/include/asm/prctl.h4
-rw-r--r--arch/x86/include/asm/processor.h2
-rw-r--r--arch/x86/include/asm/proto.h4
-rw-r--r--arch/x86/include/asm/rdc321x_defs.h (renamed from arch/x86/include/asm/mach-rdc321x/rdc321x_defs.h)0
-rw-r--r--arch/x86/include/asm/setup.h8
-rw-r--r--arch/x86/include/asm/setup_arch.h (renamed from arch/x86/include/asm/mach-default/setup_arch.h)0
-rw-r--r--arch/x86/include/asm/smp.h19
-rw-r--r--arch/x86/include/asm/smpboot_hooks.h (renamed from arch/x86/include/asm/mach-default/smpboot_hooks.h)6
-rw-r--r--arch/x86/include/asm/spinlock.h4
-rw-r--r--arch/x86/include/asm/summit/apic.h202
-rw-r--r--arch/x86/include/asm/summit/apicdef.h13
-rw-r--r--arch/x86/include/asm/summit/ipi.h26
-rw-r--r--arch/x86/include/asm/summit/mpparse.h109
-rw-r--r--arch/x86/include/asm/system.h6
-rw-r--r--arch/x86/include/asm/voyager.h42
-rw-r--r--arch/x86/include/asm/xen/events.h6
-rw-r--r--arch/x86/kernel/Makefile13
-rw-r--r--arch/x86/kernel/acpi/boot.c43
-rw-r--r--arch/x86/kernel/apic.c120
-rw-r--r--arch/x86/kernel/apm_32.c2
-rw-r--r--arch/x86/kernel/bigsmp_32.c266
-rw-r--r--arch/x86/kernel/cpu/addon_cpuid_features.c54
-rw-r--r--arch/x86/kernel/cpu/amd.c2
-rw-r--r--arch/x86/kernel/cpu/common.c93
-rw-r--r--arch/x86/kernel/cpu/cpufreq/powernow-k8.c28
-rw-r--r--arch/x86/kernel/cpu/intel.c14
-rw-r--r--arch/x86/kernel/crash.c2
-rw-r--r--arch/x86/kernel/entry_32.S2
-rw-r--r--arch/x86/kernel/entry_64.S2
-rw-r--r--arch/x86/kernel/es7000_32.c468
-rw-r--r--arch/x86/kernel/ftrace.c17
-rw-r--r--arch/x86/kernel/genapic_64.c22
-rw-r--r--arch/x86/kernel/genapic_flat_64.c176
-rw-r--r--arch/x86/kernel/genx2apic_cluster.c133
-rw-r--r--arch/x86/kernel/genx2apic_phys.c125
-rw-r--r--arch/x86/kernel/genx2apic_uv_x.c111
-rw-r--r--arch/x86/kernel/head_32.S13
-rw-r--r--arch/x86/kernel/hpet.c12
-rw-r--r--arch/x86/kernel/i8237.c17
-rw-r--r--arch/x86/kernel/io_apic.c272
-rw-r--r--arch/x86/kernel/ipi.c176
-rw-r--r--arch/x86/kernel/irq.c38
-rw-r--r--arch/x86/kernel/irq_32.c31
-rw-r--r--arch/x86/kernel/irq_64.c34
-rw-r--r--arch/x86/kernel/irqinit_32.c12
-rw-r--r--arch/x86/kernel/kgdb.c4
-rw-r--r--arch/x86/kernel/mpparse.c36
-rw-r--r--arch/x86/kernel/nmi.c2
-rw-r--r--arch/x86/kernel/numaq_32.c307
-rw-r--r--arch/x86/kernel/probe_32.c411
-rw-r--r--arch/x86/kernel/probe_roms_32.c2
-rw-r--r--arch/x86/kernel/process.c2
-rw-r--r--arch/x86/kernel/reboot.c4
-rw-r--r--arch/x86/kernel/setup.c30
-rw-r--r--arch/x86/kernel/smp.c15
-rw-r--r--arch/x86/kernel/smpboot.c43
-rw-r--r--arch/x86/kernel/stacktrace.c2
-rw-r--r--arch/x86/kernel/summit_32.c416
-rw-r--r--arch/x86/kernel/time_32.c2
-rw-r--r--arch/x86/kernel/tlb_uv.c2
-rw-r--r--arch/x86/kernel/traps.c2
-rw-r--r--arch/x86/kernel/tsc.c2
-rw-r--r--arch/x86/kernel/visws_quirks.c6
-rw-r--r--arch/x86/kernel/vmiclock_32.c2
-rw-r--r--arch/x86/mach-default/Makefile5
-rw-r--r--arch/x86/mach-default/setup.c174
-rw-r--r--arch/x86/mach-generic/Makefile11
-rw-r--r--arch/x86/mach-generic/bigsmp.c60
-rw-r--r--arch/x86/mach-generic/default.c27
-rw-r--r--arch/x86/mach-generic/es7000.c103
-rw-r--r--arch/x86/mach-generic/numaq.c53
-rw-r--r--arch/x86/mach-generic/probe.c152
-rw-r--r--arch/x86/mach-generic/summit.c40
-rw-r--r--arch/x86/mach-rdc321x/Makefile5
-rw-r--r--arch/x86/mach-rdc321x/gpio.c194
-rw-r--r--arch/x86/mach-rdc321x/platform.c69
-rw-r--r--arch/x86/mm/Makefile2
-rw-r--r--arch/x86/mm/fault.c1
-rw-r--r--arch/x86/mm/ioremap.c2
-rw-r--r--arch/x86/mm/mmap.c2
-rw-r--r--arch/x86/mm/pat.c31
-rw-r--r--arch/x86/mm/tlb.c4
-rw-r--r--arch/x86/pci/numaq_32.c6
-rw-r--r--arch/x86/pci/pcbios.c2
-rw-r--r--arch/x86/xen/irq.c17
-rw-r--r--crypto/algapi.c6
-rw-r--r--crypto/api.c20
-rw-r--r--crypto/scatterwalk.c3
-rw-r--r--crypto/shash.c7
-rw-r--r--drivers/atm/solos-pci.c1
-rw-r--r--drivers/block/nbd.c9
-rw-r--r--drivers/char/tpm/tpm_infineon.c4
-rw-r--r--drivers/clocksource/acpi_pm.c2
-rw-r--r--drivers/clocksource/cyclone.c2
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c47
-rw-r--r--drivers/eisa/Kconfig6
-rw-r--r--drivers/gpu/drm/Kconfig2
-rw-r--r--drivers/gpu/drm/drm_irq.c1
-rw-r--r--drivers/gpu/drm/drm_memory.c7
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c47
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c1
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h8
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c83
-rw-r--r--drivers/gpu/drm/i915/i915_gem_tiling.c91
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c13
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h10
-rw-r--r--drivers/gpu/drm/i915/intel_display.c20
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h1
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c49
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c870
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo_regs.h404
-rw-r--r--drivers/gpu/drm/radeon/radeon_cp.c6
-rw-r--r--drivers/input/keyboard/Kconfig4
-rw-r--r--drivers/input/mouse/Kconfig2
-rw-r--r--drivers/isdn/hardware/mISDN/hfcmulti.c2
-rw-r--r--drivers/mtd/nand/Kconfig2
-rw-r--r--drivers/net/3c509.c1
-rw-r--r--drivers/net/gianfar.c6
-rw-r--r--drivers/net/netxen/netxen_nic.h2
-rw-r--r--drivers/net/netxen/netxen_nic_main.c13
-rw-r--r--drivers/net/r8169.c93
-rw-r--r--drivers/net/sungem.c8
-rw-r--r--drivers/net/sunhme.c12
-rw-r--r--drivers/net/tulip/de2104x.c3
-rw-r--r--drivers/net/tun.c10
-rw-r--r--drivers/parport/parport_serial.c5
-rw-r--r--drivers/power/pcf50633-charger.c3
-rw-r--r--drivers/rtc/rtc-au1xxx.c2
-rw-r--r--drivers/rtc/rtc-pxa.c2
-rw-r--r--drivers/s390/block/dasd.c46
-rw-r--r--drivers/s390/block/dasd_devmap.c2
-rw-r--r--drivers/staging/android/Kconfig1
-rw-r--r--drivers/staging/android/ram_console.c14
-rw-r--r--drivers/staging/android/timed_gpio.c2
-rw-r--r--drivers/staging/at76_usb/Kconfig2
-rw-r--r--drivers/staging/at76_usb/at76_usb.c4620
-rw-r--r--drivers/staging/at76_usb/at76_usb.h227
-rw-r--r--drivers/staging/panel/panel.c10
-rw-r--r--drivers/usb/Makefile1
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c46
-rw-r--r--drivers/usb/serial/aircable.c4
-rw-r--r--drivers/usb/serial/ftdi_sio.c5
-rw-r--r--drivers/usb/serial/ftdi_sio.h3
-rw-r--r--drivers/usb/serial/option.c93
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c10
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.h2
-rw-r--r--drivers/usb/storage/scsiglue.c2
-rw-r--r--drivers/usb/storage/transport.c36
-rw-r--r--drivers/usb/storage/unusual_devs.h17
-rw-r--r--drivers/video/Kconfig6
-rw-r--r--drivers/video/bfin-t350mcqb-fb.c2
-rw-r--r--drivers/video/geode/gx1fb_core.c17
-rw-r--r--drivers/video/geode/gxfb_core.c17
-rw-r--r--drivers/video/geode/lxfb_core.c17
-rw-r--r--drivers/w1/slaves/w1_therm.c2
-rw-r--r--drivers/watchdog/rdc321x_wdt.c2
-rw-r--r--drivers/xen/events.c227
-rw-r--r--fs/btrfs/ctree.c3
-rw-r--r--fs/btrfs/locking.c22
-rw-r--r--fs/btrfs/locking.h2
-rw-r--r--fs/ext2/super.c9
-rw-r--r--fs/ext3/super.c11
-rw-r--r--fs/hugetlbfs/inode.c8
-rw-r--r--fs/jbd/journal.c17
-rw-r--r--fs/lockd/svclock.c6
-rw-r--r--include/crypto/hash.h2
-rw-r--r--include/drm/i915_drm.h2
-rw-r--r--include/linux/cgroup.h1
-rw-r--r--include/linux/crypto.h7
-rw-r--r--include/linux/dmaengine.h12
-rw-r--r--include/linux/hugetlb.h11
-rw-r--r--include/linux/init_task.h11
-rw-r--r--include/linux/mm.h3
-rw-r--r--include/linux/sched.h64
-rw-r--r--include/linux/smp.h6
-rw-r--r--include/linux/spinlock.h5
-rw-r--r--include/linux/syscalls.h28
-rw-r--r--init/main.c12
-rw-r--r--ipc/shm.c8
-rw-r--r--kernel/cgroup.c3
-rw-r--r--kernel/exit.c3
-rw-r--r--kernel/fork.c5
-rw-r--r--kernel/itimer.c4
-rw-r--r--kernel/posix-cpu-timers.c117
-rw-r--r--kernel/profile.c3
-rw-r--r--kernel/sched.c27
-rw-r--r--kernel/sched_fair.c11
-rw-r--r--kernel/sched_stats.h45
-rw-r--r--kernel/signal.c8
-rw-r--r--kernel/sysctl.c5
-rw-r--r--mm/fremap.c2
-rw-r--r--mm/hugetlb.c28
-rw-r--r--mm/migrate.c2
-rw-r--r--mm/mlock.c5
-rw-r--r--mm/mmap.c48
-rw-r--r--mm/mprotect.c5
-rw-r--r--mm/page-writeback.c33
-rw-r--r--mm/page_cgroup.c3
-rw-r--r--mm/rmap.c3
-rw-r--r--mm/slab.c1
-rw-r--r--mm/slob.c1
-rw-r--r--mm/slub.c1
-rw-r--r--net/9p/protocol.c22
-rw-r--r--net/bridge/br_forward.c7
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/neighbour.c14
-rw-r--r--net/ipv4/udp.c6
-rw-r--r--net/ipv6/ip6_flowlabel.c8
-rw-r--r--net/ipv6/ip6_tunnel.c2
-rw-r--r--net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c25
-rw-r--r--net/netfilter/nf_conntrack_netlink.c15
-rw-r--r--net/netfilter/xt_sctp.c2
-rw-r--r--net/rxrpc/af_rxrpc.c5
-rwxr-xr-xscripts/kernel-doc40
-rw-r--r--sound/arm/aaci.c6
-rw-r--r--sound/drivers/Kconfig2
315 files changed, 10336 insertions, 6109 deletions
diff --git a/Documentation/kernel-doc-nano-HOWTO.txt b/Documentation/kernel-doc-nano-HOWTO.txt
index d73fbd2b2b4..026ec7d5738 100644
--- a/Documentation/kernel-doc-nano-HOWTO.txt
+++ b/Documentation/kernel-doc-nano-HOWTO.txt
@@ -43,7 +43,8 @@ Only comments so marked will be considered by the kernel-doc scripts,
43and any comment so marked must be in kernel-doc format. Do not use 43and any comment so marked must be in kernel-doc format. Do not use
44"/**" to be begin a comment block unless the comment block contains 44"/**" to be begin a comment block unless the comment block contains
45kernel-doc formatted comments. The closing comment marker for 45kernel-doc formatted comments. The closing comment marker for
46kernel-doc comments can be either "*/" or "**/". 46kernel-doc comments can be either "*/" or "**/", but "*/" is
47preferred in the Linux kernel tree.
47 48
48Kernel-doc comments should be placed just before the function 49Kernel-doc comments should be placed just before the function
49or data structure being described. 50or data structure being described.
@@ -63,7 +64,7 @@ Example kernel-doc function comment:
63 * comment lines. 64 * comment lines.
64 * 65 *
65 * The longer description can have multiple paragraphs. 66 * The longer description can have multiple paragraphs.
66 **/ 67 */
67 68
68The first line, with the short description, must be on a single line. 69The first line, with the short description, must be on a single line.
69 70
@@ -85,7 +86,7 @@ Example kernel-doc data structure comment.
85 * perhaps with more lines and words. 86 * perhaps with more lines and words.
86 * 87 *
87 * Longer description of this structure. 88 * Longer description of this structure.
88 **/ 89 */
89 90
90The kernel-doc function comments describe each parameter to the 91The kernel-doc function comments describe each parameter to the
91function, in order, with the @name lines. 92function, in order, with the @name lines.
diff --git a/Documentation/x86/boot.txt b/Documentation/x86/boot.txt
index 7b4596ac412..12299697b7c 100644
--- a/Documentation/x86/boot.txt
+++ b/Documentation/x86/boot.txt
@@ -158,7 +158,7 @@ Offset Proto Name Meaning
1580202/4 2.00+ header Magic signature "HdrS" 1580202/4 2.00+ header Magic signature "HdrS"
1590206/2 2.00+ version Boot protocol version supported 1590206/2 2.00+ version Boot protocol version supported
1600208/4 2.00+ realmode_swtch Boot loader hook (see below) 1600208/4 2.00+ realmode_swtch Boot loader hook (see below)
161020C/2 2.00+ start_sys The load-low segment (0x1000) (obsolete) 161020C/2 2.00+ start_sys_seg The load-low segment (0x1000) (obsolete)
162020E/2 2.00+ kernel_version Pointer to kernel version string 162020E/2 2.00+ kernel_version Pointer to kernel version string
1630210/1 2.00+ type_of_loader Boot loader identifier 1630210/1 2.00+ type_of_loader Boot loader identifier
1640211/1 2.00+ loadflags Boot protocol option flags 1640211/1 2.00+ loadflags Boot protocol option flags
@@ -170,10 +170,11 @@ Offset Proto Name Meaning
1700224/2 2.01+ heap_end_ptr Free memory after setup end 1700224/2 2.01+ heap_end_ptr Free memory after setup end
1710226/2 N/A pad1 Unused 1710226/2 N/A pad1 Unused
1720228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line 1720228/4 2.02+ cmd_line_ptr 32-bit pointer to the kernel command line
173022C/4 2.03+ initrd_addr_max Highest legal initrd address 173022C/4 2.03+ ramdisk_max Highest legal initrd address
1740230/4 2.05+ kernel_alignment Physical addr alignment required for kernel 1740230/4 2.05+ kernel_alignment Physical addr alignment required for kernel
1750234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not 1750234/1 2.05+ relocatable_kernel Whether kernel is relocatable or not
1760235/3 N/A pad2 Unused 1760235/1 N/A pad2 Unused
1770236/2 N/A pad3 Unused
1770238/4 2.06+ cmdline_size Maximum size of the kernel command line 1780238/4 2.06+ cmdline_size Maximum size of the kernel command line
178023C/4 2.07+ hardware_subarch Hardware subarchitecture 179023C/4 2.07+ hardware_subarch Hardware subarchitecture
1790240/8 2.07+ hardware_subarch_data Subarchitecture-specific data 1800240/8 2.07+ hardware_subarch_data Subarchitecture-specific data
@@ -299,14 +300,14 @@ Protocol: 2.00+
299 e.g. 0x0204 for version 2.04, and 0x0a11 for a hypothetical version 300 e.g. 0x0204 for version 2.04, and 0x0a11 for a hypothetical version
300 10.17. 301 10.17.
301 302
302Field name: readmode_swtch 303Field name: realmode_swtch
303Type: modify (optional) 304Type: modify (optional)
304Offset/size: 0x208/4 305Offset/size: 0x208/4
305Protocol: 2.00+ 306Protocol: 2.00+
306 307
307 Boot loader hook (see ADVANCED BOOT LOADER HOOKS below.) 308 Boot loader hook (see ADVANCED BOOT LOADER HOOKS below.)
308 309
309Field name: start_sys 310Field name: start_sys_seg
310Type: read 311Type: read
311Offset/size: 0x20c/2 312Offset/size: 0x20c/2
312Protocol: 2.00+ 313Protocol: 2.00+
@@ -468,7 +469,7 @@ Protocol: 2.02+
468 zero, the kernel will assume that your boot loader does not support 469 zero, the kernel will assume that your boot loader does not support
469 the 2.02+ protocol. 470 the 2.02+ protocol.
470 471
471Field name: initrd_addr_max 472Field name: ramdisk_max
472Type: read 473Type: read
473Offset/size: 0x22c/4 474Offset/size: 0x22c/4
474Protocol: 2.03+ 475Protocol: 2.03+
diff --git a/MAINTAINERS b/MAINTAINERS
index 0ea3a6d9871..db65b4e6d13 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1202,6 +1202,8 @@ S: Supported
1202CONTROL GROUPS (CGROUPS) 1202CONTROL GROUPS (CGROUPS)
1203P: Paul Menage 1203P: Paul Menage
1204M: menage@google.com 1204M: menage@google.com
1205P: Li Zefan
1206M: lizf@cn.fujitsu.com
1205L: containers@lists.linux-foundation.org 1207L: containers@lists.linux-foundation.org
1206S: Maintained 1208S: Maintained
1207 1209
@@ -3537,6 +3539,12 @@ S: Maintained
3537PXA MMCI DRIVER 3539PXA MMCI DRIVER
3538S: Orphan 3540S: Orphan
3539 3541
3542PXA RTC DRIVER
3543P: Robert Jarzmik
3544M: robert.jarzmik@free.fr
3545L: rtc-linux@googlegroups.com
3546S: Maintained
3547
3540QLOGIC QLA2XXX FC-SCSI DRIVER 3548QLOGIC QLA2XXX FC-SCSI DRIVER
3541P: Andrew Vasquez 3549P: Andrew Vasquez
3542M: linux-driver@qlogic.com 3550M: linux-driver@qlogic.com
@@ -4285,8 +4293,8 @@ P: Rajiv Andrade
4285M: srajiv@linux.vnet.ibm.com 4293M: srajiv@linux.vnet.ibm.com
4286W: http://tpmdd.sourceforge.net 4294W: http://tpmdd.sourceforge.net
4287P: Marcel Selhorst 4295P: Marcel Selhorst
4288M: tpm@selhorst.net 4296M: m.selhorst@sirrix.com
4289W: http://www.prosec.rub.de/tpm/ 4297W: http://www.sirrix.com
4290L: tpmdd-devel@lists.sourceforge.net (moderated for non-subscribers) 4298L: tpmdd-devel@lists.sourceforge.net (moderated for non-subscribers)
4291S: Maintained 4299S: Maintained
4292 4300
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index 440dc62cdc3..598ca61e7bc 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -13,8 +13,8 @@
13#include <asm/cacheflush.h> 13#include <asm/cacheflush.h>
14#include <asm/mach-types.h> 14#include <asm/mach-types.h>
15 15
16const extern unsigned char relocate_new_kernel[]; 16extern const unsigned char relocate_new_kernel[];
17const extern unsigned int relocate_new_kernel_size; 17extern const unsigned int relocate_new_kernel_size;
18 18
19extern void setup_mm_for_reboot(char mode); 19extern void setup_mm_for_reboot(char mode);
20 20
diff --git a/arch/arm/mach-pxa/dma.c b/arch/arm/mach-pxa/dma.c
index b1514fb20d3..7de17fc5d54 100644
--- a/arch/arm/mach-pxa/dma.c
+++ b/arch/arm/mach-pxa/dma.c
@@ -121,20 +121,22 @@ int __init pxa_init_dma(int num_ch)
121 if (dma_channels == NULL) 121 if (dma_channels == NULL)
122 return -ENOMEM; 122 return -ENOMEM;
123 123
124 ret = request_irq(IRQ_DMA, dma_irq_handler, IRQF_DISABLED, "DMA", NULL);
125 if (ret) {
126 printk (KERN_CRIT "Wow! Can't register IRQ for DMA\n");
127 kfree(dma_channels);
128 return ret;
129 }
130
131 /* dma channel priorities on pxa2xx processors: 124 /* dma channel priorities on pxa2xx processors:
132 * ch 0 - 3, 16 - 19 <--> (0) DMA_PRIO_HIGH 125 * ch 0 - 3, 16 - 19 <--> (0) DMA_PRIO_HIGH
133 * ch 4 - 7, 20 - 23 <--> (1) DMA_PRIO_MEDIUM 126 * ch 4 - 7, 20 - 23 <--> (1) DMA_PRIO_MEDIUM
134 * ch 8 - 15, 24 - 31 <--> (2) DMA_PRIO_LOW 127 * ch 8 - 15, 24 - 31 <--> (2) DMA_PRIO_LOW
135 */ 128 */
136 for (i = 0; i < num_ch; i++) 129 for (i = 0; i < num_ch; i++) {
130 DCSR(i) = 0;
137 dma_channels[i].prio = min((i & 0xf) >> 2, DMA_PRIO_LOW); 131 dma_channels[i].prio = min((i & 0xf) >> 2, DMA_PRIO_LOW);
132 }
133
134 ret = request_irq(IRQ_DMA, dma_irq_handler, IRQF_DISABLED, "DMA", NULL);
135 if (ret) {
136 printk (KERN_CRIT "Wow! Can't register IRQ for DMA\n");
137 kfree(dma_channels);
138 return ret;
139 }
138 140
139 num_dma_channels = num_ch; 141 num_dma_channels = num_ch;
140 return 0; 142 return 0;
diff --git a/arch/arm/mach-pxa/include/mach/regs-ac97.h b/arch/arm/mach-pxa/include/mach/regs-ac97.h
index e41b9d202b8..b8d14bd9ae5 100644
--- a/arch/arm/mach-pxa/include/mach/regs-ac97.h
+++ b/arch/arm/mach-pxa/include/mach/regs-ac97.h
@@ -1,6 +1,8 @@
1#ifndef __ASM_ARCH_REGS_AC97_H 1#ifndef __ASM_ARCH_REGS_AC97_H
2#define __ASM_ARCH_REGS_AC97_H 2#define __ASM_ARCH_REGS_AC97_H
3 3
4#include <mach/hardware.h>
5
4/* 6/*
5 * AC97 Controller registers 7 * AC97 Controller registers
6 */ 8 */
diff --git a/arch/arm/mach-pxa/include/mach/regs-ssp.h b/arch/arm/mach-pxa/include/mach/regs-ssp.h
index 3c04cde2cf1..cf31986f6f0 100644
--- a/arch/arm/mach-pxa/include/mach/regs-ssp.h
+++ b/arch/arm/mach-pxa/include/mach/regs-ssp.h
@@ -41,6 +41,9 @@
41#elif defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx) 41#elif defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
42#define SSCR0_SCR (0x000fff00) /* Serial Clock Rate (mask) */ 42#define SSCR0_SCR (0x000fff00) /* Serial Clock Rate (mask) */
43#define SSCR0_SerClkDiv(x) (((x) - 1) << 8) /* Divisor [1..4096] */ 43#define SSCR0_SerClkDiv(x) (((x) - 1) << 8) /* Divisor [1..4096] */
44#endif
45
46#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
44#define SSCR0_EDSS (1 << 20) /* Extended data size select */ 47#define SSCR0_EDSS (1 << 20) /* Extended data size select */
45#define SSCR0_NCS (1 << 21) /* Network clock select */ 48#define SSCR0_NCS (1 << 21) /* Network clock select */
46#define SSCR0_RIM (1 << 22) /* Receive FIFO overrrun interrupt mask */ 49#define SSCR0_RIM (1 << 22) /* Receive FIFO overrrun interrupt mask */
diff --git a/arch/arm/mach-pxa/pxa300.c b/arch/arm/mach-pxa/pxa300.c
index f735e58e666..83fb609b6eb 100644
--- a/arch/arm/mach-pxa/pxa300.c
+++ b/arch/arm/mach-pxa/pxa300.c
@@ -88,13 +88,13 @@ static struct pxa3xx_mfp_addr_map pxa310_mfp_addr_map[] __initdata = {
88static DEFINE_PXA3_CKEN(common_nand, NAND, 156000000, 0); 88static DEFINE_PXA3_CKEN(common_nand, NAND, 156000000, 0);
89 89
90static struct clk_lookup common_clkregs[] = { 90static struct clk_lookup common_clkregs[] = {
91 INIT_CLKREG(&clk_common_nand, "pxa3xx-nand", "NANDCLK"), 91 INIT_CLKREG(&clk_common_nand, "pxa3xx-nand", NULL),
92}; 92};
93 93
94static DEFINE_PXA3_CKEN(pxa310_mmc3, MMC3, 19500000, 0); 94static DEFINE_PXA3_CKEN(pxa310_mmc3, MMC3, 19500000, 0);
95 95
96static struct clk_lookup pxa310_clkregs[] = { 96static struct clk_lookup pxa310_clkregs[] = {
97 INIT_CLKREG(&clk_pxa310_mmc3, "pxa2xx-mci.2", "MMCCLK"), 97 INIT_CLKREG(&clk_pxa310_mmc3, "pxa2xx-mci.2", NULL),
98}; 98};
99 99
100static int __init pxa300_init(void) 100static int __init pxa300_init(void)
diff --git a/arch/arm/mach-pxa/pxa320.c b/arch/arm/mach-pxa/pxa320.c
index effe408c186..36f066196fa 100644
--- a/arch/arm/mach-pxa/pxa320.c
+++ b/arch/arm/mach-pxa/pxa320.c
@@ -83,7 +83,7 @@ static struct pxa3xx_mfp_addr_map pxa320_mfp_addr_map[] __initdata = {
83static DEFINE_PXA3_CKEN(pxa320_nand, NAND, 104000000, 0); 83static DEFINE_PXA3_CKEN(pxa320_nand, NAND, 104000000, 0);
84 84
85static struct clk_lookup pxa320_clkregs[] = { 85static struct clk_lookup pxa320_clkregs[] = {
86 INIT_CLKREG(&clk_pxa320_nand, "pxa3xx-nand", "NANDCLK"), 86 INIT_CLKREG(&clk_pxa320_nand, "pxa3xx-nand", NULL),
87}; 87};
88 88
89static int __init pxa320_init(void) 89static int __init pxa320_init(void)
diff --git a/arch/frv/mm/dma-alloc.c b/arch/frv/mm/dma-alloc.c
index dc6522c464d..44840e73e90 100644
--- a/arch/frv/mm/dma-alloc.c
+++ b/arch/frv/mm/dma-alloc.c
@@ -36,10 +36,10 @@
36#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
37#include <linux/init.h> 37#include <linux/init.h>
38#include <linux/pci.h> 38#include <linux/pci.h>
39#include <linux/hardirq.h>
39 40
40#include <asm/pgalloc.h> 41#include <asm/pgalloc.h>
41#include <asm/io.h> 42#include <asm/io.h>
42#include <asm/hardirq.h>
43#include <asm/mmu_context.h> 43#include <asm/mmu_context.h>
44#include <asm/pgtable.h> 44#include <asm/pgtable.h>
45#include <asm/mmu.h> 45#include <asm/mmu.h>
diff --git a/arch/mips/include/asm/spinlock.h b/arch/mips/include/asm/spinlock.h
index 1a1f320c30d..0884947ebe2 100644
--- a/arch/mips/include/asm/spinlock.h
+++ b/arch/mips/include/asm/spinlock.h
@@ -51,6 +51,7 @@ static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
51 51
52 return (((counters >> 14) - counters) & 0x1fff) > 1; 52 return (((counters >> 14) - counters) & 0x1fff) > 1;
53} 53}
54#define __raw_spin_is_contended __raw_spin_is_contended
54 55
55static inline void __raw_spin_lock(raw_spinlock_t *lock) 56static inline void __raw_spin_lock(raw_spinlock_t *lock)
56{ 57{
diff --git a/arch/powerpc/boot/dts/mpc8313erdb.dts b/arch/powerpc/boot/dts/mpc8313erdb.dts
index 909a89cab9a..3ebf7ec0484 100644
--- a/arch/powerpc/boot/dts/mpc8313erdb.dts
+++ b/arch/powerpc/boot/dts/mpc8313erdb.dts
@@ -191,7 +191,8 @@
191 interrupts = <37 0x8 36 0x8 35 0x8>; 191 interrupts = <37 0x8 36 0x8 35 0x8>;
192 interrupt-parent = <&ipic>; 192 interrupt-parent = <&ipic>;
193 tbi-handle = < &tbi0 >; 193 tbi-handle = < &tbi0 >;
194 phy-handle = < &phy1 >; 194 /* Vitesse 7385 isn't on the MDIO bus */
195 fixed-link = <1 1 1000 0 0>;
195 fsl,magic-packet; 196 fsl,magic-packet;
196 197
197 mdio@24520 { 198 mdio@24520 {
@@ -199,12 +200,6 @@
199 #size-cells = <0>; 200 #size-cells = <0>;
200 compatible = "fsl,gianfar-mdio"; 201 compatible = "fsl,gianfar-mdio";
201 reg = <0x24520 0x20>; 202 reg = <0x24520 0x20>;
202 phy1: ethernet-phy@1 {
203 interrupt-parent = <&ipic>;
204 interrupts = <19 0x8>;
205 reg = <0x1>;
206 device_type = "ethernet-phy";
207 };
208 phy4: ethernet-phy@4 { 203 phy4: ethernet-phy@4 {
209 interrupt-parent = <&ipic>; 204 interrupt-parent = <&ipic>;
210 interrupts = <20 0x8>; 205 interrupts = <20 0x8>;
@@ -219,6 +214,8 @@
219 }; 214 };
220 215
221 enet1: ethernet@25000 { 216 enet1: ethernet@25000 {
217 #address-cells = <1>;
218 #size-cells = <1>;
222 cell-index = <1>; 219 cell-index = <1>;
223 device_type = "network"; 220 device_type = "network";
224 model = "eTSEC"; 221 model = "eTSEC";
diff --git a/arch/powerpc/configs/83xx/mpc8313_rdb_defconfig b/arch/powerpc/configs/83xx/mpc8313_rdb_defconfig
index 9e47ae957e2..409d017621a 100644
--- a/arch/powerpc/configs/83xx/mpc8313_rdb_defconfig
+++ b/arch/powerpc/configs/83xx/mpc8313_rdb_defconfig
@@ -651,7 +651,7 @@ CONFIG_CICADA_PHY=y
651# CONFIG_NATIONAL_PHY is not set 651# CONFIG_NATIONAL_PHY is not set
652# CONFIG_STE10XP is not set 652# CONFIG_STE10XP is not set
653# CONFIG_LSI_ET1011C_PHY is not set 653# CONFIG_LSI_ET1011C_PHY is not set
654# CONFIG_FIXED_PHY is not set 654CONFIG_FIXED_PHY=y
655# CONFIG_MDIO_BITBANG is not set 655# CONFIG_MDIO_BITBANG is not set
656CONFIG_NET_ETHERNET=y 656CONFIG_NET_ETHERNET=y
657CONFIG_MII=y 657CONFIG_MII=y
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 5355244c99f..60c60ccf5e3 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -195,8 +195,9 @@ __ftrace_make_nop(struct module *mod,
195 return -EINVAL; 195 return -EINVAL;
196 } 196 }
197 197
198 offset = (unsigned)((unsigned short)jmp[0]) << 16 | 198 /* The bottom half is signed extended */
199 (unsigned)((unsigned short)jmp[1]); 199 offset = ((unsigned)((unsigned short)jmp[0]) << 16) +
200 (int)((short)jmp[1]);
200 201
201 DEBUGP(" %x ", offset); 202 DEBUGP(" %x ", offset);
202 203
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 19b12d2cbb4..0f418127231 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -561,8 +561,21 @@ int pci_mmap_legacy_page_range(struct pci_bus *bus,
561 (unsigned long long)(offset + size - 1)); 561 (unsigned long long)(offset + size - 1));
562 562
563 if (mmap_state == pci_mmap_mem) { 563 if (mmap_state == pci_mmap_mem) {
564 if ((offset + size) > hose->isa_mem_size) 564 /* Hack alert !
565 return -ENXIO; 565 *
566 * Because X is lame and can fail starting if it gets an error trying
567 * to mmap legacy_mem (instead of just moving on without legacy memory
568 * access) we fake it here by giving it anonymous memory, effectively
569 * behaving just like /dev/zero
570 */
571 if ((offset + size) > hose->isa_mem_size) {
572 printk(KERN_DEBUG
573 "Process %s (pid:%d) mapped non-existing PCI legacy memory for 0%04x:%02x\n",
574 current->comm, current->pid, pci_domain_nr(bus), bus->number);
575 if (vma->vm_flags & VM_SHARED)
576 return shmem_zero_setup(vma);
577 return 0;
578 }
566 offset += hose->isa_mem_phys; 579 offset += hose->isa_mem_phys;
567 } else { 580 } else {
568 unsigned long io_offset = (unsigned long)hose->io_base_virt - _IO_BASE; 581 unsigned long io_offset = (unsigned long)hose->io_base_virt - _IO_BASE;
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 4aae0c38764..13b7d54f185 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -172,6 +172,8 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
172 } 172 }
173 break; 173 break;
174 case 0x378: /* orx */ 174 case 0x378: /* orx */
175 if (instr & 1)
176 break;
175 rs = (instr >> 21) & 0x1f; 177 rs = (instr >> 21) & 0x1f;
176 rb = (instr >> 11) & 0x1f; 178 rb = (instr >> 11) & 0x1f;
177 if (rs == rb) { /* mr */ 179 if (rs == rb) { /* mr */
diff --git a/arch/powerpc/mm/fsl_booke_mmu.c b/arch/powerpc/mm/fsl_booke_mmu.c
index 1971e4ee3d6..ea6e41e39d9 100644
--- a/arch/powerpc/mm/fsl_booke_mmu.c
+++ b/arch/powerpc/mm/fsl_booke_mmu.c
@@ -73,7 +73,7 @@ extern unsigned int tlbcam_index;
73/* 73/*
74 * Return PA for this VA if it is mapped by a CAM, or 0 74 * Return PA for this VA if it is mapped by a CAM, or 0
75 */ 75 */
76unsigned long v_mapped_by_tlbcam(unsigned long va) 76phys_addr_t v_mapped_by_tlbcam(unsigned long va)
77{ 77{
78 int b; 78 int b;
79 for (b = 0; b < tlbcam_index; ++b) 79 for (b = 0; b < tlbcam_index; ++b)
@@ -85,7 +85,7 @@ unsigned long v_mapped_by_tlbcam(unsigned long va)
85/* 85/*
86 * Return VA for a given PA or 0 if not mapped 86 * Return VA for a given PA or 0 if not mapped
87 */ 87 */
88unsigned long p_mapped_by_tlbcam(unsigned long pa) 88unsigned long p_mapped_by_tlbcam(phys_addr_t pa)
89{ 89{
90 int b; 90 int b;
91 for (b = 0; b < tlbcam_index; ++b) 91 for (b = 0; b < tlbcam_index; ++b)
diff --git a/arch/powerpc/mm/hash_low_32.S b/arch/powerpc/mm/hash_low_32.S
index 67850ec9feb..14af8cedab7 100644
--- a/arch/powerpc/mm/hash_low_32.S
+++ b/arch/powerpc/mm/hash_low_32.S
@@ -320,7 +320,7 @@ _GLOBAL(create_hpte)
320 and r8,r8,r0 /* writable if _RW & _DIRTY */ 320 and r8,r8,r0 /* writable if _RW & _DIRTY */
321 rlwimi r5,r5,32-1,30,30 /* _PAGE_USER -> PP msb */ 321 rlwimi r5,r5,32-1,30,30 /* _PAGE_USER -> PP msb */
322 rlwimi r5,r5,32-2,31,31 /* _PAGE_USER -> PP lsb */ 322 rlwimi r5,r5,32-2,31,31 /* _PAGE_USER -> PP lsb */
323 ori r8,r8,0xe14 /* clear out reserved bits and M */ 323 ori r8,r8,0xe04 /* clear out reserved bits */
324 andc r8,r5,r8 /* PP = user? (rw&dirty? 2: 3): 0 */ 324 andc r8,r5,r8 /* PP = user? (rw&dirty? 2: 3): 0 */
325BEGIN_FTR_SECTION 325BEGIN_FTR_SECTION
326 rlwinm r8,r8,0,~_PAGE_COHERENT /* clear M (coherence not required) */ 326 rlwinm r8,r8,0,~_PAGE_COHERENT /* clear M (coherence not required) */
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 22972cd83cc..58bcaeba728 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -61,8 +61,8 @@ void setbat(int index, unsigned long virt, phys_addr_t phys,
61 61
62#ifdef HAVE_TLBCAM 62#ifdef HAVE_TLBCAM
63extern unsigned int tlbcam_index; 63extern unsigned int tlbcam_index;
64extern unsigned long v_mapped_by_tlbcam(unsigned long va); 64extern phys_addr_t v_mapped_by_tlbcam(unsigned long va);
65extern unsigned long p_mapped_by_tlbcam(unsigned long pa); 65extern unsigned long p_mapped_by_tlbcam(phys_addr_t pa);
66#else /* !HAVE_TLBCAM */ 66#else /* !HAVE_TLBCAM */
67#define v_mapped_by_tlbcam(x) (0UL) 67#define v_mapped_by_tlbcam(x) (0UL)
68#define p_mapped_by_tlbcam(x) (0UL) 68#define p_mapped_by_tlbcam(x) (0UL)
diff --git a/arch/powerpc/oprofile/cell/spu_profiler.c b/arch/powerpc/oprofile/cell/spu_profiler.c
index 9305ddaac51..b129d007e7f 100644
--- a/arch/powerpc/oprofile/cell/spu_profiler.c
+++ b/arch/powerpc/oprofile/cell/spu_profiler.c
@@ -16,6 +16,7 @@
16#include <linux/smp.h> 16#include <linux/smp.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <asm/cell-pmu.h> 18#include <asm/cell-pmu.h>
19#include <asm/time.h>
19#include "pr_util.h" 20#include "pr_util.h"
20 21
21#define SCALE_SHIFT 14 22#define SCALE_SHIFT 14
diff --git a/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c b/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
index 9876d7e072f..ddf0bdc0fc8 100644
--- a/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
+++ b/arch/powerpc/platforms/82xx/pq2ads-pci-pic.c
@@ -186,7 +186,7 @@ out_unmap_regs:
186 iounmap(priv->regs); 186 iounmap(priv->regs);
187out_free_bootmem: 187out_free_bootmem:
188 free_bootmem((unsigned long)priv, 188 free_bootmem((unsigned long)priv,
189 sizeof(sizeof(struct pq2ads_pci_pic))); 189 sizeof(struct pq2ads_pci_pic));
190 of_node_put(np); 190 of_node_put(np);
191out_unmap_irq: 191out_unmap_irq:
192 irq_dispose_mapping(irq); 192 irq_dispose_mapping(irq);
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index a623ad256e9..9b21ee68ea5 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -14,6 +14,7 @@
14#include <asm/firmware.h> 14#include <asm/firmware.h>
15#include <asm/machdep.h> 15#include <asm/machdep.h>
16#include <asm/pSeries_reconfig.h> 16#include <asm/pSeries_reconfig.h>
17#include <asm/sparsemem.h>
17 18
18static int pseries_remove_lmb(unsigned long base, unsigned int lmb_size) 19static int pseries_remove_lmb(unsigned long base, unsigned int lmb_size)
19{ 20{
diff --git a/arch/powerpc/sysdev/cpm2_pic.c b/arch/powerpc/sysdev/cpm2_pic.c
index b16ca3ed65d..78f1f7cca0a 100644
--- a/arch/powerpc/sysdev/cpm2_pic.c
+++ b/arch/powerpc/sysdev/cpm2_pic.c
@@ -165,7 +165,7 @@ static int cpm2_set_irq_type(unsigned int virq, unsigned int flow_type)
165 edibit = (14 - (src - CPM2_IRQ_EXT1)); 165 edibit = (14 - (src - CPM2_IRQ_EXT1));
166 else 166 else
167 if (src >= CPM2_IRQ_PORTC15 && src <= CPM2_IRQ_PORTC0) 167 if (src >= CPM2_IRQ_PORTC15 && src <= CPM2_IRQ_PORTC0)
168 edibit = (31 - (src - CPM2_IRQ_PORTC15)); 168 edibit = (31 - (CPM2_IRQ_PORTC0 - src));
169 else 169 else
170 return (flow_type & IRQ_TYPE_LEVEL_LOW) ? 0 : -EINVAL; 170 return (flow_type & IRQ_TYPE_LEVEL_LOW) ? 0 : -EINVAL;
171 171
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index 88a983ece5c..9a89cd3e80a 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -890,7 +890,7 @@ unsigned int ipic_get_irq(void)
890 return irq_linear_revmap(primary_ipic->irqhost, irq); 890 return irq_linear_revmap(primary_ipic->irqhost, irq);
891} 891}
892 892
893#ifdef CONFIG_PM 893#ifdef CONFIG_SUSPEND
894static struct { 894static struct {
895 u32 sicfr; 895 u32 sicfr;
896 u32 siprr[2]; 896 u32 siprr[2];
diff --git a/arch/s390/defconfig b/arch/s390/defconfig
index a0e748da990..31e809c7779 100644
--- a/arch/s390/defconfig
+++ b/arch/s390/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.28-rc6 3# Linux kernel version: 2.6.29-rc4
4# Thu Nov 27 11:00:49 2008 4# Wed Feb 11 10:07:16 2009
5# 5#
6CONFIG_SCHED_MC=y 6CONFIG_SCHED_MC=y
7CONFIG_MMU=y 7CONFIG_MMU=y
@@ -14,12 +14,14 @@ CONFIG_RWSEM_XCHGADD_ALGORITHM=y
14# CONFIG_ARCH_HAS_ILOG2_U64 is not set 14# CONFIG_ARCH_HAS_ILOG2_U64 is not set
15CONFIG_GENERIC_HWEIGHT=y 15CONFIG_GENERIC_HWEIGHT=y
16CONFIG_GENERIC_TIME=y 16CONFIG_GENERIC_TIME=y
17CONFIG_GENERIC_TIME_VSYSCALL=y
17CONFIG_GENERIC_CLOCKEVENTS=y 18CONFIG_GENERIC_CLOCKEVENTS=y
18CONFIG_GENERIC_BUG=y 19CONFIG_GENERIC_BUG=y
19CONFIG_NO_IOMEM=y 20CONFIG_NO_IOMEM=y
20CONFIG_NO_DMA=y 21CONFIG_NO_DMA=y
21CONFIG_GENERIC_LOCKBREAK=y 22CONFIG_GENERIC_LOCKBREAK=y
22CONFIG_PGSTE=y 23CONFIG_PGSTE=y
24CONFIG_VIRT_CPU_ACCOUNTING=y
23CONFIG_S390=y 25CONFIG_S390=y
24CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 26CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
25 27
@@ -39,20 +41,29 @@ CONFIG_POSIX_MQUEUE=y
39# CONFIG_TASKSTATS is not set 41# CONFIG_TASKSTATS is not set
40CONFIG_AUDIT=y 42CONFIG_AUDIT=y
41# CONFIG_AUDITSYSCALL is not set 43# CONFIG_AUDITSYSCALL is not set
44
45#
46# RCU Subsystem
47#
48CONFIG_CLASSIC_RCU=y
49# CONFIG_TREE_RCU is not set
50# CONFIG_PREEMPT_RCU is not set
51# CONFIG_TREE_RCU_TRACE is not set
52# CONFIG_PREEMPT_RCU_TRACE is not set
42CONFIG_IKCONFIG=y 53CONFIG_IKCONFIG=y
43CONFIG_IKCONFIG_PROC=y 54CONFIG_IKCONFIG_PROC=y
44CONFIG_LOG_BUF_SHIFT=17 55CONFIG_LOG_BUF_SHIFT=17
56CONFIG_GROUP_SCHED=y
57CONFIG_FAIR_GROUP_SCHED=y
58# CONFIG_RT_GROUP_SCHED is not set
59CONFIG_USER_SCHED=y
60# CONFIG_CGROUP_SCHED is not set
45CONFIG_CGROUPS=y 61CONFIG_CGROUPS=y
46# CONFIG_CGROUP_DEBUG is not set 62# CONFIG_CGROUP_DEBUG is not set
47CONFIG_CGROUP_NS=y 63CONFIG_CGROUP_NS=y
48# CONFIG_CGROUP_FREEZER is not set 64# CONFIG_CGROUP_FREEZER is not set
49# CONFIG_CGROUP_DEVICE is not set 65# CONFIG_CGROUP_DEVICE is not set
50# CONFIG_CPUSETS is not set 66# CONFIG_CPUSETS is not set
51CONFIG_GROUP_SCHED=y
52CONFIG_FAIR_GROUP_SCHED=y
53# CONFIG_RT_GROUP_SCHED is not set
54CONFIG_USER_SCHED=y
55# CONFIG_CGROUP_SCHED is not set
56# CONFIG_CGROUP_CPUACCT is not set 67# CONFIG_CGROUP_CPUACCT is not set
57# CONFIG_RESOURCE_COUNTERS is not set 68# CONFIG_RESOURCE_COUNTERS is not set
58CONFIG_SYSFS_DEPRECATED=y 69CONFIG_SYSFS_DEPRECATED=y
@@ -63,6 +74,7 @@ CONFIG_UTS_NS=y
63CONFIG_IPC_NS=y 74CONFIG_IPC_NS=y
64# CONFIG_USER_NS is not set 75# CONFIG_USER_NS is not set
65# CONFIG_PID_NS is not set 76# CONFIG_PID_NS is not set
77# CONFIG_NET_NS is not set
66CONFIG_BLK_DEV_INITRD=y 78CONFIG_BLK_DEV_INITRD=y
67CONFIG_INITRAMFS_SOURCE="" 79CONFIG_INITRAMFS_SOURCE=""
68# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 80# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -91,17 +103,17 @@ CONFIG_SLAB=y
91# CONFIG_SLUB is not set 103# CONFIG_SLUB is not set
92# CONFIG_SLOB is not set 104# CONFIG_SLOB is not set
93# CONFIG_PROFILING is not set 105# CONFIG_PROFILING is not set
94# CONFIG_MARKERS is not set
95CONFIG_HAVE_OPROFILE=y 106CONFIG_HAVE_OPROFILE=y
96CONFIG_KPROBES=y 107CONFIG_KPROBES=y
108CONFIG_HAVE_SYSCALL_WRAPPERS=y
97CONFIG_KRETPROBES=y 109CONFIG_KRETPROBES=y
98CONFIG_HAVE_KPROBES=y 110CONFIG_HAVE_KPROBES=y
99CONFIG_HAVE_KRETPROBES=y 111CONFIG_HAVE_KRETPROBES=y
100CONFIG_HAVE_ARCH_TRACEHOOK=y 112CONFIG_HAVE_ARCH_TRACEHOOK=y
113CONFIG_USE_GENERIC_SMP_HELPERS=y
101# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 114# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
102CONFIG_SLABINFO=y 115CONFIG_SLABINFO=y
103CONFIG_RT_MUTEXES=y 116CONFIG_RT_MUTEXES=y
104# CONFIG_TINY_SHMEM is not set
105CONFIG_BASE_SMALL=0 117CONFIG_BASE_SMALL=0
106CONFIG_MODULES=y 118CONFIG_MODULES=y
107# CONFIG_MODULE_FORCE_LOAD is not set 119# CONFIG_MODULE_FORCE_LOAD is not set
@@ -109,7 +121,7 @@ CONFIG_MODULE_UNLOAD=y
109# CONFIG_MODULE_FORCE_UNLOAD is not set 121# CONFIG_MODULE_FORCE_UNLOAD is not set
110CONFIG_MODVERSIONS=y 122CONFIG_MODVERSIONS=y
111# CONFIG_MODULE_SRCVERSION_ALL is not set 123# CONFIG_MODULE_SRCVERSION_ALL is not set
112CONFIG_KMOD=y 124CONFIG_INIT_ALL_POSSIBLE=y
113CONFIG_STOP_MACHINE=y 125CONFIG_STOP_MACHINE=y
114CONFIG_BLOCK=y 126CONFIG_BLOCK=y
115# CONFIG_BLK_DEV_IO_TRACE is not set 127# CONFIG_BLK_DEV_IO_TRACE is not set
@@ -130,7 +142,6 @@ CONFIG_DEFAULT_DEADLINE=y
130# CONFIG_DEFAULT_NOOP is not set 142# CONFIG_DEFAULT_NOOP is not set
131CONFIG_DEFAULT_IOSCHED="deadline" 143CONFIG_DEFAULT_IOSCHED="deadline"
132CONFIG_PREEMPT_NOTIFIERS=y 144CONFIG_PREEMPT_NOTIFIERS=y
133CONFIG_CLASSIC_RCU=y
134# CONFIG_FREEZER is not set 145# CONFIG_FREEZER is not set
135 146
136# 147#
@@ -161,6 +172,7 @@ CONFIG_S390_EXEC_PROTECT=y
161CONFIG_MARCH_Z900=y 172CONFIG_MARCH_Z900=y
162# CONFIG_MARCH_Z990 is not set 173# CONFIG_MARCH_Z990 is not set
163# CONFIG_MARCH_Z9_109 is not set 174# CONFIG_MARCH_Z9_109 is not set
175# CONFIG_MARCH_Z10 is not set
164CONFIG_PACK_STACK=y 176CONFIG_PACK_STACK=y
165# CONFIG_SMALL_STACK is not set 177# CONFIG_SMALL_STACK is not set
166CONFIG_CHECK_STACK=y 178CONFIG_CHECK_STACK=y
@@ -174,7 +186,6 @@ CONFIG_ARCH_POPULATES_NODE_MAP=y
174# CONFIG_PREEMPT_NONE is not set 186# CONFIG_PREEMPT_NONE is not set
175# CONFIG_PREEMPT_VOLUNTARY is not set 187# CONFIG_PREEMPT_VOLUNTARY is not set
176CONFIG_PREEMPT=y 188CONFIG_PREEMPT=y
177# CONFIG_PREEMPT_RCU is not set
178CONFIG_ARCH_SPARSEMEM_ENABLE=y 189CONFIG_ARCH_SPARSEMEM_ENABLE=y
179CONFIG_ARCH_SPARSEMEM_DEFAULT=y 190CONFIG_ARCH_SPARSEMEM_DEFAULT=y
180CONFIG_ARCH_SELECT_MEMORY_MODEL=y 191CONFIG_ARCH_SELECT_MEMORY_MODEL=y
@@ -195,7 +206,6 @@ CONFIG_MEMORY_HOTREMOVE=y
195CONFIG_PAGEFLAGS_EXTENDED=y 206CONFIG_PAGEFLAGS_EXTENDED=y
196CONFIG_SPLIT_PTLOCK_CPUS=4 207CONFIG_SPLIT_PTLOCK_CPUS=4
197CONFIG_MIGRATION=y 208CONFIG_MIGRATION=y
198CONFIG_RESOURCES_64BIT=y
199CONFIG_PHYS_ADDR_T_64BIT=y 209CONFIG_PHYS_ADDR_T_64BIT=y
200CONFIG_ZONE_DMA_FLAG=1 210CONFIG_ZONE_DMA_FLAG=1
201CONFIG_BOUNCE=y 211CONFIG_BOUNCE=y
@@ -207,7 +217,6 @@ CONFIG_UNEVICTABLE_LRU=y
207# 217#
208CONFIG_MACHCHK_WARNING=y 218CONFIG_MACHCHK_WARNING=y
209CONFIG_QDIO=y 219CONFIG_QDIO=y
210# CONFIG_QDIO_DEBUG is not set
211CONFIG_CHSC_SCH=m 220CONFIG_CHSC_SCH=m
212 221
213# 222#
@@ -227,15 +236,13 @@ CONFIG_PFAULT=y
227# CONFIG_SHARED_KERNEL is not set 236# CONFIG_SHARED_KERNEL is not set
228# CONFIG_CMM is not set 237# CONFIG_CMM is not set
229# CONFIG_PAGE_STATES is not set 238# CONFIG_PAGE_STATES is not set
230CONFIG_VIRT_TIMER=y
231CONFIG_VIRT_CPU_ACCOUNTING=y
232# CONFIG_APPLDATA_BASE is not set 239# CONFIG_APPLDATA_BASE is not set
233CONFIG_HZ_100=y 240CONFIG_HZ_100=y
234# CONFIG_HZ_250 is not set 241# CONFIG_HZ_250 is not set
235# CONFIG_HZ_300 is not set 242# CONFIG_HZ_300 is not set
236# CONFIG_HZ_1000 is not set 243# CONFIG_HZ_1000 is not set
237CONFIG_HZ=100 244CONFIG_HZ=100
238# CONFIG_SCHED_HRTICK is not set 245CONFIG_SCHED_HRTICK=y
239CONFIG_S390_HYPFS_FS=y 246CONFIG_S390_HYPFS_FS=y
240CONFIG_KEXEC=y 247CONFIG_KEXEC=y
241# CONFIG_ZFCPDUMP is not set 248# CONFIG_ZFCPDUMP is not set
@@ -245,6 +252,7 @@ CONFIG_NET=y
245# 252#
246# Networking options 253# Networking options
247# 254#
255CONFIG_COMPAT_NET_DEV_OPS=y
248CONFIG_PACKET=y 256CONFIG_PACKET=y
249# CONFIG_PACKET_MMAP is not set 257# CONFIG_PACKET_MMAP is not set
250CONFIG_UNIX=y 258CONFIG_UNIX=y
@@ -383,6 +391,7 @@ CONFIG_NET_SCH_TBF=m
383CONFIG_NET_SCH_GRED=m 391CONFIG_NET_SCH_GRED=m
384CONFIG_NET_SCH_DSMARK=m 392CONFIG_NET_SCH_DSMARK=m
385# CONFIG_NET_SCH_NETEM is not set 393# CONFIG_NET_SCH_NETEM is not set
394# CONFIG_NET_SCH_DRR is not set
386# CONFIG_NET_SCH_INGRESS is not set 395# CONFIG_NET_SCH_INGRESS is not set
387 396
388# 397#
@@ -400,6 +409,7 @@ CONFIG_CLS_U32_MARK=y
400CONFIG_NET_CLS_RSVP=m 409CONFIG_NET_CLS_RSVP=m
401CONFIG_NET_CLS_RSVP6=m 410CONFIG_NET_CLS_RSVP6=m
402CONFIG_NET_CLS_FLOW=m 411CONFIG_NET_CLS_FLOW=m
412# CONFIG_NET_CLS_CGROUP is not set
403# CONFIG_NET_EMATCH is not set 413# CONFIG_NET_EMATCH is not set
404CONFIG_NET_CLS_ACT=y 414CONFIG_NET_CLS_ACT=y
405CONFIG_NET_ACT_POLICE=y 415CONFIG_NET_ACT_POLICE=y
@@ -411,6 +421,7 @@ CONFIG_NET_ACT_NAT=m
411# CONFIG_NET_ACT_SKBEDIT is not set 421# CONFIG_NET_ACT_SKBEDIT is not set
412# CONFIG_NET_CLS_IND is not set 422# CONFIG_NET_CLS_IND is not set
413CONFIG_NET_SCH_FIFO=y 423CONFIG_NET_SCH_FIFO=y
424# CONFIG_DCB is not set
414 425
415# 426#
416# Network testing 427# Network testing
@@ -428,6 +439,7 @@ CONFIG_CAN_VCAN=m
428# CONFIG_CAN_DEBUG_DEVICES is not set 439# CONFIG_CAN_DEBUG_DEVICES is not set
429# CONFIG_AF_RXRPC is not set 440# CONFIG_AF_RXRPC is not set
430# CONFIG_PHONET is not set 441# CONFIG_PHONET is not set
442# CONFIG_WIMAX is not set
431# CONFIG_RFKILL is not set 443# CONFIG_RFKILL is not set
432# CONFIG_NET_9P is not set 444# CONFIG_NET_9P is not set
433# CONFIG_PCMCIA is not set 445# CONFIG_PCMCIA is not set
@@ -475,11 +487,15 @@ CONFIG_DASD_DIAG=y
475CONFIG_DASD_EER=y 487CONFIG_DASD_EER=y
476CONFIG_VIRTIO_BLK=m 488CONFIG_VIRTIO_BLK=m
477CONFIG_MISC_DEVICES=y 489CONFIG_MISC_DEVICES=y
478# CONFIG_EEPROM_93CX6 is not set
479# CONFIG_ENCLOSURE_SERVICES is not set 490# CONFIG_ENCLOSURE_SERVICES is not set
480# CONFIG_C2PORT is not set 491# CONFIG_C2PORT is not set
481 492
482# 493#
494# EEPROM support
495#
496# CONFIG_EEPROM_93CX6 is not set
497
498#
483# SCSI device support 499# SCSI device support
484# 500#
485# CONFIG_RAID_ATTRS is not set 501# CONFIG_RAID_ATTRS is not set
@@ -520,6 +536,7 @@ CONFIG_SCSI_FC_ATTRS=y
520# CONFIG_SCSI_SRP_ATTRS is not set 536# CONFIG_SCSI_SRP_ATTRS is not set
521CONFIG_SCSI_LOWLEVEL=y 537CONFIG_SCSI_LOWLEVEL=y
522# CONFIG_ISCSI_TCP is not set 538# CONFIG_ISCSI_TCP is not set
539# CONFIG_LIBFC is not set
523# CONFIG_SCSI_DEBUG is not set 540# CONFIG_SCSI_DEBUG is not set
524CONFIG_ZFCP=y 541CONFIG_ZFCP=y
525CONFIG_SCSI_DH=m 542CONFIG_SCSI_DH=m
@@ -566,6 +583,10 @@ CONFIG_NET_ETHERNET=y
566CONFIG_NETDEV_1000=y 583CONFIG_NETDEV_1000=y
567CONFIG_NETDEV_10000=y 584CONFIG_NETDEV_10000=y
568# CONFIG_TR is not set 585# CONFIG_TR is not set
586
587#
588# Enable WiMAX (Networking options) to see the WiMAX drivers
589#
569# CONFIG_WAN is not set 590# CONFIG_WAN is not set
570 591
571# 592#
@@ -593,9 +614,11 @@ CONFIG_VIRTIO_NET=m
593# 614#
594CONFIG_DEVKMEM=y 615CONFIG_DEVKMEM=y
595CONFIG_UNIX98_PTYS=y 616CONFIG_UNIX98_PTYS=y
617# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
596CONFIG_LEGACY_PTYS=y 618CONFIG_LEGACY_PTYS=y
597CONFIG_LEGACY_PTY_COUNT=256 619CONFIG_LEGACY_PTY_COUNT=256
598CONFIG_HVC_DRIVER=y 620CONFIG_HVC_DRIVER=y
621CONFIG_HVC_IUCV=y
599CONFIG_VIRTIO_CONSOLE=y 622CONFIG_VIRTIO_CONSOLE=y
600CONFIG_HW_RANDOM=m 623CONFIG_HW_RANDOM=m
601CONFIG_HW_RANDOM_VIRTIO=m 624CONFIG_HW_RANDOM_VIRTIO=m
@@ -645,7 +668,6 @@ CONFIG_S390_VMUR=m
645# CONFIG_NEW_LEDS is not set 668# CONFIG_NEW_LEDS is not set
646CONFIG_ACCESSIBILITY=y 669CONFIG_ACCESSIBILITY=y
647# CONFIG_STAGING is not set 670# CONFIG_STAGING is not set
648CONFIG_STAGING_EXCLUDE_BUILD=y
649 671
650# 672#
651# File systems 673# File systems
@@ -668,6 +690,7 @@ CONFIG_FILE_LOCKING=y
668# CONFIG_XFS_FS is not set 690# CONFIG_XFS_FS is not set
669# CONFIG_GFS2_FS is not set 691# CONFIG_GFS2_FS is not set
670# CONFIG_OCFS2_FS is not set 692# CONFIG_OCFS2_FS is not set
693# CONFIG_BTRFS_FS is not set
671CONFIG_DNOTIFY=y 694CONFIG_DNOTIFY=y
672CONFIG_INOTIFY=y 695CONFIG_INOTIFY=y
673CONFIG_INOTIFY_USER=y 696CONFIG_INOTIFY_USER=y
@@ -703,10 +726,7 @@ CONFIG_TMPFS_POSIX_ACL=y
703# CONFIG_HUGETLBFS is not set 726# CONFIG_HUGETLBFS is not set
704# CONFIG_HUGETLB_PAGE is not set 727# CONFIG_HUGETLB_PAGE is not set
705CONFIG_CONFIGFS_FS=m 728CONFIG_CONFIGFS_FS=m
706 729CONFIG_MISC_FILESYSTEMS=y
707#
708# Miscellaneous filesystems
709#
710# CONFIG_ADFS_FS is not set 730# CONFIG_ADFS_FS is not set
711# CONFIG_AFFS_FS is not set 731# CONFIG_AFFS_FS is not set
712# CONFIG_HFS_FS is not set 732# CONFIG_HFS_FS is not set
@@ -715,6 +735,7 @@ CONFIG_CONFIGFS_FS=m
715# CONFIG_BFS_FS is not set 735# CONFIG_BFS_FS is not set
716# CONFIG_EFS_FS is not set 736# CONFIG_EFS_FS is not set
717# CONFIG_CRAMFS is not set 737# CONFIG_CRAMFS is not set
738# CONFIG_SQUASHFS is not set
718# CONFIG_VXFS_FS is not set 739# CONFIG_VXFS_FS is not set
719# CONFIG_MINIX_FS is not set 740# CONFIG_MINIX_FS is not set
720# CONFIG_OMFS_FS is not set 741# CONFIG_OMFS_FS is not set
@@ -808,6 +829,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
808CONFIG_DEBUG_MEMORY_INIT=y 829CONFIG_DEBUG_MEMORY_INIT=y
809# CONFIG_DEBUG_LIST is not set 830# CONFIG_DEBUG_LIST is not set
810# CONFIG_DEBUG_SG is not set 831# CONFIG_DEBUG_SG is not set
832# CONFIG_DEBUG_NOTIFIERS is not set
811# CONFIG_FRAME_POINTER is not set 833# CONFIG_FRAME_POINTER is not set
812# CONFIG_RCU_TORTURE_TEST is not set 834# CONFIG_RCU_TORTURE_TEST is not set
813# CONFIG_RCU_CPU_STALL_DETECTOR is not set 835# CONFIG_RCU_CPU_STALL_DETECTOR is not set
@@ -818,15 +840,19 @@ CONFIG_DEBUG_MEMORY_INIT=y
818# CONFIG_FAULT_INJECTION is not set 840# CONFIG_FAULT_INJECTION is not set
819# CONFIG_LATENCYTOP is not set 841# CONFIG_LATENCYTOP is not set
820CONFIG_SYSCTL_SYSCALL_CHECK=y 842CONFIG_SYSCTL_SYSCALL_CHECK=y
843CONFIG_HAVE_FUNCTION_TRACER=y
821 844
822# 845#
823# Tracers 846# Tracers
824# 847#
848# CONFIG_FUNCTION_TRACER is not set
825# CONFIG_IRQSOFF_TRACER is not set 849# CONFIG_IRQSOFF_TRACER is not set
826# CONFIG_PREEMPT_TRACER is not set 850# CONFIG_PREEMPT_TRACER is not set
827# CONFIG_SCHED_TRACER is not set 851# CONFIG_SCHED_TRACER is not set
828# CONFIG_CONTEXT_SWITCH_TRACER is not set 852# CONFIG_CONTEXT_SWITCH_TRACER is not set
829# CONFIG_BOOT_TRACER is not set 853# CONFIG_BOOT_TRACER is not set
854# CONFIG_TRACE_BRANCH_PROFILING is not set
855# CONFIG_STACK_TRACER is not set
830# CONFIG_DYNAMIC_PRINTK_DEBUG is not set 856# CONFIG_DYNAMIC_PRINTK_DEBUG is not set
831CONFIG_SAMPLES=y 857CONFIG_SAMPLES=y
832# CONFIG_SAMPLE_KOBJECT is not set 858# CONFIG_SAMPLE_KOBJECT is not set
@@ -847,11 +873,17 @@ CONFIG_CRYPTO=y
847# 873#
848CONFIG_CRYPTO_FIPS=y 874CONFIG_CRYPTO_FIPS=y
849CONFIG_CRYPTO_ALGAPI=y 875CONFIG_CRYPTO_ALGAPI=y
850CONFIG_CRYPTO_AEAD=y 876CONFIG_CRYPTO_ALGAPI2=y
877CONFIG_CRYPTO_AEAD=m
878CONFIG_CRYPTO_AEAD2=y
851CONFIG_CRYPTO_BLKCIPHER=y 879CONFIG_CRYPTO_BLKCIPHER=y
852CONFIG_CRYPTO_HASH=y 880CONFIG_CRYPTO_BLKCIPHER2=y
853CONFIG_CRYPTO_RNG=y 881CONFIG_CRYPTO_HASH=m
882CONFIG_CRYPTO_HASH2=y
883CONFIG_CRYPTO_RNG=m
884CONFIG_CRYPTO_RNG2=y
854CONFIG_CRYPTO_MANAGER=y 885CONFIG_CRYPTO_MANAGER=y
886CONFIG_CRYPTO_MANAGER2=y
855CONFIG_CRYPTO_GF128MUL=m 887CONFIG_CRYPTO_GF128MUL=m
856# CONFIG_CRYPTO_NULL is not set 888# CONFIG_CRYPTO_NULL is not set
857# CONFIG_CRYPTO_CRYPTD is not set 889# CONFIG_CRYPTO_CRYPTD is not set
@@ -885,7 +917,7 @@ CONFIG_CRYPTO_HMAC=m
885# 917#
886# Digest 918# Digest
887# 919#
888# CONFIG_CRYPTO_CRC32C is not set 920CONFIG_CRYPTO_CRC32C=m
889# CONFIG_CRYPTO_MD4 is not set 921# CONFIG_CRYPTO_MD4 is not set
890CONFIG_CRYPTO_MD5=m 922CONFIG_CRYPTO_MD5=m
891# CONFIG_CRYPTO_MICHAEL_MIC is not set 923# CONFIG_CRYPTO_MICHAEL_MIC is not set
@@ -942,6 +974,7 @@ CONFIG_S390_PRNG=m
942# Library routines 974# Library routines
943# 975#
944CONFIG_BITREVERSE=m 976CONFIG_BITREVERSE=m
977CONFIG_GENERIC_FIND_LAST_BIT=y
945# CONFIG_CRC_CCITT is not set 978# CONFIG_CRC_CCITT is not set
946# CONFIG_CRC16 is not set 979# CONFIG_CRC16 is not set
947CONFIG_CRC_T10DIF=y 980CONFIG_CRC_T10DIF=y
diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcore.h
index ffdef5fe858..f3720defdd1 100644
--- a/arch/s390/include/asm/lowcore.h
+++ b/arch/s390/include/asm/lowcore.h
@@ -384,8 +384,8 @@ struct _lowcore
384 __u32 panic_magic; /* 0xe00 */ 384 __u32 panic_magic; /* 0xe00 */
385 385
386 /* Per cpu primary space access list */ 386 /* Per cpu primary space access list */
387 __u8 pad_0xe04[0xe3c-0xe04]; /* 0xe04 */ 387 __u8 pad_0xe04[0xe38-0xe04]; /* 0xe04 */
388 __u32 vdso_per_cpu_data; /* 0xe3c */ 388 __u64 vdso_per_cpu_data; /* 0xe38 */
389 __u32 paste[16]; /* 0xe40 */ 389 __u32 paste[16]; /* 0xe40 */
390 390
391 __u8 pad13[0x11b8-0xe80]; /* 0xe80 */ 391 __u8 pad13[0x11b8-0xe80]; /* 0xe80 */
diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index e7c5bfb7c75..026a37a94fc 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -95,6 +95,7 @@ asmlinkage void do_softirq(void)
95 local_irq_restore(flags); 95 local_irq_restore(flags);
96} 96}
97 97
98#ifdef CONFIG_PROC_FS
98void init_irq_proc(void) 99void init_irq_proc(void)
99{ 100{
100 struct proc_dir_entry *root_irq_dir; 101 struct proc_dir_entry *root_irq_dir;
@@ -102,3 +103,4 @@ void init_irq_proc(void)
102 root_irq_dir = proc_mkdir("irq", NULL); 103 root_irq_dir = proc_mkdir("irq", NULL);
103 create_prof_cpu_mask(root_irq_dir); 104 create_prof_cpu_mask(root_irq_dir);
104} 105}
106#endif
diff --git a/arch/sparc/kernel/head_64.S b/arch/sparc/kernel/head_64.S
index 8ffee714f93..a46c3a21e26 100644
--- a/arch/sparc/kernel/head_64.S
+++ b/arch/sparc/kernel/head_64.S
@@ -891,10 +891,35 @@ prom_tba: .xword 0
891tlb_type: .word 0 /* Must NOT end up in BSS */ 891tlb_type: .word 0 /* Must NOT end up in BSS */
892 .section ".fixup",#alloc,#execinstr 892 .section ".fixup",#alloc,#execinstr
893 893
894 .globl __ret_efault, __retl_efault 894 .globl __ret_efault, __retl_efault, __ret_one, __retl_one
895__ret_efault: 895ENTRY(__ret_efault)
896 ret 896 ret
897 restore %g0, -EFAULT, %o0 897 restore %g0, -EFAULT, %o0
898__retl_efault: 898ENDPROC(__ret_efault)
899
900ENTRY(__retl_efault)
899 retl 901 retl
900 mov -EFAULT, %o0 902 mov -EFAULT, %o0
903ENDPROC(__retl_efault)
904
905ENTRY(__retl_one)
906 retl
907 mov 1, %o0
908ENDPROC(__retl_one)
909
910ENTRY(__ret_one_asi)
911 wr %g0, ASI_AIUS, %asi
912 ret
913 restore %g0, 1, %o0
914ENDPROC(__ret_one_asi)
915
916ENTRY(__retl_one_asi)
917 wr %g0, ASI_AIUS, %asi
918 retl
919 mov 1, %o0
920ENDPROC(__retl_one_asi)
921
922ENTRY(__retl_o1)
923 retl
924 mov %o1, %o0
925ENDPROC(__retl_o1)
diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c
index 09f088ed4a6..f3577223c86 100644
--- a/arch/sparc/kernel/nmi.c
+++ b/arch/sparc/kernel/nmi.c
@@ -70,6 +70,7 @@ static void die_nmi(const char *str, struct pt_regs *regs, int do_panic)
70 printk(" on CPU%d, ip %08lx, registers:\n", 70 printk(" on CPU%d, ip %08lx, registers:\n",
71 smp_processor_id(), regs->tpc); 71 smp_processor_id(), regs->tpc);
72 show_regs(regs); 72 show_regs(regs);
73 dump_stack();
73 74
74 bust_spinlocks(0); 75 bust_spinlocks(0);
75 76
diff --git a/arch/sparc/kernel/pcr.c b/arch/sparc/kernel/pcr.c
index 92e0dda141a..1ae8cdd7e70 100644
--- a/arch/sparc/kernel/pcr.c
+++ b/arch/sparc/kernel/pcr.c
@@ -133,11 +133,16 @@ int __init pcr_arch_init(void)
133 133
134 case cheetah: 134 case cheetah:
135 case cheetah_plus: 135 case cheetah_plus:
136 case spitfire:
137 pcr_ops = &direct_pcr_ops; 136 pcr_ops = &direct_pcr_ops;
138 pcr_enable = PCR_SUN4U_ENABLE; 137 pcr_enable = PCR_SUN4U_ENABLE;
139 break; 138 break;
140 139
140 case spitfire:
141 /* UltraSPARC-I/II and derivatives lack a profile
142 * counter overflow interrupt so we can't make use of
143 * their hardware currently.
144 */
145 /* fallthrough */
141 default: 146 default:
142 err = -ENODEV; 147 err = -ENODEV;
143 goto out_unregister; 148 goto out_unregister;
diff --git a/arch/sparc/lib/GENbzero.S b/arch/sparc/lib/GENbzero.S
index 6a4f956a2f7..8e7a843ddd8 100644
--- a/arch/sparc/lib/GENbzero.S
+++ b/arch/sparc/lib/GENbzero.S
@@ -6,13 +6,9 @@
6 6
7#define EX_ST(x,y) \ 7#define EX_ST(x,y) \
898: x,y; \ 898: x,y; \
9 .section .fixup; \
10 .align 4; \
1199: retl; \
12 mov %o1, %o0; \
13 .section __ex_table,"a";\ 9 .section __ex_table,"a";\
14 .align 4; \ 10 .align 4; \
15 .word 98b, 99b; \ 11 .word 98b, __retl_o1; \
16 .text; \ 12 .text; \
17 .align 4; 13 .align 4;
18 14
diff --git a/arch/sparc/lib/GENcopy_from_user.S b/arch/sparc/lib/GENcopy_from_user.S
index 2b9df99e87f..b7d0bd6b140 100644
--- a/arch/sparc/lib/GENcopy_from_user.S
+++ b/arch/sparc/lib/GENcopy_from_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_LD(x) \ 6#define EX_LD(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
@@ -27,7 +23,7 @@
27#define PREAMBLE \ 23#define PREAMBLE \
28 rd %asi, %g1; \ 24 rd %asi, %g1; \
29 cmp %g1, ASI_AIUS; \ 25 cmp %g1, ASI_AIUS; \
30 bne,pn %icc, memcpy_user_stub; \ 26 bne,pn %icc, ___copy_in_user; \
31 nop 27 nop
32#endif 28#endif
33 29
diff --git a/arch/sparc/lib/GENcopy_to_user.S b/arch/sparc/lib/GENcopy_to_user.S
index bb3f7084daf..780550e1afc 100644
--- a/arch/sparc/lib/GENcopy_to_user.S
+++ b/arch/sparc/lib/GENcopy_to_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_ST(x) \ 6#define EX_ST(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
@@ -31,7 +27,7 @@
31#define PREAMBLE \ 27#define PREAMBLE \
32 rd %asi, %g1; \ 28 rd %asi, %g1; \
33 cmp %g1, ASI_AIUS; \ 29 cmp %g1, ASI_AIUS; \
34 bne,pn %icc, memcpy_user_stub; \ 30 bne,pn %icc, ___copy_in_user; \
35 nop 31 nop
36#endif 32#endif
37 33
diff --git a/arch/sparc/lib/NG2copy_from_user.S b/arch/sparc/lib/NG2copy_from_user.S
index c77ef5f2210..119ccb9a54f 100644
--- a/arch/sparc/lib/NG2copy_from_user.S
+++ b/arch/sparc/lib/NG2copy_from_user.S
@@ -5,14 +5,9 @@
5 5
6#define EX_LD(x) \ 6#define EX_LD(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: wr %g0, ASI_AIUS, %asi;\
11 retl; \
12 mov 1, %o0; \
13 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
14 .align 4; \ 9 .align 4; \
15 .word 98b, 99b; \ 10 .word 98b, __retl_one_asi;\
16 .text; \ 11 .text; \
17 .align 4; 12 .align 4;
18 13
@@ -33,7 +28,7 @@
33#define PREAMBLE \ 28#define PREAMBLE \
34 rd %asi, %g1; \ 29 rd %asi, %g1; \
35 cmp %g1, ASI_AIUS; \ 30 cmp %g1, ASI_AIUS; \
36 bne,pn %icc, memcpy_user_stub; \ 31 bne,pn %icc, ___copy_in_user; \
37 nop 32 nop
38#endif 33#endif
39 34
diff --git a/arch/sparc/lib/NG2copy_to_user.S b/arch/sparc/lib/NG2copy_to_user.S
index 4bd4093acbb..7fe1ccefd9d 100644
--- a/arch/sparc/lib/NG2copy_to_user.S
+++ b/arch/sparc/lib/NG2copy_to_user.S
@@ -5,14 +5,9 @@
5 5
6#define EX_ST(x) \ 6#define EX_ST(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: wr %g0, ASI_AIUS, %asi;\
11 retl; \
12 mov 1, %o0; \
13 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
14 .align 4; \ 9 .align 4; \
15 .word 98b, 99b; \ 10 .word 98b, __retl_one_asi;\
16 .text; \ 11 .text; \
17 .align 4; 12 .align 4;
18 13
@@ -42,7 +37,7 @@
42#define PREAMBLE \ 37#define PREAMBLE \
43 rd %asi, %g1; \ 38 rd %asi, %g1; \
44 cmp %g1, ASI_AIUS; \ 39 cmp %g1, ASI_AIUS; \
45 bne,pn %icc, memcpy_user_stub; \ 40 bne,pn %icc, ___copy_in_user; \
46 nop 41 nop
47#endif 42#endif
48 43
diff --git a/arch/sparc/lib/NGbzero.S b/arch/sparc/lib/NGbzero.S
index 814d5f7a45e..beab29bf419 100644
--- a/arch/sparc/lib/NGbzero.S
+++ b/arch/sparc/lib/NGbzero.S
@@ -6,13 +6,9 @@
6 6
7#define EX_ST(x,y) \ 7#define EX_ST(x,y) \
898: x,y; \ 898: x,y; \
9 .section .fixup; \
10 .align 4; \
1199: retl; \
12 mov %o1, %o0; \
13 .section __ex_table,"a";\ 9 .section __ex_table,"a";\
14 .align 4; \ 10 .align 4; \
15 .word 98b, 99b; \ 11 .word 98b, __retl_o1; \
16 .text; \ 12 .text; \
17 .align 4; 13 .align 4;
18 14
diff --git a/arch/sparc/lib/NGcopy_from_user.S b/arch/sparc/lib/NGcopy_from_user.S
index e7f433f71b4..5d1e4d1ac21 100644
--- a/arch/sparc/lib/NGcopy_from_user.S
+++ b/arch/sparc/lib/NGcopy_from_user.S
@@ -5,14 +5,9 @@
5 5
6#define EX_LD(x) \ 6#define EX_LD(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: wr %g0, ASI_AIUS, %asi;\
11 ret; \
12 restore %g0, 1, %o0; \
13 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
14 .align 4; \ 9 .align 4; \
15 .word 98b, 99b; \ 10 .word 98b, __ret_one_asi;\
16 .text; \ 11 .text; \
17 .align 4; 12 .align 4;
18 13
@@ -30,7 +25,7 @@
30#define PREAMBLE \ 25#define PREAMBLE \
31 rd %asi, %g1; \ 26 rd %asi, %g1; \
32 cmp %g1, ASI_AIUS; \ 27 cmp %g1, ASI_AIUS; \
33 bne,pn %icc, memcpy_user_stub; \ 28 bne,pn %icc, ___copy_in_user; \
34 nop 29 nop
35#endif 30#endif
36 31
diff --git a/arch/sparc/lib/NGcopy_to_user.S b/arch/sparc/lib/NGcopy_to_user.S
index 6ea01c5532a..ff630dcb273 100644
--- a/arch/sparc/lib/NGcopy_to_user.S
+++ b/arch/sparc/lib/NGcopy_to_user.S
@@ -5,14 +5,9 @@
5 5
6#define EX_ST(x) \ 6#define EX_ST(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: wr %g0, ASI_AIUS, %asi;\
11 ret; \
12 restore %g0, 1, %o0; \
13 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
14 .align 4; \ 9 .align 4; \
15 .word 98b, 99b; \ 10 .word 98b, __ret_one_asi;\
16 .text; \ 11 .text; \
17 .align 4; 12 .align 4;
18 13
@@ -33,7 +28,7 @@
33#define PREAMBLE \ 28#define PREAMBLE \
34 rd %asi, %g1; \ 29 rd %asi, %g1; \
35 cmp %g1, ASI_AIUS; \ 30 cmp %g1, ASI_AIUS; \
36 bne,pn %icc, memcpy_user_stub; \ 31 bne,pn %icc, ___copy_in_user; \
37 nop 32 nop
38#endif 33#endif
39 34
diff --git a/arch/sparc/lib/U1copy_from_user.S b/arch/sparc/lib/U1copy_from_user.S
index 3192b0bf4fa..a6ae2ea04bf 100644
--- a/arch/sparc/lib/U1copy_from_user.S
+++ b/arch/sparc/lib/U1copy_from_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_LD(x) \ 6#define EX_LD(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
@@ -27,7 +23,7 @@
27#define PREAMBLE \ 23#define PREAMBLE \
28 rd %asi, %g1; \ 24 rd %asi, %g1; \
29 cmp %g1, ASI_AIUS; \ 25 cmp %g1, ASI_AIUS; \
30 bne,pn %icc, memcpy_user_stub; \ 26 bne,pn %icc, ___copy_in_user; \
31 nop; \ 27 nop; \
32 28
33#include "U1memcpy.S" 29#include "U1memcpy.S"
diff --git a/arch/sparc/lib/U1copy_to_user.S b/arch/sparc/lib/U1copy_to_user.S
index d1210ffb0b8..f4b970eeb48 100644
--- a/arch/sparc/lib/U1copy_to_user.S
+++ b/arch/sparc/lib/U1copy_to_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_ST(x) \ 6#define EX_ST(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
@@ -27,7 +23,7 @@
27#define PREAMBLE \ 23#define PREAMBLE \
28 rd %asi, %g1; \ 24 rd %asi, %g1; \
29 cmp %g1, ASI_AIUS; \ 25 cmp %g1, ASI_AIUS; \
30 bne,pn %icc, memcpy_user_stub; \ 26 bne,pn %icc, ___copy_in_user; \
31 nop; \ 27 nop; \
32 28
33#include "U1memcpy.S" 29#include "U1memcpy.S"
diff --git a/arch/sparc/lib/U3copy_from_user.S b/arch/sparc/lib/U3copy_from_user.S
index f5bfc8d9d21..b1acd1331c3 100644
--- a/arch/sparc/lib/U3copy_from_user.S
+++ b/arch/sparc/lib/U3copy_from_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_LD(x) \ 6#define EX_LD(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
diff --git a/arch/sparc/lib/U3copy_to_user.S b/arch/sparc/lib/U3copy_to_user.S
index 2334f111bb0..ef1e493afdf 100644
--- a/arch/sparc/lib/U3copy_to_user.S
+++ b/arch/sparc/lib/U3copy_to_user.S
@@ -5,13 +5,9 @@
5 5
6#define EX_ST(x) \ 6#define EX_ST(x) \
798: x; \ 798: x; \
8 .section .fixup; \
9 .align 4; \
1099: retl; \
11 mov 1, %o0; \
12 .section __ex_table,"a";\ 8 .section __ex_table,"a";\
13 .align 4; \ 9 .align 4; \
14 .word 98b, 99b; \ 10 .word 98b, __retl_one; \
15 .text; \ 11 .text; \
16 .align 4; 12 .align 4;
17 13
@@ -27,7 +23,7 @@
27#define PREAMBLE \ 23#define PREAMBLE \
28 rd %asi, %g1; \ 24 rd %asi, %g1; \
29 cmp %g1, ASI_AIUS; \ 25 cmp %g1, ASI_AIUS; \
30 bne,pn %icc, memcpy_user_stub; \ 26 bne,pn %icc, ___copy_in_user; \
31 nop; \ 27 nop; \
32 28
33#include "U3memcpy.S" 29#include "U3memcpy.S"
diff --git a/arch/sparc/lib/bzero.S b/arch/sparc/lib/bzero.S
index c7bbae8c590..b6557297440 100644
--- a/arch/sparc/lib/bzero.S
+++ b/arch/sparc/lib/bzero.S
@@ -88,13 +88,9 @@ __bzero_done:
88 88
89#define EX_ST(x,y) \ 89#define EX_ST(x,y) \
9098: x,y; \ 9098: x,y; \
91 .section .fixup; \
92 .align 4; \
9399: retl; \
94 mov %o1, %o0; \
95 .section __ex_table,"a";\ 91 .section __ex_table,"a";\
96 .align 4; \ 92 .align 4; \
97 .word 98b, 99b; \ 93 .word 98b, __retl_o1; \
98 .text; \ 94 .text; \
99 .align 4; 95 .align 4;
100 96
diff --git a/arch/sparc/lib/copy_in_user.S b/arch/sparc/lib/copy_in_user.S
index 650af3f21f7..302c0e60dc2 100644
--- a/arch/sparc/lib/copy_in_user.S
+++ b/arch/sparc/lib/copy_in_user.S
@@ -3,19 +3,16 @@
3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com) 3 * Copyright (C) 1999, 2000, 2004 David S. Miller (davem@redhat.com)
4 */ 4 */
5 5
6#include <linux/linkage.h>
6#include <asm/asi.h> 7#include <asm/asi.h>
7 8
8#define XCC xcc 9#define XCC xcc
9 10
10#define EX(x,y) \ 11#define EX(x,y) \
1198: x,y; \ 1298: x,y; \
12 .section .fixup; \
13 .align 4; \
1499: retl; \
15 mov 1, %o0; \
16 .section __ex_table,"a";\ 13 .section __ex_table,"a";\
17 .align 4; \ 14 .align 4; \
18 .word 98b, 99b; \ 15 .word 98b, __retl_one; \
19 .text; \ 16 .text; \
20 .align 4; 17 .align 4;
21 18
@@ -31,18 +28,7 @@
31 * to copy register windows around during thread cloning. 28 * to copy register windows around during thread cloning.
32 */ 29 */
33 30
34 .globl ___copy_in_user 31ENTRY(___copy_in_user) /* %o0=dst, %o1=src, %o2=len */
35 .type ___copy_in_user,#function
36___copy_in_user: /* %o0=dst, %o1=src, %o2=len */
37 /* Writing to %asi is _expensive_ so we hardcode it.
38 * Reading %asi to check for KERNEL_DS is comparatively
39 * cheap.
40 */
41 rd %asi, %g1
42 cmp %g1, ASI_AIUS
43 bne,pn %icc, memcpy_user_stub
44 nop
45
46 cmp %o2, 0 32 cmp %o2, 0
47 be,pn %XCC, 85f 33 be,pn %XCC, 85f
48 or %o0, %o1, %o3 34 or %o0, %o1, %o3
@@ -53,22 +39,24 @@ ___copy_in_user: /* %o0=dst, %o1=src, %o2=len */
53 /* 16 < len <= 64 */ 39 /* 16 < len <= 64 */
54 andcc %o3, 0x7, %g0 40 andcc %o3, 0x7, %g0
55 bne,pn %XCC, 90f 41 bne,pn %XCC, 90f
56 sub %o0, %o1, %o3 42 nop
57 43
58 andn %o2, 0x7, %o4 44 andn %o2, 0x7, %o4
59 and %o2, 0x7, %o2 45 and %o2, 0x7, %o2
601: subcc %o4, 0x8, %o4 461: subcc %o4, 0x8, %o4
61 EX(ldxa [%o1] %asi, %o5) 47 EX(ldxa [%o1] %asi, %o5)
62 EX(stxa %o5, [%o1 + %o3] ASI_AIUS) 48 EX(stxa %o5, [%o0] %asi)
49 add %o1, 0x8, %o1
63 bgu,pt %XCC, 1b 50 bgu,pt %XCC, 1b
64 add %o1, 0x8, %o1 51 add %o0, 0x8, %o0
65 andcc %o2, 0x4, %g0 52 andcc %o2, 0x4, %g0
66 be,pt %XCC, 1f 53 be,pt %XCC, 1f
67 nop 54 nop
68 sub %o2, 0x4, %o2 55 sub %o2, 0x4, %o2
69 EX(lduwa [%o1] %asi, %o5) 56 EX(lduwa [%o1] %asi, %o5)
70 EX(stwa %o5, [%o1 + %o3] ASI_AIUS) 57 EX(stwa %o5, [%o0] %asi)
71 add %o1, 0x4, %o1 58 add %o1, 0x4, %o1
59 add %o0, 0x4, %o0
721: cmp %o2, 0 601: cmp %o2, 0
73 be,pt %XCC, 85f 61 be,pt %XCC, 85f
74 nop 62 nop
@@ -78,14 +66,15 @@ ___copy_in_user: /* %o0=dst, %o1=src, %o2=len */
7880: /* 0 < len <= 16 */ 6680: /* 0 < len <= 16 */
79 andcc %o3, 0x3, %g0 67 andcc %o3, 0x3, %g0
80 bne,pn %XCC, 90f 68 bne,pn %XCC, 90f
81 sub %o0, %o1, %o3 69 nop
82 70
8382: 7182:
84 subcc %o2, 4, %o2 72 subcc %o2, 4, %o2
85 EX(lduwa [%o1] %asi, %g1) 73 EX(lduwa [%o1] %asi, %g1)
86 EX(stwa %g1, [%o1 + %o3] ASI_AIUS) 74 EX(stwa %g1, [%o0] %asi)
75 add %o1, 4, %o1
87 bgu,pt %XCC, 82b 76 bgu,pt %XCC, 82b
88 add %o1, 4, %o1 77 add %o0, 4, %o0
89 78
9085: retl 7985: retl
91 clr %o0 80 clr %o0
@@ -94,26 +83,10 @@ ___copy_in_user: /* %o0=dst, %o1=src, %o2=len */
9490: 8390:
95 subcc %o2, 1, %o2 84 subcc %o2, 1, %o2
96 EX(lduba [%o1] %asi, %g1) 85 EX(lduba [%o1] %asi, %g1)
97 EX(stba %g1, [%o1 + %o3] ASI_AIUS) 86 EX(stba %g1, [%o0] %asi)
87 add %o1, 1, %o1
98 bgu,pt %XCC, 90b 88 bgu,pt %XCC, 90b
99 add %o1, 1, %o1 89 add %o0, 1, %o0
100 retl 90 retl
101 clr %o0 91 clr %o0
102 92ENDPROC(___copy_in_user)
103 .size ___copy_in_user, .-___copy_in_user
104
105 /* Act like copy_{to,in}_user(), ie. return zero instead
106 * of original destination pointer. This is invoked when
107 * copy_{to,in}_user() finds that %asi is kernel space.
108 */
109 .globl memcpy_user_stub
110 .type memcpy_user_stub,#function
111memcpy_user_stub:
112 save %sp, -192, %sp
113 mov %i0, %o0
114 mov %i1, %o1
115 call memcpy
116 mov %i2, %o2
117 ret
118 restore %g0, %g0, %o0
119 .size memcpy_user_stub, .-memcpy_user_stub
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f760a22f95d..1042d69b267 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -5,7 +5,7 @@ mainmenu "Linux Kernel Configuration for x86"
5config 64BIT 5config 64BIT
6 bool "64-bit kernel" if ARCH = "x86" 6 bool "64-bit kernel" if ARCH = "x86"
7 default ARCH = "x86_64" 7 default ARCH = "x86_64"
8 help 8 ---help---
9 Say yes to build a 64-bit kernel - formerly known as x86_64 9 Say yes to build a 64-bit kernel - formerly known as x86_64
10 Say no to build a 32-bit kernel - formerly known as i386 10 Say no to build a 32-bit kernel - formerly known as i386
11 11
@@ -34,8 +34,8 @@ config X86
34 select HAVE_FUNCTION_TRACER 34 select HAVE_FUNCTION_TRACER
35 select HAVE_FUNCTION_GRAPH_TRACER 35 select HAVE_FUNCTION_GRAPH_TRACER
36 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 36 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
37 select HAVE_KVM if ((X86_32 && !X86_VOYAGER && !X86_VISWS && !X86_NUMAQ) || X86_64) 37 select HAVE_KVM
38 select HAVE_ARCH_KGDB if !X86_VOYAGER 38 select HAVE_ARCH_KGDB
39 select HAVE_ARCH_TRACEHOOK 39 select HAVE_ARCH_TRACEHOOK
40 select HAVE_GENERIC_DMA_COHERENT if X86_32 40 select HAVE_GENERIC_DMA_COHERENT if X86_32
41 select HAVE_EFFICIENT_UNALIGNED_ACCESS 41 select HAVE_EFFICIENT_UNALIGNED_ACCESS
@@ -140,11 +140,9 @@ config HAVE_CPUMASK_OF_CPU_MAP
140 140
141config ARCH_HIBERNATION_POSSIBLE 141config ARCH_HIBERNATION_POSSIBLE
142 def_bool y 142 def_bool y
143 depends on !SMP || !X86_VOYAGER
144 143
145config ARCH_SUSPEND_POSSIBLE 144config ARCH_SUSPEND_POSSIBLE
146 def_bool y 145 def_bool y
147 depends on !X86_VOYAGER
148 146
149config ZONE_DMA32 147config ZONE_DMA32
150 bool 148 bool
@@ -174,11 +172,6 @@ config GENERIC_PENDING_IRQ
174 depends on GENERIC_HARDIRQS && SMP 172 depends on GENERIC_HARDIRQS && SMP
175 default y 173 default y
176 174
177config X86_SMP
178 bool
179 depends on SMP && ((X86_32 && !X86_VOYAGER) || X86_64)
180 default y
181
182config USE_GENERIC_SMP_HELPERS 175config USE_GENERIC_SMP_HELPERS
183 def_bool y 176 def_bool y
184 depends on SMP 177 depends on SMP
@@ -194,17 +187,11 @@ config X86_64_SMP
194config X86_HT 187config X86_HT
195 bool 188 bool
196 depends on SMP 189 depends on SMP
197 depends on (X86_32 && !X86_VOYAGER) || X86_64
198 default y
199
200config X86_BIOS_REBOOT
201 bool
202 depends on !X86_VOYAGER
203 default y 190 default y
204 191
205config X86_TRAMPOLINE 192config X86_TRAMPOLINE
206 bool 193 bool
207 depends on X86_SMP || (X86_VOYAGER && SMP) || (64BIT && ACPI_SLEEP) 194 depends on SMP || (64BIT && ACPI_SLEEP)
208 default y 195 default y
209 196
210config X86_32_LAZY_GS 197config X86_32_LAZY_GS
@@ -248,14 +235,10 @@ config SMP
248 235
249 If you don't know what to do here, say N. 236 If you don't know what to do here, say N.
250 237
251config X86_HAS_BOOT_CPU_ID
252 def_bool y
253 depends on X86_VOYAGER
254
255config SPARSE_IRQ 238config SPARSE_IRQ
256 bool "Support sparse irq numbering" 239 bool "Support sparse irq numbering"
257 depends on PCI_MSI || HT_IRQ 240 depends on PCI_MSI || HT_IRQ
258 help 241 ---help---
259 This enables support for sparse irqs. This is useful for distro 242 This enables support for sparse irqs. This is useful for distro
260 kernels that want to define a high CONFIG_NR_CPUS value but still 243 kernels that want to define a high CONFIG_NR_CPUS value but still
261 want to have low kernel memory footprint on smaller machines. 244 want to have low kernel memory footprint on smaller machines.
@@ -269,114 +252,114 @@ config NUMA_MIGRATE_IRQ_DESC
269 bool "Move irq desc when changing irq smp_affinity" 252 bool "Move irq desc when changing irq smp_affinity"
270 depends on SPARSE_IRQ && NUMA 253 depends on SPARSE_IRQ && NUMA
271 default n 254 default n
272 help 255 ---help---
273 This enables moving irq_desc to cpu/node that irq will use handled. 256 This enables moving irq_desc to cpu/node that irq will use handled.
274 257
275 If you don't know what to do here, say N. 258 If you don't know what to do here, say N.
276 259
277config X86_FIND_SMP_CONFIG
278 def_bool y
279 depends on X86_MPPARSE || X86_VOYAGER
280
281config X86_MPPARSE 260config X86_MPPARSE
282 bool "Enable MPS table" if ACPI 261 bool "Enable MPS table" if ACPI
283 default y 262 default y
284 depends on X86_LOCAL_APIC 263 depends on X86_LOCAL_APIC
285 help 264 ---help---
286 For old smp systems that do not have proper acpi support. Newer systems 265 For old smp systems that do not have proper acpi support. Newer systems
287 (esp with 64bit cpus) with acpi support, MADT and DSDT will override it 266 (esp with 64bit cpus) with acpi support, MADT and DSDT will override it
288 267
289choice 268config X86_BIGSMP
290 prompt "Subarchitecture Type" 269 bool "Support for big SMP systems with more than 8 CPUs"
291 default X86_PC 270 depends on X86_32 && SMP
271 ---help---
272 This option is needed for the systems that have more than 8 CPUs
292 273
293config X86_PC 274config X86_EXTENDED_PLATFORM
294 bool "PC-compatible" 275 bool "Support for extended (non-PC) x86 platforms"
295 help 276 default y
296 Choose this option if your computer is a standard PC or compatible. 277 ---help---
278 If you disable this option then the kernel will only support
279 standard PC platforms. (which covers the vast majority of
280 systems out there.)
281
282 If you enable this option then you'll be able to select a number
283 of non-PC x86 platforms.
284
285 If you have one of these systems, or if you want to build a
286 generic distribution kernel, say Y here - otherwise say N.
287
288# This is an alphabetically sorted list of 64 bit extended platforms
289# Please maintain the alphabetic order if and when there are additions
290
291config X86_VSMP
292 bool "ScaleMP vSMP"
293 select PARAVIRT
294 depends on X86_64 && PCI
295 depends on X86_EXTENDED_PLATFORM
296 ---help---
297 Support for ScaleMP vSMP systems. Say 'Y' here if this kernel is
298 supposed to run on these EM64T-based machines. Only choose this option
299 if you have one of these machines.
300
301config X86_UV
302 bool "SGI Ultraviolet"
303 depends on X86_64
304 depends on X86_EXTENDED_PLATFORM
305 ---help---
306 This option is needed in order to support SGI Ultraviolet systems.
307 If you don't have one of these, you should say N here.
308
309# Following is an alphabetically sorted list of 32 bit extended platforms
310# Please maintain the alphabetic order if and when there are additions
297 311
298config X86_ELAN 312config X86_ELAN
299 bool "AMD Elan" 313 bool "AMD Elan"
300 depends on X86_32 314 depends on X86_32
301 help 315 depends on X86_EXTENDED_PLATFORM
316 ---help---
302 Select this for an AMD Elan processor. 317 Select this for an AMD Elan processor.
303 318
304 Do not use this option for K6/Athlon/Opteron processors! 319 Do not use this option for K6/Athlon/Opteron processors!
305 320
306 If unsure, choose "PC-compatible" instead. 321 If unsure, choose "PC-compatible" instead.
307 322
308config X86_VOYAGER 323config X86_RDC321X
309 bool "Voyager (NCR)" 324 bool "RDC R-321x SoC"
310 depends on X86_32 && (SMP || BROKEN) && !PCI
311 help
312 Voyager is an MCA-based 32-way capable SMP architecture proprietary
313 to NCR Corp. Machine classes 345x/35xx/4100/51xx are Voyager-based.
314
315 *** WARNING ***
316
317 If you do not specifically know you have a Voyager based machine,
318 say N here, otherwise the kernel you build will not be bootable.
319
320config X86_GENERICARCH
321 bool "Generic architecture"
322 depends on X86_32 325 depends on X86_32
323 help 326 depends on X86_EXTENDED_PLATFORM
324 This option compiles in the NUMAQ, Summit, bigsmp, ES7000, default 327 select M486
328 select X86_REBOOTFIXUPS
329 ---help---
330 This option is needed for RDC R-321x system-on-chip, also known
331 as R-8610-(G).
332 If you don't have one of these chips, you should say N here.
333
334config X86_32_NON_STANDARD
335 bool "Support non-standard 32-bit SMP architectures"
336 depends on X86_32 && SMP
337 depends on X86_EXTENDED_PLATFORM
338 ---help---
339 This option compiles in the NUMAQ, Summit, bigsmp, ES7000, default
325 subarchitectures. It is intended for a generic binary kernel. 340 subarchitectures. It is intended for a generic binary kernel.
326 if you select them all, kernel will probe it one by one. and will 341 if you select them all, kernel will probe it one by one. and will
327 fallback to default. 342 fallback to default.
328 343
329if X86_GENERICARCH 344# Alphabetically sorted list of Non standard 32 bit platforms
330 345
331config X86_NUMAQ 346config X86_NUMAQ
332 bool "NUMAQ (IBM/Sequent)" 347 bool "NUMAQ (IBM/Sequent)"
333 depends on SMP && X86_32 && PCI && X86_MPPARSE 348 depends on X86_32_NON_STANDARD
334 select NUMA 349 select NUMA
335 help 350 select X86_MPPARSE
351 ---help---
336 This option is used for getting Linux to run on a NUMAQ (IBM/Sequent) 352 This option is used for getting Linux to run on a NUMAQ (IBM/Sequent)
337 NUMA multiquad box. This changes the way that processors are 353 NUMA multiquad box. This changes the way that processors are
338 bootstrapped, and uses Clustered Logical APIC addressing mode instead 354 bootstrapped, and uses Clustered Logical APIC addressing mode instead
339 of Flat Logical. You will need a new lynxer.elf file to flash your 355 of Flat Logical. You will need a new lynxer.elf file to flash your
340 firmware with - send email to <Martin.Bligh@us.ibm.com>. 356 firmware with - send email to <Martin.Bligh@us.ibm.com>.
341 357
342config X86_SUMMIT
343 bool "Summit/EXA (IBM x440)"
344 depends on X86_32 && SMP
345 help
346 This option is needed for IBM systems that use the Summit/EXA chipset.
347 In particular, it is needed for the x440.
348
349config X86_ES7000
350 bool "Support for Unisys ES7000 IA32 series"
351 depends on X86_32 && SMP
352 help
353 Support for Unisys ES7000 systems. Say 'Y' here if this kernel is
354 supposed to run on an IA32-based Unisys ES7000 system.
355
356config X86_BIGSMP
357 bool "Support for big SMP systems with more than 8 CPUs"
358 depends on X86_32 && SMP
359 help
360 This option is needed for the systems that have more than 8 CPUs
361 and if the system is not of any sub-arch type above.
362
363endif
364
365config X86_VSMP
366 bool "Support for ScaleMP vSMP"
367 select PARAVIRT
368 depends on X86_64 && PCI
369 help
370 Support for ScaleMP vSMP systems. Say 'Y' here if this kernel is
371 supposed to run on these EM64T-based machines. Only choose this option
372 if you have one of these machines.
373
374endchoice
375
376config X86_VISWS 358config X86_VISWS
377 bool "SGI 320/540 (Visual Workstation)" 359 bool "SGI 320/540 (Visual Workstation)"
378 depends on X86_32 && PCI && !X86_VOYAGER && X86_MPPARSE && PCI_GODIRECT 360 depends on X86_32 && PCI && X86_MPPARSE && PCI_GODIRECT
379 help 361 depends on X86_32_NON_STANDARD
362 ---help---
380 The SGI Visual Workstation series is an IA32-based workstation 363 The SGI Visual Workstation series is an IA32-based workstation
381 based on SGI systems chips with some legacy PC hardware attached. 364 based on SGI systems chips with some legacy PC hardware attached.
382 365
@@ -385,28 +368,38 @@ config X86_VISWS
385 A kernel compiled for the Visual Workstation will run on general 368 A kernel compiled for the Visual Workstation will run on general
386 PCs as well. See <file:Documentation/sgi-visws.txt> for details. 369 PCs as well. See <file:Documentation/sgi-visws.txt> for details.
387 370
388config X86_RDC321X 371config X86_SUMMIT
389 bool "RDC R-321x SoC" 372 bool "Summit/EXA (IBM x440)"
390 depends on X86_32 373 depends on X86_32_NON_STANDARD
391 select M486 374 ---help---
392 select X86_REBOOTFIXUPS 375 This option is needed for IBM systems that use the Summit/EXA chipset.
393 help 376 In particular, it is needed for the x440.
394 This option is needed for RDC R-321x system-on-chip, also known
395 as R-8610-(G).
396 If you don't have one of these chips, you should say N here.
397 377
398config X86_UV 378config X86_ES7000
399 bool "SGI Ultraviolet" 379 bool "Unisys ES7000 IA32 series"
400 depends on X86_64 380 depends on X86_32_NON_STANDARD && X86_BIGSMP
401 help 381 ---help---
402 This option is needed in order to support SGI Ultraviolet systems. 382 Support for Unisys ES7000 systems. Say 'Y' here if this kernel is
403 If you don't have one of these, you should say N here. 383 supposed to run on an IA32-based Unisys ES7000 system.
384
385config X86_VOYAGER
386 bool "Voyager (NCR)"
387 depends on SMP && !PCI && BROKEN
388 depends on X86_32_NON_STANDARD
389 ---help---
390 Voyager is an MCA-based 32-way capable SMP architecture proprietary
391 to NCR Corp. Machine classes 345x/35xx/4100/51xx are Voyager-based.
392
393 *** WARNING ***
394
395 If you do not specifically know you have a Voyager based machine,
396 say N here, otherwise the kernel you build will not be bootable.
404 397
405config SCHED_OMIT_FRAME_POINTER 398config SCHED_OMIT_FRAME_POINTER
406 def_bool y 399 def_bool y
407 prompt "Single-depth WCHAN output" 400 prompt "Single-depth WCHAN output"
408 depends on X86 401 depends on X86
409 help 402 ---help---
410 Calculate simpler /proc/<PID>/wchan values. If this option 403 Calculate simpler /proc/<PID>/wchan values. If this option
411 is disabled then wchan values will recurse back to the 404 is disabled then wchan values will recurse back to the
412 caller function. This provides more accurate wchan values, 405 caller function. This provides more accurate wchan values,
@@ -416,7 +409,7 @@ config SCHED_OMIT_FRAME_POINTER
416 409
417menuconfig PARAVIRT_GUEST 410menuconfig PARAVIRT_GUEST
418 bool "Paravirtualized guest support" 411 bool "Paravirtualized guest support"
419 help 412 ---help---
420 Say Y here to get to see options related to running Linux under 413 Say Y here to get to see options related to running Linux under
421 various hypervisors. This option alone does not add any kernel code. 414 various hypervisors. This option alone does not add any kernel code.
422 415
@@ -430,8 +423,7 @@ config VMI
430 bool "VMI Guest support" 423 bool "VMI Guest support"
431 select PARAVIRT 424 select PARAVIRT
432 depends on X86_32 425 depends on X86_32
433 depends on !X86_VOYAGER 426 ---help---
434 help
435 VMI provides a paravirtualized interface to the VMware ESX server 427 VMI provides a paravirtualized interface to the VMware ESX server
436 (it could be used by other hypervisors in theory too, but is not 428 (it could be used by other hypervisors in theory too, but is not
437 at the moment), by linking the kernel to a GPL-ed ROM module 429 at the moment), by linking the kernel to a GPL-ed ROM module
@@ -441,8 +433,7 @@ config KVM_CLOCK
441 bool "KVM paravirtualized clock" 433 bool "KVM paravirtualized clock"
442 select PARAVIRT 434 select PARAVIRT
443 select PARAVIRT_CLOCK 435 select PARAVIRT_CLOCK
444 depends on !X86_VOYAGER 436 ---help---
445 help
446 Turning on this option will allow you to run a paravirtualized clock 437 Turning on this option will allow you to run a paravirtualized clock
447 when running over the KVM hypervisor. Instead of relying on a PIT 438 when running over the KVM hypervisor. Instead of relying on a PIT
448 (or probably other) emulation by the underlying device model, the host 439 (or probably other) emulation by the underlying device model, the host
@@ -452,17 +443,15 @@ config KVM_CLOCK
452config KVM_GUEST 443config KVM_GUEST
453 bool "KVM Guest support" 444 bool "KVM Guest support"
454 select PARAVIRT 445 select PARAVIRT
455 depends on !X86_VOYAGER 446 ---help---
456 help 447 This option enables various optimizations for running under the KVM
457 This option enables various optimizations for running under the KVM 448 hypervisor.
458 hypervisor.
459 449
460source "arch/x86/lguest/Kconfig" 450source "arch/x86/lguest/Kconfig"
461 451
462config PARAVIRT 452config PARAVIRT
463 bool "Enable paravirtualization code" 453 bool "Enable paravirtualization code"
464 depends on !X86_VOYAGER 454 ---help---
465 help
466 This changes the kernel so it can modify itself when it is run 455 This changes the kernel so it can modify itself when it is run
467 under a hypervisor, potentially improving performance significantly 456 under a hypervisor, potentially improving performance significantly
468 over full virtualization. However, when run without a hypervisor 457 over full virtualization. However, when run without a hypervisor
@@ -475,51 +464,51 @@ config PARAVIRT_CLOCK
475endif 464endif
476 465
477config PARAVIRT_DEBUG 466config PARAVIRT_DEBUG
478 bool "paravirt-ops debugging" 467 bool "paravirt-ops debugging"
479 depends on PARAVIRT && DEBUG_KERNEL 468 depends on PARAVIRT && DEBUG_KERNEL
480 help 469 ---help---
481 Enable to debug paravirt_ops internals. Specifically, BUG if 470 Enable to debug paravirt_ops internals. Specifically, BUG if
482 a paravirt_op is missing when it is called. 471 a paravirt_op is missing when it is called.
483 472
484config MEMTEST 473config MEMTEST
485 bool "Memtest" 474 bool "Memtest"
486 help 475 ---help---
487 This option adds a kernel parameter 'memtest', which allows memtest 476 This option adds a kernel parameter 'memtest', which allows memtest
488 to be set. 477 to be set.
489 memtest=0, mean disabled; -- default 478 memtest=0, mean disabled; -- default
490 memtest=1, mean do 1 test pattern; 479 memtest=1, mean do 1 test pattern;
491 ... 480 ...
492 memtest=4, mean do 4 test patterns. 481 memtest=4, mean do 4 test patterns.
493 If you are unsure how to answer this question, answer N. 482 If you are unsure how to answer this question, answer N.
494 483
495config X86_SUMMIT_NUMA 484config X86_SUMMIT_NUMA
496 def_bool y 485 def_bool y
497 depends on X86_32 && NUMA && X86_GENERICARCH 486 depends on X86_32 && NUMA && X86_32_NON_STANDARD
498 487
499config X86_CYCLONE_TIMER 488config X86_CYCLONE_TIMER
500 def_bool y 489 def_bool y
501 depends on X86_GENERICARCH 490 depends on X86_32_NON_STANDARD
502 491
503source "arch/x86/Kconfig.cpu" 492source "arch/x86/Kconfig.cpu"
504 493
505config HPET_TIMER 494config HPET_TIMER
506 def_bool X86_64 495 def_bool X86_64
507 prompt "HPET Timer Support" if X86_32 496 prompt "HPET Timer Support" if X86_32
508 help 497 ---help---
509 Use the IA-PC HPET (High Precision Event Timer) to manage 498 Use the IA-PC HPET (High Precision Event Timer) to manage
510 time in preference to the PIT and RTC, if a HPET is 499 time in preference to the PIT and RTC, if a HPET is
511 present. 500 present.
512 HPET is the next generation timer replacing legacy 8254s. 501 HPET is the next generation timer replacing legacy 8254s.
513 The HPET provides a stable time base on SMP 502 The HPET provides a stable time base on SMP
514 systems, unlike the TSC, but it is more expensive to access, 503 systems, unlike the TSC, but it is more expensive to access,
515 as it is off-chip. You can find the HPET spec at 504 as it is off-chip. You can find the HPET spec at
516 <http://www.intel.com/hardwaredesign/hpetspec_1.pdf>. 505 <http://www.intel.com/hardwaredesign/hpetspec_1.pdf>.
517 506
518 You can safely choose Y here. However, HPET will only be 507 You can safely choose Y here. However, HPET will only be
519 activated if the platform and the BIOS support this feature. 508 activated if the platform and the BIOS support this feature.
520 Otherwise the 8254 will be used for timing services. 509 Otherwise the 8254 will be used for timing services.
521 510
522 Choose N to continue using the legacy 8254 timer. 511 Choose N to continue using the legacy 8254 timer.
523 512
524config HPET_EMULATE_RTC 513config HPET_EMULATE_RTC
525 def_bool y 514 def_bool y
@@ -530,7 +519,7 @@ config HPET_EMULATE_RTC
530config DMI 519config DMI
531 default y 520 default y
532 bool "Enable DMI scanning" if EMBEDDED 521 bool "Enable DMI scanning" if EMBEDDED
533 help 522 ---help---
534 Enabled scanning of DMI to identify machine quirks. Say Y 523 Enabled scanning of DMI to identify machine quirks. Say Y
535 here unless you have verified that your setup is not 524 here unless you have verified that your setup is not
536 affected by entries in the DMI blacklist. Required by PNP 525 affected by entries in the DMI blacklist. Required by PNP
@@ -542,7 +531,7 @@ config GART_IOMMU
542 select SWIOTLB 531 select SWIOTLB
543 select AGP 532 select AGP
544 depends on X86_64 && PCI 533 depends on X86_64 && PCI
545 help 534 ---help---
546 Support for full DMA access of devices with 32bit memory access only 535 Support for full DMA access of devices with 32bit memory access only
547 on systems with more than 3GB. This is usually needed for USB, 536 on systems with more than 3GB. This is usually needed for USB,
548 sound, many IDE/SATA chipsets and some other devices. 537 sound, many IDE/SATA chipsets and some other devices.
@@ -557,7 +546,7 @@ config CALGARY_IOMMU
557 bool "IBM Calgary IOMMU support" 546 bool "IBM Calgary IOMMU support"
558 select SWIOTLB 547 select SWIOTLB
559 depends on X86_64 && PCI && EXPERIMENTAL 548 depends on X86_64 && PCI && EXPERIMENTAL
560 help 549 ---help---
561 Support for hardware IOMMUs in IBM's xSeries x366 and x460 550 Support for hardware IOMMUs in IBM's xSeries x366 and x460
562 systems. Needed to run systems with more than 3GB of memory 551 systems. Needed to run systems with more than 3GB of memory
563 properly with 32-bit PCI devices that do not support DAC 552 properly with 32-bit PCI devices that do not support DAC
@@ -575,7 +564,7 @@ config CALGARY_IOMMU_ENABLED_BY_DEFAULT
575 def_bool y 564 def_bool y
576 prompt "Should Calgary be enabled by default?" 565 prompt "Should Calgary be enabled by default?"
577 depends on CALGARY_IOMMU 566 depends on CALGARY_IOMMU
578 help 567 ---help---
579 Should Calgary be enabled by default? if you choose 'y', Calgary 568 Should Calgary be enabled by default? if you choose 'y', Calgary
580 will be used (if it exists). If you choose 'n', Calgary will not be 569 will be used (if it exists). If you choose 'n', Calgary will not be
581 used even if it exists. If you choose 'n' and would like to use 570 used even if it exists. If you choose 'n' and would like to use
@@ -587,7 +576,7 @@ config AMD_IOMMU
587 select SWIOTLB 576 select SWIOTLB
588 select PCI_MSI 577 select PCI_MSI
589 depends on X86_64 && PCI && ACPI 578 depends on X86_64 && PCI && ACPI
590 help 579 ---help---
591 With this option you can enable support for AMD IOMMU hardware in 580 With this option you can enable support for AMD IOMMU hardware in
592 your system. An IOMMU is a hardware component which provides 581 your system. An IOMMU is a hardware component which provides
593 remapping of DMA memory accesses from devices. With an AMD IOMMU you 582 remapping of DMA memory accesses from devices. With an AMD IOMMU you
@@ -602,7 +591,7 @@ config AMD_IOMMU_STATS
602 bool "Export AMD IOMMU statistics to debugfs" 591 bool "Export AMD IOMMU statistics to debugfs"
603 depends on AMD_IOMMU 592 depends on AMD_IOMMU
604 select DEBUG_FS 593 select DEBUG_FS
605 help 594 ---help---
606 This option enables code in the AMD IOMMU driver to collect various 595 This option enables code in the AMD IOMMU driver to collect various
607 statistics about whats happening in the driver and exports that 596 statistics about whats happening in the driver and exports that
608 information to userspace via debugfs. 597 information to userspace via debugfs.
@@ -611,7 +600,7 @@ config AMD_IOMMU_STATS
611# need this always selected by IOMMU for the VIA workaround 600# need this always selected by IOMMU for the VIA workaround
612config SWIOTLB 601config SWIOTLB
613 def_bool y if X86_64 602 def_bool y if X86_64
614 help 603 ---help---
615 Support for software bounce buffers used on x86-64 systems 604 Support for software bounce buffers used on x86-64 systems
616 which don't have a hardware IOMMU (e.g. the current generation 605 which don't have a hardware IOMMU (e.g. the current generation
617 of Intel's x86-64 CPUs). Using this PCI devices which can only 606 of Intel's x86-64 CPUs). Using this PCI devices which can only
@@ -629,7 +618,7 @@ config MAXSMP
629 depends on X86_64 && SMP && DEBUG_KERNEL && EXPERIMENTAL 618 depends on X86_64 && SMP && DEBUG_KERNEL && EXPERIMENTAL
630 select CPUMASK_OFFSTACK 619 select CPUMASK_OFFSTACK
631 default n 620 default n
632 help 621 ---help---
633 Configure maximum number of CPUS and NUMA Nodes for this architecture. 622 Configure maximum number of CPUS and NUMA Nodes for this architecture.
634 If unsure, say N. 623 If unsure, say N.
635 624
@@ -640,7 +629,7 @@ config NR_CPUS
640 default "4096" if MAXSMP 629 default "4096" if MAXSMP
641 default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000) 630 default "32" if SMP && (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP || X86_ES7000)
642 default "8" if SMP 631 default "8" if SMP
643 help 632 ---help---
644 This allows you to specify the maximum number of CPUs which this 633 This allows you to specify the maximum number of CPUs which this
645 kernel will support. The maximum supported value is 512 and the 634 kernel will support. The maximum supported value is 512 and the
646 minimum value which makes sense is 2. 635 minimum value which makes sense is 2.
@@ -651,7 +640,7 @@ config NR_CPUS
651config SCHED_SMT 640config SCHED_SMT
652 bool "SMT (Hyperthreading) scheduler support" 641 bool "SMT (Hyperthreading) scheduler support"
653 depends on X86_HT 642 depends on X86_HT
654 help 643 ---help---
655 SMT scheduler support improves the CPU scheduler's decision making 644 SMT scheduler support improves the CPU scheduler's decision making
656 when dealing with Intel Pentium 4 chips with HyperThreading at a 645 when dealing with Intel Pentium 4 chips with HyperThreading at a
657 cost of slightly increased overhead in some places. If unsure say 646 cost of slightly increased overhead in some places. If unsure say
@@ -661,7 +650,7 @@ config SCHED_MC
661 def_bool y 650 def_bool y
662 prompt "Multi-core scheduler support" 651 prompt "Multi-core scheduler support"
663 depends on X86_HT 652 depends on X86_HT
664 help 653 ---help---
665 Multi-core scheduler support improves the CPU scheduler's decision 654 Multi-core scheduler support improves the CPU scheduler's decision
666 making when dealing with multi-core CPU chips at a cost of slightly 655 making when dealing with multi-core CPU chips at a cost of slightly
667 increased overhead in some places. If unsure say N here. 656 increased overhead in some places. If unsure say N here.
@@ -670,8 +659,8 @@ source "kernel/Kconfig.preempt"
670 659
671config X86_UP_APIC 660config X86_UP_APIC
672 bool "Local APIC support on uniprocessors" 661 bool "Local APIC support on uniprocessors"
673 depends on X86_32 && !SMP && !(X86_VOYAGER || X86_GENERICARCH) 662 depends on X86_32 && !SMP && !X86_32_NON_STANDARD
674 help 663 ---help---
675 A local APIC (Advanced Programmable Interrupt Controller) is an 664 A local APIC (Advanced Programmable Interrupt Controller) is an
676 integrated interrupt controller in the CPU. If you have a single-CPU 665 integrated interrupt controller in the CPU. If you have a single-CPU
677 system which has a processor with a local APIC, you can say Y here to 666 system which has a processor with a local APIC, you can say Y here to
@@ -684,7 +673,7 @@ config X86_UP_APIC
684config X86_UP_IOAPIC 673config X86_UP_IOAPIC
685 bool "IO-APIC support on uniprocessors" 674 bool "IO-APIC support on uniprocessors"
686 depends on X86_UP_APIC 675 depends on X86_UP_APIC
687 help 676 ---help---
688 An IO-APIC (I/O Advanced Programmable Interrupt Controller) is an 677 An IO-APIC (I/O Advanced Programmable Interrupt Controller) is an
689 SMP-capable replacement for PC-style interrupt controllers. Most 678 SMP-capable replacement for PC-style interrupt controllers. Most
690 SMP systems and many recent uniprocessor systems have one. 679 SMP systems and many recent uniprocessor systems have one.
@@ -695,11 +684,11 @@ config X86_UP_IOAPIC
695 684
696config X86_LOCAL_APIC 685config X86_LOCAL_APIC
697 def_bool y 686 def_bool y
698 depends on X86_64 || (X86_32 && (X86_UP_APIC || (SMP && !X86_VOYAGER) || X86_GENERICARCH)) 687 depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC
699 688
700config X86_IO_APIC 689config X86_IO_APIC
701 def_bool y 690 def_bool y
702 depends on X86_64 || (X86_32 && (X86_UP_IOAPIC || (SMP && !X86_VOYAGER) || X86_GENERICARCH)) 691 depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC
703 692
704config X86_VISWS_APIC 693config X86_VISWS_APIC
705 def_bool y 694 def_bool y
@@ -709,7 +698,7 @@ config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
709 bool "Reroute for broken boot IRQs" 698 bool "Reroute for broken boot IRQs"
710 default n 699 default n
711 depends on X86_IO_APIC 700 depends on X86_IO_APIC
712 help 701 ---help---
713 This option enables a workaround that fixes a source of 702 This option enables a workaround that fixes a source of
714 spurious interrupts. This is recommended when threaded 703 spurious interrupts. This is recommended when threaded
715 interrupt handling is used on systems where the generation of 704 interrupt handling is used on systems where the generation of
@@ -731,7 +720,6 @@ config X86_REROUTE_FOR_BROKEN_BOOT_IRQS
731 720
732config X86_MCE 721config X86_MCE
733 bool "Machine Check Exception" 722 bool "Machine Check Exception"
734 depends on !X86_VOYAGER
735 ---help--- 723 ---help---
736 Machine Check Exception support allows the processor to notify the 724 Machine Check Exception support allows the processor to notify the
737 kernel if it detects a problem (e.g. overheating, component failure). 725 kernel if it detects a problem (e.g. overheating, component failure).
@@ -750,7 +738,7 @@ config X86_MCE_INTEL
750 def_bool y 738 def_bool y
751 prompt "Intel MCE features" 739 prompt "Intel MCE features"
752 depends on X86_64 && X86_MCE && X86_LOCAL_APIC 740 depends on X86_64 && X86_MCE && X86_LOCAL_APIC
753 help 741 ---help---
754 Additional support for intel specific MCE features such as 742 Additional support for intel specific MCE features such as
755 the thermal monitor. 743 the thermal monitor.
756 744
@@ -758,14 +746,14 @@ config X86_MCE_AMD
758 def_bool y 746 def_bool y
759 prompt "AMD MCE features" 747 prompt "AMD MCE features"
760 depends on X86_64 && X86_MCE && X86_LOCAL_APIC 748 depends on X86_64 && X86_MCE && X86_LOCAL_APIC
761 help 749 ---help---
762 Additional support for AMD specific MCE features such as 750 Additional support for AMD specific MCE features such as
763 the DRAM Error Threshold. 751 the DRAM Error Threshold.
764 752
765config X86_MCE_NONFATAL 753config X86_MCE_NONFATAL
766 tristate "Check for non-fatal errors on AMD Athlon/Duron / Intel Pentium 4" 754 tristate "Check for non-fatal errors on AMD Athlon/Duron / Intel Pentium 4"
767 depends on X86_32 && X86_MCE 755 depends on X86_32 && X86_MCE
768 help 756 ---help---
769 Enabling this feature starts a timer that triggers every 5 seconds which 757 Enabling this feature starts a timer that triggers every 5 seconds which
770 will look at the machine check registers to see if anything happened. 758 will look at the machine check registers to see if anything happened.
771 Non-fatal problems automatically get corrected (but still logged). 759 Non-fatal problems automatically get corrected (but still logged).
@@ -778,7 +766,7 @@ config X86_MCE_NONFATAL
778config X86_MCE_P4THERMAL 766config X86_MCE_P4THERMAL
779 bool "check for P4 thermal throttling interrupt." 767 bool "check for P4 thermal throttling interrupt."
780 depends on X86_32 && X86_MCE && (X86_UP_APIC || SMP) 768 depends on X86_32 && X86_MCE && (X86_UP_APIC || SMP)
781 help 769 ---help---
782 Enabling this feature will cause a message to be printed when the P4 770 Enabling this feature will cause a message to be printed when the P4
783 enters thermal throttling. 771 enters thermal throttling.
784 772
@@ -786,11 +774,11 @@ config VM86
786 bool "Enable VM86 support" if EMBEDDED 774 bool "Enable VM86 support" if EMBEDDED
787 default y 775 default y
788 depends on X86_32 776 depends on X86_32
789 help 777 ---help---
790 This option is required by programs like DOSEMU to run 16-bit legacy 778 This option is required by programs like DOSEMU to run 16-bit legacy
791 code on X86 processors. It also may be needed by software like 779 code on X86 processors. It also may be needed by software like
792 XFree86 to initialize some video cards via BIOS. Disabling this 780 XFree86 to initialize some video cards via BIOS. Disabling this
793 option saves about 6k. 781 option saves about 6k.
794 782
795config TOSHIBA 783config TOSHIBA
796 tristate "Toshiba Laptop support" 784 tristate "Toshiba Laptop support"
@@ -864,33 +852,33 @@ config MICROCODE
864 module will be called microcode. 852 module will be called microcode.
865 853
866config MICROCODE_INTEL 854config MICROCODE_INTEL
867 bool "Intel microcode patch loading support" 855 bool "Intel microcode patch loading support"
868 depends on MICROCODE 856 depends on MICROCODE
869 default MICROCODE 857 default MICROCODE
870 select FW_LOADER 858 select FW_LOADER
871 --help--- 859 ---help---
872 This options enables microcode patch loading support for Intel 860 This options enables microcode patch loading support for Intel
873 processors. 861 processors.
874 862
875 For latest news and information on obtaining all the required 863 For latest news and information on obtaining all the required
876 Intel ingredients for this driver, check: 864 Intel ingredients for this driver, check:
877 <http://www.urbanmyth.org/microcode/>. 865 <http://www.urbanmyth.org/microcode/>.
878 866
879config MICROCODE_AMD 867config MICROCODE_AMD
880 bool "AMD microcode patch loading support" 868 bool "AMD microcode patch loading support"
881 depends on MICROCODE 869 depends on MICROCODE
882 select FW_LOADER 870 select FW_LOADER
883 --help--- 871 ---help---
884 If you select this option, microcode patch loading support for AMD 872 If you select this option, microcode patch loading support for AMD
885 processors will be enabled. 873 processors will be enabled.
886 874
887 config MICROCODE_OLD_INTERFACE 875config MICROCODE_OLD_INTERFACE
888 def_bool y 876 def_bool y
889 depends on MICROCODE 877 depends on MICROCODE
890 878
891config X86_MSR 879config X86_MSR
892 tristate "/dev/cpu/*/msr - Model-specific register support" 880 tristate "/dev/cpu/*/msr - Model-specific register support"
893 help 881 ---help---
894 This device gives privileged processes access to the x86 882 This device gives privileged processes access to the x86
895 Model-Specific Registers (MSRs). It is a character device with 883 Model-Specific Registers (MSRs). It is a character device with
896 major 202 and minors 0 to 31 for /dev/cpu/0/msr to /dev/cpu/31/msr. 884 major 202 and minors 0 to 31 for /dev/cpu/0/msr to /dev/cpu/31/msr.
@@ -899,7 +887,7 @@ config X86_MSR
899 887
900config X86_CPUID 888config X86_CPUID
901 tristate "/dev/cpu/*/cpuid - CPU information support" 889 tristate "/dev/cpu/*/cpuid - CPU information support"
902 help 890 ---help---
903 This device gives processes access to the x86 CPUID instruction to 891 This device gives processes access to the x86 CPUID instruction to
904 be executed on a specific processor. It is a character device 892 be executed on a specific processor. It is a character device
905 with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to 893 with major 203 and minors 0 to 31 for /dev/cpu/0/cpuid to
@@ -951,7 +939,7 @@ config NOHIGHMEM
951config HIGHMEM4G 939config HIGHMEM4G
952 bool "4GB" 940 bool "4GB"
953 depends on !X86_NUMAQ 941 depends on !X86_NUMAQ
954 help 942 ---help---
955 Select this if you have a 32-bit processor and between 1 and 4 943 Select this if you have a 32-bit processor and between 1 and 4
956 gigabytes of physical RAM. 944 gigabytes of physical RAM.
957 945
@@ -959,7 +947,7 @@ config HIGHMEM64G
959 bool "64GB" 947 bool "64GB"
960 depends on !M386 && !M486 948 depends on !M386 && !M486
961 select X86_PAE 949 select X86_PAE
962 help 950 ---help---
963 Select this if you have a 32-bit processor and more than 4 951 Select this if you have a 32-bit processor and more than 4
964 gigabytes of physical RAM. 952 gigabytes of physical RAM.
965 953
@@ -970,7 +958,7 @@ choice
970 prompt "Memory split" if EMBEDDED 958 prompt "Memory split" if EMBEDDED
971 default VMSPLIT_3G 959 default VMSPLIT_3G
972 depends on X86_32 960 depends on X86_32
973 help 961 ---help---
974 Select the desired split between kernel and user memory. 962 Select the desired split between kernel and user memory.
975 963
976 If the address range available to the kernel is less than the 964 If the address range available to the kernel is less than the
@@ -1016,20 +1004,20 @@ config HIGHMEM
1016config X86_PAE 1004config X86_PAE
1017 bool "PAE (Physical Address Extension) Support" 1005 bool "PAE (Physical Address Extension) Support"
1018 depends on X86_32 && !HIGHMEM4G 1006 depends on X86_32 && !HIGHMEM4G
1019 help 1007 ---help---
1020 PAE is required for NX support, and furthermore enables 1008 PAE is required for NX support, and furthermore enables
1021 larger swapspace support for non-overcommit purposes. It 1009 larger swapspace support for non-overcommit purposes. It
1022 has the cost of more pagetable lookup overhead, and also 1010 has the cost of more pagetable lookup overhead, and also
1023 consumes more pagetable space per process. 1011 consumes more pagetable space per process.
1024 1012
1025config ARCH_PHYS_ADDR_T_64BIT 1013config ARCH_PHYS_ADDR_T_64BIT
1026 def_bool X86_64 || X86_PAE 1014 def_bool X86_64 || X86_PAE
1027 1015
1028config DIRECT_GBPAGES 1016config DIRECT_GBPAGES
1029 bool "Enable 1GB pages for kernel pagetables" if EMBEDDED 1017 bool "Enable 1GB pages for kernel pagetables" if EMBEDDED
1030 default y 1018 default y
1031 depends on X86_64 1019 depends on X86_64
1032 help 1020 ---help---
1033 Allow the kernel linear mapping to use 1GB pages on CPUs that 1021 Allow the kernel linear mapping to use 1GB pages on CPUs that
1034 support it. This can improve the kernel's performance a tiny bit by 1022 support it. This can improve the kernel's performance a tiny bit by
1035 reducing TLB pressure. If in doubt, say "Y". 1023 reducing TLB pressure. If in doubt, say "Y".
@@ -1039,9 +1027,8 @@ config NUMA
1039 bool "Numa Memory Allocation and Scheduler Support" 1027 bool "Numa Memory Allocation and Scheduler Support"
1040 depends on SMP 1028 depends on SMP
1041 depends on X86_64 || (X86_32 && HIGHMEM64G && (X86_NUMAQ || X86_BIGSMP || X86_SUMMIT && ACPI) && EXPERIMENTAL) 1029 depends on X86_64 || (X86_32 && HIGHMEM64G && (X86_NUMAQ || X86_BIGSMP || X86_SUMMIT && ACPI) && EXPERIMENTAL)
1042 default n if X86_PC
1043 default y if (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP) 1030 default y if (X86_NUMAQ || X86_SUMMIT || X86_BIGSMP)
1044 help 1031 ---help---
1045 Enable NUMA (Non Uniform Memory Access) support. 1032 Enable NUMA (Non Uniform Memory Access) support.
1046 1033
1047 The kernel will try to allocate memory used by a CPU on the 1034 The kernel will try to allocate memory used by a CPU on the
@@ -1064,19 +1051,19 @@ config K8_NUMA
1064 def_bool y 1051 def_bool y
1065 prompt "Old style AMD Opteron NUMA detection" 1052 prompt "Old style AMD Opteron NUMA detection"
1066 depends on X86_64 && NUMA && PCI 1053 depends on X86_64 && NUMA && PCI
1067 help 1054 ---help---
1068 Enable K8 NUMA node topology detection. You should say Y here if 1055 Enable K8 NUMA node topology detection. You should say Y here if
1069 you have a multi processor AMD K8 system. This uses an old 1056 you have a multi processor AMD K8 system. This uses an old
1070 method to read the NUMA configuration directly from the builtin 1057 method to read the NUMA configuration directly from the builtin
1071 Northbridge of Opteron. It is recommended to use X86_64_ACPI_NUMA 1058 Northbridge of Opteron. It is recommended to use X86_64_ACPI_NUMA
1072 instead, which also takes priority if both are compiled in. 1059 instead, which also takes priority if both are compiled in.
1073 1060
1074config X86_64_ACPI_NUMA 1061config X86_64_ACPI_NUMA
1075 def_bool y 1062 def_bool y
1076 prompt "ACPI NUMA detection" 1063 prompt "ACPI NUMA detection"
1077 depends on X86_64 && NUMA && ACPI && PCI 1064 depends on X86_64 && NUMA && ACPI && PCI
1078 select ACPI_NUMA 1065 select ACPI_NUMA
1079 help 1066 ---help---
1080 Enable ACPI SRAT based node topology detection. 1067 Enable ACPI SRAT based node topology detection.
1081 1068
1082# Some NUMA nodes have memory ranges that span 1069# Some NUMA nodes have memory ranges that span
@@ -1091,7 +1078,7 @@ config NODES_SPAN_OTHER_NODES
1091config NUMA_EMU 1078config NUMA_EMU
1092 bool "NUMA emulation" 1079 bool "NUMA emulation"
1093 depends on X86_64 && NUMA 1080 depends on X86_64 && NUMA
1094 help 1081 ---help---
1095 Enable NUMA emulation. A flat machine will be split 1082 Enable NUMA emulation. A flat machine will be split
1096 into virtual nodes when booted with "numa=fake=N", where N is the 1083 into virtual nodes when booted with "numa=fake=N", where N is the
1097 number of nodes. This is only useful for debugging. 1084 number of nodes. This is only useful for debugging.
@@ -1104,7 +1091,7 @@ config NODES_SHIFT
1104 default "4" if X86_NUMAQ 1091 default "4" if X86_NUMAQ
1105 default "3" 1092 default "3"
1106 depends on NEED_MULTIPLE_NODES 1093 depends on NEED_MULTIPLE_NODES
1107 help 1094 ---help---
1108 Specify the maximum number of NUMA Nodes available on the target 1095 Specify the maximum number of NUMA Nodes available on the target
1109 system. Increases memory reserved to accomodate various tables. 1096 system. Increases memory reserved to accomodate various tables.
1110 1097
@@ -1142,7 +1129,7 @@ config ARCH_SPARSEMEM_DEFAULT
1142 1129
1143config ARCH_SPARSEMEM_ENABLE 1130config ARCH_SPARSEMEM_ENABLE
1144 def_bool y 1131 def_bool y
1145 depends on X86_64 || NUMA || (EXPERIMENTAL && X86_PC) || X86_GENERICARCH 1132 depends on X86_64 || NUMA || (EXPERIMENTAL && X86_32) || X86_32_NON_STANDARD
1146 select SPARSEMEM_STATIC if X86_32 1133 select SPARSEMEM_STATIC if X86_32
1147 select SPARSEMEM_VMEMMAP_ENABLE if X86_64 1134 select SPARSEMEM_VMEMMAP_ENABLE if X86_64
1148 1135
@@ -1159,61 +1146,61 @@ source "mm/Kconfig"
1159config HIGHPTE 1146config HIGHPTE
1160 bool "Allocate 3rd-level pagetables from highmem" 1147 bool "Allocate 3rd-level pagetables from highmem"
1161 depends on X86_32 && (HIGHMEM4G || HIGHMEM64G) 1148 depends on X86_32 && (HIGHMEM4G || HIGHMEM64G)
1162 help 1149 ---help---
1163 The VM uses one page table entry for each page of physical memory. 1150 The VM uses one page table entry for each page of physical memory.
1164 For systems with a lot of RAM, this can be wasteful of precious 1151 For systems with a lot of RAM, this can be wasteful of precious
1165 low memory. Setting this option will put user-space page table 1152 low memory. Setting this option will put user-space page table
1166 entries in high memory. 1153 entries in high memory.
1167 1154
1168config X86_CHECK_BIOS_CORRUPTION 1155config X86_CHECK_BIOS_CORRUPTION
1169 bool "Check for low memory corruption" 1156 bool "Check for low memory corruption"
1170 help 1157 ---help---
1171 Periodically check for memory corruption in low memory, which 1158 Periodically check for memory corruption in low memory, which
1172 is suspected to be caused by BIOS. Even when enabled in the 1159 is suspected to be caused by BIOS. Even when enabled in the
1173 configuration, it is disabled at runtime. Enable it by 1160 configuration, it is disabled at runtime. Enable it by
1174 setting "memory_corruption_check=1" on the kernel command 1161 setting "memory_corruption_check=1" on the kernel command
1175 line. By default it scans the low 64k of memory every 60 1162 line. By default it scans the low 64k of memory every 60
1176 seconds; see the memory_corruption_check_size and 1163 seconds; see the memory_corruption_check_size and
1177 memory_corruption_check_period parameters in 1164 memory_corruption_check_period parameters in
1178 Documentation/kernel-parameters.txt to adjust this. 1165 Documentation/kernel-parameters.txt to adjust this.
1179 1166
1180 When enabled with the default parameters, this option has 1167 When enabled with the default parameters, this option has
1181 almost no overhead, as it reserves a relatively small amount 1168 almost no overhead, as it reserves a relatively small amount
1182 of memory and scans it infrequently. It both detects corruption 1169 of memory and scans it infrequently. It both detects corruption
1183 and prevents it from affecting the running system. 1170 and prevents it from affecting the running system.
1184 1171
1185 It is, however, intended as a diagnostic tool; if repeatable 1172 It is, however, intended as a diagnostic tool; if repeatable
1186 BIOS-originated corruption always affects the same memory, 1173 BIOS-originated corruption always affects the same memory,
1187 you can use memmap= to prevent the kernel from using that 1174 you can use memmap= to prevent the kernel from using that
1188 memory. 1175 memory.
1189 1176
1190config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK 1177config X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK
1191 bool "Set the default setting of memory_corruption_check" 1178 bool "Set the default setting of memory_corruption_check"
1192 depends on X86_CHECK_BIOS_CORRUPTION 1179 depends on X86_CHECK_BIOS_CORRUPTION
1193 default y 1180 default y
1194 help 1181 ---help---
1195 Set whether the default state of memory_corruption_check is 1182 Set whether the default state of memory_corruption_check is
1196 on or off. 1183 on or off.
1197 1184
1198config X86_RESERVE_LOW_64K 1185config X86_RESERVE_LOW_64K
1199 bool "Reserve low 64K of RAM on AMI/Phoenix BIOSen" 1186 bool "Reserve low 64K of RAM on AMI/Phoenix BIOSen"
1200 default y 1187 default y
1201 help 1188 ---help---
1202 Reserve the first 64K of physical RAM on BIOSes that are known 1189 Reserve the first 64K of physical RAM on BIOSes that are known
1203 to potentially corrupt that memory range. A numbers of BIOSes are 1190 to potentially corrupt that memory range. A numbers of BIOSes are
1204 known to utilize this area during suspend/resume, so it must not 1191 known to utilize this area during suspend/resume, so it must not
1205 be used by the kernel. 1192 be used by the kernel.
1206 1193
1207 Set this to N if you are absolutely sure that you trust the BIOS 1194 Set this to N if you are absolutely sure that you trust the BIOS
1208 to get all its memory reservations and usages right. 1195 to get all its memory reservations and usages right.
1209 1196
1210 If you have doubts about the BIOS (e.g. suspend/resume does not 1197 If you have doubts about the BIOS (e.g. suspend/resume does not
1211 work or there's kernel crashes after certain hardware hotplug 1198 work or there's kernel crashes after certain hardware hotplug
1212 events) and it's not AMI or Phoenix, then you might want to enable 1199 events) and it's not AMI or Phoenix, then you might want to enable
1213 X86_CHECK_BIOS_CORRUPTION=y to allow the kernel to check typical 1200 X86_CHECK_BIOS_CORRUPTION=y to allow the kernel to check typical
1214 corruption patterns. 1201 corruption patterns.
1215 1202
1216 Say Y if unsure. 1203 Say Y if unsure.
1217 1204
1218config MATH_EMULATION 1205config MATH_EMULATION
1219 bool 1206 bool
@@ -1279,7 +1266,7 @@ config MTRR_SANITIZER
1279 def_bool y 1266 def_bool y
1280 prompt "MTRR cleanup support" 1267 prompt "MTRR cleanup support"
1281 depends on MTRR 1268 depends on MTRR
1282 help 1269 ---help---
1283 Convert MTRR layout from continuous to discrete, so X drivers can 1270 Convert MTRR layout from continuous to discrete, so X drivers can
1284 add writeback entries. 1271 add writeback entries.
1285 1272
@@ -1294,7 +1281,7 @@ config MTRR_SANITIZER_ENABLE_DEFAULT
1294 range 0 1 1281 range 0 1
1295 default "0" 1282 default "0"
1296 depends on MTRR_SANITIZER 1283 depends on MTRR_SANITIZER
1297 help 1284 ---help---
1298 Enable mtrr cleanup default value 1285 Enable mtrr cleanup default value
1299 1286
1300config MTRR_SANITIZER_SPARE_REG_NR_DEFAULT 1287config MTRR_SANITIZER_SPARE_REG_NR_DEFAULT
@@ -1302,7 +1289,7 @@ config MTRR_SANITIZER_SPARE_REG_NR_DEFAULT
1302 range 0 7 1289 range 0 7
1303 default "1" 1290 default "1"
1304 depends on MTRR_SANITIZER 1291 depends on MTRR_SANITIZER
1305 help 1292 ---help---
1306 mtrr cleanup spare entries default, it can be changed via 1293 mtrr cleanup spare entries default, it can be changed via
1307 mtrr_spare_reg_nr=N on the kernel command line. 1294 mtrr_spare_reg_nr=N on the kernel command line.
1308 1295
@@ -1310,7 +1297,7 @@ config X86_PAT
1310 bool 1297 bool
1311 prompt "x86 PAT support" 1298 prompt "x86 PAT support"
1312 depends on MTRR 1299 depends on MTRR
1313 help 1300 ---help---
1314 Use PAT attributes to setup page level cache control. 1301 Use PAT attributes to setup page level cache control.
1315 1302
1316 PATs are the modern equivalents of MTRRs and are much more 1303 PATs are the modern equivalents of MTRRs and are much more
@@ -1325,20 +1312,20 @@ config EFI
1325 bool "EFI runtime service support" 1312 bool "EFI runtime service support"
1326 depends on ACPI 1313 depends on ACPI
1327 ---help--- 1314 ---help---
1328 This enables the kernel to use EFI runtime services that are 1315 This enables the kernel to use EFI runtime services that are
1329 available (such as the EFI variable services). 1316 available (such as the EFI variable services).
1330 1317
1331 This option is only useful on systems that have EFI firmware. 1318 This option is only useful on systems that have EFI firmware.
1332 In addition, you should use the latest ELILO loader available 1319 In addition, you should use the latest ELILO loader available
1333 at <http://elilo.sourceforge.net> in order to take advantage 1320 at <http://elilo.sourceforge.net> in order to take advantage
1334 of EFI runtime services. However, even with this option, the 1321 of EFI runtime services. However, even with this option, the
1335 resultant kernel should continue to boot on existing non-EFI 1322 resultant kernel should continue to boot on existing non-EFI
1336 platforms. 1323 platforms.
1337 1324
1338config SECCOMP 1325config SECCOMP
1339 def_bool y 1326 def_bool y
1340 prompt "Enable seccomp to safely compute untrusted bytecode" 1327 prompt "Enable seccomp to safely compute untrusted bytecode"
1341 help 1328 ---help---
1342 This kernel feature is useful for number crunching applications 1329 This kernel feature is useful for number crunching applications
1343 that may need to compute untrusted bytecode during their 1330 that may need to compute untrusted bytecode during their
1344 execution. By using pipes or other transports made available to 1331 execution. By using pipes or other transports made available to
@@ -1357,8 +1344,8 @@ config CC_STACKPROTECTOR_ALL
1357config CC_STACKPROTECTOR 1344config CC_STACKPROTECTOR
1358 bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)" 1345 bool "Enable -fstack-protector buffer overflow detection (EXPERIMENTAL)"
1359 select CC_STACKPROTECTOR_ALL 1346 select CC_STACKPROTECTOR_ALL
1360 help 1347 ---help---
1361 This option turns on the -fstack-protector GCC feature. This 1348 This option turns on the -fstack-protector GCC feature. This
1362 feature puts, at the beginning of functions, a canary value on 1349 feature puts, at the beginning of functions, a canary value on
1363 the stack just before the return address, and validates 1350 the stack just before the return address, and validates
1364 the value just before actually returning. Stack based buffer 1351 the value just before actually returning. Stack based buffer
@@ -1375,8 +1362,7 @@ source kernel/Kconfig.hz
1375 1362
1376config KEXEC 1363config KEXEC
1377 bool "kexec system call" 1364 bool "kexec system call"
1378 depends on X86_BIOS_REBOOT 1365 ---help---
1379 help
1380 kexec is a system call that implements the ability to shutdown your 1366 kexec is a system call that implements the ability to shutdown your
1381 current kernel, and to start another kernel. It is like a reboot 1367 current kernel, and to start another kernel. It is like a reboot
1382 but it is independent of the system firmware. And like a reboot 1368 but it is independent of the system firmware. And like a reboot
@@ -1393,7 +1379,7 @@ config KEXEC
1393config CRASH_DUMP 1379config CRASH_DUMP
1394 bool "kernel crash dumps" 1380 bool "kernel crash dumps"
1395 depends on X86_64 || (X86_32 && HIGHMEM) 1381 depends on X86_64 || (X86_32 && HIGHMEM)
1396 help 1382 ---help---
1397 Generate crash dump after being started by kexec. 1383 Generate crash dump after being started by kexec.
1398 This should be normally only set in special crash dump kernels 1384 This should be normally only set in special crash dump kernels
1399 which are loaded in the main kernel with kexec-tools into 1385 which are loaded in the main kernel with kexec-tools into
@@ -1408,7 +1394,7 @@ config KEXEC_JUMP
1408 bool "kexec jump (EXPERIMENTAL)" 1394 bool "kexec jump (EXPERIMENTAL)"
1409 depends on EXPERIMENTAL 1395 depends on EXPERIMENTAL
1410 depends on KEXEC && HIBERNATION && X86_32 1396 depends on KEXEC && HIBERNATION && X86_32
1411 help 1397 ---help---
1412 Jump between original kernel and kexeced kernel and invoke 1398 Jump between original kernel and kexeced kernel and invoke
1413 code in physical address mode via KEXEC 1399 code in physical address mode via KEXEC
1414 1400
@@ -1417,7 +1403,7 @@ config PHYSICAL_START
1417 default "0x1000000" if X86_NUMAQ 1403 default "0x1000000" if X86_NUMAQ
1418 default "0x200000" if X86_64 1404 default "0x200000" if X86_64
1419 default "0x100000" 1405 default "0x100000"
1420 help 1406 ---help---
1421 This gives the physical address where the kernel is loaded. 1407 This gives the physical address where the kernel is loaded.
1422 1408
1423 If kernel is a not relocatable (CONFIG_RELOCATABLE=n) then 1409 If kernel is a not relocatable (CONFIG_RELOCATABLE=n) then
@@ -1458,7 +1444,7 @@ config PHYSICAL_START
1458config RELOCATABLE 1444config RELOCATABLE
1459 bool "Build a relocatable kernel (EXPERIMENTAL)" 1445 bool "Build a relocatable kernel (EXPERIMENTAL)"
1460 depends on EXPERIMENTAL 1446 depends on EXPERIMENTAL
1461 help 1447 ---help---
1462 This builds a kernel image that retains relocation information 1448 This builds a kernel image that retains relocation information
1463 so it can be loaded someplace besides the default 1MB. 1449 so it can be loaded someplace besides the default 1MB.
1464 The relocations tend to make the kernel binary about 10% larger, 1450 The relocations tend to make the kernel binary about 10% larger,
@@ -1478,7 +1464,7 @@ config PHYSICAL_ALIGN
1478 default "0x100000" if X86_32 1464 default "0x100000" if X86_32
1479 default "0x200000" if X86_64 1465 default "0x200000" if X86_64
1480 range 0x2000 0x400000 1466 range 0x2000 0x400000
1481 help 1467 ---help---
1482 This value puts the alignment restrictions on physical address 1468 This value puts the alignment restrictions on physical address
1483 where kernel is loaded and run from. Kernel is compiled for an 1469 where kernel is loaded and run from. Kernel is compiled for an
1484 address which meets above alignment restriction. 1470 address which meets above alignment restriction.
@@ -1499,7 +1485,7 @@ config PHYSICAL_ALIGN
1499 1485
1500config HOTPLUG_CPU 1486config HOTPLUG_CPU
1501 bool "Support for hot-pluggable CPUs" 1487 bool "Support for hot-pluggable CPUs"
1502 depends on SMP && HOTPLUG && !X86_VOYAGER 1488 depends on SMP && HOTPLUG
1503 ---help--- 1489 ---help---
1504 Say Y here to allow turning CPUs off and on. CPUs can be 1490 Say Y here to allow turning CPUs off and on. CPUs can be
1505 controlled through /sys/devices/system/cpu. 1491 controlled through /sys/devices/system/cpu.
@@ -1511,7 +1497,7 @@ config COMPAT_VDSO
1511 def_bool y 1497 def_bool y
1512 prompt "Compat VDSO support" 1498 prompt "Compat VDSO support"
1513 depends on X86_32 || IA32_EMULATION 1499 depends on X86_32 || IA32_EMULATION
1514 help 1500 ---help---
1515 Map the 32-bit VDSO to the predictable old-style address too. 1501 Map the 32-bit VDSO to the predictable old-style address too.
1516 ---help--- 1502 ---help---
1517 Say N here if you are running a sufficiently recent glibc 1503 Say N here if you are running a sufficiently recent glibc
@@ -1523,7 +1509,7 @@ config COMPAT_VDSO
1523config CMDLINE_BOOL 1509config CMDLINE_BOOL
1524 bool "Built-in kernel command line" 1510 bool "Built-in kernel command line"
1525 default n 1511 default n
1526 help 1512 ---help---
1527 Allow for specifying boot arguments to the kernel at 1513 Allow for specifying boot arguments to the kernel at
1528 build time. On some systems (e.g. embedded ones), it is 1514 build time. On some systems (e.g. embedded ones), it is
1529 necessary or convenient to provide some or all of the 1515 necessary or convenient to provide some or all of the
@@ -1541,7 +1527,7 @@ config CMDLINE
1541 string "Built-in kernel command string" 1527 string "Built-in kernel command string"
1542 depends on CMDLINE_BOOL 1528 depends on CMDLINE_BOOL
1543 default "" 1529 default ""
1544 help 1530 ---help---
1545 Enter arguments here that should be compiled into the kernel 1531 Enter arguments here that should be compiled into the kernel
1546 image and used at boot time. If the boot loader provides a 1532 image and used at boot time. If the boot loader provides a
1547 command line at boot time, it is appended to this string to 1533 command line at boot time, it is appended to this string to
@@ -1558,7 +1544,7 @@ config CMDLINE_OVERRIDE
1558 bool "Built-in command line overrides boot loader arguments" 1544 bool "Built-in command line overrides boot loader arguments"
1559 default n 1545 default n
1560 depends on CMDLINE_BOOL 1546 depends on CMDLINE_BOOL
1561 help 1547 ---help---
1562 Set this option to 'Y' to have the kernel ignore the boot loader 1548 Set this option to 'Y' to have the kernel ignore the boot loader
1563 command line, and use ONLY the built-in command line. 1549 command line, and use ONLY the built-in command line.
1564 1550
@@ -1580,7 +1566,6 @@ config HAVE_ARCH_EARLY_PFN_TO_NID
1580 depends on NUMA 1566 depends on NUMA
1581 1567
1582menu "Power management and ACPI options" 1568menu "Power management and ACPI options"
1583 depends on !X86_VOYAGER
1584 1569
1585config ARCH_HIBERNATION_HEADER 1570config ARCH_HIBERNATION_HEADER
1586 def_bool y 1571 def_bool y
@@ -1658,7 +1643,7 @@ if APM
1658 1643
1659config APM_IGNORE_USER_SUSPEND 1644config APM_IGNORE_USER_SUSPEND
1660 bool "Ignore USER SUSPEND" 1645 bool "Ignore USER SUSPEND"
1661 help 1646 ---help---
1662 This option will ignore USER SUSPEND requests. On machines with a 1647 This option will ignore USER SUSPEND requests. On machines with a
1663 compliant APM BIOS, you want to say N. However, on the NEC Versa M 1648 compliant APM BIOS, you want to say N. However, on the NEC Versa M
1664 series notebooks, it is necessary to say Y because of a BIOS bug. 1649 series notebooks, it is necessary to say Y because of a BIOS bug.
@@ -1682,7 +1667,7 @@ config APM_DO_ENABLE
1682 1667
1683config APM_CPU_IDLE 1668config APM_CPU_IDLE
1684 bool "Make CPU Idle calls when idle" 1669 bool "Make CPU Idle calls when idle"
1685 help 1670 ---help---
1686 Enable calls to APM CPU Idle/CPU Busy inside the kernel's idle loop. 1671 Enable calls to APM CPU Idle/CPU Busy inside the kernel's idle loop.
1687 On some machines, this can activate improved power savings, such as 1672 On some machines, this can activate improved power savings, such as
1688 a slowed CPU clock rate, when the machine is idle. These idle calls 1673 a slowed CPU clock rate, when the machine is idle. These idle calls
@@ -1693,7 +1678,7 @@ config APM_CPU_IDLE
1693 1678
1694config APM_DISPLAY_BLANK 1679config APM_DISPLAY_BLANK
1695 bool "Enable console blanking using APM" 1680 bool "Enable console blanking using APM"
1696 help 1681 ---help---
1697 Enable console blanking using the APM. Some laptops can use this to 1682 Enable console blanking using the APM. Some laptops can use this to
1698 turn off the LCD backlight when the screen blanker of the Linux 1683 turn off the LCD backlight when the screen blanker of the Linux
1699 virtual console blanks the screen. Note that this is only used by 1684 virtual console blanks the screen. Note that this is only used by
@@ -1706,7 +1691,7 @@ config APM_DISPLAY_BLANK
1706 1691
1707config APM_ALLOW_INTS 1692config APM_ALLOW_INTS
1708 bool "Allow interrupts during APM BIOS calls" 1693 bool "Allow interrupts during APM BIOS calls"
1709 help 1694 ---help---
1710 Normally we disable external interrupts while we are making calls to 1695 Normally we disable external interrupts while we are making calls to
1711 the APM BIOS as a measure to lessen the effects of a badly behaving 1696 the APM BIOS as a measure to lessen the effects of a badly behaving
1712 BIOS implementation. The BIOS should reenable interrupts if it 1697 BIOS implementation. The BIOS should reenable interrupts if it
@@ -1731,7 +1716,7 @@ config PCI
1731 bool "PCI support" 1716 bool "PCI support"
1732 default y 1717 default y
1733 select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC) 1718 select ARCH_SUPPORTS_MSI if (X86_LOCAL_APIC && X86_IO_APIC)
1734 help 1719 ---help---
1735 Find out whether you have a PCI motherboard. PCI is the name of a 1720 Find out whether you have a PCI motherboard. PCI is the name of a
1736 bus system, i.e. the way the CPU talks to the other stuff inside 1721 bus system, i.e. the way the CPU talks to the other stuff inside
1737 your box. Other bus systems are ISA, EISA, MicroChannel (MCA) or 1722 your box. Other bus systems are ISA, EISA, MicroChannel (MCA) or
@@ -1802,7 +1787,7 @@ config PCI_MMCONFIG
1802config DMAR 1787config DMAR
1803 bool "Support for DMA Remapping Devices (EXPERIMENTAL)" 1788 bool "Support for DMA Remapping Devices (EXPERIMENTAL)"
1804 depends on X86_64 && PCI_MSI && ACPI && EXPERIMENTAL 1789 depends on X86_64 && PCI_MSI && ACPI && EXPERIMENTAL
1805 help 1790 ---help---
1806 DMA remapping (DMAR) devices support enables independent address 1791 DMA remapping (DMAR) devices support enables independent address
1807 translations for Direct Memory Access (DMA) from devices. 1792 translations for Direct Memory Access (DMA) from devices.
1808 These DMA remapping devices are reported via ACPI tables 1793 These DMA remapping devices are reported via ACPI tables
@@ -1824,29 +1809,29 @@ config DMAR_GFX_WA
1824 def_bool y 1809 def_bool y
1825 prompt "Support for Graphics workaround" 1810 prompt "Support for Graphics workaround"
1826 depends on DMAR 1811 depends on DMAR
1827 help 1812 ---help---
1828 Current Graphics drivers tend to use physical address 1813 Current Graphics drivers tend to use physical address
1829 for DMA and avoid using DMA APIs. Setting this config 1814 for DMA and avoid using DMA APIs. Setting this config
1830 option permits the IOMMU driver to set a unity map for 1815 option permits the IOMMU driver to set a unity map for
1831 all the OS-visible memory. Hence the driver can continue 1816 all the OS-visible memory. Hence the driver can continue
1832 to use physical addresses for DMA. 1817 to use physical addresses for DMA.
1833 1818
1834config DMAR_FLOPPY_WA 1819config DMAR_FLOPPY_WA
1835 def_bool y 1820 def_bool y
1836 depends on DMAR 1821 depends on DMAR
1837 help 1822 ---help---
1838 Floppy disk drivers are know to bypass DMA API calls 1823 Floppy disk drivers are know to bypass DMA API calls
1839 thereby failing to work when IOMMU is enabled. This 1824 thereby failing to work when IOMMU is enabled. This
1840 workaround will setup a 1:1 mapping for the first 1825 workaround will setup a 1:1 mapping for the first
1841 16M to make floppy (an ISA device) work. 1826 16M to make floppy (an ISA device) work.
1842 1827
1843config INTR_REMAP 1828config INTR_REMAP
1844 bool "Support for Interrupt Remapping (EXPERIMENTAL)" 1829 bool "Support for Interrupt Remapping (EXPERIMENTAL)"
1845 depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI && EXPERIMENTAL 1830 depends on X86_64 && X86_IO_APIC && PCI_MSI && ACPI && EXPERIMENTAL
1846 help 1831 ---help---
1847 Supports Interrupt remapping for IO-APIC and MSI devices. 1832 Supports Interrupt remapping for IO-APIC and MSI devices.
1848 To use x2apic mode in the CPU's which support x2APIC enhancements or 1833 To use x2apic mode in the CPU's which support x2APIC enhancements or
1849 to support platforms with CPU's having > 8 bit APIC ID, say Y. 1834 to support platforms with CPU's having > 8 bit APIC ID, say Y.
1850 1835
1851source "drivers/pci/pcie/Kconfig" 1836source "drivers/pci/pcie/Kconfig"
1852 1837
@@ -1860,8 +1845,7 @@ if X86_32
1860 1845
1861config ISA 1846config ISA
1862 bool "ISA support" 1847 bool "ISA support"
1863 depends on !X86_VOYAGER 1848 ---help---
1864 help
1865 Find out whether you have ISA slots on your motherboard. ISA is the 1849 Find out whether you have ISA slots on your motherboard. ISA is the
1866 name of a bus system, i.e. the way the CPU talks to the other stuff 1850 name of a bus system, i.e. the way the CPU talks to the other stuff
1867 inside your box. Other bus systems are PCI, EISA, MicroChannel 1851 inside your box. Other bus systems are PCI, EISA, MicroChannel
@@ -1887,9 +1871,8 @@ config EISA
1887source "drivers/eisa/Kconfig" 1871source "drivers/eisa/Kconfig"
1888 1872
1889config MCA 1873config MCA
1890 bool "MCA support" if !X86_VOYAGER 1874 bool "MCA support"
1891 default y if X86_VOYAGER 1875 ---help---
1892 help
1893 MicroChannel Architecture is found in some IBM PS/2 machines and 1876 MicroChannel Architecture is found in some IBM PS/2 machines and
1894 laptops. It is a bus system similar to PCI or ISA. See 1877 laptops. It is a bus system similar to PCI or ISA. See
1895 <file:Documentation/mca.txt> (and especially the web page given 1878 <file:Documentation/mca.txt> (and especially the web page given
@@ -1899,8 +1882,7 @@ source "drivers/mca/Kconfig"
1899 1882
1900config SCx200 1883config SCx200
1901 tristate "NatSemi SCx200 support" 1884 tristate "NatSemi SCx200 support"
1902 depends on !X86_VOYAGER 1885 ---help---
1903 help
1904 This provides basic support for National Semiconductor's 1886 This provides basic support for National Semiconductor's
1905 (now AMD's) Geode processors. The driver probes for the 1887 (now AMD's) Geode processors. The driver probes for the
1906 PCI-IDs of several on-chip devices, so its a good dependency 1888 PCI-IDs of several on-chip devices, so its a good dependency
@@ -1912,7 +1894,7 @@ config SCx200HR_TIMER
1912 tristate "NatSemi SCx200 27MHz High-Resolution Timer Support" 1894 tristate "NatSemi SCx200 27MHz High-Resolution Timer Support"
1913 depends on SCx200 && GENERIC_TIME 1895 depends on SCx200 && GENERIC_TIME
1914 default y 1896 default y
1915 help 1897 ---help---
1916 This driver provides a clocksource built upon the on-chip 1898 This driver provides a clocksource built upon the on-chip
1917 27MHz high-resolution timer. Its also a workaround for 1899 27MHz high-resolution timer. Its also a workaround for
1918 NSC Geode SC-1100's buggy TSC, which loses time when the 1900 NSC Geode SC-1100's buggy TSC, which loses time when the
@@ -1923,7 +1905,7 @@ config GEODE_MFGPT_TIMER
1923 def_bool y 1905 def_bool y
1924 prompt "Geode Multi-Function General Purpose Timer (MFGPT) events" 1906 prompt "Geode Multi-Function General Purpose Timer (MFGPT) events"
1925 depends on MGEODE_LX && GENERIC_TIME && GENERIC_CLOCKEVENTS 1907 depends on MGEODE_LX && GENERIC_TIME && GENERIC_CLOCKEVENTS
1926 help 1908 ---help---
1927 This driver provides a clock event source based on the MFGPT 1909 This driver provides a clock event source based on the MFGPT
1928 timer(s) in the CS5535 and CS5536 companion chip for the geode. 1910 timer(s) in the CS5535 and CS5536 companion chip for the geode.
1929 MFGPTs have a better resolution and max interval than the 1911 MFGPTs have a better resolution and max interval than the
@@ -1932,7 +1914,7 @@ config GEODE_MFGPT_TIMER
1932config OLPC 1914config OLPC
1933 bool "One Laptop Per Child support" 1915 bool "One Laptop Per Child support"
1934 default n 1916 default n
1935 help 1917 ---help---
1936 Add support for detecting the unique features of the OLPC 1918 Add support for detecting the unique features of the OLPC
1937 XO hardware. 1919 XO hardware.
1938 1920
@@ -1957,16 +1939,16 @@ config IA32_EMULATION
1957 bool "IA32 Emulation" 1939 bool "IA32 Emulation"
1958 depends on X86_64 1940 depends on X86_64
1959 select COMPAT_BINFMT_ELF 1941 select COMPAT_BINFMT_ELF
1960 help 1942 ---help---
1961 Include code to run 32-bit programs under a 64-bit kernel. You should 1943 Include code to run 32-bit programs under a 64-bit kernel. You should
1962 likely turn this on, unless you're 100% sure that you don't have any 1944 likely turn this on, unless you're 100% sure that you don't have any
1963 32-bit programs left. 1945 32-bit programs left.
1964 1946
1965config IA32_AOUT 1947config IA32_AOUT
1966 tristate "IA32 a.out support" 1948 tristate "IA32 a.out support"
1967 depends on IA32_EMULATION 1949 depends on IA32_EMULATION
1968 help 1950 ---help---
1969 Support old a.out binaries in the 32bit emulation. 1951 Support old a.out binaries in the 32bit emulation.
1970 1952
1971config COMPAT 1953config COMPAT
1972 def_bool y 1954 def_bool y
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 085fef4d866..a95eaf0e582 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -50,7 +50,7 @@ config M386
50config M486 50config M486
51 bool "486" 51 bool "486"
52 depends on X86_32 52 depends on X86_32
53 help 53 ---help---
54 Select this for a 486 series processor, either Intel or one of the 54 Select this for a 486 series processor, either Intel or one of the
55 compatible processors from AMD, Cyrix, IBM, or Intel. Includes DX, 55 compatible processors from AMD, Cyrix, IBM, or Intel. Includes DX,
56 DX2, and DX4 variants; also SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or 56 DX2, and DX4 variants; also SL/SLC/SLC2/SLC3/SX/SX2 and UMC U5D or
@@ -59,7 +59,7 @@ config M486
59config M586 59config M586
60 bool "586/K5/5x86/6x86/6x86MX" 60 bool "586/K5/5x86/6x86/6x86MX"
61 depends on X86_32 61 depends on X86_32
62 help 62 ---help---
63 Select this for an 586 or 686 series processor such as the AMD K5, 63 Select this for an 586 or 686 series processor such as the AMD K5,
64 the Cyrix 5x86, 6x86 and 6x86MX. This choice does not 64 the Cyrix 5x86, 6x86 and 6x86MX. This choice does not
65 assume the RDTSC (Read Time Stamp Counter) instruction. 65 assume the RDTSC (Read Time Stamp Counter) instruction.
@@ -67,21 +67,21 @@ config M586
67config M586TSC 67config M586TSC
68 bool "Pentium-Classic" 68 bool "Pentium-Classic"
69 depends on X86_32 69 depends on X86_32
70 help 70 ---help---
71 Select this for a Pentium Classic processor with the RDTSC (Read 71 Select this for a Pentium Classic processor with the RDTSC (Read
72 Time Stamp Counter) instruction for benchmarking. 72 Time Stamp Counter) instruction for benchmarking.
73 73
74config M586MMX 74config M586MMX
75 bool "Pentium-MMX" 75 bool "Pentium-MMX"
76 depends on X86_32 76 depends on X86_32
77 help 77 ---help---
78 Select this for a Pentium with the MMX graphics/multimedia 78 Select this for a Pentium with the MMX graphics/multimedia
79 extended instructions. 79 extended instructions.
80 80
81config M686 81config M686
82 bool "Pentium-Pro" 82 bool "Pentium-Pro"
83 depends on X86_32 83 depends on X86_32
84 help 84 ---help---
85 Select this for Intel Pentium Pro chips. This enables the use of 85 Select this for Intel Pentium Pro chips. This enables the use of
86 Pentium Pro extended instructions, and disables the init-time guard 86 Pentium Pro extended instructions, and disables the init-time guard
87 against the f00f bug found in earlier Pentiums. 87 against the f00f bug found in earlier Pentiums.
@@ -89,7 +89,7 @@ config M686
89config MPENTIUMII 89config MPENTIUMII
90 bool "Pentium-II/Celeron(pre-Coppermine)" 90 bool "Pentium-II/Celeron(pre-Coppermine)"
91 depends on X86_32 91 depends on X86_32
92 help 92 ---help---
93 Select this for Intel chips based on the Pentium-II and 93 Select this for Intel chips based on the Pentium-II and
94 pre-Coppermine Celeron core. This option enables an unaligned 94 pre-Coppermine Celeron core. This option enables an unaligned
95 copy optimization, compiles the kernel with optimization flags 95 copy optimization, compiles the kernel with optimization flags
@@ -99,7 +99,7 @@ config MPENTIUMII
99config MPENTIUMIII 99config MPENTIUMIII
100 bool "Pentium-III/Celeron(Coppermine)/Pentium-III Xeon" 100 bool "Pentium-III/Celeron(Coppermine)/Pentium-III Xeon"
101 depends on X86_32 101 depends on X86_32
102 help 102 ---help---
103 Select this for Intel chips based on the Pentium-III and 103 Select this for Intel chips based on the Pentium-III and
104 Celeron-Coppermine core. This option enables use of some 104 Celeron-Coppermine core. This option enables use of some
105 extended prefetch instructions in addition to the Pentium II 105 extended prefetch instructions in addition to the Pentium II
@@ -108,14 +108,14 @@ config MPENTIUMIII
108config MPENTIUMM 108config MPENTIUMM
109 bool "Pentium M" 109 bool "Pentium M"
110 depends on X86_32 110 depends on X86_32
111 help 111 ---help---
112 Select this for Intel Pentium M (not Pentium-4 M) 112 Select this for Intel Pentium M (not Pentium-4 M)
113 notebook chips. 113 notebook chips.
114 114
115config MPENTIUM4 115config MPENTIUM4
116 bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon" 116 bool "Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon"
117 depends on X86_32 117 depends on X86_32
118 help 118 ---help---
119 Select this for Intel Pentium 4 chips. This includes the 119 Select this for Intel Pentium 4 chips. This includes the
120 Pentium 4, Pentium D, P4-based Celeron and Xeon, and 120 Pentium 4, Pentium D, P4-based Celeron and Xeon, and
121 Pentium-4 M (not Pentium M) chips. This option enables compile 121 Pentium-4 M (not Pentium M) chips. This option enables compile
@@ -151,7 +151,7 @@ config MPENTIUM4
151config MK6 151config MK6
152 bool "K6/K6-II/K6-III" 152 bool "K6/K6-II/K6-III"
153 depends on X86_32 153 depends on X86_32
154 help 154 ---help---
155 Select this for an AMD K6-family processor. Enables use of 155 Select this for an AMD K6-family processor. Enables use of
156 some extended instructions, and passes appropriate optimization 156 some extended instructions, and passes appropriate optimization
157 flags to GCC. 157 flags to GCC.
@@ -159,14 +159,14 @@ config MK6
159config MK7 159config MK7
160 bool "Athlon/Duron/K7" 160 bool "Athlon/Duron/K7"
161 depends on X86_32 161 depends on X86_32
162 help 162 ---help---
163 Select this for an AMD Athlon K7-family processor. Enables use of 163 Select this for an AMD Athlon K7-family processor. Enables use of
164 some extended instructions, and passes appropriate optimization 164 some extended instructions, and passes appropriate optimization
165 flags to GCC. 165 flags to GCC.
166 166
167config MK8 167config MK8
168 bool "Opteron/Athlon64/Hammer/K8" 168 bool "Opteron/Athlon64/Hammer/K8"
169 help 169 ---help---
170 Select this for an AMD Opteron or Athlon64 Hammer-family processor. 170 Select this for an AMD Opteron or Athlon64 Hammer-family processor.
171 Enables use of some extended instructions, and passes appropriate 171 Enables use of some extended instructions, and passes appropriate
172 optimization flags to GCC. 172 optimization flags to GCC.
@@ -174,7 +174,7 @@ config MK8
174config MCRUSOE 174config MCRUSOE
175 bool "Crusoe" 175 bool "Crusoe"
176 depends on X86_32 176 depends on X86_32
177 help 177 ---help---
178 Select this for a Transmeta Crusoe processor. Treats the processor 178 Select this for a Transmeta Crusoe processor. Treats the processor
179 like a 586 with TSC, and sets some GCC optimization flags (like a 179 like a 586 with TSC, and sets some GCC optimization flags (like a
180 Pentium Pro with no alignment requirements). 180 Pentium Pro with no alignment requirements).
@@ -182,13 +182,13 @@ config MCRUSOE
182config MEFFICEON 182config MEFFICEON
183 bool "Efficeon" 183 bool "Efficeon"
184 depends on X86_32 184 depends on X86_32
185 help 185 ---help---
186 Select this for a Transmeta Efficeon processor. 186 Select this for a Transmeta Efficeon processor.
187 187
188config MWINCHIPC6 188config MWINCHIPC6
189 bool "Winchip-C6" 189 bool "Winchip-C6"
190 depends on X86_32 190 depends on X86_32
191 help 191 ---help---
192 Select this for an IDT Winchip C6 chip. Linux and GCC 192 Select this for an IDT Winchip C6 chip. Linux and GCC
193 treat this chip as a 586TSC with some extended instructions 193 treat this chip as a 586TSC with some extended instructions
194 and alignment requirements. 194 and alignment requirements.
@@ -196,7 +196,7 @@ config MWINCHIPC6
196config MWINCHIP3D 196config MWINCHIP3D
197 bool "Winchip-2/Winchip-2A/Winchip-3" 197 bool "Winchip-2/Winchip-2A/Winchip-3"
198 depends on X86_32 198 depends on X86_32
199 help 199 ---help---
200 Select this for an IDT Winchip-2, 2A or 3. Linux and GCC 200 Select this for an IDT Winchip-2, 2A or 3. Linux and GCC
201 treat this chip as a 586TSC with some extended instructions 201 treat this chip as a 586TSC with some extended instructions
202 and alignment requirements. Also enable out of order memory 202 and alignment requirements. Also enable out of order memory
@@ -206,19 +206,19 @@ config MWINCHIP3D
206config MGEODEGX1 206config MGEODEGX1
207 bool "GeodeGX1" 207 bool "GeodeGX1"
208 depends on X86_32 208 depends on X86_32
209 help 209 ---help---
210 Select this for a Geode GX1 (Cyrix MediaGX) chip. 210 Select this for a Geode GX1 (Cyrix MediaGX) chip.
211 211
212config MGEODE_LX 212config MGEODE_LX
213 bool "Geode GX/LX" 213 bool "Geode GX/LX"
214 depends on X86_32 214 depends on X86_32
215 help 215 ---help---
216 Select this for AMD Geode GX and LX processors. 216 Select this for AMD Geode GX and LX processors.
217 217
218config MCYRIXIII 218config MCYRIXIII
219 bool "CyrixIII/VIA-C3" 219 bool "CyrixIII/VIA-C3"
220 depends on X86_32 220 depends on X86_32
221 help 221 ---help---
222 Select this for a Cyrix III or C3 chip. Presently Linux and GCC 222 Select this for a Cyrix III or C3 chip. Presently Linux and GCC
223 treat this chip as a generic 586. Whilst the CPU is 686 class, 223 treat this chip as a generic 586. Whilst the CPU is 686 class,
224 it lacks the cmov extension which gcc assumes is present when 224 it lacks the cmov extension which gcc assumes is present when
@@ -230,7 +230,7 @@ config MCYRIXIII
230config MVIAC3_2 230config MVIAC3_2
231 bool "VIA C3-2 (Nehemiah)" 231 bool "VIA C3-2 (Nehemiah)"
232 depends on X86_32 232 depends on X86_32
233 help 233 ---help---
234 Select this for a VIA C3 "Nehemiah". Selecting this enables usage 234 Select this for a VIA C3 "Nehemiah". Selecting this enables usage
235 of SSE and tells gcc to treat the CPU as a 686. 235 of SSE and tells gcc to treat the CPU as a 686.
236 Note, this kernel will not boot on older (pre model 9) C3s. 236 Note, this kernel will not boot on older (pre model 9) C3s.
@@ -238,14 +238,14 @@ config MVIAC3_2
238config MVIAC7 238config MVIAC7
239 bool "VIA C7" 239 bool "VIA C7"
240 depends on X86_32 240 depends on X86_32
241 help 241 ---help---
242 Select this for a VIA C7. Selecting this uses the correct cache 242 Select this for a VIA C7. Selecting this uses the correct cache
243 shift and tells gcc to treat the CPU as a 686. 243 shift and tells gcc to treat the CPU as a 686.
244 244
245config MPSC 245config MPSC
246 bool "Intel P4 / older Netburst based Xeon" 246 bool "Intel P4 / older Netburst based Xeon"
247 depends on X86_64 247 depends on X86_64
248 help 248 ---help---
249 Optimize for Intel Pentium 4, Pentium D and older Nocona/Dempsey 249 Optimize for Intel Pentium 4, Pentium D and older Nocona/Dempsey
250 Xeon CPUs with Intel 64bit which is compatible with x86-64. 250 Xeon CPUs with Intel 64bit which is compatible with x86-64.
251 Note that the latest Xeons (Xeon 51xx and 53xx) are not based on the 251 Note that the latest Xeons (Xeon 51xx and 53xx) are not based on the
@@ -255,7 +255,7 @@ config MPSC
255 255
256config MCORE2 256config MCORE2
257 bool "Core 2/newer Xeon" 257 bool "Core 2/newer Xeon"
258 help 258 ---help---
259 259
260 Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and 260 Select this for Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and
261 53xx) CPUs. You can distinguish newer from older Xeons by the CPU 261 53xx) CPUs. You can distinguish newer from older Xeons by the CPU
@@ -265,7 +265,7 @@ config MCORE2
265config GENERIC_CPU 265config GENERIC_CPU
266 bool "Generic-x86-64" 266 bool "Generic-x86-64"
267 depends on X86_64 267 depends on X86_64
268 help 268 ---help---
269 Generic x86-64 CPU. 269 Generic x86-64 CPU.
270 Run equally well on all x86-64 CPUs. 270 Run equally well on all x86-64 CPUs.
271 271
@@ -274,7 +274,7 @@ endchoice
274config X86_GENERIC 274config X86_GENERIC
275 bool "Generic x86 support" 275 bool "Generic x86 support"
276 depends on X86_32 276 depends on X86_32
277 help 277 ---help---
278 Instead of just including optimizations for the selected 278 Instead of just including optimizations for the selected
279 x86 variant (e.g. PII, Crusoe or Athlon), include some more 279 x86 variant (e.g. PII, Crusoe or Athlon), include some more
280 generic optimizations as well. This will make the kernel 280 generic optimizations as well. This will make the kernel
@@ -319,7 +319,7 @@ config X86_XADD
319config X86_PPRO_FENCE 319config X86_PPRO_FENCE
320 bool "PentiumPro memory ordering errata workaround" 320 bool "PentiumPro memory ordering errata workaround"
321 depends on M686 || M586MMX || M586TSC || M586 || M486 || M386 || MGEODEGX1 321 depends on M686 || M586MMX || M586TSC || M586 || M486 || M386 || MGEODEGX1
322 help 322 ---help---
323 Old PentiumPro multiprocessor systems had errata that could cause 323 Old PentiumPro multiprocessor systems had errata that could cause
324 memory operations to violate the x86 ordering standard in rare cases. 324 memory operations to violate the x86 ordering standard in rare cases.
325 Enabling this option will attempt to work around some (but not all) 325 Enabling this option will attempt to work around some (but not all)
@@ -412,14 +412,14 @@ config X86_DEBUGCTLMSR
412 412
413menuconfig PROCESSOR_SELECT 413menuconfig PROCESSOR_SELECT
414 bool "Supported processor vendors" if EMBEDDED 414 bool "Supported processor vendors" if EMBEDDED
415 help 415 ---help---
416 This lets you choose what x86 vendor support code your kernel 416 This lets you choose what x86 vendor support code your kernel
417 will include. 417 will include.
418 418
419config CPU_SUP_INTEL 419config CPU_SUP_INTEL
420 default y 420 default y
421 bool "Support Intel processors" if PROCESSOR_SELECT 421 bool "Support Intel processors" if PROCESSOR_SELECT
422 help 422 ---help---
423 This enables detection, tunings and quirks for Intel processors 423 This enables detection, tunings and quirks for Intel processors
424 424
425 You need this enabled if you want your kernel to run on an 425 You need this enabled if you want your kernel to run on an
@@ -433,7 +433,7 @@ config CPU_SUP_CYRIX_32
433 default y 433 default y
434 bool "Support Cyrix processors" if PROCESSOR_SELECT 434 bool "Support Cyrix processors" if PROCESSOR_SELECT
435 depends on !64BIT 435 depends on !64BIT
436 help 436 ---help---
437 This enables detection, tunings and quirks for Cyrix processors 437 This enables detection, tunings and quirks for Cyrix processors
438 438
439 You need this enabled if you want your kernel to run on a 439 You need this enabled if you want your kernel to run on a
@@ -446,7 +446,7 @@ config CPU_SUP_CYRIX_32
446config CPU_SUP_AMD 446config CPU_SUP_AMD
447 default y 447 default y
448 bool "Support AMD processors" if PROCESSOR_SELECT 448 bool "Support AMD processors" if PROCESSOR_SELECT
449 help 449 ---help---
450 This enables detection, tunings and quirks for AMD processors 450 This enables detection, tunings and quirks for AMD processors
451 451
452 You need this enabled if you want your kernel to run on an 452 You need this enabled if you want your kernel to run on an
@@ -460,7 +460,7 @@ config CPU_SUP_CENTAUR_32
460 default y 460 default y
461 bool "Support Centaur processors" if PROCESSOR_SELECT 461 bool "Support Centaur processors" if PROCESSOR_SELECT
462 depends on !64BIT 462 depends on !64BIT
463 help 463 ---help---
464 This enables detection, tunings and quirks for Centaur processors 464 This enables detection, tunings and quirks for Centaur processors
465 465
466 You need this enabled if you want your kernel to run on a 466 You need this enabled if you want your kernel to run on a
@@ -474,7 +474,7 @@ config CPU_SUP_CENTAUR_64
474 default y 474 default y
475 bool "Support Centaur processors" if PROCESSOR_SELECT 475 bool "Support Centaur processors" if PROCESSOR_SELECT
476 depends on 64BIT 476 depends on 64BIT
477 help 477 ---help---
478 This enables detection, tunings and quirks for Centaur processors 478 This enables detection, tunings and quirks for Centaur processors
479 479
480 You need this enabled if you want your kernel to run on a 480 You need this enabled if you want your kernel to run on a
@@ -488,7 +488,7 @@ config CPU_SUP_TRANSMETA_32
488 default y 488 default y
489 bool "Support Transmeta processors" if PROCESSOR_SELECT 489 bool "Support Transmeta processors" if PROCESSOR_SELECT
490 depends on !64BIT 490 depends on !64BIT
491 help 491 ---help---
492 This enables detection, tunings and quirks for Transmeta processors 492 This enables detection, tunings and quirks for Transmeta processors
493 493
494 You need this enabled if you want your kernel to run on a 494 You need this enabled if you want your kernel to run on a
@@ -502,7 +502,7 @@ config CPU_SUP_UMC_32
502 default y 502 default y
503 bool "Support UMC processors" if PROCESSOR_SELECT 503 bool "Support UMC processors" if PROCESSOR_SELECT
504 depends on !64BIT 504 depends on !64BIT
505 help 505 ---help---
506 This enables detection, tunings and quirks for UMC processors 506 This enables detection, tunings and quirks for UMC processors
507 507
508 You need this enabled if you want your kernel to run on a 508 You need this enabled if you want your kernel to run on a
@@ -521,7 +521,7 @@ config X86_PTRACE_BTS
521 bool "Branch Trace Store" 521 bool "Branch Trace Store"
522 default y 522 default y
523 depends on X86_DEBUGCTLMSR 523 depends on X86_DEBUGCTLMSR
524 help 524 ---help---
525 This adds a ptrace interface to the hardware's branch trace store. 525 This adds a ptrace interface to the hardware's branch trace store.
526 526
527 Debuggers may use it to collect an execution trace of the debugged 527 Debuggers may use it to collect an execution trace of the debugged
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 28f111461ca..ba4781b9389 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -7,7 +7,7 @@ source "lib/Kconfig.debug"
7 7
8config STRICT_DEVMEM 8config STRICT_DEVMEM
9 bool "Filter access to /dev/mem" 9 bool "Filter access to /dev/mem"
10 help 10 ---help---
11 If this option is disabled, you allow userspace (root) access to all 11 If this option is disabled, you allow userspace (root) access to all
12 of memory, including kernel and userspace memory. Accidental 12 of memory, including kernel and userspace memory. Accidental
13 access to this is obviously disastrous, but specific access can 13 access to this is obviously disastrous, but specific access can
@@ -25,7 +25,7 @@ config STRICT_DEVMEM
25config X86_VERBOSE_BOOTUP 25config X86_VERBOSE_BOOTUP
26 bool "Enable verbose x86 bootup info messages" 26 bool "Enable verbose x86 bootup info messages"
27 default y 27 default y
28 help 28 ---help---
29 Enables the informational output from the decompression stage 29 Enables the informational output from the decompression stage
30 (e.g. bzImage) of the boot. If you disable this you will still 30 (e.g. bzImage) of the boot. If you disable this you will still
31 see errors. Disable this if you want silent bootup. 31 see errors. Disable this if you want silent bootup.
@@ -33,7 +33,7 @@ config X86_VERBOSE_BOOTUP
33config EARLY_PRINTK 33config EARLY_PRINTK
34 bool "Early printk" if EMBEDDED 34 bool "Early printk" if EMBEDDED
35 default y 35 default y
36 help 36 ---help---
37 Write kernel log output directly into the VGA buffer or to a serial 37 Write kernel log output directly into the VGA buffer or to a serial
38 port. 38 port.
39 39
@@ -47,7 +47,7 @@ config EARLY_PRINTK_DBGP
47 bool "Early printk via EHCI debug port" 47 bool "Early printk via EHCI debug port"
48 default n 48 default n
49 depends on EARLY_PRINTK && PCI 49 depends on EARLY_PRINTK && PCI
50 help 50 ---help---
51 Write kernel log output directly into the EHCI debug port. 51 Write kernel log output directly into the EHCI debug port.
52 52
53 This is useful for kernel debugging when your machine crashes very 53 This is useful for kernel debugging when your machine crashes very
@@ -59,14 +59,14 @@ config EARLY_PRINTK_DBGP
59config DEBUG_STACKOVERFLOW 59config DEBUG_STACKOVERFLOW
60 bool "Check for stack overflows" 60 bool "Check for stack overflows"
61 depends on DEBUG_KERNEL 61 depends on DEBUG_KERNEL
62 help 62 ---help---
63 This option will cause messages to be printed if free stack space 63 This option will cause messages to be printed if free stack space
64 drops below a certain limit. 64 drops below a certain limit.
65 65
66config DEBUG_STACK_USAGE 66config DEBUG_STACK_USAGE
67 bool "Stack utilization instrumentation" 67 bool "Stack utilization instrumentation"
68 depends on DEBUG_KERNEL 68 depends on DEBUG_KERNEL
69 help 69 ---help---
70 Enables the display of the minimum amount of free stack which each 70 Enables the display of the minimum amount of free stack which each
71 task has ever had available in the sysrq-T and sysrq-P debug output. 71 task has ever had available in the sysrq-T and sysrq-P debug output.
72 72
@@ -75,7 +75,7 @@ config DEBUG_STACK_USAGE
75config DEBUG_PAGEALLOC 75config DEBUG_PAGEALLOC
76 bool "Debug page memory allocations" 76 bool "Debug page memory allocations"
77 depends on DEBUG_KERNEL 77 depends on DEBUG_KERNEL
78 help 78 ---help---
79 Unmap pages from the kernel linear mapping after free_pages(). 79 Unmap pages from the kernel linear mapping after free_pages().
80 This results in a large slowdown, but helps to find certain types 80 This results in a large slowdown, but helps to find certain types
81 of memory corruptions. 81 of memory corruptions.
@@ -83,9 +83,9 @@ config DEBUG_PAGEALLOC
83config DEBUG_PER_CPU_MAPS 83config DEBUG_PER_CPU_MAPS
84 bool "Debug access to per_cpu maps" 84 bool "Debug access to per_cpu maps"
85 depends on DEBUG_KERNEL 85 depends on DEBUG_KERNEL
86 depends on X86_SMP 86 depends on SMP
87 default n 87 default n
88 help 88 ---help---
89 Say Y to verify that the per_cpu map being accessed has 89 Say Y to verify that the per_cpu map being accessed has
90 been setup. Adds a fair amount of code to kernel memory 90 been setup. Adds a fair amount of code to kernel memory
91 and decreases performance. 91 and decreases performance.
@@ -96,7 +96,7 @@ config X86_PTDUMP
96 bool "Export kernel pagetable layout to userspace via debugfs" 96 bool "Export kernel pagetable layout to userspace via debugfs"
97 depends on DEBUG_KERNEL 97 depends on DEBUG_KERNEL
98 select DEBUG_FS 98 select DEBUG_FS
99 help 99 ---help---
100 Say Y here if you want to show the kernel pagetable layout in a 100 Say Y here if you want to show the kernel pagetable layout in a
101 debugfs file. This information is only useful for kernel developers 101 debugfs file. This information is only useful for kernel developers
102 who are working in architecture specific areas of the kernel. 102 who are working in architecture specific areas of the kernel.
@@ -108,7 +108,7 @@ config DEBUG_RODATA
108 bool "Write protect kernel read-only data structures" 108 bool "Write protect kernel read-only data structures"
109 default y 109 default y
110 depends on DEBUG_KERNEL 110 depends on DEBUG_KERNEL
111 help 111 ---help---
112 Mark the kernel read-only data as write-protected in the pagetables, 112 Mark the kernel read-only data as write-protected in the pagetables,
113 in order to catch accidental (and incorrect) writes to such const 113 in order to catch accidental (and incorrect) writes to such const
114 data. This is recommended so that we can catch kernel bugs sooner. 114 data. This is recommended so that we can catch kernel bugs sooner.
@@ -118,7 +118,7 @@ config DEBUG_RODATA_TEST
118 bool "Testcase for the DEBUG_RODATA feature" 118 bool "Testcase for the DEBUG_RODATA feature"
119 depends on DEBUG_RODATA 119 depends on DEBUG_RODATA
120 default y 120 default y
121 help 121 ---help---
122 This option enables a testcase for the DEBUG_RODATA 122 This option enables a testcase for the DEBUG_RODATA
123 feature as well as for the change_page_attr() infrastructure. 123 feature as well as for the change_page_attr() infrastructure.
124 If in doubt, say "N" 124 If in doubt, say "N"
@@ -126,7 +126,7 @@ config DEBUG_RODATA_TEST
126config DEBUG_NX_TEST 126config DEBUG_NX_TEST
127 tristate "Testcase for the NX non-executable stack feature" 127 tristate "Testcase for the NX non-executable stack feature"
128 depends on DEBUG_KERNEL && m 128 depends on DEBUG_KERNEL && m
129 help 129 ---help---
130 This option enables a testcase for the CPU NX capability 130 This option enables a testcase for the CPU NX capability
131 and the software setup of this feature. 131 and the software setup of this feature.
132 If in doubt, say "N" 132 If in doubt, say "N"
@@ -134,7 +134,7 @@ config DEBUG_NX_TEST
134config 4KSTACKS 134config 4KSTACKS
135 bool "Use 4Kb for kernel stacks instead of 8Kb" 135 bool "Use 4Kb for kernel stacks instead of 8Kb"
136 depends on X86_32 136 depends on X86_32
137 help 137 ---help---
138 If you say Y here the kernel will use a 4Kb stacksize for the 138 If you say Y here the kernel will use a 4Kb stacksize for the
139 kernel stack attached to each process/thread. This facilitates 139 kernel stack attached to each process/thread. This facilitates
140 running more threads on a system and also reduces the pressure 140 running more threads on a system and also reduces the pressure
@@ -145,7 +145,7 @@ config DOUBLEFAULT
145 default y 145 default y
146 bool "Enable doublefault exception handler" if EMBEDDED 146 bool "Enable doublefault exception handler" if EMBEDDED
147 depends on X86_32 147 depends on X86_32
148 help 148 ---help---
149 This option allows trapping of rare doublefault exceptions that 149 This option allows trapping of rare doublefault exceptions that
150 would otherwise cause a system to silently reboot. Disabling this 150 would otherwise cause a system to silently reboot. Disabling this
151 option saves about 4k and might cause you much additional grey 151 option saves about 4k and might cause you much additional grey
@@ -155,7 +155,7 @@ config IOMMU_DEBUG
155 bool "Enable IOMMU debugging" 155 bool "Enable IOMMU debugging"
156 depends on GART_IOMMU && DEBUG_KERNEL 156 depends on GART_IOMMU && DEBUG_KERNEL
157 depends on X86_64 157 depends on X86_64
158 help 158 ---help---
159 Force the IOMMU to on even when you have less than 4GB of 159 Force the IOMMU to on even when you have less than 4GB of
160 memory and add debugging code. On overflow always panic. And 160 memory and add debugging code. On overflow always panic. And
161 allow to enable IOMMU leak tracing. Can be disabled at boot 161 allow to enable IOMMU leak tracing. Can be disabled at boot
@@ -171,7 +171,7 @@ config IOMMU_LEAK
171 bool "IOMMU leak tracing" 171 bool "IOMMU leak tracing"
172 depends on DEBUG_KERNEL 172 depends on DEBUG_KERNEL
173 depends on IOMMU_DEBUG 173 depends on IOMMU_DEBUG
174 help 174 ---help---
175 Add a simple leak tracer to the IOMMU code. This is useful when you 175 Add a simple leak tracer to the IOMMU code. This is useful when you
176 are debugging a buggy device driver that leaks IOMMU mappings. 176 are debugging a buggy device driver that leaks IOMMU mappings.
177 177
@@ -224,25 +224,25 @@ choice
224 224
225config IO_DELAY_0X80 225config IO_DELAY_0X80
226 bool "port 0x80 based port-IO delay [recommended]" 226 bool "port 0x80 based port-IO delay [recommended]"
227 help 227 ---help---
228 This is the traditional Linux IO delay used for in/out_p. 228 This is the traditional Linux IO delay used for in/out_p.
229 It is the most tested hence safest selection here. 229 It is the most tested hence safest selection here.
230 230
231config IO_DELAY_0XED 231config IO_DELAY_0XED
232 bool "port 0xed based port-IO delay" 232 bool "port 0xed based port-IO delay"
233 help 233 ---help---
234 Use port 0xed as the IO delay. This frees up port 0x80 which is 234 Use port 0xed as the IO delay. This frees up port 0x80 which is
235 often used as a hardware-debug port. 235 often used as a hardware-debug port.
236 236
237config IO_DELAY_UDELAY 237config IO_DELAY_UDELAY
238 bool "udelay based port-IO delay" 238 bool "udelay based port-IO delay"
239 help 239 ---help---
240 Use udelay(2) as the IO delay method. This provides the delay 240 Use udelay(2) as the IO delay method. This provides the delay
241 while not having any side-effect on the IO port space. 241 while not having any side-effect on the IO port space.
242 242
243config IO_DELAY_NONE 243config IO_DELAY_NONE
244 bool "no port-IO delay" 244 bool "no port-IO delay"
245 help 245 ---help---
246 No port-IO delay. Will break on old boxes that require port-IO 246 No port-IO delay. Will break on old boxes that require port-IO
247 delay for certain operations. Should work on most new machines. 247 delay for certain operations. Should work on most new machines.
248 248
@@ -276,18 +276,18 @@ config DEBUG_BOOT_PARAMS
276 bool "Debug boot parameters" 276 bool "Debug boot parameters"
277 depends on DEBUG_KERNEL 277 depends on DEBUG_KERNEL
278 depends on DEBUG_FS 278 depends on DEBUG_FS
279 help 279 ---help---
280 This option will cause struct boot_params to be exported via debugfs. 280 This option will cause struct boot_params to be exported via debugfs.
281 281
282config CPA_DEBUG 282config CPA_DEBUG
283 bool "CPA self-test code" 283 bool "CPA self-test code"
284 depends on DEBUG_KERNEL 284 depends on DEBUG_KERNEL
285 help 285 ---help---
286 Do change_page_attr() self-tests every 30 seconds. 286 Do change_page_attr() self-tests every 30 seconds.
287 287
288config OPTIMIZE_INLINING 288config OPTIMIZE_INLINING
289 bool "Allow gcc to uninline functions marked 'inline'" 289 bool "Allow gcc to uninline functions marked 'inline'"
290 help 290 ---help---
291 This option determines if the kernel forces gcc to inline the functions 291 This option determines if the kernel forces gcc to inline the functions
292 developers have marked 'inline'. Doing so takes away freedom from gcc to 292 developers have marked 'inline'. Doing so takes away freedom from gcc to
293 do what it thinks is best, which is desirable for the gcc 3.x series of 293 do what it thinks is best, which is desirable for the gcc 3.x series of
@@ -300,4 +300,3 @@ config OPTIMIZE_INLINING
300 If unsure, say N. 300 If unsure, say N.
301 301
302endmenu 302endmenu
303
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index ab48ab497e5..1836191839e 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -105,29 +105,6 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
105# prevent gcc from generating any FP code by mistake 105# prevent gcc from generating any FP code by mistake
106KBUILD_CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,) 106KBUILD_CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
107 107
108###
109# Sub architecture support
110# fcore-y is linked before mcore-y files.
111
112# Default subarch .c files
113mcore-y := arch/x86/mach-default/
114
115# Voyager subarch support
116mflags-$(CONFIG_X86_VOYAGER) := -Iarch/x86/include/asm/mach-voyager
117mcore-$(CONFIG_X86_VOYAGER) := arch/x86/mach-voyager/
118
119# generic subarchitecture
120mflags-$(CONFIG_X86_GENERICARCH):= -Iarch/x86/include/asm/mach-generic
121fcore-$(CONFIG_X86_GENERICARCH) += arch/x86/mach-generic/
122mcore-$(CONFIG_X86_GENERICARCH) := arch/x86/mach-default/
123
124# default subarch .h files
125mflags-y += -Iarch/x86/include/asm/mach-default
126
127# 64 bit does not support subarch support - clear sub arch variables
128fcore-$(CONFIG_X86_64) :=
129mcore-$(CONFIG_X86_64) :=
130
131KBUILD_CFLAGS += $(mflags-y) 108KBUILD_CFLAGS += $(mflags-y)
132KBUILD_AFLAGS += $(mflags-y) 109KBUILD_AFLAGS += $(mflags-y)
133 110
@@ -153,9 +130,6 @@ core-$(CONFIG_LGUEST_GUEST) += arch/x86/lguest/
153core-y += arch/x86/kernel/ 130core-y += arch/x86/kernel/
154core-y += arch/x86/mm/ 131core-y += arch/x86/mm/
155 132
156# Remaining sub architecture files
157core-y += $(mcore-y)
158
159core-y += arch/x86/crypto/ 133core-y += arch/x86/crypto/
160core-y += arch/x86/vdso/ 134core-y += arch/x86/vdso/
161core-$(CONFIG_IA32_EMULATION) += arch/x86/ia32/ 135core-$(CONFIG_IA32_EMULATION) += arch/x86/ia32/
diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig
index edba00d98ac..739bce993b5 100644
--- a/arch/x86/configs/i386_defconfig
+++ b/arch/x86/configs/i386_defconfig
@@ -188,7 +188,6 @@ CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
188CONFIG_SMP=y 188CONFIG_SMP=y
189CONFIG_X86_FIND_SMP_CONFIG=y 189CONFIG_X86_FIND_SMP_CONFIG=y
190CONFIG_X86_MPPARSE=y 190CONFIG_X86_MPPARSE=y
191CONFIG_X86_PC=y
192# CONFIG_X86_ELAN is not set 191# CONFIG_X86_ELAN is not set
193# CONFIG_X86_VOYAGER is not set 192# CONFIG_X86_VOYAGER is not set
194# CONFIG_X86_GENERICARCH is not set 193# CONFIG_X86_GENERICARCH is not set
diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig
index 322dd2748fc..02b514e8f4c 100644
--- a/arch/x86/configs/x86_64_defconfig
+++ b/arch/x86/configs/x86_64_defconfig
@@ -187,7 +187,6 @@ CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
187CONFIG_SMP=y 187CONFIG_SMP=y
188CONFIG_X86_FIND_SMP_CONFIG=y 188CONFIG_X86_FIND_SMP_CONFIG=y
189CONFIG_X86_MPPARSE=y 189CONFIG_X86_MPPARSE=y
190CONFIG_X86_PC=y
191# CONFIG_X86_ELAN is not set 190# CONFIG_X86_ELAN is not set
192# CONFIG_X86_VOYAGER is not set 191# CONFIG_X86_VOYAGER is not set
193# CONFIG_X86_GENERICARCH is not set 192# CONFIG_X86_GENERICARCH is not set
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index ab1d51a8855..fba49f66228 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -33,7 +33,13 @@
33 } while (0) 33 } while (0)
34 34
35 35
36#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
36extern void generic_apic_probe(void); 37extern void generic_apic_probe(void);
38#else
39static inline void generic_apic_probe(void)
40{
41}
42#endif
37 43
38#ifdef CONFIG_X86_LOCAL_APIC 44#ifdef CONFIG_X86_LOCAL_APIC
39 45
@@ -41,6 +47,21 @@ extern unsigned int apic_verbosity;
41extern int local_apic_timer_c2_ok; 47extern int local_apic_timer_c2_ok;
42 48
43extern int disable_apic; 49extern int disable_apic;
50
51#ifdef CONFIG_SMP
52extern void __inquire_remote_apic(int apicid);
53#else /* CONFIG_SMP */
54static inline void __inquire_remote_apic(int apicid)
55{
56}
57#endif /* CONFIG_SMP */
58
59static inline void default_inquire_remote_apic(int apicid)
60{
61 if (apic_verbosity >= APIC_DEBUG)
62 __inquire_remote_apic(apicid);
63}
64
44/* 65/*
45 * Basic functions accessing APICs. 66 * Basic functions accessing APICs.
46 */ 67 */
@@ -124,12 +145,35 @@ struct apic_ops {
124 145
125extern struct apic_ops *apic_ops; 146extern struct apic_ops *apic_ops;
126 147
127#define apic_read (apic_ops->read) 148static inline u32 apic_read(u32 reg)
128#define apic_write (apic_ops->write) 149{
129#define apic_icr_read (apic_ops->icr_read) 150 return apic_ops->read(reg);
130#define apic_icr_write (apic_ops->icr_write) 151}
131#define apic_wait_icr_idle (apic_ops->wait_icr_idle) 152
132#define safe_apic_wait_icr_idle (apic_ops->safe_wait_icr_idle) 153static inline void apic_write(u32 reg, u32 val)
154{
155 apic_ops->write(reg, val);
156}
157
158static inline u64 apic_icr_read(void)
159{
160 return apic_ops->icr_read();
161}
162
163static inline void apic_icr_write(u32 low, u32 high)
164{
165 apic_ops->icr_write(low, high);
166}
167
168static inline void apic_wait_icr_idle(void)
169{
170 apic_ops->wait_icr_idle();
171}
172
173static inline u32 safe_apic_wait_icr_idle(void)
174{
175 return apic_ops->safe_wait_icr_idle();
176}
133 177
134extern int get_physical_broadcast(void); 178extern int get_physical_broadcast(void);
135 179
@@ -196,4 +240,22 @@ static inline void disable_local_APIC(void) { }
196 240
197#endif /* !CONFIG_X86_LOCAL_APIC */ 241#endif /* !CONFIG_X86_LOCAL_APIC */
198 242
243#ifdef CONFIG_X86_64
244#define SET_APIC_ID(x) (apic->set_apic_id(x))
245#else
246
247#ifdef CONFIG_X86_LOCAL_APIC
248static inline unsigned default_get_apic_id(unsigned long x)
249{
250 unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
251
252 if (APIC_XAPIC(ver))
253 return (x >> 24) & 0xFF;
254 else
255 return (x >> 24) & 0x0F;
256}
257#endif
258
259#endif
260
199#endif /* _ASM_X86_APIC_H */ 261#endif /* _ASM_X86_APIC_H */
diff --git a/arch/x86/include/asm/mach-default/apm.h b/arch/x86/include/asm/apm.h
index 20370c6db74..20370c6db74 100644
--- a/arch/x86/include/asm/mach-default/apm.h
+++ b/arch/x86/include/asm/apm.h
diff --git a/arch/x86/include/asm/bigsmp/apic.h b/arch/x86/include/asm/bigsmp/apic.h
deleted file mode 100644
index d8dd9f53791..00000000000
--- a/arch/x86/include/asm/bigsmp/apic.h
+++ /dev/null
@@ -1,155 +0,0 @@
1#ifndef __ASM_MACH_APIC_H
2#define __ASM_MACH_APIC_H
3
4#define xapic_phys_to_log_apicid(cpu) (per_cpu(x86_bios_cpu_apicid, cpu))
5#define esr_disable (1)
6
7static inline int apic_id_registered(void)
8{
9 return (1);
10}
11
12static inline const cpumask_t *target_cpus(void)
13{
14#ifdef CONFIG_SMP
15 return &cpu_online_map;
16#else
17 return &cpumask_of_cpu(0);
18#endif
19}
20
21#undef APIC_DEST_LOGICAL
22#define APIC_DEST_LOGICAL 0
23#define APIC_DFR_VALUE (APIC_DFR_FLAT)
24#define INT_DELIVERY_MODE (dest_Fixed)
25#define INT_DEST_MODE (0) /* phys delivery to target proc */
26#define NO_BALANCE_IRQ (0)
27
28static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
29{
30 return (0);
31}
32
33static inline unsigned long check_apicid_present(int bit)
34{
35 return (1);
36}
37
38static inline unsigned long calculate_ldr(int cpu)
39{
40 unsigned long val, id;
41 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
42 id = xapic_phys_to_log_apicid(cpu);
43 val |= SET_APIC_LOGICAL_ID(id);
44 return val;
45}
46
47/*
48 * Set up the logical destination ID.
49 *
50 * Intel recommends to set DFR, LDR and TPR before enabling
51 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
52 * document number 292116). So here it goes...
53 */
54static inline void init_apic_ldr(void)
55{
56 unsigned long val;
57 int cpu = smp_processor_id();
58
59 apic_write(APIC_DFR, APIC_DFR_VALUE);
60 val = calculate_ldr(cpu);
61 apic_write(APIC_LDR, val);
62}
63
64static inline void setup_apic_routing(void)
65{
66 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
67 "Physflat", nr_ioapics);
68}
69
70static inline int multi_timer_check(int apic, int irq)
71{
72 return (0);
73}
74
75static inline int apicid_to_node(int logical_apicid)
76{
77 return apicid_2_node[hard_smp_processor_id()];
78}
79
80static inline int cpu_present_to_apicid(int mps_cpu)
81{
82 if (mps_cpu < nr_cpu_ids)
83 return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
84
85 return BAD_APICID;
86}
87
88static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
89{
90 return physid_mask_of_physid(phys_apicid);
91}
92
93extern u8 cpu_2_logical_apicid[];
94/* Mapping from cpu number to logical apicid */
95static inline int cpu_to_logical_apicid(int cpu)
96{
97 if (cpu >= nr_cpu_ids)
98 return BAD_APICID;
99 return cpu_physical_id(cpu);
100}
101
102static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
103{
104 /* For clustered we don't have a good way to do this yet - hack */
105 return physids_promote(0xFFL);
106}
107
108static inline void setup_portio_remap(void)
109{
110}
111
112static inline void enable_apic_mode(void)
113{
114}
115
116static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
117{
118 return (1);
119}
120
121/* As we are using single CPU as destination, pick only one CPU here */
122static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
123{
124 int cpu;
125 int apicid;
126
127 cpu = first_cpu(*cpumask);
128 apicid = cpu_to_logical_apicid(cpu);
129 return apicid;
130}
131
132static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask,
133 const struct cpumask *andmask)
134{
135 int cpu;
136
137 /*
138 * We're using fixed IRQ delivery, can only return one phys APIC ID.
139 * May as well be the first.
140 */
141 for_each_cpu_and(cpu, cpumask, andmask)
142 if (cpumask_test_cpu(cpu, cpu_online_mask))
143 break;
144 if (cpu < nr_cpu_ids)
145 return cpu_to_logical_apicid(cpu);
146
147 return BAD_APICID;
148}
149
150static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
151{
152 return cpuid_apic >> index_msb;
153}
154
155#endif /* __ASM_MACH_APIC_H */
diff --git a/arch/x86/include/asm/bigsmp/apicdef.h b/arch/x86/include/asm/bigsmp/apicdef.h
deleted file mode 100644
index 392c3f5ef2f..00000000000
--- a/arch/x86/include/asm/bigsmp/apicdef.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#ifndef __ASM_MACH_APICDEF_H
2#define __ASM_MACH_APICDEF_H
3
4#define APIC_ID_MASK (0xFF<<24)
5
6static inline unsigned get_apic_id(unsigned long x)
7{
8 return (((x)>>24)&0xFF);
9}
10
11#define GET_APIC_ID(x) get_apic_id(x)
12
13#endif
diff --git a/arch/x86/include/asm/bigsmp/ipi.h b/arch/x86/include/asm/bigsmp/ipi.h
deleted file mode 100644
index 27fcd01b3ae..00000000000
--- a/arch/x86/include/asm/bigsmp/ipi.h
+++ /dev/null
@@ -1,22 +0,0 @@
1#ifndef __ASM_MACH_IPI_H
2#define __ASM_MACH_IPI_H
3
4void send_IPI_mask_sequence(const struct cpumask *mask, int vector);
5void send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
6
7static inline void send_IPI_mask(const struct cpumask *mask, int vector)
8{
9 send_IPI_mask_sequence(mask, vector);
10}
11
12static inline void send_IPI_allbutself(int vector)
13{
14 send_IPI_mask_allbutself(cpu_online_mask, vector);
15}
16
17static inline void send_IPI_all(int vector)
18{
19 send_IPI_mask(cpu_online_mask, vector);
20}
21
22#endif /* __ASM_MACH_IPI_H */
diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h
index f03b23e3286..b185091bf19 100644
--- a/arch/x86/include/asm/cpu.h
+++ b/arch/x86/include/asm/cpu.h
@@ -32,10 +32,6 @@ extern void arch_unregister_cpu(int);
32 32
33DECLARE_PER_CPU(int, cpu_state); 33DECLARE_PER_CPU(int, cpu_state);
34 34
35#ifdef CONFIG_X86_HAS_BOOT_CPU_ID 35extern unsigned int boot_cpu_id;
36extern unsigned char boot_cpu_id;
37#else
38#define boot_cpu_id 0
39#endif
40 36
41#endif /* _ASM_X86_CPU_H */ 37#endif /* _ASM_X86_CPU_H */
diff --git a/arch/x86/include/asm/mach-default/do_timer.h b/arch/x86/include/asm/do_timer.h
index 23ecda0b28a..23ecda0b28a 100644
--- a/arch/x86/include/asm/mach-default/do_timer.h
+++ b/arch/x86/include/asm/do_timer.h
diff --git a/arch/x86/include/asm/mach-default/entry_arch.h b/arch/x86/include/asm/entry_arch.h
index 6fa399ad1de..854d538ae85 100644
--- a/arch/x86/include/asm/mach-default/entry_arch.h
+++ b/arch/x86/include/asm/entry_arch.h
@@ -9,7 +9,7 @@
9 * is no hardware IRQ pin equivalent for them, they are triggered 9 * is no hardware IRQ pin equivalent for them, they are triggered
10 * through the ICC by us (IPIs) 10 * through the ICC by us (IPIs)
11 */ 11 */
12#ifdef CONFIG_X86_SMP 12#ifdef CONFIG_SMP
13BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR) 13BUILD_INTERRUPT(reschedule_interrupt,RESCHEDULE_VECTOR)
14BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR) 14BUILD_INTERRUPT(call_function_interrupt,CALL_FUNCTION_VECTOR)
15BUILD_INTERRUPT(call_function_single_interrupt,CALL_FUNCTION_SINGLE_VECTOR) 15BUILD_INTERRUPT(call_function_single_interrupt,CALL_FUNCTION_SINGLE_VECTOR)
@@ -41,10 +41,15 @@ BUILD_INTERRUPT3(invalidate_interrupt7,INVALIDATE_TLB_VECTOR_START+7,
41 * a much simpler SMP time architecture: 41 * a much simpler SMP time architecture:
42 */ 42 */
43#ifdef CONFIG_X86_LOCAL_APIC 43#ifdef CONFIG_X86_LOCAL_APIC
44
44BUILD_INTERRUPT(apic_timer_interrupt,LOCAL_TIMER_VECTOR) 45BUILD_INTERRUPT(apic_timer_interrupt,LOCAL_TIMER_VECTOR)
45BUILD_INTERRUPT(error_interrupt,ERROR_APIC_VECTOR) 46BUILD_INTERRUPT(error_interrupt,ERROR_APIC_VECTOR)
46BUILD_INTERRUPT(spurious_interrupt,SPURIOUS_APIC_VECTOR) 47BUILD_INTERRUPT(spurious_interrupt,SPURIOUS_APIC_VECTOR)
47 48
49#ifdef CONFIG_PERF_COUNTERS
50BUILD_INTERRUPT(perf_counter_interrupt, LOCAL_PERF_VECTOR)
51#endif
52
48#ifdef CONFIG_X86_MCE_P4THERMAL 53#ifdef CONFIG_X86_MCE_P4THERMAL
49BUILD_INTERRUPT(thermal_interrupt,THERMAL_APIC_VECTOR) 54BUILD_INTERRUPT(thermal_interrupt,THERMAL_APIC_VECTOR)
50#endif 55#endif
diff --git a/arch/x86/include/asm/es7000/apic.h b/arch/x86/include/asm/es7000/apic.h
deleted file mode 100644
index c58b9cc7446..00000000000
--- a/arch/x86/include/asm/es7000/apic.h
+++ /dev/null
@@ -1,242 +0,0 @@
1#ifndef __ASM_ES7000_APIC_H
2#define __ASM_ES7000_APIC_H
3
4#include <linux/gfp.h>
5
6#define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu)
7#define esr_disable (1)
8
9static inline int apic_id_registered(void)
10{
11 return (1);
12}
13
14static inline const cpumask_t *target_cpus_cluster(void)
15{
16 return &CPU_MASK_ALL;
17}
18
19static inline const cpumask_t *target_cpus(void)
20{
21 return &cpumask_of_cpu(smp_processor_id());
22}
23
24#define APIC_DFR_VALUE_CLUSTER (APIC_DFR_CLUSTER)
25#define INT_DELIVERY_MODE_CLUSTER (dest_LowestPrio)
26#define INT_DEST_MODE_CLUSTER (1) /* logical delivery broadcast to all procs */
27#define NO_BALANCE_IRQ_CLUSTER (1)
28
29#define APIC_DFR_VALUE (APIC_DFR_FLAT)
30#define INT_DELIVERY_MODE (dest_Fixed)
31#define INT_DEST_MODE (0) /* phys delivery to target procs */
32#define NO_BALANCE_IRQ (0)
33#undef APIC_DEST_LOGICAL
34#define APIC_DEST_LOGICAL 0x0
35
36static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
37{
38 return 0;
39}
40static inline unsigned long check_apicid_present(int bit)
41{
42 return physid_isset(bit, phys_cpu_present_map);
43}
44
45#define apicid_cluster(apicid) (apicid & 0xF0)
46
47static inline unsigned long calculate_ldr(int cpu)
48{
49 unsigned long id;
50 id = xapic_phys_to_log_apicid(cpu);
51 return (SET_APIC_LOGICAL_ID(id));
52}
53
54/*
55 * Set up the logical destination ID.
56 *
57 * Intel recommends to set DFR, LdR and TPR before enabling
58 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
59 * document number 292116). So here it goes...
60 */
61static inline void init_apic_ldr_cluster(void)
62{
63 unsigned long val;
64 int cpu = smp_processor_id();
65
66 apic_write(APIC_DFR, APIC_DFR_VALUE_CLUSTER);
67 val = calculate_ldr(cpu);
68 apic_write(APIC_LDR, val);
69}
70
71static inline void init_apic_ldr(void)
72{
73 unsigned long val;
74 int cpu = smp_processor_id();
75
76 apic_write(APIC_DFR, APIC_DFR_VALUE);
77 val = calculate_ldr(cpu);
78 apic_write(APIC_LDR, val);
79}
80
81extern int apic_version [MAX_APICS];
82static inline void setup_apic_routing(void)
83{
84 int apic = per_cpu(x86_bios_cpu_apicid, smp_processor_id());
85 printk("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n",
86 (apic_version[apic] == 0x14) ?
87 "Physical Cluster" : "Logical Cluster",
88 nr_ioapics, cpus_addr(*target_cpus())[0]);
89}
90
91static inline int multi_timer_check(int apic, int irq)
92{
93 return 0;
94}
95
96static inline int apicid_to_node(int logical_apicid)
97{
98 return 0;
99}
100
101
102static inline int cpu_present_to_apicid(int mps_cpu)
103{
104 if (!mps_cpu)
105 return boot_cpu_physical_apicid;
106 else if (mps_cpu < nr_cpu_ids)
107 return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
108 else
109 return BAD_APICID;
110}
111
112static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
113{
114 static int id = 0;
115 physid_mask_t mask;
116 mask = physid_mask_of_physid(id);
117 ++id;
118 return mask;
119}
120
121extern u8 cpu_2_logical_apicid[];
122/* Mapping from cpu number to logical apicid */
123static inline int cpu_to_logical_apicid(int cpu)
124{
125#ifdef CONFIG_SMP
126 if (cpu >= nr_cpu_ids)
127 return BAD_APICID;
128 return (int)cpu_2_logical_apicid[cpu];
129#else
130 return logical_smp_processor_id();
131#endif
132}
133
134static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
135{
136 /* For clustered we don't have a good way to do this yet - hack */
137 return physids_promote(0xff);
138}
139
140
141static inline void setup_portio_remap(void)
142{
143}
144
145extern unsigned int boot_cpu_physical_apicid;
146static inline int check_phys_apicid_present(int cpu_physical_apicid)
147{
148 boot_cpu_physical_apicid = read_apic_id();
149 return (1);
150}
151
152static inline unsigned int
153cpu_mask_to_apicid_cluster(const struct cpumask *cpumask)
154{
155 int num_bits_set;
156 int cpus_found = 0;
157 int cpu;
158 int apicid;
159
160 num_bits_set = cpumask_weight(cpumask);
161 /* Return id to all */
162 if (num_bits_set == nr_cpu_ids)
163 return 0xFF;
164 /*
165 * The cpus in the mask must all be on the apic cluster. If are not
166 * on the same apicid cluster return default value of TARGET_CPUS.
167 */
168 cpu = cpumask_first(cpumask);
169 apicid = cpu_to_logical_apicid(cpu);
170 while (cpus_found < num_bits_set) {
171 if (cpumask_test_cpu(cpu, cpumask)) {
172 int new_apicid = cpu_to_logical_apicid(cpu);
173 if (apicid_cluster(apicid) !=
174 apicid_cluster(new_apicid)){
175 printk ("%s: Not a valid mask!\n", __func__);
176 return 0xFF;
177 }
178 apicid = new_apicid;
179 cpus_found++;
180 }
181 cpu++;
182 }
183 return apicid;
184}
185
186static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
187{
188 int num_bits_set;
189 int cpus_found = 0;
190 int cpu;
191 int apicid;
192
193 num_bits_set = cpus_weight(*cpumask);
194 /* Return id to all */
195 if (num_bits_set == nr_cpu_ids)
196 return cpu_to_logical_apicid(0);
197 /*
198 * The cpus in the mask must all be on the apic cluster. If are not
199 * on the same apicid cluster return default value of TARGET_CPUS.
200 */
201 cpu = first_cpu(*cpumask);
202 apicid = cpu_to_logical_apicid(cpu);
203 while (cpus_found < num_bits_set) {
204 if (cpu_isset(cpu, *cpumask)) {
205 int new_apicid = cpu_to_logical_apicid(cpu);
206 if (apicid_cluster(apicid) !=
207 apicid_cluster(new_apicid)){
208 printk ("%s: Not a valid mask!\n", __func__);
209 return cpu_to_logical_apicid(0);
210 }
211 apicid = new_apicid;
212 cpus_found++;
213 }
214 cpu++;
215 }
216 return apicid;
217}
218
219
220static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask,
221 const struct cpumask *andmask)
222{
223 int apicid = cpu_to_logical_apicid(0);
224 cpumask_var_t cpumask;
225
226 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC))
227 return apicid;
228
229 cpumask_and(cpumask, inmask, andmask);
230 cpumask_and(cpumask, cpumask, cpu_online_mask);
231 apicid = cpu_mask_to_apicid(cpumask);
232
233 free_cpumask_var(cpumask);
234 return apicid;
235}
236
237static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
238{
239 return cpuid_apic >> index_msb;
240}
241
242#endif /* __ASM_ES7000_APIC_H */
diff --git a/arch/x86/include/asm/es7000/apicdef.h b/arch/x86/include/asm/es7000/apicdef.h
deleted file mode 100644
index 8b234a3cb85..00000000000
--- a/arch/x86/include/asm/es7000/apicdef.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#ifndef __ASM_ES7000_APICDEF_H
2#define __ASM_ES7000_APICDEF_H
3
4#define APIC_ID_MASK (0xFF<<24)
5
6static inline unsigned get_apic_id(unsigned long x)
7{
8 return (((x)>>24)&0xFF);
9}
10
11#define GET_APIC_ID(x) get_apic_id(x)
12
13#endif
diff --git a/arch/x86/include/asm/es7000/ipi.h b/arch/x86/include/asm/es7000/ipi.h
deleted file mode 100644
index 7e8ed24d4b8..00000000000
--- a/arch/x86/include/asm/es7000/ipi.h
+++ /dev/null
@@ -1,22 +0,0 @@
1#ifndef __ASM_ES7000_IPI_H
2#define __ASM_ES7000_IPI_H
3
4void send_IPI_mask_sequence(const struct cpumask *mask, int vector);
5void send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
6
7static inline void send_IPI_mask(const struct cpumask *mask, int vector)
8{
9 send_IPI_mask_sequence(mask, vector);
10}
11
12static inline void send_IPI_allbutself(int vector)
13{
14 send_IPI_mask_allbutself(cpu_online_mask, vector);
15}
16
17static inline void send_IPI_all(int vector)
18{
19 send_IPI_mask(cpu_online_mask, vector);
20}
21
22#endif /* __ASM_ES7000_IPI_H */
diff --git a/arch/x86/include/asm/es7000/mpparse.h b/arch/x86/include/asm/es7000/mpparse.h
deleted file mode 100644
index c1629b090ec..00000000000
--- a/arch/x86/include/asm/es7000/mpparse.h
+++ /dev/null
@@ -1,29 +0,0 @@
1#ifndef __ASM_ES7000_MPPARSE_H
2#define __ASM_ES7000_MPPARSE_H
3
4#include <linux/acpi.h>
5
6extern int parse_unisys_oem (char *oemptr);
7extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
8extern void unmap_unisys_acpi_oem_table(unsigned long oem_addr);
9extern void setup_unisys(void);
10
11#ifndef CONFIG_X86_GENERICARCH
12extern int acpi_madt_oem_check(char *oem_id, char *oem_table_id);
13extern int mps_oem_check(struct mpc_table *mpc, char *oem, char *productid);
14#endif
15
16#ifdef CONFIG_ACPI
17
18static inline int es7000_check_dsdt(void)
19{
20 struct acpi_table_header header;
21
22 if (ACPI_SUCCESS(acpi_get_table_header(ACPI_SIG_DSDT, 0, &header)) &&
23 !strncmp(header.oem_id, "UNISYS", 6))
24 return 1;
25 return 0;
26}
27#endif
28
29#endif /* __ASM_MACH_MPPARSE_H */
diff --git a/arch/x86/include/asm/es7000/wakecpu.h b/arch/x86/include/asm/es7000/wakecpu.h
deleted file mode 100644
index 78f0daaee43..00000000000
--- a/arch/x86/include/asm/es7000/wakecpu.h
+++ /dev/null
@@ -1,37 +0,0 @@
1#ifndef __ASM_ES7000_WAKECPU_H
2#define __ASM_ES7000_WAKECPU_H
3
4#define TRAMPOLINE_PHYS_LOW 0x467
5#define TRAMPOLINE_PHYS_HIGH 0x469
6
7static inline void wait_for_init_deassert(atomic_t *deassert)
8{
9#ifndef CONFIG_ES7000_CLUSTERED_APIC
10 while (!atomic_read(deassert))
11 cpu_relax();
12#endif
13 return;
14}
15
16/* Nothing to do for most platforms, since cleared by the INIT cycle */
17static inline void smp_callin_clear_local_apic(void)
18{
19}
20
21static inline void store_NMI_vector(unsigned short *high, unsigned short *low)
22{
23}
24
25static inline void restore_NMI_vector(unsigned short *high, unsigned short *low)
26{
27}
28
29extern void __inquire_remote_apic(int apicid);
30
31static inline void inquire_remote_apic(int apicid)
32{
33 if (apic_verbosity >= APIC_DEBUG)
34 __inquire_remote_apic(apicid);
35}
36
37#endif /* __ASM_MACH_WAKECPU_H */
diff --git a/arch/x86/include/asm/genapic.h b/arch/x86/include/asm/genapic.h
index d48bee663a6..273b99452ae 100644
--- a/arch/x86/include/asm/genapic.h
+++ b/arch/x86/include/asm/genapic.h
@@ -1,5 +1,263 @@
1#ifndef _ASM_X86_GENAPIC_H
2#define _ASM_X86_GENAPIC_H
3
4#include <linux/cpumask.h>
5
6#include <asm/mpspec.h>
7#include <asm/atomic.h>
8
9/*
10 * Copyright 2004 James Cleverdon, IBM.
11 * Subject to the GNU Public License, v.2
12 *
13 * Generic APIC sub-arch data struct.
14 *
15 * Hacked for x86-64 by James Cleverdon from i386 architecture code by
16 * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
17 * James Cleverdon.
18 */
19struct genapic {
20 char *name;
21
22 int (*probe)(void);
23 int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
24 int (*apic_id_registered)(void);
25
26 u32 irq_delivery_mode;
27 u32 irq_dest_mode;
28
29 const struct cpumask *(*target_cpus)(void);
30
31 int disable_esr;
32
33 int dest_logical;
34 unsigned long (*check_apicid_used)(physid_mask_t bitmap, int apicid);
35 unsigned long (*check_apicid_present)(int apicid);
36
37 void (*vector_allocation_domain)(int cpu, struct cpumask *retmask);
38 void (*init_apic_ldr)(void);
39
40 physid_mask_t (*ioapic_phys_id_map)(physid_mask_t map);
41
42 void (*setup_apic_routing)(void);
43 int (*multi_timer_check)(int apic, int irq);
44 int (*apicid_to_node)(int logical_apicid);
45 int (*cpu_to_logical_apicid)(int cpu);
46 int (*cpu_present_to_apicid)(int mps_cpu);
47 physid_mask_t (*apicid_to_cpu_present)(int phys_apicid);
48 void (*setup_portio_remap)(void);
49 int (*check_phys_apicid_present)(int boot_cpu_physical_apicid);
50 void (*enable_apic_mode)(void);
51 int (*phys_pkg_id)(int cpuid_apic, int index_msb);
52
53 /*
54 * When one of the next two hooks returns 1 the genapic
55 * is switched to this. Essentially they are additional
56 * probe functions:
57 */
58 int (*mps_oem_check)(struct mpc_table *mpc, char *oem, char *productid);
59
60 unsigned int (*get_apic_id)(unsigned long x);
61 unsigned long (*set_apic_id)(unsigned int id);
62 unsigned long apic_id_mask;
63
64 unsigned int (*cpu_mask_to_apicid)(const struct cpumask *cpumask);
65 unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,
66 const struct cpumask *andmask);
67
68 /* ipi */
69 void (*send_IPI_mask)(const struct cpumask *mask, int vector);
70 void (*send_IPI_mask_allbutself)(const struct cpumask *mask,
71 int vector);
72 void (*send_IPI_allbutself)(int vector);
73 void (*send_IPI_all)(int vector);
74 void (*send_IPI_self)(int vector);
75
76 /* wakeup_secondary_cpu */
77 int (*wakeup_cpu)(int apicid, unsigned long start_eip);
78
79 int trampoline_phys_low;
80 int trampoline_phys_high;
81
82 void (*wait_for_init_deassert)(atomic_t *deassert);
83 void (*smp_callin_clear_local_apic)(void);
84 void (*store_NMI_vector)(unsigned short *high, unsigned short *low);
85 void (*inquire_remote_apic)(int apicid);
86};
87
88extern struct genapic *apic;
89
90/*
91 * Warm reset vector default position:
92 */
93#define DEFAULT_TRAMPOLINE_PHYS_LOW 0x467
94#define DEFAULT_TRAMPOLINE_PHYS_HIGH 0x469
95
1#ifdef CONFIG_X86_32 96#ifdef CONFIG_X86_32
2# include "genapic_32.h" 97extern void es7000_update_genapic_to_cluster(void);
3#else 98#else
4# include "genapic_64.h" 99extern struct genapic apic_flat;
100extern struct genapic apic_physflat;
101extern struct genapic apic_x2apic_cluster;
102extern struct genapic apic_x2apic_phys;
103extern int default_acpi_madt_oem_check(char *, char *);
104
105extern void apic_send_IPI_self(int vector);
106
107extern struct genapic apic_x2apic_uv_x;
108DECLARE_PER_CPU(int, x2apic_extra_bits);
109
110extern void default_setup_apic_routing(void);
111
112extern int default_cpu_present_to_apicid(int mps_cpu);
113extern int default_check_phys_apicid_present(int boot_cpu_physical_apicid);
5#endif 114#endif
115
116static inline void default_wait_for_init_deassert(atomic_t *deassert)
117{
118 while (!atomic_read(deassert))
119 cpu_relax();
120 return;
121}
122
123extern void generic_bigsmp_probe(void);
124
125
126#ifdef CONFIG_X86_LOCAL_APIC
127
128#include <asm/smp.h>
129
130#define APIC_DFR_VALUE (APIC_DFR_FLAT)
131
132static inline const struct cpumask *default_target_cpus(void)
133{
134#ifdef CONFIG_SMP
135 return cpu_online_mask;
136#else
137 return cpumask_of(0);
138#endif
139}
140
141DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid);
142
143
144static inline unsigned int read_apic_id(void)
145{
146 unsigned int reg;
147
148 reg = apic_read(APIC_ID);
149
150 return apic->get_apic_id(reg);
151}
152
153#ifdef CONFIG_X86_64
154extern void default_setup_apic_routing(void);
155#else
156
157/*
158 * Set up the logical destination ID.
159 *
160 * Intel recommends to set DFR, LDR and TPR before enabling
161 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
162 * document number 292116). So here it goes...
163 */
164extern void default_init_apic_ldr(void);
165
166static inline int default_apic_id_registered(void)
167{
168 return physid_isset(read_apic_id(), phys_cpu_present_map);
169}
170
171static inline unsigned int
172default_cpu_mask_to_apicid(const struct cpumask *cpumask)
173{
174 return cpumask_bits(cpumask)[0];
175}
176
177static inline unsigned int
178default_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
179 const struct cpumask *andmask)
180{
181 unsigned long mask1 = cpumask_bits(cpumask)[0];
182 unsigned long mask2 = cpumask_bits(andmask)[0];
183 unsigned long mask3 = cpumask_bits(cpu_online_mask)[0];
184
185 return (unsigned int)(mask1 & mask2 & mask3);
186}
187
188static inline int default_phys_pkg_id(int cpuid_apic, int index_msb)
189{
190 return cpuid_apic >> index_msb;
191}
192
193static inline void default_setup_apic_routing(void)
194{
195#ifdef CONFIG_X86_IO_APIC
196 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
197 "Flat", nr_ioapics);
198#endif
199}
200
201extern int default_apicid_to_node(int logical_apicid);
202
203#endif
204
205static inline unsigned long default_check_apicid_used(physid_mask_t bitmap, int apicid)
206{
207 return physid_isset(apicid, bitmap);
208}
209
210static inline unsigned long default_check_apicid_present(int bit)
211{
212 return physid_isset(bit, phys_cpu_present_map);
213}
214
215static inline physid_mask_t default_ioapic_phys_id_map(physid_mask_t phys_map)
216{
217 return phys_map;
218}
219
220/* Mapping from cpu number to logical apicid */
221static inline int default_cpu_to_logical_apicid(int cpu)
222{
223 return 1 << cpu;
224}
225
226static inline int __default_cpu_present_to_apicid(int mps_cpu)
227{
228 if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu))
229 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
230 else
231 return BAD_APICID;
232}
233
234static inline int
235__default_check_phys_apicid_present(int boot_cpu_physical_apicid)
236{
237 return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
238}
239
240#ifdef CONFIG_X86_32
241static inline int default_cpu_present_to_apicid(int mps_cpu)
242{
243 return __default_cpu_present_to_apicid(mps_cpu);
244}
245
246static inline int
247default_check_phys_apicid_present(int boot_cpu_physical_apicid)
248{
249 return __default_check_phys_apicid_present(boot_cpu_physical_apicid);
250}
251#else
252extern int default_cpu_present_to_apicid(int mps_cpu);
253extern int default_check_phys_apicid_present(int boot_cpu_physical_apicid);
254#endif
255
256static inline physid_mask_t default_apicid_to_cpu_present(int phys_apicid)
257{
258 return physid_mask_of_physid(phys_apicid);
259}
260
261#endif /* CONFIG_X86_LOCAL_APIC */
262
263#endif /* _ASM_X86_GENAPIC_64_H */
diff --git a/arch/x86/include/asm/genapic_32.h b/arch/x86/include/asm/genapic_32.h
deleted file mode 100644
index 4334502d366..00000000000
--- a/arch/x86/include/asm/genapic_32.h
+++ /dev/null
@@ -1,141 +0,0 @@
1#ifndef _ASM_X86_GENAPIC_32_H
2#define _ASM_X86_GENAPIC_32_H
3
4#include <asm/mpspec.h>
5#include <asm/atomic.h>
6
7/*
8 * Generic APIC driver interface.
9 *
10 * An straight forward mapping of the APIC related parts of the
11 * x86 subarchitecture interface to a dynamic object.
12 *
13 * This is used by the "generic" x86 subarchitecture.
14 *
15 * Copyright 2003 Andi Kleen, SuSE Labs.
16 */
17
18struct mpc_bus;
19struct mpc_table;
20struct mpc_cpu;
21
22struct genapic {
23 char *name;
24 int (*probe)(void);
25
26 int (*apic_id_registered)(void);
27 const struct cpumask *(*target_cpus)(void);
28 int int_delivery_mode;
29 int int_dest_mode;
30 int ESR_DISABLE;
31 int apic_destination_logical;
32 unsigned long (*check_apicid_used)(physid_mask_t bitmap, int apicid);
33 unsigned long (*check_apicid_present)(int apicid);
34 int no_balance_irq;
35 int no_ioapic_check;
36 void (*init_apic_ldr)(void);
37 physid_mask_t (*ioapic_phys_id_map)(physid_mask_t map);
38
39 void (*setup_apic_routing)(void);
40 int (*multi_timer_check)(int apic, int irq);
41 int (*apicid_to_node)(int logical_apicid);
42 int (*cpu_to_logical_apicid)(int cpu);
43 int (*cpu_present_to_apicid)(int mps_cpu);
44 physid_mask_t (*apicid_to_cpu_present)(int phys_apicid);
45 void (*setup_portio_remap)(void);
46 int (*check_phys_apicid_present)(int boot_cpu_physical_apicid);
47 void (*enable_apic_mode)(void);
48 u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb);
49
50 /* mpparse */
51 /* When one of the next two hooks returns 1 the genapic
52 is switched to this. Essentially they are additional probe
53 functions. */
54 int (*mps_oem_check)(struct mpc_table *mpc, char *oem,
55 char *productid);
56 int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
57
58 unsigned (*get_apic_id)(unsigned long x);
59 unsigned long apic_id_mask;
60 unsigned int (*cpu_mask_to_apicid)(const struct cpumask *cpumask);
61 unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,
62 const struct cpumask *andmask);
63 void (*vector_allocation_domain)(int cpu, struct cpumask *retmask);
64
65#ifdef CONFIG_SMP
66 /* ipi */
67 void (*send_IPI_mask)(const struct cpumask *mask, int vector);
68 void (*send_IPI_mask_allbutself)(const struct cpumask *mask,
69 int vector);
70 void (*send_IPI_allbutself)(int vector);
71 void (*send_IPI_all)(int vector);
72#endif
73 int (*wakeup_cpu)(int apicid, unsigned long start_eip);
74 int trampoline_phys_low;
75 int trampoline_phys_high;
76 void (*wait_for_init_deassert)(atomic_t *deassert);
77 void (*smp_callin_clear_local_apic)(void);
78 void (*store_NMI_vector)(unsigned short *high, unsigned short *low);
79 void (*restore_NMI_vector)(unsigned short *high, unsigned short *low);
80 void (*inquire_remote_apic)(int apicid);
81};
82
83#define APICFUNC(x) .x = x,
84
85/* More functions could be probably marked IPIFUNC and save some space
86 in UP GENERICARCH kernels, but I don't have the nerve right now
87 to untangle this mess. -AK */
88#ifdef CONFIG_SMP
89#define IPIFUNC(x) APICFUNC(x)
90#else
91#define IPIFUNC(x)
92#endif
93
94#define APIC_INIT(aname, aprobe) \
95{ \
96 .name = aname, \
97 .probe = aprobe, \
98 .int_delivery_mode = INT_DELIVERY_MODE, \
99 .int_dest_mode = INT_DEST_MODE, \
100 .no_balance_irq = NO_BALANCE_IRQ, \
101 .ESR_DISABLE = esr_disable, \
102 .apic_destination_logical = APIC_DEST_LOGICAL, \
103 APICFUNC(apic_id_registered) \
104 APICFUNC(target_cpus) \
105 APICFUNC(check_apicid_used) \
106 APICFUNC(check_apicid_present) \
107 APICFUNC(init_apic_ldr) \
108 APICFUNC(ioapic_phys_id_map) \
109 APICFUNC(setup_apic_routing) \
110 APICFUNC(multi_timer_check) \
111 APICFUNC(apicid_to_node) \
112 APICFUNC(cpu_to_logical_apicid) \
113 APICFUNC(cpu_present_to_apicid) \
114 APICFUNC(apicid_to_cpu_present) \
115 APICFUNC(setup_portio_remap) \
116 APICFUNC(check_phys_apicid_present) \
117 APICFUNC(mps_oem_check) \
118 APICFUNC(get_apic_id) \
119 .apic_id_mask = APIC_ID_MASK, \
120 APICFUNC(cpu_mask_to_apicid) \
121 APICFUNC(cpu_mask_to_apicid_and) \
122 APICFUNC(vector_allocation_domain) \
123 APICFUNC(acpi_madt_oem_check) \
124 IPIFUNC(send_IPI_mask) \
125 IPIFUNC(send_IPI_allbutself) \
126 IPIFUNC(send_IPI_all) \
127 APICFUNC(enable_apic_mode) \
128 APICFUNC(phys_pkg_id) \
129 .trampoline_phys_low = TRAMPOLINE_PHYS_LOW, \
130 .trampoline_phys_high = TRAMPOLINE_PHYS_HIGH, \
131 APICFUNC(wait_for_init_deassert) \
132 APICFUNC(smp_callin_clear_local_apic) \
133 APICFUNC(store_NMI_vector) \
134 APICFUNC(restore_NMI_vector) \
135 APICFUNC(inquire_remote_apic) \
136}
137
138extern struct genapic *genapic;
139extern void es7000_update_genapic_to_cluster(void);
140
141#endif /* _ASM_X86_GENAPIC_32_H */
diff --git a/arch/x86/include/asm/genapic_64.h b/arch/x86/include/asm/genapic_64.h
deleted file mode 100644
index 7bb092c5905..00000000000
--- a/arch/x86/include/asm/genapic_64.h
+++ /dev/null
@@ -1,60 +0,0 @@
1#ifndef _ASM_X86_GENAPIC_64_H
2#define _ASM_X86_GENAPIC_64_H
3
4#include <linux/cpumask.h>
5
6/*
7 * Copyright 2004 James Cleverdon, IBM.
8 * Subject to the GNU Public License, v.2
9 *
10 * Generic APIC sub-arch data struct.
11 *
12 * Hacked for x86-64 by James Cleverdon from i386 architecture code by
13 * Martin Bligh, Andi Kleen, James Bottomley, John Stultz, and
14 * James Cleverdon.
15 */
16
17struct genapic {
18 char *name;
19 int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
20 u32 int_delivery_mode;
21 u32 int_dest_mode;
22 int (*apic_id_registered)(void);
23 const struct cpumask *(*target_cpus)(void);
24 void (*vector_allocation_domain)(int cpu, struct cpumask *retmask);
25 void (*init_apic_ldr)(void);
26 /* ipi */
27 void (*send_IPI_mask)(const struct cpumask *mask, int vector);
28 void (*send_IPI_mask_allbutself)(const struct cpumask *mask,
29 int vector);
30 void (*send_IPI_allbutself)(int vector);
31 void (*send_IPI_all)(int vector);
32 void (*send_IPI_self)(int vector);
33 /* */
34 unsigned int (*cpu_mask_to_apicid)(const struct cpumask *cpumask);
35 unsigned int (*cpu_mask_to_apicid_and)(const struct cpumask *cpumask,
36 const struct cpumask *andmask);
37 unsigned int (*phys_pkg_id)(int index_msb);
38 unsigned int (*get_apic_id)(unsigned long x);
39 unsigned long (*set_apic_id)(unsigned int id);
40 unsigned long apic_id_mask;
41 /* wakeup_secondary_cpu */
42 int (*wakeup_cpu)(int apicid, unsigned long start_eip);
43};
44
45extern struct genapic *genapic;
46
47extern struct genapic apic_flat;
48extern struct genapic apic_physflat;
49extern struct genapic apic_x2apic_cluster;
50extern struct genapic apic_x2apic_phys;
51extern int acpi_madt_oem_check(char *, char *);
52
53extern void apic_send_IPI_self(int vector);
54
55extern struct genapic apic_x2apic_uv_x;
56DECLARE_PER_CPU(int, x2apic_extra_bits);
57
58extern void setup_apic_routing(void);
59
60#endif /* _ASM_X86_GENAPIC_64_H */
diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
index 8de644b6b95..370e1c83bb4 100644
--- a/arch/x86/include/asm/hw_irq.h
+++ b/arch/x86/include/asm/hw_irq.h
@@ -25,8 +25,6 @@
25#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/sections.h> 26#include <asm/sections.h>
27 27
28#define platform_legacy_irq(irq) ((irq) < 16)
29
30/* Interrupt handlers registered during init_IRQ */ 28/* Interrupt handlers registered during init_IRQ */
31extern void apic_timer_interrupt(void); 29extern void apic_timer_interrupt(void);
32extern void error_interrupt(void); 30extern void error_interrupt(void);
@@ -58,7 +56,7 @@ extern void make_8259A_irq(unsigned int irq);
58extern void init_8259A(int aeoi); 56extern void init_8259A(int aeoi);
59 57
60/* IOAPIC */ 58/* IOAPIC */
61#define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs)) 59#define IO_APIC_IRQ(x) (((x) >= NR_IRQS_LEGACY) || ((1<<(x)) & io_apic_irqs))
62extern unsigned long io_apic_irqs; 60extern unsigned long io_apic_irqs;
63 61
64extern void init_VISWS_APIC_irqs(void); 62extern void init_VISWS_APIC_irqs(void);
@@ -67,15 +65,7 @@ extern void disable_IO_APIC(void);
67extern int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn); 65extern int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn);
68extern void setup_ioapic_dest(void); 66extern void setup_ioapic_dest(void);
69 67
70#ifdef CONFIG_X86_64
71extern void enable_IO_APIC(void); 68extern void enable_IO_APIC(void);
72#endif
73
74/* IPI functions */
75#ifdef CONFIG_X86_32
76extern void send_IPI_self(int vector);
77#endif
78extern void send_IPI(int dest, int vector);
79 69
80/* Statistics */ 70/* Statistics */
81extern atomic_t irq_err_count; 71extern atomic_t irq_err_count;
@@ -84,21 +74,11 @@ extern atomic_t irq_mis_count;
84/* EISA */ 74/* EISA */
85extern void eisa_set_level_irq(unsigned int irq); 75extern void eisa_set_level_irq(unsigned int irq);
86 76
87/* Voyager functions */
88extern asmlinkage void vic_cpi_interrupt(void);
89extern asmlinkage void vic_sys_interrupt(void);
90extern asmlinkage void vic_cmn_interrupt(void);
91extern asmlinkage void qic_timer_interrupt(void);
92extern asmlinkage void qic_invalidate_interrupt(void);
93extern asmlinkage void qic_reschedule_interrupt(void);
94extern asmlinkage void qic_enable_irq_interrupt(void);
95extern asmlinkage void qic_call_function_interrupt(void);
96
97/* SMP */ 77/* SMP */
98extern void smp_apic_timer_interrupt(struct pt_regs *); 78extern void smp_apic_timer_interrupt(struct pt_regs *);
99extern void smp_spurious_interrupt(struct pt_regs *); 79extern void smp_spurious_interrupt(struct pt_regs *);
100extern void smp_error_interrupt(struct pt_regs *); 80extern void smp_error_interrupt(struct pt_regs *);
101#ifdef CONFIG_X86_SMP 81#ifdef CONFIG_SMP
102extern void smp_reschedule_interrupt(struct pt_regs *); 82extern void smp_reschedule_interrupt(struct pt_regs *);
103extern void smp_call_function_interrupt(struct pt_regs *); 83extern void smp_call_function_interrupt(struct pt_regs *);
104extern void smp_call_function_single_interrupt(struct pt_regs *); 84extern void smp_call_function_single_interrupt(struct pt_regs *);
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
index 1dbbdf4be9b..bcf7ea4e136 100644
--- a/arch/x86/include/asm/io.h
+++ b/arch/x86/include/asm/io.h
@@ -91,7 +91,7 @@ extern void unxlate_dev_mem_ptr(unsigned long phys, void *addr);
91 91
92extern int ioremap_change_attr(unsigned long vaddr, unsigned long size, 92extern int ioremap_change_attr(unsigned long vaddr, unsigned long size,
93 unsigned long prot_val); 93 unsigned long prot_val);
94extern void __iomem *ioremap_wc(unsigned long offset, unsigned long size); 94extern void __iomem *ioremap_wc(resource_size_t offset, unsigned long size);
95 95
96/* 96/*
97 * early_ioremap() and early_iounmap() are for temporary early boot-time 97 * early_ioremap() and early_iounmap() are for temporary early boot-time
diff --git a/arch/x86/include/asm/io_apic.h b/arch/x86/include/asm/io_apic.h
index 08ec793aa04..59cb4a1317b 100644
--- a/arch/x86/include/asm/io_apic.h
+++ b/arch/x86/include/asm/io_apic.h
@@ -143,15 +143,6 @@ extern int noioapicreroute;
143/* 1 if the timer IRQ uses the '8259A Virtual Wire' mode */ 143/* 1 if the timer IRQ uses the '8259A Virtual Wire' mode */
144extern int timer_through_8259; 144extern int timer_through_8259;
145 145
146static inline void disable_ioapic_setup(void)
147{
148#ifdef CONFIG_PCI
149 noioapicquirk = 1;
150 noioapicreroute = -1;
151#endif
152 skip_ioapic_setup = 1;
153}
154
155/* 146/*
156 * If we use the IO-APIC for IRQ routing, disable automatic 147 * If we use the IO-APIC for IRQ routing, disable automatic
157 * assignment of PCI IRQ's. 148 * assignment of PCI IRQ's.
@@ -178,6 +169,12 @@ extern void reinit_intr_remapped_IO_APIC(int);
178 169
179extern void probe_nr_irqs_gsi(void); 170extern void probe_nr_irqs_gsi(void);
180 171
172extern int setup_ioapic_entry(int apic, int irq,
173 struct IO_APIC_route_entry *entry,
174 unsigned int destination, int trigger,
175 int polarity, int vector);
176extern void ioapic_write_entry(int apic, int pin,
177 struct IO_APIC_route_entry e);
181#else /* !CONFIG_X86_IO_APIC */ 178#else /* !CONFIG_X86_IO_APIC */
182#define io_apic_assign_pci_irqs 0 179#define io_apic_assign_pci_irqs 0
183static const int timer_through_8259 = 0; 180static const int timer_through_8259 = 0;
diff --git a/arch/x86/include/asm/ipi.h b/arch/x86/include/asm/ipi.h
index c745a306f7d..5f2efc5d992 100644
--- a/arch/x86/include/asm/ipi.h
+++ b/arch/x86/include/asm/ipi.h
@@ -1,6 +1,8 @@
1#ifndef _ASM_X86_IPI_H 1#ifndef _ASM_X86_IPI_H
2#define _ASM_X86_IPI_H 2#define _ASM_X86_IPI_H
3 3
4#ifdef CONFIG_X86_LOCAL_APIC
5
4/* 6/*
5 * Copyright 2004 James Cleverdon, IBM. 7 * Copyright 2004 James Cleverdon, IBM.
6 * Subject to the GNU Public License, v.2 8 * Subject to the GNU Public License, v.2
@@ -55,8 +57,8 @@ static inline void __xapic_wait_icr_idle(void)
55 cpu_relax(); 57 cpu_relax();
56} 58}
57 59
58static inline void __send_IPI_shortcut(unsigned int shortcut, int vector, 60static inline void
59 unsigned int dest) 61__default_send_IPI_shortcut(unsigned int shortcut, int vector, unsigned int dest)
60{ 62{
61 /* 63 /*
62 * Subtle. In the case of the 'never do double writes' workaround 64 * Subtle. In the case of the 'never do double writes' workaround
@@ -87,8 +89,8 @@ static inline void __send_IPI_shortcut(unsigned int shortcut, int vector,
87 * This is used to send an IPI with no shorthand notation (the destination is 89 * This is used to send an IPI with no shorthand notation (the destination is
88 * specified in bits 56 to 63 of the ICR). 90 * specified in bits 56 to 63 of the ICR).
89 */ 91 */
90static inline void __send_IPI_dest_field(unsigned int mask, int vector, 92static inline void
91 unsigned int dest) 93 __default_send_IPI_dest_field(unsigned int mask, int vector, unsigned int dest)
92{ 94{
93 unsigned long cfg; 95 unsigned long cfg;
94 96
@@ -117,41 +119,46 @@ static inline void __send_IPI_dest_field(unsigned int mask, int vector,
117 native_apic_mem_write(APIC_ICR, cfg); 119 native_apic_mem_write(APIC_ICR, cfg);
118} 120}
119 121
120static inline void send_IPI_mask_sequence(const struct cpumask *mask, 122extern void default_send_IPI_mask_sequence_phys(const struct cpumask *mask,
121 int vector) 123 int vector);
122{ 124extern void default_send_IPI_mask_allbutself_phys(const struct cpumask *mask,
123 unsigned long flags; 125 int vector);
124 unsigned long query_cpu; 126#include <asm/genapic.h>
125 127
126 /* 128extern void default_send_IPI_mask_sequence_logical(const struct cpumask *mask,
127 * Hack. The clustered APIC addressing mode doesn't allow us to send 129 int vector);
128 * to an arbitrary mask, so I do a unicast to each CPU instead. 130extern void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask,
129 * - mbligh 131 int vector);
130 */ 132
131 local_irq_save(flags); 133/* Avoid include hell */
132 for_each_cpu(query_cpu, mask) { 134#define NMI_VECTOR 0x02
133 __send_IPI_dest_field(per_cpu(x86_cpu_to_apicid, query_cpu), 135
134 vector, APIC_DEST_PHYSICAL); 136extern int no_broadcast;
135 } 137
136 local_irq_restore(flags); 138static inline void __default_local_send_IPI_allbutself(int vector)
139{
140 if (no_broadcast || vector == NMI_VECTOR)
141 apic->send_IPI_mask_allbutself(cpu_online_mask, vector);
142 else
143 __default_send_IPI_shortcut(APIC_DEST_ALLBUT, vector, apic->dest_logical);
137} 144}
138 145
139static inline void send_IPI_mask_allbutself(const struct cpumask *mask, 146static inline void __default_local_send_IPI_all(int vector)
140 int vector)
141{ 147{
142 unsigned long flags; 148 if (no_broadcast || vector == NMI_VECTOR)
143 unsigned int query_cpu; 149 apic->send_IPI_mask(cpu_online_mask, vector);
144 unsigned int this_cpu = smp_processor_id(); 150 else
145 151 __default_send_IPI_shortcut(APIC_DEST_ALLINC, vector, apic->dest_logical);
146 /* See Hack comment above */
147
148 local_irq_save(flags);
149 for_each_cpu(query_cpu, mask)
150 if (query_cpu != this_cpu)
151 __send_IPI_dest_field(
152 per_cpu(x86_cpu_to_apicid, query_cpu),
153 vector, APIC_DEST_PHYSICAL);
154 local_irq_restore(flags);
155} 152}
156 153
154#ifdef CONFIG_X86_32
155extern void default_send_IPI_mask_logical(const struct cpumask *mask,
156 int vector);
157extern void default_send_IPI_allbutself(int vector);
158extern void default_send_IPI_all(int vector);
159extern void default_send_IPI_self(int vector);
160#endif
161
162#endif
163
157#endif /* _ASM_X86_IPI_H */ 164#endif /* _ASM_X86_IPI_H */
diff --git a/arch/x86/include/asm/irq.h b/arch/x86/include/asm/irq.h
index 592688ed04d..107eb219669 100644
--- a/arch/x86/include/asm/irq.h
+++ b/arch/x86/include/asm/irq.h
@@ -36,9 +36,11 @@ static inline int irq_canonicalize(int irq)
36extern void fixup_irqs(void); 36extern void fixup_irqs(void);
37#endif 37#endif
38 38
39extern unsigned int do_IRQ(struct pt_regs *regs);
40extern void init_IRQ(void); 39extern void init_IRQ(void);
41extern void native_init_IRQ(void); 40extern void native_init_IRQ(void);
41extern bool handle_irq(unsigned irq, struct pt_regs *regs);
42
43extern unsigned int do_IRQ(struct pt_regs *regs);
42 44
43/* Interrupt vector management */ 45/* Interrupt vector management */
44extern DECLARE_BITMAP(used_vectors, NR_VECTORS); 46extern DECLARE_BITMAP(used_vectors, NR_VECTORS);
diff --git a/arch/x86/include/asm/irq_vectors.h b/arch/x86/include/asm/irq_vectors.h
index 9a83a10a5d5..b07278c55e9 100644
--- a/arch/x86/include/asm/irq_vectors.h
+++ b/arch/x86/include/asm/irq_vectors.h
@@ -1,47 +1,69 @@
1#ifndef _ASM_X86_IRQ_VECTORS_H 1#ifndef _ASM_X86_IRQ_VECTORS_H
2#define _ASM_X86_IRQ_VECTORS_H 2#define _ASM_X86_IRQ_VECTORS_H
3 3
4#include <linux/threads.h> 4/*
5 * Linux IRQ vector layout.
6 *
7 * There are 256 IDT entries (per CPU - each entry is 8 bytes) which can
8 * be defined by Linux. They are used as a jump table by the CPU when a
9 * given vector is triggered - by a CPU-external, CPU-internal or
10 * software-triggered event.
11 *
12 * Linux sets the kernel code address each entry jumps to early during
13 * bootup, and never changes them. This is the general layout of the
14 * IDT entries:
15 *
16 * Vectors 0 ... 31 : system traps and exceptions - hardcoded events
17 * Vectors 32 ... 127 : device interrupts
18 * Vector 128 : legacy int80 syscall interface
19 * Vectors 129 ... 237 : device interrupts
20 * Vectors 238 ... 255 : special interrupts
21 *
22 * 64-bit x86 has per CPU IDT tables, 32-bit has one shared IDT table.
23 *
24 * This file enumerates the exact layout of them:
25 */
5 26
6#define NMI_VECTOR 0x02 27#define NMI_VECTOR 0x02
7 28
8/* 29/*
9 * IDT vectors usable for external interrupt sources start 30 * IDT vectors usable for external interrupt sources start
10 * at 0x20: 31 * at 0x20:
11 */ 32 */
12#define FIRST_EXTERNAL_VECTOR 0x20 33#define FIRST_EXTERNAL_VECTOR 0x20
13 34
14#ifdef CONFIG_X86_32 35#ifdef CONFIG_X86_32
15# define SYSCALL_VECTOR 0x80 36# define SYSCALL_VECTOR 0x80
16#else 37#else
17# define IA32_SYSCALL_VECTOR 0x80 38# define IA32_SYSCALL_VECTOR 0x80
18#endif 39#endif
19 40
20/* 41/*
21 * Reserve the lowest usable priority level 0x20 - 0x2f for triggering 42 * Reserve the lowest usable priority level 0x20 - 0x2f for triggering
22 * cleanup after irq migration. 43 * cleanup after irq migration.
23 */ 44 */
24#define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR 45#define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR
25 46
26/* 47/*
27 * Vectors 0x30-0x3f are used for ISA interrupts. 48 * Vectors 0x30-0x3f are used for ISA interrupts.
28 */ 49 */
29#define IRQ0_VECTOR (FIRST_EXTERNAL_VECTOR + 0x10) 50#define IRQ0_VECTOR (FIRST_EXTERNAL_VECTOR + 0x10)
30#define IRQ1_VECTOR (IRQ0_VECTOR + 1) 51
31#define IRQ2_VECTOR (IRQ0_VECTOR + 2) 52#define IRQ1_VECTOR (IRQ0_VECTOR + 1)
32#define IRQ3_VECTOR (IRQ0_VECTOR + 3) 53#define IRQ2_VECTOR (IRQ0_VECTOR + 2)
33#define IRQ4_VECTOR (IRQ0_VECTOR + 4) 54#define IRQ3_VECTOR (IRQ0_VECTOR + 3)
34#define IRQ5_VECTOR (IRQ0_VECTOR + 5) 55#define IRQ4_VECTOR (IRQ0_VECTOR + 4)
35#define IRQ6_VECTOR (IRQ0_VECTOR + 6) 56#define IRQ5_VECTOR (IRQ0_VECTOR + 5)
36#define IRQ7_VECTOR (IRQ0_VECTOR + 7) 57#define IRQ6_VECTOR (IRQ0_VECTOR + 6)
37#define IRQ8_VECTOR (IRQ0_VECTOR + 8) 58#define IRQ7_VECTOR (IRQ0_VECTOR + 7)
38#define IRQ9_VECTOR (IRQ0_VECTOR + 9) 59#define IRQ8_VECTOR (IRQ0_VECTOR + 8)
39#define IRQ10_VECTOR (IRQ0_VECTOR + 10) 60#define IRQ9_VECTOR (IRQ0_VECTOR + 9)
40#define IRQ11_VECTOR (IRQ0_VECTOR + 11) 61#define IRQ10_VECTOR (IRQ0_VECTOR + 10)
41#define IRQ12_VECTOR (IRQ0_VECTOR + 12) 62#define IRQ11_VECTOR (IRQ0_VECTOR + 11)
42#define IRQ13_VECTOR (IRQ0_VECTOR + 13) 63#define IRQ12_VECTOR (IRQ0_VECTOR + 12)
43#define IRQ14_VECTOR (IRQ0_VECTOR + 14) 64#define IRQ13_VECTOR (IRQ0_VECTOR + 13)
44#define IRQ15_VECTOR (IRQ0_VECTOR + 15) 65#define IRQ14_VECTOR (IRQ0_VECTOR + 14)
66#define IRQ15_VECTOR (IRQ0_VECTOR + 15)
45 67
46/* 68/*
47 * Special IRQ vectors used by the SMP architecture, 0xf0-0xff 69 * Special IRQ vectors used by the SMP architecture, 0xf0-0xff
@@ -50,123 +72,97 @@
50 * into a single vector (CALL_FUNCTION_VECTOR) to save vector space. 72 * into a single vector (CALL_FUNCTION_VECTOR) to save vector space.
51 * TLB, reschedule and local APIC vectors are performance-critical. 73 * TLB, reschedule and local APIC vectors are performance-critical.
52 */ 74 */
53#ifdef CONFIG_X86_32
54 75
55# define SPURIOUS_APIC_VECTOR 0xff 76#define SPURIOUS_APIC_VECTOR 0xff
56# define ERROR_APIC_VECTOR 0xfe 77/*
57# define RESCHEDULE_VECTOR 0xfd 78 * Sanity check
58# define CALL_FUNCTION_VECTOR 0xfc 79 */
59# define CALL_FUNCTION_SINGLE_VECTOR 0xfb 80#if ((SPURIOUS_APIC_VECTOR & 0x0F) != 0x0F)
60# define THERMAL_APIC_VECTOR 0xfa 81# error SPURIOUS_APIC_VECTOR definition error
61/* 0xf8 - 0xf9 : free */ 82#endif
62# define INVALIDATE_TLB_VECTOR_END 0xf7
63# define INVALIDATE_TLB_VECTOR_START 0xf0 /* f0-f7 used for TLB flush */
64 83
65# define NUM_INVALIDATE_TLB_VECTORS 8 84#define ERROR_APIC_VECTOR 0xfe
85#define RESCHEDULE_VECTOR 0xfd
86#define CALL_FUNCTION_VECTOR 0xfc
87#define CALL_FUNCTION_SINGLE_VECTOR 0xfb
88#define THERMAL_APIC_VECTOR 0xfa
66 89
90#ifdef CONFIG_X86_32
91/* 0xf8 - 0xf9 : free */
67#else 92#else
68
69# define SPURIOUS_APIC_VECTOR 0xff
70# define ERROR_APIC_VECTOR 0xfe
71# define RESCHEDULE_VECTOR 0xfd
72# define CALL_FUNCTION_VECTOR 0xfc
73# define CALL_FUNCTION_SINGLE_VECTOR 0xfb
74# define THERMAL_APIC_VECTOR 0xfa
75# define THRESHOLD_APIC_VECTOR 0xf9 93# define THRESHOLD_APIC_VECTOR 0xf9
76# define UV_BAU_MESSAGE 0xf8 94# define UV_BAU_MESSAGE 0xf8
77# define INVALIDATE_TLB_VECTOR_END 0xf7
78# define INVALIDATE_TLB_VECTOR_START 0xf0 /* f0-f7 used for TLB flush */
79
80#define NUM_INVALIDATE_TLB_VECTORS 8
81
82#endif 95#endif
83 96
97/* f0-f7 used for spreading out TLB flushes: */
98#define INVALIDATE_TLB_VECTOR_END 0xf7
99#define INVALIDATE_TLB_VECTOR_START 0xf0
100#define NUM_INVALIDATE_TLB_VECTORS 8
101
84/* 102/*
85 * Local APIC timer IRQ vector is on a different priority level, 103 * Local APIC timer IRQ vector is on a different priority level,
86 * to work around the 'lost local interrupt if more than 2 IRQ 104 * to work around the 'lost local interrupt if more than 2 IRQ
87 * sources per level' errata. 105 * sources per level' errata.
88 */ 106 */
89#define LOCAL_TIMER_VECTOR 0xef 107#define LOCAL_TIMER_VECTOR 0xef
108
109/*
110 * Performance monitoring interrupt vector:
111 */
112#define LOCAL_PERF_VECTOR 0xee
90 113
91/* 114/*
92 * First APIC vector available to drivers: (vectors 0x30-0xee) we 115 * First APIC vector available to drivers: (vectors 0x30-0xee) we
93 * start at 0x31(0x41) to spread out vectors evenly between priority 116 * start at 0x31(0x41) to spread out vectors evenly between priority
94 * levels. (0x80 is the syscall vector) 117 * levels. (0x80 is the syscall vector)
95 */ 118 */
96#define FIRST_DEVICE_VECTOR (IRQ15_VECTOR + 2) 119#define FIRST_DEVICE_VECTOR (IRQ15_VECTOR + 2)
97
98#define NR_VECTORS 256
99
100#define FPU_IRQ 13
101
102#define FIRST_VM86_IRQ 3
103#define LAST_VM86_IRQ 15
104#define invalid_vm86_irq(irq) ((irq) < 3 || (irq) > 15)
105 120
106#define NR_IRQS_LEGACY 16 121#define NR_VECTORS 256
107 122
108#if defined(CONFIG_X86_IO_APIC) && !defined(CONFIG_X86_VOYAGER) 123#define FPU_IRQ 13
109
110#include <asm/apicnum.h> /* need MAX_IO_APICS */
111
112#ifndef CONFIG_SPARSE_IRQ
113# if NR_CPUS < MAX_IO_APICS
114# define NR_IRQS (NR_VECTORS + (32 * NR_CPUS))
115# else
116# define NR_IRQS (NR_VECTORS + (32 * MAX_IO_APICS))
117# endif
118#else
119 124
120# define NR_IRQS \ 125#define FIRST_VM86_IRQ 3
121 ((8 * NR_CPUS) > (32 * MAX_IO_APICS) ? \ 126#define LAST_VM86_IRQ 15
122 (NR_VECTORS + (8 * NR_CPUS)) : \
123 (NR_VECTORS + (32 * MAX_IO_APICS))) \
124 127
128#ifndef __ASSEMBLY__
129static inline int invalid_vm86_irq(int irq)
130{
131 return irq < 3 || irq > 15;
132}
125#endif 133#endif
126 134
127#elif defined(CONFIG_X86_VOYAGER) 135/*
128 136 * Size the maximum number of interrupts.
129# define NR_IRQS 224 137 *
138 * If the irq_desc[] array has a sparse layout, we can size things
139 * generously - it scales up linearly with the maximum number of CPUs,
140 * and the maximum number of IO-APICs, whichever is higher.
141 *
142 * In other cases we size more conservatively, to not create too large
143 * static arrays.
144 */
130 145
131#else /* IO_APIC || VOYAGER */ 146#define NR_IRQS_LEGACY 16
132 147
133# define NR_IRQS 16 148#define CPU_VECTOR_LIMIT ( 8 * NR_CPUS )
149#define IO_APIC_VECTOR_LIMIT ( 32 * MAX_IO_APICS )
134 150
151#ifdef CONFIG_X86_IO_APIC
152# ifdef CONFIG_SPARSE_IRQ
153# define NR_IRQS \
154 (CPU_VECTOR_LIMIT > IO_APIC_VECTOR_LIMIT ? \
155 (NR_VECTORS + CPU_VECTOR_LIMIT) : \
156 (NR_VECTORS + IO_APIC_VECTOR_LIMIT))
157# else
158# if NR_CPUS < MAX_IO_APICS
159# define NR_IRQS (NR_VECTORS + 4*CPU_VECTOR_LIMIT)
160# else
161# define NR_IRQS (NR_VECTORS + IO_APIC_VECTOR_LIMIT)
162# endif
163# endif
164#else /* !CONFIG_X86_IO_APIC: */
165# define NR_IRQS NR_IRQS_LEGACY
135#endif 166#endif
136 167
137/* Voyager specific defines */
138/* These define the CPIs we use in linux */
139#define VIC_CPI_LEVEL0 0
140#define VIC_CPI_LEVEL1 1
141/* now the fake CPIs */
142#define VIC_TIMER_CPI 2
143#define VIC_INVALIDATE_CPI 3
144#define VIC_RESCHEDULE_CPI 4
145#define VIC_ENABLE_IRQ_CPI 5
146#define VIC_CALL_FUNCTION_CPI 6
147#define VIC_CALL_FUNCTION_SINGLE_CPI 7
148
149/* Now the QIC CPIs: Since we don't need the two initial levels,
150 * these are 2 less than the VIC CPIs */
151#define QIC_CPI_OFFSET 1
152#define QIC_TIMER_CPI (VIC_TIMER_CPI - QIC_CPI_OFFSET)
153#define QIC_INVALIDATE_CPI (VIC_INVALIDATE_CPI - QIC_CPI_OFFSET)
154#define QIC_RESCHEDULE_CPI (VIC_RESCHEDULE_CPI - QIC_CPI_OFFSET)
155#define QIC_ENABLE_IRQ_CPI (VIC_ENABLE_IRQ_CPI - QIC_CPI_OFFSET)
156#define QIC_CALL_FUNCTION_CPI (VIC_CALL_FUNCTION_CPI - QIC_CPI_OFFSET)
157#define QIC_CALL_FUNCTION_SINGLE_CPI (VIC_CALL_FUNCTION_SINGLE_CPI - QIC_CPI_OFFSET)
158
159#define VIC_START_FAKE_CPI VIC_TIMER_CPI
160#define VIC_END_FAKE_CPI VIC_CALL_FUNCTION_SINGLE_CPI
161
162/* this is the SYS_INT CPI. */
163#define VIC_SYS_INT 8
164#define VIC_CMN_INT 15
165
166/* This is the boot CPI for alternate processors. It gets overwritten
167 * by the above once the system has activated all available processors */
168#define VIC_CPU_BOOT_CPI VIC_CPI_LEVEL0
169#define VIC_CPU_BOOT_ERRATA_CPI (VIC_CPI_LEVEL0 + 8)
170
171
172#endif /* _ASM_X86_IRQ_VECTORS_H */ 168#endif /* _ASM_X86_IRQ_VECTORS_H */
diff --git a/arch/x86/include/asm/mach-default/mach_apic.h b/arch/x86/include/asm/mach-default/mach_apic.h
deleted file mode 100644
index cc09cbbee27..00000000000
--- a/arch/x86/include/asm/mach-default/mach_apic.h
+++ /dev/null
@@ -1,168 +0,0 @@
1#ifndef _ASM_X86_MACH_DEFAULT_MACH_APIC_H
2#define _ASM_X86_MACH_DEFAULT_MACH_APIC_H
3
4#ifdef CONFIG_X86_LOCAL_APIC
5
6#include <mach_apicdef.h>
7#include <asm/smp.h>
8
9#define APIC_DFR_VALUE (APIC_DFR_FLAT)
10
11static inline const struct cpumask *target_cpus(void)
12{
13#ifdef CONFIG_SMP
14 return cpu_online_mask;
15#else
16 return cpumask_of(0);
17#endif
18}
19
20#define NO_BALANCE_IRQ (0)
21#define esr_disable (0)
22
23#ifdef CONFIG_X86_64
24#include <asm/genapic.h>
25#define INT_DELIVERY_MODE (genapic->int_delivery_mode)
26#define INT_DEST_MODE (genapic->int_dest_mode)
27#define TARGET_CPUS (genapic->target_cpus())
28#define apic_id_registered (genapic->apic_id_registered)
29#define init_apic_ldr (genapic->init_apic_ldr)
30#define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
31#define cpu_mask_to_apicid_and (genapic->cpu_mask_to_apicid_and)
32#define phys_pkg_id (genapic->phys_pkg_id)
33#define vector_allocation_domain (genapic->vector_allocation_domain)
34#define read_apic_id() (GET_APIC_ID(apic_read(APIC_ID)))
35#define send_IPI_self (genapic->send_IPI_self)
36#define wakeup_secondary_cpu (genapic->wakeup_cpu)
37extern void setup_apic_routing(void);
38#else
39#define INT_DELIVERY_MODE dest_LowestPrio
40#define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */
41#define TARGET_CPUS (target_cpus())
42#define wakeup_secondary_cpu wakeup_secondary_cpu_via_init
43/*
44 * Set up the logical destination ID.
45 *
46 * Intel recommends to set DFR, LDR and TPR before enabling
47 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
48 * document number 292116). So here it goes...
49 */
50static inline void init_apic_ldr(void)
51{
52 unsigned long val;
53
54 apic_write(APIC_DFR, APIC_DFR_VALUE);
55 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
56 val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id());
57 apic_write(APIC_LDR, val);
58}
59
60static inline int apic_id_registered(void)
61{
62 return physid_isset(read_apic_id(), phys_cpu_present_map);
63}
64
65static inline unsigned int cpu_mask_to_apicid(const struct cpumask *cpumask)
66{
67 return cpumask_bits(cpumask)[0];
68}
69
70static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask,
71 const struct cpumask *andmask)
72{
73 unsigned long mask1 = cpumask_bits(cpumask)[0];
74 unsigned long mask2 = cpumask_bits(andmask)[0];
75 unsigned long mask3 = cpumask_bits(cpu_online_mask)[0];
76
77 return (unsigned int)(mask1 & mask2 & mask3);
78}
79
80static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
81{
82 return cpuid_apic >> index_msb;
83}
84
85static inline void setup_apic_routing(void)
86{
87#ifdef CONFIG_X86_IO_APIC
88 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
89 "Flat", nr_ioapics);
90#endif
91}
92
93static inline int apicid_to_node(int logical_apicid)
94{
95#ifdef CONFIG_SMP
96 return apicid_2_node[hard_smp_processor_id()];
97#else
98 return 0;
99#endif
100}
101
102static inline void vector_allocation_domain(int cpu, struct cpumask *retmask)
103{
104 /* Careful. Some cpus do not strictly honor the set of cpus
105 * specified in the interrupt destination when using lowest
106 * priority interrupt delivery mode.
107 *
108 * In particular there was a hyperthreading cpu observed to
109 * deliver interrupts to the wrong hyperthread when only one
110 * hyperthread was specified in the interrupt desitination.
111 */
112 *retmask = (cpumask_t) { { [0] = APIC_ALL_CPUS } };
113}
114#endif
115
116static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
117{
118 return physid_isset(apicid, bitmap);
119}
120
121static inline unsigned long check_apicid_present(int bit)
122{
123 return physid_isset(bit, phys_cpu_present_map);
124}
125
126static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
127{
128 return phys_map;
129}
130
131static inline int multi_timer_check(int apic, int irq)
132{
133 return 0;
134}
135
136/* Mapping from cpu number to logical apicid */
137static inline int cpu_to_logical_apicid(int cpu)
138{
139 return 1 << cpu;
140}
141
142static inline int cpu_present_to_apicid(int mps_cpu)
143{
144 if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu))
145 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
146 else
147 return BAD_APICID;
148}
149
150static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
151{
152 return physid_mask_of_physid(phys_apicid);
153}
154
155static inline void setup_portio_remap(void)
156{
157}
158
159static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
160{
161 return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
162}
163
164static inline void enable_apic_mode(void)
165{
166}
167#endif /* CONFIG_X86_LOCAL_APIC */
168#endif /* _ASM_X86_MACH_DEFAULT_MACH_APIC_H */
diff --git a/arch/x86/include/asm/mach-default/mach_apicdef.h b/arch/x86/include/asm/mach-default/mach_apicdef.h
deleted file mode 100644
index 53179936d6c..00000000000
--- a/arch/x86/include/asm/mach-default/mach_apicdef.h
+++ /dev/null
@@ -1,24 +0,0 @@
1#ifndef _ASM_X86_MACH_DEFAULT_MACH_APICDEF_H
2#define _ASM_X86_MACH_DEFAULT_MACH_APICDEF_H
3
4#include <asm/apic.h>
5
6#ifdef CONFIG_X86_64
7#define APIC_ID_MASK (genapic->apic_id_mask)
8#define GET_APIC_ID(x) (genapic->get_apic_id(x))
9#define SET_APIC_ID(x) (genapic->set_apic_id(x))
10#else
11#define APIC_ID_MASK (0xF<<24)
12static inline unsigned get_apic_id(unsigned long x)
13{
14 unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
15 if (APIC_XAPIC(ver))
16 return (((x)>>24)&0xFF);
17 else
18 return (((x)>>24)&0xF);
19}
20
21#define GET_APIC_ID(x) get_apic_id(x)
22#endif
23
24#endif /* _ASM_X86_MACH_DEFAULT_MACH_APICDEF_H */
diff --git a/arch/x86/include/asm/mach-default/mach_ipi.h b/arch/x86/include/asm/mach-default/mach_ipi.h
deleted file mode 100644
index 191312d155d..00000000000
--- a/arch/x86/include/asm/mach-default/mach_ipi.h
+++ /dev/null
@@ -1,64 +0,0 @@
1#ifndef _ASM_X86_MACH_DEFAULT_MACH_IPI_H
2#define _ASM_X86_MACH_DEFAULT_MACH_IPI_H
3
4/* Avoid include hell */
5#define NMI_VECTOR 0x02
6
7void send_IPI_mask_bitmask(const struct cpumask *mask, int vector);
8void send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
9void __send_IPI_shortcut(unsigned int shortcut, int vector);
10
11extern int no_broadcast;
12
13#ifdef CONFIG_X86_64
14#include <asm/genapic.h>
15#define send_IPI_mask (genapic->send_IPI_mask)
16#define send_IPI_mask_allbutself (genapic->send_IPI_mask_allbutself)
17#else
18static inline void send_IPI_mask(const struct cpumask *mask, int vector)
19{
20 send_IPI_mask_bitmask(mask, vector);
21}
22void send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
23#endif
24
25static inline void __local_send_IPI_allbutself(int vector)
26{
27 if (no_broadcast || vector == NMI_VECTOR)
28 send_IPI_mask_allbutself(cpu_online_mask, vector);
29 else
30 __send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
31}
32
33static inline void __local_send_IPI_all(int vector)
34{
35 if (no_broadcast || vector == NMI_VECTOR)
36 send_IPI_mask(cpu_online_mask, vector);
37 else
38 __send_IPI_shortcut(APIC_DEST_ALLINC, vector);
39}
40
41#ifdef CONFIG_X86_64
42#define send_IPI_allbutself (genapic->send_IPI_allbutself)
43#define send_IPI_all (genapic->send_IPI_all)
44#else
45static inline void send_IPI_allbutself(int vector)
46{
47 /*
48 * if there are no other CPUs in the system then we get an APIC send
49 * error if we try to broadcast, thus avoid sending IPIs in this case.
50 */
51 if (!(num_online_cpus() > 1))
52 return;
53
54 __local_send_IPI_allbutself(vector);
55 return;
56}
57
58static inline void send_IPI_all(int vector)
59{
60 __local_send_IPI_all(vector);
61}
62#endif
63
64#endif /* _ASM_X86_MACH_DEFAULT_MACH_IPI_H */
diff --git a/arch/x86/include/asm/mach-default/mach_mpparse.h b/arch/x86/include/asm/mach-default/mach_mpparse.h
deleted file mode 100644
index c70a263d68c..00000000000
--- a/arch/x86/include/asm/mach-default/mach_mpparse.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef _ASM_X86_MACH_DEFAULT_MACH_MPPARSE_H
2#define _ASM_X86_MACH_DEFAULT_MACH_MPPARSE_H
3
4static inline int
5mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
6{
7 return 0;
8}
9
10/* Hook from generic ACPI tables.c */
11static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
12{
13 return 0;
14}
15
16
17#endif /* _ASM_X86_MACH_DEFAULT_MACH_MPPARSE_H */
diff --git a/arch/x86/include/asm/mach-default/mach_mpspec.h b/arch/x86/include/asm/mach-default/mach_mpspec.h
deleted file mode 100644
index e85ede686be..00000000000
--- a/arch/x86/include/asm/mach-default/mach_mpspec.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#ifndef _ASM_X86_MACH_DEFAULT_MACH_MPSPEC_H
2#define _ASM_X86_MACH_DEFAULT_MACH_MPSPEC_H
3
4#define MAX_IRQ_SOURCES 256
5
6#if CONFIG_BASE_SMALL == 0
7#define MAX_MP_BUSSES 256
8#else
9#define MAX_MP_BUSSES 32
10#endif
11
12#endif /* _ASM_X86_MACH_DEFAULT_MACH_MPSPEC_H */
diff --git a/arch/x86/include/asm/mach-default/mach_wakecpu.h b/arch/x86/include/asm/mach-default/mach_wakecpu.h
deleted file mode 100644
index 89897a6a65b..00000000000
--- a/arch/x86/include/asm/mach-default/mach_wakecpu.h
+++ /dev/null
@@ -1,41 +0,0 @@
1#ifndef _ASM_X86_MACH_DEFAULT_MACH_WAKECPU_H
2#define _ASM_X86_MACH_DEFAULT_MACH_WAKECPU_H
3
4#define TRAMPOLINE_PHYS_LOW (0x467)
5#define TRAMPOLINE_PHYS_HIGH (0x469)
6
7static inline void wait_for_init_deassert(atomic_t *deassert)
8{
9 while (!atomic_read(deassert))
10 cpu_relax();
11 return;
12}
13
14/* Nothing to do for most platforms, since cleared by the INIT cycle */
15static inline void smp_callin_clear_local_apic(void)
16{
17}
18
19static inline void store_NMI_vector(unsigned short *high, unsigned short *low)
20{
21}
22
23static inline void restore_NMI_vector(unsigned short *high, unsigned short *low)
24{
25}
26
27#ifdef CONFIG_SMP
28extern void __inquire_remote_apic(int apicid);
29#else /* CONFIG_SMP */
30static inline void __inquire_remote_apic(int apicid)
31{
32}
33#endif /* CONFIG_SMP */
34
35static inline void inquire_remote_apic(int apicid)
36{
37 if (apic_verbosity >= APIC_DEBUG)
38 __inquire_remote_apic(apicid);
39}
40
41#endif /* _ASM_X86_MACH_DEFAULT_MACH_WAKECPU_H */
diff --git a/arch/x86/include/asm/mach-generic/gpio.h b/arch/x86/include/asm/mach-generic/gpio.h
deleted file mode 100644
index 995c45efdb3..00000000000
--- a/arch/x86/include/asm/mach-generic/gpio.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef _ASM_X86_MACH_GENERIC_GPIO_H
2#define _ASM_X86_MACH_GENERIC_GPIO_H
3
4int gpio_request(unsigned gpio, const char *label);
5void gpio_free(unsigned gpio);
6int gpio_direction_input(unsigned gpio);
7int gpio_direction_output(unsigned gpio, int value);
8int gpio_get_value(unsigned gpio);
9void gpio_set_value(unsigned gpio, int value);
10int gpio_to_irq(unsigned gpio);
11int irq_to_gpio(unsigned irq);
12
13#include <asm-generic/gpio.h> /* cansleep wrappers */
14
15#endif /* _ASM_X86_MACH_GENERIC_GPIO_H */
diff --git a/arch/x86/include/asm/mach-generic/mach_apic.h b/arch/x86/include/asm/mach-generic/mach_apic.h
deleted file mode 100644
index 48553e958ad..00000000000
--- a/arch/x86/include/asm/mach-generic/mach_apic.h
+++ /dev/null
@@ -1,35 +0,0 @@
1#ifndef _ASM_X86_MACH_GENERIC_MACH_APIC_H
2#define _ASM_X86_MACH_GENERIC_MACH_APIC_H
3
4#include <asm/genapic.h>
5
6#define esr_disable (genapic->ESR_DISABLE)
7#define NO_BALANCE_IRQ (genapic->no_balance_irq)
8#define INT_DELIVERY_MODE (genapic->int_delivery_mode)
9#define INT_DEST_MODE (genapic->int_dest_mode)
10#undef APIC_DEST_LOGICAL
11#define APIC_DEST_LOGICAL (genapic->apic_destination_logical)
12#define TARGET_CPUS (genapic->target_cpus())
13#define apic_id_registered (genapic->apic_id_registered)
14#define init_apic_ldr (genapic->init_apic_ldr)
15#define ioapic_phys_id_map (genapic->ioapic_phys_id_map)
16#define setup_apic_routing (genapic->setup_apic_routing)
17#define multi_timer_check (genapic->multi_timer_check)
18#define apicid_to_node (genapic->apicid_to_node)
19#define cpu_to_logical_apicid (genapic->cpu_to_logical_apicid)
20#define cpu_present_to_apicid (genapic->cpu_present_to_apicid)
21#define apicid_to_cpu_present (genapic->apicid_to_cpu_present)
22#define setup_portio_remap (genapic->setup_portio_remap)
23#define check_apicid_present (genapic->check_apicid_present)
24#define check_phys_apicid_present (genapic->check_phys_apicid_present)
25#define check_apicid_used (genapic->check_apicid_used)
26#define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid)
27#define cpu_mask_to_apicid_and (genapic->cpu_mask_to_apicid_and)
28#define vector_allocation_domain (genapic->vector_allocation_domain)
29#define enable_apic_mode (genapic->enable_apic_mode)
30#define phys_pkg_id (genapic->phys_pkg_id)
31#define wakeup_secondary_cpu (genapic->wakeup_cpu)
32
33extern void generic_bigsmp_probe(void);
34
35#endif /* _ASM_X86_MACH_GENERIC_MACH_APIC_H */
diff --git a/arch/x86/include/asm/mach-generic/mach_apicdef.h b/arch/x86/include/asm/mach-generic/mach_apicdef.h
deleted file mode 100644
index 68041f3802f..00000000000
--- a/arch/x86/include/asm/mach-generic/mach_apicdef.h
+++ /dev/null
@@ -1,11 +0,0 @@
1#ifndef _ASM_X86_MACH_GENERIC_MACH_APICDEF_H
2#define _ASM_X86_MACH_GENERIC_MACH_APICDEF_H
3
4#ifndef APIC_DEFINITION
5#include <asm/genapic.h>
6
7#define GET_APIC_ID (genapic->get_apic_id)
8#define APIC_ID_MASK (genapic->apic_id_mask)
9#endif
10
11#endif /* _ASM_X86_MACH_GENERIC_MACH_APICDEF_H */
diff --git a/arch/x86/include/asm/mach-generic/mach_ipi.h b/arch/x86/include/asm/mach-generic/mach_ipi.h
deleted file mode 100644
index ffd637e3c3d..00000000000
--- a/arch/x86/include/asm/mach-generic/mach_ipi.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#ifndef _ASM_X86_MACH_GENERIC_MACH_IPI_H
2#define _ASM_X86_MACH_GENERIC_MACH_IPI_H
3
4#include <asm/genapic.h>
5
6#define send_IPI_mask (genapic->send_IPI_mask)
7#define send_IPI_allbutself (genapic->send_IPI_allbutself)
8#define send_IPI_all (genapic->send_IPI_all)
9
10#endif /* _ASM_X86_MACH_GENERIC_MACH_IPI_H */
diff --git a/arch/x86/include/asm/mach-generic/mach_mpparse.h b/arch/x86/include/asm/mach-generic/mach_mpparse.h
deleted file mode 100644
index 9444ab8dca9..00000000000
--- a/arch/x86/include/asm/mach-generic/mach_mpparse.h
+++ /dev/null
@@ -1,9 +0,0 @@
1#ifndef _ASM_X86_MACH_GENERIC_MACH_MPPARSE_H
2#define _ASM_X86_MACH_GENERIC_MACH_MPPARSE_H
3
4
5extern int mps_oem_check(struct mpc_table *, char *, char *);
6
7extern int acpi_madt_oem_check(char *, char *);
8
9#endif /* _ASM_X86_MACH_GENERIC_MACH_MPPARSE_H */
diff --git a/arch/x86/include/asm/mach-generic/mach_mpspec.h b/arch/x86/include/asm/mach-generic/mach_mpspec.h
deleted file mode 100644
index 3bc40722657..00000000000
--- a/arch/x86/include/asm/mach-generic/mach_mpspec.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#ifndef _ASM_X86_MACH_GENERIC_MACH_MPSPEC_H
2#define _ASM_X86_MACH_GENERIC_MACH_MPSPEC_H
3
4#define MAX_IRQ_SOURCES 256
5
6/* Summit or generic (i.e. installer) kernels need lots of bus entries. */
7/* Maximum 256 PCI busses, plus 1 ISA bus in each of 4 cabinets. */
8#define MAX_MP_BUSSES 260
9
10extern void numaq_mps_oem_check(struct mpc_table *, char *, char *);
11
12#endif /* _ASM_X86_MACH_GENERIC_MACH_MPSPEC_H */
diff --git a/arch/x86/include/asm/mach-generic/mach_wakecpu.h b/arch/x86/include/asm/mach-generic/mach_wakecpu.h
deleted file mode 100644
index 1ab16b168c8..00000000000
--- a/arch/x86/include/asm/mach-generic/mach_wakecpu.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#ifndef _ASM_X86_MACH_GENERIC_MACH_WAKECPU_H
2#define _ASM_X86_MACH_GENERIC_MACH_WAKECPU_H
3
4#define TRAMPOLINE_PHYS_LOW (genapic->trampoline_phys_low)
5#define TRAMPOLINE_PHYS_HIGH (genapic->trampoline_phys_high)
6#define wait_for_init_deassert (genapic->wait_for_init_deassert)
7#define smp_callin_clear_local_apic (genapic->smp_callin_clear_local_apic)
8#define store_NMI_vector (genapic->store_NMI_vector)
9#define restore_NMI_vector (genapic->restore_NMI_vector)
10#define inquire_remote_apic (genapic->inquire_remote_apic)
11
12#endif /* _ASM_X86_MACH_GENERIC_MACH_APIC_H */
diff --git a/arch/x86/include/asm/mach-rdc321x/gpio.h b/arch/x86/include/asm/mach-rdc321x/gpio.h
deleted file mode 100644
index c210ab5788b..00000000000
--- a/arch/x86/include/asm/mach-rdc321x/gpio.h
+++ /dev/null
@@ -1,60 +0,0 @@
1#ifndef _ASM_X86_MACH_RDC321X_GPIO_H
2#define _ASM_X86_MACH_RDC321X_GPIO_H
3
4#include <linux/kernel.h>
5
6extern int rdc_gpio_get_value(unsigned gpio);
7extern void rdc_gpio_set_value(unsigned gpio, int value);
8extern int rdc_gpio_direction_input(unsigned gpio);
9extern int rdc_gpio_direction_output(unsigned gpio, int value);
10extern int rdc_gpio_request(unsigned gpio, const char *label);
11extern void rdc_gpio_free(unsigned gpio);
12extern void __init rdc321x_gpio_setup(void);
13
14/* Wrappers for the arch-neutral GPIO API */
15
16static inline int gpio_request(unsigned gpio, const char *label)
17{
18 return rdc_gpio_request(gpio, label);
19}
20
21static inline void gpio_free(unsigned gpio)
22{
23 might_sleep();
24 rdc_gpio_free(gpio);
25}
26
27static inline int gpio_direction_input(unsigned gpio)
28{
29 return rdc_gpio_direction_input(gpio);
30}
31
32static inline int gpio_direction_output(unsigned gpio, int value)
33{
34 return rdc_gpio_direction_output(gpio, value);
35}
36
37static inline int gpio_get_value(unsigned gpio)
38{
39 return rdc_gpio_get_value(gpio);
40}
41
42static inline void gpio_set_value(unsigned gpio, int value)
43{
44 rdc_gpio_set_value(gpio, value);
45}
46
47static inline int gpio_to_irq(unsigned gpio)
48{
49 return gpio;
50}
51
52static inline int irq_to_gpio(unsigned irq)
53{
54 return irq;
55}
56
57/* For cansleep */
58#include <asm-generic/gpio.h>
59
60#endif /* _ASM_X86_MACH_RDC321X_GPIO_H */
diff --git a/arch/x86/include/asm/mach-default/mach_timer.h b/arch/x86/include/asm/mach_timer.h
index 853728519ae..853728519ae 100644
--- a/arch/x86/include/asm/mach-default/mach_timer.h
+++ b/arch/x86/include/asm/mach_timer.h
diff --git a/arch/x86/include/asm/mach-default/mach_traps.h b/arch/x86/include/asm/mach_traps.h
index f7920601e47..f7920601e47 100644
--- a/arch/x86/include/asm/mach-default/mach_traps.h
+++ b/arch/x86/include/asm/mach_traps.h
diff --git a/arch/x86/include/asm/mpspec.h b/arch/x86/include/asm/mpspec.h
index bd22f2a3713..5916c8df09d 100644
--- a/arch/x86/include/asm/mpspec.h
+++ b/arch/x86/include/asm/mpspec.h
@@ -9,7 +9,18 @@ extern int apic_version[MAX_APICS];
9extern int pic_mode; 9extern int pic_mode;
10 10
11#ifdef CONFIG_X86_32 11#ifdef CONFIG_X86_32
12#include <mach_mpspec.h> 12
13/*
14 * Summit or generic (i.e. installer) kernels need lots of bus entries.
15 * Maximum 256 PCI busses, plus 1 ISA bus in each of 4 cabinets.
16 */
17#if CONFIG_BASE_SMALL == 0
18# define MAX_MP_BUSSES 260
19#else
20# define MAX_MP_BUSSES 32
21#endif
22
23#define MAX_IRQ_SOURCES 256
13 24
14extern unsigned int def_to_bigsmp; 25extern unsigned int def_to_bigsmp;
15extern u8 apicid_2_node[]; 26extern u8 apicid_2_node[];
@@ -20,15 +31,15 @@ extern int mp_bus_id_to_local[MAX_MP_BUSSES];
20extern int quad_local_to_mp_bus_id [NR_CPUS/4][4]; 31extern int quad_local_to_mp_bus_id [NR_CPUS/4][4];
21#endif 32#endif
22 33
23#define MAX_APICID 256 34#define MAX_APICID 256
24 35
25#else 36#else /* CONFIG_X86_64: */
26 37
27#define MAX_MP_BUSSES 256 38#define MAX_MP_BUSSES 256
28/* Each PCI slot may be a combo card with its own bus. 4 IRQ pins per slot. */ 39/* Each PCI slot may be a combo card with its own bus. 4 IRQ pins per slot. */
29#define MAX_IRQ_SOURCES (MAX_MP_BUSSES * 4) 40#define MAX_IRQ_SOURCES (MAX_MP_BUSSES * 4)
30 41
31#endif 42#endif /* CONFIG_X86_64 */
32 43
33extern void early_find_smp_config(void); 44extern void early_find_smp_config(void);
34extern void early_get_smp_config(void); 45extern void early_get_smp_config(void);
@@ -45,11 +56,13 @@ extern int smp_found_config;
45extern int mpc_default_type; 56extern int mpc_default_type;
46extern unsigned long mp_lapic_addr; 57extern unsigned long mp_lapic_addr;
47 58
48extern void find_smp_config(void);
49extern void get_smp_config(void); 59extern void get_smp_config(void);
60
50#ifdef CONFIG_X86_MPPARSE 61#ifdef CONFIG_X86_MPPARSE
62extern void find_smp_config(void);
51extern void early_reserve_e820_mpc_new(void); 63extern void early_reserve_e820_mpc_new(void);
52#else 64#else
65static inline void find_smp_config(void) { }
53static inline void early_reserve_e820_mpc_new(void) { } 66static inline void early_reserve_e820_mpc_new(void) { }
54#endif 67#endif
55 68
@@ -64,6 +77,8 @@ extern int acpi_probe_gsi(void);
64#ifdef CONFIG_X86_IO_APIC 77#ifdef CONFIG_X86_IO_APIC
65extern int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin, 78extern int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin,
66 u32 gsi, int triggering, int polarity); 79 u32 gsi, int triggering, int polarity);
80extern int mp_find_ioapic(int gsi);
81extern int mp_find_ioapic_pin(int ioapic, int gsi);
67#else 82#else
68static inline int 83static inline int
69mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin, 84mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin,
@@ -148,4 +163,10 @@ static inline void physid_set_mask_of_physid(int physid, physid_mask_t *map)
148 163
149extern physid_mask_t phys_cpu_present_map; 164extern physid_mask_t phys_cpu_present_map;
150 165
166extern int generic_mps_oem_check(struct mpc_table *, char *, char *);
167
168extern int default_acpi_madt_oem_check(char *, char *);
169
170extern void numaq_mps_oem_check(struct mpc_table *, char *, char *);
171
151#endif /* _ASM_X86_MPSPEC_H */ 172#endif /* _ASM_X86_MPSPEC_H */
diff --git a/arch/x86/include/asm/numaq.h b/arch/x86/include/asm/numaq.h
index 1e8bd30b4c1..9f0a5f5d29e 100644
--- a/arch/x86/include/asm/numaq.h
+++ b/arch/x86/include/asm/numaq.h
@@ -31,6 +31,8 @@
31extern int found_numaq; 31extern int found_numaq;
32extern int get_memcfg_numaq(void); 32extern int get_memcfg_numaq(void);
33 33
34extern void *xquad_portio;
35
34/* 36/*
35 * SYS_CFG_DATA_PRIV_ADDR, struct eachquadmem, and struct sys_cfg_data are the 37 * SYS_CFG_DATA_PRIV_ADDR, struct eachquadmem, and struct sys_cfg_data are the
36 */ 38 */
diff --git a/arch/x86/include/asm/numaq/apic.h b/arch/x86/include/asm/numaq/apic.h
deleted file mode 100644
index bf37bc49bd8..00000000000
--- a/arch/x86/include/asm/numaq/apic.h
+++ /dev/null
@@ -1,142 +0,0 @@
1#ifndef __ASM_NUMAQ_APIC_H
2#define __ASM_NUMAQ_APIC_H
3
4#include <asm/io.h>
5#include <linux/mmzone.h>
6#include <linux/nodemask.h>
7
8#define APIC_DFR_VALUE (APIC_DFR_CLUSTER)
9
10static inline const cpumask_t *target_cpus(void)
11{
12 return &CPU_MASK_ALL;
13}
14
15#define NO_BALANCE_IRQ (1)
16#define esr_disable (1)
17
18#define INT_DELIVERY_MODE dest_LowestPrio
19#define INT_DEST_MODE 0 /* physical delivery on LOCAL quad */
20
21static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
22{
23 return physid_isset(apicid, bitmap);
24}
25static inline unsigned long check_apicid_present(int bit)
26{
27 return physid_isset(bit, phys_cpu_present_map);
28}
29#define apicid_cluster(apicid) (apicid & 0xF0)
30
31static inline int apic_id_registered(void)
32{
33 return 1;
34}
35
36static inline void init_apic_ldr(void)
37{
38 /* Already done in NUMA-Q firmware */
39}
40
41static inline void setup_apic_routing(void)
42{
43 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
44 "NUMA-Q", nr_ioapics);
45}
46
47/*
48 * Skip adding the timer int on secondary nodes, which causes
49 * a small but painful rift in the time-space continuum.
50 */
51static inline int multi_timer_check(int apic, int irq)
52{
53 return apic != 0 && irq == 0;
54}
55
56static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
57{
58 /* We don't have a good way to do this yet - hack */
59 return physids_promote(0xFUL);
60}
61
62/* Mapping from cpu number to logical apicid */
63extern u8 cpu_2_logical_apicid[];
64static inline int cpu_to_logical_apicid(int cpu)
65{
66 if (cpu >= nr_cpu_ids)
67 return BAD_APICID;
68 return (int)cpu_2_logical_apicid[cpu];
69}
70
71/*
72 * Supporting over 60 cpus on NUMA-Q requires a locality-dependent
73 * cpu to APIC ID relation to properly interact with the intelligent
74 * mode of the cluster controller.
75 */
76static inline int cpu_present_to_apicid(int mps_cpu)
77{
78 if (mps_cpu < 60)
79 return ((mps_cpu >> 2) << 4) | (1 << (mps_cpu & 0x3));
80 else
81 return BAD_APICID;
82}
83
84static inline int apicid_to_node(int logical_apicid)
85{
86 return logical_apicid >> 4;
87}
88
89static inline physid_mask_t apicid_to_cpu_present(int logical_apicid)
90{
91 int node = apicid_to_node(logical_apicid);
92 int cpu = __ffs(logical_apicid & 0xf);
93
94 return physid_mask_of_physid(cpu + 4*node);
95}
96
97extern void *xquad_portio;
98
99static inline void setup_portio_remap(void)
100{
101 int num_quads = num_online_nodes();
102
103 if (num_quads <= 1)
104 return;
105
106 printk("Remapping cross-quad port I/O for %d quads\n", num_quads);
107 xquad_portio = ioremap(XQUAD_PORTIO_BASE, num_quads*XQUAD_PORTIO_QUAD);
108 printk("xquad_portio vaddr 0x%08lx, len %08lx\n",
109 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
110}
111
112static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
113{
114 return (1);
115}
116
117static inline void enable_apic_mode(void)
118{
119}
120
121/*
122 * We use physical apicids here, not logical, so just return the default
123 * physical broadcast to stop people from breaking us
124 */
125static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
126{
127 return (int) 0xF;
128}
129
130static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask,
131 const struct cpumask *andmask)
132{
133 return (int) 0xF;
134}
135
136/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
137static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
138{
139 return cpuid_apic >> index_msb;
140}
141
142#endif /* __ASM_NUMAQ_APIC_H */
diff --git a/arch/x86/include/asm/numaq/apicdef.h b/arch/x86/include/asm/numaq/apicdef.h
deleted file mode 100644
index e012a46cc22..00000000000
--- a/arch/x86/include/asm/numaq/apicdef.h
+++ /dev/null
@@ -1,14 +0,0 @@
1#ifndef __ASM_NUMAQ_APICDEF_H
2#define __ASM_NUMAQ_APICDEF_H
3
4
5#define APIC_ID_MASK (0xF<<24)
6
7static inline unsigned get_apic_id(unsigned long x)
8{
9 return (((x)>>24)&0x0F);
10}
11
12#define GET_APIC_ID(x) get_apic_id(x)
13
14#endif
diff --git a/arch/x86/include/asm/numaq/ipi.h b/arch/x86/include/asm/numaq/ipi.h
deleted file mode 100644
index a8374c65277..00000000000
--- a/arch/x86/include/asm/numaq/ipi.h
+++ /dev/null
@@ -1,22 +0,0 @@
1#ifndef __ASM_NUMAQ_IPI_H
2#define __ASM_NUMAQ_IPI_H
3
4void send_IPI_mask_sequence(const struct cpumask *mask, int vector);
5void send_IPI_mask_allbutself(const struct cpumask *mask, int vector);
6
7static inline void send_IPI_mask(const struct cpumask *mask, int vector)
8{
9 send_IPI_mask_sequence(mask, vector);
10}
11
12static inline void send_IPI_allbutself(int vector)
13{
14 send_IPI_mask_allbutself(cpu_online_mask, vector);
15}
16
17static inline void send_IPI_all(int vector)
18{
19 send_IPI_mask(cpu_online_mask, vector);
20}
21
22#endif /* __ASM_NUMAQ_IPI_H */
diff --git a/arch/x86/include/asm/numaq/mpparse.h b/arch/x86/include/asm/numaq/mpparse.h
deleted file mode 100644
index a2eeefcd1cc..00000000000
--- a/arch/x86/include/asm/numaq/mpparse.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_NUMAQ_MPPARSE_H
2#define __ASM_NUMAQ_MPPARSE_H
3
4extern void numaq_mps_oem_check(struct mpc_table *, char *, char *);
5
6#endif /* __ASM_NUMAQ_MPPARSE_H */
diff --git a/arch/x86/include/asm/numaq/wakecpu.h b/arch/x86/include/asm/numaq/wakecpu.h
deleted file mode 100644
index 6f499df8edd..00000000000
--- a/arch/x86/include/asm/numaq/wakecpu.h
+++ /dev/null
@@ -1,45 +0,0 @@
1#ifndef __ASM_NUMAQ_WAKECPU_H
2#define __ASM_NUMAQ_WAKECPU_H
3
4/* This file copes with machines that wakeup secondary CPUs by NMIs */
5
6#define TRAMPOLINE_PHYS_LOW (0x8)
7#define TRAMPOLINE_PHYS_HIGH (0xa)
8
9/* We don't do anything here because we use NMI's to boot instead */
10static inline void wait_for_init_deassert(atomic_t *deassert)
11{
12}
13
14/*
15 * Because we use NMIs rather than the INIT-STARTUP sequence to
16 * bootstrap the CPUs, the APIC may be in a weird state. Kick it.
17 */
18static inline void smp_callin_clear_local_apic(void)
19{
20 clear_local_APIC();
21}
22
23static inline void store_NMI_vector(unsigned short *high, unsigned short *low)
24{
25 printk("Storing NMI vector\n");
26 *high =
27 *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_HIGH));
28 *low =
29 *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_LOW));
30}
31
32static inline void restore_NMI_vector(unsigned short *high, unsigned short *low)
33{
34 printk("Restoring NMI vector\n");
35 *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_HIGH)) =
36 *high;
37 *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) =
38 *low;
39}
40
41static inline void inquire_remote_apic(int apicid)
42{
43}
44
45#endif /* __ASM_NUMAQ_WAKECPU_H */
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index ff691736f5e..1c244b64573 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -1482,6 +1482,7 @@ static inline int __raw_spin_is_contended(struct raw_spinlock *lock)
1482{ 1482{
1483 return PVOP_CALL1(int, pv_lock_ops.spin_is_contended, lock); 1483 return PVOP_CALL1(int, pv_lock_ops.spin_is_contended, lock);
1484} 1484}
1485#define __raw_spin_is_contended __raw_spin_is_contended
1485 1486
1486static __always_inline void __raw_spin_lock(struct raw_spinlock *lock) 1487static __always_inline void __raw_spin_lock(struct raw_spinlock *lock)
1487{ 1488{
diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h
index b8493b3b989..9709fdff661 100644
--- a/arch/x86/include/asm/pat.h
+++ b/arch/x86/include/asm/pat.h
@@ -5,10 +5,8 @@
5 5
6#ifdef CONFIG_X86_PAT 6#ifdef CONFIG_X86_PAT
7extern int pat_enabled; 7extern int pat_enabled;
8extern void validate_pat_support(struct cpuinfo_x86 *c);
9#else 8#else
10static const int pat_enabled; 9static const int pat_enabled;
11static inline void validate_pat_support(struct cpuinfo_x86 *c) { }
12#endif 10#endif
13 11
14extern void pat_init(void); 12extern void pat_init(void);
@@ -17,6 +15,4 @@ extern int reserve_memtype(u64 start, u64 end,
17 unsigned long req_type, unsigned long *ret_type); 15 unsigned long req_type, unsigned long *ret_type);
18extern int free_memtype(u64 start, u64 end); 16extern int free_memtype(u64 start, u64 end);
19 17
20extern void pat_disable(char *reason);
21
22#endif /* _ASM_X86_PAT_H */ 18#endif /* _ASM_X86_PAT_H */
diff --git a/arch/x86/include/asm/mach-default/pci-functions.h b/arch/x86/include/asm/pci-functions.h
index ed0bab42735..ed0bab42735 100644
--- a/arch/x86/include/asm/mach-default/pci-functions.h
+++ b/arch/x86/include/asm/pci-functions.h
diff --git a/arch/x86/include/asm/prctl.h b/arch/x86/include/asm/prctl.h
index a8894647dd9..3ac5032fae0 100644
--- a/arch/x86/include/asm/prctl.h
+++ b/arch/x86/include/asm/prctl.h
@@ -6,8 +6,4 @@
6#define ARCH_GET_FS 0x1003 6#define ARCH_GET_FS 0x1003
7#define ARCH_GET_GS 0x1004 7#define ARCH_GET_GS 0x1004
8 8
9#ifdef CONFIG_X86_64
10extern long sys_arch_prctl(int, unsigned long);
11#endif /* CONFIG_X86_64 */
12
13#endif /* _ASM_X86_PRCTL_H */ 9#endif /* _ASM_X86_PRCTL_H */
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 5a947210425..a0133838b67 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -73,7 +73,7 @@ struct cpuinfo_x86 {
73 char pad0; 73 char pad0;
74#else 74#else
75 /* Number of 4K pages in DTLB/ITLB combined(in pages): */ 75 /* Number of 4K pages in DTLB/ITLB combined(in pages): */
76 int x86_tlbsize; 76 int x86_tlbsize;
77 __u8 x86_virt_bits; 77 __u8 x86_virt_bits;
78 __u8 x86_phys_bits; 78 __u8 x86_phys_bits;
79#endif 79#endif
diff --git a/arch/x86/include/asm/proto.h b/arch/x86/include/asm/proto.h
index d6a22f92ba7..49fb3ecf3bb 100644
--- a/arch/x86/include/asm/proto.h
+++ b/arch/x86/include/asm/proto.h
@@ -18,11 +18,7 @@ extern void syscall32_cpu_init(void);
18 18
19extern void check_efer(void); 19extern void check_efer(void);
20 20
21#ifdef CONFIG_X86_BIOS_REBOOT
22extern int reboot_force; 21extern int reboot_force;
23#else
24static const int reboot_force = 0;
25#endif
26 22
27long do_arch_prctl(struct task_struct *task, int code, unsigned long addr); 23long do_arch_prctl(struct task_struct *task, int code, unsigned long addr);
28 24
diff --git a/arch/x86/include/asm/mach-rdc321x/rdc321x_defs.h b/arch/x86/include/asm/rdc321x_defs.h
index c8e9c8bed3d..c8e9c8bed3d 100644
--- a/arch/x86/include/asm/mach-rdc321x/rdc321x_defs.h
+++ b/arch/x86/include/asm/rdc321x_defs.h
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index 536949749bc..45b40278b58 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -1,6 +1,8 @@
1#ifndef _ASM_X86_SETUP_H 1#ifndef _ASM_X86_SETUP_H
2#define _ASM_X86_SETUP_H 2#define _ASM_X86_SETUP_H
3 3
4#ifdef __KERNEL__
5
4#define COMMAND_LINE_SIZE 2048 6#define COMMAND_LINE_SIZE 2048
5 7
6#ifndef __ASSEMBLY__ 8#ifndef __ASSEMBLY__
@@ -8,10 +10,8 @@
8/* Interrupt control for vSMPowered x86_64 systems */ 10/* Interrupt control for vSMPowered x86_64 systems */
9void vsmp_init(void); 11void vsmp_init(void);
10 12
11
12void setup_bios_corruption_check(void); 13void setup_bios_corruption_check(void);
13 14
14
15#ifdef CONFIG_X86_VISWS 15#ifdef CONFIG_X86_VISWS
16extern void visws_early_detect(void); 16extern void visws_early_detect(void);
17extern int is_visws_box(void); 17extern int is_visws_box(void);
@@ -43,7 +43,7 @@ struct x86_quirks {
43 void (*mpc_oem_bus_info)(struct mpc_bus *m, char *name); 43 void (*mpc_oem_bus_info)(struct mpc_bus *m, char *name);
44 void (*mpc_oem_pci_bus)(struct mpc_bus *m); 44 void (*mpc_oem_pci_bus)(struct mpc_bus *m);
45 void (*smp_read_mpc_oem)(struct mpc_oemtable *oemtable, 45 void (*smp_read_mpc_oem)(struct mpc_oemtable *oemtable,
46 unsigned short oemsize); 46 unsigned short oemsize);
47 int (*setup_ioapic_ids)(void); 47 int (*setup_ioapic_ids)(void);
48 int (*update_genapic)(void); 48 int (*update_genapic)(void);
49}; 49};
@@ -56,8 +56,6 @@ extern unsigned long saved_video_mode;
56#endif 56#endif
57#endif /* __ASSEMBLY__ */ 57#endif /* __ASSEMBLY__ */
58 58
59#ifdef __KERNEL__
60
61#ifdef __i386__ 59#ifdef __i386__
62 60
63#include <linux/pfn.h> 61#include <linux/pfn.h>
diff --git a/arch/x86/include/asm/mach-default/setup_arch.h b/arch/x86/include/asm/setup_arch.h
index 38846208b54..38846208b54 100644
--- a/arch/x86/include/asm/mach-default/setup_arch.h
+++ b/arch/x86/include/asm/setup_arch.h
diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
index 45ef8a1b9d7..47d0e21f2b9 100644
--- a/arch/x86/include/asm/smp.h
+++ b/arch/x86/include/asm/smp.h
@@ -182,28 +182,9 @@ static inline int logical_smp_processor_id(void)
182 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR)); 182 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
183} 183}
184 184
185#include <mach_apicdef.h>
186static inline unsigned int read_apic_id(void)
187{
188 unsigned int reg;
189
190 reg = *(u32 *)(APIC_BASE + APIC_ID);
191
192 return GET_APIC_ID(reg);
193}
194#endif 185#endif
195 186
196
197# if defined(APIC_DEFINITION) || defined(CONFIG_X86_64)
198extern int hard_smp_processor_id(void); 187extern int hard_smp_processor_id(void);
199# else
200#include <mach_apicdef.h>
201static inline int hard_smp_processor_id(void)
202{
203 /* we don't want to mark this access volatile - bad code generation */
204 return read_apic_id();
205}
206# endif /* APIC_DEFINITION */
207 188
208#else /* CONFIG_X86_LOCAL_APIC */ 189#else /* CONFIG_X86_LOCAL_APIC */
209 190
diff --git a/arch/x86/include/asm/mach-default/smpboot_hooks.h b/arch/x86/include/asm/smpboot_hooks.h
index 23bf52103b8..1def6011490 100644
--- a/arch/x86/include/asm/mach-default/smpboot_hooks.h
+++ b/arch/x86/include/asm/smpboot_hooks.h
@@ -13,10 +13,10 @@ static inline void smpboot_setup_warm_reset_vector(unsigned long start_eip)
13 CMOS_WRITE(0xa, 0xf); 13 CMOS_WRITE(0xa, 0xf);
14 local_flush_tlb(); 14 local_flush_tlb();
15 pr_debug("1.\n"); 15 pr_debug("1.\n");
16 *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_HIGH)) = 16 *((volatile unsigned short *)phys_to_virt(apic->trampoline_phys_high)) =
17 start_eip >> 4; 17 start_eip >> 4;
18 pr_debug("2.\n"); 18 pr_debug("2.\n");
19 *((volatile unsigned short *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = 19 *((volatile unsigned short *)phys_to_virt(apic->trampoline_phys_low)) =
20 start_eip & 0xf; 20 start_eip & 0xf;
21 pr_debug("3.\n"); 21 pr_debug("3.\n");
22} 22}
@@ -34,7 +34,7 @@ static inline void smpboot_restore_warm_reset_vector(void)
34 */ 34 */
35 CMOS_WRITE(0, 0xf); 35 CMOS_WRITE(0, 0xf);
36 36
37 *((volatile long *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = 0; 37 *((volatile long *)phys_to_virt(apic->trampoline_phys_low)) = 0;
38} 38}
39 39
40static inline void __init smpboot_setup_io_apic(void) 40static inline void __init smpboot_setup_io_apic(void)
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index 2bd6b111a41..3a569665668 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -183,6 +183,7 @@ static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
183{ 183{
184 return __ticket_spin_is_contended(lock); 184 return __ticket_spin_is_contended(lock);
185} 185}
186#define __raw_spin_is_contended __raw_spin_is_contended
186 187
187static __always_inline void __raw_spin_lock(raw_spinlock_t *lock) 188static __always_inline void __raw_spin_lock(raw_spinlock_t *lock)
188{ 189{
@@ -267,8 +268,7 @@ static inline int __raw_read_trylock(raw_rwlock_t *lock)
267{ 268{
268 atomic_t *count = (atomic_t *)lock; 269 atomic_t *count = (atomic_t *)lock;
269 270
270 atomic_dec(count); 271 if (atomic_dec_return(count) >= 0)
271 if (atomic_read(count) >= 0)
272 return 1; 272 return 1;
273 atomic_inc(count); 273 atomic_inc(count);
274 return 0; 274 return 0;
diff --git a/arch/x86/include/asm/summit/apic.h b/arch/x86/include/asm/summit/apic.h
deleted file mode 100644
index 93d2c8667cf..00000000000
--- a/arch/x86/include/asm/summit/apic.h
+++ /dev/null
@@ -1,202 +0,0 @@
1#ifndef __ASM_SUMMIT_APIC_H
2#define __ASM_SUMMIT_APIC_H
3
4#include <asm/smp.h>
5#include <linux/gfp.h>
6
7#define esr_disable (1)
8#define NO_BALANCE_IRQ (0)
9
10/* In clustered mode, the high nibble of APIC ID is a cluster number.
11 * The low nibble is a 4-bit bitmap. */
12#define XAPIC_DEST_CPUS_SHIFT 4
13#define XAPIC_DEST_CPUS_MASK ((1u << XAPIC_DEST_CPUS_SHIFT) - 1)
14#define XAPIC_DEST_CLUSTER_MASK (XAPIC_DEST_CPUS_MASK << XAPIC_DEST_CPUS_SHIFT)
15
16#define APIC_DFR_VALUE (APIC_DFR_CLUSTER)
17
18static inline const cpumask_t *target_cpus(void)
19{
20 /* CPU_MASK_ALL (0xff) has undefined behaviour with
21 * dest_LowestPrio mode logical clustered apic interrupt routing
22 * Just start on cpu 0. IRQ balancing will spread load
23 */
24 return &cpumask_of_cpu(0);
25}
26
27#define INT_DELIVERY_MODE (dest_LowestPrio)
28#define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */
29
30static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
31{
32 return 0;
33}
34
35/* we don't use the phys_cpu_present_map to indicate apicid presence */
36static inline unsigned long check_apicid_present(int bit)
37{
38 return 1;
39}
40
41#define apicid_cluster(apicid) ((apicid) & XAPIC_DEST_CLUSTER_MASK)
42
43extern u8 cpu_2_logical_apicid[];
44
45static inline void init_apic_ldr(void)
46{
47 unsigned long val, id;
48 int count = 0;
49 u8 my_id = (u8)hard_smp_processor_id();
50 u8 my_cluster = (u8)apicid_cluster(my_id);
51#ifdef CONFIG_SMP
52 u8 lid;
53 int i;
54
55 /* Create logical APIC IDs by counting CPUs already in cluster. */
56 for (count = 0, i = nr_cpu_ids; --i >= 0; ) {
57 lid = cpu_2_logical_apicid[i];
58 if (lid != BAD_APICID && apicid_cluster(lid) == my_cluster)
59 ++count;
60 }
61#endif
62 /* We only have a 4 wide bitmap in cluster mode. If a deranged
63 * BIOS puts 5 CPUs in one APIC cluster, we're hosed. */
64 BUG_ON(count >= XAPIC_DEST_CPUS_SHIFT);
65 id = my_cluster | (1UL << count);
66 apic_write(APIC_DFR, APIC_DFR_VALUE);
67 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
68 val |= SET_APIC_LOGICAL_ID(id);
69 apic_write(APIC_LDR, val);
70}
71
72static inline int multi_timer_check(int apic, int irq)
73{
74 return 0;
75}
76
77static inline int apic_id_registered(void)
78{
79 return 1;
80}
81
82static inline void setup_apic_routing(void)
83{
84 printk("Enabling APIC mode: Summit. Using %d I/O APICs\n",
85 nr_ioapics);
86}
87
88static inline int apicid_to_node(int logical_apicid)
89{
90#ifdef CONFIG_SMP
91 return apicid_2_node[hard_smp_processor_id()];
92#else
93 return 0;
94#endif
95}
96
97/* Mapping from cpu number to logical apicid */
98static inline int cpu_to_logical_apicid(int cpu)
99{
100#ifdef CONFIG_SMP
101 if (cpu >= nr_cpu_ids)
102 return BAD_APICID;
103 return (int)cpu_2_logical_apicid[cpu];
104#else
105 return logical_smp_processor_id();
106#endif
107}
108
109static inline int cpu_present_to_apicid(int mps_cpu)
110{
111 if (mps_cpu < nr_cpu_ids)
112 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
113 else
114 return BAD_APICID;
115}
116
117static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_id_map)
118{
119 /* For clustered we don't have a good way to do this yet - hack */
120 return physids_promote(0x0F);
121}
122
123static inline physid_mask_t apicid_to_cpu_present(int apicid)
124{
125 return physid_mask_of_physid(0);
126}
127
128static inline void setup_portio_remap(void)
129{
130}
131
132static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
133{
134 return 1;
135}
136
137static inline void enable_apic_mode(void)
138{
139}
140
141static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
142{
143 int num_bits_set;
144 int cpus_found = 0;
145 int cpu;
146 int apicid;
147
148 num_bits_set = cpus_weight(*cpumask);
149 /* Return id to all */
150 if (num_bits_set >= nr_cpu_ids)
151 return (int) 0xFF;
152 /*
153 * The cpus in the mask must all be on the apic cluster. If are not
154 * on the same apicid cluster return default value of TARGET_CPUS.
155 */
156 cpu = first_cpu(*cpumask);
157 apicid = cpu_to_logical_apicid(cpu);
158 while (cpus_found < num_bits_set) {
159 if (cpu_isset(cpu, *cpumask)) {
160 int new_apicid = cpu_to_logical_apicid(cpu);
161 if (apicid_cluster(apicid) !=
162 apicid_cluster(new_apicid)){
163 printk ("%s: Not a valid mask!\n", __func__);
164 return 0xFF;
165 }
166 apicid = apicid | new_apicid;
167 cpus_found++;
168 }
169 cpu++;
170 }
171 return apicid;
172}
173
174static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *inmask,
175 const struct cpumask *andmask)
176{
177 int apicid = cpu_to_logical_apicid(0);
178 cpumask_var_t cpumask;
179
180 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC))
181 return apicid;
182
183 cpumask_and(cpumask, inmask, andmask);
184 cpumask_and(cpumask, cpumask, cpu_online_mask);
185 apicid = cpu_mask_to_apicid(cpumask);
186
187 free_cpumask_var(cpumask);
188 return apicid;
189}
190
191/* cpuid returns the value latched in the HW at reset, not the APIC ID
192 * register's value. For any box whose BIOS changes APIC IDs, like
193 * clustered APIC systems, we must use hard_smp_processor_id.
194 *
195 * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID.
196 */
197static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
198{
199 return hard_smp_processor_id() >> index_msb;
200}
201
202#endif /* __ASM_SUMMIT_APIC_H */
diff --git a/arch/x86/include/asm/summit/apicdef.h b/arch/x86/include/asm/summit/apicdef.h
deleted file mode 100644
index f3fbca1f61c..00000000000
--- a/arch/x86/include/asm/summit/apicdef.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#ifndef __ASM_SUMMIT_APICDEF_H
2#define __ASM_SUMMIT_APICDEF_H
3
4#define APIC_ID_MASK (0xFF<<24)
5
6static inline unsigned get_apic_id(unsigned long x)
7{
8 return (x>>24)&0xFF;
9}
10
11#define GET_APIC_ID(x) get_apic_id(x)
12
13#endif
diff --git a/arch/x86/include/asm/summit/ipi.h b/arch/x86/include/asm/summit/ipi.h
deleted file mode 100644
index a8a2c24f50c..00000000000
--- a/arch/x86/include/asm/summit/ipi.h
+++ /dev/null
@@ -1,26 +0,0 @@
1#ifndef __ASM_SUMMIT_IPI_H
2#define __ASM_SUMMIT_IPI_H
3
4void send_IPI_mask_sequence(const cpumask_t *mask, int vector);
5void send_IPI_mask_allbutself(const cpumask_t *mask, int vector);
6
7static inline void send_IPI_mask(const cpumask_t *mask, int vector)
8{
9 send_IPI_mask_sequence(mask, vector);
10}
11
12static inline void send_IPI_allbutself(int vector)
13{
14 cpumask_t mask = cpu_online_map;
15 cpu_clear(smp_processor_id(), mask);
16
17 if (!cpus_empty(mask))
18 send_IPI_mask(&mask, vector);
19}
20
21static inline void send_IPI_all(int vector)
22{
23 send_IPI_mask(&cpu_online_map, vector);
24}
25
26#endif /* __ASM_SUMMIT_IPI_H */
diff --git a/arch/x86/include/asm/summit/mpparse.h b/arch/x86/include/asm/summit/mpparse.h
deleted file mode 100644
index 380e86c0236..00000000000
--- a/arch/x86/include/asm/summit/mpparse.h
+++ /dev/null
@@ -1,109 +0,0 @@
1#ifndef __ASM_SUMMIT_MPPARSE_H
2#define __ASM_SUMMIT_MPPARSE_H
3
4#include <asm/tsc.h>
5
6extern int use_cyclone;
7
8#ifdef CONFIG_X86_SUMMIT_NUMA
9extern void setup_summit(void);
10#else
11#define setup_summit() {}
12#endif
13
14static inline int mps_oem_check(struct mpc_table *mpc, char *oem,
15 char *productid)
16{
17 if (!strncmp(oem, "IBM ENSW", 8) &&
18 (!strncmp(productid, "VIGIL SMP", 9)
19 || !strncmp(productid, "EXA", 3)
20 || !strncmp(productid, "RUTHLESS SMP", 12))){
21 mark_tsc_unstable("Summit based system");
22 use_cyclone = 1; /*enable cyclone-timer*/
23 setup_summit();
24 return 1;
25 }
26 return 0;
27}
28
29/* Hook from generic ACPI tables.c */
30static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
31{
32 if (!strncmp(oem_id, "IBM", 3) &&
33 (!strncmp(oem_table_id, "SERVIGIL", 8)
34 || !strncmp(oem_table_id, "EXA", 3))){
35 mark_tsc_unstable("Summit based system");
36 use_cyclone = 1; /*enable cyclone-timer*/
37 setup_summit();
38 return 1;
39 }
40 return 0;
41}
42
43struct rio_table_hdr {
44 unsigned char version; /* Version number of this data structure */
45 /* Version 3 adds chassis_num & WP_index */
46 unsigned char num_scal_dev; /* # of Scalability devices (Twisters for Vigil) */
47 unsigned char num_rio_dev; /* # of RIO I/O devices (Cyclones and Winnipegs) */
48} __attribute__((packed));
49
50struct scal_detail {
51 unsigned char node_id; /* Scalability Node ID */
52 unsigned long CBAR; /* Address of 1MB register space */
53 unsigned char port0node; /* Node ID port connected to: 0xFF=None */
54 unsigned char port0port; /* Port num port connected to: 0,1,2, or 0xFF=None */
55 unsigned char port1node; /* Node ID port connected to: 0xFF = None */
56 unsigned char port1port; /* Port num port connected to: 0,1,2, or 0xFF=None */
57 unsigned char port2node; /* Node ID port connected to: 0xFF = None */
58 unsigned char port2port; /* Port num port connected to: 0,1,2, or 0xFF=None */
59 unsigned char chassis_num; /* 1 based Chassis number (1 = boot node) */
60} __attribute__((packed));
61
62struct rio_detail {
63 unsigned char node_id; /* RIO Node ID */
64 unsigned long BBAR; /* Address of 1MB register space */
65 unsigned char type; /* Type of device */
66 unsigned char owner_id; /* For WPEG: Node ID of Cyclone that owns this WPEG*/
67 /* For CYC: Node ID of Twister that owns this CYC */
68 unsigned char port0node; /* Node ID port connected to: 0xFF=None */
69 unsigned char port0port; /* Port num port connected to: 0,1,2, or 0xFF=None */
70 unsigned char port1node; /* Node ID port connected to: 0xFF=None */
71 unsigned char port1port; /* Port num port connected to: 0,1,2, or 0xFF=None */
72 unsigned char first_slot; /* For WPEG: Lowest slot number below this WPEG */
73 /* For CYC: 0 */
74 unsigned char status; /* For WPEG: Bit 0 = 1 : the XAPIC is used */
75 /* = 0 : the XAPIC is not used, ie:*/
76 /* ints fwded to another XAPIC */
77 /* Bits1:7 Reserved */
78 /* For CYC: Bits0:7 Reserved */
79 unsigned char WP_index; /* For WPEG: WPEG instance index - lower ones have */
80 /* lower slot numbers/PCI bus numbers */
81 /* For CYC: No meaning */
82 unsigned char chassis_num; /* 1 based Chassis number */
83 /* For LookOut WPEGs this field indicates the */
84 /* Expansion Chassis #, enumerated from Boot */
85 /* Node WPEG external port, then Boot Node CYC */
86 /* external port, then Next Vigil chassis WPEG */
87 /* external port, etc. */
88 /* Shared Lookouts have only 1 chassis number (the */
89 /* first one assigned) */
90} __attribute__((packed));
91
92
93typedef enum {
94 CompatTwister = 0, /* Compatibility Twister */
95 AltTwister = 1, /* Alternate Twister of internal 8-way */
96 CompatCyclone = 2, /* Compatibility Cyclone */
97 AltCyclone = 3, /* Alternate Cyclone of internal 8-way */
98 CompatWPEG = 4, /* Compatibility WPEG */
99 AltWPEG = 5, /* Second Planar WPEG */
100 LookOutAWPEG = 6, /* LookOut WPEG */
101 LookOutBWPEG = 7, /* LookOut WPEG */
102} node_type;
103
104static inline int is_WPEG(struct rio_detail *rio){
105 return (rio->type == CompatWPEG || rio->type == AltWPEG ||
106 rio->type == LookOutAWPEG || rio->type == LookOutBWPEG);
107}
108
109#endif /* __ASM_SUMMIT_MPPARSE_H */
diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
index 7a80f72bec4..c00bfdbdd45 100644
--- a/arch/x86/include/asm/system.h
+++ b/arch/x86/include/asm/system.h
@@ -130,16 +130,16 @@ do { \
130 "movq "__percpu_arg([current_task])",%%rsi\n\t" \ 130 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
131 __switch_canary \ 131 __switch_canary \
132 "movq %P[thread_info](%%rsi),%%r8\n\t" \ 132 "movq %P[thread_info](%%rsi),%%r8\n\t" \
133 LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \
134 "movq %%rax,%%rdi\n\t" \ 133 "movq %%rax,%%rdi\n\t" \
135 "jc ret_from_fork\n\t" \ 134 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
135 "jnz ret_from_fork\n\t" \
136 RESTORE_CONTEXT \ 136 RESTORE_CONTEXT \
137 : "=a" (last) \ 137 : "=a" (last) \
138 __switch_canary_oparam \ 138 __switch_canary_oparam \
139 : [next] "S" (next), [prev] "D" (prev), \ 139 : [next] "S" (next), [prev] "D" (prev), \
140 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \ 140 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
141 [ti_flags] "i" (offsetof(struct thread_info, flags)), \ 141 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
142 [tif_fork] "i" (TIF_FORK), \ 142 [_tif_fork] "i" (_TIF_FORK), \
143 [thread_info] "i" (offsetof(struct task_struct, stack)), \ 143 [thread_info] "i" (offsetof(struct task_struct, stack)), \
144 [current_task] "m" (per_cpu_var(current_task)) \ 144 [current_task] "m" (per_cpu_var(current_task)) \
145 __switch_canary_iparam \ 145 __switch_canary_iparam \
diff --git a/arch/x86/include/asm/voyager.h b/arch/x86/include/asm/voyager.h
index b3e64730762..c1635d43616 100644
--- a/arch/x86/include/asm/voyager.h
+++ b/arch/x86/include/asm/voyager.h
@@ -527,3 +527,45 @@ extern void voyager_smp_intr_init(void);
527#define VOYAGER_PSI_SUBREAD 2 527#define VOYAGER_PSI_SUBREAD 2
528#define VOYAGER_PSI_SUBWRITE 3 528#define VOYAGER_PSI_SUBWRITE 3
529extern void voyager_cat_psi(__u8, __u16, __u8 *); 529extern void voyager_cat_psi(__u8, __u16, __u8 *);
530
531/* These define the CPIs we use in linux */
532#define VIC_CPI_LEVEL0 0
533#define VIC_CPI_LEVEL1 1
534/* now the fake CPIs */
535#define VIC_TIMER_CPI 2
536#define VIC_INVALIDATE_CPI 3
537#define VIC_RESCHEDULE_CPI 4
538#define VIC_ENABLE_IRQ_CPI 5
539#define VIC_CALL_FUNCTION_CPI 6
540#define VIC_CALL_FUNCTION_SINGLE_CPI 7
541
542/* Now the QIC CPIs: Since we don't need the two initial levels,
543 * these are 2 less than the VIC CPIs */
544#define QIC_CPI_OFFSET 1
545#define QIC_TIMER_CPI (VIC_TIMER_CPI - QIC_CPI_OFFSET)
546#define QIC_INVALIDATE_CPI (VIC_INVALIDATE_CPI - QIC_CPI_OFFSET)
547#define QIC_RESCHEDULE_CPI (VIC_RESCHEDULE_CPI - QIC_CPI_OFFSET)
548#define QIC_ENABLE_IRQ_CPI (VIC_ENABLE_IRQ_CPI - QIC_CPI_OFFSET)
549#define QIC_CALL_FUNCTION_CPI (VIC_CALL_FUNCTION_CPI - QIC_CPI_OFFSET)
550#define QIC_CALL_FUNCTION_SINGLE_CPI (VIC_CALL_FUNCTION_SINGLE_CPI - QIC_CPI_OFFSET)
551
552#define VIC_START_FAKE_CPI VIC_TIMER_CPI
553#define VIC_END_FAKE_CPI VIC_CALL_FUNCTION_SINGLE_CPI
554
555/* this is the SYS_INT CPI. */
556#define VIC_SYS_INT 8
557#define VIC_CMN_INT 15
558
559/* This is the boot CPI for alternate processors. It gets overwritten
560 * by the above once the system has activated all available processors */
561#define VIC_CPU_BOOT_CPI VIC_CPI_LEVEL0
562#define VIC_CPU_BOOT_ERRATA_CPI (VIC_CPI_LEVEL0 + 8)
563
564extern asmlinkage void vic_cpi_interrupt(void);
565extern asmlinkage void vic_sys_interrupt(void);
566extern asmlinkage void vic_cmn_interrupt(void);
567extern asmlinkage void qic_timer_interrupt(void);
568extern asmlinkage void qic_invalidate_interrupt(void);
569extern asmlinkage void qic_reschedule_interrupt(void);
570extern asmlinkage void qic_enable_irq_interrupt(void);
571extern asmlinkage void qic_call_function_interrupt(void);
diff --git a/arch/x86/include/asm/xen/events.h b/arch/x86/include/asm/xen/events.h
index 19144184983..1df35417c41 100644
--- a/arch/x86/include/asm/xen/events.h
+++ b/arch/x86/include/asm/xen/events.h
@@ -15,10 +15,4 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
15 return raw_irqs_disabled_flags(regs->flags); 15 return raw_irqs_disabled_flags(regs->flags);
16} 16}
17 17
18static inline void xen_do_IRQ(int irq, struct pt_regs *regs)
19{
20 regs->orig_ax = ~irq;
21 do_IRQ(regs);
22}
23
24#endif /* _ASM_X86_XEN_EVENTS_H */ 18#endif /* _ASM_X86_XEN_EVENTS_H */
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 37fa30bada1..24f357e7557 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -30,7 +30,7 @@ obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
30obj-y += time_$(BITS).o ioport.o ldt.o dumpstack.o 30obj-y += time_$(BITS).o ioport.o ldt.o dumpstack.o
31obj-y += setup.o i8259.o irqinit_$(BITS).o 31obj-y += setup.o i8259.o irqinit_$(BITS).o
32obj-$(CONFIG_X86_VISWS) += visws_quirks.o 32obj-$(CONFIG_X86_VISWS) += visws_quirks.o
33obj-$(CONFIG_X86_32) += probe_roms_32.o 33obj-$(CONFIG_X86_32) += probe_32.o probe_roms_32.o
34obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o 34obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
35obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o 35obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
36obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o 36obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o
@@ -50,20 +50,20 @@ obj-y += step.o
50obj-$(CONFIG_STACKTRACE) += stacktrace.o 50obj-$(CONFIG_STACKTRACE) += stacktrace.o
51obj-y += cpu/ 51obj-y += cpu/
52obj-y += acpi/ 52obj-y += acpi/
53obj-$(CONFIG_X86_BIOS_REBOOT) += reboot.o 53obj-y += reboot.o
54obj-$(CONFIG_MCA) += mca_32.o 54obj-$(CONFIG_MCA) += mca_32.o
55obj-$(CONFIG_X86_MSR) += msr.o 55obj-$(CONFIG_X86_MSR) += msr.o
56obj-$(CONFIG_X86_CPUID) += cpuid.o 56obj-$(CONFIG_X86_CPUID) += cpuid.o
57obj-$(CONFIG_PCI) += early-quirks.o 57obj-$(CONFIG_PCI) += early-quirks.o
58apm-y := apm_32.o 58apm-y := apm_32.o
59obj-$(CONFIG_APM) += apm.o 59obj-$(CONFIG_APM) += apm.o
60obj-$(CONFIG_X86_SMP) += smp.o 60obj-$(CONFIG_SMP) += smp.o
61obj-$(CONFIG_X86_SMP) += smpboot.o tsc_sync.o ipi.o 61obj-$(CONFIG_SMP) += smpboot.o tsc_sync.o ipi.o
62obj-$(CONFIG_SMP) += setup_percpu.o 62obj-$(CONFIG_SMP) += setup_percpu.o
63obj-$(CONFIG_X86_64_SMP) += tsc_sync.o 63obj-$(CONFIG_X86_64_SMP) += tsc_sync.o
64obj-$(CONFIG_X86_TRAMPOLINE) += trampoline_$(BITS).o 64obj-$(CONFIG_X86_TRAMPOLINE) += trampoline_$(BITS).o
65obj-$(CONFIG_X86_MPPARSE) += mpparse.o 65obj-$(CONFIG_X86_MPPARSE) += mpparse.o
66obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o 66obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o ipi.o
67obj-$(CONFIG_X86_IO_APIC) += io_apic.o 67obj-$(CONFIG_X86_IO_APIC) += io_apic.o
68obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o 68obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o
69obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o 69obj-$(CONFIG_DYNAMIC_FTRACE) += ftrace.o
@@ -71,9 +71,10 @@ obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
71obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o 71obj-$(CONFIG_KEXEC) += machine_kexec_$(BITS).o
72obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o 72obj-$(CONFIG_KEXEC) += relocate_kernel_$(BITS).o crash.o
73obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o 73obj-$(CONFIG_CRASH_DUMP) += crash_dump_$(BITS).o
74obj-$(CONFIG_X86_BIGSMP) += bigsmp_32.o
74obj-$(CONFIG_X86_NUMAQ) += numaq_32.o 75obj-$(CONFIG_X86_NUMAQ) += numaq_32.o
75obj-$(CONFIG_X86_ES7000) += es7000_32.o 76obj-$(CONFIG_X86_ES7000) += es7000_32.o
76obj-$(CONFIG_X86_SUMMIT_NUMA) += summit_32.o 77obj-$(CONFIG_X86_SUMMIT) += summit_32.o
77obj-y += vsmp_64.o 78obj-y += vsmp_64.o
78obj-$(CONFIG_KPROBES) += kprobes.o 79obj-$(CONFIG_KPROBES) += kprobes.o
79obj-$(CONFIG_MODULES) += module_$(BITS).o 80obj-$(CONFIG_MODULES) += module_$(BITS).o
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index c193ec3c695..bba162c81d5 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -42,10 +42,6 @@
42#include <asm/mpspec.h> 42#include <asm/mpspec.h>
43#include <asm/smp.h> 43#include <asm/smp.h>
44 44
45#ifdef CONFIG_X86_LOCAL_APIC
46# include <mach_apic.h>
47#endif
48
49static int __initdata acpi_force = 0; 45static int __initdata acpi_force = 0;
50u32 acpi_rsdt_forced; 46u32 acpi_rsdt_forced;
51#ifdef CONFIG_ACPI 47#ifdef CONFIG_ACPI
@@ -56,16 +52,7 @@ int acpi_disabled = 1;
56EXPORT_SYMBOL(acpi_disabled); 52EXPORT_SYMBOL(acpi_disabled);
57 53
58#ifdef CONFIG_X86_64 54#ifdef CONFIG_X86_64
59 55# include <asm/proto.h>
60#include <asm/proto.h>
61
62#else /* X86 */
63
64#ifdef CONFIG_X86_LOCAL_APIC
65#include <mach_apic.h>
66#include <mach_mpparse.h>
67#endif /* CONFIG_X86_LOCAL_APIC */
68
69#endif /* X86 */ 56#endif /* X86 */
70 57
71#define BAD_MADT_ENTRY(entry, end) ( \ 58#define BAD_MADT_ENTRY(entry, end) ( \
@@ -239,7 +226,8 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
239 madt->address); 226 madt->address);
240 } 227 }
241 228
242 acpi_madt_oem_check(madt->header.oem_id, madt->header.oem_table_id); 229 default_acpi_madt_oem_check(madt->header.oem_id,
230 madt->header.oem_table_id);
243 231
244 return 0; 232 return 0;
245} 233}
@@ -884,7 +872,7 @@ static struct {
884 DECLARE_BITMAP(pin_programmed, MP_MAX_IOAPIC_PIN + 1); 872 DECLARE_BITMAP(pin_programmed, MP_MAX_IOAPIC_PIN + 1);
885} mp_ioapic_routing[MAX_IO_APICS]; 873} mp_ioapic_routing[MAX_IO_APICS];
886 874
887static int mp_find_ioapic(int gsi) 875int mp_find_ioapic(int gsi)
888{ 876{
889 int i = 0; 877 int i = 0;
890 878
@@ -899,6 +887,16 @@ static int mp_find_ioapic(int gsi)
899 return -1; 887 return -1;
900} 888}
901 889
890int mp_find_ioapic_pin(int ioapic, int gsi)
891{
892 if (WARN_ON(ioapic == -1))
893 return -1;
894 if (WARN_ON(gsi > mp_ioapic_routing[ioapic].gsi_end))
895 return -1;
896
897 return gsi - mp_ioapic_routing[ioapic].gsi_base;
898}
899
902static u8 __init uniq_ioapic_id(u8 id) 900static u8 __init uniq_ioapic_id(u8 id)
903{ 901{
904#ifdef CONFIG_X86_32 902#ifdef CONFIG_X86_32
@@ -1034,7 +1032,7 @@ void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
1034 ioapic = mp_find_ioapic(gsi); 1032 ioapic = mp_find_ioapic(gsi);
1035 if (ioapic < 0) 1033 if (ioapic < 0)
1036 return; 1034 return;
1037 pin = gsi - mp_ioapic_routing[ioapic].gsi_base; 1035 pin = mp_find_ioapic_pin(ioapic, gsi);
1038 1036
1039 /* 1037 /*
1040 * TBD: This check is for faulty timer entries, where the override 1038 * TBD: This check is for faulty timer entries, where the override
@@ -1154,7 +1152,7 @@ int mp_register_gsi(u32 gsi, int triggering, int polarity)
1154 return gsi; 1152 return gsi;
1155 } 1153 }
1156 1154
1157 ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base; 1155 ioapic_pin = mp_find_ioapic_pin(ioapic, gsi);
1158 1156
1159#ifdef CONFIG_X86_32 1157#ifdef CONFIG_X86_32
1160 if (ioapic_renumber_irq) 1158 if (ioapic_renumber_irq)
@@ -1243,7 +1241,7 @@ int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin,
1243 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3); 1241 mp_irq.srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
1244 ioapic = mp_find_ioapic(gsi); 1242 ioapic = mp_find_ioapic(gsi);
1245 mp_irq.dstapic = mp_ioapic_routing[ioapic].apic_id; 1243 mp_irq.dstapic = mp_ioapic_routing[ioapic].apic_id;
1246 mp_irq.dstirq = gsi - mp_ioapic_routing[ioapic].gsi_base; 1244 mp_irq.dstirq = mp_find_ioapic_pin(ioapic, gsi);
1247 1245
1248 save_mp_irq(&mp_irq); 1246 save_mp_irq(&mp_irq);
1249#endif 1247#endif
@@ -1370,7 +1368,7 @@ static void __init acpi_process_madt(void)
1370 if (!error) { 1368 if (!error) {
1371 acpi_lapic = 1; 1369 acpi_lapic = 1;
1372 1370
1373#ifdef CONFIG_X86_GENERICARCH 1371#ifdef CONFIG_X86_BIGSMP
1374 generic_bigsmp_probe(); 1372 generic_bigsmp_probe();
1375#endif 1373#endif
1376 /* 1374 /*
@@ -1382,9 +1380,8 @@ static void __init acpi_process_madt(void)
1382 acpi_ioapic = 1; 1380 acpi_ioapic = 1;
1383 1381
1384 smp_found_config = 1; 1382 smp_found_config = 1;
1385#ifdef CONFIG_X86_32 1383 if (apic->setup_apic_routing)
1386 setup_apic_routing(); 1384 apic->setup_apic_routing();
1387#endif
1388 } 1385 }
1389 } 1386 }
1390 if (error == -EINVAL) { 1387 if (error == -EINVAL) {
diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c
index 383d827eef8..8bd801db24d 100644
--- a/arch/x86/kernel/apic.c
+++ b/arch/x86/kernel/apic.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Local APIC handling, local APIC timers 2 * Local APIC handling, local APIC timers
3 * 3 *
4 * (c) 1999, 2000 Ingo Molnar <mingo@redhat.com> 4 * (c) 1999, 2000, 2009 Ingo Molnar <mingo@redhat.com>
5 * 5 *
6 * Fixes 6 * Fixes
7 * Maciej W. Rozycki : Bits for genuine 82489DX APICs; 7 * Maciej W. Rozycki : Bits for genuine 82489DX APICs;
@@ -14,60 +14,62 @@
14 * Mikael Pettersson : PM converted to driver model. 14 * Mikael Pettersson : PM converted to driver model.
15 */ 15 */
16 16
17#include <linux/init.h>
18
19#include <linux/mm.h>
20#include <linux/delay.h>
21#include <linux/bootmem.h>
22#include <linux/interrupt.h>
23#include <linux/mc146818rtc.h>
24#include <linux/kernel_stat.h> 17#include <linux/kernel_stat.h>
25#include <linux/sysdev.h> 18#include <linux/mc146818rtc.h>
26#include <linux/ioport.h>
27#include <linux/cpu.h>
28#include <linux/clockchips.h>
29#include <linux/acpi_pmtmr.h> 19#include <linux/acpi_pmtmr.h>
20#include <linux/clockchips.h>
21#include <linux/interrupt.h>
22#include <linux/bootmem.h>
23#include <linux/ftrace.h>
24#include <linux/ioport.h>
30#include <linux/module.h> 25#include <linux/module.h>
31#include <linux/dmi.h> 26#include <linux/sysdev.h>
27#include <linux/delay.h>
28#include <linux/timex.h>
32#include <linux/dmar.h> 29#include <linux/dmar.h>
33#include <linux/ftrace.h> 30#include <linux/init.h>
34#include <linux/smp.h> 31#include <linux/cpu.h>
32#include <linux/dmi.h>
35#include <linux/nmi.h> 33#include <linux/nmi.h>
36#include <linux/timex.h> 34#include <linux/smp.h>
35#include <linux/mm.h>
37 36
38#include <asm/atomic.h>
39#include <asm/mtrr.h>
40#include <asm/mpspec.h>
41#include <asm/desc.h>
42#include <asm/arch_hooks.h> 37#include <asm/arch_hooks.h>
43#include <asm/hpet.h>
44#include <asm/pgalloc.h> 38#include <asm/pgalloc.h>
39#include <asm/genapic.h>
40#include <asm/atomic.h>
41#include <asm/mpspec.h>
45#include <asm/i8253.h> 42#include <asm/i8253.h>
46#include <asm/idle.h> 43#include <asm/i8259.h>
47#include <asm/proto.h> 44#include <asm/proto.h>
48#include <asm/apic.h> 45#include <asm/apic.h>
49#include <asm/i8259.h> 46#include <asm/desc.h>
47#include <asm/hpet.h>
48#include <asm/idle.h>
49#include <asm/mtrr.h>
50#include <asm/smp.h> 50#include <asm/smp.h>
51 51
52#include <mach_apic.h>
53#include <mach_apicdef.h>
54#include <mach_ipi.h>
55
56/*
57 * Sanity check
58 */
59#if ((SPURIOUS_APIC_VECTOR & 0x0F) != 0x0F)
60# error SPURIOUS_APIC_VECTOR definition error
61#endif
62
63unsigned int num_processors; 52unsigned int num_processors;
53
64unsigned disabled_cpus __cpuinitdata; 54unsigned disabled_cpus __cpuinitdata;
55
65/* Processor that is doing the boot up */ 56/* Processor that is doing the boot up */
66unsigned int boot_cpu_physical_apicid = -1U; 57unsigned int boot_cpu_physical_apicid = -1U;
67EXPORT_SYMBOL(boot_cpu_physical_apicid); 58
59/*
60 * The highest APIC ID seen during enumeration.
61 *
62 * This determines the messaging protocol we can use: if all APIC IDs
63 * are in the 0 ... 7 range, then we can use logical addressing which
64 * has some performance advantages (better broadcasting).
65 *
66 * If there's an APIC ID above 8, we use physical addressing.
67 */
68unsigned int max_physical_apicid; 68unsigned int max_physical_apicid;
69 69
70/* Bitmask of physically existing CPUs */ 70/*
71 * Bitmask of physically existing CPUs:
72 */
71physid_mask_t phys_cpu_present_map; 73physid_mask_t phys_cpu_present_map;
72 74
73/* 75/*
@@ -475,7 +477,7 @@ static void lapic_timer_setup(enum clock_event_mode mode,
475static void lapic_timer_broadcast(const struct cpumask *mask) 477static void lapic_timer_broadcast(const struct cpumask *mask)
476{ 478{
477#ifdef CONFIG_SMP 479#ifdef CONFIG_SMP
478 send_IPI_mask(mask, LOCAL_TIMER_VECTOR); 480 apic->send_IPI_mask(mask, LOCAL_TIMER_VECTOR);
479#endif 481#endif
480} 482}
481 483
@@ -1009,11 +1011,11 @@ int __init verify_local_APIC(void)
1009 */ 1011 */
1010 reg0 = apic_read(APIC_ID); 1012 reg0 = apic_read(APIC_ID);
1011 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0); 1013 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg0);
1012 apic_write(APIC_ID, reg0 ^ APIC_ID_MASK); 1014 apic_write(APIC_ID, reg0 ^ apic->apic_id_mask);
1013 reg1 = apic_read(APIC_ID); 1015 reg1 = apic_read(APIC_ID);
1014 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg1); 1016 apic_printk(APIC_DEBUG, "Getting ID: %x\n", reg1);
1015 apic_write(APIC_ID, reg0); 1017 apic_write(APIC_ID, reg0);
1016 if (reg1 != (reg0 ^ APIC_ID_MASK)) 1018 if (reg1 != (reg0 ^ apic->apic_id_mask))
1017 return 0; 1019 return 0;
1018 1020
1019 /* 1021 /*
@@ -1107,7 +1109,7 @@ static void __cpuinit lapic_setup_esr(void)
1107 return; 1109 return;
1108 } 1110 }
1109 1111
1110 if (esr_disable) { 1112 if (apic->disable_esr) {
1111 /* 1113 /*
1112 * Something untraceable is creating bad interrupts on 1114 * Something untraceable is creating bad interrupts on
1113 * secondary quads ... for the moment, just leave the 1115 * secondary quads ... for the moment, just leave the
@@ -1149,15 +1151,13 @@ void __cpuinit setup_local_APIC(void)
1149 int i, j; 1151 int i, j;
1150 1152
1151 if (disable_apic) { 1153 if (disable_apic) {
1152#ifdef CONFIG_X86_IO_APIC 1154 arch_disable_smp_support();
1153 disable_ioapic_setup();
1154#endif
1155 return; 1155 return;
1156 } 1156 }
1157 1157
1158#ifdef CONFIG_X86_32 1158#ifdef CONFIG_X86_32
1159 /* Pound the ESR really hard over the head with a big hammer - mbligh */ 1159 /* Pound the ESR really hard over the head with a big hammer - mbligh */
1160 if (lapic_is_integrated() && esr_disable) { 1160 if (lapic_is_integrated() && apic->disable_esr) {
1161 apic_write(APIC_ESR, 0); 1161 apic_write(APIC_ESR, 0);
1162 apic_write(APIC_ESR, 0); 1162 apic_write(APIC_ESR, 0);
1163 apic_write(APIC_ESR, 0); 1163 apic_write(APIC_ESR, 0);
@@ -1171,7 +1171,7 @@ void __cpuinit setup_local_APIC(void)
1171 * Double-check whether this APIC is really registered. 1171 * Double-check whether this APIC is really registered.
1172 * This is meaningless in clustered apic mode, so we skip it. 1172 * This is meaningless in clustered apic mode, so we skip it.
1173 */ 1173 */
1174 if (!apic_id_registered()) 1174 if (!apic->apic_id_registered())
1175 BUG(); 1175 BUG();
1176 1176
1177 /* 1177 /*
@@ -1179,7 +1179,7 @@ void __cpuinit setup_local_APIC(void)
1179 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel 1179 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
1180 * document number 292116). So here it goes... 1180 * document number 292116). So here it goes...
1181 */ 1181 */
1182 init_apic_ldr(); 1182 apic->init_apic_ldr();
1183 1183
1184 /* 1184 /*
1185 * Set Task Priority to 'accept all'. We never change this 1185 * Set Task Priority to 'accept all'. We never change this
@@ -1625,7 +1625,7 @@ int __init APIC_init_uniprocessor(void)
1625 enable_IR_x2apic(); 1625 enable_IR_x2apic();
1626#endif 1626#endif
1627#ifdef CONFIG_X86_64 1627#ifdef CONFIG_X86_64
1628 setup_apic_routing(); 1628 default_setup_apic_routing();
1629#endif 1629#endif
1630 1630
1631 verify_local_APIC(); 1631 verify_local_APIC();
@@ -1763,7 +1763,8 @@ void __init connect_bsp_APIC(void)
1763 outb(0x01, 0x23); 1763 outb(0x01, 0x23);
1764 } 1764 }
1765#endif 1765#endif
1766 enable_apic_mode(); 1766 if (apic->enable_apic_mode)
1767 apic->enable_apic_mode();
1767} 1768}
1768 1769
1769/** 1770/**
@@ -1901,7 +1902,7 @@ void __cpuinit generic_processor_info(int apicid, int version)
1901 } 1902 }
1902#endif 1903#endif
1903 1904
1904#if defined(CONFIG_X86_SMP) || defined(CONFIG_X86_64) 1905#if defined(CONFIG_SMP) || defined(CONFIG_X86_64)
1905 early_per_cpu(x86_cpu_to_apicid, cpu) = apicid; 1906 early_per_cpu(x86_cpu_to_apicid, cpu) = apicid;
1906 early_per_cpu(x86_bios_cpu_apicid, cpu) = apicid; 1907 early_per_cpu(x86_bios_cpu_apicid, cpu) = apicid;
1907#endif 1908#endif
@@ -1910,11 +1911,30 @@ void __cpuinit generic_processor_info(int apicid, int version)
1910 set_cpu_present(cpu, true); 1911 set_cpu_present(cpu, true);
1911} 1912}
1912 1913
1913#ifdef CONFIG_X86_64
1914int hard_smp_processor_id(void) 1914int hard_smp_processor_id(void)
1915{ 1915{
1916 return read_apic_id(); 1916 return read_apic_id();
1917} 1917}
1918
1919void default_init_apic_ldr(void)
1920{
1921 unsigned long val;
1922
1923 apic_write(APIC_DFR, APIC_DFR_VALUE);
1924 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
1925 val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id());
1926 apic_write(APIC_LDR, val);
1927}
1928
1929#ifdef CONFIG_X86_32
1930int default_apicid_to_node(int logical_apicid)
1931{
1932#ifdef CONFIG_SMP
1933 return apicid_2_node[hard_smp_processor_id()];
1934#else
1935 return 0;
1936#endif
1937}
1918#endif 1938#endif
1919 1939
1920/* 1940/*
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 98807bb095a..37ba5f85b71 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -301,7 +301,7 @@ extern int (*console_blank_hook)(int);
301 */ 301 */
302#define APM_ZERO_SEGS 302#define APM_ZERO_SEGS
303 303
304#include "apm.h" 304#include <asm/apm.h>
305 305
306/* 306/*
307 * Define to re-initialize the interrupt 0 timer to 100 Hz after a suspend. 307 * Define to re-initialize the interrupt 0 timer to 100 Hz after a suspend.
diff --git a/arch/x86/kernel/bigsmp_32.c b/arch/x86/kernel/bigsmp_32.c
new file mode 100644
index 00000000000..47a62f46afd
--- /dev/null
+++ b/arch/x86/kernel/bigsmp_32.c
@@ -0,0 +1,266 @@
1/*
2 * APIC driver for "bigsmp" XAPIC machines with more than 8 virtual CPUs.
3 * Drives the local APIC in "clustered mode".
4 */
5#define APIC_DEFINITION 1
6#include <linux/threads.h>
7#include <linux/cpumask.h>
8#include <asm/mpspec.h>
9#include <asm/genapic.h>
10#include <asm/fixmap.h>
11#include <asm/apicdef.h>
12#include <asm/ipi.h>
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/dmi.h>
16#include <linux/smp.h>
17
18
19static inline unsigned bigsmp_get_apic_id(unsigned long x)
20{
21 return (x >> 24) & 0xFF;
22}
23
24#define xapic_phys_to_log_apicid(cpu) (per_cpu(x86_bios_cpu_apicid, cpu))
25
26static inline int bigsmp_apic_id_registered(void)
27{
28 return 1;
29}
30
31static inline const cpumask_t *bigsmp_target_cpus(void)
32{
33#ifdef CONFIG_SMP
34 return &cpu_online_map;
35#else
36 return &cpumask_of_cpu(0);
37#endif
38}
39
40#define APIC_DFR_VALUE (APIC_DFR_FLAT)
41
42static inline unsigned long
43bigsmp_check_apicid_used(physid_mask_t bitmap, int apicid)
44{
45 return 0;
46}
47
48static inline unsigned long bigsmp_check_apicid_present(int bit)
49{
50 return 1;
51}
52
53static inline unsigned long calculate_ldr(int cpu)
54{
55 unsigned long val, id;
56 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
57 id = xapic_phys_to_log_apicid(cpu);
58 val |= SET_APIC_LOGICAL_ID(id);
59 return val;
60}
61
62/*
63 * Set up the logical destination ID.
64 *
65 * Intel recommends to set DFR, LDR and TPR before enabling
66 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
67 * document number 292116). So here it goes...
68 */
69static inline void bigsmp_init_apic_ldr(void)
70{
71 unsigned long val;
72 int cpu = smp_processor_id();
73
74 apic_write(APIC_DFR, APIC_DFR_VALUE);
75 val = calculate_ldr(cpu);
76 apic_write(APIC_LDR, val);
77}
78
79static inline void bigsmp_setup_apic_routing(void)
80{
81 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
82 "Physflat", nr_ioapics);
83}
84
85static inline int bigsmp_apicid_to_node(int logical_apicid)
86{
87 return apicid_2_node[hard_smp_processor_id()];
88}
89
90static inline int bigsmp_cpu_present_to_apicid(int mps_cpu)
91{
92 if (mps_cpu < nr_cpu_ids)
93 return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
94
95 return BAD_APICID;
96}
97
98static inline physid_mask_t bigsmp_apicid_to_cpu_present(int phys_apicid)
99{
100 return physid_mask_of_physid(phys_apicid);
101}
102
103extern u8 cpu_2_logical_apicid[];
104/* Mapping from cpu number to logical apicid */
105static inline int bigsmp_cpu_to_logical_apicid(int cpu)
106{
107 if (cpu >= nr_cpu_ids)
108 return BAD_APICID;
109 return cpu_physical_id(cpu);
110}
111
112static inline physid_mask_t bigsmp_ioapic_phys_id_map(physid_mask_t phys_map)
113{
114 /* For clustered we don't have a good way to do this yet - hack */
115 return physids_promote(0xFFL);
116}
117
118static inline void bigsmp_setup_portio_remap(void)
119{
120}
121
122static inline int bigsmp_check_phys_apicid_present(int boot_cpu_physical_apicid)
123{
124 return 1;
125}
126
127/* As we are using single CPU as destination, pick only one CPU here */
128static inline unsigned int bigsmp_cpu_mask_to_apicid(const cpumask_t *cpumask)
129{
130 return bigsmp_cpu_to_logical_apicid(first_cpu(*cpumask));
131}
132
133static inline unsigned int
134bigsmp_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
135 const struct cpumask *andmask)
136{
137 int cpu;
138
139 /*
140 * We're using fixed IRQ delivery, can only return one phys APIC ID.
141 * May as well be the first.
142 */
143 for_each_cpu_and(cpu, cpumask, andmask) {
144 if (cpumask_test_cpu(cpu, cpu_online_mask))
145 break;
146 }
147 if (cpu < nr_cpu_ids)
148 return bigsmp_cpu_to_logical_apicid(cpu);
149
150 return BAD_APICID;
151}
152
153static inline int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb)
154{
155 return cpuid_apic >> index_msb;
156}
157
158static inline void bigsmp_send_IPI_mask(const struct cpumask *mask, int vector)
159{
160 default_send_IPI_mask_sequence_phys(mask, vector);
161}
162
163static inline void bigsmp_send_IPI_allbutself(int vector)
164{
165 default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
166}
167
168static inline void bigsmp_send_IPI_all(int vector)
169{
170 bigsmp_send_IPI_mask(cpu_online_mask, vector);
171}
172
173static int dmi_bigsmp; /* can be set by dmi scanners */
174
175static int hp_ht_bigsmp(const struct dmi_system_id *d)
176{
177 printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
178 dmi_bigsmp = 1;
179 return 0;
180}
181
182
183static const struct dmi_system_id bigsmp_dmi_table[] = {
184 { hp_ht_bigsmp, "HP ProLiant DL760 G2",
185 { DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
186 DMI_MATCH(DMI_BIOS_VERSION, "P44-"),}
187 },
188
189 { hp_ht_bigsmp, "HP ProLiant DL740",
190 { DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
191 DMI_MATCH(DMI_BIOS_VERSION, "P47-"),}
192 },
193 { }
194};
195
196static void bigsmp_vector_allocation_domain(int cpu, cpumask_t *retmask)
197{
198 cpus_clear(*retmask);
199 cpu_set(cpu, *retmask);
200}
201
202static int probe_bigsmp(void)
203{
204 if (def_to_bigsmp)
205 dmi_bigsmp = 1;
206 else
207 dmi_check_system(bigsmp_dmi_table);
208 return dmi_bigsmp;
209}
210
211struct genapic apic_bigsmp = {
212
213 .name = "bigsmp",
214 .probe = probe_bigsmp,
215 .acpi_madt_oem_check = NULL,
216 .apic_id_registered = bigsmp_apic_id_registered,
217
218 .irq_delivery_mode = dest_Fixed,
219 /* phys delivery to target CPU: */
220 .irq_dest_mode = 0,
221
222 .target_cpus = bigsmp_target_cpus,
223 .disable_esr = 1,
224 .dest_logical = 0,
225 .check_apicid_used = bigsmp_check_apicid_used,
226 .check_apicid_present = bigsmp_check_apicid_present,
227
228 .vector_allocation_domain = bigsmp_vector_allocation_domain,
229 .init_apic_ldr = bigsmp_init_apic_ldr,
230
231 .ioapic_phys_id_map = bigsmp_ioapic_phys_id_map,
232 .setup_apic_routing = bigsmp_setup_apic_routing,
233 .multi_timer_check = NULL,
234 .apicid_to_node = bigsmp_apicid_to_node,
235 .cpu_to_logical_apicid = bigsmp_cpu_to_logical_apicid,
236 .cpu_present_to_apicid = bigsmp_cpu_present_to_apicid,
237 .apicid_to_cpu_present = bigsmp_apicid_to_cpu_present,
238 .setup_portio_remap = NULL,
239 .check_phys_apicid_present = bigsmp_check_phys_apicid_present,
240 .enable_apic_mode = NULL,
241 .phys_pkg_id = bigsmp_phys_pkg_id,
242 .mps_oem_check = NULL,
243
244 .get_apic_id = bigsmp_get_apic_id,
245 .set_apic_id = NULL,
246 .apic_id_mask = 0xFF << 24,
247
248 .cpu_mask_to_apicid = bigsmp_cpu_mask_to_apicid,
249 .cpu_mask_to_apicid_and = bigsmp_cpu_mask_to_apicid_and,
250
251 .send_IPI_mask = bigsmp_send_IPI_mask,
252 .send_IPI_mask_allbutself = NULL,
253 .send_IPI_allbutself = bigsmp_send_IPI_allbutself,
254 .send_IPI_all = bigsmp_send_IPI_all,
255 .send_IPI_self = default_send_IPI_self,
256
257 .wakeup_cpu = NULL,
258 .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
259 .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
260
261 .wait_for_init_deassert = default_wait_for_init_deassert,
262
263 .smp_callin_clear_local_apic = NULL,
264 .store_NMI_vector = NULL,
265 .inquire_remote_apic = default_inquire_remote_apic,
266};
diff --git a/arch/x86/kernel/cpu/addon_cpuid_features.c b/arch/x86/kernel/cpu/addon_cpuid_features.c
index 2cf23634b6d..e48640cfac0 100644
--- a/arch/x86/kernel/cpu/addon_cpuid_features.c
+++ b/arch/x86/kernel/cpu/addon_cpuid_features.c
@@ -7,7 +7,7 @@
7#include <asm/pat.h> 7#include <asm/pat.h>
8#include <asm/processor.h> 8#include <asm/processor.h>
9 9
10#include <mach_apic.h> 10#include <asm/genapic.h>
11 11
12struct cpuid_bit { 12struct cpuid_bit {
13 u16 feature; 13 u16 feature;
@@ -69,7 +69,7 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
69 */ 69 */
70void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c) 70void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)
71{ 71{
72#ifdef CONFIG_X86_SMP 72#ifdef CONFIG_SMP
73 unsigned int eax, ebx, ecx, edx, sub_index; 73 unsigned int eax, ebx, ecx, edx, sub_index;
74 unsigned int ht_mask_width, core_plus_mask_width; 74 unsigned int ht_mask_width, core_plus_mask_width;
75 unsigned int core_select_mask, core_level_siblings; 75 unsigned int core_select_mask, core_level_siblings;
@@ -116,22 +116,14 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)
116 116
117 core_select_mask = (~(-1 << core_plus_mask_width)) >> ht_mask_width; 117 core_select_mask = (~(-1 << core_plus_mask_width)) >> ht_mask_width;
118 118
119#ifdef CONFIG_X86_32 119 c->cpu_core_id = apic->phys_pkg_id(c->initial_apicid, ht_mask_width)
120 c->cpu_core_id = phys_pkg_id(c->initial_apicid, ht_mask_width)
121 & core_select_mask; 120 & core_select_mask;
122 c->phys_proc_id = phys_pkg_id(c->initial_apicid, core_plus_mask_width); 121 c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, core_plus_mask_width);
123 /* 122 /*
124 * Reinit the apicid, now that we have extended initial_apicid. 123 * Reinit the apicid, now that we have extended initial_apicid.
125 */ 124 */
126 c->apicid = phys_pkg_id(c->initial_apicid, 0); 125 c->apicid = apic->phys_pkg_id(c->initial_apicid, 0);
127#else 126
128 c->cpu_core_id = phys_pkg_id(ht_mask_width) & core_select_mask;
129 c->phys_proc_id = phys_pkg_id(core_plus_mask_width);
130 /*
131 * Reinit the apicid, now that we have extended initial_apicid.
132 */
133 c->apicid = phys_pkg_id(0);
134#endif
135 c->x86_max_cores = (core_level_siblings / smp_num_siblings); 127 c->x86_max_cores = (core_level_siblings / smp_num_siblings);
136 128
137 129
@@ -143,37 +135,3 @@ void __cpuinit detect_extended_topology(struct cpuinfo_x86 *c)
143 return; 135 return;
144#endif 136#endif
145} 137}
146
147#ifdef CONFIG_X86_PAT
148void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
149{
150 if (!cpu_has_pat)
151 pat_disable("PAT not supported by CPU.");
152
153 switch (c->x86_vendor) {
154 case X86_VENDOR_INTEL:
155 /*
156 * There is a known erratum on Pentium III and Core Solo
157 * and Core Duo CPUs.
158 * " Page with PAT set to WC while associated MTRR is UC
159 * may consolidate to UC "
160 * Because of this erratum, it is better to stick with
161 * setting WC in MTRR rather than using PAT on these CPUs.
162 *
163 * Enable PAT WC only on P4, Core 2 or later CPUs.
164 */
165 if (c->x86 > 0x6 || (c->x86 == 6 && c->x86_model >= 15))
166 return;
167
168 pat_disable("PAT WC disabled due to known CPU erratum.");
169 return;
170
171 case X86_VENDOR_AMD:
172 case X86_VENDOR_CENTAUR:
173 case X86_VENDOR_TRANSMETA:
174 return;
175 }
176
177 pat_disable("PAT disabled. Not yet verified on this CPU type.");
178}
179#endif
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index 7c878f6aa91..ff4d7b9e32e 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -12,7 +12,7 @@
12# include <asm/cacheflush.h> 12# include <asm/cacheflush.h>
13#endif 13#endif
14 14
15#include <mach_apic.h> 15#include <asm/genapic.h>
16 16
17#include "cpu.h" 17#include "cpu.h"
18 18
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 260fe4cb2c8..e8f4a386bd9 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -26,7 +26,7 @@
26#ifdef CONFIG_X86_LOCAL_APIC 26#ifdef CONFIG_X86_LOCAL_APIC
27#include <asm/mpspec.h> 27#include <asm/mpspec.h>
28#include <asm/apic.h> 28#include <asm/apic.h>
29#include <mach_apic.h> 29#include <asm/genapic.h>
30#include <asm/genapic.h> 30#include <asm/genapic.h>
31#include <asm/uv/uv.h> 31#include <asm/uv/uv.h>
32#endif 32#endif
@@ -226,6 +226,49 @@ static inline void squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
226#endif 226#endif
227 227
228/* 228/*
229 * Some CPU features depend on higher CPUID levels, which may not always
230 * be available due to CPUID level capping or broken virtualization
231 * software. Add those features to this table to auto-disable them.
232 */
233struct cpuid_dependent_feature {
234 u32 feature;
235 u32 level;
236};
237static const struct cpuid_dependent_feature __cpuinitconst
238cpuid_dependent_features[] = {
239 { X86_FEATURE_MWAIT, 0x00000005 },
240 { X86_FEATURE_DCA, 0x00000009 },
241 { X86_FEATURE_XSAVE, 0x0000000d },
242 { 0, 0 }
243};
244
245static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn)
246{
247 const struct cpuid_dependent_feature *df;
248 for (df = cpuid_dependent_features; df->feature; df++) {
249 /*
250 * Note: cpuid_level is set to -1 if unavailable, but
251 * extended_extended_level is set to 0 if unavailable
252 * and the legitimate extended levels are all negative
253 * when signed; hence the weird messing around with
254 * signs here...
255 */
256 if (cpu_has(c, df->feature) &&
257 ((s32)df->feature < 0 ?
258 (u32)df->feature > (u32)c->extended_cpuid_level :
259 (s32)df->feature > (s32)c->cpuid_level)) {
260 clear_cpu_cap(c, df->feature);
261 if (warn)
262 printk(KERN_WARNING
263 "CPU: CPU feature %s disabled "
264 "due to lack of CPUID level 0x%x\n",
265 x86_cap_flags[df->feature],
266 df->level);
267 }
268 }
269}
270
271/*
229 * Naming convention should be: <Name> [(<Codename>)] 272 * Naming convention should be: <Name> [(<Codename>)]
230 * This table only is used unless init_<vendor>() below doesn't set it; 273 * This table only is used unless init_<vendor>() below doesn't set it;
231 * in particular, if CPUID levels 0x80000002..4 are supported, this isn't used 274 * in particular, if CPUID levels 0x80000002..4 are supported, this isn't used
@@ -407,11 +450,7 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
407 } 450 }
408 451
409 index_msb = get_count_order(smp_num_siblings); 452 index_msb = get_count_order(smp_num_siblings);
410#ifdef CONFIG_X86_64 453 c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, index_msb);
411 c->phys_proc_id = phys_pkg_id(index_msb);
412#else
413 c->phys_proc_id = phys_pkg_id(c->initial_apicid, index_msb);
414#endif
415 454
416 smp_num_siblings = smp_num_siblings / c->x86_max_cores; 455 smp_num_siblings = smp_num_siblings / c->x86_max_cores;
417 456
@@ -419,13 +458,8 @@ void __cpuinit detect_ht(struct cpuinfo_x86 *c)
419 458
420 core_bits = get_count_order(c->x86_max_cores); 459 core_bits = get_count_order(c->x86_max_cores);
421 460
422#ifdef CONFIG_X86_64 461 c->cpu_core_id = apic->phys_pkg_id(c->initial_apicid, index_msb) &
423 c->cpu_core_id = phys_pkg_id(index_msb) &
424 ((1 << core_bits) - 1);
425#else
426 c->cpu_core_id = phys_pkg_id(c->initial_apicid, index_msb) &
427 ((1 << core_bits) - 1); 462 ((1 << core_bits) - 1);
428#endif
429 } 463 }
430 464
431out: 465out:
@@ -594,11 +628,10 @@ static void __init early_identify_cpu(struct cpuinfo_x86 *c)
594 if (this_cpu->c_early_init) 628 if (this_cpu->c_early_init)
595 this_cpu->c_early_init(c); 629 this_cpu->c_early_init(c);
596 630
597 validate_pat_support(c);
598
599#ifdef CONFIG_SMP 631#ifdef CONFIG_SMP
600 c->cpu_index = boot_cpu_id; 632 c->cpu_index = boot_cpu_id;
601#endif 633#endif
634 filter_cpuid_features(c, false);
602} 635}
603 636
604void __init early_cpu_init(void) 637void __init early_cpu_init(void)
@@ -661,7 +694,7 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
661 c->initial_apicid = (cpuid_ebx(1) >> 24) & 0xFF; 694 c->initial_apicid = (cpuid_ebx(1) >> 24) & 0xFF;
662#ifdef CONFIG_X86_32 695#ifdef CONFIG_X86_32
663# ifdef CONFIG_X86_HT 696# ifdef CONFIG_X86_HT
664 c->apicid = phys_pkg_id(c->initial_apicid, 0); 697 c->apicid = apic->phys_pkg_id(c->initial_apicid, 0);
665# else 698# else
666 c->apicid = c->initial_apicid; 699 c->apicid = c->initial_apicid;
667# endif 700# endif
@@ -708,7 +741,7 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
708 this_cpu->c_identify(c); 741 this_cpu->c_identify(c);
709 742
710#ifdef CONFIG_X86_64 743#ifdef CONFIG_X86_64
711 c->apicid = phys_pkg_id(0); 744 c->apicid = apic->phys_pkg_id(c->initial_apicid, 0);
712#endif 745#endif
713 746
714 /* 747 /*
@@ -732,6 +765,9 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
732 * we do "generic changes." 765 * we do "generic changes."
733 */ 766 */
734 767
768 /* Filter out anything that depends on CPUID levels we don't have */
769 filter_cpuid_features(c, true);
770
735 /* If the model name is still unset, do table lookup. */ 771 /* If the model name is still unset, do table lookup. */
736 if (!c->x86_model_id[0]) { 772 if (!c->x86_model_id[0]) {
737 char *p; 773 char *p;
@@ -1062,22 +1098,19 @@ void __cpuinit cpu_init(void)
1062 */ 1098 */
1063 if (kgdb_connected && arch_kgdb_ops.correct_hw_break) 1099 if (kgdb_connected && arch_kgdb_ops.correct_hw_break)
1064 arch_kgdb_ops.correct_hw_break(); 1100 arch_kgdb_ops.correct_hw_break();
1065 else { 1101 else
1066#endif 1102#endif
1067 /* 1103 {
1068 * Clear all 6 debug registers: 1104 /*
1069 */ 1105 * Clear all 6 debug registers:
1070 1106 */
1071 set_debugreg(0UL, 0); 1107 set_debugreg(0UL, 0);
1072 set_debugreg(0UL, 1); 1108 set_debugreg(0UL, 1);
1073 set_debugreg(0UL, 2); 1109 set_debugreg(0UL, 2);
1074 set_debugreg(0UL, 3); 1110 set_debugreg(0UL, 3);
1075 set_debugreg(0UL, 6); 1111 set_debugreg(0UL, 6);
1076 set_debugreg(0UL, 7); 1112 set_debugreg(0UL, 7);
1077#ifdef CONFIG_KGDB
1078 /* If the kgdb is connected no debug regs should be altered. */
1079 } 1113 }
1080#endif
1081 1114
1082 fpu_init(); 1115 fpu_init();
1083 1116
diff --git a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
index 5c28b37dea1..fb039cd345d 100644
--- a/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/x86/kernel/cpu/cpufreq/powernow-k8.c
@@ -939,10 +939,25 @@ static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data)
939 free_cpumask_var(data->acpi_data.shared_cpu_map); 939 free_cpumask_var(data->acpi_data.shared_cpu_map);
940} 940}
941 941
942static int get_transition_latency(struct powernow_k8_data *data)
943{
944 int max_latency = 0;
945 int i;
946 for (i = 0; i < data->acpi_data.state_count; i++) {
947 int cur_latency = data->acpi_data.states[i].transition_latency
948 + data->acpi_data.states[i].bus_master_latency;
949 if (cur_latency > max_latency)
950 max_latency = cur_latency;
951 }
952 /* value in usecs, needs to be in nanoseconds */
953 return 1000 * max_latency;
954}
955
942#else 956#else
943static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) { return -ENODEV; } 957static int powernow_k8_cpu_init_acpi(struct powernow_k8_data *data) { return -ENODEV; }
944static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) { return; } 958static void powernow_k8_cpu_exit_acpi(struct powernow_k8_data *data) { return; }
945static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) { return; } 959static void powernow_k8_acpi_pst_values(struct powernow_k8_data *data, unsigned int index) { return; }
960static int get_transition_latency(struct powernow_k8_data *data) { return 0; }
946#endif /* CONFIG_X86_POWERNOW_K8_ACPI */ 961#endif /* CONFIG_X86_POWERNOW_K8_ACPI */
947 962
948/* Take a frequency, and issue the fid/vid transition command */ 963/* Take a frequency, and issue the fid/vid transition command */
@@ -1173,7 +1188,13 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1173 if (rc) { 1188 if (rc) {
1174 goto err_out; 1189 goto err_out;
1175 } 1190 }
1176 } 1191 /* Take a crude guess here.
1192 * That guess was in microseconds, so multiply with 1000 */
1193 pol->cpuinfo.transition_latency = (
1194 ((data->rvo + 8) * data->vstable * VST_UNITS_20US) +
1195 ((1 << data->irt) * 30)) * 1000;
1196 } else /* ACPI _PSS objects available */
1197 pol->cpuinfo.transition_latency = get_transition_latency(data);
1177 1198
1178 /* only run on specific CPU from here on */ 1199 /* only run on specific CPU from here on */
1179 oldmask = current->cpus_allowed; 1200 oldmask = current->cpus_allowed;
@@ -1204,11 +1225,6 @@ static int __cpuinit powernowk8_cpu_init(struct cpufreq_policy *pol)
1204 cpumask_copy(pol->cpus, &per_cpu(cpu_core_map, pol->cpu)); 1225 cpumask_copy(pol->cpus, &per_cpu(cpu_core_map, pol->cpu));
1205 data->available_cores = pol->cpus; 1226 data->available_cores = pol->cpus;
1206 1227
1207 /* Take a crude guess here.
1208 * That guess was in microseconds, so multiply with 1000 */
1209 pol->cpuinfo.transition_latency = (((data->rvo + 8) * data->vstable * VST_UNITS_20US)
1210 + (3 * (1 << data->irt) * 10)) * 1000;
1211
1212 if (cpu_family == CPU_HW_PSTATE) 1228 if (cpu_family == CPU_HW_PSTATE)
1213 pol->cur = find_khz_freq_from_pstate(data->powernow_table, data->currpstate); 1229 pol->cur = find_khz_freq_from_pstate(data->powernow_table, data->currpstate);
1214 else 1230 else
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 24ff26a38ad..1f137a87d4b 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -24,7 +24,7 @@
24#ifdef CONFIG_X86_LOCAL_APIC 24#ifdef CONFIG_X86_LOCAL_APIC
25#include <asm/mpspec.h> 25#include <asm/mpspec.h>
26#include <asm/apic.h> 26#include <asm/apic.h>
27#include <mach_apic.h> 27#include <asm/genapic.h>
28#endif 28#endif
29 29
30static void __cpuinit early_init_intel(struct cpuinfo_x86 *c) 30static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
@@ -63,6 +63,18 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
63 set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC); 63 set_cpu_cap(c, X86_FEATURE_NONSTOP_TSC);
64 } 64 }
65 65
66 /*
67 * There is a known erratum on Pentium III and Core Solo
68 * and Core Duo CPUs.
69 * " Page with PAT set to WC while associated MTRR is UC
70 * may consolidate to UC "
71 * Because of this erratum, it is better to stick with
72 * setting WC in MTRR rather than using PAT on these CPUs.
73 *
74 * Enable PAT WC only on P4, Core 2 or later CPUs.
75 */
76 if (c->x86 == 6 && c->x86_model < 15)
77 clear_cpu_cap(c, X86_FEATURE_PAT);
66} 78}
67 79
68#ifdef CONFIG_X86_32 80#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index 11b93cabdf7..ad7f2a696f4 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -28,7 +28,7 @@
28#include <asm/reboot.h> 28#include <asm/reboot.h>
29#include <asm/virtext.h> 29#include <asm/virtext.h>
30 30
31#include <mach_ipi.h> 31#include <asm/genapic.h>
32 32
33 33
34#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) 34#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 3de7b5710dc..e9920683145 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -812,7 +812,7 @@ ENDPROC(name)
812#define BUILD_INTERRUPT(name, nr) BUILD_INTERRUPT3(name, nr, smp_##name) 812#define BUILD_INTERRUPT(name, nr) BUILD_INTERRUPT3(name, nr, smp_##name)
813 813
814/* The include is where all of the SMP etc. interrupts come from */ 814/* The include is where all of the SMP etc. interrupts come from */
815#include "entry_arch.h" 815#include <asm/entry_arch.h>
816 816
817ENTRY(coprocessor_error) 817ENTRY(coprocessor_error)
818 RING0_INT_FRAME 818 RING0_INT_FRAME
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 586bed67755..fbcf96b295f 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -410,6 +410,8 @@ END(save_paranoid)
410ENTRY(ret_from_fork) 410ENTRY(ret_from_fork)
411 DEFAULT_FRAME 411 DEFAULT_FRAME
412 412
413 LOCK ; btr $TIF_FORK,TI_flags(%r8)
414
413 push kernel_eflags(%rip) 415 push kernel_eflags(%rip)
414 CFI_ADJUST_CFA_OFFSET 8 416 CFI_ADJUST_CFA_OFFSET 8
415 popf # reset kernel eflags 417 popf # reset kernel eflags
diff --git a/arch/x86/kernel/es7000_32.c b/arch/x86/kernel/es7000_32.c
index 53699c931ad..d6184c12a18 100644
--- a/arch/x86/kernel/es7000_32.c
+++ b/arch/x86/kernel/es7000_32.c
@@ -40,7 +40,6 @@
40#include <asm/smp.h> 40#include <asm/smp.h>
41#include <asm/atomic.h> 41#include <asm/atomic.h>
42#include <asm/apicdef.h> 42#include <asm/apicdef.h>
43#include <mach_mpparse.h>
44#include <asm/genapic.h> 43#include <asm/genapic.h>
45#include <asm/setup.h> 44#include <asm/setup.h>
46 45
@@ -182,20 +181,16 @@ static int wakeup_secondary_cpu_via_mip(int cpu, unsigned long eip)
182 return 0; 181 return 0;
183} 182}
184 183
185static void noop_wait_for_deassert(atomic_t *deassert_not_used)
186{
187}
188
189static int __init es7000_update_genapic(void) 184static int __init es7000_update_genapic(void)
190{ 185{
191 genapic->wakeup_cpu = wakeup_secondary_cpu_via_mip; 186 apic->wakeup_cpu = wakeup_secondary_cpu_via_mip;
192 187
193 /* MPENTIUMIII */ 188 /* MPENTIUMIII */
194 if (boot_cpu_data.x86 == 6 && 189 if (boot_cpu_data.x86 == 6 &&
195 (boot_cpu_data.x86_model >= 7 || boot_cpu_data.x86_model <= 11)) { 190 (boot_cpu_data.x86_model >= 7 || boot_cpu_data.x86_model <= 11)) {
196 es7000_update_genapic_to_cluster(); 191 es7000_update_genapic_to_cluster();
197 genapic->wait_for_init_deassert = noop_wait_for_deassert; 192 apic->wait_for_init_deassert = NULL;
198 genapic->wakeup_cpu = wakeup_secondary_cpu_via_mip; 193 apic->wakeup_cpu = wakeup_secondary_cpu_via_mip;
199 } 194 }
200 195
201 return 0; 196 return 0;
@@ -359,20 +354,449 @@ es7000_mip_write(struct mip_reg *mip_reg)
359 return status; 354 return status;
360} 355}
361 356
362void __init 357void __init es7000_enable_apic_mode(void)
363es7000_sw_apic(void) 358{
364{ 359 struct mip_reg es7000_mip_reg;
365 if (es7000_plat) { 360 int mip_status;
366 int mip_status; 361
367 struct mip_reg es7000_mip_reg; 362 if (!es7000_plat)
368
369 printk("ES7000: Enabling APIC mode.\n");
370 memset(&es7000_mip_reg, 0, sizeof(struct mip_reg));
371 es7000_mip_reg.off_0 = MIP_SW_APIC;
372 es7000_mip_reg.off_38 = (MIP_VALID);
373 while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0)
374 printk("es7000_sw_apic: command failed, status = %x\n",
375 mip_status);
376 return; 363 return;
364
365 printk("ES7000: Enabling APIC mode.\n");
366 memset(&es7000_mip_reg, 0, sizeof(struct mip_reg));
367 es7000_mip_reg.off_0 = MIP_SW_APIC;
368 es7000_mip_reg.off_38 = MIP_VALID;
369
370 while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0) {
371 printk("es7000_enable_apic_mode: command failed, status = %x\n",
372 mip_status);
373 }
374}
375
376/*
377 * APIC driver for the Unisys ES7000 chipset.
378 */
379#define APIC_DEFINITION 1
380#include <linux/threads.h>
381#include <linux/cpumask.h>
382#include <asm/mpspec.h>
383#include <asm/genapic.h>
384#include <asm/fixmap.h>
385#include <asm/apicdef.h>
386#include <linux/kernel.h>
387#include <linux/string.h>
388#include <linux/init.h>
389#include <linux/acpi.h>
390#include <linux/smp.h>
391#include <asm/ipi.h>
392
393#define APIC_DFR_VALUE_CLUSTER (APIC_DFR_CLUSTER)
394#define INT_DELIVERY_MODE_CLUSTER (dest_LowestPrio)
395#define INT_DEST_MODE_CLUSTER (1) /* logical delivery broadcast to all procs */
396
397#define APIC_DFR_VALUE (APIC_DFR_FLAT)
398
399extern void es7000_enable_apic_mode(void);
400extern int apic_version [MAX_APICS];
401extern u8 cpu_2_logical_apicid[];
402extern unsigned int boot_cpu_physical_apicid;
403
404extern int parse_unisys_oem (char *oemptr);
405extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
406extern void unmap_unisys_acpi_oem_table(unsigned long oem_addr);
407extern void setup_unisys(void);
408
409#define apicid_cluster(apicid) (apicid & 0xF0)
410#define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu)
411
412static void es7000_vector_allocation_domain(int cpu, cpumask_t *retmask)
413{
414 /* Careful. Some cpus do not strictly honor the set of cpus
415 * specified in the interrupt destination when using lowest
416 * priority interrupt delivery mode.
417 *
418 * In particular there was a hyperthreading cpu observed to
419 * deliver interrupts to the wrong hyperthread when only one
420 * hyperthread was specified in the interrupt desitination.
421 */
422 *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
423}
424
425
426static void es7000_wait_for_init_deassert(atomic_t *deassert)
427{
428#ifndef CONFIG_ES7000_CLUSTERED_APIC
429 while (!atomic_read(deassert))
430 cpu_relax();
431#endif
432 return;
433}
434
435static unsigned int es7000_get_apic_id(unsigned long x)
436{
437 return (x >> 24) & 0xFF;
438}
439
440#ifdef CONFIG_ACPI
441static int es7000_check_dsdt(void)
442{
443 struct acpi_table_header header;
444
445 if (ACPI_SUCCESS(acpi_get_table_header(ACPI_SIG_DSDT, 0, &header)) &&
446 !strncmp(header.oem_id, "UNISYS", 6))
447 return 1;
448 return 0;
449}
450#endif
451
452static void es7000_send_IPI_mask(const struct cpumask *mask, int vector)
453{
454 default_send_IPI_mask_sequence_phys(mask, vector);
455}
456
457static void es7000_send_IPI_allbutself(int vector)
458{
459 default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
460}
461
462static void es7000_send_IPI_all(int vector)
463{
464 es7000_send_IPI_mask(cpu_online_mask, vector);
465}
466
467static int es7000_apic_id_registered(void)
468{
469 return 1;
470}
471
472static const cpumask_t *target_cpus_cluster(void)
473{
474 return &CPU_MASK_ALL;
475}
476
477static const cpumask_t *es7000_target_cpus(void)
478{
479 return &cpumask_of_cpu(smp_processor_id());
480}
481
482static unsigned long
483es7000_check_apicid_used(physid_mask_t bitmap, int apicid)
484{
485 return 0;
486}
487static unsigned long es7000_check_apicid_present(int bit)
488{
489 return physid_isset(bit, phys_cpu_present_map);
490}
491
492static unsigned long calculate_ldr(int cpu)
493{
494 unsigned long id = xapic_phys_to_log_apicid(cpu);
495
496 return (SET_APIC_LOGICAL_ID(id));
497}
498
499/*
500 * Set up the logical destination ID.
501 *
502 * Intel recommends to set DFR, LdR and TPR before enabling
503 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
504 * document number 292116). So here it goes...
505 */
506static void es7000_init_apic_ldr_cluster(void)
507{
508 unsigned long val;
509 int cpu = smp_processor_id();
510
511 apic_write(APIC_DFR, APIC_DFR_VALUE_CLUSTER);
512 val = calculate_ldr(cpu);
513 apic_write(APIC_LDR, val);
514}
515
516static void es7000_init_apic_ldr(void)
517{
518 unsigned long val;
519 int cpu = smp_processor_id();
520
521 apic_write(APIC_DFR, APIC_DFR_VALUE);
522 val = calculate_ldr(cpu);
523 apic_write(APIC_LDR, val);
524}
525
526static void es7000_setup_apic_routing(void)
527{
528 int apic = per_cpu(x86_bios_cpu_apicid, smp_processor_id());
529 printk("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n",
530 (apic_version[apic] == 0x14) ?
531 "Physical Cluster" : "Logical Cluster",
532 nr_ioapics, cpus_addr(*es7000_target_cpus())[0]);
533}
534
535static int es7000_apicid_to_node(int logical_apicid)
536{
537 return 0;
538}
539
540
541static int es7000_cpu_present_to_apicid(int mps_cpu)
542{
543 if (!mps_cpu)
544 return boot_cpu_physical_apicid;
545 else if (mps_cpu < nr_cpu_ids)
546 return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
547 else
548 return BAD_APICID;
549}
550
551static physid_mask_t es7000_apicid_to_cpu_present(int phys_apicid)
552{
553 static int id = 0;
554 physid_mask_t mask;
555
556 mask = physid_mask_of_physid(id);
557 ++id;
558
559 return mask;
560}
561
562/* Mapping from cpu number to logical apicid */
563static int es7000_cpu_to_logical_apicid(int cpu)
564{
565#ifdef CONFIG_SMP
566 if (cpu >= nr_cpu_ids)
567 return BAD_APICID;
568 return (int)cpu_2_logical_apicid[cpu];
569#else
570 return logical_smp_processor_id();
571#endif
572}
573
574static physid_mask_t es7000_ioapic_phys_id_map(physid_mask_t phys_map)
575{
576 /* For clustered we don't have a good way to do this yet - hack */
577 return physids_promote(0xff);
578}
579
580static int es7000_check_phys_apicid_present(int cpu_physical_apicid)
581{
582 boot_cpu_physical_apicid = read_apic_id();
583 return (1);
584}
585
586static unsigned int
587es7000_cpu_mask_to_apicid_cluster(const struct cpumask *cpumask)
588{
589 int cpus_found = 0;
590 int num_bits_set;
591 int apicid;
592 int cpu;
593
594 num_bits_set = cpumask_weight(cpumask);
595 /* Return id to all */
596 if (num_bits_set == nr_cpu_ids)
597 return 0xFF;
598 /*
599 * The cpus in the mask must all be on the apic cluster. If are not
600 * on the same apicid cluster return default value of target_cpus():
601 */
602 cpu = cpumask_first(cpumask);
603 apicid = es7000_cpu_to_logical_apicid(cpu);
604
605 while (cpus_found < num_bits_set) {
606 if (cpumask_test_cpu(cpu, cpumask)) {
607 int new_apicid = es7000_cpu_to_logical_apicid(cpu);
608
609 if (apicid_cluster(apicid) !=
610 apicid_cluster(new_apicid)) {
611 printk ("%s: Not a valid mask!\n", __func__);
612
613 return 0xFF;
614 }
615 apicid = new_apicid;
616 cpus_found++;
617 }
618 cpu++;
377 } 619 }
620 return apicid;
378} 621}
622
623static unsigned int es7000_cpu_mask_to_apicid(const cpumask_t *cpumask)
624{
625 int cpus_found = 0;
626 int num_bits_set;
627 int apicid;
628 int cpu;
629
630 num_bits_set = cpus_weight(*cpumask);
631 /* Return id to all */
632 if (num_bits_set == nr_cpu_ids)
633 return es7000_cpu_to_logical_apicid(0);
634 /*
635 * The cpus in the mask must all be on the apic cluster. If are not
636 * on the same apicid cluster return default value of target_cpus():
637 */
638 cpu = first_cpu(*cpumask);
639 apicid = es7000_cpu_to_logical_apicid(cpu);
640 while (cpus_found < num_bits_set) {
641 if (cpu_isset(cpu, *cpumask)) {
642 int new_apicid = es7000_cpu_to_logical_apicid(cpu);
643
644 if (apicid_cluster(apicid) !=
645 apicid_cluster(new_apicid)) {
646 printk ("%s: Not a valid mask!\n", __func__);
647
648 return es7000_cpu_to_logical_apicid(0);
649 }
650 apicid = new_apicid;
651 cpus_found++;
652 }
653 cpu++;
654 }
655 return apicid;
656}
657
658static unsigned int
659es7000_cpu_mask_to_apicid_and(const struct cpumask *inmask,
660 const struct cpumask *andmask)
661{
662 int apicid = es7000_cpu_to_logical_apicid(0);
663 cpumask_var_t cpumask;
664
665 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC))
666 return apicid;
667
668 cpumask_and(cpumask, inmask, andmask);
669 cpumask_and(cpumask, cpumask, cpu_online_mask);
670 apicid = es7000_cpu_mask_to_apicid(cpumask);
671
672 free_cpumask_var(cpumask);
673
674 return apicid;
675}
676
677static int es7000_phys_pkg_id(int cpuid_apic, int index_msb)
678{
679 return cpuid_apic >> index_msb;
680}
681
682void __init es7000_update_genapic_to_cluster(void)
683{
684 apic->target_cpus = target_cpus_cluster;
685 apic->irq_delivery_mode = INT_DELIVERY_MODE_CLUSTER;
686 apic->irq_dest_mode = INT_DEST_MODE_CLUSTER;
687
688 apic->init_apic_ldr = es7000_init_apic_ldr_cluster;
689
690 apic->cpu_mask_to_apicid = es7000_cpu_mask_to_apicid_cluster;
691}
692
693static int probe_es7000(void)
694{
695 /* probed later in mptable/ACPI hooks */
696 return 0;
697}
698
699static __init int
700es7000_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
701{
702 if (mpc->oemptr) {
703 struct mpc_oemtable *oem_table =
704 (struct mpc_oemtable *)mpc->oemptr;
705
706 if (!strncmp(oem, "UNISYS", 6))
707 return parse_unisys_oem((char *)oem_table);
708 }
709 return 0;
710}
711
712#ifdef CONFIG_ACPI
713/* Hook from generic ACPI tables.c */
714static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
715{
716 unsigned long oem_addr = 0;
717 int check_dsdt;
718 int ret = 0;
719
720 /* check dsdt at first to avoid clear fix_map for oem_addr */
721 check_dsdt = es7000_check_dsdt();
722
723 if (!find_unisys_acpi_oem_table(&oem_addr)) {
724 if (check_dsdt)
725 ret = parse_unisys_oem((char *)oem_addr);
726 else {
727 setup_unisys();
728 ret = 1;
729 }
730 /*
731 * we need to unmap it
732 */
733 unmap_unisys_acpi_oem_table(oem_addr);
734 }
735 return ret;
736}
737#else
738static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
739{
740 return 0;
741}
742#endif
743
744
745struct genapic apic_es7000 = {
746
747 .name = "es7000",
748 .probe = probe_es7000,
749 .acpi_madt_oem_check = es7000_acpi_madt_oem_check,
750 .apic_id_registered = es7000_apic_id_registered,
751
752 .irq_delivery_mode = dest_Fixed,
753 /* phys delivery to target CPUs: */
754 .irq_dest_mode = 0,
755
756 .target_cpus = es7000_target_cpus,
757 .disable_esr = 1,
758 .dest_logical = 0,
759 .check_apicid_used = es7000_check_apicid_used,
760 .check_apicid_present = es7000_check_apicid_present,
761
762 .vector_allocation_domain = es7000_vector_allocation_domain,
763 .init_apic_ldr = es7000_init_apic_ldr,
764
765 .ioapic_phys_id_map = es7000_ioapic_phys_id_map,
766 .setup_apic_routing = es7000_setup_apic_routing,
767 .multi_timer_check = NULL,
768 .apicid_to_node = es7000_apicid_to_node,
769 .cpu_to_logical_apicid = es7000_cpu_to_logical_apicid,
770 .cpu_present_to_apicid = es7000_cpu_present_to_apicid,
771 .apicid_to_cpu_present = es7000_apicid_to_cpu_present,
772 .setup_portio_remap = NULL,
773 .check_phys_apicid_present = es7000_check_phys_apicid_present,
774 .enable_apic_mode = es7000_enable_apic_mode,
775 .phys_pkg_id = es7000_phys_pkg_id,
776 .mps_oem_check = es7000_mps_oem_check,
777
778 .get_apic_id = es7000_get_apic_id,
779 .set_apic_id = NULL,
780 .apic_id_mask = 0xFF << 24,
781
782 .cpu_mask_to_apicid = es7000_cpu_mask_to_apicid,
783 .cpu_mask_to_apicid_and = es7000_cpu_mask_to_apicid_and,
784
785 .send_IPI_mask = es7000_send_IPI_mask,
786 .send_IPI_mask_allbutself = NULL,
787 .send_IPI_allbutself = es7000_send_IPI_allbutself,
788 .send_IPI_all = es7000_send_IPI_all,
789 .send_IPI_self = default_send_IPI_self,
790
791 .wakeup_cpu = NULL,
792
793 .trampoline_phys_low = 0x467,
794 .trampoline_phys_high = 0x469,
795
796 .wait_for_init_deassert = es7000_wait_for_init_deassert,
797
798 /* Nothing to do for most platforms, since cleared by the INIT cycle: */
799 .smp_callin_clear_local_apic = NULL,
800 .store_NMI_vector = NULL,
801 .inquire_remote_apic = default_inquire_remote_apic,
802};
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
index 1b43086b097..231bdd3c5b1 100644
--- a/arch/x86/kernel/ftrace.c
+++ b/arch/x86/kernel/ftrace.c
@@ -488,20 +488,21 @@ void prepare_ftrace_return(unsigned long *parent, unsigned long self_addr)
488 * ignore such a protection. 488 * ignore such a protection.
489 */ 489 */
490 asm volatile( 490 asm volatile(
491 "1: " _ASM_MOV " (%[parent_old]), %[old]\n" 491 "1: " _ASM_MOV " (%[parent]), %[old]\n"
492 "2: " _ASM_MOV " %[return_hooker], (%[parent_replaced])\n" 492 "2: " _ASM_MOV " %[return_hooker], (%[parent])\n"
493 " movl $0, %[faulted]\n" 493 " movl $0, %[faulted]\n"
494 "3:\n"
494 495
495 ".section .fixup, \"ax\"\n" 496 ".section .fixup, \"ax\"\n"
496 "3: movl $1, %[faulted]\n" 497 "4: movl $1, %[faulted]\n"
498 " jmp 3b\n"
497 ".previous\n" 499 ".previous\n"
498 500
499 _ASM_EXTABLE(1b, 3b) 501 _ASM_EXTABLE(1b, 4b)
500 _ASM_EXTABLE(2b, 3b) 502 _ASM_EXTABLE(2b, 4b)
501 503
502 : [parent_replaced] "=r" (parent), [old] "=r" (old), 504 : [old] "=r" (old), [faulted] "=r" (faulted)
503 [faulted] "=r" (faulted) 505 : [parent] "r" (parent), [return_hooker] "r" (return_hooker)
504 : [parent_old] "0" (parent), [return_hooker] "r" (return_hooker)
505 : "memory" 506 : "memory"
506 ); 507 );
507 508
diff --git a/arch/x86/kernel/genapic_64.c b/arch/x86/kernel/genapic_64.c
index e656c272115..820dea5d0eb 100644
--- a/arch/x86/kernel/genapic_64.c
+++ b/arch/x86/kernel/genapic_64.c
@@ -29,7 +29,7 @@ extern struct genapic apic_x2xpic_uv_x;
29extern struct genapic apic_x2apic_phys; 29extern struct genapic apic_x2apic_phys;
30extern struct genapic apic_x2apic_cluster; 30extern struct genapic apic_x2apic_cluster;
31 31
32struct genapic __read_mostly *genapic = &apic_flat; 32struct genapic __read_mostly *apic = &apic_flat;
33 33
34static struct genapic *apic_probe[] __initdata = { 34static struct genapic *apic_probe[] __initdata = {
35#ifdef CONFIG_X86_UV 35#ifdef CONFIG_X86_UV
@@ -44,17 +44,17 @@ static struct genapic *apic_probe[] __initdata = {
44/* 44/*
45 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode. 45 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
46 */ 46 */
47void __init setup_apic_routing(void) 47void __init default_setup_apic_routing(void)
48{ 48{
49 if (genapic == &apic_x2apic_phys || genapic == &apic_x2apic_cluster) { 49 if (apic == &apic_x2apic_phys || apic == &apic_x2apic_cluster) {
50 if (!intr_remapping_enabled) 50 if (!intr_remapping_enabled)
51 genapic = &apic_flat; 51 apic = &apic_flat;
52 } 52 }
53 53
54 if (genapic == &apic_flat) { 54 if (apic == &apic_flat) {
55 if (max_physical_apicid >= 8) 55 if (max_physical_apicid >= 8)
56 genapic = &apic_physflat; 56 apic = &apic_physflat;
57 printk(KERN_INFO "Setting APIC routing to %s\n", genapic->name); 57 printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
58 } 58 }
59 59
60 if (x86_quirks->update_genapic) 60 if (x86_quirks->update_genapic)
@@ -65,18 +65,18 @@ void __init setup_apic_routing(void)
65 65
66void apic_send_IPI_self(int vector) 66void apic_send_IPI_self(int vector)
67{ 67{
68 __send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); 68 __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL);
69} 69}
70 70
71int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id) 71int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
72{ 72{
73 int i; 73 int i;
74 74
75 for (i = 0; apic_probe[i]; ++i) { 75 for (i = 0; apic_probe[i]; ++i) {
76 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) { 76 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
77 genapic = apic_probe[i]; 77 apic = apic_probe[i];
78 printk(KERN_INFO "Setting APIC routing to %s.\n", 78 printk(KERN_INFO "Setting APIC routing to %s.\n",
79 genapic->name); 79 apic->name);
80 return 1; 80 return 1;
81 } 81 }
82 } 82 }
diff --git a/arch/x86/kernel/genapic_flat_64.c b/arch/x86/kernel/genapic_flat_64.c
index 34185488e4f..249d2d3c034 100644
--- a/arch/x86/kernel/genapic_flat_64.c
+++ b/arch/x86/kernel/genapic_flat_64.c
@@ -19,7 +19,6 @@
19#include <asm/smp.h> 19#include <asm/smp.h>
20#include <asm/ipi.h> 20#include <asm/ipi.h>
21#include <asm/genapic.h> 21#include <asm/genapic.h>
22#include <mach_apicdef.h>
23 22
24#ifdef CONFIG_ACPI 23#ifdef CONFIG_ACPI
25#include <acpi/acpi_bus.h> 24#include <acpi/acpi_bus.h>
@@ -74,7 +73,7 @@ static inline void _flat_send_IPI_mask(unsigned long mask, int vector)
74 unsigned long flags; 73 unsigned long flags;
75 74
76 local_irq_save(flags); 75 local_irq_save(flags);
77 __send_IPI_dest_field(mask, vector, APIC_DEST_LOGICAL); 76 __default_send_IPI_dest_field(mask, vector, apic->dest_logical);
78 local_irq_restore(flags); 77 local_irq_restore(flags);
79} 78}
80 79
@@ -85,14 +84,15 @@ static void flat_send_IPI_mask(const struct cpumask *cpumask, int vector)
85 _flat_send_IPI_mask(mask, vector); 84 _flat_send_IPI_mask(mask, vector);
86} 85}
87 86
88static void flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, 87static void
89 int vector) 88 flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)
90{ 89{
91 unsigned long mask = cpumask_bits(cpumask)[0]; 90 unsigned long mask = cpumask_bits(cpumask)[0];
92 int cpu = smp_processor_id(); 91 int cpu = smp_processor_id();
93 92
94 if (cpu < BITS_PER_LONG) 93 if (cpu < BITS_PER_LONG)
95 clear_bit(cpu, &mask); 94 clear_bit(cpu, &mask);
95
96 _flat_send_IPI_mask(mask, vector); 96 _flat_send_IPI_mask(mask, vector);
97} 97}
98 98
@@ -114,23 +114,27 @@ static void flat_send_IPI_allbutself(int vector)
114 _flat_send_IPI_mask(mask, vector); 114 _flat_send_IPI_mask(mask, vector);
115 } 115 }
116 } else if (num_online_cpus() > 1) { 116 } else if (num_online_cpus() > 1) {
117 __send_IPI_shortcut(APIC_DEST_ALLBUT, vector,APIC_DEST_LOGICAL); 117 __default_send_IPI_shortcut(APIC_DEST_ALLBUT,
118 vector, apic->dest_logical);
118 } 119 }
119} 120}
120 121
121static void flat_send_IPI_all(int vector) 122static void flat_send_IPI_all(int vector)
122{ 123{
123 if (vector == NMI_VECTOR) 124 if (vector == NMI_VECTOR) {
124 flat_send_IPI_mask(cpu_online_mask, vector); 125 flat_send_IPI_mask(cpu_online_mask, vector);
125 else 126 } else {
126 __send_IPI_shortcut(APIC_DEST_ALLINC, vector, APIC_DEST_LOGICAL); 127 __default_send_IPI_shortcut(APIC_DEST_ALLINC,
128 vector, apic->dest_logical);
129 }
127} 130}
128 131
129static unsigned int get_apic_id(unsigned long x) 132static unsigned int flat_get_apic_id(unsigned long x)
130{ 133{
131 unsigned int id; 134 unsigned int id;
132 135
133 id = (((x)>>24) & 0xFFu); 136 id = (((x)>>24) & 0xFFu);
137
134 return id; 138 return id;
135} 139}
136 140
@@ -146,7 +150,7 @@ static unsigned int read_xapic_id(void)
146{ 150{
147 unsigned int id; 151 unsigned int id;
148 152
149 id = get_apic_id(apic_read(APIC_ID)); 153 id = flat_get_apic_id(apic_read(APIC_ID));
150 return id; 154 return id;
151} 155}
152 156
@@ -169,31 +173,62 @@ static unsigned int flat_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
169 return mask1 & mask2; 173 return mask1 & mask2;
170} 174}
171 175
172static unsigned int phys_pkg_id(int index_msb) 176static int flat_phys_pkg_id(int initial_apic_id, int index_msb)
173{ 177{
174 return hard_smp_processor_id() >> index_msb; 178 return hard_smp_processor_id() >> index_msb;
175} 179}
176 180
177struct genapic apic_flat = { 181struct genapic apic_flat = {
178 .name = "flat", 182 .name = "flat",
179 .acpi_madt_oem_check = flat_acpi_madt_oem_check, 183 .probe = NULL,
180 .int_delivery_mode = dest_LowestPrio, 184 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
181 .int_dest_mode = (APIC_DEST_LOGICAL != 0), 185 .apic_id_registered = flat_apic_id_registered,
182 .target_cpus = flat_target_cpus, 186
183 .vector_allocation_domain = flat_vector_allocation_domain, 187 .irq_delivery_mode = dest_LowestPrio,
184 .apic_id_registered = flat_apic_id_registered, 188 .irq_dest_mode = 1, /* logical */
185 .init_apic_ldr = flat_init_apic_ldr, 189
186 .send_IPI_all = flat_send_IPI_all, 190 .target_cpus = flat_target_cpus,
187 .send_IPI_allbutself = flat_send_IPI_allbutself, 191 .disable_esr = 0,
188 .send_IPI_mask = flat_send_IPI_mask, 192 .dest_logical = APIC_DEST_LOGICAL,
189 .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself, 193 .check_apicid_used = NULL,
190 .send_IPI_self = apic_send_IPI_self, 194 .check_apicid_present = NULL,
191 .cpu_mask_to_apicid = flat_cpu_mask_to_apicid, 195
192 .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and, 196 .vector_allocation_domain = flat_vector_allocation_domain,
193 .phys_pkg_id = phys_pkg_id, 197 .init_apic_ldr = flat_init_apic_ldr,
194 .get_apic_id = get_apic_id, 198
195 .set_apic_id = set_apic_id, 199 .ioapic_phys_id_map = NULL,
196 .apic_id_mask = (0xFFu<<24), 200 .setup_apic_routing = NULL,
201 .multi_timer_check = NULL,
202 .apicid_to_node = NULL,
203 .cpu_to_logical_apicid = NULL,
204 .cpu_present_to_apicid = default_cpu_present_to_apicid,
205 .apicid_to_cpu_present = NULL,
206 .setup_portio_remap = NULL,
207 .check_phys_apicid_present = default_check_phys_apicid_present,
208 .enable_apic_mode = NULL,
209 .phys_pkg_id = flat_phys_pkg_id,
210 .mps_oem_check = NULL,
211
212 .get_apic_id = flat_get_apic_id,
213 .set_apic_id = set_apic_id,
214 .apic_id_mask = 0xFFu << 24,
215
216 .cpu_mask_to_apicid = flat_cpu_mask_to_apicid,
217 .cpu_mask_to_apicid_and = flat_cpu_mask_to_apicid_and,
218
219 .send_IPI_mask = flat_send_IPI_mask,
220 .send_IPI_mask_allbutself = flat_send_IPI_mask_allbutself,
221 .send_IPI_allbutself = flat_send_IPI_allbutself,
222 .send_IPI_all = flat_send_IPI_all,
223 .send_IPI_self = apic_send_IPI_self,
224
225 .wakeup_cpu = NULL,
226 .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
227 .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
228 .wait_for_init_deassert = NULL,
229 .smp_callin_clear_local_apic = NULL,
230 .store_NMI_vector = NULL,
231 .inquire_remote_apic = NULL,
197}; 232};
198 233
199/* 234/*
@@ -232,18 +267,18 @@ static void physflat_vector_allocation_domain(int cpu, struct cpumask *retmask)
232 267
233static void physflat_send_IPI_mask(const struct cpumask *cpumask, int vector) 268static void physflat_send_IPI_mask(const struct cpumask *cpumask, int vector)
234{ 269{
235 send_IPI_mask_sequence(cpumask, vector); 270 default_send_IPI_mask_sequence_phys(cpumask, vector);
236} 271}
237 272
238static void physflat_send_IPI_mask_allbutself(const struct cpumask *cpumask, 273static void physflat_send_IPI_mask_allbutself(const struct cpumask *cpumask,
239 int vector) 274 int vector)
240{ 275{
241 send_IPI_mask_allbutself(cpumask, vector); 276 default_send_IPI_mask_allbutself_phys(cpumask, vector);
242} 277}
243 278
244static void physflat_send_IPI_allbutself(int vector) 279static void physflat_send_IPI_allbutself(int vector)
245{ 280{
246 send_IPI_mask_allbutself(cpu_online_mask, vector); 281 default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
247} 282}
248 283
249static void physflat_send_IPI_all(int vector) 284static void physflat_send_IPI_all(int vector)
@@ -276,32 +311,67 @@ physflat_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
276 * We're using fixed IRQ delivery, can only return one phys APIC ID. 311 * We're using fixed IRQ delivery, can only return one phys APIC ID.
277 * May as well be the first. 312 * May as well be the first.
278 */ 313 */
279 for_each_cpu_and(cpu, cpumask, andmask) 314 for_each_cpu_and(cpu, cpumask, andmask) {
280 if (cpumask_test_cpu(cpu, cpu_online_mask)) 315 if (cpumask_test_cpu(cpu, cpu_online_mask))
281 break; 316 break;
317 }
282 if (cpu < nr_cpu_ids) 318 if (cpu < nr_cpu_ids)
283 return per_cpu(x86_cpu_to_apicid, cpu); 319 return per_cpu(x86_cpu_to_apicid, cpu);
320
284 return BAD_APICID; 321 return BAD_APICID;
285} 322}
286 323
287struct genapic apic_physflat = { 324struct genapic apic_physflat = {
288 .name = "physical flat", 325
289 .acpi_madt_oem_check = physflat_acpi_madt_oem_check, 326 .name = "physical flat",
290 .int_delivery_mode = dest_Fixed, 327 .probe = NULL,
291 .int_dest_mode = (APIC_DEST_PHYSICAL != 0), 328 .acpi_madt_oem_check = physflat_acpi_madt_oem_check,
292 .target_cpus = physflat_target_cpus, 329 .apic_id_registered = flat_apic_id_registered,
293 .vector_allocation_domain = physflat_vector_allocation_domain, 330
294 .apic_id_registered = flat_apic_id_registered, 331 .irq_delivery_mode = dest_Fixed,
295 .init_apic_ldr = flat_init_apic_ldr,/*not needed, but shouldn't hurt*/ 332 .irq_dest_mode = 0, /* physical */
296 .send_IPI_all = physflat_send_IPI_all, 333
297 .send_IPI_allbutself = physflat_send_IPI_allbutself, 334 .target_cpus = physflat_target_cpus,
298 .send_IPI_mask = physflat_send_IPI_mask, 335 .disable_esr = 0,
299 .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself, 336 .dest_logical = 0,
300 .send_IPI_self = apic_send_IPI_self, 337 .check_apicid_used = NULL,
301 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid, 338 .check_apicid_present = NULL,
302 .cpu_mask_to_apicid_and = physflat_cpu_mask_to_apicid_and, 339
303 .phys_pkg_id = phys_pkg_id, 340 .vector_allocation_domain = physflat_vector_allocation_domain,
304 .get_apic_id = get_apic_id, 341 /* not needed, but shouldn't hurt: */
305 .set_apic_id = set_apic_id, 342 .init_apic_ldr = flat_init_apic_ldr,
306 .apic_id_mask = (0xFFu<<24), 343
344 .ioapic_phys_id_map = NULL,
345 .setup_apic_routing = NULL,
346 .multi_timer_check = NULL,
347 .apicid_to_node = NULL,
348 .cpu_to_logical_apicid = NULL,
349 .cpu_present_to_apicid = default_cpu_present_to_apicid,
350 .apicid_to_cpu_present = NULL,
351 .setup_portio_remap = NULL,
352 .check_phys_apicid_present = default_check_phys_apicid_present,
353 .enable_apic_mode = NULL,
354 .phys_pkg_id = flat_phys_pkg_id,
355 .mps_oem_check = NULL,
356
357 .get_apic_id = flat_get_apic_id,
358 .set_apic_id = set_apic_id,
359 .apic_id_mask = 0xFFu << 24,
360
361 .cpu_mask_to_apicid = physflat_cpu_mask_to_apicid,
362 .cpu_mask_to_apicid_and = physflat_cpu_mask_to_apicid_and,
363
364 .send_IPI_mask = physflat_send_IPI_mask,
365 .send_IPI_mask_allbutself = physflat_send_IPI_mask_allbutself,
366 .send_IPI_allbutself = physflat_send_IPI_allbutself,
367 .send_IPI_all = physflat_send_IPI_all,
368 .send_IPI_self = apic_send_IPI_self,
369
370 .wakeup_cpu = NULL,
371 .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
372 .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
373 .wait_for_init_deassert = NULL,
374 .smp_callin_clear_local_apic = NULL,
375 .store_NMI_vector = NULL,
376 .inquire_remote_apic = NULL,
307}; 377};
diff --git a/arch/x86/kernel/genx2apic_cluster.c b/arch/x86/kernel/genx2apic_cluster.c
index 6ce497cc372..7c87156b641 100644
--- a/arch/x86/kernel/genx2apic_cluster.c
+++ b/arch/x86/kernel/genx2apic_cluster.c
@@ -36,8 +36,8 @@ static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask)
36 cpumask_set_cpu(cpu, retmask); 36 cpumask_set_cpu(cpu, retmask);
37} 37}
38 38
39static void __x2apic_send_IPI_dest(unsigned int apicid, int vector, 39static void
40 unsigned int dest) 40 __x2apic_send_IPI_dest(unsigned int apicid, int vector, unsigned int dest)
41{ 41{
42 unsigned long cfg; 42 unsigned long cfg;
43 43
@@ -57,45 +57,50 @@ static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
57 */ 57 */
58static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) 58static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
59{ 59{
60 unsigned long flags;
61 unsigned long query_cpu; 60 unsigned long query_cpu;
61 unsigned long flags;
62 62
63 local_irq_save(flags); 63 local_irq_save(flags);
64 for_each_cpu(query_cpu, mask) 64 for_each_cpu(query_cpu, mask) {
65 __x2apic_send_IPI_dest( 65 __x2apic_send_IPI_dest(
66 per_cpu(x86_cpu_to_logical_apicid, query_cpu), 66 per_cpu(x86_cpu_to_logical_apicid, query_cpu),
67 vector, APIC_DEST_LOGICAL); 67 vector, apic->dest_logical);
68 }
68 local_irq_restore(flags); 69 local_irq_restore(flags);
69} 70}
70 71
71static void x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, 72static void
72 int vector) 73 x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
73{ 74{
74 unsigned long flags;
75 unsigned long query_cpu;
76 unsigned long this_cpu = smp_processor_id(); 75 unsigned long this_cpu = smp_processor_id();
76 unsigned long query_cpu;
77 unsigned long flags;
77 78
78 local_irq_save(flags); 79 local_irq_save(flags);
79 for_each_cpu(query_cpu, mask) 80 for_each_cpu(query_cpu, mask) {
80 if (query_cpu != this_cpu) 81 if (query_cpu == this_cpu)
81 __x2apic_send_IPI_dest( 82 continue;
83 __x2apic_send_IPI_dest(
82 per_cpu(x86_cpu_to_logical_apicid, query_cpu), 84 per_cpu(x86_cpu_to_logical_apicid, query_cpu),
83 vector, APIC_DEST_LOGICAL); 85 vector, apic->dest_logical);
86 }
84 local_irq_restore(flags); 87 local_irq_restore(flags);
85} 88}
86 89
87static void x2apic_send_IPI_allbutself(int vector) 90static void x2apic_send_IPI_allbutself(int vector)
88{ 91{
89 unsigned long flags;
90 unsigned long query_cpu;
91 unsigned long this_cpu = smp_processor_id(); 92 unsigned long this_cpu = smp_processor_id();
93 unsigned long query_cpu;
94 unsigned long flags;
92 95
93 local_irq_save(flags); 96 local_irq_save(flags);
94 for_each_online_cpu(query_cpu) 97 for_each_online_cpu(query_cpu) {
95 if (query_cpu != this_cpu) 98 if (query_cpu == this_cpu)
96 __x2apic_send_IPI_dest( 99 continue;
100 __x2apic_send_IPI_dest(
97 per_cpu(x86_cpu_to_logical_apicid, query_cpu), 101 per_cpu(x86_cpu_to_logical_apicid, query_cpu),
98 vector, APIC_DEST_LOGICAL); 102 vector, apic->dest_logical);
103 }
99 local_irq_restore(flags); 104 local_irq_restore(flags);
100} 105}
101 106
@@ -111,21 +116,21 @@ static int x2apic_apic_id_registered(void)
111 116
112static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) 117static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask)
113{ 118{
114 int cpu;
115
116 /* 119 /*
117 * We're using fixed IRQ delivery, can only return one logical APIC ID. 120 * We're using fixed IRQ delivery, can only return one logical APIC ID.
118 * May as well be the first. 121 * May as well be the first.
119 */ 122 */
120 cpu = cpumask_first(cpumask); 123 int cpu = cpumask_first(cpumask);
124
121 if ((unsigned)cpu < nr_cpu_ids) 125 if ((unsigned)cpu < nr_cpu_ids)
122 return per_cpu(x86_cpu_to_logical_apicid, cpu); 126 return per_cpu(x86_cpu_to_logical_apicid, cpu);
123 else 127 else
124 return BAD_APICID; 128 return BAD_APICID;
125} 129}
126 130
127static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 131static unsigned int
128 const struct cpumask *andmask) 132x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
133 const struct cpumask *andmask)
129{ 134{
130 int cpu; 135 int cpu;
131 136
@@ -133,15 +138,18 @@ static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
133 * We're using fixed IRQ delivery, can only return one logical APIC ID. 138 * We're using fixed IRQ delivery, can only return one logical APIC ID.
134 * May as well be the first. 139 * May as well be the first.
135 */ 140 */
136 for_each_cpu_and(cpu, cpumask, andmask) 141 for_each_cpu_and(cpu, cpumask, andmask) {
137 if (cpumask_test_cpu(cpu, cpu_online_mask)) 142 if (cpumask_test_cpu(cpu, cpu_online_mask))
138 break; 143 break;
144 }
145
139 if (cpu < nr_cpu_ids) 146 if (cpu < nr_cpu_ids)
140 return per_cpu(x86_cpu_to_logical_apicid, cpu); 147 return per_cpu(x86_cpu_to_logical_apicid, cpu);
148
141 return BAD_APICID; 149 return BAD_APICID;
142} 150}
143 151
144static unsigned int get_apic_id(unsigned long x) 152static unsigned int x2apic_cluster_phys_get_apic_id(unsigned long x)
145{ 153{
146 unsigned int id; 154 unsigned int id;
147 155
@@ -157,7 +165,7 @@ static unsigned long set_apic_id(unsigned int id)
157 return x; 165 return x;
158} 166}
159 167
160static unsigned int phys_pkg_id(int index_msb) 168static int x2apic_cluster_phys_pkg_id(int initial_apicid, int index_msb)
161{ 169{
162 return current_cpu_data.initial_apicid >> index_msb; 170 return current_cpu_data.initial_apicid >> index_msb;
163} 171}
@@ -172,27 +180,58 @@ static void init_x2apic_ldr(void)
172 int cpu = smp_processor_id(); 180 int cpu = smp_processor_id();
173 181
174 per_cpu(x86_cpu_to_logical_apicid, cpu) = apic_read(APIC_LDR); 182 per_cpu(x86_cpu_to_logical_apicid, cpu) = apic_read(APIC_LDR);
175 return;
176} 183}
177 184
178struct genapic apic_x2apic_cluster = { 185struct genapic apic_x2apic_cluster = {
179 .name = "cluster x2apic", 186
180 .acpi_madt_oem_check = x2apic_acpi_madt_oem_check, 187 .name = "cluster x2apic",
181 .int_delivery_mode = dest_LowestPrio, 188 .probe = NULL,
182 .int_dest_mode = (APIC_DEST_LOGICAL != 0), 189 .acpi_madt_oem_check = x2apic_acpi_madt_oem_check,
183 .target_cpus = x2apic_target_cpus, 190 .apic_id_registered = x2apic_apic_id_registered,
184 .vector_allocation_domain = x2apic_vector_allocation_domain, 191
185 .apic_id_registered = x2apic_apic_id_registered, 192 .irq_delivery_mode = dest_LowestPrio,
186 .init_apic_ldr = init_x2apic_ldr, 193 .irq_dest_mode = 1, /* logical */
187 .send_IPI_all = x2apic_send_IPI_all, 194
188 .send_IPI_allbutself = x2apic_send_IPI_allbutself, 195 .target_cpus = x2apic_target_cpus,
189 .send_IPI_mask = x2apic_send_IPI_mask, 196 .disable_esr = 0,
190 .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself, 197 .dest_logical = APIC_DEST_LOGICAL,
191 .send_IPI_self = x2apic_send_IPI_self, 198 .check_apicid_used = NULL,
192 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, 199 .check_apicid_present = NULL,
193 .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and, 200
194 .phys_pkg_id = phys_pkg_id, 201 .vector_allocation_domain = x2apic_vector_allocation_domain,
195 .get_apic_id = get_apic_id, 202 .init_apic_ldr = init_x2apic_ldr,
196 .set_apic_id = set_apic_id, 203
197 .apic_id_mask = (0xFFFFFFFFu), 204 .ioapic_phys_id_map = NULL,
205 .setup_apic_routing = NULL,
206 .multi_timer_check = NULL,
207 .apicid_to_node = NULL,
208 .cpu_to_logical_apicid = NULL,
209 .cpu_present_to_apicid = default_cpu_present_to_apicid,
210 .apicid_to_cpu_present = NULL,
211 .setup_portio_remap = NULL,
212 .check_phys_apicid_present = default_check_phys_apicid_present,
213 .enable_apic_mode = NULL,
214 .phys_pkg_id = x2apic_cluster_phys_pkg_id,
215 .mps_oem_check = NULL,
216
217 .get_apic_id = x2apic_cluster_phys_get_apic_id,
218 .set_apic_id = set_apic_id,
219 .apic_id_mask = 0xFFFFFFFFu,
220
221 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
222 .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and,
223
224 .send_IPI_mask = x2apic_send_IPI_mask,
225 .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself,
226 .send_IPI_allbutself = x2apic_send_IPI_allbutself,
227 .send_IPI_all = x2apic_send_IPI_all,
228 .send_IPI_self = x2apic_send_IPI_self,
229
230 .wakeup_cpu = NULL,
231 .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
232 .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
233 .wait_for_init_deassert = NULL,
234 .smp_callin_clear_local_apic = NULL,
235 .store_NMI_vector = NULL,
236 .inquire_remote_apic = NULL,
198}; 237};
diff --git a/arch/x86/kernel/genx2apic_phys.c b/arch/x86/kernel/genx2apic_phys.c
index 21bcc0e098b..5cbae8aa040 100644
--- a/arch/x86/kernel/genx2apic_phys.c
+++ b/arch/x86/kernel/genx2apic_phys.c
@@ -55,8 +55,8 @@ static void __x2apic_send_IPI_dest(unsigned int apicid, int vector,
55 55
56static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector) 56static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
57{ 57{
58 unsigned long flags;
59 unsigned long query_cpu; 58 unsigned long query_cpu;
59 unsigned long flags;
60 60
61 local_irq_save(flags); 61 local_irq_save(flags);
62 for_each_cpu(query_cpu, mask) { 62 for_each_cpu(query_cpu, mask) {
@@ -66,12 +66,12 @@ static void x2apic_send_IPI_mask(const struct cpumask *mask, int vector)
66 local_irq_restore(flags); 66 local_irq_restore(flags);
67} 67}
68 68
69static void x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, 69static void
70 int vector) 70 x2apic_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
71{ 71{
72 unsigned long flags;
73 unsigned long query_cpu;
74 unsigned long this_cpu = smp_processor_id(); 72 unsigned long this_cpu = smp_processor_id();
73 unsigned long query_cpu;
74 unsigned long flags;
75 75
76 local_irq_save(flags); 76 local_irq_save(flags);
77 for_each_cpu(query_cpu, mask) { 77 for_each_cpu(query_cpu, mask) {
@@ -85,16 +85,17 @@ static void x2apic_send_IPI_mask_allbutself(const struct cpumask *mask,
85 85
86static void x2apic_send_IPI_allbutself(int vector) 86static void x2apic_send_IPI_allbutself(int vector)
87{ 87{
88 unsigned long flags;
89 unsigned long query_cpu;
90 unsigned long this_cpu = smp_processor_id(); 88 unsigned long this_cpu = smp_processor_id();
89 unsigned long query_cpu;
90 unsigned long flags;
91 91
92 local_irq_save(flags); 92 local_irq_save(flags);
93 for_each_online_cpu(query_cpu) 93 for_each_online_cpu(query_cpu) {
94 if (query_cpu != this_cpu) 94 if (query_cpu == this_cpu)
95 __x2apic_send_IPI_dest( 95 continue;
96 per_cpu(x86_cpu_to_apicid, query_cpu), 96 __x2apic_send_IPI_dest(per_cpu(x86_cpu_to_apicid, query_cpu),
97 vector, APIC_DEST_PHYSICAL); 97 vector, APIC_DEST_PHYSICAL);
98 }
98 local_irq_restore(flags); 99 local_irq_restore(flags);
99} 100}
100 101
@@ -110,21 +111,21 @@ static int x2apic_apic_id_registered(void)
110 111
111static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask) 112static unsigned int x2apic_cpu_mask_to_apicid(const struct cpumask *cpumask)
112{ 113{
113 int cpu;
114
115 /* 114 /*
116 * We're using fixed IRQ delivery, can only return one phys APIC ID. 115 * We're using fixed IRQ delivery, can only return one phys APIC ID.
117 * May as well be the first. 116 * May as well be the first.
118 */ 117 */
119 cpu = cpumask_first(cpumask); 118 int cpu = cpumask_first(cpumask);
119
120 if ((unsigned)cpu < nr_cpu_ids) 120 if ((unsigned)cpu < nr_cpu_ids)
121 return per_cpu(x86_cpu_to_apicid, cpu); 121 return per_cpu(x86_cpu_to_apicid, cpu);
122 else 122 else
123 return BAD_APICID; 123 return BAD_APICID;
124} 124}
125 125
126static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 126static unsigned int
127 const struct cpumask *andmask) 127x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
128 const struct cpumask *andmask)
128{ 129{
129 int cpu; 130 int cpu;
130 131
@@ -132,31 +133,28 @@ static unsigned int x2apic_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
132 * We're using fixed IRQ delivery, can only return one phys APIC ID. 133 * We're using fixed IRQ delivery, can only return one phys APIC ID.
133 * May as well be the first. 134 * May as well be the first.
134 */ 135 */
135 for_each_cpu_and(cpu, cpumask, andmask) 136 for_each_cpu_and(cpu, cpumask, andmask) {
136 if (cpumask_test_cpu(cpu, cpu_online_mask)) 137 if (cpumask_test_cpu(cpu, cpu_online_mask))
137 break; 138 break;
139 }
140
138 if (cpu < nr_cpu_ids) 141 if (cpu < nr_cpu_ids)
139 return per_cpu(x86_cpu_to_apicid, cpu); 142 return per_cpu(x86_cpu_to_apicid, cpu);
143
140 return BAD_APICID; 144 return BAD_APICID;
141} 145}
142 146
143static unsigned int get_apic_id(unsigned long x) 147static unsigned int x2apic_phys_get_apic_id(unsigned long x)
144{ 148{
145 unsigned int id; 149 return x;
146
147 id = x;
148 return id;
149} 150}
150 151
151static unsigned long set_apic_id(unsigned int id) 152static unsigned long set_apic_id(unsigned int id)
152{ 153{
153 unsigned long x; 154 return id;
154
155 x = id;
156 return x;
157} 155}
158 156
159static unsigned int phys_pkg_id(int index_msb) 157static int x2apic_phys_pkg_id(int initial_apicid, int index_msb)
160{ 158{
161 return current_cpu_data.initial_apicid >> index_msb; 159 return current_cpu_data.initial_apicid >> index_msb;
162} 160}
@@ -168,27 +166,58 @@ static void x2apic_send_IPI_self(int vector)
168 166
169static void init_x2apic_ldr(void) 167static void init_x2apic_ldr(void)
170{ 168{
171 return;
172} 169}
173 170
174struct genapic apic_x2apic_phys = { 171struct genapic apic_x2apic_phys = {
175 .name = "physical x2apic", 172
176 .acpi_madt_oem_check = x2apic_acpi_madt_oem_check, 173 .name = "physical x2apic",
177 .int_delivery_mode = dest_Fixed, 174 .probe = NULL,
178 .int_dest_mode = (APIC_DEST_PHYSICAL != 0), 175 .acpi_madt_oem_check = x2apic_acpi_madt_oem_check,
179 .target_cpus = x2apic_target_cpus, 176 .apic_id_registered = x2apic_apic_id_registered,
180 .vector_allocation_domain = x2apic_vector_allocation_domain, 177
181 .apic_id_registered = x2apic_apic_id_registered, 178 .irq_delivery_mode = dest_Fixed,
182 .init_apic_ldr = init_x2apic_ldr, 179 .irq_dest_mode = 0, /* physical */
183 .send_IPI_all = x2apic_send_IPI_all, 180
184 .send_IPI_allbutself = x2apic_send_IPI_allbutself, 181 .target_cpus = x2apic_target_cpus,
185 .send_IPI_mask = x2apic_send_IPI_mask, 182 .disable_esr = 0,
186 .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself, 183 .dest_logical = 0,
187 .send_IPI_self = x2apic_send_IPI_self, 184 .check_apicid_used = NULL,
188 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid, 185 .check_apicid_present = NULL,
189 .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and, 186
190 .phys_pkg_id = phys_pkg_id, 187 .vector_allocation_domain = x2apic_vector_allocation_domain,
191 .get_apic_id = get_apic_id, 188 .init_apic_ldr = init_x2apic_ldr,
192 .set_apic_id = set_apic_id, 189
193 .apic_id_mask = (0xFFFFFFFFu), 190 .ioapic_phys_id_map = NULL,
191 .setup_apic_routing = NULL,
192 .multi_timer_check = NULL,
193 .apicid_to_node = NULL,
194 .cpu_to_logical_apicid = NULL,
195 .cpu_present_to_apicid = default_cpu_present_to_apicid,
196 .apicid_to_cpu_present = NULL,
197 .setup_portio_remap = NULL,
198 .check_phys_apicid_present = default_check_phys_apicid_present,
199 .enable_apic_mode = NULL,
200 .phys_pkg_id = x2apic_phys_pkg_id,
201 .mps_oem_check = NULL,
202
203 .get_apic_id = x2apic_phys_get_apic_id,
204 .set_apic_id = set_apic_id,
205 .apic_id_mask = 0xFFFFFFFFu,
206
207 .cpu_mask_to_apicid = x2apic_cpu_mask_to_apicid,
208 .cpu_mask_to_apicid_and = x2apic_cpu_mask_to_apicid_and,
209
210 .send_IPI_mask = x2apic_send_IPI_mask,
211 .send_IPI_mask_allbutself = x2apic_send_IPI_mask_allbutself,
212 .send_IPI_allbutself = x2apic_send_IPI_allbutself,
213 .send_IPI_all = x2apic_send_IPI_all,
214 .send_IPI_self = x2apic_send_IPI_self,
215
216 .wakeup_cpu = NULL,
217 .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
218 .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
219 .wait_for_init_deassert = NULL,
220 .smp_callin_clear_local_apic = NULL,
221 .store_NMI_vector = NULL,
222 .inquire_remote_apic = NULL,
194}; 223};
diff --git a/arch/x86/kernel/genx2apic_uv_x.c b/arch/x86/kernel/genx2apic_uv_x.c
index bfe36249145..6adb5e6f4d9 100644
--- a/arch/x86/kernel/genx2apic_uv_x.c
+++ b/arch/x86/kernel/genx2apic_uv_x.c
@@ -118,12 +118,13 @@ static void uv_send_IPI_one(int cpu, int vector)
118 int pnode; 118 int pnode;
119 119
120 apicid = per_cpu(x86_cpu_to_apicid, cpu); 120 apicid = per_cpu(x86_cpu_to_apicid, cpu);
121 lapicid = apicid & 0x3f; /* ZZZ macro needed */ 121 lapicid = apicid & 0x3f; /* ZZZ macro needed */
122 pnode = uv_apicid_to_pnode(apicid); 122 pnode = uv_apicid_to_pnode(apicid);
123 val = 123
124 (1UL << UVH_IPI_INT_SEND_SHFT) | (lapicid << 124 val = ( 1UL << UVH_IPI_INT_SEND_SHFT ) |
125 UVH_IPI_INT_APIC_ID_SHFT) | 125 ( lapicid << UVH_IPI_INT_APIC_ID_SHFT ) |
126 (vector << UVH_IPI_INT_VECTOR_SHFT); 126 ( vector << UVH_IPI_INT_VECTOR_SHFT );
127
127 uv_write_global_mmr64(pnode, UVH_IPI_INT, val); 128 uv_write_global_mmr64(pnode, UVH_IPI_INT, val);
128} 129}
129 130
@@ -137,22 +138,24 @@ static void uv_send_IPI_mask(const struct cpumask *mask, int vector)
137 138
138static void uv_send_IPI_mask_allbutself(const struct cpumask *mask, int vector) 139static void uv_send_IPI_mask_allbutself(const struct cpumask *mask, int vector)
139{ 140{
140 unsigned int cpu;
141 unsigned int this_cpu = smp_processor_id(); 141 unsigned int this_cpu = smp_processor_id();
142 unsigned int cpu;
142 143
143 for_each_cpu(cpu, mask) 144 for_each_cpu(cpu, mask) {
144 if (cpu != this_cpu) 145 if (cpu != this_cpu)
145 uv_send_IPI_one(cpu, vector); 146 uv_send_IPI_one(cpu, vector);
147 }
146} 148}
147 149
148static void uv_send_IPI_allbutself(int vector) 150static void uv_send_IPI_allbutself(int vector)
149{ 151{
150 unsigned int cpu;
151 unsigned int this_cpu = smp_processor_id(); 152 unsigned int this_cpu = smp_processor_id();
153 unsigned int cpu;
152 154
153 for_each_online_cpu(cpu) 155 for_each_online_cpu(cpu) {
154 if (cpu != this_cpu) 156 if (cpu != this_cpu)
155 uv_send_IPI_one(cpu, vector); 157 uv_send_IPI_one(cpu, vector);
158 }
156} 159}
157 160
158static void uv_send_IPI_all(int vector) 161static void uv_send_IPI_all(int vector)
@@ -171,21 +174,21 @@ static void uv_init_apic_ldr(void)
171 174
172static unsigned int uv_cpu_mask_to_apicid(const struct cpumask *cpumask) 175static unsigned int uv_cpu_mask_to_apicid(const struct cpumask *cpumask)
173{ 176{
174 int cpu;
175
176 /* 177 /*
177 * We're using fixed IRQ delivery, can only return one phys APIC ID. 178 * We're using fixed IRQ delivery, can only return one phys APIC ID.
178 * May as well be the first. 179 * May as well be the first.
179 */ 180 */
180 cpu = cpumask_first(cpumask); 181 int cpu = cpumask_first(cpumask);
182
181 if ((unsigned)cpu < nr_cpu_ids) 183 if ((unsigned)cpu < nr_cpu_ids)
182 return per_cpu(x86_cpu_to_apicid, cpu); 184 return per_cpu(x86_cpu_to_apicid, cpu);
183 else 185 else
184 return BAD_APICID; 186 return BAD_APICID;
185} 187}
186 188
187static unsigned int uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask, 189static unsigned int
188 const struct cpumask *andmask) 190uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
191 const struct cpumask *andmask)
189{ 192{
190 int cpu; 193 int cpu;
191 194
@@ -193,15 +196,17 @@ static unsigned int uv_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
193 * We're using fixed IRQ delivery, can only return one phys APIC ID. 196 * We're using fixed IRQ delivery, can only return one phys APIC ID.
194 * May as well be the first. 197 * May as well be the first.
195 */ 198 */
196 for_each_cpu_and(cpu, cpumask, andmask) 199 for_each_cpu_and(cpu, cpumask, andmask) {
197 if (cpumask_test_cpu(cpu, cpu_online_mask)) 200 if (cpumask_test_cpu(cpu, cpu_online_mask))
198 break; 201 break;
202 }
199 if (cpu < nr_cpu_ids) 203 if (cpu < nr_cpu_ids)
200 return per_cpu(x86_cpu_to_apicid, cpu); 204 return per_cpu(x86_cpu_to_apicid, cpu);
205
201 return BAD_APICID; 206 return BAD_APICID;
202} 207}
203 208
204static unsigned int get_apic_id(unsigned long x) 209static unsigned int x2apic_get_apic_id(unsigned long x)
205{ 210{
206 unsigned int id; 211 unsigned int id;
207 212
@@ -223,10 +228,10 @@ static unsigned long set_apic_id(unsigned int id)
223static unsigned int uv_read_apic_id(void) 228static unsigned int uv_read_apic_id(void)
224{ 229{
225 230
226 return get_apic_id(apic_read(APIC_ID)); 231 return x2apic_get_apic_id(apic_read(APIC_ID));
227} 232}
228 233
229static unsigned int phys_pkg_id(int index_msb) 234static int uv_phys_pkg_id(int initial_apicid, int index_msb)
230{ 235{
231 return uv_read_apic_id() >> index_msb; 236 return uv_read_apic_id() >> index_msb;
232} 237}
@@ -237,25 +242,57 @@ static void uv_send_IPI_self(int vector)
237} 242}
238 243
239struct genapic apic_x2apic_uv_x = { 244struct genapic apic_x2apic_uv_x = {
240 .name = "UV large system", 245
241 .acpi_madt_oem_check = uv_acpi_madt_oem_check, 246 .name = "UV large system",
242 .int_delivery_mode = dest_Fixed, 247 .probe = NULL,
243 .int_dest_mode = (APIC_DEST_PHYSICAL != 0), 248 .acpi_madt_oem_check = uv_acpi_madt_oem_check,
244 .target_cpus = uv_target_cpus, 249 .apic_id_registered = uv_apic_id_registered,
245 .vector_allocation_domain = uv_vector_allocation_domain, 250
246 .apic_id_registered = uv_apic_id_registered, 251 .irq_delivery_mode = dest_Fixed,
247 .init_apic_ldr = uv_init_apic_ldr, 252 .irq_dest_mode = 1, /* logical */
248 .send_IPI_all = uv_send_IPI_all, 253
249 .send_IPI_allbutself = uv_send_IPI_allbutself, 254 .target_cpus = uv_target_cpus,
250 .send_IPI_mask = uv_send_IPI_mask, 255 .disable_esr = 0,
251 .send_IPI_mask_allbutself = uv_send_IPI_mask_allbutself, 256 .dest_logical = APIC_DEST_LOGICAL,
252 .send_IPI_self = uv_send_IPI_self, 257 .check_apicid_used = NULL,
253 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid, 258 .check_apicid_present = NULL,
254 .cpu_mask_to_apicid_and = uv_cpu_mask_to_apicid_and, 259
255 .phys_pkg_id = phys_pkg_id, 260 .vector_allocation_domain = uv_vector_allocation_domain,
256 .get_apic_id = get_apic_id, 261 .init_apic_ldr = uv_init_apic_ldr,
257 .set_apic_id = set_apic_id, 262
258 .apic_id_mask = (0xFFFFFFFFu), 263 .ioapic_phys_id_map = NULL,
264 .setup_apic_routing = NULL,
265 .multi_timer_check = NULL,
266 .apicid_to_node = NULL,
267 .cpu_to_logical_apicid = NULL,
268 .cpu_present_to_apicid = default_cpu_present_to_apicid,
269 .apicid_to_cpu_present = NULL,
270 .setup_portio_remap = NULL,
271 .check_phys_apicid_present = default_check_phys_apicid_present,
272 .enable_apic_mode = NULL,
273 .phys_pkg_id = uv_phys_pkg_id,
274 .mps_oem_check = NULL,
275
276 .get_apic_id = x2apic_get_apic_id,
277 .set_apic_id = set_apic_id,
278 .apic_id_mask = 0xFFFFFFFFu,
279
280 .cpu_mask_to_apicid = uv_cpu_mask_to_apicid,
281 .cpu_mask_to_apicid_and = uv_cpu_mask_to_apicid_and,
282
283 .send_IPI_mask = uv_send_IPI_mask,
284 .send_IPI_mask_allbutself = uv_send_IPI_mask_allbutself,
285 .send_IPI_allbutself = uv_send_IPI_allbutself,
286 .send_IPI_all = uv_send_IPI_all,
287 .send_IPI_self = uv_send_IPI_self,
288
289 .wakeup_cpu = NULL,
290 .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
291 .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
292 .wait_for_init_deassert = NULL,
293 .smp_callin_clear_local_apic = NULL,
294 .store_NMI_vector = NULL,
295 .inquire_remote_apic = NULL,
259}; 296};
260 297
261static __cpuinit void set_x2apic_extra_bits(int pnode) 298static __cpuinit void set_x2apic_extra_bits(int pnode)
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index cf21fd0cf6a..2a0aad7718d 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -567,12 +567,8 @@ early_fault:
567 pushl %eax 567 pushl %eax
568 pushl %edx /* trapno */ 568 pushl %edx /* trapno */
569 pushl $fault_msg 569 pushl $fault_msg
570#ifdef CONFIG_EARLY_PRINTK
571 call early_printk
572#else
573 call printk 570 call printk
574#endif 571#endif
575#endif
576 call dump_stack 572 call dump_stack
577hlt_loop: 573hlt_loop:
578 hlt 574 hlt
@@ -599,11 +595,10 @@ ignore_int:
599 pushl 32(%esp) 595 pushl 32(%esp)
600 pushl 40(%esp) 596 pushl 40(%esp)
601 pushl $int_msg 597 pushl $int_msg
602#ifdef CONFIG_EARLY_PRINTK
603 call early_printk
604#else
605 call printk 598 call printk
606#endif 599
600 call dump_stack
601
607 addl $(5*4),%esp 602 addl $(5*4),%esp
608 popl %ds 603 popl %ds
609 popl %es 604 popl %es
@@ -679,7 +674,7 @@ early_recursion_flag:
679 .long 0 674 .long 0
680 675
681int_msg: 676int_msg:
682 .asciz "Unknown interrupt or fault at EIP %p %p %p\n" 677 .asciz "Unknown interrupt or fault at: %p %p %p\n"
683 678
684fault_msg: 679fault_msg:
685/* fault info: */ 680/* fault info: */
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 64d5ad0b8ad..388254f69a2 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -897,7 +897,7 @@ static unsigned long hpet_rtc_flags;
897static int hpet_prev_update_sec; 897static int hpet_prev_update_sec;
898static struct rtc_time hpet_alarm_time; 898static struct rtc_time hpet_alarm_time;
899static unsigned long hpet_pie_count; 899static unsigned long hpet_pie_count;
900static unsigned long hpet_t1_cmp; 900static u32 hpet_t1_cmp;
901static unsigned long hpet_default_delta; 901static unsigned long hpet_default_delta;
902static unsigned long hpet_pie_delta; 902static unsigned long hpet_pie_delta;
903static unsigned long hpet_pie_limit; 903static unsigned long hpet_pie_limit;
@@ -905,6 +905,14 @@ static unsigned long hpet_pie_limit;
905static rtc_irq_handler irq_handler; 905static rtc_irq_handler irq_handler;
906 906
907/* 907/*
908 * Check that the hpet counter c1 is ahead of the c2
909 */
910static inline int hpet_cnt_ahead(u32 c1, u32 c2)
911{
912 return (s32)(c2 - c1) < 0;
913}
914
915/*
908 * Registers a IRQ handler. 916 * Registers a IRQ handler.
909 */ 917 */
910int hpet_register_irq_handler(rtc_irq_handler handler) 918int hpet_register_irq_handler(rtc_irq_handler handler)
@@ -1075,7 +1083,7 @@ static void hpet_rtc_timer_reinit(void)
1075 hpet_t1_cmp += delta; 1083 hpet_t1_cmp += delta;
1076 hpet_writel(hpet_t1_cmp, HPET_T1_CMP); 1084 hpet_writel(hpet_t1_cmp, HPET_T1_CMP);
1077 lost_ints++; 1085 lost_ints++;
1078 } while ((long)(hpet_readl(HPET_COUNTER) - hpet_t1_cmp) > 0); 1086 } while (!hpet_cnt_ahead(hpet_t1_cmp, hpet_readl(HPET_COUNTER)));
1079 1087
1080 if (lost_ints) { 1088 if (lost_ints) {
1081 if (hpet_rtc_flags & RTC_PIE) 1089 if (hpet_rtc_flags & RTC_PIE)
diff --git a/arch/x86/kernel/i8237.c b/arch/x86/kernel/i8237.c
index dbd6c1d1b63..b42ca694dc6 100644
--- a/arch/x86/kernel/i8237.c
+++ b/arch/x86/kernel/i8237.c
@@ -28,10 +28,10 @@ static int i8237A_resume(struct sys_device *dev)
28 28
29 flags = claim_dma_lock(); 29 flags = claim_dma_lock();
30 30
31 dma_outb(DMA1_RESET_REG, 0); 31 dma_outb(0, DMA1_RESET_REG);
32 dma_outb(DMA2_RESET_REG, 0); 32 dma_outb(0, DMA2_RESET_REG);
33 33
34 for (i = 0;i < 8;i++) { 34 for (i = 0; i < 8; i++) {
35 set_dma_addr(i, 0x000000); 35 set_dma_addr(i, 0x000000);
36 /* DMA count is a bit weird so this is not 0 */ 36 /* DMA count is a bit weird so this is not 0 */
37 set_dma_count(i, 1); 37 set_dma_count(i, 1);
@@ -51,14 +51,14 @@ static int i8237A_suspend(struct sys_device *dev, pm_message_t state)
51} 51}
52 52
53static struct sysdev_class i8237_sysdev_class = { 53static struct sysdev_class i8237_sysdev_class = {
54 .name = "i8237", 54 .name = "i8237",
55 .suspend = i8237A_suspend, 55 .suspend = i8237A_suspend,
56 .resume = i8237A_resume, 56 .resume = i8237A_resume,
57}; 57};
58 58
59static struct sys_device device_i8237A = { 59static struct sys_device device_i8237A = {
60 .id = 0, 60 .id = 0,
61 .cls = &i8237_sysdev_class, 61 .cls = &i8237_sysdev_class,
62}; 62};
63 63
64static int __init i8237A_init_sysfs(void) 64static int __init i8237A_init_sysfs(void)
@@ -68,5 +68,4 @@ static int __init i8237A_init_sysfs(void)
68 error = sysdev_register(&device_i8237A); 68 error = sysdev_register(&device_i8237A);
69 return error; 69 return error;
70} 70}
71
72device_initcall(i8237A_init_sysfs); 71device_initcall(i8237A_init_sysfs);
diff --git a/arch/x86/kernel/io_apic.c b/arch/x86/kernel/io_apic.c
index 0480d06a12a..7248ca11bdc 100644
--- a/arch/x86/kernel/io_apic.c
+++ b/arch/x86/kernel/io_apic.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Intel IO-APIC support for multi-Pentium hosts. 2 * Intel IO-APIC support for multi-Pentium hosts.
3 * 3 *
4 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar, Hajnalka Szabo 4 * Copyright (C) 1997, 1998, 1999, 2000, 2009 Ingo Molnar, Hajnalka Szabo
5 * 5 *
6 * Many thanks to Stig Venaas for trying out countless experimental 6 * Many thanks to Stig Venaas for trying out countless experimental
7 * patches and reporting/debugging problems patiently! 7 * patches and reporting/debugging problems patiently!
@@ -62,9 +62,7 @@
62#include <asm/uv/uv_hub.h> 62#include <asm/uv/uv_hub.h>
63#include <asm/uv/uv_irq.h> 63#include <asm/uv/uv_irq.h>
64 64
65#include <mach_ipi.h> 65#include <asm/genapic.h>
66#include <mach_apic.h>
67#include <mach_apicdef.h>
68 66
69#define __apicdebuginit(type) static type __init 67#define __apicdebuginit(type) static type __init
70 68
@@ -100,10 +98,19 @@ DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
100 98
101int skip_ioapic_setup; 99int skip_ioapic_setup;
102 100
101void arch_disable_smp_support(void)
102{
103#ifdef CONFIG_PCI
104 noioapicquirk = 1;
105 noioapicreroute = -1;
106#endif
107 skip_ioapic_setup = 1;
108}
109
103static int __init parse_noapic(char *str) 110static int __init parse_noapic(char *str)
104{ 111{
105 /* disable IO-APIC */ 112 /* disable IO-APIC */
106 disable_ioapic_setup(); 113 arch_disable_smp_support();
107 return 0; 114 return 0;
108} 115}
109early_param("noapic", parse_noapic); 116early_param("noapic", parse_noapic);
@@ -479,7 +486,7 @@ __ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
479 io_apic_write(apic, 0x10 + 2*pin, eu.w1); 486 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
480} 487}
481 488
482static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) 489void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
483{ 490{
484 unsigned long flags; 491 unsigned long flags;
485 spin_lock_irqsave(&ioapic_lock, flags); 492 spin_lock_irqsave(&ioapic_lock, flags);
@@ -514,11 +521,11 @@ static void send_cleanup_vector(struct irq_cfg *cfg)
514 for_each_cpu_and(i, cfg->old_domain, cpu_online_mask) 521 for_each_cpu_and(i, cfg->old_domain, cpu_online_mask)
515 cfg->move_cleanup_count++; 522 cfg->move_cleanup_count++;
516 for_each_cpu_and(i, cfg->old_domain, cpu_online_mask) 523 for_each_cpu_and(i, cfg->old_domain, cpu_online_mask)
517 send_IPI_mask(cpumask_of(i), IRQ_MOVE_CLEANUP_VECTOR); 524 apic->send_IPI_mask(cpumask_of(i), IRQ_MOVE_CLEANUP_VECTOR);
518 } else { 525 } else {
519 cpumask_and(cleanup_mask, cfg->old_domain, cpu_online_mask); 526 cpumask_and(cleanup_mask, cfg->old_domain, cpu_online_mask);
520 cfg->move_cleanup_count = cpumask_weight(cleanup_mask); 527 cfg->move_cleanup_count = cpumask_weight(cleanup_mask);
521 send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR); 528 apic->send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR);
522 free_cpumask_var(cleanup_mask); 529 free_cpumask_var(cleanup_mask);
523 } 530 }
524 cfg->move_in_progress = 0; 531 cfg->move_in_progress = 0;
@@ -563,8 +570,9 @@ static int
563assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask); 570assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask);
564 571
565/* 572/*
566 * Either sets desc->affinity to a valid value, and returns cpu_mask_to_apicid 573 * Either sets desc->affinity to a valid value, and returns
567 * of that, or returns BAD_APICID and leaves desc->affinity untouched. 574 * ->cpu_mask_to_apicid of that, or returns BAD_APICID and
575 * leaves desc->affinity untouched.
568 */ 576 */
569static unsigned int 577static unsigned int
570set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask) 578set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask)
@@ -582,7 +590,8 @@ set_desc_affinity(struct irq_desc *desc, const struct cpumask *mask)
582 590
583 cpumask_and(desc->affinity, cfg->domain, mask); 591 cpumask_and(desc->affinity, cfg->domain, mask);
584 set_extra_move_desc(desc, mask); 592 set_extra_move_desc(desc, mask);
585 return cpu_mask_to_apicid_and(desc->affinity, cpu_online_mask); 593
594 return apic->cpu_mask_to_apicid_and(desc->affinity, cpu_online_mask);
586} 595}
587 596
588static void 597static void
@@ -797,23 +806,6 @@ static void clear_IO_APIC (void)
797 clear_IO_APIC_pin(apic, pin); 806 clear_IO_APIC_pin(apic, pin);
798} 807}
799 808
800#if !defined(CONFIG_SMP) && defined(CONFIG_X86_32)
801void send_IPI_self(int vector)
802{
803 unsigned int cfg;
804
805 /*
806 * Wait for idle.
807 */
808 apic_wait_icr_idle();
809 cfg = APIC_DM_FIXED | APIC_DEST_SELF | vector | APIC_DEST_LOGICAL;
810 /*
811 * Send the IPI. The write to APIC_ICR fires this off.
812 */
813 apic_write(APIC_ICR, cfg);
814}
815#endif /* !CONFIG_SMP && CONFIG_X86_32*/
816
817#ifdef CONFIG_X86_32 809#ifdef CONFIG_X86_32
818/* 810/*
819 * support for broken MP BIOSs, enables hand-redirection of PIRQ0-7 to 811 * support for broken MP BIOSs, enables hand-redirection of PIRQ0-7 to
@@ -1316,7 +1308,7 @@ __assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask)
1316 int new_cpu; 1308 int new_cpu;
1317 int vector, offset; 1309 int vector, offset;
1318 1310
1319 vector_allocation_domain(cpu, tmp_mask); 1311 apic->vector_allocation_domain(cpu, tmp_mask);
1320 1312
1321 vector = current_vector; 1313 vector = current_vector;
1322 offset = current_offset; 1314 offset = current_offset;
@@ -1486,10 +1478,10 @@ static void ioapic_register_intr(int irq, struct irq_desc *desc, unsigned long t
1486 handle_edge_irq, "edge"); 1478 handle_edge_irq, "edge");
1487} 1479}
1488 1480
1489static int setup_ioapic_entry(int apic, int irq, 1481int setup_ioapic_entry(int apic_id, int irq,
1490 struct IO_APIC_route_entry *entry, 1482 struct IO_APIC_route_entry *entry,
1491 unsigned int destination, int trigger, 1483 unsigned int destination, int trigger,
1492 int polarity, int vector) 1484 int polarity, int vector)
1493{ 1485{
1494 /* 1486 /*
1495 * add it to the IO-APIC irq-routing table: 1487 * add it to the IO-APIC irq-routing table:
@@ -1498,25 +1490,25 @@ static int setup_ioapic_entry(int apic, int irq,
1498 1490
1499#ifdef CONFIG_INTR_REMAP 1491#ifdef CONFIG_INTR_REMAP
1500 if (intr_remapping_enabled) { 1492 if (intr_remapping_enabled) {
1501 struct intel_iommu *iommu = map_ioapic_to_ir(apic); 1493 struct intel_iommu *iommu = map_ioapic_to_ir(apic_id);
1502 struct irte irte; 1494 struct irte irte;
1503 struct IR_IO_APIC_route_entry *ir_entry = 1495 struct IR_IO_APIC_route_entry *ir_entry =
1504 (struct IR_IO_APIC_route_entry *) entry; 1496 (struct IR_IO_APIC_route_entry *) entry;
1505 int index; 1497 int index;
1506 1498
1507 if (!iommu) 1499 if (!iommu)
1508 panic("No mapping iommu for ioapic %d\n", apic); 1500 panic("No mapping iommu for ioapic %d\n", apic_id);
1509 1501
1510 index = alloc_irte(iommu, irq, 1); 1502 index = alloc_irte(iommu, irq, 1);
1511 if (index < 0) 1503 if (index < 0)
1512 panic("Failed to allocate IRTE for ioapic %d\n", apic); 1504 panic("Failed to allocate IRTE for ioapic %d\n", apic_id);
1513 1505
1514 memset(&irte, 0, sizeof(irte)); 1506 memset(&irte, 0, sizeof(irte));
1515 1507
1516 irte.present = 1; 1508 irte.present = 1;
1517 irte.dst_mode = INT_DEST_MODE; 1509 irte.dst_mode = apic->irq_dest_mode;
1518 irte.trigger_mode = trigger; 1510 irte.trigger_mode = trigger;
1519 irte.dlvry_mode = INT_DELIVERY_MODE; 1511 irte.dlvry_mode = apic->irq_delivery_mode;
1520 irte.vector = vector; 1512 irte.vector = vector;
1521 irte.dest_id = IRTE_DEST(destination); 1513 irte.dest_id = IRTE_DEST(destination);
1522 1514
@@ -1529,8 +1521,8 @@ static int setup_ioapic_entry(int apic, int irq,
1529 } else 1521 } else
1530#endif 1522#endif
1531 { 1523 {
1532 entry->delivery_mode = INT_DELIVERY_MODE; 1524 entry->delivery_mode = apic->irq_delivery_mode;
1533 entry->dest_mode = INT_DEST_MODE; 1525 entry->dest_mode = apic->irq_dest_mode;
1534 entry->dest = destination; 1526 entry->dest = destination;
1535 } 1527 }
1536 1528
@@ -1547,7 +1539,7 @@ static int setup_ioapic_entry(int apic, int irq,
1547 return 0; 1539 return 0;
1548} 1540}
1549 1541
1550static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq, struct irq_desc *desc, 1542static void setup_IO_APIC_irq(int apic_id, int pin, unsigned int irq, struct irq_desc *desc,
1551 int trigger, int polarity) 1543 int trigger, int polarity)
1552{ 1544{
1553 struct irq_cfg *cfg; 1545 struct irq_cfg *cfg;
@@ -1559,22 +1551,22 @@ static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq, struct irq_de
1559 1551
1560 cfg = desc->chip_data; 1552 cfg = desc->chip_data;
1561 1553
1562 if (assign_irq_vector(irq, cfg, TARGET_CPUS)) 1554 if (assign_irq_vector(irq, cfg, apic->target_cpus()))
1563 return; 1555 return;
1564 1556
1565 dest = cpu_mask_to_apicid_and(cfg->domain, TARGET_CPUS); 1557 dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus());
1566 1558
1567 apic_printk(APIC_VERBOSE,KERN_DEBUG 1559 apic_printk(APIC_VERBOSE,KERN_DEBUG
1568 "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> " 1560 "IOAPIC[%d]: Set routing entry (%d-%d -> 0x%x -> "
1569 "IRQ %d Mode:%i Active:%i)\n", 1561 "IRQ %d Mode:%i Active:%i)\n",
1570 apic, mp_ioapics[apic].apicid, pin, cfg->vector, 1562 apic_id, mp_ioapics[apic_id].apicid, pin, cfg->vector,
1571 irq, trigger, polarity); 1563 irq, trigger, polarity);
1572 1564
1573 1565
1574 if (setup_ioapic_entry(mp_ioapics[apic].apicid, irq, &entry, 1566 if (setup_ioapic_entry(mp_ioapics[apic_id].apicid, irq, &entry,
1575 dest, trigger, polarity, cfg->vector)) { 1567 dest, trigger, polarity, cfg->vector)) {
1576 printk("Failed to setup ioapic entry for ioapic %d, pin %d\n", 1568 printk("Failed to setup ioapic entry for ioapic %d, pin %d\n",
1577 mp_ioapics[apic].apicid, pin); 1569 mp_ioapics[apic_id].apicid, pin);
1578 __clear_irq_vector(irq, cfg); 1570 __clear_irq_vector(irq, cfg);
1579 return; 1571 return;
1580 } 1572 }
@@ -1583,12 +1575,12 @@ static void setup_IO_APIC_irq(int apic, int pin, unsigned int irq, struct irq_de
1583 if (irq < NR_IRQS_LEGACY) 1575 if (irq < NR_IRQS_LEGACY)
1584 disable_8259A_irq(irq); 1576 disable_8259A_irq(irq);
1585 1577
1586 ioapic_write_entry(apic, pin, entry); 1578 ioapic_write_entry(apic_id, pin, entry);
1587} 1579}
1588 1580
1589static void __init setup_IO_APIC_irqs(void) 1581static void __init setup_IO_APIC_irqs(void)
1590{ 1582{
1591 int apic, pin, idx, irq; 1583 int apic_id, pin, idx, irq;
1592 int notcon = 0; 1584 int notcon = 0;
1593 struct irq_desc *desc; 1585 struct irq_desc *desc;
1594 struct irq_cfg *cfg; 1586 struct irq_cfg *cfg;
@@ -1596,19 +1588,19 @@ static void __init setup_IO_APIC_irqs(void)
1596 1588
1597 apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n"); 1589 apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
1598 1590
1599 for (apic = 0; apic < nr_ioapics; apic++) { 1591 for (apic_id = 0; apic_id < nr_ioapics; apic_id++) {
1600 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { 1592 for (pin = 0; pin < nr_ioapic_registers[apic_id]; pin++) {
1601 1593
1602 idx = find_irq_entry(apic, pin, mp_INT); 1594 idx = find_irq_entry(apic_id, pin, mp_INT);
1603 if (idx == -1) { 1595 if (idx == -1) {
1604 if (!notcon) { 1596 if (!notcon) {
1605 notcon = 1; 1597 notcon = 1;
1606 apic_printk(APIC_VERBOSE, 1598 apic_printk(APIC_VERBOSE,
1607 KERN_DEBUG " %d-%d", 1599 KERN_DEBUG " %d-%d",
1608 mp_ioapics[apic].apicid, pin); 1600 mp_ioapics[apic_id].apicid, pin);
1609 } else 1601 } else
1610 apic_printk(APIC_VERBOSE, " %d-%d", 1602 apic_printk(APIC_VERBOSE, " %d-%d",
1611 mp_ioapics[apic].apicid, pin); 1603 mp_ioapics[apic_id].apicid, pin);
1612 continue; 1604 continue;
1613 } 1605 }
1614 if (notcon) { 1606 if (notcon) {
@@ -1617,20 +1609,25 @@ static void __init setup_IO_APIC_irqs(void)
1617 notcon = 0; 1609 notcon = 0;
1618 } 1610 }
1619 1611
1620 irq = pin_2_irq(idx, apic, pin); 1612 irq = pin_2_irq(idx, apic_id, pin);
1621#ifdef CONFIG_X86_32 1613
1622 if (multi_timer_check(apic, irq)) 1614 /*
1615 * Skip the timer IRQ if there's a quirk handler
1616 * installed and if it returns 1:
1617 */
1618 if (apic->multi_timer_check &&
1619 apic->multi_timer_check(apic_id, irq))
1623 continue; 1620 continue;
1624#endif 1621
1625 desc = irq_to_desc_alloc_cpu(irq, cpu); 1622 desc = irq_to_desc_alloc_cpu(irq, cpu);
1626 if (!desc) { 1623 if (!desc) {
1627 printk(KERN_INFO "can not get irq_desc for %d\n", irq); 1624 printk(KERN_INFO "can not get irq_desc for %d\n", irq);
1628 continue; 1625 continue;
1629 } 1626 }
1630 cfg = desc->chip_data; 1627 cfg = desc->chip_data;
1631 add_pin_to_irq_cpu(cfg, cpu, apic, pin); 1628 add_pin_to_irq_cpu(cfg, cpu, apic_id, pin);
1632 1629
1633 setup_IO_APIC_irq(apic, pin, irq, desc, 1630 setup_IO_APIC_irq(apic_id, pin, irq, desc,
1634 irq_trigger(idx), irq_polarity(idx)); 1631 irq_trigger(idx), irq_polarity(idx));
1635 } 1632 }
1636 } 1633 }
@@ -1643,7 +1640,7 @@ static void __init setup_IO_APIC_irqs(void)
1643/* 1640/*
1644 * Set up the timer pin, possibly with the 8259A-master behind. 1641 * Set up the timer pin, possibly with the 8259A-master behind.
1645 */ 1642 */
1646static void __init setup_timer_IRQ0_pin(unsigned int apic, unsigned int pin, 1643static void __init setup_timer_IRQ0_pin(unsigned int apic_id, unsigned int pin,
1647 int vector) 1644 int vector)
1648{ 1645{
1649 struct IO_APIC_route_entry entry; 1646 struct IO_APIC_route_entry entry;
@@ -1659,10 +1656,10 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic, unsigned int pin,
1659 * We use logical delivery to get the timer IRQ 1656 * We use logical delivery to get the timer IRQ
1660 * to the first CPU. 1657 * to the first CPU.
1661 */ 1658 */
1662 entry.dest_mode = INT_DEST_MODE; 1659 entry.dest_mode = apic->irq_dest_mode;
1663 entry.mask = 1; /* mask IRQ now */ 1660 entry.mask = 0; /* don't mask IRQ for edge */
1664 entry.dest = cpu_mask_to_apicid(TARGET_CPUS); 1661 entry.dest = apic->cpu_mask_to_apicid(apic->target_cpus());
1665 entry.delivery_mode = INT_DELIVERY_MODE; 1662 entry.delivery_mode = apic->irq_delivery_mode;
1666 entry.polarity = 0; 1663 entry.polarity = 0;
1667 entry.trigger = 0; 1664 entry.trigger = 0;
1668 entry.vector = vector; 1665 entry.vector = vector;
@@ -1676,7 +1673,7 @@ static void __init setup_timer_IRQ0_pin(unsigned int apic, unsigned int pin,
1676 /* 1673 /*
1677 * Add it to the IO-APIC irq-routing table: 1674 * Add it to the IO-APIC irq-routing table:
1678 */ 1675 */
1679 ioapic_write_entry(apic, pin, entry); 1676 ioapic_write_entry(apic_id, pin, entry);
1680} 1677}
1681 1678
1682 1679
@@ -2089,7 +2086,7 @@ static void __init setup_ioapic_ids_from_mpc(void)
2089{ 2086{
2090 union IO_APIC_reg_00 reg_00; 2087 union IO_APIC_reg_00 reg_00;
2091 physid_mask_t phys_id_present_map; 2088 physid_mask_t phys_id_present_map;
2092 int apic; 2089 int apic_id;
2093 int i; 2090 int i;
2094 unsigned char old_id; 2091 unsigned char old_id;
2095 unsigned long flags; 2092 unsigned long flags;
@@ -2108,26 +2105,26 @@ static void __init setup_ioapic_ids_from_mpc(void)
2108 * This is broken; anything with a real cpu count has to 2105 * This is broken; anything with a real cpu count has to
2109 * circumvent this idiocy regardless. 2106 * circumvent this idiocy regardless.
2110 */ 2107 */
2111 phys_id_present_map = ioapic_phys_id_map(phys_cpu_present_map); 2108 phys_id_present_map = apic->ioapic_phys_id_map(phys_cpu_present_map);
2112 2109
2113 /* 2110 /*
2114 * Set the IOAPIC ID to the value stored in the MPC table. 2111 * Set the IOAPIC ID to the value stored in the MPC table.
2115 */ 2112 */
2116 for (apic = 0; apic < nr_ioapics; apic++) { 2113 for (apic_id = 0; apic_id < nr_ioapics; apic_id++) {
2117 2114
2118 /* Read the register 0 value */ 2115 /* Read the register 0 value */
2119 spin_lock_irqsave(&ioapic_lock, flags); 2116 spin_lock_irqsave(&ioapic_lock, flags);
2120 reg_00.raw = io_apic_read(apic, 0); 2117 reg_00.raw = io_apic_read(apic_id, 0);
2121 spin_unlock_irqrestore(&ioapic_lock, flags); 2118 spin_unlock_irqrestore(&ioapic_lock, flags);
2122 2119
2123 old_id = mp_ioapics[apic].apicid; 2120 old_id = mp_ioapics[apic_id].apicid;
2124 2121
2125 if (mp_ioapics[apic].apicid >= get_physical_broadcast()) { 2122 if (mp_ioapics[apic_id].apicid >= get_physical_broadcast()) {
2126 printk(KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n", 2123 printk(KERN_ERR "BIOS bug, IO-APIC#%d ID is %d in the MPC table!...\n",
2127 apic, mp_ioapics[apic].apicid); 2124 apic_id, mp_ioapics[apic_id].apicid);
2128 printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n", 2125 printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
2129 reg_00.bits.ID); 2126 reg_00.bits.ID);
2130 mp_ioapics[apic].apicid = reg_00.bits.ID; 2127 mp_ioapics[apic_id].apicid = reg_00.bits.ID;
2131 } 2128 }
2132 2129
2133 /* 2130 /*
@@ -2135,10 +2132,10 @@ static void __init setup_ioapic_ids_from_mpc(void)
2135 * system must have a unique ID or we get lots of nice 2132 * system must have a unique ID or we get lots of nice
2136 * 'stuck on smp_invalidate_needed IPI wait' messages. 2133 * 'stuck on smp_invalidate_needed IPI wait' messages.
2137 */ 2134 */
2138 if (check_apicid_used(phys_id_present_map, 2135 if (apic->check_apicid_used(phys_id_present_map,
2139 mp_ioapics[apic].apicid)) { 2136 mp_ioapics[apic_id].apicid)) {
2140 printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n", 2137 printk(KERN_ERR "BIOS bug, IO-APIC#%d ID %d is already used!...\n",
2141 apic, mp_ioapics[apic].apicid); 2138 apic_id, mp_ioapics[apic_id].apicid);
2142 for (i = 0; i < get_physical_broadcast(); i++) 2139 for (i = 0; i < get_physical_broadcast(); i++)
2143 if (!physid_isset(i, phys_id_present_map)) 2140 if (!physid_isset(i, phys_id_present_map))
2144 break; 2141 break;
@@ -2147,13 +2144,13 @@ static void __init setup_ioapic_ids_from_mpc(void)
2147 printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n", 2144 printk(KERN_ERR "... fixing up to %d. (tell your hw vendor)\n",
2148 i); 2145 i);
2149 physid_set(i, phys_id_present_map); 2146 physid_set(i, phys_id_present_map);
2150 mp_ioapics[apic].apicid = i; 2147 mp_ioapics[apic_id].apicid = i;
2151 } else { 2148 } else {
2152 physid_mask_t tmp; 2149 physid_mask_t tmp;
2153 tmp = apicid_to_cpu_present(mp_ioapics[apic].apicid); 2150 tmp = apic->apicid_to_cpu_present(mp_ioapics[apic_id].apicid);
2154 apic_printk(APIC_VERBOSE, "Setting %d in the " 2151 apic_printk(APIC_VERBOSE, "Setting %d in the "
2155 "phys_id_present_map\n", 2152 "phys_id_present_map\n",
2156 mp_ioapics[apic].apicid); 2153 mp_ioapics[apic_id].apicid);
2157 physids_or(phys_id_present_map, phys_id_present_map, tmp); 2154 physids_or(phys_id_present_map, phys_id_present_map, tmp);
2158 } 2155 }
2159 2156
@@ -2162,11 +2159,11 @@ static void __init setup_ioapic_ids_from_mpc(void)
2162 * We need to adjust the IRQ routing table 2159 * We need to adjust the IRQ routing table
2163 * if the ID changed. 2160 * if the ID changed.
2164 */ 2161 */
2165 if (old_id != mp_ioapics[apic].apicid) 2162 if (old_id != mp_ioapics[apic_id].apicid)
2166 for (i = 0; i < mp_irq_entries; i++) 2163 for (i = 0; i < mp_irq_entries; i++)
2167 if (mp_irqs[i].dstapic == old_id) 2164 if (mp_irqs[i].dstapic == old_id)
2168 mp_irqs[i].dstapic 2165 mp_irqs[i].dstapic
2169 = mp_ioapics[apic].apicid; 2166 = mp_ioapics[apic_id].apicid;
2170 2167
2171 /* 2168 /*
2172 * Read the right value from the MPC table and 2169 * Read the right value from the MPC table and
@@ -2174,20 +2171,20 @@ static void __init setup_ioapic_ids_from_mpc(void)
2174 */ 2171 */
2175 apic_printk(APIC_VERBOSE, KERN_INFO 2172 apic_printk(APIC_VERBOSE, KERN_INFO
2176 "...changing IO-APIC physical APIC ID to %d ...", 2173 "...changing IO-APIC physical APIC ID to %d ...",
2177 mp_ioapics[apic].apicid); 2174 mp_ioapics[apic_id].apicid);
2178 2175
2179 reg_00.bits.ID = mp_ioapics[apic].apicid; 2176 reg_00.bits.ID = mp_ioapics[apic_id].apicid;
2180 spin_lock_irqsave(&ioapic_lock, flags); 2177 spin_lock_irqsave(&ioapic_lock, flags);
2181 io_apic_write(apic, 0, reg_00.raw); 2178 io_apic_write(apic_id, 0, reg_00.raw);
2182 spin_unlock_irqrestore(&ioapic_lock, flags); 2179 spin_unlock_irqrestore(&ioapic_lock, flags);
2183 2180
2184 /* 2181 /*
2185 * Sanity check 2182 * Sanity check
2186 */ 2183 */
2187 spin_lock_irqsave(&ioapic_lock, flags); 2184 spin_lock_irqsave(&ioapic_lock, flags);
2188 reg_00.raw = io_apic_read(apic, 0); 2185 reg_00.raw = io_apic_read(apic_id, 0);
2189 spin_unlock_irqrestore(&ioapic_lock, flags); 2186 spin_unlock_irqrestore(&ioapic_lock, flags);
2190 if (reg_00.bits.ID != mp_ioapics[apic].apicid) 2187 if (reg_00.bits.ID != mp_ioapics[apic_id].apicid)
2191 printk("could not set ID!\n"); 2188 printk("could not set ID!\n");
2192 else 2189 else
2193 apic_printk(APIC_VERBOSE, " ok.\n"); 2190 apic_printk(APIC_VERBOSE, " ok.\n");
@@ -2290,7 +2287,7 @@ static int ioapic_retrigger_irq(unsigned int irq)
2290 unsigned long flags; 2287 unsigned long flags;
2291 2288
2292 spin_lock_irqsave(&vector_lock, flags); 2289 spin_lock_irqsave(&vector_lock, flags);
2293 send_IPI_mask(cpumask_of(cpumask_first(cfg->domain)), cfg->vector); 2290 apic->send_IPI_mask(cpumask_of(cpumask_first(cfg->domain)), cfg->vector);
2294 spin_unlock_irqrestore(&vector_lock, flags); 2291 spin_unlock_irqrestore(&vector_lock, flags);
2295 2292
2296 return 1; 2293 return 1;
@@ -2298,7 +2295,7 @@ static int ioapic_retrigger_irq(unsigned int irq)
2298#else 2295#else
2299static int ioapic_retrigger_irq(unsigned int irq) 2296static int ioapic_retrigger_irq(unsigned int irq)
2300{ 2297{
2301 send_IPI_self(irq_cfg(irq)->vector); 2298 apic->send_IPI_self(irq_cfg(irq)->vector);
2302 2299
2303 return 1; 2300 return 1;
2304} 2301}
@@ -2362,7 +2359,7 @@ migrate_ioapic_irq_desc(struct irq_desc *desc, const struct cpumask *mask)
2362 2359
2363 set_extra_move_desc(desc, mask); 2360 set_extra_move_desc(desc, mask);
2364 2361
2365 dest = cpu_mask_to_apicid_and(cfg->domain, mask); 2362 dest = apic->cpu_mask_to_apicid_and(cfg->domain, mask);
2366 2363
2367 modify_ioapic_rte = desc->status & IRQ_LEVEL; 2364 modify_ioapic_rte = desc->status & IRQ_LEVEL;
2368 if (modify_ioapic_rte) { 2365 if (modify_ioapic_rte) {
@@ -2866,19 +2863,15 @@ static inline void __init check_timer(void)
2866 int cpu = boot_cpu_id; 2863 int cpu = boot_cpu_id;
2867 int apic1, pin1, apic2, pin2; 2864 int apic1, pin1, apic2, pin2;
2868 unsigned long flags; 2865 unsigned long flags;
2869 unsigned int ver;
2870 int no_pin1 = 0; 2866 int no_pin1 = 0;
2871 2867
2872 local_irq_save(flags); 2868 local_irq_save(flags);
2873 2869
2874 ver = apic_read(APIC_LVR);
2875 ver = GET_APIC_VERSION(ver);
2876
2877 /* 2870 /*
2878 * get/set the timer IRQ vector: 2871 * get/set the timer IRQ vector:
2879 */ 2872 */
2880 disable_8259A_irq(0); 2873 disable_8259A_irq(0);
2881 assign_irq_vector(0, cfg, TARGET_CPUS); 2874 assign_irq_vector(0, cfg, apic->target_cpus());
2882 2875
2883 /* 2876 /*
2884 * As IRQ0 is to be enabled in the 8259A, the virtual 2877 * As IRQ0 is to be enabled in the 8259A, the virtual
@@ -2892,7 +2885,13 @@ static inline void __init check_timer(void)
2892 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT); 2885 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_EXTINT);
2893 init_8259A(1); 2886 init_8259A(1);
2894#ifdef CONFIG_X86_32 2887#ifdef CONFIG_X86_32
2895 timer_ack = (nmi_watchdog == NMI_IO_APIC && !APIC_INTEGRATED(ver)); 2888 {
2889 unsigned int ver;
2890
2891 ver = apic_read(APIC_LVR);
2892 ver = GET_APIC_VERSION(ver);
2893 timer_ack = (nmi_watchdog == NMI_IO_APIC && !APIC_INTEGRATED(ver));
2894 }
2896#endif 2895#endif
2897 2896
2898 pin1 = find_isa_irq_pin(0, mp_INT); 2897 pin1 = find_isa_irq_pin(0, mp_INT);
@@ -2931,8 +2930,17 @@ static inline void __init check_timer(void)
2931 if (no_pin1) { 2930 if (no_pin1) {
2932 add_pin_to_irq_cpu(cfg, cpu, apic1, pin1); 2931 add_pin_to_irq_cpu(cfg, cpu, apic1, pin1);
2933 setup_timer_IRQ0_pin(apic1, pin1, cfg->vector); 2932 setup_timer_IRQ0_pin(apic1, pin1, cfg->vector);
2933 } else {
2934 /* for edge trigger, setup_IO_APIC_irq already
2935 * leave it unmasked.
2936 * so only need to unmask if it is level-trigger
2937 * do we really have level trigger timer?
2938 */
2939 int idx;
2940 idx = find_irq_entry(apic1, pin1, mp_INT);
2941 if (idx != -1 && irq_trigger(idx))
2942 unmask_IO_APIC_irq_desc(desc);
2934 } 2943 }
2935 unmask_IO_APIC_irq_desc(desc);
2936 if (timer_irq_works()) { 2944 if (timer_irq_works()) {
2937 if (nmi_watchdog == NMI_IO_APIC) { 2945 if (nmi_watchdog == NMI_IO_APIC) {
2938 setup_nmi(); 2946 setup_nmi();
@@ -2946,6 +2954,7 @@ static inline void __init check_timer(void)
2946 if (intr_remapping_enabled) 2954 if (intr_remapping_enabled)
2947 panic("timer doesn't work through Interrupt-remapped IO-APIC"); 2955 panic("timer doesn't work through Interrupt-remapped IO-APIC");
2948#endif 2956#endif
2957 local_irq_disable();
2949 clear_IO_APIC_pin(apic1, pin1); 2958 clear_IO_APIC_pin(apic1, pin1);
2950 if (!no_pin1) 2959 if (!no_pin1)
2951 apic_printk(APIC_QUIET, KERN_ERR "..MP-BIOS bug: " 2960 apic_printk(APIC_QUIET, KERN_ERR "..MP-BIOS bug: "
@@ -2960,7 +2969,6 @@ static inline void __init check_timer(void)
2960 */ 2969 */
2961 replace_pin_at_irq_cpu(cfg, cpu, apic1, pin1, apic2, pin2); 2970 replace_pin_at_irq_cpu(cfg, cpu, apic1, pin1, apic2, pin2);
2962 setup_timer_IRQ0_pin(apic2, pin2, cfg->vector); 2971 setup_timer_IRQ0_pin(apic2, pin2, cfg->vector);
2963 unmask_IO_APIC_irq_desc(desc);
2964 enable_8259A_irq(0); 2972 enable_8259A_irq(0);
2965 if (timer_irq_works()) { 2973 if (timer_irq_works()) {
2966 apic_printk(APIC_QUIET, KERN_INFO "....... works.\n"); 2974 apic_printk(APIC_QUIET, KERN_INFO "....... works.\n");
@@ -2975,6 +2983,7 @@ static inline void __init check_timer(void)
2975 /* 2983 /*
2976 * Cleanup, just in case ... 2984 * Cleanup, just in case ...
2977 */ 2985 */
2986 local_irq_disable();
2978 disable_8259A_irq(0); 2987 disable_8259A_irq(0);
2979 clear_IO_APIC_pin(apic2, pin2); 2988 clear_IO_APIC_pin(apic2, pin2);
2980 apic_printk(APIC_QUIET, KERN_INFO "....... failed.\n"); 2989 apic_printk(APIC_QUIET, KERN_INFO "....... failed.\n");
@@ -3000,6 +3009,7 @@ static inline void __init check_timer(void)
3000 apic_printk(APIC_QUIET, KERN_INFO "..... works.\n"); 3009 apic_printk(APIC_QUIET, KERN_INFO "..... works.\n");
3001 goto out; 3010 goto out;
3002 } 3011 }
3012 local_irq_disable();
3003 disable_8259A_irq(0); 3013 disable_8259A_irq(0);
3004 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | cfg->vector); 3014 apic_write(APIC_LVT0, APIC_LVT_MASKED | APIC_DM_FIXED | cfg->vector);
3005 apic_printk(APIC_QUIET, KERN_INFO "..... failed.\n"); 3015 apic_printk(APIC_QUIET, KERN_INFO "..... failed.\n");
@@ -3017,6 +3027,7 @@ static inline void __init check_timer(void)
3017 apic_printk(APIC_QUIET, KERN_INFO "..... works.\n"); 3027 apic_printk(APIC_QUIET, KERN_INFO "..... works.\n");
3018 goto out; 3028 goto out;
3019 } 3029 }
3030 local_irq_disable();
3020 apic_printk(APIC_QUIET, KERN_INFO "..... failed :(.\n"); 3031 apic_printk(APIC_QUIET, KERN_INFO "..... failed :(.\n");
3021 panic("IO-APIC + timer doesn't work! Boot with apic=debug and send a " 3032 panic("IO-APIC + timer doesn't work! Boot with apic=debug and send a "
3022 "report. Then try booting with the 'noapic' option.\n"); 3033 "report. Then try booting with the 'noapic' option.\n");
@@ -3168,6 +3179,7 @@ static int __init ioapic_init_sysfs(void)
3168 3179
3169device_initcall(ioapic_init_sysfs); 3180device_initcall(ioapic_init_sysfs);
3170 3181
3182static int nr_irqs_gsi = NR_IRQS_LEGACY;
3171/* 3183/*
3172 * Dynamic irq allocate and deallocation 3184 * Dynamic irq allocate and deallocation
3173 */ 3185 */
@@ -3182,11 +3194,11 @@ unsigned int create_irq_nr(unsigned int irq_want)
3182 struct irq_desc *desc_new = NULL; 3194 struct irq_desc *desc_new = NULL;
3183 3195
3184 irq = 0; 3196 irq = 0;
3197 if (irq_want < nr_irqs_gsi)
3198 irq_want = nr_irqs_gsi;
3199
3185 spin_lock_irqsave(&vector_lock, flags); 3200 spin_lock_irqsave(&vector_lock, flags);
3186 for (new = irq_want; new < nr_irqs; new++) { 3201 for (new = irq_want; new < nr_irqs; new++) {
3187 if (platform_legacy_irq(new))
3188 continue;
3189
3190 desc_new = irq_to_desc_alloc_cpu(new, cpu); 3202 desc_new = irq_to_desc_alloc_cpu(new, cpu);
3191 if (!desc_new) { 3203 if (!desc_new) {
3192 printk(KERN_INFO "can not get irq_desc for %d\n", new); 3204 printk(KERN_INFO "can not get irq_desc for %d\n", new);
@@ -3196,7 +3208,7 @@ unsigned int create_irq_nr(unsigned int irq_want)
3196 3208
3197 if (cfg_new->vector != 0) 3209 if (cfg_new->vector != 0)
3198 continue; 3210 continue;
3199 if (__assign_irq_vector(new, cfg_new, TARGET_CPUS) == 0) 3211 if (__assign_irq_vector(new, cfg_new, apic->target_cpus()) == 0)
3200 irq = new; 3212 irq = new;
3201 break; 3213 break;
3202 } 3214 }
@@ -3211,7 +3223,6 @@ unsigned int create_irq_nr(unsigned int irq_want)
3211 return irq; 3223 return irq;
3212} 3224}
3213 3225
3214static int nr_irqs_gsi = NR_IRQS_LEGACY;
3215int create_irq(void) 3226int create_irq(void)
3216{ 3227{
3217 unsigned int irq_want; 3228 unsigned int irq_want;
@@ -3262,11 +3273,11 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms
3262 return -ENXIO; 3273 return -ENXIO;
3263 3274
3264 cfg = irq_cfg(irq); 3275 cfg = irq_cfg(irq);
3265 err = assign_irq_vector(irq, cfg, TARGET_CPUS); 3276 err = assign_irq_vector(irq, cfg, apic->target_cpus());
3266 if (err) 3277 if (err)
3267 return err; 3278 return err;
3268 3279
3269 dest = cpu_mask_to_apicid_and(cfg->domain, TARGET_CPUS); 3280 dest = apic->cpu_mask_to_apicid_and(cfg->domain, apic->target_cpus());
3270 3281
3271#ifdef CONFIG_INTR_REMAP 3282#ifdef CONFIG_INTR_REMAP
3272 if (irq_remapped(irq)) { 3283 if (irq_remapped(irq)) {
@@ -3280,9 +3291,9 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms
3280 memset (&irte, 0, sizeof(irte)); 3291 memset (&irte, 0, sizeof(irte));
3281 3292
3282 irte.present = 1; 3293 irte.present = 1;
3283 irte.dst_mode = INT_DEST_MODE; 3294 irte.dst_mode = apic->irq_dest_mode;
3284 irte.trigger_mode = 0; /* edge */ 3295 irte.trigger_mode = 0; /* edge */
3285 irte.dlvry_mode = INT_DELIVERY_MODE; 3296 irte.dlvry_mode = apic->irq_delivery_mode;
3286 irte.vector = cfg->vector; 3297 irte.vector = cfg->vector;
3287 irte.dest_id = IRTE_DEST(dest); 3298 irte.dest_id = IRTE_DEST(dest);
3288 3299
@@ -3300,10 +3311,10 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms
3300 msg->address_hi = MSI_ADDR_BASE_HI; 3311 msg->address_hi = MSI_ADDR_BASE_HI;
3301 msg->address_lo = 3312 msg->address_lo =
3302 MSI_ADDR_BASE_LO | 3313 MSI_ADDR_BASE_LO |
3303 ((INT_DEST_MODE == 0) ? 3314 ((apic->irq_dest_mode == 0) ?
3304 MSI_ADDR_DEST_MODE_PHYSICAL: 3315 MSI_ADDR_DEST_MODE_PHYSICAL:
3305 MSI_ADDR_DEST_MODE_LOGICAL) | 3316 MSI_ADDR_DEST_MODE_LOGICAL) |
3306 ((INT_DELIVERY_MODE != dest_LowestPrio) ? 3317 ((apic->irq_delivery_mode != dest_LowestPrio) ?
3307 MSI_ADDR_REDIRECTION_CPU: 3318 MSI_ADDR_REDIRECTION_CPU:
3308 MSI_ADDR_REDIRECTION_LOWPRI) | 3319 MSI_ADDR_REDIRECTION_LOWPRI) |
3309 MSI_ADDR_DEST_ID(dest); 3320 MSI_ADDR_DEST_ID(dest);
@@ -3311,7 +3322,7 @@ static int msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_ms
3311 msg->data = 3322 msg->data =
3312 MSI_DATA_TRIGGER_EDGE | 3323 MSI_DATA_TRIGGER_EDGE |
3313 MSI_DATA_LEVEL_ASSERT | 3324 MSI_DATA_LEVEL_ASSERT |
3314 ((INT_DELIVERY_MODE != dest_LowestPrio) ? 3325 ((apic->irq_delivery_mode != dest_LowestPrio) ?
3315 MSI_DATA_DELIVERY_FIXED: 3326 MSI_DATA_DELIVERY_FIXED:
3316 MSI_DATA_DELIVERY_LOWPRI) | 3327 MSI_DATA_DELIVERY_LOWPRI) |
3317 MSI_DATA_VECTOR(cfg->vector); 3328 MSI_DATA_VECTOR(cfg->vector);
@@ -3482,9 +3493,9 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
3482 sub_handle = 0; 3493 sub_handle = 0;
3483 list_for_each_entry(msidesc, &dev->msi_list, list) { 3494 list_for_each_entry(msidesc, &dev->msi_list, list) {
3484 irq = create_irq_nr(irq_want); 3495 irq = create_irq_nr(irq_want);
3485 irq_want++;
3486 if (irq == 0) 3496 if (irq == 0)
3487 return -1; 3497 return -1;
3498 irq_want = irq + 1;
3488#ifdef CONFIG_INTR_REMAP 3499#ifdef CONFIG_INTR_REMAP
3489 if (!intr_remapping_enabled) 3500 if (!intr_remapping_enabled)
3490 goto no_ir; 3501 goto no_ir;
@@ -3699,12 +3710,13 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
3699 return -ENXIO; 3710 return -ENXIO;
3700 3711
3701 cfg = irq_cfg(irq); 3712 cfg = irq_cfg(irq);
3702 err = assign_irq_vector(irq, cfg, TARGET_CPUS); 3713 err = assign_irq_vector(irq, cfg, apic->target_cpus());
3703 if (!err) { 3714 if (!err) {
3704 struct ht_irq_msg msg; 3715 struct ht_irq_msg msg;
3705 unsigned dest; 3716 unsigned dest;
3706 3717
3707 dest = cpu_mask_to_apicid_and(cfg->domain, TARGET_CPUS); 3718 dest = apic->cpu_mask_to_apicid_and(cfg->domain,
3719 apic->target_cpus());
3708 3720
3709 msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest); 3721 msg.address_hi = HT_IRQ_HIGH_DEST_ID(dest);
3710 3722
@@ -3712,11 +3724,11 @@ int arch_setup_ht_irq(unsigned int irq, struct pci_dev *dev)
3712 HT_IRQ_LOW_BASE | 3724 HT_IRQ_LOW_BASE |
3713 HT_IRQ_LOW_DEST_ID(dest) | 3725 HT_IRQ_LOW_DEST_ID(dest) |
3714 HT_IRQ_LOW_VECTOR(cfg->vector) | 3726 HT_IRQ_LOW_VECTOR(cfg->vector) |
3715 ((INT_DEST_MODE == 0) ? 3727 ((apic->irq_dest_mode == 0) ?
3716 HT_IRQ_LOW_DM_PHYSICAL : 3728 HT_IRQ_LOW_DM_PHYSICAL :
3717 HT_IRQ_LOW_DM_LOGICAL) | 3729 HT_IRQ_LOW_DM_LOGICAL) |
3718 HT_IRQ_LOW_RQEOI_EDGE | 3730 HT_IRQ_LOW_RQEOI_EDGE |
3719 ((INT_DELIVERY_MODE != dest_LowestPrio) ? 3731 ((apic->irq_delivery_mode != dest_LowestPrio) ?
3720 HT_IRQ_LOW_MT_FIXED : 3732 HT_IRQ_LOW_MT_FIXED :
3721 HT_IRQ_LOW_MT_ARBITRATED) | 3733 HT_IRQ_LOW_MT_ARBITRATED) |
3722 HT_IRQ_LOW_IRQ_MASKED; 3734 HT_IRQ_LOW_IRQ_MASKED;
@@ -3764,12 +3776,12 @@ int arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade,
3764 BUG_ON(sizeof(struct uv_IO_APIC_route_entry) != sizeof(unsigned long)); 3776 BUG_ON(sizeof(struct uv_IO_APIC_route_entry) != sizeof(unsigned long));
3765 3777
3766 entry->vector = cfg->vector; 3778 entry->vector = cfg->vector;
3767 entry->delivery_mode = INT_DELIVERY_MODE; 3779 entry->delivery_mode = apic->irq_delivery_mode;
3768 entry->dest_mode = INT_DEST_MODE; 3780 entry->dest_mode = apic->irq_dest_mode;
3769 entry->polarity = 0; 3781 entry->polarity = 0;
3770 entry->trigger = 0; 3782 entry->trigger = 0;
3771 entry->mask = 0; 3783 entry->mask = 0;
3772 entry->dest = cpu_mask_to_apicid(eligible_cpu); 3784 entry->dest = apic->cpu_mask_to_apicid(eligible_cpu);
3773 3785
3774 mmr_pnode = uv_blade_to_pnode(mmr_blade); 3786 mmr_pnode = uv_blade_to_pnode(mmr_blade);
3775 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value); 3787 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value);
@@ -3837,11 +3849,17 @@ int __init arch_probe_nr_irqs(void)
3837{ 3849{
3838 int nr; 3850 int nr;
3839 3851
3840 nr = ((8 * nr_cpu_ids) > (32 * nr_ioapics) ? 3852 if (nr_irqs > (NR_VECTORS * nr_cpu_ids))
3841 (NR_VECTORS + (8 * nr_cpu_ids)) : 3853 nr_irqs = NR_VECTORS * nr_cpu_ids;
3842 (NR_VECTORS + (32 * nr_ioapics)));
3843 3854
3844 if (nr < nr_irqs && nr > nr_irqs_gsi) 3855 nr = nr_irqs_gsi + 8 * nr_cpu_ids;
3856#if defined(CONFIG_PCI_MSI) || defined(CONFIG_HT_IRQ)
3857 /*
3858 * for MSI and HT dyn irq
3859 */
3860 nr += nr_irqs_gsi * 16;
3861#endif
3862 if (nr < nr_irqs)
3845 nr_irqs = nr; 3863 nr_irqs = nr;
3846 3864
3847 return 0; 3865 return 0;
@@ -3873,7 +3891,7 @@ int __init io_apic_get_unique_id(int ioapic, int apic_id)
3873 */ 3891 */
3874 3892
3875 if (physids_empty(apic_id_map)) 3893 if (physids_empty(apic_id_map))
3876 apic_id_map = ioapic_phys_id_map(phys_cpu_present_map); 3894 apic_id_map = apic->ioapic_phys_id_map(phys_cpu_present_map);
3877 3895
3878 spin_lock_irqsave(&ioapic_lock, flags); 3896 spin_lock_irqsave(&ioapic_lock, flags);
3879 reg_00.raw = io_apic_read(ioapic, 0); 3897 reg_00.raw = io_apic_read(ioapic, 0);
@@ -3889,10 +3907,10 @@ int __init io_apic_get_unique_id(int ioapic, int apic_id)
3889 * Every APIC in a system must have a unique ID or we get lots of nice 3907 * Every APIC in a system must have a unique ID or we get lots of nice
3890 * 'stuck on smp_invalidate_needed IPI wait' messages. 3908 * 'stuck on smp_invalidate_needed IPI wait' messages.
3891 */ 3909 */
3892 if (check_apicid_used(apic_id_map, apic_id)) { 3910 if (apic->check_apicid_used(apic_id_map, apic_id)) {
3893 3911
3894 for (i = 0; i < get_physical_broadcast(); i++) { 3912 for (i = 0; i < get_physical_broadcast(); i++) {
3895 if (!check_apicid_used(apic_id_map, i)) 3913 if (!apic->check_apicid_used(apic_id_map, i))
3896 break; 3914 break;
3897 } 3915 }
3898 3916
@@ -3905,7 +3923,7 @@ int __init io_apic_get_unique_id(int ioapic, int apic_id)
3905 apic_id = i; 3923 apic_id = i;
3906 } 3924 }
3907 3925
3908 tmp = apicid_to_cpu_present(apic_id); 3926 tmp = apic->apicid_to_cpu_present(apic_id);
3909 physids_or(apic_id_map, apic_id_map, tmp); 3927 physids_or(apic_id_map, apic_id_map, tmp);
3910 3928
3911 if (reg_00.bits.ID != apic_id) { 3929 if (reg_00.bits.ID != apic_id) {
@@ -3998,7 +4016,7 @@ int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity)
3998/* 4016/*
3999 * This function currently is only a helper for the i386 smp boot process where 4017 * This function currently is only a helper for the i386 smp boot process where
4000 * we need to reprogram the ioredtbls to cater for the cpus which have come online 4018 * we need to reprogram the ioredtbls to cater for the cpus which have come online
4001 * so mask in all cases should simply be TARGET_CPUS 4019 * so mask in all cases should simply be apic->target_cpus()
4002 */ 4020 */
4003#ifdef CONFIG_SMP 4021#ifdef CONFIG_SMP
4004void __init setup_ioapic_dest(void) 4022void __init setup_ioapic_dest(void)
@@ -4039,7 +4057,7 @@ void __init setup_ioapic_dest(void)
4039 (IRQ_NO_BALANCING | IRQ_AFFINITY_SET)) 4057 (IRQ_NO_BALANCING | IRQ_AFFINITY_SET))
4040 mask = desc->affinity; 4058 mask = desc->affinity;
4041 else 4059 else
4042 mask = TARGET_CPUS; 4060 mask = apic->target_cpus();
4043 4061
4044#ifdef CONFIG_INTR_REMAP 4062#ifdef CONFIG_INTR_REMAP
4045 if (intr_remapping_enabled) 4063 if (intr_remapping_enabled)
diff --git a/arch/x86/kernel/ipi.c b/arch/x86/kernel/ipi.c
index 285bbf8831f..dbf5445727a 100644
--- a/arch/x86/kernel/ipi.c
+++ b/arch/x86/kernel/ipi.c
@@ -17,147 +17,121 @@
17#include <asm/mmu_context.h> 17#include <asm/mmu_context.h>
18#include <asm/apic.h> 18#include <asm/apic.h>
19#include <asm/proto.h> 19#include <asm/proto.h>
20#include <asm/ipi.h>
20 21
21#ifdef CONFIG_X86_32 22void default_send_IPI_mask_sequence_phys(const struct cpumask *mask, int vector)
22#include <mach_apic.h>
23#include <mach_ipi.h>
24
25/*
26 * the following functions deal with sending IPIs between CPUs.
27 *
28 * We use 'broadcast', CPU->CPU IPIs and self-IPIs too.
29 */
30
31static inline int __prepare_ICR(unsigned int shortcut, int vector)
32{ 23{
33 unsigned int icr = shortcut | APIC_DEST_LOGICAL; 24 unsigned long query_cpu;
34 25 unsigned long flags;
35 switch (vector) { 26
36 default: 27 /*
37 icr |= APIC_DM_FIXED | vector; 28 * Hack. The clustered APIC addressing mode doesn't allow us to send
38 break; 29 * to an arbitrary mask, so I do a unicast to each CPU instead.
39 case NMI_VECTOR: 30 * - mbligh
40 icr |= APIC_DM_NMI; 31 */
41 break; 32 local_irq_save(flags);
33 for_each_cpu(query_cpu, mask) {
34 __default_send_IPI_dest_field(per_cpu(x86_cpu_to_apicid,
35 query_cpu), vector, APIC_DEST_PHYSICAL);
42 } 36 }
43 return icr; 37 local_irq_restore(flags);
44} 38}
45 39
46static inline int __prepare_ICR2(unsigned int mask) 40void default_send_IPI_mask_allbutself_phys(const struct cpumask *mask,
41 int vector)
47{ 42{
48 return SET_APIC_DEST_FIELD(mask); 43 unsigned int this_cpu = smp_processor_id();
49} 44 unsigned int query_cpu;
45 unsigned long flags;
50 46
51void __send_IPI_shortcut(unsigned int shortcut, int vector) 47 /* See Hack comment above */
52{
53 /*
54 * Subtle. In the case of the 'never do double writes' workaround
55 * we have to lock out interrupts to be safe. As we don't care
56 * of the value read we use an atomic rmw access to avoid costly
57 * cli/sti. Otherwise we use an even cheaper single atomic write
58 * to the APIC.
59 */
60 unsigned int cfg;
61 48
62 /* 49 local_irq_save(flags);
63 * Wait for idle. 50 for_each_cpu(query_cpu, mask) {
64 */ 51 if (query_cpu == this_cpu)
65 apic_wait_icr_idle(); 52 continue;
53 __default_send_IPI_dest_field(per_cpu(x86_cpu_to_apicid,
54 query_cpu), vector, APIC_DEST_PHYSICAL);
55 }
56 local_irq_restore(flags);
57}
66 58
67 /* 59void default_send_IPI_mask_sequence_logical(const struct cpumask *mask,
68 * No need to touch the target chip field 60 int vector)
69 */ 61{
70 cfg = __prepare_ICR(shortcut, vector); 62 unsigned long flags;
63 unsigned int query_cpu;
71 64
72 /* 65 /*
73 * Send the IPI. The write to APIC_ICR fires this off. 66 * Hack. The clustered APIC addressing mode doesn't allow us to send
67 * to an arbitrary mask, so I do a unicasts to each CPU instead. This
68 * should be modified to do 1 message per cluster ID - mbligh
74 */ 69 */
75 apic_write(APIC_ICR, cfg);
76}
77 70
78void send_IPI_self(int vector) 71 local_irq_save(flags);
79{ 72 for_each_cpu(query_cpu, mask)
80 __send_IPI_shortcut(APIC_DEST_SELF, vector); 73 __default_send_IPI_dest_field(
74 apic->cpu_to_logical_apicid(query_cpu), vector,
75 apic->dest_logical);
76 local_irq_restore(flags);
81} 77}
82 78
83/* 79void default_send_IPI_mask_allbutself_logical(const struct cpumask *mask,
84 * This is used to send an IPI with no shorthand notation (the destination is 80 int vector)
85 * specified in bits 56 to 63 of the ICR).
86 */
87static inline void __send_IPI_dest_field(unsigned long mask, int vector)
88{ 81{
89 unsigned long cfg; 82 unsigned long flags;
90 83 unsigned int query_cpu;
91 /* 84 unsigned int this_cpu = smp_processor_id();
92 * Wait for idle.
93 */
94 if (unlikely(vector == NMI_VECTOR))
95 safe_apic_wait_icr_idle();
96 else
97 apic_wait_icr_idle();
98
99 /*
100 * prepare target chip field
101 */
102 cfg = __prepare_ICR2(mask);
103 apic_write(APIC_ICR2, cfg);
104 85
105 /* 86 /* See Hack comment above */
106 * program the ICR
107 */
108 cfg = __prepare_ICR(0, vector);
109 87
110 /* 88 local_irq_save(flags);
111 * Send the IPI. The write to APIC_ICR fires this off. 89 for_each_cpu(query_cpu, mask) {
112 */ 90 if (query_cpu == this_cpu)
113 apic_write(APIC_ICR, cfg); 91 continue;
92 __default_send_IPI_dest_field(
93 apic->cpu_to_logical_apicid(query_cpu), vector,
94 apic->dest_logical);
95 }
96 local_irq_restore(flags);
114} 97}
115 98
99#ifdef CONFIG_X86_32
100
116/* 101/*
117 * This is only used on smaller machines. 102 * This is only used on smaller machines.
118 */ 103 */
119void send_IPI_mask_bitmask(const struct cpumask *cpumask, int vector) 104void default_send_IPI_mask_logical(const struct cpumask *cpumask, int vector)
120{ 105{
121 unsigned long mask = cpumask_bits(cpumask)[0]; 106 unsigned long mask = cpumask_bits(cpumask)[0];
122 unsigned long flags; 107 unsigned long flags;
123 108
124 local_irq_save(flags); 109 local_irq_save(flags);
125 WARN_ON(mask & ~cpumask_bits(cpu_online_mask)[0]); 110 WARN_ON(mask & ~cpumask_bits(cpu_online_mask)[0]);
126 __send_IPI_dest_field(mask, vector); 111 __default_send_IPI_dest_field(mask, vector, apic->dest_logical);
127 local_irq_restore(flags); 112 local_irq_restore(flags);
128} 113}
129 114
130void send_IPI_mask_sequence(const struct cpumask *mask, int vector) 115void default_send_IPI_allbutself(int vector)
131{ 116{
132 unsigned long flags;
133 unsigned int query_cpu;
134
135 /* 117 /*
136 * Hack. The clustered APIC addressing mode doesn't allow us to send 118 * if there are no other CPUs in the system then we get an APIC send
137 * to an arbitrary mask, so I do a unicasts to each CPU instead. This 119 * error if we try to broadcast, thus avoid sending IPIs in this case.
138 * should be modified to do 1 message per cluster ID - mbligh
139 */ 120 */
121 if (!(num_online_cpus() > 1))
122 return;
140 123
141 local_irq_save(flags); 124 __default_local_send_IPI_allbutself(vector);
142 for_each_cpu(query_cpu, mask)
143 __send_IPI_dest_field(cpu_to_logical_apicid(query_cpu), vector);
144 local_irq_restore(flags);
145} 125}
146 126
147void send_IPI_mask_allbutself(const struct cpumask *mask, int vector) 127void default_send_IPI_all(int vector)
148{ 128{
149 unsigned long flags; 129 __default_local_send_IPI_all(vector);
150 unsigned int query_cpu; 130}
151 unsigned int this_cpu = smp_processor_id();
152
153 /* See Hack comment above */
154 131
155 local_irq_save(flags); 132void default_send_IPI_self(int vector)
156 for_each_cpu(query_cpu, mask) 133{
157 if (query_cpu != this_cpu) 134 __default_send_IPI_shortcut(APIC_DEST_SELF, vector, apic->dest_logical);
158 __send_IPI_dest_field(cpu_to_logical_apicid(query_cpu),
159 vector);
160 local_irq_restore(flags);
161} 135}
162 136
163/* must come after the send_IPI functions above for inlining */ 137/* must come after the send_IPI functions above for inlining */
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index 8b30d0c2512..f13ca1650aa 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -6,10 +6,12 @@
6#include <linux/kernel_stat.h> 6#include <linux/kernel_stat.h>
7#include <linux/seq_file.h> 7#include <linux/seq_file.h>
8#include <linux/smp.h> 8#include <linux/smp.h>
9#include <linux/ftrace.h>
9 10
10#include <asm/apic.h> 11#include <asm/apic.h>
11#include <asm/io_apic.h> 12#include <asm/io_apic.h>
12#include <asm/irq.h> 13#include <asm/irq.h>
14#include <asm/idle.h>
13 15
14atomic_t irq_err_count; 16atomic_t irq_err_count;
15 17
@@ -188,4 +190,40 @@ u64 arch_irq_stat(void)
188 return sum; 190 return sum;
189} 191}
190 192
193
194/*
195 * do_IRQ handles all normal device IRQ's (the special
196 * SMP cross-CPU interrupts have their own specific
197 * handlers).
198 */
199unsigned int __irq_entry do_IRQ(struct pt_regs *regs)
200{
201 struct pt_regs *old_regs = set_irq_regs(regs);
202
203 /* high bit used in ret_from_ code */
204 unsigned vector = ~regs->orig_ax;
205 unsigned irq;
206
207 exit_idle();
208 irq_enter();
209
210 irq = __get_cpu_var(vector_irq)[vector];
211
212 if (!handle_irq(irq, regs)) {
213#ifdef CONFIG_X86_64
214 if (!disable_apic)
215 ack_APIC_irq();
216#endif
217
218 if (printk_ratelimit())
219 printk(KERN_EMERG "%s: %d.%d No irq handler for vector (irq %d)\n",
220 __func__, smp_processor_id(), vector, irq);
221 }
222
223 irq_exit();
224
225 set_irq_regs(old_regs);
226 return 1;
227}
228
191EXPORT_SYMBOL_GPL(vector_used_by_percpu_irq); 229EXPORT_SYMBOL_GPL(vector_used_by_percpu_irq);
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index e0f29be8ab0..4beb9a13873 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -191,33 +191,16 @@ static inline int
191execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) { return 0; } 191execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) { return 0; }
192#endif 192#endif
193 193
194/* 194bool handle_irq(unsigned irq, struct pt_regs *regs)
195 * do_IRQ handles all normal device IRQ's (the special
196 * SMP cross-CPU interrupts have their own specific
197 * handlers).
198 */
199unsigned int do_IRQ(struct pt_regs *regs)
200{ 195{
201 struct pt_regs *old_regs;
202 /* high bit used in ret_from_ code */
203 int overflow;
204 unsigned vector = ~regs->orig_ax;
205 struct irq_desc *desc; 196 struct irq_desc *desc;
206 unsigned irq; 197 int overflow;
207
208
209 old_regs = set_irq_regs(regs);
210 irq_enter();
211 irq = __get_cpu_var(vector_irq)[vector];
212 198
213 overflow = check_stack_overflow(); 199 overflow = check_stack_overflow();
214 200
215 desc = irq_to_desc(irq); 201 desc = irq_to_desc(irq);
216 if (unlikely(!desc)) { 202 if (unlikely(!desc))
217 printk(KERN_EMERG "%s: cannot handle IRQ %d vector %#x cpu %d\n", 203 return false;
218 __func__, irq, vector, smp_processor_id());
219 BUG();
220 }
221 204
222 if (!execute_on_irq_stack(overflow, desc, irq)) { 205 if (!execute_on_irq_stack(overflow, desc, irq)) {
223 if (unlikely(overflow)) 206 if (unlikely(overflow))
@@ -225,13 +208,11 @@ unsigned int do_IRQ(struct pt_regs *regs)
225 desc->handle_irq(irq, desc); 208 desc->handle_irq(irq, desc);
226 } 209 }
227 210
228 irq_exit(); 211 return true;
229 set_irq_regs(old_regs);
230 return 1;
231} 212}
232 213
233#ifdef CONFIG_HOTPLUG_CPU 214#ifdef CONFIG_HOTPLUG_CPU
234#include <mach_apic.h> 215#include <asm/genapic.h>
235 216
236/* A cpu has been removed from cpu_online_mask. Reset irq affinities. */ 217/* A cpu has been removed from cpu_online_mask. Reset irq affinities. */
237void fixup_irqs(void) 218void fixup_irqs(void)
diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
index 018963aa6ee..977d8b43a0d 100644
--- a/arch/x86/kernel/irq_64.c
+++ b/arch/x86/kernel/irq_64.c
@@ -48,42 +48,18 @@ static inline void stack_overflow_check(struct pt_regs *regs)
48#endif 48#endif
49} 49}
50 50
51/* 51bool handle_irq(unsigned irq, struct pt_regs *regs)
52 * do_IRQ handles all normal device IRQ's (the special
53 * SMP cross-CPU interrupts have their own specific
54 * handlers).
55 */
56asmlinkage unsigned int __irq_entry do_IRQ(struct pt_regs *regs)
57{ 52{
58 struct pt_regs *old_regs = set_irq_regs(regs);
59 struct irq_desc *desc; 53 struct irq_desc *desc;
60 54
61 /* high bit used in ret_from_ code */
62 unsigned vector = ~regs->orig_ax;
63 unsigned irq;
64
65 exit_idle();
66 irq_enter();
67 irq = __get_cpu_var(vector_irq)[vector];
68
69 stack_overflow_check(regs); 55 stack_overflow_check(regs);
70 56
71 desc = irq_to_desc(irq); 57 desc = irq_to_desc(irq);
72 if (likely(desc)) 58 if (unlikely(!desc))
73 generic_handle_irq_desc(irq, desc); 59 return false;
74 else {
75 if (!disable_apic)
76 ack_APIC_irq();
77
78 if (printk_ratelimit())
79 printk(KERN_EMERG "%s: %d.%d No irq handler for vector\n",
80 __func__, smp_processor_id(), vector);
81 }
82
83 irq_exit();
84 60
85 set_irq_regs(old_regs); 61 generic_handle_irq_desc(irq, desc);
86 return 1; 62 return true;
87} 63}
88 64
89#ifdef CONFIG_HOTPLUG_CPU 65#ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/x86/kernel/irqinit_32.c b/arch/x86/kernel/irqinit_32.c
index 22608ebf831..bf629cadec1 100644
--- a/arch/x86/kernel/irqinit_32.c
+++ b/arch/x86/kernel/irqinit_32.c
@@ -78,6 +78,15 @@ void __init init_ISA_irqs(void)
78 } 78 }
79} 79}
80 80
81/*
82 * IRQ2 is cascade interrupt to second interrupt controller
83 */
84static struct irqaction irq2 = {
85 .handler = no_action,
86 .mask = CPU_MASK_NONE,
87 .name = "cascade",
88};
89
81DEFINE_PER_CPU(vector_irq_t, vector_irq) = { 90DEFINE_PER_CPU(vector_irq_t, vector_irq) = {
82 [0 ... IRQ0_VECTOR - 1] = -1, 91 [0 ... IRQ0_VECTOR - 1] = -1,
83 [IRQ0_VECTOR] = 0, 92 [IRQ0_VECTOR] = 0,
@@ -176,6 +185,9 @@ void __init native_init_IRQ(void)
176 alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt); 185 alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
177#endif 186#endif
178 187
188 if (!acpi_ioapic)
189 setup_irq(2, &irq2);
190
179 /* setup after call gates are initialised (usually add in 191 /* setup after call gates are initialised (usually add in
180 * the architecture specific gates) 192 * the architecture specific gates)
181 */ 193 */
diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
index 10435a120d2..5c4f5548384 100644
--- a/arch/x86/kernel/kgdb.c
+++ b/arch/x86/kernel/kgdb.c
@@ -46,7 +46,7 @@
46#include <asm/apicdef.h> 46#include <asm/apicdef.h>
47#include <asm/system.h> 47#include <asm/system.h>
48 48
49#include <mach_ipi.h> 49#include <asm/genapic.h>
50 50
51/* 51/*
52 * Put the error code here just in case the user cares: 52 * Put the error code here just in case the user cares:
@@ -347,7 +347,7 @@ void kgdb_post_primary_code(struct pt_regs *regs, int e_vector, int err_code)
347 */ 347 */
348void kgdb_roundup_cpus(unsigned long flags) 348void kgdb_roundup_cpus(unsigned long flags)
349{ 349{
350 send_IPI_allbutself(APIC_DM_NMI); 350 apic->send_IPI_allbutself(APIC_DM_NMI);
351} 351}
352#endif 352#endif
353 353
diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index fa6bb263892..20076445319 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -3,7 +3,7 @@
3 * compliant MP-table parsing routines. 3 * compliant MP-table parsing routines.
4 * 4 *
5 * (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk> 5 * (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk>
6 * (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com> 6 * (c) 1998, 1999, 2000, 2009 Ingo Molnar <mingo@redhat.com>
7 * (c) 2008 Alexey Starikovskiy <astarikovskiy@suse.de> 7 * (c) 2008 Alexey Starikovskiy <astarikovskiy@suse.de>
8 */ 8 */
9 9
@@ -29,12 +29,7 @@
29#include <asm/setup.h> 29#include <asm/setup.h>
30#include <asm/smp.h> 30#include <asm/smp.h>
31 31
32#include <mach_apic.h> 32#include <asm/genapic.h>
33#ifdef CONFIG_X86_32
34#include <mach_apicdef.h>
35#include <mach_mpparse.h>
36#endif
37
38/* 33/*
39 * Checksum an MP configuration block. 34 * Checksum an MP configuration block.
40 */ 35 */
@@ -292,16 +287,7 @@ static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early)
292 return 0; 287 return 0;
293 288
294#ifdef CONFIG_X86_32 289#ifdef CONFIG_X86_32
295 /* 290 generic_mps_oem_check(mpc, oem, str);
296 * need to make sure summit and es7000's mps_oem_check is safe to be
297 * called early via genericarch 's mps_oem_check
298 */
299 if (early) {
300#ifdef CONFIG_X86_NUMAQ
301 numaq_mps_oem_check(mpc, oem, str);
302#endif
303 } else
304 mps_oem_check(mpc, oem, str);
305#endif 291#endif
306 /* save the local APIC address, it might be non-default */ 292 /* save the local APIC address, it might be non-default */
307 if (!acpi_lapic) 293 if (!acpi_lapic)
@@ -386,13 +372,13 @@ static int __init smp_read_mpc(struct mpc_table *mpc, unsigned early)
386 (*x86_quirks->mpc_record)++; 372 (*x86_quirks->mpc_record)++;
387 } 373 }
388 374
389#ifdef CONFIG_X86_GENERICARCH 375#ifdef CONFIG_X86_BIGSMP
390 generic_bigsmp_probe(); 376 generic_bigsmp_probe();
391#endif 377#endif
392 378
393#ifdef CONFIG_X86_32 379 if (apic->setup_apic_routing)
394 setup_apic_routing(); 380 apic->setup_apic_routing();
395#endif 381
396 if (!num_processors) 382 if (!num_processors)
397 printk(KERN_ERR "MPTABLE: no processors registered!\n"); 383 printk(KERN_ERR "MPTABLE: no processors registered!\n");
398 return num_processors; 384 return num_processors;
@@ -706,8 +692,8 @@ static int __init smp_scan_config(unsigned long base, unsigned long length,
706#endif 692#endif
707 mpf_found = mpf; 693 mpf_found = mpf;
708 694
709 printk(KERN_INFO "found SMP MP-table at [%p] %08lx\n", 695 printk(KERN_INFO "found SMP MP-table at [%p] %llx\n",
710 mpf, virt_to_phys(mpf)); 696 mpf, (u64)virt_to_phys(mpf));
711 697
712 if (!reserve) 698 if (!reserve)
713 return 1; 699 return 1;
@@ -1025,7 +1011,7 @@ static int __init update_mp_table(void)
1025 if (!smp_check_mpc(mpc, oem, str)) 1011 if (!smp_check_mpc(mpc, oem, str))
1026 return 0; 1012 return 0;
1027 1013
1028 printk(KERN_INFO "mpf: %lx\n", virt_to_phys(mpf)); 1014 printk(KERN_INFO "mpf: %llx\n", (u64)virt_to_phys(mpf));
1029 printk(KERN_INFO "physptr: %x\n", mpf->physptr); 1015 printk(KERN_INFO "physptr: %x\n", mpf->physptr);
1030 1016
1031 if (mpc_new_phys && mpc->length > mpc_new_length) { 1017 if (mpc_new_phys && mpc->length > mpc_new_length) {
diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
index 23b6d9e6e4f..bdfad80c3cf 100644
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -34,7 +34,7 @@
34 34
35#include <asm/mce.h> 35#include <asm/mce.h>
36 36
37#include <mach_traps.h> 37#include <asm/mach_traps.h>
38 38
39int unknown_nmi_panic; 39int unknown_nmi_panic;
40int nmi_watchdog_enabled; 40int nmi_watchdog_enabled;
diff --git a/arch/x86/kernel/numaq_32.c b/arch/x86/kernel/numaq_32.c
index f2191d4f271..0cc41a1d255 100644
--- a/arch/x86/kernel/numaq_32.c
+++ b/arch/x86/kernel/numaq_32.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 2002, IBM Corp. 4 * Copyright (C) 2002, IBM Corp.
5 * 5 *
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
@@ -23,17 +23,18 @@
23 * Send feedback to <gone@us.ibm.com> 23 * Send feedback to <gone@us.ibm.com>
24 */ 24 */
25 25
26#include <linux/mm.h> 26#include <linux/nodemask.h>
27#include <linux/bootmem.h> 27#include <linux/bootmem.h>
28#include <linux/mmzone.h> 28#include <linux/mmzone.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/nodemask.h> 30#include <linux/mm.h>
31#include <asm/numaq.h> 31
32#include <asm/topology.h>
33#include <asm/processor.h> 32#include <asm/processor.h>
33#include <asm/topology.h>
34#include <asm/genapic.h> 34#include <asm/genapic.h>
35#include <asm/e820.h> 35#include <asm/numaq.h>
36#include <asm/setup.h> 36#include <asm/setup.h>
37#include <asm/e820.h>
37 38
38#define MB_TO_PAGES(addr) ((addr) << (20 - PAGE_SHIFT)) 39#define MB_TO_PAGES(addr) ((addr) << (20 - PAGE_SHIFT))
39 40
@@ -91,19 +92,20 @@ static int __init numaq_pre_time_init(void)
91} 92}
92 93
93int found_numaq; 94int found_numaq;
95
94/* 96/*
95 * Have to match translation table entries to main table entries by counter 97 * Have to match translation table entries to main table entries by counter
96 * hence the mpc_record variable .... can't see a less disgusting way of 98 * hence the mpc_record variable .... can't see a less disgusting way of
97 * doing this .... 99 * doing this ....
98 */ 100 */
99struct mpc_config_translation { 101struct mpc_config_translation {
100 unsigned char mpc_type; 102 unsigned char mpc_type;
101 unsigned char trans_len; 103 unsigned char trans_len;
102 unsigned char trans_type; 104 unsigned char trans_type;
103 unsigned char trans_quad; 105 unsigned char trans_quad;
104 unsigned char trans_global; 106 unsigned char trans_global;
105 unsigned char trans_local; 107 unsigned char trans_local;
106 unsigned short trans_reserved; 108 unsigned short trans_reserved;
107}; 109};
108 110
109/* x86_quirks member */ 111/* x86_quirks member */
@@ -236,7 +238,7 @@ static int __init numaq_setup_ioapic_ids(void)
236 238
237static int __init numaq_update_genapic(void) 239static int __init numaq_update_genapic(void)
238{ 240{
239 genapic->wakeup_cpu = wakeup_secondary_cpu_via_nmi; 241 apic->wakeup_cpu = wakeup_secondary_cpu_via_nmi;
240 242
241 return 0; 243 return 0;
242} 244}
@@ -291,3 +293,280 @@ int __init get_memcfg_numaq(void)
291 smp_dump_qct(); 293 smp_dump_qct();
292 return 1; 294 return 1;
293} 295}
296
297/*
298 * APIC driver for the IBM NUMAQ chipset.
299 */
300#define APIC_DEFINITION 1
301#include <linux/threads.h>
302#include <linux/cpumask.h>
303#include <asm/mpspec.h>
304#include <asm/genapic.h>
305#include <asm/fixmap.h>
306#include <asm/apicdef.h>
307#include <asm/ipi.h>
308#include <linux/kernel.h>
309#include <linux/string.h>
310#include <linux/init.h>
311#include <linux/numa.h>
312#include <linux/smp.h>
313#include <asm/numaq.h>
314#include <asm/io.h>
315#include <linux/mmzone.h>
316#include <linux/nodemask.h>
317
318#define NUMAQ_APIC_DFR_VALUE (APIC_DFR_CLUSTER)
319
320static inline unsigned int numaq_get_apic_id(unsigned long x)
321{
322 return (x >> 24) & 0x0F;
323}
324
325static inline void numaq_send_IPI_mask(const struct cpumask *mask, int vector)
326{
327 default_send_IPI_mask_sequence_logical(mask, vector);
328}
329
330static inline void numaq_send_IPI_allbutself(int vector)
331{
332 default_send_IPI_mask_allbutself_logical(cpu_online_mask, vector);
333}
334
335static inline void numaq_send_IPI_all(int vector)
336{
337 numaq_send_IPI_mask(cpu_online_mask, vector);
338}
339
340extern void numaq_mps_oem_check(struct mpc_table *, char *, char *);
341
342#define NUMAQ_TRAMPOLINE_PHYS_LOW (0x8)
343#define NUMAQ_TRAMPOLINE_PHYS_HIGH (0xa)
344
345/*
346 * Because we use NMIs rather than the INIT-STARTUP sequence to
347 * bootstrap the CPUs, the APIC may be in a weird state. Kick it:
348 */
349static inline void numaq_smp_callin_clear_local_apic(void)
350{
351 clear_local_APIC();
352}
353
354static inline void
355numaq_store_NMI_vector(unsigned short *high, unsigned short *low)
356{
357 printk("Storing NMI vector\n");
358 *high =
359 *((volatile unsigned short *)phys_to_virt(NUMAQ_TRAMPOLINE_PHYS_HIGH));
360 *low =
361 *((volatile unsigned short *)phys_to_virt(NUMAQ_TRAMPOLINE_PHYS_LOW));
362}
363
364static inline const cpumask_t *numaq_target_cpus(void)
365{
366 return &CPU_MASK_ALL;
367}
368
369static inline unsigned long
370numaq_check_apicid_used(physid_mask_t bitmap, int apicid)
371{
372 return physid_isset(apicid, bitmap);
373}
374
375static inline unsigned long numaq_check_apicid_present(int bit)
376{
377 return physid_isset(bit, phys_cpu_present_map);
378}
379
380#define apicid_cluster(apicid) (apicid & 0xF0)
381
382static inline int numaq_apic_id_registered(void)
383{
384 return 1;
385}
386
387static inline void numaq_init_apic_ldr(void)
388{
389 /* Already done in NUMA-Q firmware */
390}
391
392static inline void numaq_setup_apic_routing(void)
393{
394 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
395 "NUMA-Q", nr_ioapics);
396}
397
398/*
399 * Skip adding the timer int on secondary nodes, which causes
400 * a small but painful rift in the time-space continuum.
401 */
402static inline int numaq_multi_timer_check(int apic, int irq)
403{
404 return apic != 0 && irq == 0;
405}
406
407static inline physid_mask_t numaq_ioapic_phys_id_map(physid_mask_t phys_map)
408{
409 /* We don't have a good way to do this yet - hack */
410 return physids_promote(0xFUL);
411}
412
413/* Mapping from cpu number to logical apicid */
414extern u8 cpu_2_logical_apicid[];
415
416static inline int numaq_cpu_to_logical_apicid(int cpu)
417{
418 if (cpu >= nr_cpu_ids)
419 return BAD_APICID;
420 return (int)cpu_2_logical_apicid[cpu];
421}
422
423/*
424 * Supporting over 60 cpus on NUMA-Q requires a locality-dependent
425 * cpu to APIC ID relation to properly interact with the intelligent
426 * mode of the cluster controller.
427 */
428static inline int numaq_cpu_present_to_apicid(int mps_cpu)
429{
430 if (mps_cpu < 60)
431 return ((mps_cpu >> 2) << 4) | (1 << (mps_cpu & 0x3));
432 else
433 return BAD_APICID;
434}
435
436static inline int numaq_apicid_to_node(int logical_apicid)
437{
438 return logical_apicid >> 4;
439}
440
441static inline physid_mask_t numaq_apicid_to_cpu_present(int logical_apicid)
442{
443 int node = numaq_apicid_to_node(logical_apicid);
444 int cpu = __ffs(logical_apicid & 0xf);
445
446 return physid_mask_of_physid(cpu + 4*node);
447}
448
449/* Where the IO area was mapped on multiquad, always 0 otherwise */
450void *xquad_portio;
451
452static inline int numaq_check_phys_apicid_present(int boot_cpu_physical_apicid)
453{
454 return 1;
455}
456
457/*
458 * We use physical apicids here, not logical, so just return the default
459 * physical broadcast to stop people from breaking us
460 */
461static inline unsigned int numaq_cpu_mask_to_apicid(const cpumask_t *cpumask)
462{
463 return 0x0F;
464}
465
466static inline unsigned int
467numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
468 const struct cpumask *andmask)
469{
470 return 0x0F;
471}
472
473/* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
474static inline int numaq_phys_pkg_id(int cpuid_apic, int index_msb)
475{
476 return cpuid_apic >> index_msb;
477}
478static int __numaq_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
479{
480 numaq_mps_oem_check(mpc, oem, productid);
481 return found_numaq;
482}
483
484static int probe_numaq(void)
485{
486 /* already know from get_memcfg_numaq() */
487 return found_numaq;
488}
489
490static void numaq_vector_allocation_domain(int cpu, cpumask_t *retmask)
491{
492 /* Careful. Some cpus do not strictly honor the set of cpus
493 * specified in the interrupt destination when using lowest
494 * priority interrupt delivery mode.
495 *
496 * In particular there was a hyperthreading cpu observed to
497 * deliver interrupts to the wrong hyperthread when only one
498 * hyperthread was specified in the interrupt desitination.
499 */
500 *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
501}
502
503static void numaq_setup_portio_remap(void)
504{
505 int num_quads = num_online_nodes();
506
507 if (num_quads <= 1)
508 return;
509
510 printk("Remapping cross-quad port I/O for %d quads\n", num_quads);
511 xquad_portio = ioremap(XQUAD_PORTIO_BASE, num_quads*XQUAD_PORTIO_QUAD);
512 printk("xquad_portio vaddr 0x%08lx, len %08lx\n",
513 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
514}
515
516struct genapic apic_numaq = {
517
518 .name = "NUMAQ",
519 .probe = probe_numaq,
520 .acpi_madt_oem_check = NULL,
521 .apic_id_registered = numaq_apic_id_registered,
522
523 .irq_delivery_mode = dest_LowestPrio,
524 /* physical delivery on LOCAL quad: */
525 .irq_dest_mode = 0,
526
527 .target_cpus = numaq_target_cpus,
528 .disable_esr = 1,
529 .dest_logical = APIC_DEST_LOGICAL,
530 .check_apicid_used = numaq_check_apicid_used,
531 .check_apicid_present = numaq_check_apicid_present,
532
533 .vector_allocation_domain = numaq_vector_allocation_domain,
534 .init_apic_ldr = numaq_init_apic_ldr,
535
536 .ioapic_phys_id_map = numaq_ioapic_phys_id_map,
537 .setup_apic_routing = numaq_setup_apic_routing,
538 .multi_timer_check = numaq_multi_timer_check,
539 .apicid_to_node = numaq_apicid_to_node,
540 .cpu_to_logical_apicid = numaq_cpu_to_logical_apicid,
541 .cpu_present_to_apicid = numaq_cpu_present_to_apicid,
542 .apicid_to_cpu_present = numaq_apicid_to_cpu_present,
543 .setup_portio_remap = numaq_setup_portio_remap,
544 .check_phys_apicid_present = numaq_check_phys_apicid_present,
545 .enable_apic_mode = NULL,
546 .phys_pkg_id = numaq_phys_pkg_id,
547 .mps_oem_check = __numaq_mps_oem_check,
548
549 .get_apic_id = numaq_get_apic_id,
550 .set_apic_id = NULL,
551 .apic_id_mask = 0x0F << 24,
552
553 .cpu_mask_to_apicid = numaq_cpu_mask_to_apicid,
554 .cpu_mask_to_apicid_and = numaq_cpu_mask_to_apicid_and,
555
556 .send_IPI_mask = numaq_send_IPI_mask,
557 .send_IPI_mask_allbutself = NULL,
558 .send_IPI_allbutself = numaq_send_IPI_allbutself,
559 .send_IPI_all = numaq_send_IPI_all,
560 .send_IPI_self = default_send_IPI_self,
561
562 .wakeup_cpu = NULL,
563 .trampoline_phys_low = NUMAQ_TRAMPOLINE_PHYS_LOW,
564 .trampoline_phys_high = NUMAQ_TRAMPOLINE_PHYS_HIGH,
565
566 /* We don't do anything here because we use NMI's to boot instead */
567 .wait_for_init_deassert = NULL,
568
569 .smp_callin_clear_local_apic = numaq_smp_callin_clear_local_apic,
570 .store_NMI_vector = numaq_store_NMI_vector,
571 .inquire_remote_apic = NULL,
572};
diff --git a/arch/x86/kernel/probe_32.c b/arch/x86/kernel/probe_32.c
new file mode 100644
index 00000000000..22337b75de6
--- /dev/null
+++ b/arch/x86/kernel/probe_32.c
@@ -0,0 +1,411 @@
1/*
2 * Default generic APIC driver. This handles up to 8 CPUs.
3 *
4 * Copyright 2003 Andi Kleen, SuSE Labs.
5 * Subject to the GNU Public License, v.2
6 *
7 * Generic x86 APIC driver probe layer.
8 */
9#include <linux/threads.h>
10#include <linux/cpumask.h>
11#include <linux/string.h>
12#include <linux/kernel.h>
13#include <linux/ctype.h>
14#include <linux/init.h>
15#include <linux/errno.h>
16#include <asm/fixmap.h>
17#include <asm/mpspec.h>
18#include <asm/apicdef.h>
19#include <asm/genapic.h>
20#include <asm/setup.h>
21
22#include <linux/threads.h>
23#include <linux/cpumask.h>
24#include <asm/mpspec.h>
25#include <asm/genapic.h>
26#include <asm/fixmap.h>
27#include <asm/apicdef.h>
28#include <linux/kernel.h>
29#include <linux/string.h>
30#include <linux/smp.h>
31#include <linux/init.h>
32#include <asm/genapic.h>
33#include <asm/ipi.h>
34
35#include <linux/smp.h>
36#include <linux/init.h>
37#include <linux/interrupt.h>
38#include <asm/acpi.h>
39#include <asm/arch_hooks.h>
40#include <asm/e820.h>
41#include <asm/setup.h>
42
43#include <asm/genapic.h>
44
45#ifdef CONFIG_HOTPLUG_CPU
46#define DEFAULT_SEND_IPI (1)
47#else
48#define DEFAULT_SEND_IPI (0)
49#endif
50
51int no_broadcast = DEFAULT_SEND_IPI;
52
53#ifdef CONFIG_X86_LOCAL_APIC
54
55static void default_vector_allocation_domain(int cpu, struct cpumask *retmask)
56{
57 /*
58 * Careful. Some cpus do not strictly honor the set of cpus
59 * specified in the interrupt destination when using lowest
60 * priority interrupt delivery mode.
61 *
62 * In particular there was a hyperthreading cpu observed to
63 * deliver interrupts to the wrong hyperthread when only one
64 * hyperthread was specified in the interrupt desitination.
65 */
66 *retmask = (cpumask_t) { { [0] = APIC_ALL_CPUS } };
67}
68
69/* should be called last. */
70static int probe_default(void)
71{
72 return 1;
73}
74
75struct genapic apic_default = {
76
77 .name = "default",
78 .probe = probe_default,
79 .acpi_madt_oem_check = NULL,
80 .apic_id_registered = default_apic_id_registered,
81
82 .irq_delivery_mode = dest_LowestPrio,
83 /* logical delivery broadcast to all CPUs: */
84 .irq_dest_mode = 1,
85
86 .target_cpus = default_target_cpus,
87 .disable_esr = 0,
88 .dest_logical = APIC_DEST_LOGICAL,
89 .check_apicid_used = default_check_apicid_used,
90 .check_apicid_present = default_check_apicid_present,
91
92 .vector_allocation_domain = default_vector_allocation_domain,
93 .init_apic_ldr = default_init_apic_ldr,
94
95 .ioapic_phys_id_map = default_ioapic_phys_id_map,
96 .setup_apic_routing = default_setup_apic_routing,
97 .multi_timer_check = NULL,
98 .apicid_to_node = default_apicid_to_node,
99 .cpu_to_logical_apicid = default_cpu_to_logical_apicid,
100 .cpu_present_to_apicid = default_cpu_present_to_apicid,
101 .apicid_to_cpu_present = default_apicid_to_cpu_present,
102 .setup_portio_remap = NULL,
103 .check_phys_apicid_present = default_check_phys_apicid_present,
104 .enable_apic_mode = NULL,
105 .phys_pkg_id = default_phys_pkg_id,
106 .mps_oem_check = NULL,
107
108 .get_apic_id = default_get_apic_id,
109 .set_apic_id = NULL,
110 .apic_id_mask = 0x0F << 24,
111
112 .cpu_mask_to_apicid = default_cpu_mask_to_apicid,
113 .cpu_mask_to_apicid_and = default_cpu_mask_to_apicid_and,
114
115 .send_IPI_mask = default_send_IPI_mask_logical,
116 .send_IPI_mask_allbutself = default_send_IPI_mask_allbutself_logical,
117 .send_IPI_allbutself = default_send_IPI_allbutself,
118 .send_IPI_all = default_send_IPI_all,
119 .send_IPI_self = default_send_IPI_self,
120
121 .wakeup_cpu = NULL,
122 .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
123 .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
124
125 .wait_for_init_deassert = default_wait_for_init_deassert,
126
127 .smp_callin_clear_local_apic = NULL,
128 .store_NMI_vector = NULL,
129 .inquire_remote_apic = default_inquire_remote_apic,
130};
131
132extern struct genapic apic_numaq;
133extern struct genapic apic_summit;
134extern struct genapic apic_bigsmp;
135extern struct genapic apic_es7000;
136extern struct genapic apic_default;
137
138struct genapic *apic = &apic_default;
139
140static struct genapic *apic_probe[] __initdata = {
141#ifdef CONFIG_X86_NUMAQ
142 &apic_numaq,
143#endif
144#ifdef CONFIG_X86_SUMMIT
145 &apic_summit,
146#endif
147#ifdef CONFIG_X86_BIGSMP
148 &apic_bigsmp,
149#endif
150#ifdef CONFIG_X86_ES7000
151 &apic_es7000,
152#endif
153 &apic_default, /* must be last */
154 NULL,
155};
156
157static int cmdline_apic __initdata;
158static int __init parse_apic(char *arg)
159{
160 int i;
161
162 if (!arg)
163 return -EINVAL;
164
165 for (i = 0; apic_probe[i]; i++) {
166 if (!strcmp(apic_probe[i]->name, arg)) {
167 apic = apic_probe[i];
168 cmdline_apic = 1;
169 return 0;
170 }
171 }
172
173 if (x86_quirks->update_genapic)
174 x86_quirks->update_genapic();
175
176 /* Parsed again by __setup for debug/verbose */
177 return 0;
178}
179early_param("apic", parse_apic);
180
181void __init generic_bigsmp_probe(void)
182{
183#ifdef CONFIG_X86_BIGSMP
184 /*
185 * This routine is used to switch to bigsmp mode when
186 * - There is no apic= option specified by the user
187 * - generic_apic_probe() has chosen apic_default as the sub_arch
188 * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
189 */
190
191 if (!cmdline_apic && apic == &apic_default) {
192 if (apic_bigsmp.probe()) {
193 apic = &apic_bigsmp;
194 if (x86_quirks->update_genapic)
195 x86_quirks->update_genapic();
196 printk(KERN_INFO "Overriding APIC driver with %s\n",
197 apic->name);
198 }
199 }
200#endif
201}
202
203void __init generic_apic_probe(void)
204{
205 if (!cmdline_apic) {
206 int i;
207 for (i = 0; apic_probe[i]; i++) {
208 if (apic_probe[i]->probe()) {
209 apic = apic_probe[i];
210 break;
211 }
212 }
213 /* Not visible without early console */
214 if (!apic_probe[i])
215 panic("Didn't find an APIC driver");
216
217 if (x86_quirks->update_genapic)
218 x86_quirks->update_genapic();
219 }
220 printk(KERN_INFO "Using APIC driver %s\n", apic->name);
221}
222
223/* These functions can switch the APIC even after the initial ->probe() */
224
225int __init
226generic_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
227{
228 int i;
229
230 for (i = 0; apic_probe[i]; ++i) {
231 if (!apic_probe[i]->mps_oem_check)
232 continue;
233 if (!apic_probe[i]->mps_oem_check(mpc, oem, productid))
234 continue;
235
236 if (!cmdline_apic) {
237 apic = apic_probe[i];
238 if (x86_quirks->update_genapic)
239 x86_quirks->update_genapic();
240 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
241 apic->name);
242 }
243 return 1;
244 }
245 return 0;
246}
247
248int __init default_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
249{
250 int i;
251
252 for (i = 0; apic_probe[i]; ++i) {
253 if (!apic_probe[i]->acpi_madt_oem_check)
254 continue;
255 if (!apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id))
256 continue;
257
258 if (!cmdline_apic) {
259 apic = apic_probe[i];
260 if (x86_quirks->update_genapic)
261 x86_quirks->update_genapic();
262 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
263 apic->name);
264 }
265 return 1;
266 }
267 return 0;
268}
269
270#endif /* CONFIG_X86_LOCAL_APIC */
271
272/**
273 * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
274 *
275 * Description:
276 * Perform any necessary interrupt initialisation prior to setting up
277 * the "ordinary" interrupt call gates. For legacy reasons, the ISA
278 * interrupts should be initialised here if the machine emulates a PC
279 * in any way.
280 **/
281void __init pre_intr_init_hook(void)
282{
283 if (x86_quirks->arch_pre_intr_init) {
284 if (x86_quirks->arch_pre_intr_init())
285 return;
286 }
287 init_ISA_irqs();
288}
289
290/**
291 * intr_init_hook - post gate setup interrupt initialisation
292 *
293 * Description:
294 * Fill in any interrupts that may have been left out by the general
295 * init_IRQ() routine. interrupts having to do with the machine rather
296 * than the devices on the I/O bus (like APIC interrupts in intel MP
297 * systems) are started here.
298 **/
299void __init intr_init_hook(void)
300{
301 if (x86_quirks->arch_intr_init) {
302 if (x86_quirks->arch_intr_init())
303 return;
304 }
305}
306
307/**
308 * pre_setup_arch_hook - hook called prior to any setup_arch() execution
309 *
310 * Description:
311 * generally used to activate any machine specific identification
312 * routines that may be needed before setup_arch() runs. On Voyager
313 * this is used to get the board revision and type.
314 **/
315void __init pre_setup_arch_hook(void)
316{
317}
318
319/**
320 * trap_init_hook - initialise system specific traps
321 *
322 * Description:
323 * Called as the final act of trap_init(). Used in VISWS to initialise
324 * the various board specific APIC traps.
325 **/
326void __init trap_init_hook(void)
327{
328 if (x86_quirks->arch_trap_init) {
329 if (x86_quirks->arch_trap_init())
330 return;
331 }
332}
333
334static struct irqaction irq0 = {
335 .handler = timer_interrupt,
336 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL,
337 .mask = CPU_MASK_NONE,
338 .name = "timer"
339};
340
341/**
342 * pre_time_init_hook - do any specific initialisations before.
343 *
344 **/
345void __init pre_time_init_hook(void)
346{
347 if (x86_quirks->arch_pre_time_init)
348 x86_quirks->arch_pre_time_init();
349}
350
351/**
352 * time_init_hook - do any specific initialisations for the system timer.
353 *
354 * Description:
355 * Must plug the system timer interrupt source at HZ into the IRQ listed
356 * in irq_vectors.h:TIMER_IRQ
357 **/
358void __init time_init_hook(void)
359{
360 if (x86_quirks->arch_time_init) {
361 /*
362 * A nonzero return code does not mean failure, it means
363 * that the architecture quirk does not want any
364 * generic (timer) setup to be performed after this:
365 */
366 if (x86_quirks->arch_time_init())
367 return;
368 }
369
370 irq0.mask = cpumask_of_cpu(0);
371 setup_irq(0, &irq0);
372}
373
374#ifdef CONFIG_MCA
375/**
376 * mca_nmi_hook - hook into MCA specific NMI chain
377 *
378 * Description:
379 * The MCA (Microchannel Architecture) has an NMI chain for NMI sources
380 * along the MCA bus. Use this to hook into that chain if you will need
381 * it.
382 **/
383void mca_nmi_hook(void)
384{
385 /*
386 * If I recall correctly, there's a whole bunch of other things that
387 * we can do to check for NMI problems, but that's all I know about
388 * at the moment.
389 */
390 pr_warning("NMI generated from unknown source!\n");
391}
392#endif
393
394static __init int no_ipi_broadcast(char *str)
395{
396 get_option(&str, &no_broadcast);
397 pr_info("Using %s mode\n",
398 no_broadcast ? "No IPI Broadcast" : "IPI Broadcast");
399 return 1;
400}
401__setup("no_ipi_broadcast=", no_ipi_broadcast);
402
403static int __init print_ipi_mode(void)
404{
405 pr_info("Using IPI %s mode\n",
406 no_broadcast ? "No-Shortcut" : "Shortcut");
407 return 0;
408}
409
410late_initcall(print_ipi_mode);
411
diff --git a/arch/x86/kernel/probe_roms_32.c b/arch/x86/kernel/probe_roms_32.c
index 675a48c404a..071e7fea42e 100644
--- a/arch/x86/kernel/probe_roms_32.c
+++ b/arch/x86/kernel/probe_roms_32.c
@@ -18,7 +18,7 @@
18#include <asm/setup.h> 18#include <asm/setup.h>
19#include <asm/sections.h> 19#include <asm/sections.h>
20#include <asm/io.h> 20#include <asm/io.h>
21#include <setup_arch.h> 21#include <asm/setup_arch.h>
22 22
23static struct resource system_rom_resource = { 23static struct resource system_rom_resource = {
24 .name = "System ROM", 24 .name = "System ROM",
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 6d12f7e37f8..87b69d4fac1 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -350,7 +350,7 @@ static void c1e_idle(void)
350 350
351void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c) 351void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
352{ 352{
353#ifdef CONFIG_X86_SMP 353#ifdef CONFIG_SMP
354 if (pm_idle == poll_idle && smp_num_siblings > 1) { 354 if (pm_idle == poll_idle && smp_num_siblings > 1) {
355 printk(KERN_WARNING "WARNING: polling idle and HT enabled," 355 printk(KERN_WARNING "WARNING: polling idle and HT enabled,"
356 " performance may degrade.\n"); 356 " performance may degrade.\n");
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index f8536fee5c1..32e8f0af292 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -24,7 +24,7 @@
24# include <asm/iommu.h> 24# include <asm/iommu.h>
25#endif 25#endif
26 26
27#include <mach_ipi.h> 27#include <asm/genapic.h>
28 28
29/* 29/*
30 * Power off function, if any 30 * Power off function, if any
@@ -651,7 +651,7 @@ static int crash_nmi_callback(struct notifier_block *self,
651 651
652static void smp_send_nmi_allbutself(void) 652static void smp_send_nmi_allbutself(void)
653{ 653{
654 send_IPI_allbutself(NMI_VECTOR); 654 apic->send_IPI_allbutself(NMI_VECTOR);
655} 655}
656 656
657static struct notifier_block crash_nmi_nb = { 657static struct notifier_block crash_nmi_nb = {
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index d5d6693b706..8fce6c71451 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -81,7 +81,7 @@
81#include <asm/io_apic.h> 81#include <asm/io_apic.h>
82#include <asm/ist.h> 82#include <asm/ist.h>
83#include <asm/vmi.h> 83#include <asm/vmi.h>
84#include <setup_arch.h> 84#include <asm/setup_arch.h>
85#include <asm/bios_ebda.h> 85#include <asm/bios_ebda.h>
86#include <asm/cacheflush.h> 86#include <asm/cacheflush.h>
87#include <asm/processor.h> 87#include <asm/processor.h>
@@ -97,7 +97,7 @@
97#include <asm/mmu_context.h> 97#include <asm/mmu_context.h>
98#include <asm/proto.h> 98#include <asm/proto.h>
99 99
100#include <mach_apic.h> 100#include <asm/genapic.h>
101#include <asm/paravirt.h> 101#include <asm/paravirt.h>
102#include <asm/hypervisor.h> 102#include <asm/hypervisor.h>
103 103
@@ -112,6 +112,20 @@
112#define ARCH_SETUP 112#define ARCH_SETUP
113#endif 113#endif
114 114
115unsigned int boot_cpu_id __read_mostly;
116
117#ifdef CONFIG_X86_64
118int default_cpu_present_to_apicid(int mps_cpu)
119{
120 return __default_cpu_present_to_apicid(mps_cpu);
121}
122
123int default_check_phys_apicid_present(int boot_cpu_physical_apicid)
124{
125 return __default_check_phys_apicid_present(boot_cpu_physical_apicid);
126}
127#endif
128
115#ifndef CONFIG_DEBUG_BOOT_PARAMS 129#ifndef CONFIG_DEBUG_BOOT_PARAMS
116struct boot_params __initdata boot_params; 130struct boot_params __initdata boot_params;
117#else 131#else
@@ -588,10 +602,9 @@ early_param("elfcorehdr", setup_elfcorehdr);
588 602
589static int __init default_update_genapic(void) 603static int __init default_update_genapic(void)
590{ 604{
591#ifdef CONFIG_X86_SMP 605#ifdef CONFIG_SMP
592# if defined(CONFIG_X86_GENERICARCH) || defined(CONFIG_X86_64) 606 if (!apic->wakeup_cpu)
593 genapic->wakeup_cpu = wakeup_secondary_cpu_via_init; 607 apic->wakeup_cpu = wakeup_secondary_cpu_via_init;
594# endif
595#endif 608#endif
596 609
597 return 0; 610 return 0;
@@ -892,12 +905,11 @@ void __init setup_arch(char **cmdline_p)
892 */ 905 */
893 acpi_reserve_bootmem(); 906 acpi_reserve_bootmem();
894#endif 907#endif
895#ifdef CONFIG_X86_FIND_SMP_CONFIG
896 /* 908 /*
897 * Find and reserve possible boot-time SMP configuration: 909 * Find and reserve possible boot-time SMP configuration:
898 */ 910 */
899 find_smp_config(); 911 find_smp_config();
900#endif 912
901 reserve_crashkernel(); 913 reserve_crashkernel();
902 914
903#ifdef CONFIG_X86_64 915#ifdef CONFIG_X86_64
@@ -924,9 +936,7 @@ void __init setup_arch(char **cmdline_p)
924 map_vsyscall(); 936 map_vsyscall();
925#endif 937#endif
926 938
927#ifdef CONFIG_X86_GENERICARCH
928 generic_apic_probe(); 939 generic_apic_probe();
929#endif
930 940
931 early_quirks(); 941 early_quirks();
932 942
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
index e6faa3316bd..eaaffae31cc 100644
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -2,7 +2,7 @@
2 * Intel SMP support routines. 2 * Intel SMP support routines.
3 * 3 *
4 * (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk> 4 * (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk>
5 * (c) 1998-99, 2000 Ingo Molnar <mingo@redhat.com> 5 * (c) 1998-99, 2000, 2009 Ingo Molnar <mingo@redhat.com>
6 * (c) 2002,2003 Andi Kleen, SuSE Labs. 6 * (c) 2002,2003 Andi Kleen, SuSE Labs.
7 * 7 *
8 * i386 and x86_64 integration by Glauber Costa <gcosta@redhat.com> 8 * i386 and x86_64 integration by Glauber Costa <gcosta@redhat.com>
@@ -26,8 +26,7 @@
26#include <asm/tlbflush.h> 26#include <asm/tlbflush.h>
27#include <asm/mmu_context.h> 27#include <asm/mmu_context.h>
28#include <asm/proto.h> 28#include <asm/proto.h>
29#include <mach_ipi.h> 29#include <asm/genapic.h>
30#include <mach_apic.h>
31/* 30/*
32 * Some notes on x86 processor bugs affecting SMP operation: 31 * Some notes on x86 processor bugs affecting SMP operation:
33 * 32 *
@@ -118,12 +117,12 @@ static void native_smp_send_reschedule(int cpu)
118 WARN_ON(1); 117 WARN_ON(1);
119 return; 118 return;
120 } 119 }
121 send_IPI_mask(cpumask_of(cpu), RESCHEDULE_VECTOR); 120 apic->send_IPI_mask(cpumask_of(cpu), RESCHEDULE_VECTOR);
122} 121}
123 122
124void native_send_call_func_single_ipi(int cpu) 123void native_send_call_func_single_ipi(int cpu)
125{ 124{
126 send_IPI_mask(cpumask_of(cpu), CALL_FUNCTION_SINGLE_VECTOR); 125 apic->send_IPI_mask(cpumask_of(cpu), CALL_FUNCTION_SINGLE_VECTOR);
127} 126}
128 127
129void native_send_call_func_ipi(const struct cpumask *mask) 128void native_send_call_func_ipi(const struct cpumask *mask)
@@ -131,7 +130,7 @@ void native_send_call_func_ipi(const struct cpumask *mask)
131 cpumask_var_t allbutself; 130 cpumask_var_t allbutself;
132 131
133 if (!alloc_cpumask_var(&allbutself, GFP_ATOMIC)) { 132 if (!alloc_cpumask_var(&allbutself, GFP_ATOMIC)) {
134 send_IPI_mask(mask, CALL_FUNCTION_VECTOR); 133 apic->send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
135 return; 134 return;
136 } 135 }
137 136
@@ -140,9 +139,9 @@ void native_send_call_func_ipi(const struct cpumask *mask)
140 139
141 if (cpumask_equal(mask, allbutself) && 140 if (cpumask_equal(mask, allbutself) &&
142 cpumask_equal(cpu_online_mask, cpu_callout_mask)) 141 cpumask_equal(cpu_online_mask, cpu_callout_mask))
143 send_IPI_allbutself(CALL_FUNCTION_VECTOR); 142 apic->send_IPI_allbutself(CALL_FUNCTION_VECTOR);
144 else 143 else
145 send_IPI_mask(mask, CALL_FUNCTION_VECTOR); 144 apic->send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
146 145
147 free_cpumask_var(allbutself); 146 free_cpumask_var(allbutself);
148} 147}
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 612d3c74f6a..af57f88186e 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -2,7 +2,7 @@
2 * x86 SMP booting functions 2 * x86 SMP booting functions
3 * 3 *
4 * (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk> 4 * (c) 1995 Alan Cox, Building #3 <alan@lxorguk.ukuu.org.uk>
5 * (c) 1998, 1999, 2000 Ingo Molnar <mingo@redhat.com> 5 * (c) 1998, 1999, 2000, 2009 Ingo Molnar <mingo@redhat.com>
6 * Copyright 2001 Andi Kleen, SuSE Labs. 6 * Copyright 2001 Andi Kleen, SuSE Labs.
7 * 7 *
8 * Much of the core SMP work is based on previous work by Thomas Radke, to 8 * Much of the core SMP work is based on previous work by Thomas Radke, to
@@ -65,9 +65,8 @@
65#include <asm/uv/uv.h> 65#include <asm/uv/uv.h>
66#include <linux/mc146818rtc.h> 66#include <linux/mc146818rtc.h>
67 67
68#include <mach_apic.h> 68#include <asm/genapic.h>
69#include <mach_wakecpu.h> 69#include <asm/smpboot_hooks.h>
70#include <smpboot_hooks.h>
71 70
72#ifdef CONFIG_X86_32 71#ifdef CONFIG_X86_32
73u8 apicid_2_node[MAX_APICID]; 72u8 apicid_2_node[MAX_APICID];
@@ -163,7 +162,7 @@ static void map_cpu_to_logical_apicid(void)
163{ 162{
164 int cpu = smp_processor_id(); 163 int cpu = smp_processor_id();
165 int apicid = logical_smp_processor_id(); 164 int apicid = logical_smp_processor_id();
166 int node = apicid_to_node(apicid); 165 int node = apic->apicid_to_node(apicid);
167 166
168 if (!node_online(node)) 167 if (!node_online(node))
169 node = first_online_node; 168 node = first_online_node;
@@ -196,7 +195,8 @@ static void __cpuinit smp_callin(void)
196 * our local APIC. We have to wait for the IPI or we'll 195 * our local APIC. We have to wait for the IPI or we'll
197 * lock up on an APIC access. 196 * lock up on an APIC access.
198 */ 197 */
199 wait_for_init_deassert(&init_deasserted); 198 if (apic->wait_for_init_deassert)
199 apic->wait_for_init_deassert(&init_deasserted);
200 200
201 /* 201 /*
202 * (This works even if the APIC is not enabled.) 202 * (This works even if the APIC is not enabled.)
@@ -243,7 +243,8 @@ static void __cpuinit smp_callin(void)
243 */ 243 */
244 244
245 pr_debug("CALLIN, before setup_local_APIC().\n"); 245 pr_debug("CALLIN, before setup_local_APIC().\n");
246 smp_callin_clear_local_apic(); 246 if (apic->smp_callin_clear_local_apic)
247 apic->smp_callin_clear_local_apic();
247 setup_local_APIC(); 248 setup_local_APIC();
248 end_local_APIC_setup(); 249 end_local_APIC_setup();
249 map_cpu_to_logical_apicid(); 250 map_cpu_to_logical_apicid();
@@ -583,7 +584,7 @@ wakeup_secondary_cpu_via_nmi(int logical_apicid, unsigned long start_eip)
583 /* Target chip */ 584 /* Target chip */
584 /* Boot on the stack */ 585 /* Boot on the stack */
585 /* Kick the second */ 586 /* Kick the second */
586 apic_icr_write(APIC_DM_NMI | APIC_DEST_LOGICAL, logical_apicid); 587 apic_icr_write(APIC_DM_NMI | apic->dest_logical, logical_apicid);
587 588
588 pr_debug("Waiting for send to finish...\n"); 589 pr_debug("Waiting for send to finish...\n");
589 send_status = safe_apic_wait_icr_idle(); 590 send_status = safe_apic_wait_icr_idle();
@@ -749,7 +750,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu)
749/* 750/*
750 * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad 751 * NOTE - on most systems this is a PHYSICAL apic ID, but on multiquad
751 * (ie clustered apic addressing mode), this is a LOGICAL apic ID. 752 * (ie clustered apic addressing mode), this is a LOGICAL apic ID.
752 * Returns zero if CPU booted OK, else error code from wakeup_secondary_cpu. 753 * Returns zero if CPU booted OK, else error code from ->wakeup_cpu.
753 */ 754 */
754{ 755{
755 unsigned long boot_error = 0; 756 unsigned long boot_error = 0;
@@ -824,7 +825,8 @@ do_rest:
824 825
825 pr_debug("Setting warm reset code and vector.\n"); 826 pr_debug("Setting warm reset code and vector.\n");
826 827
827 store_NMI_vector(&nmi_high, &nmi_low); 828 if (apic->store_NMI_vector)
829 apic->store_NMI_vector(&nmi_high, &nmi_low);
828 830
829 smpboot_setup_warm_reset_vector(start_ip); 831 smpboot_setup_warm_reset_vector(start_ip);
830 /* 832 /*
@@ -839,7 +841,7 @@ do_rest:
839 /* 841 /*
840 * Starting actual IPI sequence... 842 * Starting actual IPI sequence...
841 */ 843 */
842 boot_error = wakeup_secondary_cpu(apicid, start_ip); 844 boot_error = apic->wakeup_cpu(apicid, start_ip);
843 845
844 if (!boot_error) { 846 if (!boot_error) {
845 /* 847 /*
@@ -873,8 +875,8 @@ do_rest:
873 else 875 else
874 /* trampoline code not run */ 876 /* trampoline code not run */
875 printk(KERN_ERR "Not responding.\n"); 877 printk(KERN_ERR "Not responding.\n");
876 if (get_uv_system_type() != UV_NON_UNIQUE_APIC) 878 if (apic->inquire_remote_apic)
877 inquire_remote_apic(apicid); 879 apic->inquire_remote_apic(apicid);
878 } 880 }
879 } 881 }
880 882
@@ -905,7 +907,7 @@ do_rest:
905 907
906int __cpuinit native_cpu_up(unsigned int cpu) 908int __cpuinit native_cpu_up(unsigned int cpu)
907{ 909{
908 int apicid = cpu_present_to_apicid(cpu); 910 int apicid = apic->cpu_present_to_apicid(cpu);
909 unsigned long flags; 911 unsigned long flags;
910 int err; 912 int err;
911 913
@@ -998,14 +1000,14 @@ static int __init smp_sanity_check(unsigned max_cpus)
998{ 1000{
999 preempt_disable(); 1001 preempt_disable();
1000 1002
1001#if defined(CONFIG_X86_PC) && defined(CONFIG_X86_32) 1003#if !defined(CONFIG_X86_BIGSMP) && defined(CONFIG_X86_32)
1002 if (def_to_bigsmp && nr_cpu_ids > 8) { 1004 if (def_to_bigsmp && nr_cpu_ids > 8) {
1003 unsigned int cpu; 1005 unsigned int cpu;
1004 unsigned nr; 1006 unsigned nr;
1005 1007
1006 printk(KERN_WARNING 1008 printk(KERN_WARNING
1007 "More than 8 CPUs detected - skipping them.\n" 1009 "More than 8 CPUs detected - skipping them.\n"
1008 "Use CONFIG_X86_GENERICARCH and CONFIG_X86_BIGSMP.\n"); 1010 "Use CONFIG_X86_BIGSMP.\n");
1009 1011
1010 nr = 0; 1012 nr = 0;
1011 for_each_present_cpu(cpu) { 1013 for_each_present_cpu(cpu) {
@@ -1051,7 +1053,7 @@ static int __init smp_sanity_check(unsigned max_cpus)
1051 * Should not be necessary because the MP table should list the boot 1053 * Should not be necessary because the MP table should list the boot
1052 * CPU too, but we do it for the sake of robustness anyway. 1054 * CPU too, but we do it for the sake of robustness anyway.
1053 */ 1055 */
1054 if (!check_phys_apicid_present(boot_cpu_physical_apicid)) { 1056 if (!apic->check_phys_apicid_present(boot_cpu_physical_apicid)) {
1055 printk(KERN_NOTICE 1057 printk(KERN_NOTICE
1056 "weird, boot CPU (#%d) not listed by the BIOS.\n", 1058 "weird, boot CPU (#%d) not listed by the BIOS.\n",
1057 boot_cpu_physical_apicid); 1059 boot_cpu_physical_apicid);
@@ -1069,7 +1071,7 @@ static int __init smp_sanity_check(unsigned max_cpus)
1069 printk(KERN_ERR "... forcing use of dummy APIC emulation." 1071 printk(KERN_ERR "... forcing use of dummy APIC emulation."
1070 "(tell your hw vendor)\n"); 1072 "(tell your hw vendor)\n");
1071 smpboot_clear_io_apic(); 1073 smpboot_clear_io_apic();
1072 disable_ioapic_setup(); 1074 arch_disable_smp_support();
1073 return -1; 1075 return -1;
1074 } 1076 }
1075 1077
@@ -1128,7 +1130,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1128 1130
1129#ifdef CONFIG_X86_64 1131#ifdef CONFIG_X86_64
1130 enable_IR_x2apic(); 1132 enable_IR_x2apic();
1131 setup_apic_routing(); 1133 default_setup_apic_routing();
1132#endif 1134#endif
1133 1135
1134 if (smp_sanity_check(max_cpus) < 0) { 1136 if (smp_sanity_check(max_cpus) < 0) {
@@ -1163,7 +1165,8 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
1163 1165
1164 map_cpu_to_logical_apicid(); 1166 map_cpu_to_logical_apicid();
1165 1167
1166 setup_portio_remap(); 1168 if (apic->setup_portio_remap)
1169 apic->setup_portio_remap();
1167 1170
1168 smpboot_setup_io_apic(); 1171 smpboot_setup_io_apic();
1169 /* 1172 /*
diff --git a/arch/x86/kernel/stacktrace.c b/arch/x86/kernel/stacktrace.c
index 10786af9554..f7bddc2e37d 100644
--- a/arch/x86/kernel/stacktrace.c
+++ b/arch/x86/kernel/stacktrace.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Stack trace management functions 2 * Stack trace management functions
3 * 3 *
4 * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com> 4 * Copyright (C) 2006-2009 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
5 */ 5 */
6#include <linux/sched.h> 6#include <linux/sched.h>
7#include <linux/stacktrace.h> 7#include <linux/stacktrace.h>
diff --git a/arch/x86/kernel/summit_32.c b/arch/x86/kernel/summit_32.c
index 7b987852e87..1e733eff9b3 100644
--- a/arch/x86/kernel/summit_32.c
+++ b/arch/x86/kernel/summit_32.c
@@ -30,8 +30,364 @@
30#include <linux/init.h> 30#include <linux/init.h>
31#include <asm/io.h> 31#include <asm/io.h>
32#include <asm/bios_ebda.h> 32#include <asm/bios_ebda.h>
33#include <asm/summit/mpparse.h>
34 33
34/*
35 * APIC driver for the IBM "Summit" chipset.
36 */
37#define APIC_DEFINITION 1
38#include <linux/threads.h>
39#include <linux/cpumask.h>
40#include <asm/mpspec.h>
41#include <asm/apic.h>
42#include <asm/smp.h>
43#include <asm/genapic.h>
44#include <asm/fixmap.h>
45#include <asm/apicdef.h>
46#include <asm/ipi.h>
47#include <linux/kernel.h>
48#include <linux/string.h>
49#include <linux/init.h>
50#include <linux/gfp.h>
51#include <linux/smp.h>
52
53static inline unsigned summit_get_apic_id(unsigned long x)
54{
55 return (x >> 24) & 0xFF;
56}
57
58static inline void summit_send_IPI_mask(const cpumask_t *mask, int vector)
59{
60 default_send_IPI_mask_sequence_logical(mask, vector);
61}
62
63static inline void summit_send_IPI_allbutself(int vector)
64{
65 cpumask_t mask = cpu_online_map;
66 cpu_clear(smp_processor_id(), mask);
67
68 if (!cpus_empty(mask))
69 summit_send_IPI_mask(&mask, vector);
70}
71
72static inline void summit_send_IPI_all(int vector)
73{
74 summit_send_IPI_mask(&cpu_online_map, vector);
75}
76
77#include <asm/tsc.h>
78
79extern int use_cyclone;
80
81#ifdef CONFIG_X86_SUMMIT_NUMA
82extern void setup_summit(void);
83#else
84#define setup_summit() {}
85#endif
86
87static inline int
88summit_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
89{
90 if (!strncmp(oem, "IBM ENSW", 8) &&
91 (!strncmp(productid, "VIGIL SMP", 9)
92 || !strncmp(productid, "EXA", 3)
93 || !strncmp(productid, "RUTHLESS SMP", 12))){
94 mark_tsc_unstable("Summit based system");
95 use_cyclone = 1; /*enable cyclone-timer*/
96 setup_summit();
97 return 1;
98 }
99 return 0;
100}
101
102/* Hook from generic ACPI tables.c */
103static inline int summit_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
104{
105 if (!strncmp(oem_id, "IBM", 3) &&
106 (!strncmp(oem_table_id, "SERVIGIL", 8)
107 || !strncmp(oem_table_id, "EXA", 3))){
108 mark_tsc_unstable("Summit based system");
109 use_cyclone = 1; /*enable cyclone-timer*/
110 setup_summit();
111 return 1;
112 }
113 return 0;
114}
115
116struct rio_table_hdr {
117 unsigned char version; /* Version number of this data structure */
118 /* Version 3 adds chassis_num & WP_index */
119 unsigned char num_scal_dev; /* # of Scalability devices (Twisters for Vigil) */
120 unsigned char num_rio_dev; /* # of RIO I/O devices (Cyclones and Winnipegs) */
121} __attribute__((packed));
122
123struct scal_detail {
124 unsigned char node_id; /* Scalability Node ID */
125 unsigned long CBAR; /* Address of 1MB register space */
126 unsigned char port0node; /* Node ID port connected to: 0xFF=None */
127 unsigned char port0port; /* Port num port connected to: 0,1,2, or 0xFF=None */
128 unsigned char port1node; /* Node ID port connected to: 0xFF = None */
129 unsigned char port1port; /* Port num port connected to: 0,1,2, or 0xFF=None */
130 unsigned char port2node; /* Node ID port connected to: 0xFF = None */
131 unsigned char port2port; /* Port num port connected to: 0,1,2, or 0xFF=None */
132 unsigned char chassis_num; /* 1 based Chassis number (1 = boot node) */
133} __attribute__((packed));
134
135struct rio_detail {
136 unsigned char node_id; /* RIO Node ID */
137 unsigned long BBAR; /* Address of 1MB register space */
138 unsigned char type; /* Type of device */
139 unsigned char owner_id; /* For WPEG: Node ID of Cyclone that owns this WPEG*/
140 /* For CYC: Node ID of Twister that owns this CYC */
141 unsigned char port0node; /* Node ID port connected to: 0xFF=None */
142 unsigned char port0port; /* Port num port connected to: 0,1,2, or 0xFF=None */
143 unsigned char port1node; /* Node ID port connected to: 0xFF=None */
144 unsigned char port1port; /* Port num port connected to: 0,1,2, or 0xFF=None */
145 unsigned char first_slot; /* For WPEG: Lowest slot number below this WPEG */
146 /* For CYC: 0 */
147 unsigned char status; /* For WPEG: Bit 0 = 1 : the XAPIC is used */
148 /* = 0 : the XAPIC is not used, ie:*/
149 /* ints fwded to another XAPIC */
150 /* Bits1:7 Reserved */
151 /* For CYC: Bits0:7 Reserved */
152 unsigned char WP_index; /* For WPEG: WPEG instance index - lower ones have */
153 /* lower slot numbers/PCI bus numbers */
154 /* For CYC: No meaning */
155 unsigned char chassis_num; /* 1 based Chassis number */
156 /* For LookOut WPEGs this field indicates the */
157 /* Expansion Chassis #, enumerated from Boot */
158 /* Node WPEG external port, then Boot Node CYC */
159 /* external port, then Next Vigil chassis WPEG */
160 /* external port, etc. */
161 /* Shared Lookouts have only 1 chassis number (the */
162 /* first one assigned) */
163} __attribute__((packed));
164
165
166typedef enum {
167 CompatTwister = 0, /* Compatibility Twister */
168 AltTwister = 1, /* Alternate Twister of internal 8-way */
169 CompatCyclone = 2, /* Compatibility Cyclone */
170 AltCyclone = 3, /* Alternate Cyclone of internal 8-way */
171 CompatWPEG = 4, /* Compatibility WPEG */
172 AltWPEG = 5, /* Second Planar WPEG */
173 LookOutAWPEG = 6, /* LookOut WPEG */
174 LookOutBWPEG = 7, /* LookOut WPEG */
175} node_type;
176
177static inline int is_WPEG(struct rio_detail *rio){
178 return (rio->type == CompatWPEG || rio->type == AltWPEG ||
179 rio->type == LookOutAWPEG || rio->type == LookOutBWPEG);
180}
181
182
183/* In clustered mode, the high nibble of APIC ID is a cluster number.
184 * The low nibble is a 4-bit bitmap. */
185#define XAPIC_DEST_CPUS_SHIFT 4
186#define XAPIC_DEST_CPUS_MASK ((1u << XAPIC_DEST_CPUS_SHIFT) - 1)
187#define XAPIC_DEST_CLUSTER_MASK (XAPIC_DEST_CPUS_MASK << XAPIC_DEST_CPUS_SHIFT)
188
189#define SUMMIT_APIC_DFR_VALUE (APIC_DFR_CLUSTER)
190
191static inline const cpumask_t *summit_target_cpus(void)
192{
193 /* CPU_MASK_ALL (0xff) has undefined behaviour with
194 * dest_LowestPrio mode logical clustered apic interrupt routing
195 * Just start on cpu 0. IRQ balancing will spread load
196 */
197 return &cpumask_of_cpu(0);
198}
199
200static inline unsigned long
201summit_check_apicid_used(physid_mask_t bitmap, int apicid)
202{
203 return 0;
204}
205
206/* we don't use the phys_cpu_present_map to indicate apicid presence */
207static inline unsigned long summit_check_apicid_present(int bit)
208{
209 return 1;
210}
211
212#define apicid_cluster(apicid) ((apicid) & XAPIC_DEST_CLUSTER_MASK)
213
214extern u8 cpu_2_logical_apicid[];
215
216static inline void summit_init_apic_ldr(void)
217{
218 unsigned long val, id;
219 int count = 0;
220 u8 my_id = (u8)hard_smp_processor_id();
221 u8 my_cluster = (u8)apicid_cluster(my_id);
222#ifdef CONFIG_SMP
223 u8 lid;
224 int i;
225
226 /* Create logical APIC IDs by counting CPUs already in cluster. */
227 for (count = 0, i = nr_cpu_ids; --i >= 0; ) {
228 lid = cpu_2_logical_apicid[i];
229 if (lid != BAD_APICID && apicid_cluster(lid) == my_cluster)
230 ++count;
231 }
232#endif
233 /* We only have a 4 wide bitmap in cluster mode. If a deranged
234 * BIOS puts 5 CPUs in one APIC cluster, we're hosed. */
235 BUG_ON(count >= XAPIC_DEST_CPUS_SHIFT);
236 id = my_cluster | (1UL << count);
237 apic_write(APIC_DFR, SUMMIT_APIC_DFR_VALUE);
238 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
239 val |= SET_APIC_LOGICAL_ID(id);
240 apic_write(APIC_LDR, val);
241}
242
243static inline int summit_apic_id_registered(void)
244{
245 return 1;
246}
247
248static inline void summit_setup_apic_routing(void)
249{
250 printk("Enabling APIC mode: Summit. Using %d I/O APICs\n",
251 nr_ioapics);
252}
253
254static inline int summit_apicid_to_node(int logical_apicid)
255{
256#ifdef CONFIG_SMP
257 return apicid_2_node[hard_smp_processor_id()];
258#else
259 return 0;
260#endif
261}
262
263/* Mapping from cpu number to logical apicid */
264static inline int summit_cpu_to_logical_apicid(int cpu)
265{
266#ifdef CONFIG_SMP
267 if (cpu >= nr_cpu_ids)
268 return BAD_APICID;
269 return (int)cpu_2_logical_apicid[cpu];
270#else
271 return logical_smp_processor_id();
272#endif
273}
274
275static inline int summit_cpu_present_to_apicid(int mps_cpu)
276{
277 if (mps_cpu < nr_cpu_ids)
278 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
279 else
280 return BAD_APICID;
281}
282
283static inline physid_mask_t
284summit_ioapic_phys_id_map(physid_mask_t phys_id_map)
285{
286 /* For clustered we don't have a good way to do this yet - hack */
287 return physids_promote(0x0F);
288}
289
290static inline physid_mask_t summit_apicid_to_cpu_present(int apicid)
291{
292 return physid_mask_of_physid(0);
293}
294
295static inline void summit_setup_portio_remap(void)
296{
297}
298
299static inline int summit_check_phys_apicid_present(int boot_cpu_physical_apicid)
300{
301 return 1;
302}
303
304static inline unsigned int summit_cpu_mask_to_apicid(const cpumask_t *cpumask)
305{
306 int cpus_found = 0;
307 int num_bits_set;
308 int apicid;
309 int cpu;
310
311 num_bits_set = cpus_weight(*cpumask);
312 /* Return id to all */
313 if (num_bits_set >= nr_cpu_ids)
314 return 0xFF;
315 /*
316 * The cpus in the mask must all be on the apic cluster. If are not
317 * on the same apicid cluster return default value of target_cpus():
318 */
319 cpu = first_cpu(*cpumask);
320 apicid = summit_cpu_to_logical_apicid(cpu);
321
322 while (cpus_found < num_bits_set) {
323 if (cpu_isset(cpu, *cpumask)) {
324 int new_apicid = summit_cpu_to_logical_apicid(cpu);
325
326 if (apicid_cluster(apicid) !=
327 apicid_cluster(new_apicid)) {
328 printk ("%s: Not a valid mask!\n", __func__);
329
330 return 0xFF;
331 }
332 apicid = apicid | new_apicid;
333 cpus_found++;
334 }
335 cpu++;
336 }
337 return apicid;
338}
339
340static inline unsigned int
341summit_cpu_mask_to_apicid_and(const struct cpumask *inmask,
342 const struct cpumask *andmask)
343{
344 int apicid = summit_cpu_to_logical_apicid(0);
345 cpumask_var_t cpumask;
346
347 if (!alloc_cpumask_var(&cpumask, GFP_ATOMIC))
348 return apicid;
349
350 cpumask_and(cpumask, inmask, andmask);
351 cpumask_and(cpumask, cpumask, cpu_online_mask);
352 apicid = summit_cpu_mask_to_apicid(cpumask);
353
354 free_cpumask_var(cpumask);
355
356 return apicid;
357}
358
359/*
360 * cpuid returns the value latched in the HW at reset, not the APIC ID
361 * register's value. For any box whose BIOS changes APIC IDs, like
362 * clustered APIC systems, we must use hard_smp_processor_id.
363 *
364 * See Intel's IA-32 SW Dev's Manual Vol2 under CPUID.
365 */
366static inline int summit_phys_pkg_id(int cpuid_apic, int index_msb)
367{
368 return hard_smp_processor_id() >> index_msb;
369}
370
371static int probe_summit(void)
372{
373 /* probed later in mptable/ACPI hooks */
374 return 0;
375}
376
377static void summit_vector_allocation_domain(int cpu, cpumask_t *retmask)
378{
379 /* Careful. Some cpus do not strictly honor the set of cpus
380 * specified in the interrupt destination when using lowest
381 * priority interrupt delivery mode.
382 *
383 * In particular there was a hyperthreading cpu observed to
384 * deliver interrupts to the wrong hyperthread when only one
385 * hyperthread was specified in the interrupt desitination.
386 */
387 *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
388}
389
390#ifdef CONFIG_X86_SUMMIT_NUMA
35static struct rio_table_hdr *rio_table_hdr __initdata; 391static struct rio_table_hdr *rio_table_hdr __initdata;
36static struct scal_detail *scal_devs[MAX_NUMNODES] __initdata; 392static struct scal_detail *scal_devs[MAX_NUMNODES] __initdata;
37static struct rio_detail *rio_devs[MAX_NUMNODES*4] __initdata; 393static struct rio_detail *rio_devs[MAX_NUMNODES*4] __initdata;
@@ -186,3 +542,61 @@ void __init setup_summit(void)
186 next_wpeg = 0; 542 next_wpeg = 0;
187 } while (next_wpeg != 0); 543 } while (next_wpeg != 0);
188} 544}
545#endif
546
547struct genapic apic_summit = {
548
549 .name = "summit",
550 .probe = probe_summit,
551 .acpi_madt_oem_check = summit_acpi_madt_oem_check,
552 .apic_id_registered = summit_apic_id_registered,
553
554 .irq_delivery_mode = dest_LowestPrio,
555 /* logical delivery broadcast to all CPUs: */
556 .irq_dest_mode = 1,
557
558 .target_cpus = summit_target_cpus,
559 .disable_esr = 1,
560 .dest_logical = APIC_DEST_LOGICAL,
561 .check_apicid_used = summit_check_apicid_used,
562 .check_apicid_present = summit_check_apicid_present,
563
564 .vector_allocation_domain = summit_vector_allocation_domain,
565 .init_apic_ldr = summit_init_apic_ldr,
566
567 .ioapic_phys_id_map = summit_ioapic_phys_id_map,
568 .setup_apic_routing = summit_setup_apic_routing,
569 .multi_timer_check = NULL,
570 .apicid_to_node = summit_apicid_to_node,
571 .cpu_to_logical_apicid = summit_cpu_to_logical_apicid,
572 .cpu_present_to_apicid = summit_cpu_present_to_apicid,
573 .apicid_to_cpu_present = summit_apicid_to_cpu_present,
574 .setup_portio_remap = NULL,
575 .check_phys_apicid_present = summit_check_phys_apicid_present,
576 .enable_apic_mode = NULL,
577 .phys_pkg_id = summit_phys_pkg_id,
578 .mps_oem_check = summit_mps_oem_check,
579
580 .get_apic_id = summit_get_apic_id,
581 .set_apic_id = NULL,
582 .apic_id_mask = 0xFF << 24,
583
584 .cpu_mask_to_apicid = summit_cpu_mask_to_apicid,
585 .cpu_mask_to_apicid_and = summit_cpu_mask_to_apicid_and,
586
587 .send_IPI_mask = summit_send_IPI_mask,
588 .send_IPI_mask_allbutself = NULL,
589 .send_IPI_allbutself = summit_send_IPI_allbutself,
590 .send_IPI_all = summit_send_IPI_all,
591 .send_IPI_self = default_send_IPI_self,
592
593 .wakeup_cpu = NULL,
594 .trampoline_phys_low = DEFAULT_TRAMPOLINE_PHYS_LOW,
595 .trampoline_phys_high = DEFAULT_TRAMPOLINE_PHYS_HIGH,
596
597 .wait_for_init_deassert = default_wait_for_init_deassert,
598
599 .smp_callin_clear_local_apic = NULL,
600 .store_NMI_vector = NULL,
601 .inquire_remote_apic = default_inquire_remote_apic,
602};
diff --git a/arch/x86/kernel/time_32.c b/arch/x86/kernel/time_32.c
index 3985cac0ed4..764c74e871f 100644
--- a/arch/x86/kernel/time_32.c
+++ b/arch/x86/kernel/time_32.c
@@ -38,7 +38,7 @@
38#include <asm/time.h> 38#include <asm/time.h>
39#include <asm/timer.h> 39#include <asm/timer.h>
40 40
41#include "do_timer.h" 41#include <asm/do_timer.h>
42 42
43int timer_ack; 43int timer_ack;
44 44
diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/kernel/tlb_uv.c
index f4b2f27d19b..f396e61bcb3 100644
--- a/arch/x86/kernel/tlb_uv.c
+++ b/arch/x86/kernel/tlb_uv.c
@@ -20,7 +20,7 @@
20#include <asm/tsc.h> 20#include <asm/tsc.h>
21#include <asm/irq_vectors.h> 21#include <asm/irq_vectors.h>
22 22
23#include <mach_apic.h> 23#include <asm/genapic.h>
24 24
25static struct bau_control **uv_bau_table_bases __read_mostly; 25static struct bau_control **uv_bau_table_bases __read_mostly;
26static int uv_bau_retry_limit __read_mostly; 26static int uv_bau_retry_limit __read_mostly;
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 71a8f871331..bde57f0f161 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -54,7 +54,7 @@
54#include <asm/desc.h> 54#include <asm/desc.h>
55#include <asm/i387.h> 55#include <asm/i387.h>
56 56
57#include <mach_traps.h> 57#include <asm/mach_traps.h>
58 58
59#ifdef CONFIG_X86_64 59#ifdef CONFIG_X86_64
60#include <asm/pgalloc.h> 60#include <asm/pgalloc.h>
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 599e5816863..83d53ce5d4c 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -773,7 +773,7 @@ __cpuinit int unsynchronized_tsc(void)
773 if (!cpu_has_tsc || tsc_unstable) 773 if (!cpu_has_tsc || tsc_unstable)
774 return 1; 774 return 1;
775 775
776#ifdef CONFIG_X86_SMP 776#ifdef CONFIG_SMP
777 if (apic_is_clustered_box()) 777 if (apic_is_clustered_box())
778 return 1; 778 return 1;
779#endif 779#endif
diff --git a/arch/x86/kernel/visws_quirks.c b/arch/x86/kernel/visws_quirks.c
index d801d06af06..4fd646e6dd4 100644
--- a/arch/x86/kernel/visws_quirks.c
+++ b/arch/x86/kernel/visws_quirks.c
@@ -32,9 +32,9 @@
32#include <asm/e820.h> 32#include <asm/e820.h>
33#include <asm/io.h> 33#include <asm/io.h>
34 34
35#include <mach_ipi.h> 35#include <asm/genapic.h>
36 36
37#include "mach_apic.h" 37#include <asm/genapic.h>
38 38
39#include <linux/kernel_stat.h> 39#include <linux/kernel_stat.h>
40 40
@@ -200,7 +200,7 @@ static void __init MP_processor_info(struct mpc_cpu *m)
200 return; 200 return;
201 } 201 }
202 202
203 apic_cpus = apicid_to_cpu_present(m->apicid); 203 apic_cpus = apic->apicid_to_cpu_present(m->apicid);
204 physids_or(phys_cpu_present_map, phys_cpu_present_map, apic_cpus); 204 physids_or(phys_cpu_present_map, phys_cpu_present_map, apic_cpus);
205 /* 205 /*
206 * Validate version 206 * Validate version
diff --git a/arch/x86/kernel/vmiclock_32.c b/arch/x86/kernel/vmiclock_32.c
index c4c1f9e0940..a4791ef412d 100644
--- a/arch/x86/kernel/vmiclock_32.c
+++ b/arch/x86/kernel/vmiclock_32.c
@@ -256,7 +256,7 @@ void __devinit vmi_time_bsp_init(void)
256 */ 256 */
257 clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL); 257 clockevents_notify(CLOCK_EVT_NOTIFY_SUSPEND, NULL);
258 local_irq_disable(); 258 local_irq_disable();
259#ifdef CONFIG_X86_SMP 259#ifdef CONFIG_SMP
260 /* 260 /*
261 * XXX handle_percpu_irq only defined for SMP; we need to switch over 261 * XXX handle_percpu_irq only defined for SMP; we need to switch over
262 * to using it, since this is a local interrupt, which each CPU must 262 * to using it, since this is a local interrupt, which each CPU must
diff --git a/arch/x86/mach-default/Makefile b/arch/x86/mach-default/Makefile
deleted file mode 100644
index 012fe34459e..00000000000
--- a/arch/x86/mach-default/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for the linux kernel.
3#
4
5obj-y := setup.o
diff --git a/arch/x86/mach-default/setup.c b/arch/x86/mach-default/setup.c
deleted file mode 100644
index a265a7c6319..00000000000
--- a/arch/x86/mach-default/setup.c
+++ /dev/null
@@ -1,174 +0,0 @@
1/*
2 * Machine specific setup for generic
3 */
4
5#include <linux/smp.h>
6#include <linux/init.h>
7#include <linux/interrupt.h>
8#include <asm/acpi.h>
9#include <asm/arch_hooks.h>
10#include <asm/e820.h>
11#include <asm/setup.h>
12
13#include <mach_ipi.h>
14
15#ifdef CONFIG_HOTPLUG_CPU
16#define DEFAULT_SEND_IPI (1)
17#else
18#define DEFAULT_SEND_IPI (0)
19#endif
20
21int no_broadcast = DEFAULT_SEND_IPI;
22
23/**
24 * pre_intr_init_hook - initialisation prior to setting up interrupt vectors
25 *
26 * Description:
27 * Perform any necessary interrupt initialisation prior to setting up
28 * the "ordinary" interrupt call gates. For legacy reasons, the ISA
29 * interrupts should be initialised here if the machine emulates a PC
30 * in any way.
31 **/
32void __init pre_intr_init_hook(void)
33{
34 if (x86_quirks->arch_pre_intr_init) {
35 if (x86_quirks->arch_pre_intr_init())
36 return;
37 }
38 init_ISA_irqs();
39}
40
41/*
42 * IRQ2 is cascade interrupt to second interrupt controller
43 */
44static struct irqaction irq2 = {
45 .handler = no_action,
46 .mask = CPU_MASK_NONE,
47 .name = "cascade",
48};
49
50/**
51 * intr_init_hook - post gate setup interrupt initialisation
52 *
53 * Description:
54 * Fill in any interrupts that may have been left out by the general
55 * init_IRQ() routine. interrupts having to do with the machine rather
56 * than the devices on the I/O bus (like APIC interrupts in intel MP
57 * systems) are started here.
58 **/
59void __init intr_init_hook(void)
60{
61 if (x86_quirks->arch_intr_init) {
62 if (x86_quirks->arch_intr_init())
63 return;
64 }
65 if (!acpi_ioapic)
66 setup_irq(2, &irq2);
67
68}
69
70/**
71 * pre_setup_arch_hook - hook called prior to any setup_arch() execution
72 *
73 * Description:
74 * generally used to activate any machine specific identification
75 * routines that may be needed before setup_arch() runs. On Voyager
76 * this is used to get the board revision and type.
77 **/
78void __init pre_setup_arch_hook(void)
79{
80}
81
82/**
83 * trap_init_hook - initialise system specific traps
84 *
85 * Description:
86 * Called as the final act of trap_init(). Used in VISWS to initialise
87 * the various board specific APIC traps.
88 **/
89void __init trap_init_hook(void)
90{
91 if (x86_quirks->arch_trap_init) {
92 if (x86_quirks->arch_trap_init())
93 return;
94 }
95}
96
97static struct irqaction irq0 = {
98 .handler = timer_interrupt,
99 .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL,
100 .mask = CPU_MASK_NONE,
101 .name = "timer"
102};
103
104/**
105 * pre_time_init_hook - do any specific initialisations before.
106 *
107 **/
108void __init pre_time_init_hook(void)
109{
110 if (x86_quirks->arch_pre_time_init)
111 x86_quirks->arch_pre_time_init();
112}
113
114/**
115 * time_init_hook - do any specific initialisations for the system timer.
116 *
117 * Description:
118 * Must plug the system timer interrupt source at HZ into the IRQ listed
119 * in irq_vectors.h:TIMER_IRQ
120 **/
121void __init time_init_hook(void)
122{
123 if (x86_quirks->arch_time_init) {
124 /*
125 * A nonzero return code does not mean failure, it means
126 * that the architecture quirk does not want any
127 * generic (timer) setup to be performed after this:
128 */
129 if (x86_quirks->arch_time_init())
130 return;
131 }
132
133 irq0.mask = cpumask_of_cpu(0);
134 setup_irq(0, &irq0);
135}
136
137#ifdef CONFIG_MCA
138/**
139 * mca_nmi_hook - hook into MCA specific NMI chain
140 *
141 * Description:
142 * The MCA (Microchannel Architecture) has an NMI chain for NMI sources
143 * along the MCA bus. Use this to hook into that chain if you will need
144 * it.
145 **/
146void mca_nmi_hook(void)
147{
148 /*
149 * If I recall correctly, there's a whole bunch of other things that
150 * we can do to check for NMI problems, but that's all I know about
151 * at the moment.
152 */
153 pr_warning("NMI generated from unknown source!\n");
154}
155#endif
156
157static __init int no_ipi_broadcast(char *str)
158{
159 get_option(&str, &no_broadcast);
160 pr_info("Using %s mode\n",
161 no_broadcast ? "No IPI Broadcast" : "IPI Broadcast");
162 return 1;
163}
164__setup("no_ipi_broadcast=", no_ipi_broadcast);
165
166static int __init print_ipi_mode(void)
167{
168 pr_info("Using IPI %s mode\n",
169 no_broadcast ? "No-Shortcut" : "Shortcut");
170 return 0;
171}
172
173late_initcall(print_ipi_mode);
174
diff --git a/arch/x86/mach-generic/Makefile b/arch/x86/mach-generic/Makefile
deleted file mode 100644
index 6730f4e7c74..00000000000
--- a/arch/x86/mach-generic/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
1#
2# Makefile for the generic architecture
3#
4
5EXTRA_CFLAGS := -Iarch/x86/kernel
6
7obj-y := probe.o default.o
8obj-$(CONFIG_X86_NUMAQ) += numaq.o
9obj-$(CONFIG_X86_SUMMIT) += summit.o
10obj-$(CONFIG_X86_BIGSMP) += bigsmp.o
11obj-$(CONFIG_X86_ES7000) += es7000.o
diff --git a/arch/x86/mach-generic/bigsmp.c b/arch/x86/mach-generic/bigsmp.c
deleted file mode 100644
index bc4c7840b2a..00000000000
--- a/arch/x86/mach-generic/bigsmp.c
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * APIC driver for "bigsmp" XAPIC machines with more than 8 virtual CPUs.
3 * Drives the local APIC in "clustered mode".
4 */
5#define APIC_DEFINITION 1
6#include <linux/threads.h>
7#include <linux/cpumask.h>
8#include <asm/mpspec.h>
9#include <asm/genapic.h>
10#include <asm/fixmap.h>
11#include <asm/apicdef.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/dmi.h>
15#include <asm/bigsmp/apicdef.h>
16#include <linux/smp.h>
17#include <asm/bigsmp/apic.h>
18#include <asm/bigsmp/ipi.h>
19#include <asm/mach-default/mach_mpparse.h>
20#include <asm/mach-default/mach_wakecpu.h>
21
22static int dmi_bigsmp; /* can be set by dmi scanners */
23
24static int hp_ht_bigsmp(const struct dmi_system_id *d)
25{
26 printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
27 dmi_bigsmp = 1;
28 return 0;
29}
30
31
32static const struct dmi_system_id bigsmp_dmi_table[] = {
33 { hp_ht_bigsmp, "HP ProLiant DL760 G2",
34 { DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
35 DMI_MATCH(DMI_BIOS_VERSION, "P44-"),}
36 },
37
38 { hp_ht_bigsmp, "HP ProLiant DL740",
39 { DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
40 DMI_MATCH(DMI_BIOS_VERSION, "P47-"),}
41 },
42 { }
43};
44
45static void vector_allocation_domain(int cpu, cpumask_t *retmask)
46{
47 cpus_clear(*retmask);
48 cpu_set(cpu, *retmask);
49}
50
51static int probe_bigsmp(void)
52{
53 if (def_to_bigsmp)
54 dmi_bigsmp = 1;
55 else
56 dmi_check_system(bigsmp_dmi_table);
57 return dmi_bigsmp;
58}
59
60struct genapic apic_bigsmp = APIC_INIT("bigsmp", probe_bigsmp);
diff --git a/arch/x86/mach-generic/default.c b/arch/x86/mach-generic/default.c
deleted file mode 100644
index e63a4a76d8c..00000000000
--- a/arch/x86/mach-generic/default.c
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * Default generic APIC driver. This handles up to 8 CPUs.
3 */
4#define APIC_DEFINITION 1
5#include <linux/threads.h>
6#include <linux/cpumask.h>
7#include <asm/mpspec.h>
8#include <asm/mach-default/mach_apicdef.h>
9#include <asm/genapic.h>
10#include <asm/fixmap.h>
11#include <asm/apicdef.h>
12#include <linux/kernel.h>
13#include <linux/string.h>
14#include <linux/smp.h>
15#include <linux/init.h>
16#include <asm/mach-default/mach_apic.h>
17#include <asm/mach-default/mach_ipi.h>
18#include <asm/mach-default/mach_mpparse.h>
19#include <asm/mach-default/mach_wakecpu.h>
20
21/* should be called last. */
22static int probe_default(void)
23{
24 return 1;
25}
26
27struct genapic apic_default = APIC_INIT("default", probe_default);
diff --git a/arch/x86/mach-generic/es7000.c b/arch/x86/mach-generic/es7000.c
deleted file mode 100644
index c2ded144802..00000000000
--- a/arch/x86/mach-generic/es7000.c
+++ /dev/null
@@ -1,103 +0,0 @@
1/*
2 * APIC driver for the Unisys ES7000 chipset.
3 */
4#define APIC_DEFINITION 1
5#include <linux/threads.h>
6#include <linux/cpumask.h>
7#include <asm/mpspec.h>
8#include <asm/genapic.h>
9#include <asm/fixmap.h>
10#include <asm/apicdef.h>
11#include <linux/kernel.h>
12#include <linux/string.h>
13#include <linux/init.h>
14#include <asm/es7000/apicdef.h>
15#include <linux/smp.h>
16#include <asm/es7000/apic.h>
17#include <asm/es7000/ipi.h>
18#include <asm/es7000/mpparse.h>
19#include <asm/mach-default/mach_wakecpu.h>
20
21void __init es7000_update_genapic_to_cluster(void)
22{
23 genapic->target_cpus = target_cpus_cluster;
24 genapic->int_delivery_mode = INT_DELIVERY_MODE_CLUSTER;
25 genapic->int_dest_mode = INT_DEST_MODE_CLUSTER;
26 genapic->no_balance_irq = NO_BALANCE_IRQ_CLUSTER;
27
28 genapic->init_apic_ldr = init_apic_ldr_cluster;
29
30 genapic->cpu_mask_to_apicid = cpu_mask_to_apicid_cluster;
31}
32
33static int probe_es7000(void)
34{
35 /* probed later in mptable/ACPI hooks */
36 return 0;
37}
38
39extern void es7000_sw_apic(void);
40static void __init enable_apic_mode(void)
41{
42 es7000_sw_apic();
43 return;
44}
45
46static __init int
47mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
48{
49 if (mpc->oemptr) {
50 struct mpc_oemtable *oem_table =
51 (struct mpc_oemtable *)mpc->oemptr;
52 if (!strncmp(oem, "UNISYS", 6))
53 return parse_unisys_oem((char *)oem_table);
54 }
55 return 0;
56}
57
58#ifdef CONFIG_ACPI
59/* Hook from generic ACPI tables.c */
60static int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
61{
62 unsigned long oem_addr = 0;
63 int check_dsdt;
64 int ret = 0;
65
66 /* check dsdt at first to avoid clear fix_map for oem_addr */
67 check_dsdt = es7000_check_dsdt();
68
69 if (!find_unisys_acpi_oem_table(&oem_addr)) {
70 if (check_dsdt)
71 ret = parse_unisys_oem((char *)oem_addr);
72 else {
73 setup_unisys();
74 ret = 1;
75 }
76 /*
77 * we need to unmap it
78 */
79 unmap_unisys_acpi_oem_table(oem_addr);
80 }
81 return ret;
82}
83#else
84static int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
85{
86 return 0;
87}
88#endif
89
90static void vector_allocation_domain(int cpu, cpumask_t *retmask)
91{
92 /* Careful. Some cpus do not strictly honor the set of cpus
93 * specified in the interrupt destination when using lowest
94 * priority interrupt delivery mode.
95 *
96 * In particular there was a hyperthreading cpu observed to
97 * deliver interrupts to the wrong hyperthread when only one
98 * hyperthread was specified in the interrupt desitination.
99 */
100 *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
101}
102
103struct genapic __initdata_refok apic_es7000 = APIC_INIT("es7000", probe_es7000);
diff --git a/arch/x86/mach-generic/numaq.c b/arch/x86/mach-generic/numaq.c
deleted file mode 100644
index 3679e225564..00000000000
--- a/arch/x86/mach-generic/numaq.c
+++ /dev/null
@@ -1,53 +0,0 @@
1/*
2 * APIC driver for the IBM NUMAQ chipset.
3 */
4#define APIC_DEFINITION 1
5#include <linux/threads.h>
6#include <linux/cpumask.h>
7#include <asm/mpspec.h>
8#include <asm/genapic.h>
9#include <asm/fixmap.h>
10#include <asm/apicdef.h>
11#include <linux/kernel.h>
12#include <linux/string.h>
13#include <linux/init.h>
14#include <asm/numaq/apicdef.h>
15#include <linux/smp.h>
16#include <asm/numaq/apic.h>
17#include <asm/numaq/ipi.h>
18#include <asm/numaq/mpparse.h>
19#include <asm/numaq/wakecpu.h>
20#include <asm/numaq.h>
21
22static int mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
23{
24 numaq_mps_oem_check(mpc, oem, productid);
25 return found_numaq;
26}
27
28static int probe_numaq(void)
29{
30 /* already know from get_memcfg_numaq() */
31 return found_numaq;
32}
33
34/* Hook from generic ACPI tables.c */
35static int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
36{
37 return 0;
38}
39
40static void vector_allocation_domain(int cpu, cpumask_t *retmask)
41{
42 /* Careful. Some cpus do not strictly honor the set of cpus
43 * specified in the interrupt destination when using lowest
44 * priority interrupt delivery mode.
45 *
46 * In particular there was a hyperthreading cpu observed to
47 * deliver interrupts to the wrong hyperthread when only one
48 * hyperthread was specified in the interrupt desitination.
49 */
50 *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
51}
52
53struct genapic apic_numaq = APIC_INIT("NUMAQ", probe_numaq);
diff --git a/arch/x86/mach-generic/probe.c b/arch/x86/mach-generic/probe.c
deleted file mode 100644
index 15a38daef1a..00000000000
--- a/arch/x86/mach-generic/probe.c
+++ /dev/null
@@ -1,152 +0,0 @@
1/*
2 * Copyright 2003 Andi Kleen, SuSE Labs.
3 * Subject to the GNU Public License, v.2
4 *
5 * Generic x86 APIC driver probe layer.
6 */
7#include <linux/threads.h>
8#include <linux/cpumask.h>
9#include <linux/string.h>
10#include <linux/kernel.h>
11#include <linux/ctype.h>
12#include <linux/init.h>
13#include <linux/errno.h>
14#include <asm/fixmap.h>
15#include <asm/mpspec.h>
16#include <asm/apicdef.h>
17#include <asm/genapic.h>
18#include <asm/setup.h>
19
20extern struct genapic apic_numaq;
21extern struct genapic apic_summit;
22extern struct genapic apic_bigsmp;
23extern struct genapic apic_es7000;
24extern struct genapic apic_default;
25
26struct genapic *genapic = &apic_default;
27
28static struct genapic *apic_probe[] __initdata = {
29#ifdef CONFIG_X86_NUMAQ
30 &apic_numaq,
31#endif
32#ifdef CONFIG_X86_SUMMIT
33 &apic_summit,
34#endif
35#ifdef CONFIG_X86_BIGSMP
36 &apic_bigsmp,
37#endif
38#ifdef CONFIG_X86_ES7000
39 &apic_es7000,
40#endif
41 &apic_default, /* must be last */
42 NULL,
43};
44
45static int cmdline_apic __initdata;
46static int __init parse_apic(char *arg)
47{
48 int i;
49
50 if (!arg)
51 return -EINVAL;
52
53 for (i = 0; apic_probe[i]; i++) {
54 if (!strcmp(apic_probe[i]->name, arg)) {
55 genapic = apic_probe[i];
56 cmdline_apic = 1;
57 return 0;
58 }
59 }
60
61 if (x86_quirks->update_genapic)
62 x86_quirks->update_genapic();
63
64 /* Parsed again by __setup for debug/verbose */
65 return 0;
66}
67early_param("apic", parse_apic);
68
69void __init generic_bigsmp_probe(void)
70{
71#ifdef CONFIG_X86_BIGSMP
72 /*
73 * This routine is used to switch to bigsmp mode when
74 * - There is no apic= option specified by the user
75 * - generic_apic_probe() has chosen apic_default as the sub_arch
76 * - we find more than 8 CPUs in acpi LAPIC listing with xAPIC support
77 */
78
79 if (!cmdline_apic && genapic == &apic_default) {
80 if (apic_bigsmp.probe()) {
81 genapic = &apic_bigsmp;
82 if (x86_quirks->update_genapic)
83 x86_quirks->update_genapic();
84 printk(KERN_INFO "Overriding APIC driver with %s\n",
85 genapic->name);
86 }
87 }
88#endif
89}
90
91void __init generic_apic_probe(void)
92{
93 if (!cmdline_apic) {
94 int i;
95 for (i = 0; apic_probe[i]; i++) {
96 if (apic_probe[i]->probe()) {
97 genapic = apic_probe[i];
98 break;
99 }
100 }
101 /* Not visible without early console */
102 if (!apic_probe[i])
103 panic("Didn't find an APIC driver");
104
105 if (x86_quirks->update_genapic)
106 x86_quirks->update_genapic();
107 }
108 printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
109}
110
111/* These functions can switch the APIC even after the initial ->probe() */
112
113int __init mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
114{
115 int i;
116 for (i = 0; apic_probe[i]; ++i) {
117 if (apic_probe[i]->mps_oem_check(mpc, oem, productid)) {
118 if (!cmdline_apic) {
119 genapic = apic_probe[i];
120 if (x86_quirks->update_genapic)
121 x86_quirks->update_genapic();
122 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
123 genapic->name);
124 }
125 return 1;
126 }
127 }
128 return 0;
129}
130
131int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
132{
133 int i;
134 for (i = 0; apic_probe[i]; ++i) {
135 if (apic_probe[i]->acpi_madt_oem_check(oem_id, oem_table_id)) {
136 if (!cmdline_apic) {
137 genapic = apic_probe[i];
138 if (x86_quirks->update_genapic)
139 x86_quirks->update_genapic();
140 printk(KERN_INFO "Switched to APIC driver `%s'.\n",
141 genapic->name);
142 }
143 return 1;
144 }
145 }
146 return 0;
147}
148
149int hard_smp_processor_id(void)
150{
151 return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
152}
diff --git a/arch/x86/mach-generic/summit.c b/arch/x86/mach-generic/summit.c
deleted file mode 100644
index 2821ffc188b..00000000000
--- a/arch/x86/mach-generic/summit.c
+++ /dev/null
@@ -1,40 +0,0 @@
1/*
2 * APIC driver for the IBM "Summit" chipset.
3 */
4#define APIC_DEFINITION 1
5#include <linux/threads.h>
6#include <linux/cpumask.h>
7#include <asm/mpspec.h>
8#include <asm/genapic.h>
9#include <asm/fixmap.h>
10#include <asm/apicdef.h>
11#include <linux/kernel.h>
12#include <linux/string.h>
13#include <linux/init.h>
14#include <asm/summit/apicdef.h>
15#include <linux/smp.h>
16#include <asm/summit/apic.h>
17#include <asm/summit/ipi.h>
18#include <asm/summit/mpparse.h>
19#include <asm/mach-default/mach_wakecpu.h>
20
21static int probe_summit(void)
22{
23 /* probed later in mptable/ACPI hooks */
24 return 0;
25}
26
27static void vector_allocation_domain(int cpu, cpumask_t *retmask)
28{
29 /* Careful. Some cpus do not strictly honor the set of cpus
30 * specified in the interrupt destination when using lowest
31 * priority interrupt delivery mode.
32 *
33 * In particular there was a hyperthreading cpu observed to
34 * deliver interrupts to the wrong hyperthread when only one
35 * hyperthread was specified in the interrupt desitination.
36 */
37 *retmask = (cpumask_t){ { [0] = APIC_ALL_CPUS, } };
38}
39
40struct genapic apic_summit = APIC_INIT("summit", probe_summit);
diff --git a/arch/x86/mach-rdc321x/Makefile b/arch/x86/mach-rdc321x/Makefile
deleted file mode 100644
index 8325b4ca431..00000000000
--- a/arch/x86/mach-rdc321x/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
1#
2# Makefile for the RDC321x specific parts of the kernel
3#
4obj-$(CONFIG_X86_RDC321X) := gpio.o platform.o
5
diff --git a/arch/x86/mach-rdc321x/gpio.c b/arch/x86/mach-rdc321x/gpio.c
deleted file mode 100644
index 247f33d3a40..00000000000
--- a/arch/x86/mach-rdc321x/gpio.c
+++ /dev/null
@@ -1,194 +0,0 @@
1/*
2 * GPIO support for RDC SoC R3210/R8610
3 *
4 * Copyright (C) 2007, Florian Fainelli <florian@openwrt.org>
5 * Copyright (C) 2008, Volker Weiss <dev@tintuc.de>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23
24#include <linux/spinlock.h>
25#include <linux/io.h>
26#include <linux/types.h>
27#include <linux/module.h>
28
29#include <asm/gpio.h>
30#include <asm/mach-rdc321x/rdc321x_defs.h>
31
32
33/* spin lock to protect our private copy of GPIO data register plus
34 the access to PCI conf registers. */
35static DEFINE_SPINLOCK(gpio_lock);
36
37/* copy of GPIO data registers */
38static u32 gpio_data_reg1;
39static u32 gpio_data_reg2;
40
41static u32 gpio_request_data[2];
42
43
44static inline void rdc321x_conf_write(unsigned addr, u32 value)
45{
46 outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR);
47 outl(value, RDC3210_CFGREG_DATA);
48}
49
50static inline void rdc321x_conf_or(unsigned addr, u32 value)
51{
52 outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR);
53 value |= inl(RDC3210_CFGREG_DATA);
54 outl(value, RDC3210_CFGREG_DATA);
55}
56
57static inline u32 rdc321x_conf_read(unsigned addr)
58{
59 outl((1 << 31) | (7 << 11) | addr, RDC3210_CFGREG_ADDR);
60
61 return inl(RDC3210_CFGREG_DATA);
62}
63
64/* configure pin as GPIO */
65static void rdc321x_configure_gpio(unsigned gpio)
66{
67 unsigned long flags;
68
69 spin_lock_irqsave(&gpio_lock, flags);
70 rdc321x_conf_or(gpio < 32
71 ? RDC321X_GPIO_CTRL_REG1 : RDC321X_GPIO_CTRL_REG2,
72 1 << (gpio & 0x1f));
73 spin_unlock_irqrestore(&gpio_lock, flags);
74}
75
76/* initially setup the 2 copies of the gpio data registers.
77 This function must be called by the platform setup code. */
78void __init rdc321x_gpio_setup()
79{
80 /* this might not be, what others (BIOS, bootloader, etc.)
81 wrote to these registers before, but it's a good guess. Still
82 better than just using 0xffffffff. */
83
84 gpio_data_reg1 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG1);
85 gpio_data_reg2 = rdc321x_conf_read(RDC321X_GPIO_DATA_REG2);
86}
87
88/* determine, if gpio number is valid */
89static inline int rdc321x_is_gpio(unsigned gpio)
90{
91 return gpio <= RDC321X_MAX_GPIO;
92}
93
94/* request GPIO */
95int rdc_gpio_request(unsigned gpio, const char *label)
96{
97 unsigned long flags;
98
99 if (!rdc321x_is_gpio(gpio))
100 return -EINVAL;
101
102 spin_lock_irqsave(&gpio_lock, flags);
103 if (gpio_request_data[(gpio & 0x20) ? 1 : 0] & (1 << (gpio & 0x1f)))
104 goto inuse;
105 gpio_request_data[(gpio & 0x20) ? 1 : 0] |= (1 << (gpio & 0x1f));
106 spin_unlock_irqrestore(&gpio_lock, flags);
107
108 return 0;
109inuse:
110 spin_unlock_irqrestore(&gpio_lock, flags);
111 return -EINVAL;
112}
113EXPORT_SYMBOL(rdc_gpio_request);
114
115/* release previously-claimed GPIO */
116void rdc_gpio_free(unsigned gpio)
117{
118 unsigned long flags;
119
120 if (!rdc321x_is_gpio(gpio))
121 return;
122
123 spin_lock_irqsave(&gpio_lock, flags);
124 gpio_request_data[(gpio & 0x20) ? 1 : 0] &= ~(1 << (gpio & 0x1f));
125 spin_unlock_irqrestore(&gpio_lock, flags);
126}
127EXPORT_SYMBOL(rdc_gpio_free);
128
129/* read GPIO pin */
130int rdc_gpio_get_value(unsigned gpio)
131{
132 u32 reg;
133 unsigned long flags;
134
135 spin_lock_irqsave(&gpio_lock, flags);
136 reg = rdc321x_conf_read(gpio < 32
137 ? RDC321X_GPIO_DATA_REG1 : RDC321X_GPIO_DATA_REG2);
138 spin_unlock_irqrestore(&gpio_lock, flags);
139
140 return (1 << (gpio & 0x1f)) & reg ? 1 : 0;
141}
142EXPORT_SYMBOL(rdc_gpio_get_value);
143
144/* set GPIO pin to value */
145void rdc_gpio_set_value(unsigned gpio, int value)
146{
147 unsigned long flags;
148 u32 reg;
149
150 reg = 1 << (gpio & 0x1f);
151 if (gpio < 32) {
152 spin_lock_irqsave(&gpio_lock, flags);
153 if (value)
154 gpio_data_reg1 |= reg;
155 else
156 gpio_data_reg1 &= ~reg;
157 rdc321x_conf_write(RDC321X_GPIO_DATA_REG1, gpio_data_reg1);
158 spin_unlock_irqrestore(&gpio_lock, flags);
159 } else {
160 spin_lock_irqsave(&gpio_lock, flags);
161 if (value)
162 gpio_data_reg2 |= reg;
163 else
164 gpio_data_reg2 &= ~reg;
165 rdc321x_conf_write(RDC321X_GPIO_DATA_REG2, gpio_data_reg2);
166 spin_unlock_irqrestore(&gpio_lock, flags);
167 }
168}
169EXPORT_SYMBOL(rdc_gpio_set_value);
170
171/* configure GPIO pin as input */
172int rdc_gpio_direction_input(unsigned gpio)
173{
174 if (!rdc321x_is_gpio(gpio))
175 return -EINVAL;
176
177 rdc321x_configure_gpio(gpio);
178
179 return 0;
180}
181EXPORT_SYMBOL(rdc_gpio_direction_input);
182
183/* configure GPIO pin as output and set value */
184int rdc_gpio_direction_output(unsigned gpio, int value)
185{
186 if (!rdc321x_is_gpio(gpio))
187 return -EINVAL;
188
189 gpio_set_value(gpio, value);
190 rdc321x_configure_gpio(gpio);
191
192 return 0;
193}
194EXPORT_SYMBOL(rdc_gpio_direction_output);
diff --git a/arch/x86/mach-rdc321x/platform.c b/arch/x86/mach-rdc321x/platform.c
deleted file mode 100644
index 4f4e50c3ad3..00000000000
--- a/arch/x86/mach-rdc321x/platform.c
+++ /dev/null
@@ -1,69 +0,0 @@
1/*
2 * Generic RDC321x platform devices
3 *
4 * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#include <linux/init.h>
24#include <linux/kernel.h>
25#include <linux/list.h>
26#include <linux/device.h>
27#include <linux/platform_device.h>
28#include <linux/leds.h>
29
30#include <asm/gpio.h>
31
32/* LEDS */
33static struct gpio_led default_leds[] = {
34 { .name = "rdc:dmz", .gpio = 1, },
35};
36
37static struct gpio_led_platform_data rdc321x_led_data = {
38 .num_leds = ARRAY_SIZE(default_leds),
39 .leds = default_leds,
40};
41
42static struct platform_device rdc321x_leds = {
43 .name = "leds-gpio",
44 .id = -1,
45 .dev = {
46 .platform_data = &rdc321x_led_data,
47 }
48};
49
50/* Watchdog */
51static struct platform_device rdc321x_wdt = {
52 .name = "rdc321x-wdt",
53 .id = -1,
54 .num_resources = 0,
55};
56
57static struct platform_device *rdc321x_devs[] = {
58 &rdc321x_leds,
59 &rdc321x_wdt
60};
61
62static int __init rdc_board_setup(void)
63{
64 rdc321x_gpio_setup();
65
66 return platform_add_devices(rdc321x_devs, ARRAY_SIZE(rdc321x_devs));
67}
68
69arch_initcall(rdc_board_setup);
diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
index 9f05157220f..2b938a38491 100644
--- a/arch/x86/mm/Makefile
+++ b/arch/x86/mm/Makefile
@@ -1,7 +1,7 @@
1obj-y := init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \ 1obj-y := init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \
2 pat.o pgtable.o gup.o 2 pat.o pgtable.o gup.o
3 3
4obj-$(CONFIG_X86_SMP) += tlb.o 4obj-$(CONFIG_SMP) += tlb.o
5 5
6obj-$(CONFIG_X86_32) += pgtable_32.o iomap_32.o 6obj-$(CONFIG_X86_32) += pgtable_32.o iomap_32.o
7 7
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 8c3f3113a6e..2a9ea3aee49 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -420,7 +420,6 @@ static noinline void pgtable_bad(struct pt_regs *regs,
420 printk(KERN_ALERT "%s: Corrupted page table at address %lx\n", 420 printk(KERN_ALERT "%s: Corrupted page table at address %lx\n",
421 tsk->comm, address); 421 tsk->comm, address);
422 dump_pagetable(address); 422 dump_pagetable(address);
423 tsk = current;
424 tsk->thread.cr2 = address; 423 tsk->thread.cr2 = address;
425 tsk->thread.trap_no = 14; 424 tsk->thread.trap_no = 14;
426 tsk->thread.error_code = error_code; 425 tsk->thread.error_code = error_code;
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index af750ab973b..1448bcb7f22 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -367,7 +367,7 @@ EXPORT_SYMBOL(ioremap_nocache);
367 * 367 *
368 * Must be freed with iounmap. 368 * Must be freed with iounmap.
369 */ 369 */
370void __iomem *ioremap_wc(unsigned long phys_addr, unsigned long size) 370void __iomem *ioremap_wc(resource_size_t phys_addr, unsigned long size)
371{ 371{
372 if (pat_enabled) 372 if (pat_enabled)
373 return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC, 373 return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC,
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index 56fe7124fbe..16582960056 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -4,7 +4,7 @@
4 * Based on code by Ingo Molnar and Andi Kleen, copyrighted 4 * Based on code by Ingo Molnar and Andi Kleen, copyrighted
5 * as follows: 5 * as follows:
6 * 6 *
7 * Copyright 2003-2004 Red Hat Inc., Durham, North Carolina. 7 * Copyright 2003-2009 Red Hat Inc.
8 * All Rights Reserved. 8 * All Rights Reserved.
9 * Copyright 2005 Andi Kleen, SUSE Labs. 9 * Copyright 2005 Andi Kleen, SUSE Labs.
10 * Copyright 2007 Jiri Kosina, SUSE Labs. 10 * Copyright 2007 Jiri Kosina, SUSE Labs.
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 7b61036427d..9127e31c726 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -30,7 +30,7 @@
30#ifdef CONFIG_X86_PAT 30#ifdef CONFIG_X86_PAT
31int __read_mostly pat_enabled = 1; 31int __read_mostly pat_enabled = 1;
32 32
33void __cpuinit pat_disable(char *reason) 33void __cpuinit pat_disable(const char *reason)
34{ 34{
35 pat_enabled = 0; 35 pat_enabled = 0;
36 printk(KERN_INFO "%s\n", reason); 36 printk(KERN_INFO "%s\n", reason);
@@ -42,6 +42,11 @@ static int __init nopat(char *str)
42 return 0; 42 return 0;
43} 43}
44early_param("nopat", nopat); 44early_param("nopat", nopat);
45#else
46static inline void pat_disable(const char *reason)
47{
48 (void)reason;
49}
45#endif 50#endif
46 51
47 52
@@ -78,16 +83,20 @@ void pat_init(void)
78 if (!pat_enabled) 83 if (!pat_enabled)
79 return; 84 return;
80 85
81 /* Paranoia check. */ 86 if (!cpu_has_pat) {
82 if (!cpu_has_pat && boot_pat_state) { 87 if (!boot_pat_state) {
83 /* 88 pat_disable("PAT not supported by CPU.");
84 * If this happens we are on a secondary CPU, but 89 return;
85 * switched to PAT on the boot CPU. We have no way to 90 } else {
86 * undo PAT. 91 /*
87 */ 92 * If this happens we are on a secondary CPU, but
88 printk(KERN_ERR "PAT enabled, " 93 * switched to PAT on the boot CPU. We have no way to
89 "but not supported by secondary CPU\n"); 94 * undo PAT.
90 BUG(); 95 */
96 printk(KERN_ERR "PAT enabled, "
97 "but not supported by secondary CPU\n");
98 BUG();
99 }
91 } 100 }
92 101
93 /* Set PWT to Write-Combining. All other bits stay the same */ 102 /* Set PWT to Write-Combining. All other bits stay the same */
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 72a6d4ebe34..14c5af4d11e 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -14,7 +14,7 @@
14DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate) 14DEFINE_PER_CPU_SHARED_ALIGNED(struct tlb_state, cpu_tlbstate)
15 = { &init_mm, 0, }; 15 = { &init_mm, 0, };
16 16
17#include <mach_ipi.h> 17#include <asm/genapic.h>
18/* 18/*
19 * Smarter SMP flushing macros. 19 * Smarter SMP flushing macros.
20 * c/o Linus Torvalds. 20 * c/o Linus Torvalds.
@@ -196,7 +196,7 @@ static void flush_tlb_others_ipi(const struct cpumask *cpumask,
196 * We have to send the IPI only to 196 * We have to send the IPI only to
197 * CPUs affected. 197 * CPUs affected.
198 */ 198 */
199 send_IPI_mask(to_cpumask(f->flush_cpumask), 199 apic->send_IPI_mask(to_cpumask(f->flush_cpumask),
200 INVALIDATE_TLB_VECTOR_START + sender); 200 INVALIDATE_TLB_VECTOR_START + sender);
201 201
202 while (!cpumask_empty(to_cpumask(f->flush_cpumask))) 202 while (!cpumask_empty(to_cpumask(f->flush_cpumask)))
diff --git a/arch/x86/pci/numaq_32.c b/arch/x86/pci/numaq_32.c
index 2089354968a..5601e829c38 100644
--- a/arch/x86/pci/numaq_32.c
+++ b/arch/x86/pci/numaq_32.c
@@ -5,7 +5,7 @@
5#include <linux/pci.h> 5#include <linux/pci.h>
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/nodemask.h> 7#include <linux/nodemask.h>
8#include <mach_apic.h> 8#include <asm/genapic.h>
9#include <asm/mpspec.h> 9#include <asm/mpspec.h>
10#include <asm/pci_x86.h> 10#include <asm/pci_x86.h>
11 11
@@ -18,10 +18,6 @@
18 18
19#define QUADLOCAL2BUS(quad,local) (quad_local_to_mp_bus_id[quad][local]) 19#define QUADLOCAL2BUS(quad,local) (quad_local_to_mp_bus_id[quad][local])
20 20
21/* Where the IO area was mapped on multiquad, always 0 otherwise */
22void *xquad_portio;
23EXPORT_SYMBOL(xquad_portio);
24
25#define XQUAD_PORT_ADDR(port, quad) (xquad_portio + (XQUAD_PORTIO_QUAD*quad) + port) 21#define XQUAD_PORT_ADDR(port, quad) (xquad_portio + (XQUAD_PORTIO_QUAD*quad) + port)
26 22
27#define PCI_CONF1_MQ_ADDRESS(bus, devfn, reg) \ 23#define PCI_CONF1_MQ_ADDRESS(bus, devfn, reg) \
diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
index b82cae970df..1c975cc9839 100644
--- a/arch/x86/pci/pcbios.c
+++ b/arch/x86/pci/pcbios.c
@@ -7,7 +7,7 @@
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/uaccess.h> 8#include <linux/uaccess.h>
9#include <asm/pci_x86.h> 9#include <asm/pci_x86.h>
10#include <asm/mach-default/pci-functions.h> 10#include <asm/pci-functions.h>
11 11
12/* BIOS32 signature: "_32_" */ 12/* BIOS32 signature: "_32_" */
13#define BIOS32_SIGNATURE (('_' << 0) + ('3' << 8) + ('2' << 16) + ('_' << 24)) 13#define BIOS32_SIGNATURE (('_' << 0) + ('3' << 8) + ('2' << 16) + ('_' << 24))
diff --git a/arch/x86/xen/irq.c b/arch/x86/xen/irq.c
index 5a070900ad3..cfd17799bd6 100644
--- a/arch/x86/xen/irq.c
+++ b/arch/x86/xen/irq.c
@@ -19,21 +19,6 @@ void xen_force_evtchn_callback(void)
19 (void)HYPERVISOR_xen_version(0, NULL); 19 (void)HYPERVISOR_xen_version(0, NULL);
20} 20}
21 21
22static void __init __xen_init_IRQ(void)
23{
24 int i;
25
26 /* Create identity vector->irq map */
27 for(i = 0; i < NR_VECTORS; i++) {
28 int cpu;
29
30 for_each_possible_cpu(cpu)
31 per_cpu(vector_irq, cpu)[i] = i;
32 }
33
34 xen_init_IRQ();
35}
36
37static unsigned long xen_save_fl(void) 22static unsigned long xen_save_fl(void)
38{ 23{
39 struct vcpu_info *vcpu; 24 struct vcpu_info *vcpu;
@@ -127,7 +112,7 @@ static void xen_halt(void)
127} 112}
128 113
129static const struct pv_irq_ops xen_irq_ops __initdata = { 114static const struct pv_irq_ops xen_irq_ops __initdata = {
130 .init_IRQ = __xen_init_IRQ, 115 .init_IRQ = xen_init_IRQ,
131 116
132 .save_fl = PV_CALLEE_SAVE(xen_save_fl), 117 .save_fl = PV_CALLEE_SAVE(xen_save_fl),
133 .restore_fl = PV_CALLEE_SAVE(xen_restore_fl), 118 .restore_fl = PV_CALLEE_SAVE(xen_restore_fl),
diff --git a/crypto/algapi.c b/crypto/algapi.c
index 7c41e7405c4..56c62e2858d 100644
--- a/crypto/algapi.c
+++ b/crypto/algapi.c
@@ -149,6 +149,9 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg)
149 if (q == alg) 149 if (q == alg)
150 goto err; 150 goto err;
151 151
152 if (crypto_is_moribund(q))
153 continue;
154
152 if (crypto_is_larval(q)) { 155 if (crypto_is_larval(q)) {
153 if (!strcmp(alg->cra_driver_name, q->cra_driver_name)) 156 if (!strcmp(alg->cra_driver_name, q->cra_driver_name))
154 goto err; 157 goto err;
@@ -197,7 +200,7 @@ void crypto_alg_tested(const char *name, int err)
197 200
198 down_write(&crypto_alg_sem); 201 down_write(&crypto_alg_sem);
199 list_for_each_entry(q, &crypto_alg_list, cra_list) { 202 list_for_each_entry(q, &crypto_alg_list, cra_list) {
200 if (!crypto_is_larval(q)) 203 if (crypto_is_moribund(q) || !crypto_is_larval(q))
201 continue; 204 continue;
202 205
203 test = (struct crypto_larval *)q; 206 test = (struct crypto_larval *)q;
@@ -210,6 +213,7 @@ void crypto_alg_tested(const char *name, int err)
210 goto unlock; 213 goto unlock;
211 214
212found: 215found:
216 q->cra_flags |= CRYPTO_ALG_DEAD;
213 alg = test->adult; 217 alg = test->adult;
214 if (err || list_empty(&alg->cra_list)) 218 if (err || list_empty(&alg->cra_list))
215 goto complete; 219 goto complete;
diff --git a/crypto/api.c b/crypto/api.c
index 9975a7bd246..efe77df6863 100644
--- a/crypto/api.c
+++ b/crypto/api.c
@@ -557,34 +557,34 @@ err:
557 return ERR_PTR(err); 557 return ERR_PTR(err);
558} 558}
559EXPORT_SYMBOL_GPL(crypto_alloc_tfm); 559EXPORT_SYMBOL_GPL(crypto_alloc_tfm);
560 560
561/* 561/*
562 * crypto_free_tfm - Free crypto transform 562 * crypto_destroy_tfm - Free crypto transform
563 * @mem: Start of tfm slab
563 * @tfm: Transform to free 564 * @tfm: Transform to free
564 * 565 *
565 * crypto_free_tfm() frees up the transform and any associated resources, 566 * This function frees up the transform and any associated resources,
566 * then drops the refcount on the associated algorithm. 567 * then drops the refcount on the associated algorithm.
567 */ 568 */
568void crypto_free_tfm(struct crypto_tfm *tfm) 569void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm)
569{ 570{
570 struct crypto_alg *alg; 571 struct crypto_alg *alg;
571 int size; 572 int size;
572 573
573 if (unlikely(!tfm)) 574 if (unlikely(!mem))
574 return; 575 return;
575 576
576 alg = tfm->__crt_alg; 577 alg = tfm->__crt_alg;
577 size = sizeof(*tfm) + alg->cra_ctxsize; 578 size = ksize(mem);
578 579
579 if (!tfm->exit && alg->cra_exit) 580 if (!tfm->exit && alg->cra_exit)
580 alg->cra_exit(tfm); 581 alg->cra_exit(tfm);
581 crypto_exit_ops(tfm); 582 crypto_exit_ops(tfm);
582 crypto_mod_put(alg); 583 crypto_mod_put(alg);
583 memset(tfm, 0, size); 584 memset(mem, 0, size);
584 kfree(tfm); 585 kfree(mem);
585} 586}
586 587EXPORT_SYMBOL_GPL(crypto_destroy_tfm);
587EXPORT_SYMBOL_GPL(crypto_free_tfm);
588 588
589int crypto_has_alg(const char *name, u32 type, u32 mask) 589int crypto_has_alg(const char *name, u32 type, u32 mask)
590{ 590{
diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c
index 9aeeb52004a..3de89a42440 100644
--- a/crypto/scatterwalk.c
+++ b/crypto/scatterwalk.c
@@ -54,7 +54,8 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
54 struct page *page; 54 struct page *page;
55 55
56 page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT); 56 page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT);
57 flush_dcache_page(page); 57 if (!PageSlab(page))
58 flush_dcache_page(page);
58 } 59 }
59 60
60 if (more) { 61 if (more) {
diff --git a/crypto/shash.c b/crypto/shash.c
index c9df367332f..d5a2b619c55 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -388,10 +388,15 @@ static int crypto_init_shash_ops_compat(struct crypto_tfm *tfm)
388 struct shash_desc *desc = crypto_tfm_ctx(tfm); 388 struct shash_desc *desc = crypto_tfm_ctx(tfm);
389 struct crypto_shash *shash; 389 struct crypto_shash *shash;
390 390
391 if (!crypto_mod_get(calg))
392 return -EAGAIN;
393
391 shash = __crypto_shash_cast(crypto_create_tfm( 394 shash = __crypto_shash_cast(crypto_create_tfm(
392 calg, &crypto_shash_type)); 395 calg, &crypto_shash_type));
393 if (IS_ERR(shash)) 396 if (IS_ERR(shash)) {
397 crypto_mod_put(calg);
394 return PTR_ERR(shash); 398 return PTR_ERR(shash);
399 }
395 400
396 desc->tfm = shash; 401 desc->tfm = shash;
397 tfm->exit = crypto_exit_shash_ops_compat; 402 tfm->exit = crypto_exit_shash_ops_compat;
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 72fc0f799a6..89d7a6e94c9 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -685,6 +685,7 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
685 out_release_regions: 685 out_release_regions:
686 pci_release_regions(dev); 686 pci_release_regions(dev);
687 out: 687 out:
688 kfree(card);
688 return err; 689 return err;
689} 690}
690 691
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 34f80fa6fed..8299e2d3b61 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -549,6 +549,15 @@ static void do_nbd_request(struct request_queue * q)
549 549
550 BUG_ON(lo->magic != LO_MAGIC); 550 BUG_ON(lo->magic != LO_MAGIC);
551 551
552 if (unlikely(!lo->sock)) {
553 printk(KERN_ERR "%s: Attempted send on closed socket\n",
554 lo->disk->disk_name);
555 req->errors++;
556 nbd_end_request(req);
557 spin_lock_irq(q->queue_lock);
558 continue;
559 }
560
552 spin_lock_irq(&lo->queue_lock); 561 spin_lock_irq(&lo->queue_lock);
553 list_add_tail(&req->queuelist, &lo->waiting_queue); 562 list_add_tail(&req->queuelist, &lo->waiting_queue);
554 spin_unlock_irq(&lo->queue_lock); 563 spin_unlock_irq(&lo->queue_lock);
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c
index 726ee8a0277..ecba4942fc8 100644
--- a/drivers/char/tpm/tpm_infineon.c
+++ b/drivers/char/tpm/tpm_infineon.c
@@ -4,7 +4,7 @@
4 * SLD 9630 TT 1.1 and SLB 9635 TT 1.2 Trusted Platform Module 4 * SLD 9630 TT 1.1 and SLB 9635 TT 1.2 Trusted Platform Module
5 * Specifications at www.trustedcomputinggroup.org 5 * Specifications at www.trustedcomputinggroup.org
6 * 6 *
7 * Copyright (C) 2005, Marcel Selhorst <selhorst@crypto.rub.de> 7 * Copyright (C) 2005, Marcel Selhorst <m.selhorst@sirrix.com>
8 * Sirrix AG - security technologies, http://www.sirrix.com and 8 * Sirrix AG - security technologies, http://www.sirrix.com and
9 * Applied Data Security Group, Ruhr-University Bochum, Germany 9 * Applied Data Security Group, Ruhr-University Bochum, Germany
10 * Project-Homepage: http://www.prosec.rub.de/tpm 10 * Project-Homepage: http://www.prosec.rub.de/tpm
@@ -636,7 +636,7 @@ static void __exit cleanup_inf(void)
636module_init(init_inf); 636module_init(init_inf);
637module_exit(cleanup_inf); 637module_exit(cleanup_inf);
638 638
639MODULE_AUTHOR("Marcel Selhorst <selhorst@crypto.rub.de>"); 639MODULE_AUTHOR("Marcel Selhorst <m.selhorst@sirrix.com>");
640MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2"); 640MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2");
641MODULE_VERSION("1.9"); 641MODULE_VERSION("1.9");
642MODULE_LICENSE("GPL"); 642MODULE_LICENSE("GPL");
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index e1129fad96d..ee19b6e8fcb 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -143,7 +143,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_LE,
143#endif 143#endif
144 144
145#ifndef CONFIG_X86_64 145#ifndef CONFIG_X86_64
146#include "mach_timer.h" 146#include <asm/mach_timer.h>
147#define PMTMR_EXPECTED_RATE \ 147#define PMTMR_EXPECTED_RATE \
148 ((CALIBRATE_LATCH * (PMTMR_TICKS_PER_SEC >> 10)) / (CLOCK_TICK_RATE>>10)) 148 ((CALIBRATE_LATCH * (PMTMR_TICKS_PER_SEC >> 10)) / (CLOCK_TICK_RATE>>10))
149/* 149/*
diff --git a/drivers/clocksource/cyclone.c b/drivers/clocksource/cyclone.c
index 1bde303b970..8615059a872 100644
--- a/drivers/clocksource/cyclone.c
+++ b/drivers/clocksource/cyclone.c
@@ -7,7 +7,7 @@
7#include <asm/pgtable.h> 7#include <asm/pgtable.h>
8#include <asm/io.h> 8#include <asm/io.h>
9 9
10#include "mach_timer.h" 10#include <asm/mach_timer.h>
11 11
12#define CYCLONE_CBAR_ADDR 0xFEB00CD0 /* base address ptr */ 12#define CYCLONE_CBAR_ADDR 0xFEB00CD0 /* base address ptr */
13#define CYCLONE_PMCC_OFFSET 0x51A0 /* offset to control register */ 13#define CYCLONE_PMCC_OFFSET 0x51A0 /* offset to control register */
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 6a2b036c938..6f45b1658a6 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -117,11 +117,7 @@ static inline cputime64_t get_cpu_idle_time_jiffy(unsigned int cpu,
117 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq); 117 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.irq);
118 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq); 118 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.softirq);
119 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal); 119 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.steal);
120 120 busy_time = cputime64_add(busy_time, kstat_cpu(cpu).cpustat.nice);
121 if (!dbs_tuners_ins.ignore_nice) {
122 busy_time = cputime64_add(busy_time,
123 kstat_cpu(cpu).cpustat.nice);
124 }
125 121
126 idle_time = cputime64_sub(cur_wall_time, busy_time); 122 idle_time = cputime64_sub(cur_wall_time, busy_time);
127 if (wall) 123 if (wall)
@@ -137,23 +133,6 @@ static inline cputime64_t get_cpu_idle_time(unsigned int cpu, cputime64_t *wall)
137 if (idle_time == -1ULL) 133 if (idle_time == -1ULL)
138 return get_cpu_idle_time_jiffy(cpu, wall); 134 return get_cpu_idle_time_jiffy(cpu, wall);
139 135
140 if (dbs_tuners_ins.ignore_nice) {
141 cputime64_t cur_nice;
142 unsigned long cur_nice_jiffies;
143 struct cpu_dbs_info_s *dbs_info;
144
145 dbs_info = &per_cpu(cpu_dbs_info, cpu);
146 cur_nice = cputime64_sub(kstat_cpu(cpu).cpustat.nice,
147 dbs_info->prev_cpu_nice);
148 /*
149 * Assumption: nice time between sampling periods will be
150 * less than 2^32 jiffies for 32 bit sys
151 */
152 cur_nice_jiffies = (unsigned long)
153 cputime64_to_jiffies64(cur_nice);
154 dbs_info->prev_cpu_nice = kstat_cpu(cpu).cpustat.nice;
155 return idle_time + jiffies_to_usecs(cur_nice_jiffies);
156 }
157 return idle_time; 136 return idle_time;
158} 137}
159 138
@@ -319,6 +298,9 @@ static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
319 dbs_info = &per_cpu(cpu_dbs_info, j); 298 dbs_info = &per_cpu(cpu_dbs_info, j);
320 dbs_info->prev_cpu_idle = get_cpu_idle_time(j, 299 dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
321 &dbs_info->prev_cpu_wall); 300 &dbs_info->prev_cpu_wall);
301 if (dbs_tuners_ins.ignore_nice)
302 dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice;
303
322 } 304 }
323 mutex_unlock(&dbs_mutex); 305 mutex_unlock(&dbs_mutex);
324 306
@@ -419,6 +401,23 @@ static void dbs_check_cpu(struct cpu_dbs_info_s *this_dbs_info)
419 j_dbs_info->prev_cpu_idle); 401 j_dbs_info->prev_cpu_idle);
420 j_dbs_info->prev_cpu_idle = cur_idle_time; 402 j_dbs_info->prev_cpu_idle = cur_idle_time;
421 403
404 if (dbs_tuners_ins.ignore_nice) {
405 cputime64_t cur_nice;
406 unsigned long cur_nice_jiffies;
407
408 cur_nice = cputime64_sub(kstat_cpu(j).cpustat.nice,
409 j_dbs_info->prev_cpu_nice);
410 /*
411 * Assumption: nice time between sampling periods will
412 * be less than 2^32 jiffies for 32 bit sys
413 */
414 cur_nice_jiffies = (unsigned long)
415 cputime64_to_jiffies64(cur_nice);
416
417 j_dbs_info->prev_cpu_nice = kstat_cpu(j).cpustat.nice;
418 idle_time += jiffies_to_usecs(cur_nice_jiffies);
419 }
420
422 if (unlikely(!wall_time || wall_time < idle_time)) 421 if (unlikely(!wall_time || wall_time < idle_time))
423 continue; 422 continue;
424 423
@@ -575,6 +574,10 @@ static int cpufreq_governor_dbs(struct cpufreq_policy *policy,
575 574
576 j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j, 575 j_dbs_info->prev_cpu_idle = get_cpu_idle_time(j,
577 &j_dbs_info->prev_cpu_wall); 576 &j_dbs_info->prev_cpu_wall);
577 if (dbs_tuners_ins.ignore_nice) {
578 j_dbs_info->prev_cpu_nice =
579 kstat_cpu(j).cpustat.nice;
580 }
578 } 581 }
579 this_dbs_info->cpu = cpu; 582 this_dbs_info->cpu = cpu;
580 /* 583 /*
diff --git a/drivers/eisa/Kconfig b/drivers/eisa/Kconfig
index c0646576cf4..2705284f622 100644
--- a/drivers/eisa/Kconfig
+++ b/drivers/eisa/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4config EISA_VLB_PRIMING 4config EISA_VLB_PRIMING
5 bool "Vesa Local Bus priming" 5 bool "Vesa Local Bus priming"
6 depends on X86_PC && EISA 6 depends on X86 && EISA
7 default n 7 default n
8 ---help--- 8 ---help---
9 Activate this option if your system contains a Vesa Local 9 Activate this option if your system contains a Vesa Local
@@ -24,11 +24,11 @@ config EISA_PCI_EISA
24 When in doubt, say Y. 24 When in doubt, say Y.
25 25
26# Using EISA_VIRTUAL_ROOT on something other than an Alpha or 26# Using EISA_VIRTUAL_ROOT on something other than an Alpha or
27# an X86_PC may lead to crashes... 27# an X86 may lead to crashes...
28 28
29config EISA_VIRTUAL_ROOT 29config EISA_VIRTUAL_ROOT
30 bool "EISA virtual root device" 30 bool "EISA virtual root device"
31 depends on EISA && (ALPHA || X86_PC) 31 depends on EISA && (ALPHA || X86)
32 default y 32 default y
33 ---help--- 33 ---help---
34 Activate this option if your system only have EISA bus 34 Activate this option if your system only have EISA bus
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 5130b72d593..4be3acbaaf9 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -70,7 +70,7 @@ config DRM_I915
70 select FB_CFB_FILLRECT 70 select FB_CFB_FILLRECT
71 select FB_CFB_COPYAREA 71 select FB_CFB_COPYAREA
72 select FB_CFB_IMAGEBLIT 72 select FB_CFB_IMAGEBLIT
73 depends on FB 73 select FB
74 tristate "i915 driver" 74 tristate "i915 driver"
75 help 75 help
76 Choose this option if you have a system that has Intel 830M, 845G, 76 Choose this option if you have a system that has Intel 830M, 845G,
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 69aa0ab2840..3795dbc0f50 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -276,6 +276,7 @@ int drm_irq_uninstall(struct drm_device * dev)
276 for (i = 0; i < dev->num_crtcs; i++) { 276 for (i = 0; i < dev->num_crtcs; i++) {
277 DRM_WAKEUP(&dev->vbl_queue[i]); 277 DRM_WAKEUP(&dev->vbl_queue[i]);
278 dev->vblank_enabled[i] = 0; 278 dev->vblank_enabled[i] = 0;
279 dev->last_vblank[i] = dev->driver->get_vblank_counter(dev, i);
279 } 280 }
280 spin_unlock_irqrestore(&dev->vbl_lock, irqflags); 281 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
281 282
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 803bc9e7ce3..bcc869bc409 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -171,9 +171,14 @@ EXPORT_SYMBOL(drm_core_ioremap);
171 171
172void drm_core_ioremap_wc(struct drm_map *map, struct drm_device *dev) 172void drm_core_ioremap_wc(struct drm_map *map, struct drm_device *dev)
173{ 173{
174 map->handle = ioremap_wc(map->offset, map->size); 174 if (drm_core_has_AGP(dev) &&
175 dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
176 map->handle = agp_remap(map->offset, map->size, dev);
177 else
178 map->handle = ioremap_wc(map->offset, map->size);
175} 179}
176EXPORT_SYMBOL(drm_core_ioremap_wc); 180EXPORT_SYMBOL(drm_core_ioremap_wc);
181
177void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev) 182void drm_core_ioremapfree(struct drm_map *map, struct drm_device *dev)
178{ 183{
179 if (!map->handle || !map->size) 184 if (!map->handle || !map->size)
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index ee64b7301f6..81f1cff56fd 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -731,8 +731,11 @@ static int i915_getparam(struct drm_device *dev, void *data,
731 case I915_PARAM_HAS_GEM: 731 case I915_PARAM_HAS_GEM:
732 value = dev_priv->has_gem; 732 value = dev_priv->has_gem;
733 break; 733 break;
734 case I915_PARAM_NUM_FENCES_AVAIL:
735 value = dev_priv->num_fence_regs - dev_priv->fence_reg_start;
736 break;
734 default: 737 default:
735 DRM_ERROR("Unknown parameter %d\n", param->param); 738 DRM_DEBUG("Unknown parameter %d\n", param->param);
736 return -EINVAL; 739 return -EINVAL;
737 } 740 }
738 741
@@ -764,8 +767,15 @@ static int i915_setparam(struct drm_device *dev, void *data,
764 case I915_SETPARAM_ALLOW_BATCHBUFFER: 767 case I915_SETPARAM_ALLOW_BATCHBUFFER:
765 dev_priv->allow_batchbuffer = param->value; 768 dev_priv->allow_batchbuffer = param->value;
766 break; 769 break;
770 case I915_SETPARAM_NUM_USED_FENCES:
771 if (param->value > dev_priv->num_fence_regs ||
772 param->value < 0)
773 return -EINVAL;
774 /* Userspace can use first N regs */
775 dev_priv->fence_reg_start = param->value;
776 break;
767 default: 777 default:
768 DRM_ERROR("unknown parameter %d\n", param->param); 778 DRM_DEBUG("unknown parameter %d\n", param->param);
769 return -EINVAL; 779 return -EINVAL;
770 } 780 }
771 781
@@ -966,10 +976,6 @@ static int i915_load_modeset_init(struct drm_device *dev)
966 if (ret) 976 if (ret)
967 goto kfree_devname; 977 goto kfree_devname;
968 978
969 dev_priv->mm.gtt_mapping =
970 io_mapping_create_wc(dev->agp->base,
971 dev->agp->agp_info.aper_size * 1024*1024);
972
973 /* Allow hardware batchbuffers unless told otherwise. 979 /* Allow hardware batchbuffers unless told otherwise.
974 */ 980 */
975 dev_priv->allow_batchbuffer = 1; 981 dev_priv->allow_batchbuffer = 1;
@@ -1081,6 +1087,23 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1081 goto free_priv; 1087 goto free_priv;
1082 } 1088 }
1083 1089
1090 dev_priv->mm.gtt_mapping =
1091 io_mapping_create_wc(dev->agp->base,
1092 dev->agp->agp_info.aper_size * 1024*1024);
1093 /* Set up a WC MTRR for non-PAT systems. This is more common than
1094 * one would think, because the kernel disables PAT on first
1095 * generation Core chips because WC PAT gets overridden by a UC
1096 * MTRR if present. Even if a UC MTRR isn't present.
1097 */
1098 dev_priv->mm.gtt_mtrr = mtrr_add(dev->agp->base,
1099 dev->agp->agp_info.aper_size *
1100 1024 * 1024,
1101 MTRR_TYPE_WRCOMB, 1);
1102 if (dev_priv->mm.gtt_mtrr < 0) {
1103 DRM_INFO("MTRR allocation failed\n. Graphics "
1104 "performance may suffer.\n");
1105 }
1106
1084#ifdef CONFIG_HIGHMEM64G 1107#ifdef CONFIG_HIGHMEM64G
1085 /* don't enable GEM on PAE - needs agp + set_memory_* interface fixes */ 1108 /* don't enable GEM on PAE - needs agp + set_memory_* interface fixes */
1086 dev_priv->has_gem = 0; 1109 dev_priv->has_gem = 0;
@@ -1089,6 +1112,10 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1089 dev_priv->has_gem = 1; 1112 dev_priv->has_gem = 1;
1090#endif 1113#endif
1091 1114
1115 dev->driver->get_vblank_counter = i915_get_vblank_counter;
1116 if (IS_GM45(dev))
1117 dev->driver->get_vblank_counter = gm45_get_vblank_counter;
1118
1092 i915_gem_load(dev); 1119 i915_gem_load(dev);
1093 1120
1094 /* Init HWS */ 1121 /* Init HWS */
@@ -1145,8 +1172,14 @@ int i915_driver_unload(struct drm_device *dev)
1145{ 1172{
1146 struct drm_i915_private *dev_priv = dev->dev_private; 1173 struct drm_i915_private *dev_priv = dev->dev_private;
1147 1174
1175 io_mapping_free(dev_priv->mm.gtt_mapping);
1176 if (dev_priv->mm.gtt_mtrr >= 0) {
1177 mtrr_del(dev_priv->mm.gtt_mtrr, dev->agp->base,
1178 dev->agp->agp_info.aper_size * 1024 * 1024);
1179 dev_priv->mm.gtt_mtrr = -1;
1180 }
1181
1148 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 1182 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
1149 io_mapping_free(dev_priv->mm.gtt_mapping);
1150 drm_irq_uninstall(dev); 1183 drm_irq_uninstall(dev);
1151 } 1184 }
1152 1185
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index f8b3df0926c..aac12ee31a4 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -112,7 +112,6 @@ static struct drm_driver driver = {
112 .suspend = i915_suspend, 112 .suspend = i915_suspend,
113 .resume = i915_resume, 113 .resume = i915_resume,
114 .device_is_agp = i915_driver_device_is_agp, 114 .device_is_agp = i915_driver_device_is_agp,
115 .get_vblank_counter = i915_get_vblank_counter,
116 .enable_vblank = i915_enable_vblank, 115 .enable_vblank = i915_enable_vblank,
117 .disable_vblank = i915_disable_vblank, 116 .disable_vblank = i915_disable_vblank,
118 .irq_preinstall = i915_driver_irq_preinstall, 117 .irq_preinstall = i915_driver_irq_preinstall,
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index e1351825200..7325363164f 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -284,6 +284,7 @@ typedef struct drm_i915_private {
284 struct drm_mm gtt_space; 284 struct drm_mm gtt_space;
285 285
286 struct io_mapping *gtt_mapping; 286 struct io_mapping *gtt_mapping;
287 int gtt_mtrr;
287 288
288 /** 289 /**
289 * List of objects currently involved in rendering from the 290 * List of objects currently involved in rendering from the
@@ -534,6 +535,7 @@ extern int i915_vblank_pipe_get(struct drm_device *dev, void *data,
534extern int i915_enable_vblank(struct drm_device *dev, int crtc); 535extern int i915_enable_vblank(struct drm_device *dev, int crtc);
535extern void i915_disable_vblank(struct drm_device *dev, int crtc); 536extern void i915_disable_vblank(struct drm_device *dev, int crtc);
536extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc); 537extern u32 i915_get_vblank_counter(struct drm_device *dev, int crtc);
538extern u32 gm45_get_vblank_counter(struct drm_device *dev, int crtc);
537extern int i915_vblank_swap(struct drm_device *dev, void *data, 539extern int i915_vblank_swap(struct drm_device *dev, void *data,
538 struct drm_file *file_priv); 540 struct drm_file *file_priv);
539extern void i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask); 541extern void i915_enable_irq(drm_i915_private_t *dev_priv, u32 mask);
@@ -601,6 +603,7 @@ int i915_gem_init_object(struct drm_gem_object *obj);
601void i915_gem_free_object(struct drm_gem_object *obj); 603void i915_gem_free_object(struct drm_gem_object *obj);
602int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment); 604int i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment);
603void i915_gem_object_unpin(struct drm_gem_object *obj); 605void i915_gem_object_unpin(struct drm_gem_object *obj);
606int i915_gem_object_unbind(struct drm_gem_object *obj);
604void i915_gem_lastclose(struct drm_device *dev); 607void i915_gem_lastclose(struct drm_device *dev);
605uint32_t i915_get_gem_seqno(struct drm_device *dev); 608uint32_t i915_get_gem_seqno(struct drm_device *dev);
606void i915_gem_retire_requests(struct drm_device *dev); 609void i915_gem_retire_requests(struct drm_device *dev);
@@ -784,6 +787,11 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
784 IS_I945GM(dev) || IS_I965GM(dev) || IS_GM45(dev)) 787 IS_I945GM(dev) || IS_I965GM(dev) || IS_GM45(dev))
785 788
786#define I915_NEED_GFX_HWS(dev) (IS_G33(dev) || IS_GM45(dev) || IS_G4X(dev)) 789#define I915_NEED_GFX_HWS(dev) (IS_G33(dev) || IS_GM45(dev) || IS_G4X(dev))
790/* With the 945 and later, Y tiling got adjusted so that it was 32 128-byte
791 * rows, which changed the alignment requirements and fence programming.
792 */
793#define HAS_128_BYTE_Y_TILING(dev) (IS_I9XX(dev) && !(IS_I915G(dev) || \
794 IS_I915GM(dev)))
787#define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev)) 795#define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev))
788 796
789#define PRIMARY_RINGBUFFER_SIZE (128*1024) 797#define PRIMARY_RINGBUFFER_SIZE (128*1024)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index debad5c04cc..81857665409 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -52,7 +52,7 @@ static void i915_gem_object_free_page_list(struct drm_gem_object *obj);
52static int i915_gem_object_wait_rendering(struct drm_gem_object *obj); 52static int i915_gem_object_wait_rendering(struct drm_gem_object *obj);
53static int i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, 53static int i915_gem_object_bind_to_gtt(struct drm_gem_object *obj,
54 unsigned alignment); 54 unsigned alignment);
55static void i915_gem_object_get_fence_reg(struct drm_gem_object *obj); 55static int i915_gem_object_get_fence_reg(struct drm_gem_object *obj, bool write);
56static void i915_gem_clear_fence_reg(struct drm_gem_object *obj); 56static void i915_gem_clear_fence_reg(struct drm_gem_object *obj);
57static int i915_gem_evict_something(struct drm_device *dev); 57static int i915_gem_evict_something(struct drm_device *dev);
58static int i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj, 58static int i915_gem_phys_pwrite(struct drm_device *dev, struct drm_gem_object *obj,
@@ -567,6 +567,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
567 pgoff_t page_offset; 567 pgoff_t page_offset;
568 unsigned long pfn; 568 unsigned long pfn;
569 int ret = 0; 569 int ret = 0;
570 bool write = !!(vmf->flags & FAULT_FLAG_WRITE);
570 571
571 /* We don't use vmf->pgoff since that has the fake offset */ 572 /* We don't use vmf->pgoff since that has the fake offset */
572 page_offset = ((unsigned long)vmf->virtual_address - vma->vm_start) >> 573 page_offset = ((unsigned long)vmf->virtual_address - vma->vm_start) >>
@@ -585,8 +586,13 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
585 586
586 /* Need a new fence register? */ 587 /* Need a new fence register? */
587 if (obj_priv->fence_reg == I915_FENCE_REG_NONE && 588 if (obj_priv->fence_reg == I915_FENCE_REG_NONE &&
588 obj_priv->tiling_mode != I915_TILING_NONE) 589 obj_priv->tiling_mode != I915_TILING_NONE) {
589 i915_gem_object_get_fence_reg(obj); 590 ret = i915_gem_object_get_fence_reg(obj, write);
591 if (ret) {
592 mutex_unlock(&dev->struct_mutex);
593 return VM_FAULT_SIGBUS;
594 }
595 }
590 596
591 pfn = ((dev->agp->base + obj_priv->gtt_offset) >> PAGE_SHIFT) + 597 pfn = ((dev->agp->base + obj_priv->gtt_offset) >> PAGE_SHIFT) +
592 page_offset; 598 page_offset;
@@ -1211,7 +1217,7 @@ i915_gem_object_wait_rendering(struct drm_gem_object *obj)
1211/** 1217/**
1212 * Unbinds an object from the GTT aperture. 1218 * Unbinds an object from the GTT aperture.
1213 */ 1219 */
1214static int 1220int
1215i915_gem_object_unbind(struct drm_gem_object *obj) 1221i915_gem_object_unbind(struct drm_gem_object *obj)
1216{ 1222{
1217 struct drm_device *dev = obj->dev; 1223 struct drm_device *dev = obj->dev;
@@ -1445,21 +1451,26 @@ static void i915_write_fence_reg(struct drm_i915_fence_reg *reg)
1445 drm_i915_private_t *dev_priv = dev->dev_private; 1451 drm_i915_private_t *dev_priv = dev->dev_private;
1446 struct drm_i915_gem_object *obj_priv = obj->driver_private; 1452 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1447 int regnum = obj_priv->fence_reg; 1453 int regnum = obj_priv->fence_reg;
1454 int tile_width;
1448 uint32_t val; 1455 uint32_t val;
1449 uint32_t pitch_val; 1456 uint32_t pitch_val;
1450 1457
1451 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) || 1458 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) ||
1452 (obj_priv->gtt_offset & (obj->size - 1))) { 1459 (obj_priv->gtt_offset & (obj->size - 1))) {
1453 WARN(1, "%s: object not 1M or size aligned\n", __func__); 1460 WARN(1, "%s: object 0x%08x not 1M or size (0x%zx) aligned\n",
1461 __func__, obj_priv->gtt_offset, obj->size);
1454 return; 1462 return;
1455 } 1463 }
1456 1464
1457 if (obj_priv->tiling_mode == I915_TILING_Y && (IS_I945G(dev) || 1465 if (obj_priv->tiling_mode == I915_TILING_Y &&
1458 IS_I945GM(dev) || 1466 HAS_128_BYTE_Y_TILING(dev))
1459 IS_G33(dev))) 1467 tile_width = 128;
1460 pitch_val = (obj_priv->stride / 128) - 1;
1461 else 1468 else
1462 pitch_val = (obj_priv->stride / 512) - 1; 1469 tile_width = 512;
1470
1471 /* Note: pitch better be a power of two tile widths */
1472 pitch_val = obj_priv->stride / tile_width;
1473 pitch_val = ffs(pitch_val) - 1;
1463 1474
1464 val = obj_priv->gtt_offset; 1475 val = obj_priv->gtt_offset;
1465 if (obj_priv->tiling_mode == I915_TILING_Y) 1476 if (obj_priv->tiling_mode == I915_TILING_Y)
@@ -1483,7 +1494,8 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *reg)
1483 1494
1484 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) || 1495 if ((obj_priv->gtt_offset & ~I915_FENCE_START_MASK) ||
1485 (obj_priv->gtt_offset & (obj->size - 1))) { 1496 (obj_priv->gtt_offset & (obj->size - 1))) {
1486 WARN(1, "%s: object not 1M or size aligned\n", __func__); 1497 WARN(1, "%s: object 0x%08x not 1M or size aligned\n",
1498 __func__, obj_priv->gtt_offset);
1487 return; 1499 return;
1488 } 1500 }
1489 1501
@@ -1503,6 +1515,7 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *reg)
1503/** 1515/**
1504 * i915_gem_object_get_fence_reg - set up a fence reg for an object 1516 * i915_gem_object_get_fence_reg - set up a fence reg for an object
1505 * @obj: object to map through a fence reg 1517 * @obj: object to map through a fence reg
1518 * @write: object is about to be written
1506 * 1519 *
1507 * When mapping objects through the GTT, userspace wants to be able to write 1520 * When mapping objects through the GTT, userspace wants to be able to write
1508 * to them without having to worry about swizzling if the object is tiled. 1521 * to them without having to worry about swizzling if the object is tiled.
@@ -1513,8 +1526,8 @@ static void i830_write_fence_reg(struct drm_i915_fence_reg *reg)
1513 * It then sets up the reg based on the object's properties: address, pitch 1526 * It then sets up the reg based on the object's properties: address, pitch
1514 * and tiling format. 1527 * and tiling format.
1515 */ 1528 */
1516static void 1529static int
1517i915_gem_object_get_fence_reg(struct drm_gem_object *obj) 1530i915_gem_object_get_fence_reg(struct drm_gem_object *obj, bool write)
1518{ 1531{
1519 struct drm_device *dev = obj->dev; 1532 struct drm_device *dev = obj->dev;
1520 struct drm_i915_private *dev_priv = dev->dev_private; 1533 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -1527,12 +1540,18 @@ i915_gem_object_get_fence_reg(struct drm_gem_object *obj)
1527 WARN(1, "allocating a fence for non-tiled object?\n"); 1540 WARN(1, "allocating a fence for non-tiled object?\n");
1528 break; 1541 break;
1529 case I915_TILING_X: 1542 case I915_TILING_X:
1530 WARN(obj_priv->stride & (512 - 1), 1543 if (!obj_priv->stride)
1531 "object is X tiled but has non-512B pitch\n"); 1544 return -EINVAL;
1545 WARN((obj_priv->stride & (512 - 1)),
1546 "object 0x%08x is X tiled but has non-512B pitch\n",
1547 obj_priv->gtt_offset);
1532 break; 1548 break;
1533 case I915_TILING_Y: 1549 case I915_TILING_Y:
1534 WARN(obj_priv->stride & (128 - 1), 1550 if (!obj_priv->stride)
1535 "object is Y tiled but has non-128B pitch\n"); 1551 return -EINVAL;
1552 WARN((obj_priv->stride & (128 - 1)),
1553 "object 0x%08x is Y tiled but has non-128B pitch\n",
1554 obj_priv->gtt_offset);
1536 break; 1555 break;
1537 } 1556 }
1538 1557
@@ -1563,10 +1582,11 @@ try_again:
1563 * objects to finish before trying again. 1582 * objects to finish before trying again.
1564 */ 1583 */
1565 if (i == dev_priv->num_fence_regs) { 1584 if (i == dev_priv->num_fence_regs) {
1566 ret = i915_gem_object_wait_rendering(reg->obj); 1585 ret = i915_gem_object_set_to_gtt_domain(reg->obj, 0);
1567 if (ret) { 1586 if (ret) {
1568 WARN(ret, "wait_rendering failed: %d\n", ret); 1587 WARN(ret != -ERESTARTSYS,
1569 return; 1588 "switch to GTT domain failed: %d\n", ret);
1589 return ret;
1570 } 1590 }
1571 goto try_again; 1591 goto try_again;
1572 } 1592 }
@@ -1591,6 +1611,8 @@ try_again:
1591 i915_write_fence_reg(reg); 1611 i915_write_fence_reg(reg);
1592 else 1612 else
1593 i830_write_fence_reg(reg); 1613 i830_write_fence_reg(reg);
1614
1615 return 0;
1594} 1616}
1595 1617
1596/** 1618/**
@@ -1631,7 +1653,7 @@ i915_gem_object_bind_to_gtt(struct drm_gem_object *obj, unsigned alignment)
1631 if (dev_priv->mm.suspended) 1653 if (dev_priv->mm.suspended)
1632 return -EBUSY; 1654 return -EBUSY;
1633 if (alignment == 0) 1655 if (alignment == 0)
1634 alignment = PAGE_SIZE; 1656 alignment = i915_gem_get_gtt_alignment(obj);
1635 if (alignment & (PAGE_SIZE - 1)) { 1657 if (alignment & (PAGE_SIZE - 1)) {
1636 DRM_ERROR("Invalid object alignment requested %u\n", alignment); 1658 DRM_ERROR("Invalid object alignment requested %u\n", alignment);
1637 return -EINVAL; 1659 return -EINVAL;
@@ -2652,6 +2674,14 @@ i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment)
2652 DRM_ERROR("Failure to bind: %d", ret); 2674 DRM_ERROR("Failure to bind: %d", ret);
2653 return ret; 2675 return ret;
2654 } 2676 }
2677 /*
2678 * Pre-965 chips need a fence register set up in order to
2679 * properly handle tiled surfaces.
2680 */
2681 if (!IS_I965G(dev) &&
2682 obj_priv->fence_reg == I915_FENCE_REG_NONE &&
2683 obj_priv->tiling_mode != I915_TILING_NONE)
2684 i915_gem_object_get_fence_reg(obj, true);
2655 } 2685 }
2656 obj_priv->pin_count++; 2686 obj_priv->pin_count++;
2657 2687
@@ -3229,10 +3259,6 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
3229 dev_priv->mm.wedged = 0; 3259 dev_priv->mm.wedged = 0;
3230 } 3260 }
3231 3261
3232 dev_priv->mm.gtt_mapping = io_mapping_create_wc(dev->agp->base,
3233 dev->agp->agp_info.aper_size
3234 * 1024 * 1024);
3235
3236 mutex_lock(&dev->struct_mutex); 3262 mutex_lock(&dev->struct_mutex);
3237 dev_priv->mm.suspended = 0; 3263 dev_priv->mm.suspended = 0;
3238 3264
@@ -3255,7 +3281,6 @@ int
3255i915_gem_leavevt_ioctl(struct drm_device *dev, void *data, 3281i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
3256 struct drm_file *file_priv) 3282 struct drm_file *file_priv)
3257{ 3283{
3258 drm_i915_private_t *dev_priv = dev->dev_private;
3259 int ret; 3284 int ret;
3260 3285
3261 if (drm_core_check_feature(dev, DRIVER_MODESET)) 3286 if (drm_core_check_feature(dev, DRIVER_MODESET))
@@ -3264,7 +3289,6 @@ i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
3264 ret = i915_gem_idle(dev); 3289 ret = i915_gem_idle(dev);
3265 drm_irq_uninstall(dev); 3290 drm_irq_uninstall(dev);
3266 3291
3267 io_mapping_free(dev_priv->mm.gtt_mapping);
3268 return ret; 3292 return ret;
3269} 3293}
3270 3294
@@ -3273,6 +3297,9 @@ i915_gem_lastclose(struct drm_device *dev)
3273{ 3297{
3274 int ret; 3298 int ret;
3275 3299
3300 if (drm_core_check_feature(dev, DRIVER_MODESET))
3301 return;
3302
3276 ret = i915_gem_idle(dev); 3303 ret = i915_gem_idle(dev);
3277 if (ret) 3304 if (ret)
3278 DRM_ERROR("failed to idle hardware: %d\n", ret); 3305 DRM_ERROR("failed to idle hardware: %d\n", ret);
@@ -3294,7 +3321,7 @@ i915_gem_load(struct drm_device *dev)
3294 /* Old X drivers will take 0-2 for front, back, depth buffers */ 3321 /* Old X drivers will take 0-2 for front, back, depth buffers */
3295 dev_priv->fence_reg_start = 3; 3322 dev_priv->fence_reg_start = 3;
3296 3323
3297 if (IS_I965G(dev)) 3324 if (IS_I965G(dev) || IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev))
3298 dev_priv->num_fence_regs = 16; 3325 dev_priv->num_fence_regs = 16;
3299 else 3326 else
3300 dev_priv->num_fence_regs = 8; 3327 dev_priv->num_fence_regs = 8;
diff --git a/drivers/gpu/drm/i915/i915_gem_tiling.c b/drivers/gpu/drm/i915/i915_gem_tiling.c
index 241f39b7f46..fa1685cba84 100644
--- a/drivers/gpu/drm/i915/i915_gem_tiling.c
+++ b/drivers/gpu/drm/i915/i915_gem_tiling.c
@@ -173,6 +173,73 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev)
173 dev_priv->mm.bit_6_swizzle_y = swizzle_y; 173 dev_priv->mm.bit_6_swizzle_y = swizzle_y;
174} 174}
175 175
176
177/**
178 * Returns the size of the fence for a tiled object of the given size.
179 */
180static int
181i915_get_fence_size(struct drm_device *dev, int size)
182{
183 int i;
184 int start;
185
186 if (IS_I965G(dev)) {
187 /* The 965 can have fences at any page boundary. */
188 return ALIGN(size, 4096);
189 } else {
190 /* Align the size to a power of two greater than the smallest
191 * fence size.
192 */
193 if (IS_I9XX(dev))
194 start = 1024 * 1024;
195 else
196 start = 512 * 1024;
197
198 for (i = start; i < size; i <<= 1)
199 ;
200
201 return i;
202 }
203}
204
205/* Check pitch constriants for all chips & tiling formats */
206static bool
207i915_tiling_ok(struct drm_device *dev, int stride, int size, int tiling_mode)
208{
209 int tile_width;
210
211 /* Linear is always fine */
212 if (tiling_mode == I915_TILING_NONE)
213 return true;
214
215 if (tiling_mode == I915_TILING_Y && HAS_128_BYTE_Y_TILING(dev))
216 tile_width = 128;
217 else
218 tile_width = 512;
219
220 /* 965+ just needs multiples of tile width */
221 if (IS_I965G(dev)) {
222 if (stride & (tile_width - 1))
223 return false;
224 return true;
225 }
226
227 /* Pre-965 needs power of two tile widths */
228 if (stride < tile_width)
229 return false;
230
231 if (stride & (stride - 1))
232 return false;
233
234 /* We don't handle the aperture area covered by the fence being bigger
235 * than the object size.
236 */
237 if (i915_get_fence_size(dev, size) != size)
238 return false;
239
240 return true;
241}
242
176/** 243/**
177 * Sets the tiling mode of an object, returning the required swizzling of 244 * Sets the tiling mode of an object, returning the required swizzling of
178 * bit 6 of addresses in the object. 245 * bit 6 of addresses in the object.
@@ -191,6 +258,11 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
191 return -EINVAL; 258 return -EINVAL;
192 obj_priv = obj->driver_private; 259 obj_priv = obj->driver_private;
193 260
261 if (!i915_tiling_ok(dev, args->stride, obj->size, args->tiling_mode)) {
262 drm_gem_object_unreference(obj);
263 return -EINVAL;
264 }
265
194 mutex_lock(&dev->struct_mutex); 266 mutex_lock(&dev->struct_mutex);
195 267
196 if (args->tiling_mode == I915_TILING_NONE) { 268 if (args->tiling_mode == I915_TILING_NONE) {
@@ -207,7 +279,24 @@ i915_gem_set_tiling(struct drm_device *dev, void *data,
207 args->swizzle_mode = I915_BIT_6_SWIZZLE_NONE; 279 args->swizzle_mode = I915_BIT_6_SWIZZLE_NONE;
208 } 280 }
209 } 281 }
210 obj_priv->tiling_mode = args->tiling_mode; 282 if (args->tiling_mode != obj_priv->tiling_mode) {
283 int ret;
284
285 /* Unbind the object, as switching tiling means we're
286 * switching the cache organization due to fencing, probably.
287 */
288 ret = i915_gem_object_unbind(obj);
289 if (ret != 0) {
290 WARN(ret != -ERESTARTSYS,
291 "failed to unbind object for tiling switch");
292 args->tiling_mode = obj_priv->tiling_mode;
293 mutex_unlock(&dev->struct_mutex);
294 drm_gem_object_unreference(obj);
295
296 return ret;
297 }
298 obj_priv->tiling_mode = args->tiling_mode;
299 }
211 obj_priv->stride = args->stride; 300 obj_priv->stride = args->stride;
212 301
213 mutex_unlock(&dev->struct_mutex); 302 mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 6290219de6c..548ff2c6643 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -174,6 +174,19 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
174 return count; 174 return count;
175} 175}
176 176
177u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
178{
179 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
180 int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45;
181
182 if (!i915_pipe_enabled(dev, pipe)) {
183 DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe);
184 return 0;
185 }
186
187 return I915_READ(reg);
188}
189
177irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) 190irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
178{ 191{
179 struct drm_device *dev = (struct drm_device *) arg; 192 struct drm_device *dev = (struct drm_device *) arg;
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 273162579e1..9d6539a868b 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -186,12 +186,12 @@
186#define FENCE_REG_830_0 0x2000 186#define FENCE_REG_830_0 0x2000
187#define I830_FENCE_START_MASK 0x07f80000 187#define I830_FENCE_START_MASK 0x07f80000
188#define I830_FENCE_TILING_Y_SHIFT 12 188#define I830_FENCE_TILING_Y_SHIFT 12
189#define I830_FENCE_SIZE_BITS(size) ((get_order(size >> 19) - 1) << 8) 189#define I830_FENCE_SIZE_BITS(size) ((ffs((size) >> 19) - 1) << 8)
190#define I830_FENCE_PITCH_SHIFT 4 190#define I830_FENCE_PITCH_SHIFT 4
191#define I830_FENCE_REG_VALID (1<<0) 191#define I830_FENCE_REG_VALID (1<<0)
192 192
193#define I915_FENCE_START_MASK 0x0ff00000 193#define I915_FENCE_START_MASK 0x0ff00000
194#define I915_FENCE_SIZE_BITS(size) ((get_order(size >> 20) - 1) << 8) 194#define I915_FENCE_SIZE_BITS(size) ((ffs((size) >> 20) - 1) << 8)
195 195
196#define FENCE_REG_965_0 0x03000 196#define FENCE_REG_965_0 0x03000
197#define I965_FENCE_PITCH_SHIFT 2 197#define I965_FENCE_PITCH_SHIFT 2
@@ -1371,6 +1371,9 @@
1371#define PIPE_FRAME_LOW_SHIFT 24 1371#define PIPE_FRAME_LOW_SHIFT 24
1372#define PIPE_PIXEL_MASK 0x00ffffff 1372#define PIPE_PIXEL_MASK 0x00ffffff
1373#define PIPE_PIXEL_SHIFT 0 1373#define PIPE_PIXEL_SHIFT 0
1374/* GM45+ just has to be different */
1375#define PIPEA_FRMCOUNT_GM45 0x70040
1376#define PIPEA_FLIPCOUNT_GM45 0x70044
1374 1377
1375/* Cursor A & B regs */ 1378/* Cursor A & B regs */
1376#define CURACNTR 0x70080 1379#define CURACNTR 0x70080
@@ -1439,6 +1442,9 @@
1439#define PIPEBSTAT 0x71024 1442#define PIPEBSTAT 0x71024
1440#define PIPEBFRAMEHIGH 0x71040 1443#define PIPEBFRAMEHIGH 0x71040
1441#define PIPEBFRAMEPIXEL 0x71044 1444#define PIPEBFRAMEPIXEL 0x71044
1445#define PIPEB_FRMCOUNT_GM45 0x71040
1446#define PIPEB_FLIPCOUNT_GM45 0x71044
1447
1442 1448
1443/* Display B control */ 1449/* Display B control */
1444#define DSPBCNTR 0x71180 1450#define DSPBCNTR 0x71180
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 31c3732b7a6..bbdd72909a1 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -755,6 +755,8 @@ static void intel_crtc_mode_set(struct drm_crtc *crtc,
755 case INTEL_OUTPUT_SDVO: 755 case INTEL_OUTPUT_SDVO:
756 case INTEL_OUTPUT_HDMI: 756 case INTEL_OUTPUT_HDMI:
757 is_sdvo = true; 757 is_sdvo = true;
758 if (intel_output->needs_tv_clock)
759 is_tv = true;
758 break; 760 break;
759 case INTEL_OUTPUT_DVO: 761 case INTEL_OUTPUT_DVO:
760 is_dvo = true; 762 is_dvo = true;
@@ -1452,6 +1454,7 @@ static int intel_connector_clones(struct drm_device *dev, int type_mask)
1452 1454
1453static void intel_setup_outputs(struct drm_device *dev) 1455static void intel_setup_outputs(struct drm_device *dev)
1454{ 1456{
1457 struct drm_i915_private *dev_priv = dev->dev_private;
1455 struct drm_connector *connector; 1458 struct drm_connector *connector;
1456 1459
1457 intel_crt_init(dev); 1460 intel_crt_init(dev);
@@ -1463,13 +1466,16 @@ static void intel_setup_outputs(struct drm_device *dev)
1463 if (IS_I9XX(dev)) { 1466 if (IS_I9XX(dev)) {
1464 int found; 1467 int found;
1465 1468
1466 found = intel_sdvo_init(dev, SDVOB); 1469 if (I915_READ(SDVOB) & SDVO_DETECTED) {
1467 if (!found && SUPPORTS_INTEGRATED_HDMI(dev)) 1470 found = intel_sdvo_init(dev, SDVOB);
1468 intel_hdmi_init(dev, SDVOB); 1471 if (!found && SUPPORTS_INTEGRATED_HDMI(dev))
1469 1472 intel_hdmi_init(dev, SDVOB);
1470 found = intel_sdvo_init(dev, SDVOC); 1473 }
1471 if (!found && SUPPORTS_INTEGRATED_HDMI(dev)) 1474 if (!IS_G4X(dev) || (I915_READ(SDVOB) & SDVO_DETECTED)) {
1472 intel_hdmi_init(dev, SDVOC); 1475 found = intel_sdvo_init(dev, SDVOC);
1476 if (!found && SUPPORTS_INTEGRATED_HDMI(dev))
1477 intel_hdmi_init(dev, SDVOC);
1478 }
1473 } else 1479 } else
1474 intel_dvo_init(dev); 1480 intel_dvo_init(dev);
1475 1481
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 8a4cc50c5b4..957daef8edf 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -82,6 +82,7 @@ struct intel_output {
82 struct intel_i2c_chan *i2c_bus; /* for control functions */ 82 struct intel_i2c_chan *i2c_bus; /* for control functions */
83 struct intel_i2c_chan *ddc_bus; /* for DDC only stuff */ 83 struct intel_i2c_chan *ddc_bus; /* for DDC only stuff */
84 bool load_detect_temp; 84 bool load_detect_temp;
85 bool needs_tv_clock;
85 void *dev_priv; 86 void *dev_priv;
86}; 87};
87 88
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index b36a5214d8d..6d4f9126535 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -27,6 +27,7 @@
27 * Jesse Barnes <jesse.barnes@intel.com> 27 * Jesse Barnes <jesse.barnes@intel.com>
28 */ 28 */
29 29
30#include <linux/dmi.h>
30#include <linux/i2c.h> 31#include <linux/i2c.h>
31#include "drmP.h" 32#include "drmP.h"
32#include "drm.h" 33#include "drm.h"
@@ -311,10 +312,8 @@ static int intel_lvds_get_modes(struct drm_connector *connector)
311 if (dev_priv->panel_fixed_mode != NULL) { 312 if (dev_priv->panel_fixed_mode != NULL) {
312 struct drm_display_mode *mode; 313 struct drm_display_mode *mode;
313 314
314 mutex_lock(&dev->mode_config.mutex);
315 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode); 315 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode);
316 drm_mode_probed_add(connector, mode); 316 drm_mode_probed_add(connector, mode);
317 mutex_unlock(&dev->mode_config.mutex);
318 317
319 return 1; 318 return 1;
320 } 319 }
@@ -405,6 +404,16 @@ void intel_lvds_init(struct drm_device *dev)
405 u32 lvds; 404 u32 lvds;
406 int pipe; 405 int pipe;
407 406
407 /* Blacklist machines that we know falsely report LVDS. */
408 /* FIXME: add a check for the Aopen Mini PC */
409
410 /* Apple Mac Mini Core Duo and Mac Mini Core 2 Duo */
411 if(dmi_match(DMI_PRODUCT_NAME, "Macmini1,1") ||
412 dmi_match(DMI_PRODUCT_NAME, "Macmini2,1")) {
413 DRM_DEBUG("Skipping LVDS initialization for Apple Mac Mini\n");
414 return;
415 }
416
408 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); 417 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
409 if (!intel_output) { 418 if (!intel_output) {
410 return; 419 return;
@@ -458,7 +467,7 @@ void intel_lvds_init(struct drm_device *dev)
458 dev_priv->panel_fixed_mode = 467 dev_priv->panel_fixed_mode =
459 drm_mode_duplicate(dev, scan); 468 drm_mode_duplicate(dev, scan);
460 mutex_unlock(&dev->mode_config.mutex); 469 mutex_unlock(&dev->mode_config.mutex);
461 goto out; /* FIXME: check for quirks */ 470 goto out;
462 } 471 }
463 mutex_unlock(&dev->mode_config.mutex); 472 mutex_unlock(&dev->mode_config.mutex);
464 } 473 }
@@ -492,7 +501,7 @@ void intel_lvds_init(struct drm_device *dev)
492 if (dev_priv->panel_fixed_mode) { 501 if (dev_priv->panel_fixed_mode) {
493 dev_priv->panel_fixed_mode->type |= 502 dev_priv->panel_fixed_mode->type |=
494 DRM_MODE_TYPE_PREFERRED; 503 DRM_MODE_TYPE_PREFERRED;
495 goto out; /* FIXME: check for quirks */ 504 goto out;
496 } 505 }
497 } 506 }
498 507
@@ -500,38 +509,6 @@ void intel_lvds_init(struct drm_device *dev)
500 if (!dev_priv->panel_fixed_mode) 509 if (!dev_priv->panel_fixed_mode)
501 goto failed; 510 goto failed;
502 511
503 /* FIXME: detect aopen & mac mini type stuff automatically? */
504 /*
505 * Blacklist machines with BIOSes that list an LVDS panel without
506 * actually having one.
507 */
508 if (IS_I945GM(dev)) {
509 /* aopen mini pc */
510 if (dev->pdev->subsystem_vendor == 0xa0a0)
511 goto failed;
512
513 if ((dev->pdev->subsystem_vendor == 0x8086) &&
514 (dev->pdev->subsystem_device == 0x7270)) {
515 /* It's a Mac Mini or Macbook Pro.
516 *
517 * Apple hardware is out to get us. The macbook pro
518 * has a real LVDS panel, but the mac mini does not,
519 * and they have the same device IDs. We'll
520 * distinguish by panel size, on the assumption
521 * that Apple isn't about to make any machines with an
522 * 800x600 display.
523 */
524
525 if (dev_priv->panel_fixed_mode != NULL &&
526 dev_priv->panel_fixed_mode->hdisplay == 800 &&
527 dev_priv->panel_fixed_mode->vdisplay == 600) {
528 DRM_DEBUG("Suspected Mac Mini, ignoring the LVDS\n");
529 goto failed;
530 }
531 }
532 }
533
534
535out: 512out:
536 drm_sysfs_connector_add(connector); 513 drm_sysfs_connector_add(connector);
537 return; 514 return;
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 40721546910..a30508b639b 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -40,13 +40,59 @@
40struct intel_sdvo_priv { 40struct intel_sdvo_priv {
41 struct intel_i2c_chan *i2c_bus; 41 struct intel_i2c_chan *i2c_bus;
42 int slaveaddr; 42 int slaveaddr;
43
44 /* Register for the SDVO device: SDVOB or SDVOC */
43 int output_device; 45 int output_device;
44 46
45 u16 active_outputs; 47 /* Active outputs controlled by this SDVO output */
48 uint16_t controlled_output;
46 49
50 /*
51 * Capabilities of the SDVO device returned by
52 * i830_sdvo_get_capabilities()
53 */
47 struct intel_sdvo_caps caps; 54 struct intel_sdvo_caps caps;
55
56 /* Pixel clock limitations reported by the SDVO device, in kHz */
48 int pixel_clock_min, pixel_clock_max; 57 int pixel_clock_min, pixel_clock_max;
49 58
59 /**
60 * This is set if we're going to treat the device as TV-out.
61 *
62 * While we have these nice friendly flags for output types that ought
63 * to decide this for us, the S-Video output on our HDMI+S-Video card
64 * shows up as RGB1 (VGA).
65 */
66 bool is_tv;
67
68 /**
69 * This is set if we treat the device as HDMI, instead of DVI.
70 */
71 bool is_hdmi;
72
73 /**
74 * Returned SDTV resolutions allowed for the current format, if the
75 * device reported it.
76 */
77 struct intel_sdvo_sdtv_resolution_reply sdtv_resolutions;
78
79 /**
80 * Current selected TV format.
81 *
82 * This is stored in the same structure that's passed to the device, for
83 * convenience.
84 */
85 struct intel_sdvo_tv_format tv_format;
86
87 /*
88 * supported encoding mode, used to determine whether HDMI is
89 * supported
90 */
91 struct intel_sdvo_encode encode;
92
93 /* DDC bus used by this SDVO output */
94 uint8_t ddc_bus;
95
50 int save_sdvo_mult; 96 int save_sdvo_mult;
51 u16 save_active_outputs; 97 u16 save_active_outputs;
52 struct intel_sdvo_dtd save_input_dtd_1, save_input_dtd_2; 98 struct intel_sdvo_dtd save_input_dtd_1, save_input_dtd_2;
@@ -148,8 +194,8 @@ static bool intel_sdvo_write_byte(struct intel_output *intel_output, int addr,
148#define SDVO_CMD_NAME_ENTRY(cmd) {cmd, #cmd} 194#define SDVO_CMD_NAME_ENTRY(cmd) {cmd, #cmd}
149/** Mapping of command numbers to names, for debug output */ 195/** Mapping of command numbers to names, for debug output */
150const static struct _sdvo_cmd_name { 196const static struct _sdvo_cmd_name {
151 u8 cmd; 197 u8 cmd;
152 char *name; 198 char *name;
153} sdvo_cmd_names[] = { 199} sdvo_cmd_names[] = {
154 SDVO_CMD_NAME_ENTRY(SDVO_CMD_RESET), 200 SDVO_CMD_NAME_ENTRY(SDVO_CMD_RESET),
155 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_DEVICE_CAPS), 201 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_DEVICE_CAPS),
@@ -186,8 +232,35 @@ const static struct _sdvo_cmd_name {
186 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_TV_FORMATS), 232 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_TV_FORMATS),
187 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_TV_FORMAT), 233 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_TV_FORMAT),
188 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TV_FORMAT), 234 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TV_FORMAT),
189 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_TV_RESOLUTION_SUPPORT), 235 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_POWER_STATES),
236 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_POWER_STATE),
237 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ENCODER_POWER_STATE),
238 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_DISPLAY_POWER_STATE),
190 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_CONTROL_BUS_SWITCH), 239 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_CONTROL_BUS_SWITCH),
240 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT),
241 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SCALED_HDTV_RESOLUTION_SUPPORT),
242 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS),
243 /* HDMI op code */
244 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_SUPP_ENCODE),
245 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_ENCODE),
246 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_ENCODE),
247 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_PIXEL_REPLI),
248 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_PIXEL_REPLI),
249 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_COLORIMETRY_CAP),
250 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_COLORIMETRY),
251 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_COLORIMETRY),
252 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_AUDIO_ENCRYPT_PREFER),
253 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_AUDIO_STAT),
254 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_AUDIO_STAT),
255 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_INDEX),
256 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_INDEX),
257 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_INFO),
258 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_AV_SPLIT),
259 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_AV_SPLIT),
260 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_TXRATE),
261 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_TXRATE),
262 SDVO_CMD_NAME_ENTRY(SDVO_CMD_SET_HBUF_DATA),
263 SDVO_CMD_NAME_ENTRY(SDVO_CMD_GET_HBUF_DATA),
191}; 264};
192 265
193#define SDVO_NAME(dev_priv) ((dev_priv)->output_device == SDVOB ? "SDVOB" : "SDVOC") 266#define SDVO_NAME(dev_priv) ((dev_priv)->output_device == SDVOB ? "SDVOB" : "SDVOC")
@@ -506,6 +579,50 @@ static bool intel_sdvo_set_output_timing(struct intel_output *intel_output,
506 SDVO_CMD_SET_OUTPUT_TIMINGS_PART1, dtd); 579 SDVO_CMD_SET_OUTPUT_TIMINGS_PART1, dtd);
507} 580}
508 581
582static bool
583intel_sdvo_create_preferred_input_timing(struct intel_output *output,
584 uint16_t clock,
585 uint16_t width,
586 uint16_t height)
587{
588 struct intel_sdvo_preferred_input_timing_args args;
589 uint8_t status;
590
591 args.clock = clock;
592 args.width = width;
593 args.height = height;
594 intel_sdvo_write_cmd(output, SDVO_CMD_CREATE_PREFERRED_INPUT_TIMING,
595 &args, sizeof(args));
596 status = intel_sdvo_read_response(output, NULL, 0);
597 if (status != SDVO_CMD_STATUS_SUCCESS)
598 return false;
599
600 return true;
601}
602
603static bool intel_sdvo_get_preferred_input_timing(struct intel_output *output,
604 struct intel_sdvo_dtd *dtd)
605{
606 bool status;
607
608 intel_sdvo_write_cmd(output, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART1,
609 NULL, 0);
610
611 status = intel_sdvo_read_response(output, &dtd->part1,
612 sizeof(dtd->part1));
613 if (status != SDVO_CMD_STATUS_SUCCESS)
614 return false;
615
616 intel_sdvo_write_cmd(output, SDVO_CMD_GET_PREFERRED_INPUT_TIMING_PART2,
617 NULL, 0);
618
619 status = intel_sdvo_read_response(output, &dtd->part2,
620 sizeof(dtd->part2));
621 if (status != SDVO_CMD_STATUS_SUCCESS)
622 return false;
623
624 return false;
625}
509 626
510static int intel_sdvo_get_clock_rate_mult(struct intel_output *intel_output) 627static int intel_sdvo_get_clock_rate_mult(struct intel_output *intel_output)
511{ 628{
@@ -536,36 +653,12 @@ static bool intel_sdvo_set_clock_rate_mult(struct intel_output *intel_output, u8
536 return true; 653 return true;
537} 654}
538 655
539static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder, 656static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
540 struct drm_display_mode *mode, 657 struct drm_display_mode *mode)
541 struct drm_display_mode *adjusted_mode)
542{
543 /* Make the CRTC code factor in the SDVO pixel multiplier. The SDVO
544 * device will be told of the multiplier during mode_set.
545 */
546 adjusted_mode->clock *= intel_sdvo_get_pixel_multiplier(mode);
547 return true;
548}
549
550static void intel_sdvo_mode_set(struct drm_encoder *encoder,
551 struct drm_display_mode *mode,
552 struct drm_display_mode *adjusted_mode)
553{ 658{
554 struct drm_device *dev = encoder->dev; 659 uint16_t width, height;
555 struct drm_i915_private *dev_priv = dev->dev_private; 660 uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len;
556 struct drm_crtc *crtc = encoder->crtc; 661 uint16_t h_sync_offset, v_sync_offset;
557 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
558 struct intel_output *intel_output = enc_to_intel_output(encoder);
559 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
560 u16 width, height;
561 u16 h_blank_len, h_sync_len, v_blank_len, v_sync_len;
562 u16 h_sync_offset, v_sync_offset;
563 u32 sdvox;
564 struct intel_sdvo_dtd output_dtd;
565 int sdvo_pixel_multiply;
566
567 if (!mode)
568 return;
569 662
570 width = mode->crtc_hdisplay; 663 width = mode->crtc_hdisplay;
571 height = mode->crtc_vdisplay; 664 height = mode->crtc_vdisplay;
@@ -580,93 +673,423 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
580 h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start; 673 h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start;
581 v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start; 674 v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start;
582 675
583 output_dtd.part1.clock = mode->clock / 10; 676 dtd->part1.clock = mode->clock / 10;
584 output_dtd.part1.h_active = width & 0xff; 677 dtd->part1.h_active = width & 0xff;
585 output_dtd.part1.h_blank = h_blank_len & 0xff; 678 dtd->part1.h_blank = h_blank_len & 0xff;
586 output_dtd.part1.h_high = (((width >> 8) & 0xf) << 4) | 679 dtd->part1.h_high = (((width >> 8) & 0xf) << 4) |
587 ((h_blank_len >> 8) & 0xf); 680 ((h_blank_len >> 8) & 0xf);
588 output_dtd.part1.v_active = height & 0xff; 681 dtd->part1.v_active = height & 0xff;
589 output_dtd.part1.v_blank = v_blank_len & 0xff; 682 dtd->part1.v_blank = v_blank_len & 0xff;
590 output_dtd.part1.v_high = (((height >> 8) & 0xf) << 4) | 683 dtd->part1.v_high = (((height >> 8) & 0xf) << 4) |
591 ((v_blank_len >> 8) & 0xf); 684 ((v_blank_len >> 8) & 0xf);
592 685
593 output_dtd.part2.h_sync_off = h_sync_offset; 686 dtd->part2.h_sync_off = h_sync_offset;
594 output_dtd.part2.h_sync_width = h_sync_len & 0xff; 687 dtd->part2.h_sync_width = h_sync_len & 0xff;
595 output_dtd.part2.v_sync_off_width = (v_sync_offset & 0xf) << 4 | 688 dtd->part2.v_sync_off_width = (v_sync_offset & 0xf) << 4 |
596 (v_sync_len & 0xf); 689 (v_sync_len & 0xf);
597 output_dtd.part2.sync_off_width_high = ((h_sync_offset & 0x300) >> 2) | 690 dtd->part2.sync_off_width_high = ((h_sync_offset & 0x300) >> 2) |
598 ((h_sync_len & 0x300) >> 4) | ((v_sync_offset & 0x30) >> 2) | 691 ((h_sync_len & 0x300) >> 4) | ((v_sync_offset & 0x30) >> 2) |
599 ((v_sync_len & 0x30) >> 4); 692 ((v_sync_len & 0x30) >> 4);
600 693
601 output_dtd.part2.dtd_flags = 0x18; 694 dtd->part2.dtd_flags = 0x18;
602 if (mode->flags & DRM_MODE_FLAG_PHSYNC) 695 if (mode->flags & DRM_MODE_FLAG_PHSYNC)
603 output_dtd.part2.dtd_flags |= 0x2; 696 dtd->part2.dtd_flags |= 0x2;
604 if (mode->flags & DRM_MODE_FLAG_PVSYNC) 697 if (mode->flags & DRM_MODE_FLAG_PVSYNC)
605 output_dtd.part2.dtd_flags |= 0x4; 698 dtd->part2.dtd_flags |= 0x4;
699
700 dtd->part2.sdvo_flags = 0;
701 dtd->part2.v_sync_off_high = v_sync_offset & 0xc0;
702 dtd->part2.reserved = 0;
703}
704
705static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode,
706 struct intel_sdvo_dtd *dtd)
707{
708 uint16_t width, height;
709 uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len;
710 uint16_t h_sync_offset, v_sync_offset;
711
712 width = mode->crtc_hdisplay;
713 height = mode->crtc_vdisplay;
714
715 /* do some mode translations */
716 h_blank_len = mode->crtc_hblank_end - mode->crtc_hblank_start;
717 h_sync_len = mode->crtc_hsync_end - mode->crtc_hsync_start;
718
719 v_blank_len = mode->crtc_vblank_end - mode->crtc_vblank_start;
720 v_sync_len = mode->crtc_vsync_end - mode->crtc_vsync_start;
721
722 h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start;
723 v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start;
724
725 mode->hdisplay = dtd->part1.h_active;
726 mode->hdisplay += ((dtd->part1.h_high >> 4) & 0x0f) << 8;
727 mode->hsync_start = mode->hdisplay + dtd->part2.h_sync_off;
728 mode->hsync_start += (dtd->part2.sync_off_width_high & 0xa0) << 2;
729 mode->hsync_end = mode->hsync_start + dtd->part2.h_sync_width;
730 mode->hsync_end += (dtd->part2.sync_off_width_high & 0x30) << 4;
731 mode->htotal = mode->hdisplay + dtd->part1.h_blank;
732 mode->htotal += (dtd->part1.h_high & 0xf) << 8;
733
734 mode->vdisplay = dtd->part1.v_active;
735 mode->vdisplay += ((dtd->part1.v_high >> 4) & 0x0f) << 8;
736 mode->vsync_start = mode->vdisplay;
737 mode->vsync_start += (dtd->part2.v_sync_off_width >> 4) & 0xf;
738 mode->vsync_start += (dtd->part2.sync_off_width_high & 0x0a) << 2;
739 mode->vsync_start += dtd->part2.v_sync_off_high & 0xc0;
740 mode->vsync_end = mode->vsync_start +
741 (dtd->part2.v_sync_off_width & 0xf);
742 mode->vsync_end += (dtd->part2.sync_off_width_high & 0x3) << 4;
743 mode->vtotal = mode->vdisplay + dtd->part1.v_blank;
744 mode->vtotal += (dtd->part1.v_high & 0xf) << 8;
745
746 mode->clock = dtd->part1.clock * 10;
747
748 mode->flags &= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
749 if (dtd->part2.dtd_flags & 0x2)
750 mode->flags |= DRM_MODE_FLAG_PHSYNC;
751 if (dtd->part2.dtd_flags & 0x4)
752 mode->flags |= DRM_MODE_FLAG_PVSYNC;
753}
754
755static bool intel_sdvo_get_supp_encode(struct intel_output *output,
756 struct intel_sdvo_encode *encode)
757{
758 uint8_t status;
759
760 intel_sdvo_write_cmd(output, SDVO_CMD_GET_SUPP_ENCODE, NULL, 0);
761 status = intel_sdvo_read_response(output, encode, sizeof(*encode));
762 if (status != SDVO_CMD_STATUS_SUCCESS) { /* non-support means DVI */
763 memset(encode, 0, sizeof(*encode));
764 return false;
765 }
766
767 return true;
768}
769
770static bool intel_sdvo_set_encode(struct intel_output *output, uint8_t mode)
771{
772 uint8_t status;
773
774 intel_sdvo_write_cmd(output, SDVO_CMD_SET_ENCODE, &mode, 1);
775 status = intel_sdvo_read_response(output, NULL, 0);
776
777 return (status == SDVO_CMD_STATUS_SUCCESS);
778}
779
780static bool intel_sdvo_set_colorimetry(struct intel_output *output,
781 uint8_t mode)
782{
783 uint8_t status;
784
785 intel_sdvo_write_cmd(output, SDVO_CMD_SET_COLORIMETRY, &mode, 1);
786 status = intel_sdvo_read_response(output, NULL, 0);
787
788 return (status == SDVO_CMD_STATUS_SUCCESS);
789}
790
791#if 0
792static void intel_sdvo_dump_hdmi_buf(struct intel_output *output)
793{
794 int i, j;
795 uint8_t set_buf_index[2];
796 uint8_t av_split;
797 uint8_t buf_size;
798 uint8_t buf[48];
799 uint8_t *pos;
800
801 intel_sdvo_write_cmd(output, SDVO_CMD_GET_HBUF_AV_SPLIT, NULL, 0);
802 intel_sdvo_read_response(output, &av_split, 1);
803
804 for (i = 0; i <= av_split; i++) {
805 set_buf_index[0] = i; set_buf_index[1] = 0;
806 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_INDEX,
807 set_buf_index, 2);
808 intel_sdvo_write_cmd(output, SDVO_CMD_GET_HBUF_INFO, NULL, 0);
809 intel_sdvo_read_response(output, &buf_size, 1);
810
811 pos = buf;
812 for (j = 0; j <= buf_size; j += 8) {
813 intel_sdvo_write_cmd(output, SDVO_CMD_GET_HBUF_DATA,
814 NULL, 0);
815 intel_sdvo_read_response(output, pos, 8);
816 pos += 8;
817 }
818 }
819}
820#endif
821
822static void intel_sdvo_set_hdmi_buf(struct intel_output *output, int index,
823 uint8_t *data, int8_t size, uint8_t tx_rate)
824{
825 uint8_t set_buf_index[2];
826
827 set_buf_index[0] = index;
828 set_buf_index[1] = 0;
829
830 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_INDEX, set_buf_index, 2);
831
832 for (; size > 0; size -= 8) {
833 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_DATA, data, 8);
834 data += 8;
835 }
836
837 intel_sdvo_write_cmd(output, SDVO_CMD_SET_HBUF_TXRATE, &tx_rate, 1);
838}
839
840static uint8_t intel_sdvo_calc_hbuf_csum(uint8_t *data, uint8_t size)
841{
842 uint8_t csum = 0;
843 int i;
844
845 for (i = 0; i < size; i++)
846 csum += data[i];
847
848 return 0x100 - csum;
849}
850
851#define DIP_TYPE_AVI 0x82
852#define DIP_VERSION_AVI 0x2
853#define DIP_LEN_AVI 13
854
855struct dip_infoframe {
856 uint8_t type;
857 uint8_t version;
858 uint8_t len;
859 uint8_t checksum;
860 union {
861 struct {
862 /* Packet Byte #1 */
863 uint8_t S:2;
864 uint8_t B:2;
865 uint8_t A:1;
866 uint8_t Y:2;
867 uint8_t rsvd1:1;
868 /* Packet Byte #2 */
869 uint8_t R:4;
870 uint8_t M:2;
871 uint8_t C:2;
872 /* Packet Byte #3 */
873 uint8_t SC:2;
874 uint8_t Q:2;
875 uint8_t EC:3;
876 uint8_t ITC:1;
877 /* Packet Byte #4 */
878 uint8_t VIC:7;
879 uint8_t rsvd2:1;
880 /* Packet Byte #5 */
881 uint8_t PR:4;
882 uint8_t rsvd3:4;
883 /* Packet Byte #6~13 */
884 uint16_t top_bar_end;
885 uint16_t bottom_bar_start;
886 uint16_t left_bar_end;
887 uint16_t right_bar_start;
888 } avi;
889 struct {
890 /* Packet Byte #1 */
891 uint8_t channel_count:3;
892 uint8_t rsvd1:1;
893 uint8_t coding_type:4;
894 /* Packet Byte #2 */
895 uint8_t sample_size:2; /* SS0, SS1 */
896 uint8_t sample_frequency:3;
897 uint8_t rsvd2:3;
898 /* Packet Byte #3 */
899 uint8_t coding_type_private:5;
900 uint8_t rsvd3:3;
901 /* Packet Byte #4 */
902 uint8_t channel_allocation;
903 /* Packet Byte #5 */
904 uint8_t rsvd4:3;
905 uint8_t level_shift:4;
906 uint8_t downmix_inhibit:1;
907 } audio;
908 uint8_t payload[28];
909 } __attribute__ ((packed)) u;
910} __attribute__((packed));
911
912static void intel_sdvo_set_avi_infoframe(struct intel_output *output,
913 struct drm_display_mode * mode)
914{
915 struct dip_infoframe avi_if = {
916 .type = DIP_TYPE_AVI,
917 .version = DIP_VERSION_AVI,
918 .len = DIP_LEN_AVI,
919 };
920
921 avi_if.checksum = intel_sdvo_calc_hbuf_csum((uint8_t *)&avi_if,
922 4 + avi_if.len);
923 intel_sdvo_set_hdmi_buf(output, 1, (uint8_t *)&avi_if, 4 + avi_if.len,
924 SDVO_HBUF_TX_VSYNC);
925}
926
927static bool intel_sdvo_mode_fixup(struct drm_encoder *encoder,
928 struct drm_display_mode *mode,
929 struct drm_display_mode *adjusted_mode)
930{
931 struct intel_output *output = enc_to_intel_output(encoder);
932 struct intel_sdvo_priv *dev_priv = output->dev_priv;
606 933
607 output_dtd.part2.sdvo_flags = 0; 934 if (!dev_priv->is_tv) {
608 output_dtd.part2.v_sync_off_high = v_sync_offset & 0xc0; 935 /* Make the CRTC code factor in the SDVO pixel multiplier. The
609 output_dtd.part2.reserved = 0; 936 * SDVO device will be told of the multiplier during mode_set.
937 */
938 adjusted_mode->clock *= intel_sdvo_get_pixel_multiplier(mode);
939 } else {
940 struct intel_sdvo_dtd output_dtd;
941 bool success;
942
943 /* We need to construct preferred input timings based on our
944 * output timings. To do that, we have to set the output
945 * timings, even though this isn't really the right place in
946 * the sequence to do it. Oh well.
947 */
948
949
950 /* Set output timings */
951 intel_sdvo_get_dtd_from_mode(&output_dtd, mode);
952 intel_sdvo_set_target_output(output,
953 dev_priv->controlled_output);
954 intel_sdvo_set_output_timing(output, &output_dtd);
955
956 /* Set the input timing to the screen. Assume always input 0. */
957 intel_sdvo_set_target_input(output, true, false);
958
959
960 success = intel_sdvo_create_preferred_input_timing(output,
961 mode->clock / 10,
962 mode->hdisplay,
963 mode->vdisplay);
964 if (success) {
965 struct intel_sdvo_dtd input_dtd;
610 966
611 /* Set the output timing to the screen */ 967 intel_sdvo_get_preferred_input_timing(output,
612 intel_sdvo_set_target_output(intel_output, sdvo_priv->active_outputs); 968 &input_dtd);
613 intel_sdvo_set_output_timing(intel_output, &output_dtd); 969 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd);
970
971 } else {
972 return false;
973 }
974 }
975 return true;
976}
977
978static void intel_sdvo_mode_set(struct drm_encoder *encoder,
979 struct drm_display_mode *mode,
980 struct drm_display_mode *adjusted_mode)
981{
982 struct drm_device *dev = encoder->dev;
983 struct drm_i915_private *dev_priv = dev->dev_private;
984 struct drm_crtc *crtc = encoder->crtc;
985 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
986 struct intel_output *output = enc_to_intel_output(encoder);
987 struct intel_sdvo_priv *sdvo_priv = output->dev_priv;
988 u32 sdvox = 0;
989 int sdvo_pixel_multiply;
990 struct intel_sdvo_in_out_map in_out;
991 struct intel_sdvo_dtd input_dtd;
992 u8 status;
993
994 if (!mode)
995 return;
996
997 /* First, set the input mapping for the first input to our controlled
998 * output. This is only correct if we're a single-input device, in
999 * which case the first input is the output from the appropriate SDVO
1000 * channel on the motherboard. In a two-input device, the first input
1001 * will be SDVOB and the second SDVOC.
1002 */
1003 in_out.in0 = sdvo_priv->controlled_output;
1004 in_out.in1 = 0;
1005
1006 intel_sdvo_write_cmd(output, SDVO_CMD_SET_IN_OUT_MAP,
1007 &in_out, sizeof(in_out));
1008 status = intel_sdvo_read_response(output, NULL, 0);
1009
1010 if (sdvo_priv->is_hdmi) {
1011 intel_sdvo_set_avi_infoframe(output, mode);
1012 sdvox |= SDVO_AUDIO_ENABLE;
1013 }
1014
1015 intel_sdvo_get_dtd_from_mode(&input_dtd, mode);
1016
1017 /* If it's a TV, we already set the output timing in mode_fixup.
1018 * Otherwise, the output timing is equal to the input timing.
1019 */
1020 if (!sdvo_priv->is_tv) {
1021 /* Set the output timing to the screen */
1022 intel_sdvo_set_target_output(output,
1023 sdvo_priv->controlled_output);
1024 intel_sdvo_set_output_timing(output, &input_dtd);
1025 }
614 1026
615 /* Set the input timing to the screen. Assume always input 0. */ 1027 /* Set the input timing to the screen. Assume always input 0. */
616 intel_sdvo_set_target_input(intel_output, true, false); 1028 intel_sdvo_set_target_input(output, true, false);
617 1029
618 /* We would like to use i830_sdvo_create_preferred_input_timing() to 1030 /* We would like to use intel_sdvo_create_preferred_input_timing() to
619 * provide the device with a timing it can support, if it supports that 1031 * provide the device with a timing it can support, if it supports that
620 * feature. However, presumably we would need to adjust the CRTC to 1032 * feature. However, presumably we would need to adjust the CRTC to
621 * output the preferred timing, and we don't support that currently. 1033 * output the preferred timing, and we don't support that currently.
622 */ 1034 */
623 intel_sdvo_set_input_timing(intel_output, &output_dtd); 1035#if 0
1036 success = intel_sdvo_create_preferred_input_timing(output, clock,
1037 width, height);
1038 if (success) {
1039 struct intel_sdvo_dtd *input_dtd;
1040
1041 intel_sdvo_get_preferred_input_timing(output, &input_dtd);
1042 intel_sdvo_set_input_timing(output, &input_dtd);
1043 }
1044#else
1045 intel_sdvo_set_input_timing(output, &input_dtd);
1046#endif
624 1047
625 switch (intel_sdvo_get_pixel_multiplier(mode)) { 1048 switch (intel_sdvo_get_pixel_multiplier(mode)) {
626 case 1: 1049 case 1:
627 intel_sdvo_set_clock_rate_mult(intel_output, 1050 intel_sdvo_set_clock_rate_mult(output,
628 SDVO_CLOCK_RATE_MULT_1X); 1051 SDVO_CLOCK_RATE_MULT_1X);
629 break; 1052 break;
630 case 2: 1053 case 2:
631 intel_sdvo_set_clock_rate_mult(intel_output, 1054 intel_sdvo_set_clock_rate_mult(output,
632 SDVO_CLOCK_RATE_MULT_2X); 1055 SDVO_CLOCK_RATE_MULT_2X);
633 break; 1056 break;
634 case 4: 1057 case 4:
635 intel_sdvo_set_clock_rate_mult(intel_output, 1058 intel_sdvo_set_clock_rate_mult(output,
636 SDVO_CLOCK_RATE_MULT_4X); 1059 SDVO_CLOCK_RATE_MULT_4X);
637 break; 1060 break;
638 } 1061 }
639 1062
640 /* Set the SDVO control regs. */ 1063 /* Set the SDVO control regs. */
641 if (0/*IS_I965GM(dev)*/) { 1064 if (IS_I965G(dev)) {
642 sdvox = SDVO_BORDER_ENABLE; 1065 sdvox |= SDVO_BORDER_ENABLE |
643 } else { 1066 SDVO_VSYNC_ACTIVE_HIGH |
644 sdvox = I915_READ(sdvo_priv->output_device); 1067 SDVO_HSYNC_ACTIVE_HIGH;
645 switch (sdvo_priv->output_device) { 1068 } else {
646 case SDVOB: 1069 sdvox |= I915_READ(sdvo_priv->output_device);
647 sdvox &= SDVOB_PRESERVE_MASK; 1070 switch (sdvo_priv->output_device) {
648 break; 1071 case SDVOB:
649 case SDVOC: 1072 sdvox &= SDVOB_PRESERVE_MASK;
650 sdvox &= SDVOC_PRESERVE_MASK; 1073 break;
651 break; 1074 case SDVOC:
652 } 1075 sdvox &= SDVOC_PRESERVE_MASK;
653 sdvox |= (9 << 19) | SDVO_BORDER_ENABLE; 1076 break;
654 } 1077 }
1078 sdvox |= (9 << 19) | SDVO_BORDER_ENABLE;
1079 }
655 if (intel_crtc->pipe == 1) 1080 if (intel_crtc->pipe == 1)
656 sdvox |= SDVO_PIPE_B_SELECT; 1081 sdvox |= SDVO_PIPE_B_SELECT;
657 1082
658 sdvo_pixel_multiply = intel_sdvo_get_pixel_multiplier(mode); 1083 sdvo_pixel_multiply = intel_sdvo_get_pixel_multiplier(mode);
659 if (IS_I965G(dev)) { 1084 if (IS_I965G(dev)) {
660 /* done in crtc_mode_set as the dpll_md reg must be written 1085 /* done in crtc_mode_set as the dpll_md reg must be written early */
661 early */ 1086 } else if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) {
662 } else if (IS_I945G(dev) || IS_I945GM(dev)) { 1087 /* done in crtc_mode_set as it lives inside the dpll register */
663 /* done in crtc_mode_set as it lives inside the
664 dpll register */
665 } else { 1088 } else {
666 sdvox |= (sdvo_pixel_multiply - 1) << SDVO_PORT_MULTIPLY_SHIFT; 1089 sdvox |= (sdvo_pixel_multiply - 1) << SDVO_PORT_MULTIPLY_SHIFT;
667 } 1090 }
668 1091
669 intel_sdvo_write_sdvox(intel_output, sdvox); 1092 intel_sdvo_write_sdvox(output, sdvox);
670} 1093}
671 1094
672static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode) 1095static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode)
@@ -714,7 +1137,7 @@ static void intel_sdvo_dpms(struct drm_encoder *encoder, int mode)
714 1137
715 if (0) 1138 if (0)
716 intel_sdvo_set_encoder_power_state(intel_output, mode); 1139 intel_sdvo_set_encoder_power_state(intel_output, mode);
717 intel_sdvo_set_active_outputs(intel_output, sdvo_priv->active_outputs); 1140 intel_sdvo_set_active_outputs(intel_output, sdvo_priv->controlled_output);
718 } 1141 }
719 return; 1142 return;
720} 1143}
@@ -752,6 +1175,9 @@ static void intel_sdvo_save(struct drm_connector *connector)
752 &sdvo_priv->save_output_dtd[o]); 1175 &sdvo_priv->save_output_dtd[o]);
753 } 1176 }
754 } 1177 }
1178 if (sdvo_priv->is_tv) {
1179 /* XXX: Save TV format/enhancements. */
1180 }
755 1181
756 sdvo_priv->save_SDVOX = I915_READ(sdvo_priv->output_device); 1182 sdvo_priv->save_SDVOX = I915_READ(sdvo_priv->output_device);
757} 1183}
@@ -759,7 +1185,6 @@ static void intel_sdvo_save(struct drm_connector *connector)
759static void intel_sdvo_restore(struct drm_connector *connector) 1185static void intel_sdvo_restore(struct drm_connector *connector)
760{ 1186{
761 struct drm_device *dev = connector->dev; 1187 struct drm_device *dev = connector->dev;
762 struct drm_i915_private *dev_priv = dev->dev_private;
763 struct intel_output *intel_output = to_intel_output(connector); 1188 struct intel_output *intel_output = to_intel_output(connector);
764 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1189 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
765 int o; 1190 int o;
@@ -790,7 +1215,11 @@ static void intel_sdvo_restore(struct drm_connector *connector)
790 1215
791 intel_sdvo_set_clock_rate_mult(intel_output, sdvo_priv->save_sdvo_mult); 1216 intel_sdvo_set_clock_rate_mult(intel_output, sdvo_priv->save_sdvo_mult);
792 1217
793 I915_WRITE(sdvo_priv->output_device, sdvo_priv->save_SDVOX); 1218 if (sdvo_priv->is_tv) {
1219 /* XXX: Restore TV format/enhancements. */
1220 }
1221
1222 intel_sdvo_write_sdvox(intel_output, sdvo_priv->save_SDVOX);
794 1223
795 if (sdvo_priv->save_SDVOX & SDVO_ENABLE) 1224 if (sdvo_priv->save_SDVOX & SDVO_ENABLE)
796 { 1225 {
@@ -916,20 +1345,173 @@ static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connect
916 status = intel_sdvo_read_response(intel_output, &response, 2); 1345 status = intel_sdvo_read_response(intel_output, &response, 2);
917 1346
918 DRM_DEBUG("SDVO response %d %d\n", response[0], response[1]); 1347 DRM_DEBUG("SDVO response %d %d\n", response[0], response[1]);
1348
1349 if (status != SDVO_CMD_STATUS_SUCCESS)
1350 return connector_status_unknown;
1351
919 if ((response[0] != 0) || (response[1] != 0)) 1352 if ((response[0] != 0) || (response[1] != 0))
920 return connector_status_connected; 1353 return connector_status_connected;
921 else 1354 else
922 return connector_status_disconnected; 1355 return connector_status_disconnected;
923} 1356}
924 1357
925static int intel_sdvo_get_modes(struct drm_connector *connector) 1358static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
926{ 1359{
927 struct intel_output *intel_output = to_intel_output(connector); 1360 struct intel_output *intel_output = to_intel_output(connector);
1361 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
928 1362
929 /* set the bus switch and get the modes */ 1363 /* set the bus switch and get the modes */
930 intel_sdvo_set_control_bus_switch(intel_output, SDVO_CONTROL_BUS_DDC2); 1364 intel_sdvo_set_control_bus_switch(intel_output, sdvo_priv->ddc_bus);
931 intel_ddc_get_modes(intel_output); 1365 intel_ddc_get_modes(intel_output);
932 1366
1367#if 0
1368 struct drm_device *dev = encoder->dev;
1369 struct drm_i915_private *dev_priv = dev->dev_private;
1370 /* Mac mini hack. On this device, I get DDC through the analog, which
1371 * load-detects as disconnected. I fail to DDC through the SDVO DDC,
1372 * but it does load-detect as connected. So, just steal the DDC bits
1373 * from analog when we fail at finding it the right way.
1374 */
1375 crt = xf86_config->output[0];
1376 intel_output = crt->driver_private;
1377 if (intel_output->type == I830_OUTPUT_ANALOG &&
1378 crt->funcs->detect(crt) == XF86OutputStatusDisconnected) {
1379 I830I2CInit(pScrn, &intel_output->pDDCBus, GPIOA, "CRTDDC_A");
1380 edid_mon = xf86OutputGetEDID(crt, intel_output->pDDCBus);
1381 xf86DestroyI2CBusRec(intel_output->pDDCBus, true, true);
1382 }
1383 if (edid_mon) {
1384 xf86OutputSetEDID(output, edid_mon);
1385 modes = xf86OutputGetEDIDModes(output);
1386 }
1387#endif
1388}
1389
1390/**
1391 * This function checks the current TV format, and chooses a default if
1392 * it hasn't been set.
1393 */
1394static void
1395intel_sdvo_check_tv_format(struct intel_output *output)
1396{
1397 struct intel_sdvo_priv *dev_priv = output->dev_priv;
1398 struct intel_sdvo_tv_format format, unset;
1399 uint8_t status;
1400
1401 intel_sdvo_write_cmd(output, SDVO_CMD_GET_TV_FORMAT, NULL, 0);
1402 status = intel_sdvo_read_response(output, &format, sizeof(format));
1403 if (status != SDVO_CMD_STATUS_SUCCESS)
1404 return;
1405
1406 memset(&unset, 0, sizeof(unset));
1407 if (memcmp(&format, &unset, sizeof(format))) {
1408 DRM_DEBUG("%s: Choosing default TV format of NTSC-M\n",
1409 SDVO_NAME(dev_priv));
1410
1411 format.ntsc_m = true;
1412 intel_sdvo_write_cmd(output, SDVO_CMD_SET_TV_FORMAT, NULL, 0);
1413 status = intel_sdvo_read_response(output, NULL, 0);
1414 }
1415}
1416
1417/*
1418 * Set of SDVO TV modes.
1419 * Note! This is in reply order (see loop in get_tv_modes).
1420 * XXX: all 60Hz refresh?
1421 */
1422struct drm_display_mode sdvo_tv_modes[] = {
1423 { DRM_MODE("320x200", DRM_MODE_TYPE_DRIVER, 5815680, 321, 384, 416,
1424 200, 0, 232, 201, 233, 4196112, 0,
1425 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1426 { DRM_MODE("320x240", DRM_MODE_TYPE_DRIVER, 6814080, 321, 384, 416,
1427 240, 0, 272, 241, 273, 4196112, 0,
1428 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1429 { DRM_MODE("400x300", DRM_MODE_TYPE_DRIVER, 9910080, 401, 464, 496,
1430 300, 0, 332, 301, 333, 4196112, 0,
1431 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1432 { DRM_MODE("640x350", DRM_MODE_TYPE_DRIVER, 16913280, 641, 704, 736,
1433 350, 0, 382, 351, 383, 4196112, 0,
1434 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1435 { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 19121280, 641, 704, 736,
1436 400, 0, 432, 401, 433, 4196112, 0,
1437 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1438 { DRM_MODE("640x400", DRM_MODE_TYPE_DRIVER, 19121280, 641, 704, 736,
1439 400, 0, 432, 401, 433, 4196112, 0,
1440 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1441 { DRM_MODE("704x480", DRM_MODE_TYPE_DRIVER, 24624000, 705, 768, 800,
1442 480, 0, 512, 481, 513, 4196112, 0,
1443 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1444 { DRM_MODE("704x576", DRM_MODE_TYPE_DRIVER, 29232000, 705, 768, 800,
1445 576, 0, 608, 577, 609, 4196112, 0,
1446 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1447 { DRM_MODE("720x350", DRM_MODE_TYPE_DRIVER, 18751680, 721, 784, 816,
1448 350, 0, 382, 351, 383, 4196112, 0,
1449 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1450 { DRM_MODE("720x400", DRM_MODE_TYPE_DRIVER, 21199680, 721, 784, 816,
1451 400, 0, 432, 401, 433, 4196112, 0,
1452 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1453 { DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 25116480, 721, 784, 816,
1454 480, 0, 512, 481, 513, 4196112, 0,
1455 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1456 { DRM_MODE("720x540", DRM_MODE_TYPE_DRIVER, 28054080, 721, 784, 816,
1457 540, 0, 572, 541, 573, 4196112, 0,
1458 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1459 { DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 29816640, 721, 784, 816,
1460 576, 0, 608, 577, 609, 4196112, 0,
1461 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1462 { DRM_MODE("768x576", DRM_MODE_TYPE_DRIVER, 31570560, 769, 832, 864,
1463 576, 0, 608, 577, 609, 4196112, 0,
1464 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1465 { DRM_MODE("800x600", DRM_MODE_TYPE_DRIVER, 34030080, 801, 864, 896,
1466 600, 0, 632, 601, 633, 4196112, 0,
1467 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1468 { DRM_MODE("832x624", DRM_MODE_TYPE_DRIVER, 36581760, 833, 896, 928,
1469 624, 0, 656, 625, 657, 4196112, 0,
1470 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1471 { DRM_MODE("920x766", DRM_MODE_TYPE_DRIVER, 48707040, 921, 984, 1016,
1472 766, 0, 798, 767, 799, 4196112, 0,
1473 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1474 { DRM_MODE("1024x768", DRM_MODE_TYPE_DRIVER, 53827200, 1025, 1088, 1120,
1475 768, 0, 800, 769, 801, 4196112, 0,
1476 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1477 { DRM_MODE("1280x1024", DRM_MODE_TYPE_DRIVER, 87265920, 1281, 1344, 1376,
1478 1024, 0, 1056, 1025, 1057, 4196112, 0,
1479 DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC) },
1480};
1481
1482static void intel_sdvo_get_tv_modes(struct drm_connector *connector)
1483{
1484 struct intel_output *output = to_intel_output(connector);
1485 uint32_t reply = 0;
1486 uint8_t status;
1487 int i = 0;
1488
1489 intel_sdvo_check_tv_format(output);
1490
1491 /* Read the list of supported input resolutions for the selected TV
1492 * format.
1493 */
1494 intel_sdvo_write_cmd(output, SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT,
1495 NULL, 0);
1496 status = intel_sdvo_read_response(output, &reply, 3);
1497 if (status != SDVO_CMD_STATUS_SUCCESS)
1498 return;
1499
1500 for (i = 0; i < ARRAY_SIZE(sdvo_tv_modes); i++)
1501 if (reply & (1 << i))
1502 drm_mode_probed_add(connector, &sdvo_tv_modes[i]);
1503}
1504
1505static int intel_sdvo_get_modes(struct drm_connector *connector)
1506{
1507 struct intel_output *output = to_intel_output(connector);
1508 struct intel_sdvo_priv *sdvo_priv = output->dev_priv;
1509
1510 if (sdvo_priv->is_tv)
1511 intel_sdvo_get_tv_modes(connector);
1512 else
1513 intel_sdvo_get_ddc_modes(connector);
1514
933 if (list_empty(&connector->probed_modes)) 1515 if (list_empty(&connector->probed_modes))
934 return 0; 1516 return 0;
935 return 1; 1517 return 1;
@@ -978,6 +1560,65 @@ static const struct drm_encoder_funcs intel_sdvo_enc_funcs = {
978}; 1560};
979 1561
980 1562
1563/**
1564 * Choose the appropriate DDC bus for control bus switch command for this
1565 * SDVO output based on the controlled output.
1566 *
1567 * DDC bus number assignment is in a priority order of RGB outputs, then TMDS
1568 * outputs, then LVDS outputs.
1569 */
1570static void
1571intel_sdvo_select_ddc_bus(struct intel_sdvo_priv *dev_priv)
1572{
1573 uint16_t mask = 0;
1574 unsigned int num_bits;
1575
1576 /* Make a mask of outputs less than or equal to our own priority in the
1577 * list.
1578 */
1579 switch (dev_priv->controlled_output) {
1580 case SDVO_OUTPUT_LVDS1:
1581 mask |= SDVO_OUTPUT_LVDS1;
1582 case SDVO_OUTPUT_LVDS0:
1583 mask |= SDVO_OUTPUT_LVDS0;
1584 case SDVO_OUTPUT_TMDS1:
1585 mask |= SDVO_OUTPUT_TMDS1;
1586 case SDVO_OUTPUT_TMDS0:
1587 mask |= SDVO_OUTPUT_TMDS0;
1588 case SDVO_OUTPUT_RGB1:
1589 mask |= SDVO_OUTPUT_RGB1;
1590 case SDVO_OUTPUT_RGB0:
1591 mask |= SDVO_OUTPUT_RGB0;
1592 break;
1593 }
1594
1595 /* Count bits to find what number we are in the priority list. */
1596 mask &= dev_priv->caps.output_flags;
1597 num_bits = hweight16(mask);
1598 if (num_bits > 3) {
1599 /* if more than 3 outputs, default to DDC bus 3 for now */
1600 num_bits = 3;
1601 }
1602
1603 /* Corresponds to SDVO_CONTROL_BUS_DDCx */
1604 dev_priv->ddc_bus = 1 << num_bits;
1605}
1606
1607static bool
1608intel_sdvo_get_digital_encoding_mode(struct intel_output *output)
1609{
1610 struct intel_sdvo_priv *sdvo_priv = output->dev_priv;
1611 uint8_t status;
1612
1613 intel_sdvo_set_target_output(output, sdvo_priv->controlled_output);
1614
1615 intel_sdvo_write_cmd(output, SDVO_CMD_GET_ENCODE, NULL, 0);
1616 status = intel_sdvo_read_response(output, &sdvo_priv->is_hdmi, 1);
1617 if (status != SDVO_CMD_STATUS_SUCCESS)
1618 return false;
1619 return true;
1620}
1621
981bool intel_sdvo_init(struct drm_device *dev, int output_device) 1622bool intel_sdvo_init(struct drm_device *dev, int output_device)
982{ 1623{
983 struct drm_connector *connector; 1624 struct drm_connector *connector;
@@ -1040,45 +1681,76 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1040 1681
1041 intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps); 1682 intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps);
1042 1683
1043 memset(&sdvo_priv->active_outputs, 0, sizeof(sdvo_priv->active_outputs)); 1684 if (sdvo_priv->caps.output_flags &
1685 (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)) {
1686 if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0)
1687 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS0;
1688 else
1689 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS1;
1690
1691 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1692 encoder_type = DRM_MODE_ENCODER_TMDS;
1693 connector_type = DRM_MODE_CONNECTOR_DVID;
1044 1694
1045 /* TODO, CVBS, SVID, YPRPB & SCART outputs. */ 1695 if (intel_sdvo_get_supp_encode(intel_output,
1046 if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0) 1696 &sdvo_priv->encode) &&
1697 intel_sdvo_get_digital_encoding_mode(intel_output) &&
1698 sdvo_priv->is_hdmi) {
1699 /* enable hdmi encoding mode if supported */
1700 intel_sdvo_set_encode(intel_output, SDVO_ENCODE_HDMI);
1701 intel_sdvo_set_colorimetry(intel_output,
1702 SDVO_COLORIMETRY_RGB256);
1703 connector_type = DRM_MODE_CONNECTOR_HDMIA;
1704 }
1705 }
1706 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_SVID0)
1047 { 1707 {
1048 sdvo_priv->active_outputs = SDVO_OUTPUT_RGB0; 1708 sdvo_priv->controlled_output = SDVO_OUTPUT_SVID0;
1709 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1710 encoder_type = DRM_MODE_ENCODER_TVDAC;
1711 connector_type = DRM_MODE_CONNECTOR_SVIDEO;
1712 sdvo_priv->is_tv = true;
1713 intel_output->needs_tv_clock = true;
1714 }
1715 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0)
1716 {
1717 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0;
1049 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1718 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1050 encoder_type = DRM_MODE_ENCODER_DAC; 1719 encoder_type = DRM_MODE_ENCODER_DAC;
1051 connector_type = DRM_MODE_CONNECTOR_VGA; 1720 connector_type = DRM_MODE_CONNECTOR_VGA;
1052 } 1721 }
1053 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1) 1722 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1)
1054 { 1723 {
1055 sdvo_priv->active_outputs = SDVO_OUTPUT_RGB1; 1724 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1;
1056 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1725 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1057 encoder_type = DRM_MODE_ENCODER_DAC; 1726 encoder_type = DRM_MODE_ENCODER_DAC;
1058 connector_type = DRM_MODE_CONNECTOR_VGA; 1727 connector_type = DRM_MODE_CONNECTOR_VGA;
1059 } 1728 }
1060 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0) 1729 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS0)
1061 { 1730 {
1062 sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS0; 1731 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0;
1063 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1732 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1064 encoder_type = DRM_MODE_ENCODER_TMDS; 1733 encoder_type = DRM_MODE_ENCODER_LVDS;
1065 connector_type = DRM_MODE_CONNECTOR_DVID; 1734 connector_type = DRM_MODE_CONNECTOR_LVDS;
1066 } 1735 }
1067 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS1) 1736 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS1)
1068 { 1737 {
1069 sdvo_priv->active_outputs = SDVO_OUTPUT_TMDS1; 1738 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS1;
1070 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 1739 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
1071 encoder_type = DRM_MODE_ENCODER_TMDS; 1740 encoder_type = DRM_MODE_ENCODER_LVDS;
1072 connector_type = DRM_MODE_CONNECTOR_DVID; 1741 connector_type = DRM_MODE_CONNECTOR_LVDS;
1073 } 1742 }
1074 else 1743 else
1075 { 1744 {
1076 unsigned char bytes[2]; 1745 unsigned char bytes[2];
1077 1746
1747 sdvo_priv->controlled_output = 0;
1078 memcpy (bytes, &sdvo_priv->caps.output_flags, 2); 1748 memcpy (bytes, &sdvo_priv->caps.output_flags, 2);
1079 DRM_DEBUG("%s: No active RGB or TMDS outputs (0x%02x%02x)\n", 1749 DRM_DEBUG("%s: Unknown SDVO output type (0x%02x%02x)\n",
1080 SDVO_NAME(sdvo_priv), 1750 SDVO_NAME(sdvo_priv),
1081 bytes[0], bytes[1]); 1751 bytes[0], bytes[1]);
1752 encoder_type = DRM_MODE_ENCODER_NONE;
1753 connector_type = DRM_MODE_CONNECTOR_Unknown;
1082 goto err_i2c; 1754 goto err_i2c;
1083 } 1755 }
1084 1756
@@ -1089,6 +1761,8 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1089 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); 1761 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc);
1090 drm_sysfs_connector_add(connector); 1762 drm_sysfs_connector_add(connector);
1091 1763
1764 intel_sdvo_select_ddc_bus(sdvo_priv);
1765
1092 /* Set the input timing to the screen. Assume always input 0. */ 1766 /* Set the input timing to the screen. Assume always input 0. */
1093 intel_sdvo_set_target_input(intel_output, true, false); 1767 intel_sdvo_set_target_input(intel_output, true, false);
1094 1768
diff --git a/drivers/gpu/drm/i915/intel_sdvo_regs.h b/drivers/gpu/drm/i915/intel_sdvo_regs.h
index 861a43f8693..1117b9c151a 100644
--- a/drivers/gpu/drm/i915/intel_sdvo_regs.h
+++ b/drivers/gpu/drm/i915/intel_sdvo_regs.h
@@ -173,6 +173,9 @@ struct intel_sdvo_get_trained_inputs_response {
173 * Returns two struct intel_sdvo_output_flags structures. 173 * Returns two struct intel_sdvo_output_flags structures.
174 */ 174 */
175#define SDVO_CMD_GET_IN_OUT_MAP 0x06 175#define SDVO_CMD_GET_IN_OUT_MAP 0x06
176struct intel_sdvo_in_out_map {
177 u16 in0, in1;
178};
176 179
177/** 180/**
178 * Sets the current mapping of SDVO inputs to outputs on the device. 181 * Sets the current mapping of SDVO inputs to outputs on the device.
@@ -206,7 +209,8 @@ struct intel_sdvo_get_trained_inputs_response {
206struct intel_sdvo_get_interrupt_event_source_response { 209struct intel_sdvo_get_interrupt_event_source_response {
207 u16 interrupt_status; 210 u16 interrupt_status;
208 unsigned int ambient_light_interrupt:1; 211 unsigned int ambient_light_interrupt:1;
209 unsigned int pad:7; 212 unsigned int hdmi_audio_encrypt_change:1;
213 unsigned int pad:6;
210} __attribute__((packed)); 214} __attribute__((packed));
211 215
212/** 216/**
@@ -305,23 +309,411 @@ struct intel_sdvo_set_target_input_args {
305# define SDVO_CLOCK_RATE_MULT_4X (1 << 3) 309# define SDVO_CLOCK_RATE_MULT_4X (1 << 3)
306 310
307#define SDVO_CMD_GET_SUPPORTED_TV_FORMATS 0x27 311#define SDVO_CMD_GET_SUPPORTED_TV_FORMATS 0x27
312/** 5 bytes of bit flags for TV formats shared by all TV format functions */
313struct intel_sdvo_tv_format {
314 unsigned int ntsc_m:1;
315 unsigned int ntsc_j:1;
316 unsigned int ntsc_443:1;
317 unsigned int pal_b:1;
318 unsigned int pal_d:1;
319 unsigned int pal_g:1;
320 unsigned int pal_h:1;
321 unsigned int pal_i:1;
322
323 unsigned int pal_m:1;
324 unsigned int pal_n:1;
325 unsigned int pal_nc:1;
326 unsigned int pal_60:1;
327 unsigned int secam_b:1;
328 unsigned int secam_d:1;
329 unsigned int secam_g:1;
330 unsigned int secam_k:1;
331
332 unsigned int secam_k1:1;
333 unsigned int secam_l:1;
334 unsigned int secam_60:1;
335 unsigned int hdtv_std_smpte_240m_1080i_59:1;
336 unsigned int hdtv_std_smpte_240m_1080i_60:1;
337 unsigned int hdtv_std_smpte_260m_1080i_59:1;
338 unsigned int hdtv_std_smpte_260m_1080i_60:1;
339 unsigned int hdtv_std_smpte_274m_1080i_50:1;
340
341 unsigned int hdtv_std_smpte_274m_1080i_59:1;
342 unsigned int hdtv_std_smpte_274m_1080i_60:1;
343 unsigned int hdtv_std_smpte_274m_1080p_23:1;
344 unsigned int hdtv_std_smpte_274m_1080p_24:1;
345 unsigned int hdtv_std_smpte_274m_1080p_25:1;
346 unsigned int hdtv_std_smpte_274m_1080p_29:1;
347 unsigned int hdtv_std_smpte_274m_1080p_30:1;
348 unsigned int hdtv_std_smpte_274m_1080p_50:1;
349
350 unsigned int hdtv_std_smpte_274m_1080p_59:1;
351 unsigned int hdtv_std_smpte_274m_1080p_60:1;
352 unsigned int hdtv_std_smpte_295m_1080i_50:1;
353 unsigned int hdtv_std_smpte_295m_1080p_50:1;
354 unsigned int hdtv_std_smpte_296m_720p_59:1;
355 unsigned int hdtv_std_smpte_296m_720p_60:1;
356 unsigned int hdtv_std_smpte_296m_720p_50:1;
357 unsigned int hdtv_std_smpte_293m_480p_59:1;
358
359 unsigned int hdtv_std_smpte_170m_480i_59:1;
360 unsigned int hdtv_std_iturbt601_576i_50:1;
361 unsigned int hdtv_std_iturbt601_576p_50:1;
362 unsigned int hdtv_std_eia_7702a_480i_60:1;
363 unsigned int hdtv_std_eia_7702a_480p_60:1;
364 unsigned int pad:3;
365} __attribute__((packed));
308 366
309#define SDVO_CMD_GET_TV_FORMAT 0x28 367#define SDVO_CMD_GET_TV_FORMAT 0x28
310 368
311#define SDVO_CMD_SET_TV_FORMAT 0x29 369#define SDVO_CMD_SET_TV_FORMAT 0x29
312 370
371/** Returns the resolutiosn that can be used with the given TV format */
372#define SDVO_CMD_GET_SDTV_RESOLUTION_SUPPORT 0x83
373struct intel_sdvo_sdtv_resolution_request {
374 unsigned int ntsc_m:1;
375 unsigned int ntsc_j:1;
376 unsigned int ntsc_443:1;
377 unsigned int pal_b:1;
378 unsigned int pal_d:1;
379 unsigned int pal_g:1;
380 unsigned int pal_h:1;
381 unsigned int pal_i:1;
382
383 unsigned int pal_m:1;
384 unsigned int pal_n:1;
385 unsigned int pal_nc:1;
386 unsigned int pal_60:1;
387 unsigned int secam_b:1;
388 unsigned int secam_d:1;
389 unsigned int secam_g:1;
390 unsigned int secam_k:1;
391
392 unsigned int secam_k1:1;
393 unsigned int secam_l:1;
394 unsigned int secam_60:1;
395 unsigned int pad:5;
396} __attribute__((packed));
397
398struct intel_sdvo_sdtv_resolution_reply {
399 unsigned int res_320x200:1;
400 unsigned int res_320x240:1;
401 unsigned int res_400x300:1;
402 unsigned int res_640x350:1;
403 unsigned int res_640x400:1;
404 unsigned int res_640x480:1;
405 unsigned int res_704x480:1;
406 unsigned int res_704x576:1;
407
408 unsigned int res_720x350:1;
409 unsigned int res_720x400:1;
410 unsigned int res_720x480:1;
411 unsigned int res_720x540:1;
412 unsigned int res_720x576:1;
413 unsigned int res_768x576:1;
414 unsigned int res_800x600:1;
415 unsigned int res_832x624:1;
416
417 unsigned int res_920x766:1;
418 unsigned int res_1024x768:1;
419 unsigned int res_1280x1024:1;
420 unsigned int pad:5;
421} __attribute__((packed));
422
423/* Get supported resolution with squire pixel aspect ratio that can be
424 scaled for the requested HDTV format */
425#define SDVO_CMD_GET_SCALED_HDTV_RESOLUTION_SUPPORT 0x85
426
427struct intel_sdvo_hdtv_resolution_request {
428 unsigned int hdtv_std_smpte_240m_1080i_59:1;
429 unsigned int hdtv_std_smpte_240m_1080i_60:1;
430 unsigned int hdtv_std_smpte_260m_1080i_59:1;
431 unsigned int hdtv_std_smpte_260m_1080i_60:1;
432 unsigned int hdtv_std_smpte_274m_1080i_50:1;
433 unsigned int hdtv_std_smpte_274m_1080i_59:1;
434 unsigned int hdtv_std_smpte_274m_1080i_60:1;
435 unsigned int hdtv_std_smpte_274m_1080p_23:1;
436
437 unsigned int hdtv_std_smpte_274m_1080p_24:1;
438 unsigned int hdtv_std_smpte_274m_1080p_25:1;
439 unsigned int hdtv_std_smpte_274m_1080p_29:1;
440 unsigned int hdtv_std_smpte_274m_1080p_30:1;
441 unsigned int hdtv_std_smpte_274m_1080p_50:1;
442 unsigned int hdtv_std_smpte_274m_1080p_59:1;
443 unsigned int hdtv_std_smpte_274m_1080p_60:1;
444 unsigned int hdtv_std_smpte_295m_1080i_50:1;
445
446 unsigned int hdtv_std_smpte_295m_1080p_50:1;
447 unsigned int hdtv_std_smpte_296m_720p_59:1;
448 unsigned int hdtv_std_smpte_296m_720p_60:1;
449 unsigned int hdtv_std_smpte_296m_720p_50:1;
450 unsigned int hdtv_std_smpte_293m_480p_59:1;
451 unsigned int hdtv_std_smpte_170m_480i_59:1;
452 unsigned int hdtv_std_iturbt601_576i_50:1;
453 unsigned int hdtv_std_iturbt601_576p_50:1;
454
455 unsigned int hdtv_std_eia_7702a_480i_60:1;
456 unsigned int hdtv_std_eia_7702a_480p_60:1;
457 unsigned int pad:6;
458} __attribute__((packed));
459
460struct intel_sdvo_hdtv_resolution_reply {
461 unsigned int res_640x480:1;
462 unsigned int res_800x600:1;
463 unsigned int res_1024x768:1;
464 unsigned int res_1280x960:1;
465 unsigned int res_1400x1050:1;
466 unsigned int res_1600x1200:1;
467 unsigned int res_1920x1440:1;
468 unsigned int res_2048x1536:1;
469
470 unsigned int res_2560x1920:1;
471 unsigned int res_3200x2400:1;
472 unsigned int res_3840x2880:1;
473 unsigned int pad1:5;
474
475 unsigned int res_848x480:1;
476 unsigned int res_1064x600:1;
477 unsigned int res_1280x720:1;
478 unsigned int res_1360x768:1;
479 unsigned int res_1704x960:1;
480 unsigned int res_1864x1050:1;
481 unsigned int res_1920x1080:1;
482 unsigned int res_2128x1200:1;
483
484 unsigned int res_2560x1400:1;
485 unsigned int res_2728x1536:1;
486 unsigned int res_3408x1920:1;
487 unsigned int res_4264x2400:1;
488 unsigned int res_5120x2880:1;
489 unsigned int pad2:3;
490
491 unsigned int res_768x480:1;
492 unsigned int res_960x600:1;
493 unsigned int res_1152x720:1;
494 unsigned int res_1124x768:1;
495 unsigned int res_1536x960:1;
496 unsigned int res_1680x1050:1;
497 unsigned int res_1728x1080:1;
498 unsigned int res_1920x1200:1;
499
500 unsigned int res_2304x1440:1;
501 unsigned int res_2456x1536:1;
502 unsigned int res_3072x1920:1;
503 unsigned int res_3840x2400:1;
504 unsigned int res_4608x2880:1;
505 unsigned int pad3:3;
506
507 unsigned int res_1280x1024:1;
508 unsigned int pad4:7;
509
510 unsigned int res_1280x768:1;
511 unsigned int pad5:7;
512} __attribute__((packed));
513
514/* Get supported power state returns info for encoder and monitor, rely on
515 last SetTargetInput and SetTargetOutput calls */
313#define SDVO_CMD_GET_SUPPORTED_POWER_STATES 0x2a 516#define SDVO_CMD_GET_SUPPORTED_POWER_STATES 0x2a
517/* Get power state returns info for encoder and monitor, rely on last
518 SetTargetInput and SetTargetOutput calls */
519#define SDVO_CMD_GET_POWER_STATE 0x2b
314#define SDVO_CMD_GET_ENCODER_POWER_STATE 0x2b 520#define SDVO_CMD_GET_ENCODER_POWER_STATE 0x2b
315#define SDVO_CMD_SET_ENCODER_POWER_STATE 0x2c 521#define SDVO_CMD_SET_ENCODER_POWER_STATE 0x2c
316# define SDVO_ENCODER_STATE_ON (1 << 0) 522# define SDVO_ENCODER_STATE_ON (1 << 0)
317# define SDVO_ENCODER_STATE_STANDBY (1 << 1) 523# define SDVO_ENCODER_STATE_STANDBY (1 << 1)
318# define SDVO_ENCODER_STATE_SUSPEND (1 << 2) 524# define SDVO_ENCODER_STATE_SUSPEND (1 << 2)
319# define SDVO_ENCODER_STATE_OFF (1 << 3) 525# define SDVO_ENCODER_STATE_OFF (1 << 3)
526# define SDVO_MONITOR_STATE_ON (1 << 4)
527# define SDVO_MONITOR_STATE_STANDBY (1 << 5)
528# define SDVO_MONITOR_STATE_SUSPEND (1 << 6)
529# define SDVO_MONITOR_STATE_OFF (1 << 7)
530
531#define SDVO_CMD_GET_MAX_PANEL_POWER_SEQUENCING 0x2d
532#define SDVO_CMD_GET_PANEL_POWER_SEQUENCING 0x2e
533#define SDVO_CMD_SET_PANEL_POWER_SEQUENCING 0x2f
534/**
535 * The panel power sequencing parameters are in units of milliseconds.
536 * The high fields are bits 8:9 of the 10-bit values.
537 */
538struct sdvo_panel_power_sequencing {
539 u8 t0;
540 u8 t1;
541 u8 t2;
542 u8 t3;
543 u8 t4;
544
545 unsigned int t0_high:2;
546 unsigned int t1_high:2;
547 unsigned int t2_high:2;
548 unsigned int t3_high:2;
549
550 unsigned int t4_high:2;
551 unsigned int pad:6;
552} __attribute__((packed));
553
554#define SDVO_CMD_GET_MAX_BACKLIGHT_LEVEL 0x30
555struct sdvo_max_backlight_reply {
556 u8 max_value;
557 u8 default_value;
558} __attribute__((packed));
559
560#define SDVO_CMD_GET_BACKLIGHT_LEVEL 0x31
561#define SDVO_CMD_SET_BACKLIGHT_LEVEL 0x32
562
563#define SDVO_CMD_GET_AMBIENT_LIGHT 0x33
564struct sdvo_get_ambient_light_reply {
565 u16 trip_low;
566 u16 trip_high;
567 u16 value;
568} __attribute__((packed));
569#define SDVO_CMD_SET_AMBIENT_LIGHT 0x34
570struct sdvo_set_ambient_light_reply {
571 u16 trip_low;
572 u16 trip_high;
573 unsigned int enable:1;
574 unsigned int pad:7;
575} __attribute__((packed));
576
577/* Set display power state */
578#define SDVO_CMD_SET_DISPLAY_POWER_STATE 0x7d
579# define SDVO_DISPLAY_STATE_ON (1 << 0)
580# define SDVO_DISPLAY_STATE_STANDBY (1 << 1)
581# define SDVO_DISPLAY_STATE_SUSPEND (1 << 2)
582# define SDVO_DISPLAY_STATE_OFF (1 << 3)
583
584#define SDVO_CMD_GET_SUPPORTED_ENHANCEMENTS 0x84
585struct intel_sdvo_enhancements_reply {
586 unsigned int flicker_filter:1;
587 unsigned int flicker_filter_adaptive:1;
588 unsigned int flicker_filter_2d:1;
589 unsigned int saturation:1;
590 unsigned int hue:1;
591 unsigned int brightness:1;
592 unsigned int contrast:1;
593 unsigned int overscan_h:1;
594
595 unsigned int overscan_v:1;
596 unsigned int position_h:1;
597 unsigned int position_v:1;
598 unsigned int sharpness:1;
599 unsigned int dot_crawl:1;
600 unsigned int dither:1;
601 unsigned int max_tv_chroma_filter:1;
602 unsigned int max_tv_luma_filter:1;
603} __attribute__((packed));
604
605/* Picture enhancement limits below are dependent on the current TV format,
606 * and thus need to be queried and set after it.
607 */
608#define SDVO_CMD_GET_MAX_FLICKER_FITER 0x4d
609#define SDVO_CMD_GET_MAX_ADAPTIVE_FLICKER_FITER 0x7b
610#define SDVO_CMD_GET_MAX_2D_FLICKER_FITER 0x52
611#define SDVO_CMD_GET_MAX_SATURATION 0x55
612#define SDVO_CMD_GET_MAX_HUE 0x58
613#define SDVO_CMD_GET_MAX_BRIGHTNESS 0x5b
614#define SDVO_CMD_GET_MAX_CONTRAST 0x5e
615#define SDVO_CMD_GET_MAX_OVERSCAN_H 0x61
616#define SDVO_CMD_GET_MAX_OVERSCAN_V 0x64
617#define SDVO_CMD_GET_MAX_POSITION_H 0x67
618#define SDVO_CMD_GET_MAX_POSITION_V 0x6a
619#define SDVO_CMD_GET_MAX_SHARPNESS_V 0x6d
620#define SDVO_CMD_GET_MAX_TV_CHROMA 0x74
621#define SDVO_CMD_GET_MAX_TV_LUMA 0x77
622struct intel_sdvo_enhancement_limits_reply {
623 u16 max_value;
624 u16 default_value;
625} __attribute__((packed));
320 626
321#define SDVO_CMD_SET_TV_RESOLUTION_SUPPORT 0x93 627#define SDVO_CMD_GET_LVDS_PANEL_INFORMATION 0x7f
628#define SDVO_CMD_SET_LVDS_PANEL_INFORMATION 0x80
629# define SDVO_LVDS_COLOR_DEPTH_18 (0 << 0)
630# define SDVO_LVDS_COLOR_DEPTH_24 (1 << 0)
631# define SDVO_LVDS_CONNECTOR_SPWG (0 << 2)
632# define SDVO_LVDS_CONNECTOR_OPENLDI (1 << 2)
633# define SDVO_LVDS_SINGLE_CHANNEL (0 << 4)
634# define SDVO_LVDS_DUAL_CHANNEL (1 << 4)
635
636#define SDVO_CMD_GET_FLICKER_FILTER 0x4e
637#define SDVO_CMD_SET_FLICKER_FILTER 0x4f
638#define SDVO_CMD_GET_ADAPTIVE_FLICKER_FITER 0x50
639#define SDVO_CMD_SET_ADAPTIVE_FLICKER_FITER 0x51
640#define SDVO_CMD_GET_2D_FLICKER_FITER 0x53
641#define SDVO_CMD_SET_2D_FLICKER_FITER 0x54
642#define SDVO_CMD_GET_SATURATION 0x56
643#define SDVO_CMD_SET_SATURATION 0x57
644#define SDVO_CMD_GET_HUE 0x59
645#define SDVO_CMD_SET_HUE 0x5a
646#define SDVO_CMD_GET_BRIGHTNESS 0x5c
647#define SDVO_CMD_SET_BRIGHTNESS 0x5d
648#define SDVO_CMD_GET_CONTRAST 0x5f
649#define SDVO_CMD_SET_CONTRAST 0x60
650#define SDVO_CMD_GET_OVERSCAN_H 0x62
651#define SDVO_CMD_SET_OVERSCAN_H 0x63
652#define SDVO_CMD_GET_OVERSCAN_V 0x65
653#define SDVO_CMD_SET_OVERSCAN_V 0x66
654#define SDVO_CMD_GET_POSITION_H 0x68
655#define SDVO_CMD_SET_POSITION_H 0x69
656#define SDVO_CMD_GET_POSITION_V 0x6b
657#define SDVO_CMD_SET_POSITION_V 0x6c
658#define SDVO_CMD_GET_SHARPNESS 0x6e
659#define SDVO_CMD_SET_SHARPNESS 0x6f
660#define SDVO_CMD_GET_TV_CHROMA 0x75
661#define SDVO_CMD_SET_TV_CHROMA 0x76
662#define SDVO_CMD_GET_TV_LUMA 0x78
663#define SDVO_CMD_SET_TV_LUMA 0x79
664struct intel_sdvo_enhancements_arg {
665 u16 value;
666}__attribute__((packed));
667
668#define SDVO_CMD_GET_DOT_CRAWL 0x70
669#define SDVO_CMD_SET_DOT_CRAWL 0x71
670# define SDVO_DOT_CRAWL_ON (1 << 0)
671# define SDVO_DOT_CRAWL_DEFAULT_ON (1 << 1)
672
673#define SDVO_CMD_GET_DITHER 0x72
674#define SDVO_CMD_SET_DITHER 0x73
675# define SDVO_DITHER_ON (1 << 0)
676# define SDVO_DITHER_DEFAULT_ON (1 << 1)
322 677
323#define SDVO_CMD_SET_CONTROL_BUS_SWITCH 0x7a 678#define SDVO_CMD_SET_CONTROL_BUS_SWITCH 0x7a
324# define SDVO_CONTROL_BUS_PROM 0x0 679# define SDVO_CONTROL_BUS_PROM (1 << 0)
325# define SDVO_CONTROL_BUS_DDC1 0x1 680# define SDVO_CONTROL_BUS_DDC1 (1 << 1)
326# define SDVO_CONTROL_BUS_DDC2 0x2 681# define SDVO_CONTROL_BUS_DDC2 (1 << 2)
327# define SDVO_CONTROL_BUS_DDC3 0x3 682# define SDVO_CONTROL_BUS_DDC3 (1 << 3)
683
684/* HDMI op codes */
685#define SDVO_CMD_GET_SUPP_ENCODE 0x9d
686#define SDVO_CMD_GET_ENCODE 0x9e
687#define SDVO_CMD_SET_ENCODE 0x9f
688 #define SDVO_ENCODE_DVI 0x0
689 #define SDVO_ENCODE_HDMI 0x1
690#define SDVO_CMD_SET_PIXEL_REPLI 0x8b
691#define SDVO_CMD_GET_PIXEL_REPLI 0x8c
692#define SDVO_CMD_GET_COLORIMETRY_CAP 0x8d
693#define SDVO_CMD_SET_COLORIMETRY 0x8e
694 #define SDVO_COLORIMETRY_RGB256 0x0
695 #define SDVO_COLORIMETRY_RGB220 0x1
696 #define SDVO_COLORIMETRY_YCrCb422 0x3
697 #define SDVO_COLORIMETRY_YCrCb444 0x4
698#define SDVO_CMD_GET_COLORIMETRY 0x8f
699#define SDVO_CMD_GET_AUDIO_ENCRYPT_PREFER 0x90
700#define SDVO_CMD_SET_AUDIO_STAT 0x91
701#define SDVO_CMD_GET_AUDIO_STAT 0x92
702#define SDVO_CMD_SET_HBUF_INDEX 0x93
703#define SDVO_CMD_GET_HBUF_INDEX 0x94
704#define SDVO_CMD_GET_HBUF_INFO 0x95
705#define SDVO_CMD_SET_HBUF_AV_SPLIT 0x96
706#define SDVO_CMD_GET_HBUF_AV_SPLIT 0x97
707#define SDVO_CMD_SET_HBUF_DATA 0x98
708#define SDVO_CMD_GET_HBUF_DATA 0x99
709#define SDVO_CMD_SET_HBUF_TXRATE 0x9a
710#define SDVO_CMD_GET_HBUF_TXRATE 0x9b
711 #define SDVO_HBUF_TX_DISABLED (0 << 6)
712 #define SDVO_HBUF_TX_ONCE (2 << 6)
713 #define SDVO_HBUF_TX_VSYNC (3 << 6)
714#define SDVO_CMD_GET_AUDIO_TX_INFO 0x9c
715
716struct intel_sdvo_encode{
717 u8 dvi_rev;
718 u8 hdmi_rev;
719} __attribute__ ((packed));
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index 63212d7bbc2..df4cf97e5d9 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -1039,9 +1039,9 @@ static int radeon_do_init_cp(struct drm_device *dev, drm_radeon_init_t *init,
1039 1039
1040#if __OS_HAS_AGP 1040#if __OS_HAS_AGP
1041 if (dev_priv->flags & RADEON_IS_AGP) { 1041 if (dev_priv->flags & RADEON_IS_AGP) {
1042 drm_core_ioremap(dev_priv->cp_ring, dev); 1042 drm_core_ioremap_wc(dev_priv->cp_ring, dev);
1043 drm_core_ioremap(dev_priv->ring_rptr, dev); 1043 drm_core_ioremap_wc(dev_priv->ring_rptr, dev);
1044 drm_core_ioremap(dev->agp_buffer_map, dev); 1044 drm_core_ioremap_wc(dev->agp_buffer_map, dev);
1045 if (!dev_priv->cp_ring->handle || 1045 if (!dev_priv->cp_ring->handle ||
1046 !dev_priv->ring_rptr->handle || 1046 !dev_priv->ring_rptr->handle ||
1047 !dev->agp_buffer_map->handle) { 1047 !dev->agp_buffer_map->handle) {
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 35561689ff3..ea2638b4198 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -13,11 +13,11 @@ menuconfig INPUT_KEYBOARD
13if INPUT_KEYBOARD 13if INPUT_KEYBOARD
14 14
15config KEYBOARD_ATKBD 15config KEYBOARD_ATKBD
16 tristate "AT keyboard" if EMBEDDED || !X86_PC 16 tristate "AT keyboard" if EMBEDDED || !X86
17 default y 17 default y
18 select SERIO 18 select SERIO
19 select SERIO_LIBPS2 19 select SERIO_LIBPS2
20 select SERIO_I8042 if X86_PC 20 select SERIO_I8042 if X86
21 select SERIO_GSCPS2 if GSC 21 select SERIO_GSCPS2 if GSC
22 help 22 help
23 Say Y here if you want to use a standard AT or PS/2 keyboard. Usually 23 Say Y here if you want to use a standard AT or PS/2 keyboard. Usually
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index 093c8c1bca7..9bef935ef19 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -17,7 +17,7 @@ config MOUSE_PS2
17 default y 17 default y
18 select SERIO 18 select SERIO
19 select SERIO_LIBPS2 19 select SERIO_LIBPS2
20 select SERIO_I8042 if X86_PC 20 select SERIO_I8042 if X86
21 select SERIO_GSCPS2 if GSC 21 select SERIO_GSCPS2 if GSC
22 help 22 help
23 Say Y here if you have a PS/2 mouse connected to your system. This 23 Say Y here if you have a PS/2 mouse connected to your system. This
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c
index 595ba8eb4a0..0b28141e43b 100644
--- a/drivers/isdn/hardware/mISDN/hfcmulti.c
+++ b/drivers/isdn/hardware/mISDN/hfcmulti.c
@@ -4599,6 +4599,7 @@ init_e1_port(struct hfc_multi *hc, struct hm_map *m)
4599 printk(KERN_ERR "%s: no memory for coeffs\n", 4599 printk(KERN_ERR "%s: no memory for coeffs\n",
4600 __func__); 4600 __func__);
4601 ret = -ENOMEM; 4601 ret = -ENOMEM;
4602 kfree(bch);
4602 goto free_chan; 4603 goto free_chan;
4603 } 4604 }
4604 bch->nr = ch; 4605 bch->nr = ch;
@@ -4767,6 +4768,7 @@ init_multi_port(struct hfc_multi *hc, int pt)
4767 printk(KERN_ERR "%s: no memory for coeffs\n", 4768 printk(KERN_ERR "%s: no memory for coeffs\n",
4768 __func__); 4769 __func__);
4769 ret = -ENOMEM; 4770 ret = -ENOMEM;
4771 kfree(bch);
4770 goto free_chan; 4772 goto free_chan;
4771 } 4773 }
4772 bch->nr = ch + 1; 4774 bch->nr = ch + 1;
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 8b12e6e109d..2ff88791ceb 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -273,7 +273,7 @@ config MTD_NAND_CAFE
273 273
274config MTD_NAND_CS553X 274config MTD_NAND_CS553X
275 tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)" 275 tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)"
276 depends on X86_32 && (X86_PC || X86_GENERICARCH) 276 depends on X86_32
277 help 277 help
278 The CS553x companion chips for the AMD Geode processor 278 The CS553x companion chips for the AMD Geode processor
279 include NAND flash controllers with built-in hardware ECC 279 include NAND flash controllers with built-in hardware ECC
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index 535c234286e..8c694213035 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -1475,6 +1475,7 @@ el3_resume(struct device *pdev)
1475 spin_lock_irqsave(&lp->lock, flags); 1475 spin_lock_irqsave(&lp->lock, flags);
1476 1476
1477 outw(PowerUp, ioaddr + EL3_CMD); 1477 outw(PowerUp, ioaddr + EL3_CMD);
1478 EL3WINDOW(0);
1478 el3_up(dev); 1479 el3_up(dev);
1479 1480
1480 if (netif_running(dev)) 1481 if (netif_running(dev))
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index acae2d8cd68..9b12a13a640 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -1629,6 +1629,12 @@ static void gfar_schedule_cleanup(struct net_device *dev)
1629 if (netif_rx_schedule_prep(&priv->napi)) { 1629 if (netif_rx_schedule_prep(&priv->napi)) {
1630 gfar_write(&priv->regs->imask, IMASK_RTX_DISABLED); 1630 gfar_write(&priv->regs->imask, IMASK_RTX_DISABLED);
1631 __netif_rx_schedule(&priv->napi); 1631 __netif_rx_schedule(&priv->napi);
1632 } else {
1633 /*
1634 * Clear IEVENT, so interrupts aren't called again
1635 * because of the packets that have already arrived.
1636 */
1637 gfar_write(&priv->regs->ievent, IEVENT_RTX_MASK);
1632 } 1638 }
1633 1639
1634 spin_unlock(&priv->rxlock); 1640 spin_unlock(&priv->rxlock);
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 9c78c963b72..f4dd9acb687 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -1203,7 +1203,7 @@ typedef struct {
1203#define NETXEN_IS_MSI_FAMILY(adapter) \ 1203#define NETXEN_IS_MSI_FAMILY(adapter) \
1204 ((adapter)->flags & (NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED)) 1204 ((adapter)->flags & (NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED))
1205 1205
1206#define MSIX_ENTRIES_PER_ADAPTER 8 1206#define MSIX_ENTRIES_PER_ADAPTER 1
1207#define NETXEN_MSIX_TBL_SPACE 8192 1207#define NETXEN_MSIX_TBL_SPACE 8192
1208#define NETXEN_PCI_REG_MSIX_TBL 0x44 1208#define NETXEN_PCI_REG_MSIX_TBL 0x44
1209 1209
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 645d384fe87..3b17a793614 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -76,6 +76,7 @@ static void netxen_nic_poll_controller(struct net_device *netdev);
76#endif 76#endif
77static irqreturn_t netxen_intr(int irq, void *data); 77static irqreturn_t netxen_intr(int irq, void *data);
78static irqreturn_t netxen_msi_intr(int irq, void *data); 78static irqreturn_t netxen_msi_intr(int irq, void *data);
79static irqreturn_t netxen_msix_intr(int irq, void *data);
79 80
80/* PCI Device ID Table */ 81/* PCI Device ID Table */
81#define ENTRY(device) \ 82#define ENTRY(device) \
@@ -1084,7 +1085,9 @@ static int netxen_nic_open(struct net_device *netdev)
1084 for (ring = 0; ring < adapter->max_rds_rings; ring++) 1085 for (ring = 0; ring < adapter->max_rds_rings; ring++)
1085 netxen_post_rx_buffers(adapter, ctx, ring); 1086 netxen_post_rx_buffers(adapter, ctx, ring);
1086 } 1087 }
1087 if (NETXEN_IS_MSI_FAMILY(adapter)) 1088 if (adapter->flags & NETXEN_NIC_MSIX_ENABLED)
1089 handler = netxen_msix_intr;
1090 else if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
1088 handler = netxen_msi_intr; 1091 handler = netxen_msi_intr;
1089 else { 1092 else {
1090 flags |= IRQF_SHARED; 1093 flags |= IRQF_SHARED;
@@ -1612,6 +1615,14 @@ static irqreturn_t netxen_msi_intr(int irq, void *data)
1612 return IRQ_HANDLED; 1615 return IRQ_HANDLED;
1613} 1616}
1614 1617
1618static irqreturn_t netxen_msix_intr(int irq, void *data)
1619{
1620 struct netxen_adapter *adapter = data;
1621
1622 napi_schedule(&adapter->napi);
1623 return IRQ_HANDLED;
1624}
1625
1615static int netxen_nic_poll(struct napi_struct *napi, int budget) 1626static int netxen_nic_poll(struct napi_struct *napi, int budget)
1616{ 1627{
1617 struct netxen_adapter *adapter = container_of(napi, struct netxen_adapter, napi); 1628 struct netxen_adapter *adapter = container_of(napi, struct netxen_adapter, napi);
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 2c73ca606b3..0771eb6fc6e 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -437,6 +437,22 @@ enum features {
437 RTL_FEATURE_GMII = (1 << 2), 437 RTL_FEATURE_GMII = (1 << 2),
438}; 438};
439 439
440struct rtl8169_counters {
441 __le64 tx_packets;
442 __le64 rx_packets;
443 __le64 tx_errors;
444 __le32 rx_errors;
445 __le16 rx_missed;
446 __le16 align_errors;
447 __le32 tx_one_collision;
448 __le32 tx_multi_collision;
449 __le64 rx_unicast;
450 __le64 rx_broadcast;
451 __le32 rx_multicast;
452 __le16 tx_aborted;
453 __le16 tx_underun;
454};
455
440struct rtl8169_private { 456struct rtl8169_private {
441 void __iomem *mmio_addr; /* memory map physical address */ 457 void __iomem *mmio_addr; /* memory map physical address */
442 struct pci_dev *pci_dev; /* Index of PCI device */ 458 struct pci_dev *pci_dev; /* Index of PCI device */
@@ -480,6 +496,7 @@ struct rtl8169_private {
480 unsigned features; 496 unsigned features;
481 497
482 struct mii_if_info mii; 498 struct mii_if_info mii;
499 struct rtl8169_counters counters;
483}; 500};
484 501
485MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); 502MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>");
@@ -1100,22 +1117,6 @@ static const char rtl8169_gstrings[][ETH_GSTRING_LEN] = {
1100 "tx_underrun", 1117 "tx_underrun",
1101}; 1118};
1102 1119
1103struct rtl8169_counters {
1104 __le64 tx_packets;
1105 __le64 rx_packets;
1106 __le64 tx_errors;
1107 __le32 rx_errors;
1108 __le16 rx_missed;
1109 __le16 align_errors;
1110 __le32 tx_one_collision;
1111 __le32 tx_multi_collision;
1112 __le64 rx_unicast;
1113 __le64 rx_broadcast;
1114 __le32 rx_multicast;
1115 __le16 tx_aborted;
1116 __le16 tx_underun;
1117};
1118
1119static int rtl8169_get_sset_count(struct net_device *dev, int sset) 1120static int rtl8169_get_sset_count(struct net_device *dev, int sset)
1120{ 1121{
1121 switch (sset) { 1122 switch (sset) {
@@ -1126,16 +1127,21 @@ static int rtl8169_get_sset_count(struct net_device *dev, int sset)
1126 } 1127 }
1127} 1128}
1128 1129
1129static void rtl8169_get_ethtool_stats(struct net_device *dev, 1130static void rtl8169_update_counters(struct net_device *dev)
1130 struct ethtool_stats *stats, u64 *data)
1131{ 1131{
1132 struct rtl8169_private *tp = netdev_priv(dev); 1132 struct rtl8169_private *tp = netdev_priv(dev);
1133 void __iomem *ioaddr = tp->mmio_addr; 1133 void __iomem *ioaddr = tp->mmio_addr;
1134 struct rtl8169_counters *counters; 1134 struct rtl8169_counters *counters;
1135 dma_addr_t paddr; 1135 dma_addr_t paddr;
1136 u32 cmd; 1136 u32 cmd;
1137 int wait = 1000;
1137 1138
1138 ASSERT_RTNL(); 1139 /*
1140 * Some chips are unable to dump tally counters when the receiver
1141 * is disabled.
1142 */
1143 if ((RTL_R8(ChipCmd) & CmdRxEnb) == 0)
1144 return;
1139 1145
1140 counters = pci_alloc_consistent(tp->pci_dev, sizeof(*counters), &paddr); 1146 counters = pci_alloc_consistent(tp->pci_dev, sizeof(*counters), &paddr);
1141 if (!counters) 1147 if (!counters)
@@ -1146,31 +1152,45 @@ static void rtl8169_get_ethtool_stats(struct net_device *dev,
1146 RTL_W32(CounterAddrLow, cmd); 1152 RTL_W32(CounterAddrLow, cmd);
1147 RTL_W32(CounterAddrLow, cmd | CounterDump); 1153 RTL_W32(CounterAddrLow, cmd | CounterDump);
1148 1154
1149 while (RTL_R32(CounterAddrLow) & CounterDump) { 1155 while (wait--) {
1150 if (msleep_interruptible(1)) 1156 if ((RTL_R32(CounterAddrLow) & CounterDump) == 0) {
1157 /* copy updated counters */
1158 memcpy(&tp->counters, counters, sizeof(*counters));
1151 break; 1159 break;
1160 }
1161 udelay(10);
1152 } 1162 }
1153 1163
1154 RTL_W32(CounterAddrLow, 0); 1164 RTL_W32(CounterAddrLow, 0);
1155 RTL_W32(CounterAddrHigh, 0); 1165 RTL_W32(CounterAddrHigh, 0);
1156 1166
1157 data[0] = le64_to_cpu(counters->tx_packets);
1158 data[1] = le64_to_cpu(counters->rx_packets);
1159 data[2] = le64_to_cpu(counters->tx_errors);
1160 data[3] = le32_to_cpu(counters->rx_errors);
1161 data[4] = le16_to_cpu(counters->rx_missed);
1162 data[5] = le16_to_cpu(counters->align_errors);
1163 data[6] = le32_to_cpu(counters->tx_one_collision);
1164 data[7] = le32_to_cpu(counters->tx_multi_collision);
1165 data[8] = le64_to_cpu(counters->rx_unicast);
1166 data[9] = le64_to_cpu(counters->rx_broadcast);
1167 data[10] = le32_to_cpu(counters->rx_multicast);
1168 data[11] = le16_to_cpu(counters->tx_aborted);
1169 data[12] = le16_to_cpu(counters->tx_underun);
1170
1171 pci_free_consistent(tp->pci_dev, sizeof(*counters), counters, paddr); 1167 pci_free_consistent(tp->pci_dev, sizeof(*counters), counters, paddr);
1172} 1168}
1173 1169
1170static void rtl8169_get_ethtool_stats(struct net_device *dev,
1171 struct ethtool_stats *stats, u64 *data)
1172{
1173 struct rtl8169_private *tp = netdev_priv(dev);
1174
1175 ASSERT_RTNL();
1176
1177 rtl8169_update_counters(dev);
1178
1179 data[0] = le64_to_cpu(tp->counters.tx_packets);
1180 data[1] = le64_to_cpu(tp->counters.rx_packets);
1181 data[2] = le64_to_cpu(tp->counters.tx_errors);
1182 data[3] = le32_to_cpu(tp->counters.rx_errors);
1183 data[4] = le16_to_cpu(tp->counters.rx_missed);
1184 data[5] = le16_to_cpu(tp->counters.align_errors);
1185 data[6] = le32_to_cpu(tp->counters.tx_one_collision);
1186 data[7] = le32_to_cpu(tp->counters.tx_multi_collision);
1187 data[8] = le64_to_cpu(tp->counters.rx_unicast);
1188 data[9] = le64_to_cpu(tp->counters.rx_broadcast);
1189 data[10] = le32_to_cpu(tp->counters.rx_multicast);
1190 data[11] = le16_to_cpu(tp->counters.tx_aborted);
1191 data[12] = le16_to_cpu(tp->counters.tx_underun);
1192}
1193
1174static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data) 1194static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data)
1175{ 1195{
1176 switch(stringset) { 1196 switch(stringset) {
@@ -3682,6 +3702,9 @@ static int rtl8169_close(struct net_device *dev)
3682 struct rtl8169_private *tp = netdev_priv(dev); 3702 struct rtl8169_private *tp = netdev_priv(dev);
3683 struct pci_dev *pdev = tp->pci_dev; 3703 struct pci_dev *pdev = tp->pci_dev;
3684 3704
3705 /* update counters before going down */
3706 rtl8169_update_counters(dev);
3707
3685 rtl8169_down(dev); 3708 rtl8169_down(dev);
3686 3709
3687 free_irq(dev->irq, dev); 3710 free_irq(dev->irq, dev);
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index b17efa9cc53..49187634106 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2221,6 +2221,8 @@ static int gem_do_start(struct net_device *dev)
2221 2221
2222 gp->running = 1; 2222 gp->running = 1;
2223 2223
2224 napi_enable(&gp->napi);
2225
2224 if (gp->lstate == link_up) { 2226 if (gp->lstate == link_up) {
2225 netif_carrier_on(gp->dev); 2227 netif_carrier_on(gp->dev);
2226 gem_set_link_modes(gp); 2228 gem_set_link_modes(gp);
@@ -2238,6 +2240,8 @@ static int gem_do_start(struct net_device *dev)
2238 spin_lock_irqsave(&gp->lock, flags); 2240 spin_lock_irqsave(&gp->lock, flags);
2239 spin_lock(&gp->tx_lock); 2241 spin_lock(&gp->tx_lock);
2240 2242
2243 napi_disable(&gp->napi);
2244
2241 gp->running = 0; 2245 gp->running = 0;
2242 gem_reset(gp); 2246 gem_reset(gp);
2243 gem_clean_rings(gp); 2247 gem_clean_rings(gp);
@@ -2338,8 +2342,6 @@ static int gem_open(struct net_device *dev)
2338 if (!gp->asleep) 2342 if (!gp->asleep)
2339 rc = gem_do_start(dev); 2343 rc = gem_do_start(dev);
2340 gp->opened = (rc == 0); 2344 gp->opened = (rc == 0);
2341 if (gp->opened)
2342 napi_enable(&gp->napi);
2343 2345
2344 mutex_unlock(&gp->pm_mutex); 2346 mutex_unlock(&gp->pm_mutex);
2345 2347
@@ -2476,8 +2478,6 @@ static int gem_resume(struct pci_dev *pdev)
2476 2478
2477 /* Re-attach net device */ 2479 /* Re-attach net device */
2478 netif_device_attach(dev); 2480 netif_device_attach(dev);
2479
2480 napi_enable(&gp->napi);
2481 } 2481 }
2482 2482
2483 spin_lock_irqsave(&gp->lock, flags); 2483 spin_lock_irqsave(&gp->lock, flags);
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c
index 7a72a3112f0..cc4013be5e1 100644
--- a/drivers/net/sunhme.c
+++ b/drivers/net/sunhme.c
@@ -2629,6 +2629,14 @@ static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
2629 int i, qfe_slot = -1; 2629 int i, qfe_slot = -1;
2630 int err = -ENODEV; 2630 int err = -ENODEV;
2631 2631
2632 sbus_dp = to_of_device(op->dev.parent)->node;
2633 if (is_qfe)
2634 sbus_dp = to_of_device(op->dev.parent->parent)->node;
2635
2636 /* We can match PCI devices too, do not accept those here. */
2637 if (strcmp(sbus_dp->name, "sbus"))
2638 return err;
2639
2632 if (is_qfe) { 2640 if (is_qfe) {
2633 qp = quattro_sbus_find(op); 2641 qp = quattro_sbus_find(op);
2634 if (qp == NULL) 2642 if (qp == NULL)
@@ -2734,10 +2742,6 @@ static int __devinit happy_meal_sbus_probe_one(struct of_device *op, int is_qfe)
2734 if (qp != NULL) 2742 if (qp != NULL)
2735 hp->happy_flags |= HFLAG_QUATTRO; 2743 hp->happy_flags |= HFLAG_QUATTRO;
2736 2744
2737 sbus_dp = to_of_device(op->dev.parent)->node;
2738 if (is_qfe)
2739 sbus_dp = to_of_device(op->dev.parent->parent)->node;
2740
2741 /* Get the supported DVMA burst sizes from our Happy SBUS. */ 2745 /* Get the supported DVMA burst sizes from our Happy SBUS. */
2742 hp->happy_bursts = of_getintprop_default(sbus_dp, 2746 hp->happy_bursts = of_getintprop_default(sbus_dp,
2743 "burst-sizes", 0x00); 2747 "burst-sizes", 0x00);
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 0bf2114738b..d4c5ecc51f7 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -464,13 +464,14 @@ static void de_rx (struct de_private *de)
464 drop = 1; 464 drop = 1;
465 465
466rx_next: 466rx_next:
467 de->rx_ring[rx_tail].opts1 = cpu_to_le32(DescOwn);
468 if (rx_tail == (DE_RX_RING_SIZE - 1)) 467 if (rx_tail == (DE_RX_RING_SIZE - 1))
469 de->rx_ring[rx_tail].opts2 = 468 de->rx_ring[rx_tail].opts2 =
470 cpu_to_le32(RingEnd | de->rx_buf_sz); 469 cpu_to_le32(RingEnd | de->rx_buf_sz);
471 else 470 else
472 de->rx_ring[rx_tail].opts2 = cpu_to_le32(de->rx_buf_sz); 471 de->rx_ring[rx_tail].opts2 = cpu_to_le32(de->rx_buf_sz);
473 de->rx_ring[rx_tail].addr1 = cpu_to_le32(mapping); 472 de->rx_ring[rx_tail].addr1 = cpu_to_le32(mapping);
473 wmb();
474 de->rx_ring[rx_tail].opts1 = cpu_to_le32(DescOwn);
474 rx_tail = NEXT_RX(rx_tail); 475 rx_tail = NEXT_RX(rx_tail);
475 } 476 }
476 477
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index d7b81e4fdd5..09fea31d3e3 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -157,10 +157,16 @@ static int update_filter(struct tap_filter *filter, void __user *arg)
157 157
158 nexact = n; 158 nexact = n;
159 159
160 /* The rest is hashed */ 160 /* Remaining multicast addresses are hashed,
161 * unicast will leave the filter disabled. */
161 memset(filter->mask, 0, sizeof(filter->mask)); 162 memset(filter->mask, 0, sizeof(filter->mask));
162 for (; n < uf.count; n++) 163 for (; n < uf.count; n++) {
164 if (!is_multicast_ether_addr(addr[n].u)) {
165 err = 0; /* no filter */
166 goto done;
167 }
163 addr_hash_set(filter->mask, addr[n].u); 168 addr_hash_set(filter->mask, addr[n].u);
169 }
164 170
165 /* For ALLMULTI just set the mask to all ones. 171 /* For ALLMULTI just set the mask to all ones.
166 * This overrides the mask populated above. */ 172 * This overrides the mask populated above. */
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 101ed49a2d1..032db815b0f 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -64,6 +64,11 @@ struct parport_pc_pci {
64 64
65static int __devinit netmos_parallel_init(struct pci_dev *dev, struct parport_pc_pci *card, int autoirq, int autodma) 65static int __devinit netmos_parallel_init(struct pci_dev *dev, struct parport_pc_pci *card, int autoirq, int autodma)
66{ 66{
67 /* the rule described below doesn't hold for this device */
68 if (dev->device == PCI_DEVICE_ID_NETMOS_9835 &&
69 dev->subsystem_vendor == PCI_VENDOR_ID_IBM &&
70 dev->subsystem_device == 0x0299)
71 return -ENODEV;
67 /* 72 /*
68 * Netmos uses the subdevice ID to indicate the number of parallel 73 * Netmos uses the subdevice ID to indicate the number of parallel
69 * and serial ports. The form is 0x00PS, where <P> is the number of 74 * and serial ports. The form is 0x00PS, where <P> is the number of
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c
index e988ec130fc..41aec2acbb9 100644
--- a/drivers/power/pcf50633-charger.c
+++ b/drivers/power/pcf50633-charger.c
@@ -199,7 +199,8 @@ static int adapter_get_property(struct power_supply *psy,
199 enum power_supply_property psp, 199 enum power_supply_property psp,
200 union power_supply_propval *val) 200 union power_supply_propval *val)
201{ 201{
202 struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb); 202 struct pcf50633_mbc *mbc = container_of(psy,
203 struct pcf50633_mbc, adapter);
203 int ret = 0; 204 int ret = 0;
204 205
205 switch (psp) { 206 switch (psp) {
diff --git a/drivers/rtc/rtc-au1xxx.c b/drivers/rtc/rtc-au1xxx.c
index 8906a688e6a..979ed0406ce 100644
--- a/drivers/rtc/rtc-au1xxx.c
+++ b/drivers/rtc/rtc-au1xxx.c
@@ -81,7 +81,7 @@ static int __devinit au1xtoy_rtc_probe(struct platform_device *pdev)
81 if (au_readl(SYS_TOYTRIM) != 32767) { 81 if (au_readl(SYS_TOYTRIM) != 32767) {
82 /* wait until hardware gives access to TRIM register */ 82 /* wait until hardware gives access to TRIM register */
83 t = 0x00100000; 83 t = 0x00100000;
84 while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T0S) && t--) 84 while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T0S) && --t)
85 msleep(1); 85 msleep(1);
86 86
87 if (!t) { 87 if (!t) {
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c
index bd56a033bfd..bb8cc05605a 100644
--- a/drivers/rtc/rtc-pxa.c
+++ b/drivers/rtc/rtc-pxa.c
@@ -485,7 +485,7 @@ static void __exit pxa_rtc_exit(void)
485module_init(pxa_rtc_init); 485module_init(pxa_rtc_init);
486module_exit(pxa_rtc_exit); 486module_exit(pxa_rtc_exit);
487 487
488MODULE_AUTHOR("Robert Jarzmik"); 488MODULE_AUTHOR("Robert Jarzmik <robert.jarzmik@free.fr>");
489MODULE_DESCRIPTION("PXA27x/PXA3xx Realtime Clock Driver (RTC)"); 489MODULE_DESCRIPTION("PXA27x/PXA3xx Realtime Clock Driver (RTC)");
490MODULE_LICENSE("GPL"); 490MODULE_LICENSE("GPL");
491MODULE_ALIAS("platform:pxa-rtc"); 491MODULE_ALIAS("platform:pxa-rtc");
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index bd591499414..08c23a92101 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -57,6 +57,8 @@ static void dasd_device_tasklet(struct dasd_device *);
57static void dasd_block_tasklet(struct dasd_block *); 57static void dasd_block_tasklet(struct dasd_block *);
58static void do_kick_device(struct work_struct *); 58static void do_kick_device(struct work_struct *);
59static void dasd_return_cqr_cb(struct dasd_ccw_req *, void *); 59static void dasd_return_cqr_cb(struct dasd_ccw_req *, void *);
60static void dasd_device_timeout(unsigned long);
61static void dasd_block_timeout(unsigned long);
60 62
61/* 63/*
62 * SECTION: Operations on the device structure. 64 * SECTION: Operations on the device structure.
@@ -99,6 +101,8 @@ struct dasd_device *dasd_alloc_device(void)
99 (unsigned long) device); 101 (unsigned long) device);
100 INIT_LIST_HEAD(&device->ccw_queue); 102 INIT_LIST_HEAD(&device->ccw_queue);
101 init_timer(&device->timer); 103 init_timer(&device->timer);
104 device->timer.function = dasd_device_timeout;
105 device->timer.data = (unsigned long) device;
102 INIT_WORK(&device->kick_work, do_kick_device); 106 INIT_WORK(&device->kick_work, do_kick_device);
103 device->state = DASD_STATE_NEW; 107 device->state = DASD_STATE_NEW;
104 device->target = DASD_STATE_NEW; 108 device->target = DASD_STATE_NEW;
@@ -138,6 +142,8 @@ struct dasd_block *dasd_alloc_block(void)
138 INIT_LIST_HEAD(&block->ccw_queue); 142 INIT_LIST_HEAD(&block->ccw_queue);
139 spin_lock_init(&block->queue_lock); 143 spin_lock_init(&block->queue_lock);
140 init_timer(&block->timer); 144 init_timer(&block->timer);
145 block->timer.function = dasd_block_timeout;
146 block->timer.data = (unsigned long) block;
141 147
142 return block; 148 return block;
143} 149}
@@ -915,19 +921,10 @@ static void dasd_device_timeout(unsigned long ptr)
915 */ 921 */
916void dasd_device_set_timer(struct dasd_device *device, int expires) 922void dasd_device_set_timer(struct dasd_device *device, int expires)
917{ 923{
918 if (expires == 0) { 924 if (expires == 0)
919 if (timer_pending(&device->timer)) 925 del_timer(&device->timer);
920 del_timer(&device->timer); 926 else
921 return; 927 mod_timer(&device->timer, jiffies + expires);
922 }
923 if (timer_pending(&device->timer)) {
924 if (mod_timer(&device->timer, jiffies + expires))
925 return;
926 }
927 device->timer.function = dasd_device_timeout;
928 device->timer.data = (unsigned long) device;
929 device->timer.expires = jiffies + expires;
930 add_timer(&device->timer);
931} 928}
932 929
933/* 930/*
@@ -935,8 +932,7 @@ void dasd_device_set_timer(struct dasd_device *device, int expires)
935 */ 932 */
936void dasd_device_clear_timer(struct dasd_device *device) 933void dasd_device_clear_timer(struct dasd_device *device)
937{ 934{
938 if (timer_pending(&device->timer)) 935 del_timer(&device->timer);
939 del_timer(&device->timer);
940} 936}
941 937
942static void dasd_handle_killed_request(struct ccw_device *cdev, 938static void dasd_handle_killed_request(struct ccw_device *cdev,
@@ -1586,19 +1582,10 @@ static void dasd_block_timeout(unsigned long ptr)
1586 */ 1582 */
1587void dasd_block_set_timer(struct dasd_block *block, int expires) 1583void dasd_block_set_timer(struct dasd_block *block, int expires)
1588{ 1584{
1589 if (expires == 0) { 1585 if (expires == 0)
1590 if (timer_pending(&block->timer)) 1586 del_timer(&block->timer);
1591 del_timer(&block->timer); 1587 else
1592 return; 1588 mod_timer(&block->timer, jiffies + expires);
1593 }
1594 if (timer_pending(&block->timer)) {
1595 if (mod_timer(&block->timer, jiffies + expires))
1596 return;
1597 }
1598 block->timer.function = dasd_block_timeout;
1599 block->timer.data = (unsigned long) block;
1600 block->timer.expires = jiffies + expires;
1601 add_timer(&block->timer);
1602} 1589}
1603 1590
1604/* 1591/*
@@ -1606,8 +1593,7 @@ void dasd_block_set_timer(struct dasd_block *block, int expires)
1606 */ 1593 */
1607void dasd_block_clear_timer(struct dasd_block *block) 1594void dasd_block_clear_timer(struct dasd_block *block)
1608{ 1595{
1609 if (timer_pending(&block->timer)) 1596 del_timer(&block->timer);
1610 del_timer(&block->timer);
1611} 1597}
1612 1598
1613/* 1599/*
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 300e28a531f..34339902efb 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -677,7 +677,7 @@ static ssize_t dasd_ff_show(struct device *dev, struct device_attribute *attr,
677 struct dasd_devmap *devmap; 677 struct dasd_devmap *devmap;
678 int ff_flag; 678 int ff_flag;
679 679
680 devmap = dasd_find_busid(dev->bus_id); 680 devmap = dasd_find_busid(dev_name(dev));
681 if (!IS_ERR(devmap)) 681 if (!IS_ERR(devmap))
682 ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0; 682 ff_flag = (devmap->features & DASD_FEATURE_FAILFAST) != 0;
683 else 683 else
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 6b996db0dd6..604bd1e0d54 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -27,6 +27,7 @@ menuconfig ANDROID_RAM_CONSOLE_ERROR_CORRECTION
27 bool "Android RAM Console Enable error correction" 27 bool "Android RAM Console Enable error correction"
28 default n 28 default n
29 depends on ANDROID_RAM_CONSOLE 29 depends on ANDROID_RAM_CONSOLE
30 depends on !ANDROID_RAM_CONSOLE_EARLY_INIT
30 select REED_SOLOMON 31 select REED_SOLOMON
31 select REED_SOLOMON_ENC8 32 select REED_SOLOMON_ENC8
32 select REED_SOLOMON_DEC8 33 select REED_SOLOMON_DEC8
diff --git a/drivers/staging/android/ram_console.c b/drivers/staging/android/ram_console.c
index bf006857a87..643ac5ce381 100644
--- a/drivers/staging/android/ram_console.c
+++ b/drivers/staging/android/ram_console.c
@@ -224,9 +224,23 @@ static int __init ram_console_init(struct ram_console_buffer *buffer,
224 ram_console_buffer_size = 224 ram_console_buffer_size =
225 buffer_size - sizeof(struct ram_console_buffer); 225 buffer_size - sizeof(struct ram_console_buffer);
226 226
227 if (ram_console_buffer_size > buffer_size) {
228 pr_err("ram_console: buffer %p, invalid size %d, datasize %d\n",
229 buffer, buffer_size, ram_console_buffer_size);
230 return 0;
231 }
232
227#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION 233#ifdef CONFIG_ANDROID_RAM_CONSOLE_ERROR_CORRECTION
228 ram_console_buffer_size -= (DIV_ROUND_UP(ram_console_buffer_size, 234 ram_console_buffer_size -= (DIV_ROUND_UP(ram_console_buffer_size,
229 ECC_BLOCK_SIZE) + 1) * ECC_SIZE; 235 ECC_BLOCK_SIZE) + 1) * ECC_SIZE;
236
237 if (ram_console_buffer_size > buffer_size) {
238 pr_err("ram_console: buffer %p, invalid size %d, "
239 "non-ecc datasize %d\n",
240 buffer, buffer_size, ram_console_buffer_size);
241 return 0;
242 }
243
230 ram_console_par_buffer = buffer->data + ram_console_buffer_size; 244 ram_console_par_buffer = buffer->data + ram_console_buffer_size;
231 245
232 246
diff --git a/drivers/staging/android/timed_gpio.c b/drivers/staging/android/timed_gpio.c
index 903270cbbe0..33daff0481d 100644
--- a/drivers/staging/android/timed_gpio.c
+++ b/drivers/staging/android/timed_gpio.c
@@ -50,7 +50,7 @@ static ssize_t gpio_enable_show(struct device *dev, struct device_attribute *att
50 if (hrtimer_active(&gpio_data->timer)) { 50 if (hrtimer_active(&gpio_data->timer)) {
51 ktime_t r = hrtimer_get_remaining(&gpio_data->timer); 51 ktime_t r = hrtimer_get_remaining(&gpio_data->timer);
52 struct timeval t = ktime_to_timeval(r); 52 struct timeval t = ktime_to_timeval(r);
53 remaining = t.tv_sec * 1000 + t.tv_usec; 53 remaining = t.tv_sec * 1000 + t.tv_usec / 1000;
54 } else 54 } else
55 remaining = 0; 55 remaining = 0;
56 56
diff --git a/drivers/staging/at76_usb/Kconfig b/drivers/staging/at76_usb/Kconfig
index 4c0e55e1544..8606f962162 100644
--- a/drivers/staging/at76_usb/Kconfig
+++ b/drivers/staging/at76_usb/Kconfig
@@ -1,6 +1,6 @@
1config USB_ATMEL 1config USB_ATMEL
2 tristate "Atmel at76c503/at76c505/at76c505a USB cards" 2 tristate "Atmel at76c503/at76c505/at76c505a USB cards"
3 depends on MAC80211 && WLAN_80211 && USB 3 depends on WLAN_80211 && USB
4 default N 4 default N
5 select FW_LOADER 5 select FW_LOADER
6 ---help--- 6 ---help---
diff --git a/drivers/staging/at76_usb/at76_usb.c b/drivers/staging/at76_usb/at76_usb.c
index 185533e5476..c8e4d31c7df 100644
--- a/drivers/staging/at76_usb/at76_usb.c
+++ b/drivers/staging/at76_usb/at76_usb.c
@@ -6,7 +6,6 @@
6 * Copyright (c) 2004 Nick Jones 6 * Copyright (c) 2004 Nick Jones
7 * Copyright (c) 2004 Balint Seeber <n0_5p4m_p13453@hotmail.com> 7 * Copyright (c) 2004 Balint Seeber <n0_5p4m_p13453@hotmail.com>
8 * Copyright (c) 2007 Guido Guenther <agx@sigxcpu.org> 8 * Copyright (c) 2007 Guido Guenther <agx@sigxcpu.org>
9 * Copyright (c) 2007 Kalle Valo <kalle.valo@iki.fi>
10 * 9 *
11 * This program is free software; you can redistribute it and/or 10 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as 11 * modify it under the terms of the GNU General Public License as
@@ -17,13 +16,6 @@
17 * Atmel AT76C503A/505/505A. 16 * Atmel AT76C503A/505/505A.
18 * 17 *
19 * Some iw_handler code was taken from airo.c, (C) 1999 Benjamin Reed 18 * Some iw_handler code was taken from airo.c, (C) 1999 Benjamin Reed
20 *
21 * TODO for the mac80211 port:
22 * o adhoc support
23 * o RTS/CTS support
24 * o Power Save Mode support
25 * o support for short/long preambles
26 * o export variables through debugfs/sysfs
27 */ 19 */
28 20
29#include <linux/init.h> 21#include <linux/init.h>
@@ -44,7 +36,7 @@
44#include <net/ieee80211_radiotap.h> 36#include <net/ieee80211_radiotap.h>
45#include <linux/firmware.h> 37#include <linux/firmware.h>
46#include <linux/leds.h> 38#include <linux/leds.h>
47#include <net/mac80211.h> 39#include <net/ieee80211.h>
48 40
49#include "at76_usb.h" 41#include "at76_usb.h"
50 42
@@ -84,43 +76,31 @@
84#define DBG_WE_EVENTS 0x08000000 /* dump wireless events */ 76#define DBG_WE_EVENTS 0x08000000 /* dump wireless events */
85#define DBG_FW 0x10000000 /* firmware download */ 77#define DBG_FW 0x10000000 /* firmware download */
86#define DBG_DFU 0x20000000 /* device firmware upgrade */ 78#define DBG_DFU 0x20000000 /* device firmware upgrade */
87#define DBG_CMD 0x40000000
88#define DBG_MAC80211 0x80000000
89 79
90#define DBG_DEFAULTS 0 80#define DBG_DEFAULTS 0
91 81
92/* Use our own dbg macro */ 82/* Use our own dbg macro */
93#define at76_dbg(bits, format, arg...) \ 83#define at76_dbg(bits, format, arg...) \
94do { \ 84 do { \
95 if (at76_debug & (bits)) \ 85 if (at76_debug & (bits)) \
96 printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , ## arg); \
97} while (0)
98
99#define at76_dbg_dump(bits, buf, len, format, arg...) \
100do { \
101 if (at76_debug & (bits)) { \
102 printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , ## arg); \ 86 printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , ## arg); \
103 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len); \ 87 } while (0)
104 } \
105} while (0)
106 88
107static int at76_debug = DBG_DEFAULTS; 89static int at76_debug = DBG_DEFAULTS;
108 90
109#define FIRMWARE_IS_WPA(ver) ((ver.major == 1) && (ver.minor == 103))
110
111/* Protect against concurrent firmware loading and parsing */ 91/* Protect against concurrent firmware loading and parsing */
112static struct mutex fw_mutex; 92static struct mutex fw_mutex;
113 93
114static struct fwentry firmwares[] = { 94static struct fwentry firmwares[] = {
115 [0] = { "" }, 95 [0] = {""},
116 [BOARD_503_ISL3861] = { "atmel_at76c503-i3861.bin" }, 96 [BOARD_503_ISL3861] = {"atmel_at76c503-i3861.bin"},
117 [BOARD_503_ISL3863] = { "atmel_at76c503-i3863.bin" }, 97 [BOARD_503_ISL3863] = {"atmel_at76c503-i3863.bin"},
118 [BOARD_503] = { "atmel_at76c503-rfmd.bin" }, 98 [BOARD_503] = {"atmel_at76c503-rfmd.bin"},
119 [BOARD_503_ACC] = { "atmel_at76c503-rfmd-acc.bin" }, 99 [BOARD_503_ACC] = {"atmel_at76c503-rfmd-acc.bin"},
120 [BOARD_505] = { "atmel_at76c505-rfmd.bin" }, 100 [BOARD_505] = {"atmel_at76c505-rfmd.bin"},
121 [BOARD_505_2958] = { "atmel_at76c505-rfmd2958.bin" }, 101 [BOARD_505_2958] = {"atmel_at76c505-rfmd2958.bin"},
122 [BOARD_505A] = { "atmel_at76c505a-rfmd2958.bin" }, 102 [BOARD_505A] = {"atmel_at76c505a-rfmd2958.bin"},
123 [BOARD_505AMX] = { "atmel_at76c505amx-rfmd.bin" }, 103 [BOARD_505AMX] = {"atmel_at76c505amx-rfmd.bin"},
124}; 104};
125 105
126#define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops) 106#define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops)
@@ -130,133 +110,135 @@ static struct usb_device_id dev_table[] = {
130 * at76c503-i3861 110 * at76c503-i3861
131 */ 111 */
132 /* Generic AT76C503/3861 device */ 112 /* Generic AT76C503/3861 device */
133 { USB_DEVICE(0x03eb, 0x7603), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 113 {USB_DEVICE(0x03eb, 0x7603), USB_DEVICE_DATA(BOARD_503_ISL3861)},
134 /* Linksys WUSB11 v2.1/v2.6 */ 114 /* Linksys WUSB11 v2.1/v2.6 */
135 { USB_DEVICE(0x066b, 0x2211), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 115 {USB_DEVICE(0x066b, 0x2211), USB_DEVICE_DATA(BOARD_503_ISL3861)},
136 /* Netgear MA101 rev. A */ 116 /* Netgear MA101 rev. A */
137 { USB_DEVICE(0x0864, 0x4100), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 117 {USB_DEVICE(0x0864, 0x4100), USB_DEVICE_DATA(BOARD_503_ISL3861)},
138 /* Tekram U300C / Allnet ALL0193 */ 118 /* Tekram U300C / Allnet ALL0193 */
139 { USB_DEVICE(0x0b3b, 0x1612), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 119 {USB_DEVICE(0x0b3b, 0x1612), USB_DEVICE_DATA(BOARD_503_ISL3861)},
140 /* HP HN210W J7801A */ 120 /* HP HN210W J7801A */
141 { USB_DEVICE(0x03f0, 0x011c), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 121 {USB_DEVICE(0x03f0, 0x011c), USB_DEVICE_DATA(BOARD_503_ISL3861)},
142 /* Sitecom/Z-Com/Zyxel M4Y-750 */ 122 /* Sitecom/Z-Com/Zyxel M4Y-750 */
143 { USB_DEVICE(0x0cde, 0x0001), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 123 {USB_DEVICE(0x0cde, 0x0001), USB_DEVICE_DATA(BOARD_503_ISL3861)},
144 /* Dynalink/Askey WLL013 (intersil) */ 124 /* Dynalink/Askey WLL013 (intersil) */
145 { USB_DEVICE(0x069a, 0x0320), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 125 {USB_DEVICE(0x069a, 0x0320), USB_DEVICE_DATA(BOARD_503_ISL3861)},
146 /* EZ connect 11Mpbs Wireless USB Adapter SMC2662W v1 */ 126 /* EZ connect 11Mpbs Wireless USB Adapter SMC2662W v1 */
147 { USB_DEVICE(0x0d5c, 0xa001), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 127 {USB_DEVICE(0x0d5c, 0xa001), USB_DEVICE_DATA(BOARD_503_ISL3861)},
148 /* BenQ AWL300 */ 128 /* BenQ AWL300 */
149 { USB_DEVICE(0x04a5, 0x9000), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 129 {USB_DEVICE(0x04a5, 0x9000), USB_DEVICE_DATA(BOARD_503_ISL3861)},
150 /* Addtron AWU-120, Compex WLU11 */ 130 /* Addtron AWU-120, Compex WLU11 */
151 { USB_DEVICE(0x05dd, 0xff31), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 131 {USB_DEVICE(0x05dd, 0xff31), USB_DEVICE_DATA(BOARD_503_ISL3861)},
152 /* Intel AP310 AnyPoint II USB */ 132 /* Intel AP310 AnyPoint II USB */
153 { USB_DEVICE(0x8086, 0x0200), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 133 {USB_DEVICE(0x8086, 0x0200), USB_DEVICE_DATA(BOARD_503_ISL3861)},
154 /* Dynalink L11U */ 134 /* Dynalink L11U */
155 { USB_DEVICE(0x0d8e, 0x7100), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 135 {USB_DEVICE(0x0d8e, 0x7100), USB_DEVICE_DATA(BOARD_503_ISL3861)},
156 /* Arescom WL-210, FCC id 07J-GL2411USB */ 136 /* Arescom WL-210, FCC id 07J-GL2411USB */
157 { USB_DEVICE(0x0d8e, 0x7110), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 137 {USB_DEVICE(0x0d8e, 0x7110), USB_DEVICE_DATA(BOARD_503_ISL3861)},
158 /* I-O DATA WN-B11/USB */ 138 /* I-O DATA WN-B11/USB */
159 { USB_DEVICE(0x04bb, 0x0919), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 139 {USB_DEVICE(0x04bb, 0x0919), USB_DEVICE_DATA(BOARD_503_ISL3861)},
160 /* BT Voyager 1010 */ 140 /* BT Voyager 1010 */
161 { USB_DEVICE(0x069a, 0x0821), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 141 {USB_DEVICE(0x069a, 0x0821), USB_DEVICE_DATA(BOARD_503_ISL3861)},
162 /* 142 /*
163 * at76c503-i3863 143 * at76c503-i3863
164 */ 144 */
165 /* Generic AT76C503/3863 device */ 145 /* Generic AT76C503/3863 device */
166 { USB_DEVICE(0x03eb, 0x7604), USB_DEVICE_DATA(BOARD_503_ISL3863) }, 146 {USB_DEVICE(0x03eb, 0x7604), USB_DEVICE_DATA(BOARD_503_ISL3863)},
167 /* Samsung SWL-2100U */ 147 /* Samsung SWL-2100U */
168 { USB_DEVICE(0x055d, 0xa000), USB_DEVICE_DATA(BOARD_503_ISL3863) }, 148 {USB_DEVICE(0x055d, 0xa000), USB_DEVICE_DATA(BOARD_503_ISL3863)},
169 /* 149 /*
170 * at76c503-rfmd 150 * at76c503-rfmd
171 */ 151 */
172 /* Generic AT76C503/RFMD device */ 152 /* Generic AT76C503/RFMD device */
173 { USB_DEVICE(0x03eb, 0x7605), USB_DEVICE_DATA(BOARD_503) }, 153 {USB_DEVICE(0x03eb, 0x7605), USB_DEVICE_DATA(BOARD_503)},
174 /* Dynalink/Askey WLL013 (rfmd) */ 154 /* Dynalink/Askey WLL013 (rfmd) */
175 { USB_DEVICE(0x069a, 0x0321), USB_DEVICE_DATA(BOARD_503) }, 155 {USB_DEVICE(0x069a, 0x0321), USB_DEVICE_DATA(BOARD_503)},
176 /* Linksys WUSB11 v2.6 */ 156 /* Linksys WUSB11 v2.6 */
177 { USB_DEVICE(0x077b, 0x2219), USB_DEVICE_DATA(BOARD_503) }, 157 {USB_DEVICE(0x077b, 0x2219), USB_DEVICE_DATA(BOARD_503)},
178 /* Network Everywhere NWU11B */ 158 /* Network Everywhere NWU11B */
179 { USB_DEVICE(0x077b, 0x2227), USB_DEVICE_DATA(BOARD_503) }, 159 {USB_DEVICE(0x077b, 0x2227), USB_DEVICE_DATA(BOARD_503)},
180 /* Netgear MA101 rev. B */ 160 /* Netgear MA101 rev. B */
181 { USB_DEVICE(0x0864, 0x4102), USB_DEVICE_DATA(BOARD_503) }, 161 {USB_DEVICE(0x0864, 0x4102), USB_DEVICE_DATA(BOARD_503)},
182 /* D-Link DWL-120 rev. E */ 162 /* D-Link DWL-120 rev. E */
183 { USB_DEVICE(0x2001, 0x3200), USB_DEVICE_DATA(BOARD_503) }, 163 {USB_DEVICE(0x2001, 0x3200), USB_DEVICE_DATA(BOARD_503)},
184 /* Actiontec 802UAT1, HWU01150-01UK */ 164 /* Actiontec 802UAT1, HWU01150-01UK */
185 { USB_DEVICE(0x1668, 0x7605), USB_DEVICE_DATA(BOARD_503) }, 165 {USB_DEVICE(0x1668, 0x7605), USB_DEVICE_DATA(BOARD_503)},
186 /* AirVast W-Buddie WN210 */ 166 /* AirVast W-Buddie WN210 */
187 { USB_DEVICE(0x03eb, 0x4102), USB_DEVICE_DATA(BOARD_503) }, 167 {USB_DEVICE(0x03eb, 0x4102), USB_DEVICE_DATA(BOARD_503)},
188 /* Dick Smith Electronics XH1153 802.11b USB adapter */ 168 /* Dick Smith Electronics XH1153 802.11b USB adapter */
189 { USB_DEVICE(0x1371, 0x5743), USB_DEVICE_DATA(BOARD_503) }, 169 {USB_DEVICE(0x1371, 0x5743), USB_DEVICE_DATA(BOARD_503)},
190 /* CNet CNUSB611 */ 170 /* CNet CNUSB611 */
191 { USB_DEVICE(0x1371, 0x0001), USB_DEVICE_DATA(BOARD_503) }, 171 {USB_DEVICE(0x1371, 0x0001), USB_DEVICE_DATA(BOARD_503)},
192 /* FiberLine FL-WL200U */ 172 /* FiberLine FL-WL200U */
193 { USB_DEVICE(0x1371, 0x0002), USB_DEVICE_DATA(BOARD_503) }, 173 {USB_DEVICE(0x1371, 0x0002), USB_DEVICE_DATA(BOARD_503)},
194 /* BenQ AWL400 USB stick */ 174 /* BenQ AWL400 USB stick */
195 { USB_DEVICE(0x04a5, 0x9001), USB_DEVICE_DATA(BOARD_503) }, 175 {USB_DEVICE(0x04a5, 0x9001), USB_DEVICE_DATA(BOARD_503)},
196 /* 3Com 3CRSHEW696 */ 176 /* 3Com 3CRSHEW696 */
197 { USB_DEVICE(0x0506, 0x0a01), USB_DEVICE_DATA(BOARD_503) }, 177 {USB_DEVICE(0x0506, 0x0a01), USB_DEVICE_DATA(BOARD_503)},
198 /* Siemens Santis ADSL WLAN USB adapter WLL 013 */ 178 /* Siemens Santis ADSL WLAN USB adapter WLL 013 */
199 { USB_DEVICE(0x0681, 0x001b), USB_DEVICE_DATA(BOARD_503) }, 179 {USB_DEVICE(0x0681, 0x001b), USB_DEVICE_DATA(BOARD_503)},
200 /* Belkin F5D6050, version 2 */ 180 /* Belkin F5D6050, version 2 */
201 { USB_DEVICE(0x050d, 0x0050), USB_DEVICE_DATA(BOARD_503) }, 181 {USB_DEVICE(0x050d, 0x0050), USB_DEVICE_DATA(BOARD_503)},
202 /* iBlitzz, BWU613 (not *B or *SB) */ 182 /* iBlitzz, BWU613 (not *B or *SB) */
203 { USB_DEVICE(0x07b8, 0xb000), USB_DEVICE_DATA(BOARD_503) }, 183 {USB_DEVICE(0x07b8, 0xb000), USB_DEVICE_DATA(BOARD_503)},
204 /* Gigabyte GN-WLBM101 */ 184 /* Gigabyte GN-WLBM101 */
205 { USB_DEVICE(0x1044, 0x8003), USB_DEVICE_DATA(BOARD_503) }, 185 {USB_DEVICE(0x1044, 0x8003), USB_DEVICE_DATA(BOARD_503)},
206 /* Planex GW-US11S */ 186 /* Planex GW-US11S */
207 { USB_DEVICE(0x2019, 0x3220), USB_DEVICE_DATA(BOARD_503) }, 187 {USB_DEVICE(0x2019, 0x3220), USB_DEVICE_DATA(BOARD_503)},
208 /* Internal WLAN adapter in h5[4,5]xx series iPAQs */ 188 /* Internal WLAN adapter in h5[4,5]xx series iPAQs */
209 { USB_DEVICE(0x049f, 0x0032), USB_DEVICE_DATA(BOARD_503) }, 189 {USB_DEVICE(0x049f, 0x0032), USB_DEVICE_DATA(BOARD_503)},
210 /* Corega Wireless LAN USB-11 mini */ 190 /* Corega Wireless LAN USB-11 mini */
211 { USB_DEVICE(0x07aa, 0x0011), USB_DEVICE_DATA(BOARD_503) }, 191 {USB_DEVICE(0x07aa, 0x0011), USB_DEVICE_DATA(BOARD_503)},
212 /* Corega Wireless LAN USB-11 mini2 */ 192 /* Corega Wireless LAN USB-11 mini2 */
213 { USB_DEVICE(0x07aa, 0x0018), USB_DEVICE_DATA(BOARD_503) }, 193 {USB_DEVICE(0x07aa, 0x0018), USB_DEVICE_DATA(BOARD_503)},
214 /* Uniden PCW100 */ 194 /* Uniden PCW100 */
215 { USB_DEVICE(0x05dd, 0xff35), USB_DEVICE_DATA(BOARD_503) }, 195 {USB_DEVICE(0x05dd, 0xff35), USB_DEVICE_DATA(BOARD_503)},
216 /* 196 /*
217 * at76c503-rfmd-acc 197 * at76c503-rfmd-acc
218 */ 198 */
219 /* SMC2664W */ 199 /* SMC2664W */
220 { USB_DEVICE(0x083a, 0x3501), USB_DEVICE_DATA(BOARD_503_ACC) }, 200 {USB_DEVICE(0x083a, 0x3501), USB_DEVICE_DATA(BOARD_503_ACC)},
221 /* Belkin F5D6050, SMC2662W v2, SMC2662W-AR */ 201 /* Belkin F5D6050, SMC2662W v2, SMC2662W-AR */
222 { USB_DEVICE(0x0d5c, 0xa002), USB_DEVICE_DATA(BOARD_503_ACC) }, 202 {USB_DEVICE(0x0d5c, 0xa002), USB_DEVICE_DATA(BOARD_503_ACC)},
223 /* 203 /*
224 * at76c505-rfmd 204 * at76c505-rfmd
225 */ 205 */
226 /* Generic AT76C505/RFMD */ 206 /* Generic AT76C505/RFMD */
227 { USB_DEVICE(0x03eb, 0x7606), USB_DEVICE_DATA(BOARD_505) }, 207 {USB_DEVICE(0x03eb, 0x7606), USB_DEVICE_DATA(BOARD_505)},
228 /* 208 /*
229 * at76c505-rfmd2958 209 * at76c505-rfmd2958
230 */ 210 */
231 /* Generic AT76C505/RFMD, OvisLink WL-1130USB */ 211 /* Generic AT76C505/RFMD, OvisLink WL-1130USB */
232 { USB_DEVICE(0x03eb, 0x7613), USB_DEVICE_DATA(BOARD_505_2958) }, 212 {USB_DEVICE(0x03eb, 0x7613), USB_DEVICE_DATA(BOARD_505_2958)},
233 /* Fiberline FL-WL240U */ 213 /* Fiberline FL-WL240U */
234 { USB_DEVICE(0x1371, 0x0014), USB_DEVICE_DATA(BOARD_505_2958) }, 214 {USB_DEVICE(0x1371, 0x0014), USB_DEVICE_DATA(BOARD_505_2958)},
235 /* CNet CNUSB-611G */ 215 /* CNet CNUSB-611G */
236 { USB_DEVICE(0x1371, 0x0013), USB_DEVICE_DATA(BOARD_505_2958) }, 216 {USB_DEVICE(0x1371, 0x0013), USB_DEVICE_DATA(BOARD_505_2958)},
237 /* Linksys WUSB11 v2.8 */ 217 /* Linksys WUSB11 v2.8 */
238 { USB_DEVICE(0x1915, 0x2233), USB_DEVICE_DATA(BOARD_505_2958) }, 218 {USB_DEVICE(0x1915, 0x2233), USB_DEVICE_DATA(BOARD_505_2958)},
239 /* Xterasys XN-2122B, IBlitzz BWU613B/BWU613SB */ 219 /* Xterasys XN-2122B, IBlitzz BWU613B/BWU613SB */
240 { USB_DEVICE(0x12fd, 0x1001), USB_DEVICE_DATA(BOARD_505_2958) }, 220 {USB_DEVICE(0x12fd, 0x1001), USB_DEVICE_DATA(BOARD_505_2958)},
241 /* Corega WLAN USB Stick 11 */ 221 /* Corega WLAN USB Stick 11 */
242 { USB_DEVICE(0x07aa, 0x7613), USB_DEVICE_DATA(BOARD_505_2958) }, 222 {USB_DEVICE(0x07aa, 0x7613), USB_DEVICE_DATA(BOARD_505_2958)},
243 /* Microstar MSI Box MS6978 */ 223 /* Microstar MSI Box MS6978 */
244 { USB_DEVICE(0x0db0, 0x1020), USB_DEVICE_DATA(BOARD_505_2958) }, 224 {USB_DEVICE(0x0db0, 0x1020), USB_DEVICE_DATA(BOARD_505_2958)},
245 /* 225 /*
246 * at76c505a-rfmd2958 226 * at76c505a-rfmd2958
247 */ 227 */
248 /* Generic AT76C505A device */ 228 /* Generic AT76C505A device */
249 { USB_DEVICE(0x03eb, 0x7614), USB_DEVICE_DATA(BOARD_505A) }, 229 {USB_DEVICE(0x03eb, 0x7614), USB_DEVICE_DATA(BOARD_505A)},
250 /* Generic AT76C505AS device */ 230 /* Generic AT76C505AS device */
251 { USB_DEVICE(0x03eb, 0x7617), USB_DEVICE_DATA(BOARD_505A) }, 231 {USB_DEVICE(0x03eb, 0x7617), USB_DEVICE_DATA(BOARD_505A)},
252 /* Siemens Gigaset USB WLAN Adapter 11 */ 232 /* Siemens Gigaset USB WLAN Adapter 11 */
253 { USB_DEVICE(0x1690, 0x0701), USB_DEVICE_DATA(BOARD_505A) }, 233 {USB_DEVICE(0x1690, 0x0701), USB_DEVICE_DATA(BOARD_505A)},
234 /* OQO Model 01+ Internal Wi-Fi */
235 {USB_DEVICE(0x1557, 0x0002), USB_DEVICE_DATA(BOARD_505A)},
254 /* 236 /*
255 * at76c505amx-rfmd 237 * at76c505amx-rfmd
256 */ 238 */
257 /* Generic AT76C505AMX device */ 239 /* Generic AT76C505AMX device */
258 { USB_DEVICE(0x03eb, 0x7615), USB_DEVICE_DATA(BOARD_505AMX) }, 240 {USB_DEVICE(0x03eb, 0x7615), USB_DEVICE_DATA(BOARD_505AMX)},
259 { } 241 {}
260}; 242};
261 243
262MODULE_DEVICE_TABLE(usb, dev_table); 244MODULE_DEVICE_TABLE(usb, dev_table);
@@ -264,8 +246,26 @@ MODULE_DEVICE_TABLE(usb, dev_table);
264/* Supported rates of this hardware, bit 7 marks basic rates */ 246/* Supported rates of this hardware, bit 7 marks basic rates */
265static const u8 hw_rates[] = { 0x82, 0x84, 0x0b, 0x16 }; 247static const u8 hw_rates[] = { 0x82, 0x84, 0x0b, 0x16 };
266 248
249/* Frequency of each channel in MHz */
250static const long channel_frequency[] = {
251 2412, 2417, 2422, 2427, 2432, 2437, 2442,
252 2447, 2452, 2457, 2462, 2467, 2472, 2484
253};
254
255#define NUM_CHANNELS ARRAY_SIZE(channel_frequency)
256
267static const char *const preambles[] = { "long", "short", "auto" }; 257static const char *const preambles[] = { "long", "short", "auto" };
268 258
259static const char *const mac_states[] = {
260 [MAC_INIT] = "INIT",
261 [MAC_SCANNING] = "SCANNING",
262 [MAC_AUTH] = "AUTH",
263 [MAC_ASSOC] = "ASSOC",
264 [MAC_JOINING] = "JOINING",
265 [MAC_CONNECTED] = "CONNECTED",
266 [MAC_OWN_IBSS] = "OWN_IBSS"
267};
268
269/* Firmware download */ 269/* Firmware download */
270/* DFU states */ 270/* DFU states */
271#define STATE_IDLE 0x00 271#define STATE_IDLE 0x00
@@ -300,30 +300,17 @@ struct dfu_status {
300 300
301static inline int at76_is_intersil(enum board_type board) 301static inline int at76_is_intersil(enum board_type board)
302{ 302{
303 if (board == BOARD_503_ISL3861 || board == BOARD_503_ISL3863) 303 return (board == BOARD_503_ISL3861 || board == BOARD_503_ISL3863);
304 return 1;
305 return 0;
306} 304}
307 305
308static inline int at76_is_503rfmd(enum board_type board) 306static inline int at76_is_503rfmd(enum board_type board)
309{ 307{
310 if (board == BOARD_503 || board == BOARD_503_ACC) 308 return (board == BOARD_503 || board == BOARD_503_ACC);
311 return 1;
312 return 0;
313}
314
315static inline int at76_is_505(enum board_type board)
316{
317 if (board == BOARD_505 || board == BOARD_505_2958)
318 return 1;
319 return 0;
320} 309}
321 310
322static inline int at76_is_505a(enum board_type board) 311static inline int at76_is_505a(enum board_type board)
323{ 312{
324 if (board == BOARD_505A || board == BOARD_505AMX) 313 return (board == BOARD_505A || board == BOARD_505AMX);
325 return 1;
326 return 0;
327} 314}
328 315
329/* Load a block of the first (internal) part of the firmware */ 316/* Load a block of the first (internal) part of the firmware */
@@ -504,6 +491,41 @@ exit:
504 return ret; 491 return ret;
505} 492}
506 493
494/* Report that the scan results are ready */
495static inline void at76_iwevent_scan_complete(struct net_device *netdev)
496{
497 union iwreq_data wrqu;
498 wrqu.data.length = 0;
499 wrqu.data.flags = 0;
500 wireless_send_event(netdev, SIOCGIWSCAN, &wrqu, NULL);
501 at76_dbg(DBG_WE_EVENTS, "%s: SIOCGIWSCAN sent", netdev->name);
502}
503
504static inline void at76_iwevent_bss_connect(struct net_device *netdev,
505 u8 *bssid)
506{
507 union iwreq_data wrqu;
508 wrqu.data.length = 0;
509 wrqu.data.flags = 0;
510 memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
511 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
512 wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
513 at76_dbg(DBG_WE_EVENTS, "%s: %s: SIOCGIWAP sent", netdev->name,
514 __func__);
515}
516
517static inline void at76_iwevent_bss_disconnect(struct net_device *netdev)
518{
519 union iwreq_data wrqu;
520 wrqu.data.length = 0;
521 wrqu.data.flags = 0;
522 memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN);
523 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
524 wireless_send_event(netdev, SIOCGIWAP, &wrqu, NULL);
525 at76_dbg(DBG_WE_EVENTS, "%s: %s: SIOCGIWAP sent", netdev->name,
526 __func__);
527}
528
507#define HEX2STR_BUFFERS 4 529#define HEX2STR_BUFFERS 4
508#define HEX2STR_MAX_LEN 64 530#define HEX2STR_MAX_LEN 64
509#define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10) 531#define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10)
@@ -575,6 +597,37 @@ static void at76_ledtrig_tx_activity(void)
575 mod_timer(&ledtrig_tx_timer, jiffies + HZ / 4); 597 mod_timer(&ledtrig_tx_timer, jiffies + HZ / 4);
576} 598}
577 599
600/* Check if the given ssid is hidden */
601static inline int at76_is_hidden_ssid(u8 *ssid, int length)
602{
603 static const u8 zeros[32];
604
605 if (length == 0)
606 return 1;
607
608 if (length == 1 && ssid[0] == ' ')
609 return 1;
610
611 return (memcmp(ssid, zeros, length) == 0);
612}
613
614static inline void at76_free_bss_list(struct at76_priv *priv)
615{
616 struct list_head *next, *ptr;
617 unsigned long flags;
618
619 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
620
621 priv->curr_bss = NULL;
622
623 list_for_each_safe(ptr, next, &priv->bss_list) {
624 list_del(ptr);
625 kfree(list_entry(ptr, struct bss_info, list));
626 }
627
628 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
629}
630
578static int at76_remap(struct usb_device *udev) 631static int at76_remap(struct usb_device *udev)
579{ 632{
580 int ret; 633 int ret;
@@ -598,7 +651,7 @@ static int at76_get_op_mode(struct usb_device *udev)
598 return -ENOMEM; 651 return -ENOMEM;
599 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, 652 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33,
600 USB_TYPE_VENDOR | USB_DIR_IN | 653 USB_TYPE_VENDOR | USB_DIR_IN |
601 USB_RECIP_INTERFACE, 0x01, 0, &op_mode, 1, 654 USB_RECIP_INTERFACE, 0x01, 0, op_mode, 1,
602 USB_CTRL_GET_TIMEOUT); 655 USB_CTRL_GET_TIMEOUT);
603 saved = *op_mode; 656 saved = *op_mode;
604 kfree(op_mode); 657 kfree(op_mode);
@@ -676,7 +729,7 @@ exit:
676 kfree(hwcfg); 729 kfree(hwcfg);
677 if (ret < 0) 730 if (ret < 0)
678 printk(KERN_ERR "%s: cannot get HW Config (error %d)\n", 731 printk(KERN_ERR "%s: cannot get HW Config (error %d)\n",
679 wiphy_name(priv->hw->wiphy), ret); 732 priv->netdev->name, ret);
680 733
681 return ret; 734 return ret;
682} 735}
@@ -685,15 +738,15 @@ static struct reg_domain const *at76_get_reg_domain(u16 code)
685{ 738{
686 int i; 739 int i;
687 static struct reg_domain const fd_tab[] = { 740 static struct reg_domain const fd_tab[] = {
688 { 0x10, "FCC (USA)", 0x7ff }, /* ch 1-11 */ 741 {0x10, "FCC (USA)", 0x7ff}, /* ch 1-11 */
689 { 0x20, "IC (Canada)", 0x7ff }, /* ch 1-11 */ 742 {0x20, "IC (Canada)", 0x7ff}, /* ch 1-11 */
690 { 0x30, "ETSI (most of Europe)", 0x1fff }, /* ch 1-13 */ 743 {0x30, "ETSI (most of Europe)", 0x1fff}, /* ch 1-13 */
691 { 0x31, "Spain", 0x600 }, /* ch 10-11 */ 744 {0x31, "Spain", 0x600}, /* ch 10-11 */
692 { 0x32, "France", 0x1e00 }, /* ch 10-13 */ 745 {0x32, "France", 0x1e00}, /* ch 10-13 */
693 { 0x40, "MKK (Japan)", 0x2000 }, /* ch 14 */ 746 {0x40, "MKK (Japan)", 0x2000}, /* ch 14 */
694 { 0x41, "MKK1 (Japan)", 0x3fff }, /* ch 1-14 */ 747 {0x41, "MKK1 (Japan)", 0x3fff}, /* ch 1-14 */
695 { 0x50, "Israel", 0x3fc }, /* ch 3-9 */ 748 {0x50, "Israel", 0x3fc}, /* ch 3-9 */
696 { 0x00, "<unknown>", 0xffffffff } /* ch 1-32 */ 749 {0x00, "<unknown>", 0xffffffff} /* ch 1-32 */
697 }; 750 };
698 751
699 /* Last entry is fallback for unknown domain code */ 752 /* Last entry is fallback for unknown domain code */
@@ -731,7 +784,7 @@ static inline int at76_get_cmd_status(struct usb_device *udev, u8 cmd)
731 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x22, 784 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x22,
732 USB_TYPE_VENDOR | USB_DIR_IN | 785 USB_TYPE_VENDOR | USB_DIR_IN |
733 USB_RECIP_INTERFACE, cmd, 0, stat_buf, 786 USB_RECIP_INTERFACE, cmd, 0, stat_buf,
734 sizeof(stat_buf), USB_CTRL_GET_TIMEOUT); 787 40, USB_CTRL_GET_TIMEOUT);
735 if (ret >= 0) 788 if (ret >= 0)
736 ret = stat_buf[5]; 789 ret = stat_buf[5];
737 kfree(stat_buf); 790 kfree(stat_buf);
@@ -739,24 +792,6 @@ static inline int at76_get_cmd_status(struct usb_device *udev, u8 cmd)
739 return ret; 792 return ret;
740} 793}
741 794
742#define MAKE_CMD_CASE(c) case (c): return #c
743
744static const char *at76_get_cmd_string(u8 cmd_status)
745{
746 switch (cmd_status) {
747 MAKE_CMD_CASE(CMD_SET_MIB);
748 MAKE_CMD_CASE(CMD_GET_MIB);
749 MAKE_CMD_CASE(CMD_SCAN);
750 MAKE_CMD_CASE(CMD_JOIN);
751 MAKE_CMD_CASE(CMD_START_IBSS);
752 MAKE_CMD_CASE(CMD_RADIO_ON);
753 MAKE_CMD_CASE(CMD_RADIO_OFF);
754 MAKE_CMD_CASE(CMD_STARTUP);
755 }
756
757 return "UNKNOWN";
758}
759
760static int at76_set_card_command(struct usb_device *udev, u8 cmd, void *buf, 795static int at76_set_card_command(struct usb_device *udev, u8 cmd, void *buf,
761 int buf_size) 796 int buf_size)
762{ 797{
@@ -772,10 +807,6 @@ static int at76_set_card_command(struct usb_device *udev, u8 cmd, void *buf,
772 cmd_buf->size = cpu_to_le16(buf_size); 807 cmd_buf->size = cpu_to_le16(buf_size);
773 memcpy(cmd_buf->data, buf, buf_size); 808 memcpy(cmd_buf->data, buf, buf_size);
774 809
775 at76_dbg_dump(DBG_CMD, cmd_buf, sizeof(struct at76_command) + buf_size,
776 "issuing command %s (0x%02x)",
777 at76_get_cmd_string(cmd), cmd);
778
779 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e, 810 ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e,
780 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 811 USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
781 0, 0, cmd_buf, 812 0, 0, cmd_buf,
@@ -813,13 +844,13 @@ static int at76_wait_completion(struct at76_priv *priv, int cmd)
813 status = at76_get_cmd_status(priv->udev, cmd); 844 status = at76_get_cmd_status(priv->udev, cmd);
814 if (status < 0) { 845 if (status < 0) {
815 printk(KERN_ERR "%s: at76_get_cmd_status failed: %d\n", 846 printk(KERN_ERR "%s: at76_get_cmd_status failed: %d\n",
816 wiphy_name(priv->hw->wiphy), status); 847 priv->netdev->name, status);
817 break; 848 break;
818 } 849 }
819 850
820 at76_dbg(DBG_WAIT_COMPLETE, 851 at76_dbg(DBG_WAIT_COMPLETE,
821 "%s: Waiting on cmd %d, status = %d (%s)", 852 "%s: Waiting on cmd %d, status = %d (%s)",
822 wiphy_name(priv->hw->wiphy), cmd, status, 853 priv->netdev->name, cmd, status,
823 at76_get_cmd_status_string(status)); 854 at76_get_cmd_status_string(status));
824 855
825 if (status != CMD_STATUS_IN_PROGRESS 856 if (status != CMD_STATUS_IN_PROGRESS
@@ -830,7 +861,7 @@ static int at76_wait_completion(struct at76_priv *priv, int cmd)
830 if (time_after(jiffies, timeout)) { 861 if (time_after(jiffies, timeout)) {
831 printk(KERN_ERR 862 printk(KERN_ERR
832 "%s: completion timeout for command %d\n", 863 "%s: completion timeout for command %d\n",
833 wiphy_name(priv->hw->wiphy), cmd); 864 priv->netdev->name, cmd);
834 status = -ETIMEDOUT; 865 status = -ETIMEDOUT;
835 break; 866 break;
836 } 867 }
@@ -853,7 +884,7 @@ static int at76_set_mib(struct at76_priv *priv, struct set_mib_buffer *buf)
853 if (ret != CMD_STATUS_COMPLETE) { 884 if (ret != CMD_STATUS_COMPLETE) {
854 printk(KERN_INFO 885 printk(KERN_INFO
855 "%s: set_mib: at76_wait_completion failed " 886 "%s: set_mib: at76_wait_completion failed "
856 "with %d\n", wiphy_name(priv->hw->wiphy), ret); 887 "with %d\n", priv->netdev->name, ret);
857 ret = -EIO; 888 ret = -EIO;
858 } 889 }
859 890
@@ -874,7 +905,7 @@ static int at76_set_radio(struct at76_priv *priv, int enable)
874 ret = at76_set_card_command(priv->udev, cmd, NULL, 0); 905 ret = at76_set_card_command(priv->udev, cmd, NULL, 0);
875 if (ret < 0) 906 if (ret < 0)
876 printk(KERN_ERR "%s: at76_set_card_command(%d) failed: %d\n", 907 printk(KERN_ERR "%s: at76_set_card_command(%d) failed: %d\n",
877 wiphy_name(priv->hw->wiphy), cmd, ret); 908 priv->netdev->name, cmd, ret);
878 else 909 else
879 ret = 1; 910 ret = 1;
880 911
@@ -895,7 +926,44 @@ static int at76_set_pm_mode(struct at76_priv *priv)
895 ret = at76_set_mib(priv, &priv->mib_buf); 926 ret = at76_set_mib(priv, &priv->mib_buf);
896 if (ret < 0) 927 if (ret < 0)
897 printk(KERN_ERR "%s: set_mib (pm_mode) failed: %d\n", 928 printk(KERN_ERR "%s: set_mib (pm_mode) failed: %d\n",
898 wiphy_name(priv->hw->wiphy), ret); 929 priv->netdev->name, ret);
930
931 return ret;
932}
933
934/* Set the association id for power save mode */
935static int at76_set_associd(struct at76_priv *priv, u16 id)
936{
937 int ret = 0;
938
939 priv->mib_buf.type = MIB_MAC_MGMT;
940 priv->mib_buf.size = 2;
941 priv->mib_buf.index = offsetof(struct mib_mac_mgmt, station_id);
942 priv->mib_buf.data.word = cpu_to_le16(id);
943
944 ret = at76_set_mib(priv, &priv->mib_buf);
945 if (ret < 0)
946 printk(KERN_ERR "%s: set_mib (associd) failed: %d\n",
947 priv->netdev->name, ret);
948
949 return ret;
950}
951
952/* Set the listen interval for power save mode */
953static int at76_set_listen_interval(struct at76_priv *priv, u16 interval)
954{
955 int ret = 0;
956
957 priv->mib_buf.type = MIB_MAC;
958 priv->mib_buf.size = 2;
959 priv->mib_buf.index = offsetof(struct mib_mac, listen_interval);
960 priv->mib_buf.data.word = cpu_to_le16(interval);
961
962 ret = at76_set_mib(priv, &priv->mib_buf);
963 if (ret < 0)
964 printk(KERN_ERR
965 "%s: set_mib (listen_interval) failed: %d\n",
966 priv->netdev->name, ret);
899 967
900 return ret; 968 return ret;
901} 969}
@@ -912,7 +980,7 @@ static int at76_set_preamble(struct at76_priv *priv, u8 type)
912 ret = at76_set_mib(priv, &priv->mib_buf); 980 ret = at76_set_mib(priv, &priv->mib_buf);
913 if (ret < 0) 981 if (ret < 0)
914 printk(KERN_ERR "%s: set_mib (preamble) failed: %d\n", 982 printk(KERN_ERR "%s: set_mib (preamble) failed: %d\n",
915 wiphy_name(priv->hw->wiphy), ret); 983 priv->netdev->name, ret);
916 984
917 return ret; 985 return ret;
918} 986}
@@ -929,7 +997,7 @@ static int at76_set_frag(struct at76_priv *priv, u16 size)
929 ret = at76_set_mib(priv, &priv->mib_buf); 997 ret = at76_set_mib(priv, &priv->mib_buf);
930 if (ret < 0) 998 if (ret < 0)
931 printk(KERN_ERR "%s: set_mib (frag threshold) failed: %d\n", 999 printk(KERN_ERR "%s: set_mib (frag threshold) failed: %d\n",
932 wiphy_name(priv->hw->wiphy), ret); 1000 priv->netdev->name, ret);
933 1001
934 return ret; 1002 return ret;
935} 1003}
@@ -946,7 +1014,7 @@ static int at76_set_rts(struct at76_priv *priv, u16 size)
946 ret = at76_set_mib(priv, &priv->mib_buf); 1014 ret = at76_set_mib(priv, &priv->mib_buf);
947 if (ret < 0) 1015 if (ret < 0)
948 printk(KERN_ERR "%s: set_mib (rts) failed: %d\n", 1016 printk(KERN_ERR "%s: set_mib (rts) failed: %d\n",
949 wiphy_name(priv->hw->wiphy), ret); 1017 priv->netdev->name, ret);
950 1018
951 return ret; 1019 return ret;
952} 1020}
@@ -963,41 +1031,24 @@ static int at76_set_autorate_fallback(struct at76_priv *priv, int onoff)
963 ret = at76_set_mib(priv, &priv->mib_buf); 1031 ret = at76_set_mib(priv, &priv->mib_buf);
964 if (ret < 0) 1032 if (ret < 0)
965 printk(KERN_ERR "%s: set_mib (autorate fallback) failed: %d\n", 1033 printk(KERN_ERR "%s: set_mib (autorate fallback) failed: %d\n",
966 wiphy_name(priv->hw->wiphy), ret); 1034 priv->netdev->name, ret);
967 1035
968 return ret; 1036 return ret;
969} 1037}
970 1038
971static int at76_set_tkip_bssid(struct at76_priv *priv, const void *addr) 1039static int at76_add_mac_address(struct at76_priv *priv, void *addr)
972{ 1040{
973 int ret = 0; 1041 int ret = 0;
974 1042
975 priv->mib_buf.type = MIB_MAC_ENCRYPTION; 1043 priv->mib_buf.type = MIB_MAC_ADDR;
976 priv->mib_buf.size = ETH_ALEN; 1044 priv->mib_buf.size = ETH_ALEN;
977 priv->mib_buf.index = offsetof(struct mib_mac_encryption, tkip_bssid); 1045 priv->mib_buf.index = offsetof(struct mib_mac_addr, mac_addr);
978 memcpy(priv->mib_buf.data.addr, addr, ETH_ALEN); 1046 memcpy(priv->mib_buf.data.addr, addr, ETH_ALEN);
979 1047
980 ret = at76_set_mib(priv, &priv->mib_buf); 1048 ret = at76_set_mib(priv, &priv->mib_buf);
981 if (ret < 0) 1049 if (ret < 0)
982 printk(KERN_ERR "%s: set_mib (MAC_ENCRYPTION, tkip_bssid) failed: %d\n", 1050 printk(KERN_ERR "%s: set_mib (MAC_ADDR, mac_addr) failed: %d\n",
983 wiphy_name(priv->hw->wiphy), ret); 1051 priv->netdev->name, ret);
984
985 return ret;
986}
987
988static int at76_reset_rsc(struct at76_priv *priv)
989{
990 int ret = 0;
991
992 priv->mib_buf.type = MIB_MAC_ENCRYPTION;
993 priv->mib_buf.size = 4 * 8;
994 priv->mib_buf.index = offsetof(struct mib_mac_encryption, key_rsc);
995 memset(priv->mib_buf.data.data, 0 , priv->mib_buf.size);
996
997 ret = at76_set_mib(priv, &priv->mib_buf);
998 if (ret < 0)
999 printk(KERN_ERR "%s: set_mib (MAC_ENCRYPTION, key_rsc) failed: %d\n",
1000 wiphy_name(priv->hw->wiphy), ret);
1001 1052
1002 return ret; 1053 return ret;
1003} 1054}
@@ -1016,16 +1067,16 @@ static void at76_dump_mib_mac_addr(struct at76_priv *priv)
1016 sizeof(struct mib_mac_addr)); 1067 sizeof(struct mib_mac_addr));
1017 if (ret < 0) { 1068 if (ret < 0) {
1018 printk(KERN_ERR "%s: at76_get_mib (MAC_ADDR) failed: %d\n", 1069 printk(KERN_ERR "%s: at76_get_mib (MAC_ADDR) failed: %d\n",
1019 wiphy_name(priv->hw->wiphy), ret); 1070 priv->netdev->name, ret);
1020 goto exit; 1071 goto exit;
1021 } 1072 }
1022 1073
1023 at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x", 1074 at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x",
1024 wiphy_name(priv->hw->wiphy), 1075 priv->netdev->name,
1025 mac2str(m->mac_addr), m->res[0], m->res[1]); 1076 mac2str(m->mac_addr), m->res[0], m->res[1]);
1026 for (i = 0; i < ARRAY_SIZE(m->group_addr); i++) 1077 for (i = 0; i < ARRAY_SIZE(m->group_addr); i++)
1027 at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: group addr %d: %s, " 1078 at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: group addr %d: %s, "
1028 "status %d", wiphy_name(priv->hw->wiphy), i, 1079 "status %d", priv->netdev->name, i,
1029 mac2str(m->group_addr[i]), m->group_addr_status[i]); 1080 mac2str(m->group_addr[i]), m->group_addr_status[i]);
1030exit: 1081exit:
1031 kfree(m); 1082 kfree(m);
@@ -1045,13 +1096,13 @@ static void at76_dump_mib_mac_wep(struct at76_priv *priv)
1045 sizeof(struct mib_mac_wep)); 1096 sizeof(struct mib_mac_wep));
1046 if (ret < 0) { 1097 if (ret < 0) {
1047 printk(KERN_ERR "%s: at76_get_mib (MAC_WEP) failed: %d\n", 1098 printk(KERN_ERR "%s: at76_get_mib (MAC_WEP) failed: %d\n",
1048 wiphy_name(priv->hw->wiphy), ret); 1099 priv->netdev->name, ret);
1049 goto exit; 1100 goto exit;
1050 } 1101 }
1051 1102
1052 at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: priv_invoked %u def_key_id %u " 1103 at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: priv_invoked %u def_key_id %u "
1053 "key_len %u excl_unencr %u wep_icv_err %u wep_excluded %u " 1104 "key_len %u excl_unencr %u wep_icv_err %u wep_excluded %u "
1054 "encr_level %u key %d", wiphy_name(priv->hw->wiphy), 1105 "encr_level %u key %d", priv->netdev->name,
1055 m->privacy_invoked, m->wep_default_key_id, 1106 m->privacy_invoked, m->wep_default_key_id,
1056 m->wep_key_mapping_len, m->exclude_unencrypted, 1107 m->wep_key_mapping_len, m->exclude_unencrypted,
1057 le32_to_cpu(m->wep_icv_error_count), 1108 le32_to_cpu(m->wep_icv_error_count),
@@ -1063,55 +1114,12 @@ static void at76_dump_mib_mac_wep(struct at76_priv *priv)
1063 1114
1064 for (i = 0; i < WEP_KEYS; i++) 1115 for (i = 0; i < WEP_KEYS; i++)
1065 at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: key %d: %s", 1116 at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: key %d: %s",
1066 wiphy_name(priv->hw->wiphy), i, 1117 priv->netdev->name, i,
1067 hex2str(m->wep_default_keyvalue[i], key_len)); 1118 hex2str(m->wep_default_keyvalue[i], key_len));
1068exit: 1119exit:
1069 kfree(m); 1120 kfree(m);
1070} 1121}
1071 1122
1072static void at76_dump_mib_mac_encryption(struct at76_priv *priv)
1073{
1074 int i;
1075 int ret;
1076 /*int key_len;*/
1077 struct mib_mac_encryption *m;
1078
1079 m = kmalloc(sizeof(struct mib_mac_encryption), GFP_KERNEL);
1080 if (!m)
1081 return;
1082
1083 ret = at76_get_mib(priv->udev, MIB_MAC_ENCRYPTION, m,
1084 sizeof(struct mib_mac_encryption));
1085 if (ret < 0) {
1086 dev_err(&priv->udev->dev,
1087 "%s: at76_get_mib (MAC_ENCRYPTION) failed: %d\n",
1088 wiphy_name(priv->hw->wiphy), ret);
1089 goto exit;
1090 }
1091
1092 at76_dbg(DBG_MIB,
1093 "%s: MIB MAC_ENCRYPTION: tkip_bssid %s priv_invoked %u "
1094 "ciph_key_id %u grp_key_id %u excl_unencr %u "
1095 "ckip_key_perm %u wep_icv_err %u wep_excluded %u",
1096 wiphy_name(priv->hw->wiphy), mac2str(m->tkip_bssid),
1097 m->privacy_invoked, m->cipher_default_key_id,
1098 m->cipher_default_group_key_id, m->exclude_unencrypted,
1099 m->ckip_key_permutation,
1100 le32_to_cpu(m->wep_icv_error_count),
1101 le32_to_cpu(m->wep_excluded_count));
1102
1103 /*key_len = (m->encryption_level == 1) ?
1104 WEP_SMALL_KEY_LEN : WEP_LARGE_KEY_LEN;*/
1105
1106 for (i = 0; i < CIPHER_KEYS; i++)
1107 at76_dbg(DBG_MIB, "%s: MIB MAC_ENCRYPTION: key %d: %s",
1108 wiphy_name(priv->hw->wiphy), i,
1109 hex2str(m->cipher_default_keyvalue[i],
1110 CIPHER_KEY_LEN));
1111exit:
1112 kfree(m);
1113}
1114
1115static void at76_dump_mib_mac_mgmt(struct at76_priv *priv) 1123static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
1116{ 1124{
1117 int ret; 1125 int ret;
@@ -1125,7 +1133,7 @@ static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
1125 sizeof(struct mib_mac_mgmt)); 1133 sizeof(struct mib_mac_mgmt));
1126 if (ret < 0) { 1134 if (ret < 0) {
1127 printk(KERN_ERR "%s: at76_get_mib (MAC_MGMT) failed: %d\n", 1135 printk(KERN_ERR "%s: at76_get_mib (MAC_MGMT) failed: %d\n",
1128 wiphy_name(priv->hw->wiphy), ret); 1136 priv->netdev->name, ret);
1129 goto exit; 1137 goto exit;
1130 } 1138 }
1131 1139
@@ -1136,7 +1144,7 @@ static void at76_dump_mib_mac_mgmt(struct at76_priv *priv)
1136 "pm_mode %d ibss_change %d res %d " 1144 "pm_mode %d ibss_change %d res %d "
1137 "multi_domain_capability_implemented %d " 1145 "multi_domain_capability_implemented %d "
1138 "international_roaming %d country_string %.3s", 1146 "international_roaming %d country_string %.3s",
1139 wiphy_name(priv->hw->wiphy), le16_to_cpu(m->beacon_period), 1147 priv->netdev->name, le16_to_cpu(m->beacon_period),
1140 le16_to_cpu(m->CFP_max_duration), 1148 le16_to_cpu(m->CFP_max_duration),
1141 le16_to_cpu(m->medium_occupancy_limit), 1149 le16_to_cpu(m->medium_occupancy_limit),
1142 le16_to_cpu(m->station_id), le16_to_cpu(m->ATIM_window), 1150 le16_to_cpu(m->station_id), le16_to_cpu(m->ATIM_window),
@@ -1161,7 +1169,7 @@ static void at76_dump_mib_mac(struct at76_priv *priv)
1161 ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac)); 1169 ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac));
1162 if (ret < 0) { 1170 if (ret < 0) {
1163 printk(KERN_ERR "%s: at76_get_mib (MAC) failed: %d\n", 1171 printk(KERN_ERR "%s: at76_get_mib (MAC) failed: %d\n",
1164 wiphy_name(priv->hw->wiphy), ret); 1172 priv->netdev->name, ret);
1165 goto exit; 1173 goto exit;
1166 } 1174 }
1167 1175
@@ -1171,8 +1179,7 @@ static void at76_dump_mib_mac(struct at76_priv *priv)
1171 "scan_type %d scan_channel %d probe_delay %u " 1179 "scan_type %d scan_channel %d probe_delay %u "
1172 "min_channel_time %d max_channel_time %d listen_int %d " 1180 "min_channel_time %d max_channel_time %d listen_int %d "
1173 "desired_ssid %s desired_bssid %s desired_bsstype %d", 1181 "desired_ssid %s desired_bssid %s desired_bsstype %d",
1174 wiphy_name(priv->hw->wiphy), 1182 priv->netdev->name, le32_to_cpu(m->max_tx_msdu_lifetime),
1175 le32_to_cpu(m->max_tx_msdu_lifetime),
1176 le32_to_cpu(m->max_rx_lifetime), 1183 le32_to_cpu(m->max_rx_lifetime),
1177 le16_to_cpu(m->frag_threshold), le16_to_cpu(m->rts_threshold), 1184 le16_to_cpu(m->frag_threshold), le16_to_cpu(m->rts_threshold),
1178 le16_to_cpu(m->cwmin), le16_to_cpu(m->cwmax), 1185 le16_to_cpu(m->cwmin), le16_to_cpu(m->cwmax),
@@ -1198,7 +1205,7 @@ static void at76_dump_mib_phy(struct at76_priv *priv)
1198 ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy)); 1205 ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy));
1199 if (ret < 0) { 1206 if (ret < 0) {
1200 printk(KERN_ERR "%s: at76_get_mib (PHY) failed: %d\n", 1207 printk(KERN_ERR "%s: at76_get_mib (PHY) failed: %d\n",
1201 wiphy_name(priv->hw->wiphy), ret); 1208 priv->netdev->name, ret);
1202 goto exit; 1209 goto exit;
1203 } 1210 }
1204 1211
@@ -1207,7 +1214,7 @@ static void at76_dump_mib_phy(struct at76_priv *priv)
1207 "mpdu_max_length %d cca_mode_supported %d operation_rate_set " 1214 "mpdu_max_length %d cca_mode_supported %d operation_rate_set "
1208 "0x%x 0x%x 0x%x 0x%x channel_id %d current_cca_mode %d " 1215 "0x%x 0x%x 0x%x 0x%x channel_id %d current_cca_mode %d "
1209 "phy_type %d current_reg_domain %d", 1216 "phy_type %d current_reg_domain %d",
1210 wiphy_name(priv->hw->wiphy), le32_to_cpu(m->ed_threshold), 1217 priv->netdev->name, le32_to_cpu(m->ed_threshold),
1211 le16_to_cpu(m->slot_time), le16_to_cpu(m->sifs_time), 1218 le16_to_cpu(m->slot_time), le16_to_cpu(m->sifs_time),
1212 le16_to_cpu(m->preamble_length), 1219 le16_to_cpu(m->preamble_length),
1213 le16_to_cpu(m->plcp_header_length), 1220 le16_to_cpu(m->plcp_header_length),
@@ -1231,14 +1238,13 @@ static void at76_dump_mib_local(struct at76_priv *priv)
1231 ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(struct mib_local)); 1238 ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(struct mib_local));
1232 if (ret < 0) { 1239 if (ret < 0) {
1233 printk(KERN_ERR "%s: at76_get_mib (LOCAL) failed: %d\n", 1240 printk(KERN_ERR "%s: at76_get_mib (LOCAL) failed: %d\n",
1234 wiphy_name(priv->hw->wiphy), ret); 1241 priv->netdev->name, ret);
1235 goto exit; 1242 goto exit;
1236 } 1243 }
1237 1244
1238 at76_dbg(DBG_MIB, "%s: MIB LOCAL: beacon_enable %d " 1245 at76_dbg(DBG_MIB, "%s: MIB LOCAL: beacon_enable %d "
1239 "txautorate_fallback %d ssid_size %d promiscuous_mode %d " 1246 "txautorate_fallback %d ssid_size %d promiscuous_mode %d "
1240 "preamble_type %d", wiphy_name(priv->hw->wiphy), 1247 "preamble_type %d", priv->netdev->name, m->beacon_enable,
1241 m->beacon_enable,
1242 m->txautorate_fallback, m->ssid_size, m->promiscuous_mode, 1248 m->txautorate_fallback, m->ssid_size, m->promiscuous_mode,
1243 m->preamble_type); 1249 m->preamble_type);
1244exit: 1250exit:
@@ -1257,21 +1263,118 @@ static void at76_dump_mib_mdomain(struct at76_priv *priv)
1257 sizeof(struct mib_mdomain)); 1263 sizeof(struct mib_mdomain));
1258 if (ret < 0) { 1264 if (ret < 0) {
1259 printk(KERN_ERR "%s: at76_get_mib (MDOMAIN) failed: %d\n", 1265 printk(KERN_ERR "%s: at76_get_mib (MDOMAIN) failed: %d\n",
1260 wiphy_name(priv->hw->wiphy), ret); 1266 priv->netdev->name, ret);
1261 goto exit; 1267 goto exit;
1262 } 1268 }
1263 1269
1264 at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s", 1270 at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s",
1265 wiphy_name(priv->hw->wiphy), 1271 priv->netdev->name,
1266 hex2str(m->channel_list, sizeof(m->channel_list))); 1272 hex2str(m->channel_list, sizeof(m->channel_list)));
1267 1273
1268 at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: tx_powerlevel %s", 1274 at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: tx_powerlevel %s",
1269 wiphy_name(priv->hw->wiphy), 1275 priv->netdev->name,
1270 hex2str(m->tx_powerlevel, sizeof(m->tx_powerlevel))); 1276 hex2str(m->tx_powerlevel, sizeof(m->tx_powerlevel)));
1271exit: 1277exit:
1272 kfree(m); 1278 kfree(m);
1273} 1279}
1274 1280
1281static int at76_get_current_bssid(struct at76_priv *priv)
1282{
1283 int ret = 0;
1284 struct mib_mac_mgmt *mac_mgmt =
1285 kmalloc(sizeof(struct mib_mac_mgmt), GFP_KERNEL);
1286
1287 if (!mac_mgmt) {
1288 ret = -ENOMEM;
1289 goto exit;
1290 }
1291
1292 ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, mac_mgmt,
1293 sizeof(struct mib_mac_mgmt));
1294 if (ret < 0) {
1295 printk(KERN_ERR "%s: at76_get_mib failed: %d\n",
1296 priv->netdev->name, ret);
1297 goto error;
1298 }
1299 memcpy(priv->bssid, mac_mgmt->current_bssid, ETH_ALEN);
1300 printk(KERN_INFO "%s: using BSSID %s\n", priv->netdev->name,
1301 mac2str(priv->bssid));
1302error:
1303 kfree(mac_mgmt);
1304exit:
1305 return ret;
1306}
1307
1308static int at76_get_current_channel(struct at76_priv *priv)
1309{
1310 int ret = 0;
1311 struct mib_phy *phy = kmalloc(sizeof(struct mib_phy), GFP_KERNEL);
1312
1313 if (!phy) {
1314 ret = -ENOMEM;
1315 goto exit;
1316 }
1317 ret = at76_get_mib(priv->udev, MIB_PHY, phy, sizeof(struct mib_phy));
1318 if (ret < 0) {
1319 printk(KERN_ERR "%s: at76_get_mib(MIB_PHY) failed: %d\n",
1320 priv->netdev->name, ret);
1321 goto error;
1322 }
1323 priv->channel = phy->channel_id;
1324error:
1325 kfree(phy);
1326exit:
1327 return ret;
1328}
1329
1330/**
1331 * at76_start_scan - start a scan
1332 *
1333 * @use_essid - use the configured ESSID in non passive mode
1334 */
1335static int at76_start_scan(struct at76_priv *priv, int use_essid)
1336{
1337 struct at76_req_scan scan;
1338
1339 memset(&scan, 0, sizeof(struct at76_req_scan));
1340 memset(scan.bssid, 0xff, ETH_ALEN);
1341
1342 if (use_essid) {
1343 memcpy(scan.essid, priv->essid, IW_ESSID_MAX_SIZE);
1344 scan.essid_size = priv->essid_size;
1345 } else
1346 scan.essid_size = 0;
1347
1348 /* jal: why should we start at a certain channel? we do scan the whole
1349 range allowed by reg domain. */
1350 scan.channel = priv->channel;
1351
1352 /* atmelwlandriver differs between scan type 0 and 1 (active/passive)
1353 For ad-hoc mode, it uses type 0 only. */
1354 scan.scan_type = priv->scan_mode;
1355
1356 /* INFO: For probe_delay, not multiplying by 1024 as this will be
1357 slightly less than min_channel_time
1358 (per spec: probe delay < min. channel time) */
1359 scan.min_channel_time = cpu_to_le16(priv->scan_min_time);
1360 scan.max_channel_time = cpu_to_le16(priv->scan_max_time);
1361 scan.probe_delay = cpu_to_le16(priv->scan_min_time * 1000);
1362 scan.international_scan = 0;
1363
1364 /* other values are set to 0 for type 0 */
1365
1366 at76_dbg(DBG_PROGRESS, "%s: start_scan (use_essid = %d, intl = %d, "
1367 "channel = %d, probe_delay = %d, scan_min_time = %d, "
1368 "scan_max_time = %d)",
1369 priv->netdev->name, use_essid,
1370 scan.international_scan, scan.channel,
1371 le16_to_cpu(scan.probe_delay),
1372 le16_to_cpu(scan.min_channel_time),
1373 le16_to_cpu(scan.max_channel_time));
1374
1375 return at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan));
1376}
1377
1275/* Enable monitor mode */ 1378/* Enable monitor mode */
1276static int at76_start_monitor(struct at76_priv *priv) 1379static int at76_start_monitor(struct at76_priv *priv)
1277{ 1380{
@@ -1292,6 +1395,86 @@ static int at76_start_monitor(struct at76_priv *priv)
1292 return ret; 1395 return ret;
1293} 1396}
1294 1397
1398static int at76_start_ibss(struct at76_priv *priv)
1399{
1400 struct at76_req_ibss bss;
1401 int ret;
1402
1403 WARN_ON(priv->mac_state != MAC_OWN_IBSS);
1404 if (priv->mac_state != MAC_OWN_IBSS)
1405 return -EBUSY;
1406
1407 memset(&bss, 0, sizeof(struct at76_req_ibss));
1408 memset(bss.bssid, 0xff, ETH_ALEN);
1409 memcpy(bss.essid, priv->essid, IW_ESSID_MAX_SIZE);
1410 bss.essid_size = priv->essid_size;
1411 bss.bss_type = ADHOC_MODE;
1412 bss.channel = priv->channel;
1413
1414 ret = at76_set_card_command(priv->udev, CMD_START_IBSS, &bss,
1415 sizeof(struct at76_req_ibss));
1416 if (ret < 0) {
1417 printk(KERN_ERR "%s: start_ibss failed: %d\n",
1418 priv->netdev->name, ret);
1419 return ret;
1420 }
1421
1422 ret = at76_wait_completion(priv, CMD_START_IBSS);
1423 if (ret != CMD_STATUS_COMPLETE) {
1424 printk(KERN_ERR "%s: start_ibss failed to complete, %d\n",
1425 priv->netdev->name, ret);
1426 return ret;
1427 }
1428
1429 ret = at76_get_current_bssid(priv);
1430 if (ret < 0)
1431 return ret;
1432
1433 ret = at76_get_current_channel(priv);
1434 if (ret < 0)
1435 return ret;
1436
1437 /* not sure what this is good for ??? */
1438 priv->mib_buf.type = MIB_MAC_MGMT;
1439 priv->mib_buf.size = 1;
1440 priv->mib_buf.index = offsetof(struct mib_mac_mgmt, ibss_change);
1441 priv->mib_buf.data.byte = 0;
1442
1443 ret = at76_set_mib(priv, &priv->mib_buf);
1444 if (ret < 0) {
1445 printk(KERN_ERR "%s: set_mib (ibss change ok) failed: %d\n",
1446 priv->netdev->name, ret);
1447 return ret;
1448 }
1449
1450 netif_carrier_on(priv->netdev);
1451 netif_start_queue(priv->netdev);
1452 return 0;
1453}
1454
1455/* Request card to join BSS in managed or ad-hoc mode */
1456static int at76_join_bss(struct at76_priv *priv, struct bss_info *ptr)
1457{
1458 struct at76_req_join join;
1459
1460 BUG_ON(!ptr);
1461
1462 memset(&join, 0, sizeof(struct at76_req_join));
1463 memcpy(join.bssid, ptr->bssid, ETH_ALEN);
1464 memcpy(join.essid, ptr->ssid, ptr->ssid_len);
1465 join.essid_size = ptr->ssid_len;
1466 join.bss_type = (priv->iw_mode == IW_MODE_ADHOC ? 1 : 2);
1467 join.channel = ptr->channel;
1468 join.timeout = cpu_to_le16(2000);
1469
1470 at76_dbg(DBG_PROGRESS,
1471 "%s join addr %s ssid %s type %d ch %d timeout %d",
1472 priv->netdev->name, mac2str(join.bssid), join.essid,
1473 join.bss_type, join.channel, le16_to_cpu(join.timeout));
1474 return at76_set_card_command(priv->udev, CMD_JOIN, &join,
1475 sizeof(struct at76_req_join));
1476}
1477
1295/* Calculate padding from txbuf->wlength (which excludes the USB TX header), 1478/* Calculate padding from txbuf->wlength (which excludes the USB TX header),
1296 likely to compensate a flaw in the AT76C503A USB part ... */ 1479 likely to compensate a flaw in the AT76C503A USB part ... */
1297static inline int at76_calc_padding(int wlen) 1480static inline int at76_calc_padding(int wlen)
@@ -1310,6 +1493,14 @@ static inline int at76_calc_padding(int wlen)
1310 return 0; 1493 return 0;
1311} 1494}
1312 1495
1496/* We are doing a lot of things here in an interrupt. Need
1497 a bh handler (Watching TV with a TV card is probably
1498 a good test: if you see flickers, we are doing too much.
1499 Currently I do see flickers... even with our tasklet :-( )
1500 Maybe because the bttv driver and usb-uhci use the same interrupt
1501*/
1502/* Or maybe because our BH handler is preempting bttv's BH handler.. BHs don't
1503 * solve everything.. (alex) */
1313static void at76_rx_callback(struct urb *urb) 1504static void at76_rx_callback(struct urb *urb)
1314{ 1505{
1315 struct at76_priv *priv = urb->context; 1506 struct at76_priv *priv = urb->context;
@@ -1319,6 +1510,1758 @@ static void at76_rx_callback(struct urb *urb)
1319 return; 1510 return;
1320} 1511}
1321 1512
1513static void at76_tx_callback(struct urb *urb)
1514{
1515 struct at76_priv *priv = urb->context;
1516 struct net_device_stats *stats = &priv->stats;
1517 unsigned long flags;
1518 struct at76_tx_buffer *mgmt_buf;
1519 int ret;
1520
1521 switch (urb->status) {
1522 case 0:
1523 stats->tx_packets++;
1524 break;
1525 case -ENOENT:
1526 case -ECONNRESET:
1527 /* urb has been unlinked */
1528 return;
1529 default:
1530 at76_dbg(DBG_URB, "%s - nonzero tx status received: %d",
1531 __func__, urb->status);
1532 stats->tx_errors++;
1533 break;
1534 }
1535
1536 spin_lock_irqsave(&priv->mgmt_spinlock, flags);
1537 mgmt_buf = priv->next_mgmt_bulk;
1538 priv->next_mgmt_bulk = NULL;
1539 spin_unlock_irqrestore(&priv->mgmt_spinlock, flags);
1540
1541 if (!mgmt_buf) {
1542 netif_wake_queue(priv->netdev);
1543 return;
1544 }
1545
1546 /* we don't copy the padding bytes, but add them
1547 to the length */
1548 memcpy(priv->bulk_out_buffer, mgmt_buf,
1549 le16_to_cpu(mgmt_buf->wlength) + AT76_TX_HDRLEN);
1550 usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe,
1551 priv->bulk_out_buffer,
1552 le16_to_cpu(mgmt_buf->wlength) + mgmt_buf->padding +
1553 AT76_TX_HDRLEN, at76_tx_callback, priv);
1554 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
1555 if (ret)
1556 printk(KERN_ERR "%s: error in tx submit urb: %d\n",
1557 priv->netdev->name, ret);
1558
1559 kfree(mgmt_buf);
1560}
1561
1562/* Send a management frame on bulk-out. txbuf->wlength must be set */
1563static int at76_tx_mgmt(struct at76_priv *priv, struct at76_tx_buffer *txbuf)
1564{
1565 unsigned long flags;
1566 int ret;
1567 int urb_status;
1568 void *oldbuf = NULL;
1569
1570 netif_carrier_off(priv->netdev); /* stop netdev watchdog */
1571 netif_stop_queue(priv->netdev); /* stop tx data packets */
1572
1573 spin_lock_irqsave(&priv->mgmt_spinlock, flags);
1574
1575 urb_status = priv->tx_urb->status;
1576 if (urb_status == -EINPROGRESS) {
1577 /* cannot transmit now, put in the queue */
1578 oldbuf = priv->next_mgmt_bulk;
1579 priv->next_mgmt_bulk = txbuf;
1580 }
1581 spin_unlock_irqrestore(&priv->mgmt_spinlock, flags);
1582
1583 if (oldbuf) {
1584 /* a data/mgmt tx is already pending in the URB -
1585 if this is no error in some situations we must
1586 implement a queue or silently modify the old msg */
1587 printk(KERN_ERR "%s: removed pending mgmt buffer %s\n",
1588 priv->netdev->name, hex2str(oldbuf, 64));
1589 kfree(oldbuf);
1590 return 0;
1591 }
1592
1593 txbuf->tx_rate = TX_RATE_1MBIT;
1594 txbuf->padding = at76_calc_padding(le16_to_cpu(txbuf->wlength));
1595 memset(txbuf->reserved, 0, sizeof(txbuf->reserved));
1596
1597 if (priv->next_mgmt_bulk)
1598 printk(KERN_ERR "%s: URB status %d, but mgmt is pending\n",
1599 priv->netdev->name, urb_status);
1600
1601 at76_dbg(DBG_TX_MGMT,
1602 "%s: tx mgmt: wlen %d tx_rate %d pad %d %s",
1603 priv->netdev->name, le16_to_cpu(txbuf->wlength),
1604 txbuf->tx_rate, txbuf->padding,
1605 hex2str(txbuf->packet, le16_to_cpu(txbuf->wlength)));
1606
1607 /* txbuf was not consumed above -> send mgmt msg immediately */
1608 memcpy(priv->bulk_out_buffer, txbuf,
1609 le16_to_cpu(txbuf->wlength) + AT76_TX_HDRLEN);
1610 usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe,
1611 priv->bulk_out_buffer,
1612 le16_to_cpu(txbuf->wlength) + txbuf->padding +
1613 AT76_TX_HDRLEN, at76_tx_callback, priv);
1614 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
1615 if (ret)
1616 printk(KERN_ERR "%s: error in tx submit urb: %d\n",
1617 priv->netdev->name, ret);
1618
1619 kfree(txbuf);
1620
1621 return ret;
1622}
1623
1624/* Go to the next information element */
1625static inline void next_ie(struct ieee80211_info_element **ie)
1626{
1627 *ie = (struct ieee80211_info_element *)(&(*ie)->data[(*ie)->len]);
1628}
1629
1630/* Challenge is the challenge string (in TLV format)
1631 we got with seq_nr 2 for shared secret authentication only and
1632 send in seq_nr 3 WEP encrypted to prove we have the correct WEP key;
1633 otherwise it is NULL */
1634static int at76_auth_req(struct at76_priv *priv, struct bss_info *bss,
1635 int seq_nr, struct ieee80211_info_element *challenge)
1636{
1637 struct at76_tx_buffer *tx_buffer;
1638 struct ieee80211_hdr_3addr *mgmt;
1639 struct ieee80211_auth *req;
1640 int buf_len = (seq_nr != 3 ? AUTH_FRAME_SIZE :
1641 AUTH_FRAME_SIZE + 1 + 1 + challenge->len);
1642
1643 BUG_ON(!bss);
1644 BUG_ON(seq_nr == 3 && !challenge);
1645 tx_buffer = kmalloc(buf_len + MAX_PADDING_SIZE, GFP_ATOMIC);
1646 if (!tx_buffer)
1647 return -ENOMEM;
1648
1649 req = (struct ieee80211_auth *)tx_buffer->packet;
1650 mgmt = &req->header;
1651
1652 /* make wireless header */
1653 /* first auth msg is not encrypted, only the second (seq_nr == 3) */
1654 mgmt->frame_ctl =
1655 cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH |
1656 (seq_nr == 3 ? IEEE80211_FCTL_PROTECTED : 0));
1657
1658 mgmt->duration_id = cpu_to_le16(0x8000);
1659 memcpy(mgmt->addr1, bss->bssid, ETH_ALEN);
1660 memcpy(mgmt->addr2, priv->netdev->dev_addr, ETH_ALEN);
1661 memcpy(mgmt->addr3, bss->bssid, ETH_ALEN);
1662 mgmt->seq_ctl = cpu_to_le16(0);
1663
1664 req->algorithm = cpu_to_le16(priv->auth_mode);
1665 req->transaction = cpu_to_le16(seq_nr);
1666 req->status = cpu_to_le16(0);
1667
1668 if (seq_nr == 3)
1669 memcpy(req->info_element, challenge, 1 + 1 + challenge->len);
1670
1671 /* init. at76_priv tx header */
1672 tx_buffer->wlength = cpu_to_le16(buf_len - AT76_TX_HDRLEN);
1673 at76_dbg(DBG_TX_MGMT, "%s: AuthReq bssid %s alg %d seq_nr %d",
1674 priv->netdev->name, mac2str(mgmt->addr3),
1675 le16_to_cpu(req->algorithm), le16_to_cpu(req->transaction));
1676 if (seq_nr == 3)
1677 at76_dbg(DBG_TX_MGMT, "%s: AuthReq challenge: %s ...",
1678 priv->netdev->name, hex2str(req->info_element, 18));
1679
1680 /* either send immediately (if no data tx is pending
1681 or put it in pending list */
1682 return at76_tx_mgmt(priv, tx_buffer);
1683}
1684
1685static int at76_assoc_req(struct at76_priv *priv, struct bss_info *bss)
1686{
1687 struct at76_tx_buffer *tx_buffer;
1688 struct ieee80211_hdr_3addr *mgmt;
1689 struct ieee80211_assoc_request *req;
1690 struct ieee80211_info_element *ie;
1691 char *essid;
1692 int essid_len;
1693 u16 capa;
1694
1695 BUG_ON(!bss);
1696
1697 tx_buffer = kmalloc(ASSOCREQ_MAX_SIZE + MAX_PADDING_SIZE, GFP_ATOMIC);
1698 if (!tx_buffer)
1699 return -ENOMEM;
1700
1701 req = (struct ieee80211_assoc_request *)tx_buffer->packet;
1702 mgmt = &req->header;
1703 ie = req->info_element;
1704
1705 /* make wireless header */
1706 mgmt->frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1707 IEEE80211_STYPE_ASSOC_REQ);
1708
1709 mgmt->duration_id = cpu_to_le16(0x8000);
1710 memcpy(mgmt->addr1, bss->bssid, ETH_ALEN);
1711 memcpy(mgmt->addr2, priv->netdev->dev_addr, ETH_ALEN);
1712 memcpy(mgmt->addr3, bss->bssid, ETH_ALEN);
1713 mgmt->seq_ctl = cpu_to_le16(0);
1714
1715 /* we must set the Privacy bit in the capabilities to assure an
1716 Agere-based AP with optional WEP transmits encrypted frames
1717 to us. AP only set the Privacy bit in their capabilities
1718 if WEP is mandatory in the BSS! */
1719 capa = bss->capa;
1720 if (priv->wep_enabled)
1721 capa |= WLAN_CAPABILITY_PRIVACY;
1722 if (priv->preamble_type != PREAMBLE_TYPE_LONG)
1723 capa |= WLAN_CAPABILITY_SHORT_PREAMBLE;
1724 req->capability = cpu_to_le16(capa);
1725
1726 req->listen_interval = cpu_to_le16(2 * bss->beacon_interval);
1727
1728 /* write TLV data elements */
1729
1730 ie->id = MFIE_TYPE_SSID;
1731 ie->len = bss->ssid_len;
1732 memcpy(ie->data, bss->ssid, bss->ssid_len);
1733 next_ie(&ie);
1734
1735 ie->id = MFIE_TYPE_RATES;
1736 ie->len = sizeof(hw_rates);
1737 memcpy(ie->data, hw_rates, sizeof(hw_rates));
1738 next_ie(&ie); /* ie points behind the supp_rates field */
1739
1740 /* init. at76_priv tx header */
1741 tx_buffer->wlength = cpu_to_le16((u8 *)ie - (u8 *)mgmt);
1742
1743 ie = req->info_element;
1744 essid = ie->data;
1745 essid_len = min_t(int, IW_ESSID_MAX_SIZE, ie->len);
1746
1747 next_ie(&ie); /* points to IE of rates now */
1748 at76_dbg(DBG_TX_MGMT,
1749 "%s: AssocReq bssid %s capa 0x%04x ssid %.*s rates %s",
1750 priv->netdev->name, mac2str(mgmt->addr3),
1751 le16_to_cpu(req->capability), essid_len, essid,
1752 hex2str(ie->data, ie->len));
1753
1754 /* either send immediately (if no data tx is pending
1755 or put it in pending list */
1756 return at76_tx_mgmt(priv, tx_buffer);
1757}
1758
1759/* We got to check the bss_list for old entries */
1760static void at76_bss_list_timeout(unsigned long par)
1761{
1762 struct at76_priv *priv = (struct at76_priv *)par;
1763 unsigned long flags;
1764 struct list_head *lptr, *nptr;
1765 struct bss_info *ptr;
1766
1767 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
1768
1769 list_for_each_safe(lptr, nptr, &priv->bss_list) {
1770
1771 ptr = list_entry(lptr, struct bss_info, list);
1772
1773 if (ptr != priv->curr_bss
1774 && time_after(jiffies, ptr->last_rx + BSS_LIST_TIMEOUT)) {
1775 at76_dbg(DBG_BSS_TABLE_RM,
1776 "%s: bss_list: removing old BSS %s ch %d",
1777 priv->netdev->name, mac2str(ptr->bssid),
1778 ptr->channel);
1779 list_del(&ptr->list);
1780 kfree(ptr);
1781 }
1782 }
1783 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
1784 /* restart the timer */
1785 mod_timer(&priv->bss_list_timer, jiffies + BSS_LIST_TIMEOUT);
1786}
1787
1788static inline void at76_set_mac_state(struct at76_priv *priv,
1789 enum mac_state mac_state)
1790{
1791 at76_dbg(DBG_MAC_STATE, "%s state: %s", priv->netdev->name,
1792 mac_states[mac_state]);
1793 priv->mac_state = mac_state;
1794}
1795
1796static void at76_dump_bss_table(struct at76_priv *priv)
1797{
1798 struct bss_info *ptr;
1799 unsigned long flags;
1800 struct list_head *lptr;
1801
1802 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
1803
1804 at76_dbg(DBG_BSS_TABLE, "%s BSS table (curr=%p):", priv->netdev->name,
1805 priv->curr_bss);
1806
1807 list_for_each(lptr, &priv->bss_list) {
1808 ptr = list_entry(lptr, struct bss_info, list);
1809 at76_dbg(DBG_BSS_TABLE, "0x%p: bssid %s channel %d ssid %.*s "
1810 "(%s) capa 0x%04x rates %s rssi %d link %d noise %d",
1811 ptr, mac2str(ptr->bssid), ptr->channel, ptr->ssid_len,
1812 ptr->ssid, hex2str(ptr->ssid, ptr->ssid_len),
1813 ptr->capa, hex2str(ptr->rates, ptr->rates_len),
1814 ptr->rssi, ptr->link_qual, ptr->noise_level);
1815 }
1816 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
1817}
1818
1819/* Called upon successful association to mark interface as connected */
1820static void at76_work_assoc_done(struct work_struct *work)
1821{
1822 struct at76_priv *priv = container_of(work, struct at76_priv,
1823 work_assoc_done);
1824
1825 mutex_lock(&priv->mtx);
1826
1827 WARN_ON(priv->mac_state != MAC_ASSOC);
1828 WARN_ON(!priv->curr_bss);
1829 if (priv->mac_state != MAC_ASSOC || !priv->curr_bss)
1830 goto exit;
1831
1832 if (priv->iw_mode == IW_MODE_INFRA) {
1833 if (priv->pm_mode != AT76_PM_OFF) {
1834 /* calculate the listen interval in units of
1835 beacon intervals of the curr_bss */
1836 u32 pm_period_beacon = (priv->pm_period >> 10) /
1837 priv->curr_bss->beacon_interval;
1838
1839 pm_period_beacon = max(pm_period_beacon, 2u);
1840 pm_period_beacon = min(pm_period_beacon, 0xffffu);
1841
1842 at76_dbg(DBG_PM,
1843 "%s: pm_mode %d assoc id 0x%x listen int %d",
1844 priv->netdev->name, priv->pm_mode,
1845 priv->assoc_id, pm_period_beacon);
1846
1847 at76_set_associd(priv, priv->assoc_id);
1848 at76_set_listen_interval(priv, (u16)pm_period_beacon);
1849 }
1850 schedule_delayed_work(&priv->dwork_beacon, BEACON_TIMEOUT);
1851 }
1852 at76_set_pm_mode(priv);
1853
1854 netif_carrier_on(priv->netdev);
1855 netif_wake_queue(priv->netdev);
1856 at76_set_mac_state(priv, MAC_CONNECTED);
1857 at76_iwevent_bss_connect(priv->netdev, priv->curr_bss->bssid);
1858 at76_dbg(DBG_PROGRESS, "%s: connected to BSSID %s",
1859 priv->netdev->name, mac2str(priv->curr_bss->bssid));
1860
1861exit:
1862 mutex_unlock(&priv->mtx);
1863}
1864
1865/* We only store the new mac address in netdev struct,
1866 it gets set when the netdev is opened. */
1867static int at76_set_mac_address(struct net_device *netdev, void *addr)
1868{
1869 struct sockaddr *mac = addr;
1870 memcpy(netdev->dev_addr, mac->sa_data, ETH_ALEN);
1871 return 1;
1872}
1873
1874static struct net_device_stats *at76_get_stats(struct net_device *netdev)
1875{
1876 struct at76_priv *priv = netdev_priv(netdev);
1877 return &priv->stats;
1878}
1879
1880static struct iw_statistics *at76_get_wireless_stats(struct net_device *netdev)
1881{
1882 struct at76_priv *priv = netdev_priv(netdev);
1883
1884 at76_dbg(DBG_IOCTL, "RETURN qual %d level %d noise %d updated %d",
1885 priv->wstats.qual.qual, priv->wstats.qual.level,
1886 priv->wstats.qual.noise, priv->wstats.qual.updated);
1887
1888 return &priv->wstats;
1889}
1890
1891static void at76_set_multicast(struct net_device *netdev)
1892{
1893 struct at76_priv *priv = netdev_priv(netdev);
1894 int promisc;
1895
1896 promisc = ((netdev->flags & IFF_PROMISC) != 0);
1897 if (promisc != priv->promisc) {
1898 /* This gets called in interrupt, must reschedule */
1899 priv->promisc = promisc;
1900 schedule_work(&priv->work_set_promisc);
1901 }
1902}
1903
1904/* Stop all network activity, flush all pending tasks */
1905static void at76_quiesce(struct at76_priv *priv)
1906{
1907 unsigned long flags;
1908
1909 netif_stop_queue(priv->netdev);
1910 netif_carrier_off(priv->netdev);
1911
1912 at76_set_mac_state(priv, MAC_INIT);
1913
1914 cancel_delayed_work(&priv->dwork_get_scan);
1915 cancel_delayed_work(&priv->dwork_beacon);
1916 cancel_delayed_work(&priv->dwork_auth);
1917 cancel_delayed_work(&priv->dwork_assoc);
1918 cancel_delayed_work(&priv->dwork_restart);
1919
1920 spin_lock_irqsave(&priv->mgmt_spinlock, flags);
1921 kfree(priv->next_mgmt_bulk);
1922 priv->next_mgmt_bulk = NULL;
1923 spin_unlock_irqrestore(&priv->mgmt_spinlock, flags);
1924}
1925
1926/*******************************************************************************
1927 * at76_priv implementations of iw_handler functions:
1928 */
1929static int at76_iw_handler_commit(struct net_device *netdev,
1930 struct iw_request_info *info,
1931 void *null, char *extra)
1932{
1933 struct at76_priv *priv = netdev_priv(netdev);
1934
1935 at76_dbg(DBG_IOCTL, "%s %s: restarting the device", netdev->name,
1936 __func__);
1937
1938 if (priv->mac_state != MAC_INIT)
1939 at76_quiesce(priv);
1940
1941 /* Wait half second before the restart to process subsequent
1942 * requests from the same iwconfig in a single restart */
1943 schedule_delayed_work(&priv->dwork_restart, HZ / 2);
1944
1945 return 0;
1946}
1947
1948static int at76_iw_handler_get_name(struct net_device *netdev,
1949 struct iw_request_info *info,
1950 char *name, char *extra)
1951{
1952 strcpy(name, "IEEE 802.11b");
1953 at76_dbg(DBG_IOCTL, "%s: SIOCGIWNAME - name %s", netdev->name, name);
1954 return 0;
1955}
1956
1957static int at76_iw_handler_set_freq(struct net_device *netdev,
1958 struct iw_request_info *info,
1959 struct iw_freq *freq, char *extra)
1960{
1961 struct at76_priv *priv = netdev_priv(netdev);
1962 int chan = -1;
1963 int ret = -EIWCOMMIT;
1964 at76_dbg(DBG_IOCTL, "%s: SIOCSIWFREQ - freq.m %d freq.e %d",
1965 netdev->name, freq->m, freq->e);
1966
1967 if ((freq->e == 0) && (freq->m <= 1000))
1968 /* Setting by channel number */
1969 chan = freq->m;
1970 else {
1971 /* Setting by frequency - search the table */
1972 int mult = 1;
1973 int i;
1974
1975 for (i = 0; i < (6 - freq->e); i++)
1976 mult *= 10;
1977
1978 for (i = 0; i < NUM_CHANNELS; i++) {
1979 if (freq->m == (channel_frequency[i] * mult))
1980 chan = i + 1;
1981 }
1982 }
1983
1984 if (chan < 1 || !priv->domain)
1985 /* non-positive channels are invalid
1986 * we need a domain info to set the channel
1987 * either that or an invalid frequency was
1988 * provided by the user */
1989 ret = -EINVAL;
1990 else if (!(priv->domain->channel_map & (1 << (chan - 1)))) {
1991 printk(KERN_INFO "%s: channel %d not allowed for domain %s\n",
1992 priv->netdev->name, chan, priv->domain->name);
1993 ret = -EINVAL;
1994 }
1995
1996 if (ret == -EIWCOMMIT) {
1997 priv->channel = chan;
1998 at76_dbg(DBG_IOCTL, "%s: SIOCSIWFREQ - ch %d", netdev->name,
1999 chan);
2000 }
2001
2002 return ret;
2003}
2004
2005static int at76_iw_handler_get_freq(struct net_device *netdev,
2006 struct iw_request_info *info,
2007 struct iw_freq *freq, char *extra)
2008{
2009 struct at76_priv *priv = netdev_priv(netdev);
2010
2011 freq->m = priv->channel;
2012 freq->e = 0;
2013
2014 if (priv->channel)
2015 at76_dbg(DBG_IOCTL, "%s: SIOCGIWFREQ - freq %ld x 10e%d",
2016 netdev->name, channel_frequency[priv->channel - 1], 6);
2017
2018 at76_dbg(DBG_IOCTL, "%s: SIOCGIWFREQ - ch %d", netdev->name,
2019 priv->channel);
2020
2021 return 0;
2022}
2023
2024static int at76_iw_handler_set_mode(struct net_device *netdev,
2025 struct iw_request_info *info,
2026 __u32 *mode, char *extra)
2027{
2028 struct at76_priv *priv = netdev_priv(netdev);
2029
2030 at76_dbg(DBG_IOCTL, "%s: SIOCSIWMODE - %d", netdev->name, *mode);
2031
2032 if ((*mode != IW_MODE_ADHOC) && (*mode != IW_MODE_INFRA) &&
2033 (*mode != IW_MODE_MONITOR))
2034 return -EINVAL;
2035
2036 priv->iw_mode = *mode;
2037 if (priv->iw_mode != IW_MODE_INFRA)
2038 priv->pm_mode = AT76_PM_OFF;
2039
2040 return -EIWCOMMIT;
2041}
2042
2043static int at76_iw_handler_get_mode(struct net_device *netdev,
2044 struct iw_request_info *info,
2045 __u32 *mode, char *extra)
2046{
2047 struct at76_priv *priv = netdev_priv(netdev);
2048
2049 *mode = priv->iw_mode;
2050
2051 at76_dbg(DBG_IOCTL, "%s: SIOCGIWMODE - %d", netdev->name, *mode);
2052
2053 return 0;
2054}
2055
2056static int at76_iw_handler_get_range(struct net_device *netdev,
2057 struct iw_request_info *info,
2058 struct iw_point *data, char *extra)
2059{
2060 /* inspired by atmel.c */
2061 struct at76_priv *priv = netdev_priv(netdev);
2062 struct iw_range *range = (struct iw_range *)extra;
2063 int i;
2064
2065 data->length = sizeof(struct iw_range);
2066 memset(range, 0, sizeof(struct iw_range));
2067
2068 /* TODO: range->throughput = xxxxxx; */
2069
2070 range->min_nwid = 0x0000;
2071 range->max_nwid = 0x0000;
2072
2073 /* this driver doesn't maintain sensitivity information */
2074 range->sensitivity = 0;
2075
2076 range->max_qual.qual = 100;
2077 range->max_qual.level = 100;
2078 range->max_qual.noise = 0;
2079 range->max_qual.updated = IW_QUAL_NOISE_INVALID;
2080
2081 range->avg_qual.qual = 50;
2082 range->avg_qual.level = 50;
2083 range->avg_qual.noise = 0;
2084 range->avg_qual.updated = IW_QUAL_NOISE_INVALID;
2085
2086 range->bitrate[0] = 1000000;
2087 range->bitrate[1] = 2000000;
2088 range->bitrate[2] = 5500000;
2089 range->bitrate[3] = 11000000;
2090 range->num_bitrates = 4;
2091
2092 range->min_rts = 0;
2093 range->max_rts = MAX_RTS_THRESHOLD;
2094
2095 range->min_frag = MIN_FRAG_THRESHOLD;
2096 range->max_frag = MAX_FRAG_THRESHOLD;
2097
2098 range->pmp_flags = IW_POWER_PERIOD;
2099 range->pmt_flags = IW_POWER_ON;
2100 range->pm_capa = IW_POWER_PERIOD | IW_POWER_ALL_R;
2101
2102 range->encoding_size[0] = WEP_SMALL_KEY_LEN;
2103 range->encoding_size[1] = WEP_LARGE_KEY_LEN;
2104 range->num_encoding_sizes = 2;
2105 range->max_encoding_tokens = WEP_KEYS;
2106
2107 /* both WL-240U and Linksys WUSB11 v2.6 specify 15 dBm as output power
2108 - take this for all (ignore antenna gains) */
2109 range->txpower[0] = 15;
2110 range->num_txpower = 1;
2111 range->txpower_capa = IW_TXPOW_DBM;
2112
2113 range->we_version_source = WIRELESS_EXT;
2114 range->we_version_compiled = WIRELESS_EXT;
2115
2116 /* same as the values used in atmel.c */
2117 range->retry_capa = IW_RETRY_LIMIT;
2118 range->retry_flags = IW_RETRY_LIMIT;
2119 range->r_time_flags = 0;
2120 range->min_retry = 1;
2121 range->max_retry = 255;
2122
2123 range->num_channels = NUM_CHANNELS;
2124 range->num_frequency = 0;
2125
2126 for (i = 0; i < NUM_CHANNELS; i++) {
2127 /* test if channel map bit is raised */
2128 if (priv->domain->channel_map & (0x1 << i)) {
2129 range->num_frequency += 1;
2130
2131 range->freq[i].i = i + 1;
2132 range->freq[i].m = channel_frequency[i] * 100000;
2133 range->freq[i].e = 1; /* freq * 10^1 */
2134 }
2135 }
2136
2137 at76_dbg(DBG_IOCTL, "%s: SIOCGIWRANGE", netdev->name);
2138
2139 return 0;
2140}
2141
2142static int at76_iw_handler_set_spy(struct net_device *netdev,
2143 struct iw_request_info *info,
2144 struct iw_point *data, char *extra)
2145{
2146 struct at76_priv *priv = netdev_priv(netdev);
2147 int ret = 0;
2148
2149 at76_dbg(DBG_IOCTL, "%s: SIOCSIWSPY - number of addresses %d",
2150 netdev->name, data->length);
2151
2152 spin_lock_bh(&priv->spy_spinlock);
2153 ret = iw_handler_set_spy(priv->netdev, info, (union iwreq_data *)data,
2154 extra);
2155 spin_unlock_bh(&priv->spy_spinlock);
2156
2157 return ret;
2158}
2159
2160static int at76_iw_handler_get_spy(struct net_device *netdev,
2161 struct iw_request_info *info,
2162 struct iw_point *data, char *extra)
2163{
2164
2165 struct at76_priv *priv = netdev_priv(netdev);
2166 int ret = 0;
2167
2168 spin_lock_bh(&priv->spy_spinlock);
2169 ret = iw_handler_get_spy(priv->netdev, info,
2170 (union iwreq_data *)data, extra);
2171 spin_unlock_bh(&priv->spy_spinlock);
2172
2173 at76_dbg(DBG_IOCTL, "%s: SIOCGIWSPY - number of addresses %d",
2174 netdev->name, data->length);
2175
2176 return ret;
2177}
2178
2179static int at76_iw_handler_set_thrspy(struct net_device *netdev,
2180 struct iw_request_info *info,
2181 struct iw_point *data, char *extra)
2182{
2183 struct at76_priv *priv = netdev_priv(netdev);
2184 int ret;
2185
2186 at76_dbg(DBG_IOCTL, "%s: SIOCSIWTHRSPY - number of addresses %d)",
2187 netdev->name, data->length);
2188
2189 spin_lock_bh(&priv->spy_spinlock);
2190 ret = iw_handler_set_thrspy(netdev, info, (union iwreq_data *)data,
2191 extra);
2192 spin_unlock_bh(&priv->spy_spinlock);
2193
2194 return ret;
2195}
2196
2197static int at76_iw_handler_get_thrspy(struct net_device *netdev,
2198 struct iw_request_info *info,
2199 struct iw_point *data, char *extra)
2200{
2201 struct at76_priv *priv = netdev_priv(netdev);
2202 int ret;
2203
2204 spin_lock_bh(&priv->spy_spinlock);
2205 ret = iw_handler_get_thrspy(netdev, info, (union iwreq_data *)data,
2206 extra);
2207 spin_unlock_bh(&priv->spy_spinlock);
2208
2209 at76_dbg(DBG_IOCTL, "%s: SIOCGIWTHRSPY - number of addresses %d)",
2210 netdev->name, data->length);
2211
2212 return ret;
2213}
2214
2215static int at76_iw_handler_set_wap(struct net_device *netdev,
2216 struct iw_request_info *info,
2217 struct sockaddr *ap_addr, char *extra)
2218{
2219 struct at76_priv *priv = netdev_priv(netdev);
2220
2221 at76_dbg(DBG_IOCTL, "%s: SIOCSIWAP - wap/bssid %s", netdev->name,
2222 mac2str(ap_addr->sa_data));
2223
2224 /* if the incoming address == ff:ff:ff:ff:ff:ff, the user has
2225 chosen any or auto AP preference */
2226 if (is_broadcast_ether_addr(ap_addr->sa_data)
2227 || is_zero_ether_addr(ap_addr->sa_data))
2228 priv->wanted_bssid_valid = 0;
2229 else {
2230 /* user wants to set a preferred AP address */
2231 priv->wanted_bssid_valid = 1;
2232 memcpy(priv->wanted_bssid, ap_addr->sa_data, ETH_ALEN);
2233 }
2234
2235 return -EIWCOMMIT;
2236}
2237
2238static int at76_iw_handler_get_wap(struct net_device *netdev,
2239 struct iw_request_info *info,
2240 struct sockaddr *ap_addr, char *extra)
2241{
2242 struct at76_priv *priv = netdev_priv(netdev);
2243
2244 ap_addr->sa_family = ARPHRD_ETHER;
2245 memcpy(ap_addr->sa_data, priv->bssid, ETH_ALEN);
2246
2247 at76_dbg(DBG_IOCTL, "%s: SIOCGIWAP - wap/bssid %s", netdev->name,
2248 mac2str(ap_addr->sa_data));
2249
2250 return 0;
2251}
2252
2253static int at76_iw_handler_set_scan(struct net_device *netdev,
2254 struct iw_request_info *info,
2255 union iwreq_data *wrqu, char *extra)
2256{
2257 struct at76_priv *priv = netdev_priv(netdev);
2258 int ret = 0;
2259
2260 at76_dbg(DBG_IOCTL, "%s: SIOCSIWSCAN", netdev->name);
2261
2262 if (mutex_lock_interruptible(&priv->mtx))
2263 return -EINTR;
2264
2265 if (!netif_running(netdev)) {
2266 ret = -ENETDOWN;
2267 goto exit;
2268 }
2269
2270 /* jal: we don't allow "iwlist ethX scan" while we are
2271 in monitor mode */
2272 if (priv->iw_mode == IW_MODE_MONITOR) {
2273 ret = -EBUSY;
2274 goto exit;
2275 }
2276
2277 /* Discard old scan results */
2278 if ((jiffies - priv->last_scan) > (20 * HZ))
2279 priv->scan_state = SCAN_IDLE;
2280 priv->last_scan = jiffies;
2281
2282 /* Initiate a scan command */
2283 if (priv->scan_state == SCAN_IN_PROGRESS) {
2284 ret = -EBUSY;
2285 goto exit;
2286 }
2287
2288 priv->scan_state = SCAN_IN_PROGRESS;
2289
2290 at76_quiesce(priv);
2291
2292 /* Try to do passive or active scan if WE asks as. */
2293 if (wrqu->data.length
2294 && wrqu->data.length == sizeof(struct iw_scan_req)) {
2295 struct iw_scan_req *req = (struct iw_scan_req *)extra;
2296
2297 if (req->scan_type == IW_SCAN_TYPE_PASSIVE)
2298 priv->scan_mode = SCAN_TYPE_PASSIVE;
2299 else if (req->scan_type == IW_SCAN_TYPE_ACTIVE)
2300 priv->scan_mode = SCAN_TYPE_ACTIVE;
2301
2302 /* Sanity check values? */
2303 if (req->min_channel_time > 0)
2304 priv->scan_min_time = req->min_channel_time;
2305
2306 if (req->max_channel_time > 0)
2307 priv->scan_max_time = req->max_channel_time;
2308 }
2309
2310 /* change to scanning state */
2311 at76_set_mac_state(priv, MAC_SCANNING);
2312 schedule_work(&priv->work_start_scan);
2313
2314exit:
2315 mutex_unlock(&priv->mtx);
2316 return ret;
2317}
2318
2319static int at76_iw_handler_get_scan(struct net_device *netdev,
2320 struct iw_request_info *info,
2321 struct iw_point *data, char *extra)
2322{
2323 struct at76_priv *priv = netdev_priv(netdev);
2324 unsigned long flags;
2325 struct list_head *lptr, *nptr;
2326 struct bss_info *curr_bss;
2327 struct iw_event *iwe = kmalloc(sizeof(struct iw_event), GFP_KERNEL);
2328 char *curr_val, *curr_pos = extra;
2329 int i;
2330
2331 at76_dbg(DBG_IOCTL, "%s: SIOCGIWSCAN", netdev->name);
2332
2333 if (!iwe)
2334 return -ENOMEM;
2335
2336 if (priv->scan_state != SCAN_COMPLETED) {
2337 /* scan not yet finished */
2338 kfree(iwe);
2339 return -EAGAIN;
2340 }
2341
2342 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
2343
2344 list_for_each_safe(lptr, nptr, &priv->bss_list) {
2345 curr_bss = list_entry(lptr, struct bss_info, list);
2346
2347 iwe->cmd = SIOCGIWAP;
2348 iwe->u.ap_addr.sa_family = ARPHRD_ETHER;
2349 memcpy(iwe->u.ap_addr.sa_data, curr_bss->bssid, 6);
2350 curr_pos = iwe_stream_add_event(info, curr_pos,
2351 extra + IW_SCAN_MAX_DATA, iwe,
2352 IW_EV_ADDR_LEN);
2353
2354 iwe->u.data.length = curr_bss->ssid_len;
2355 iwe->cmd = SIOCGIWESSID;
2356 iwe->u.data.flags = 1;
2357
2358 curr_pos = iwe_stream_add_point(info, curr_pos,
2359 extra + IW_SCAN_MAX_DATA, iwe,
2360 curr_bss->ssid);
2361
2362 iwe->cmd = SIOCGIWMODE;
2363 iwe->u.mode = (curr_bss->capa & WLAN_CAPABILITY_IBSS) ?
2364 IW_MODE_ADHOC :
2365 (curr_bss->capa & WLAN_CAPABILITY_ESS) ?
2366 IW_MODE_MASTER : IW_MODE_AUTO;
2367 /* IW_MODE_AUTO = 0 which I thought is
2368 * the most logical value to return in this case */
2369 curr_pos = iwe_stream_add_event(info, curr_pos,
2370 extra + IW_SCAN_MAX_DATA, iwe,
2371 IW_EV_UINT_LEN);
2372
2373 iwe->cmd = SIOCGIWFREQ;
2374 iwe->u.freq.m = curr_bss->channel;
2375 iwe->u.freq.e = 0;
2376 curr_pos = iwe_stream_add_event(info, curr_pos,
2377 extra + IW_SCAN_MAX_DATA, iwe,
2378 IW_EV_FREQ_LEN);
2379
2380 iwe->cmd = SIOCGIWENCODE;
2381 if (curr_bss->capa & WLAN_CAPABILITY_PRIVACY)
2382 iwe->u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
2383 else
2384 iwe->u.data.flags = IW_ENCODE_DISABLED;
2385
2386 iwe->u.data.length = 0;
2387 curr_pos = iwe_stream_add_point(info, curr_pos,
2388 extra + IW_SCAN_MAX_DATA, iwe,
2389 NULL);
2390
2391 /* Add quality statistics */
2392 iwe->cmd = IWEVQUAL;
2393 iwe->u.qual.noise = 0;
2394 iwe->u.qual.updated =
2395 IW_QUAL_NOISE_INVALID | IW_QUAL_LEVEL_UPDATED;
2396 iwe->u.qual.level = (curr_bss->rssi * 100 / 42);
2397 if (iwe->u.qual.level > 100)
2398 iwe->u.qual.level = 100;
2399 if (at76_is_intersil(priv->board_type))
2400 iwe->u.qual.qual = curr_bss->link_qual;
2401 else {
2402 iwe->u.qual.qual = 0;
2403 iwe->u.qual.updated |= IW_QUAL_QUAL_INVALID;
2404 }
2405 /* Add new value to event */
2406 curr_pos = iwe_stream_add_event(info, curr_pos,
2407 extra + IW_SCAN_MAX_DATA, iwe,
2408 IW_EV_QUAL_LEN);
2409
2410 /* Rate: stuffing multiple values in a single event requires
2411 * a bit more of magic - Jean II */
2412 curr_val = curr_pos + IW_EV_LCP_LEN;
2413
2414 iwe->cmd = SIOCGIWRATE;
2415 /* Those two flags are ignored... */
2416 iwe->u.bitrate.fixed = 0;
2417 iwe->u.bitrate.disabled = 0;
2418 /* Max 8 values */
2419 for (i = 0; i < curr_bss->rates_len; i++) {
2420 /* Bit rate given in 500 kb/s units (+ 0x80) */
2421 iwe->u.bitrate.value =
2422 ((curr_bss->rates[i] & 0x7f) * 500000);
2423 /* Add new value to event */
2424 curr_val = iwe_stream_add_value(info, curr_pos,
2425 curr_val,
2426 extra +
2427 IW_SCAN_MAX_DATA, iwe,
2428 IW_EV_PARAM_LEN);
2429 }
2430
2431 /* Check if we added any event */
2432 if ((curr_val - curr_pos) > IW_EV_LCP_LEN)
2433 curr_pos = curr_val;
2434
2435 /* more information may be sent back using IWECUSTOM */
2436
2437 }
2438
2439 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
2440
2441 data->length = (curr_pos - extra);
2442 data->flags = 0;
2443
2444 kfree(iwe);
2445 return 0;
2446}
2447
2448static int at76_iw_handler_set_essid(struct net_device *netdev,
2449 struct iw_request_info *info,
2450 struct iw_point *data, char *extra)
2451{
2452 struct at76_priv *priv = netdev_priv(netdev);
2453
2454 at76_dbg(DBG_IOCTL, "%s: SIOCSIWESSID - %s", netdev->name, extra);
2455
2456 if (data->flags) {
2457 memcpy(priv->essid, extra, data->length);
2458 priv->essid_size = data->length;
2459 } else
2460 priv->essid_size = 0; /* Use any SSID */
2461
2462 return -EIWCOMMIT;
2463}
2464
2465static int at76_iw_handler_get_essid(struct net_device *netdev,
2466 struct iw_request_info *info,
2467 struct iw_point *data, char *extra)
2468{
2469 struct at76_priv *priv = netdev_priv(netdev);
2470
2471 if (priv->essid_size) {
2472 /* not the ANY ssid in priv->essid */
2473 data->flags = 1;
2474 data->length = priv->essid_size;
2475 memcpy(extra, priv->essid, data->length);
2476 } else {
2477 /* the ANY ssid was specified */
2478 if (priv->mac_state == MAC_CONNECTED && priv->curr_bss) {
2479 /* report the SSID we have found */
2480 data->flags = 1;
2481 data->length = priv->curr_bss->ssid_len;
2482 memcpy(extra, priv->curr_bss->ssid, data->length);
2483 } else {
2484 /* report ANY back */
2485 data->flags = 0;
2486 data->length = 0;
2487 }
2488 }
2489
2490 at76_dbg(DBG_IOCTL, "%s: SIOCGIWESSID - %.*s", netdev->name,
2491 data->length, extra);
2492
2493 return 0;
2494}
2495
2496static int at76_iw_handler_set_rate(struct net_device *netdev,
2497 struct iw_request_info *info,
2498 struct iw_param *bitrate, char *extra)
2499{
2500 struct at76_priv *priv = netdev_priv(netdev);
2501 int ret = -EIWCOMMIT;
2502
2503 at76_dbg(DBG_IOCTL, "%s: SIOCSIWRATE - %d", netdev->name,
2504 bitrate->value);
2505
2506 switch (bitrate->value) {
2507 case -1:
2508 priv->txrate = TX_RATE_AUTO;
2509 break; /* auto rate */
2510 case 1000000:
2511 priv->txrate = TX_RATE_1MBIT;
2512 break;
2513 case 2000000:
2514 priv->txrate = TX_RATE_2MBIT;
2515 break;
2516 case 5500000:
2517 priv->txrate = TX_RATE_5_5MBIT;
2518 break;
2519 case 11000000:
2520 priv->txrate = TX_RATE_11MBIT;
2521 break;
2522 default:
2523 ret = -EINVAL;
2524 }
2525
2526 return ret;
2527}
2528
2529static int at76_iw_handler_get_rate(struct net_device *netdev,
2530 struct iw_request_info *info,
2531 struct iw_param *bitrate, char *extra)
2532{
2533 struct at76_priv *priv = netdev_priv(netdev);
2534 int ret = 0;
2535
2536 switch (priv->txrate) {
2537 /* return max rate if RATE_AUTO */
2538 case TX_RATE_AUTO:
2539 bitrate->value = 11000000;
2540 break;
2541 case TX_RATE_1MBIT:
2542 bitrate->value = 1000000;
2543 break;
2544 case TX_RATE_2MBIT:
2545 bitrate->value = 2000000;
2546 break;
2547 case TX_RATE_5_5MBIT:
2548 bitrate->value = 5500000;
2549 break;
2550 case TX_RATE_11MBIT:
2551 bitrate->value = 11000000;
2552 break;
2553 default:
2554 ret = -EINVAL;
2555 }
2556
2557 bitrate->fixed = (priv->txrate != TX_RATE_AUTO);
2558 bitrate->disabled = 0;
2559
2560 at76_dbg(DBG_IOCTL, "%s: SIOCGIWRATE - %d", netdev->name,
2561 bitrate->value);
2562
2563 return ret;
2564}
2565
2566static int at76_iw_handler_set_rts(struct net_device *netdev,
2567 struct iw_request_info *info,
2568 struct iw_param *rts, char *extra)
2569{
2570 struct at76_priv *priv = netdev_priv(netdev);
2571 int ret = -EIWCOMMIT;
2572 int rthr = rts->value;
2573
2574 at76_dbg(DBG_IOCTL, "%s: SIOCSIWRTS - value %d disabled %s",
2575 netdev->name, rts->value, (rts->disabled) ? "true" : "false");
2576
2577 if (rts->disabled)
2578 rthr = MAX_RTS_THRESHOLD;
2579
2580 if ((rthr < 0) || (rthr > MAX_RTS_THRESHOLD))
2581 ret = -EINVAL;
2582 else
2583 priv->rts_threshold = rthr;
2584
2585 return ret;
2586}
2587
2588static int at76_iw_handler_get_rts(struct net_device *netdev,
2589 struct iw_request_info *info,
2590 struct iw_param *rts, char *extra)
2591{
2592 struct at76_priv *priv = netdev_priv(netdev);
2593
2594 rts->value = priv->rts_threshold;
2595 rts->disabled = (rts->value >= MAX_RTS_THRESHOLD);
2596 rts->fixed = 1;
2597
2598 at76_dbg(DBG_IOCTL, "%s: SIOCGIWRTS - value %d disabled %s",
2599 netdev->name, rts->value, (rts->disabled) ? "true" : "false");
2600
2601 return 0;
2602}
2603
2604static int at76_iw_handler_set_frag(struct net_device *netdev,
2605 struct iw_request_info *info,
2606 struct iw_param *frag, char *extra)
2607{
2608 struct at76_priv *priv = netdev_priv(netdev);
2609 int ret = -EIWCOMMIT;
2610 int fthr = frag->value;
2611
2612 at76_dbg(DBG_IOCTL, "%s: SIOCSIWFRAG - value %d, disabled %s",
2613 netdev->name, frag->value,
2614 (frag->disabled) ? "true" : "false");
2615
2616 if (frag->disabled)
2617 fthr = MAX_FRAG_THRESHOLD;
2618
2619 if ((fthr < MIN_FRAG_THRESHOLD) || (fthr > MAX_FRAG_THRESHOLD))
2620 ret = -EINVAL;
2621 else
2622 priv->frag_threshold = fthr & ~0x1; /* get an even value */
2623
2624 return ret;
2625}
2626
2627static int at76_iw_handler_get_frag(struct net_device *netdev,
2628 struct iw_request_info *info,
2629 struct iw_param *frag, char *extra)
2630{
2631 struct at76_priv *priv = netdev_priv(netdev);
2632
2633 frag->value = priv->frag_threshold;
2634 frag->disabled = (frag->value >= MAX_FRAG_THRESHOLD);
2635 frag->fixed = 1;
2636
2637 at76_dbg(DBG_IOCTL, "%s: SIOCGIWFRAG - value %d, disabled %s",
2638 netdev->name, frag->value,
2639 (frag->disabled) ? "true" : "false");
2640
2641 return 0;
2642}
2643
2644static int at76_iw_handler_get_txpow(struct net_device *netdev,
2645 struct iw_request_info *info,
2646 struct iw_param *power, char *extra)
2647{
2648 power->value = 15;
2649 power->fixed = 1; /* No power control */
2650 power->disabled = 0;
2651 power->flags = IW_TXPOW_DBM;
2652
2653 at76_dbg(DBG_IOCTL, "%s: SIOCGIWTXPOW - txpow %d dBm", netdev->name,
2654 power->value);
2655
2656 return 0;
2657}
2658
2659/* jal: short retry is handled by the firmware (at least 0.90.x),
2660 while long retry is not (?) */
2661static int at76_iw_handler_set_retry(struct net_device *netdev,
2662 struct iw_request_info *info,
2663 struct iw_param *retry, char *extra)
2664{
2665 struct at76_priv *priv = netdev_priv(netdev);
2666 int ret = -EIWCOMMIT;
2667
2668 at76_dbg(DBG_IOCTL, "%s: SIOCSIWRETRY disabled %d flags 0x%x val %d",
2669 netdev->name, retry->disabled, retry->flags, retry->value);
2670
2671 if (!retry->disabled && (retry->flags & IW_RETRY_LIMIT)) {
2672 if ((retry->flags & IW_RETRY_MIN) ||
2673 !(retry->flags & IW_RETRY_MAX))
2674 priv->short_retry_limit = retry->value;
2675 else
2676 ret = -EINVAL;
2677 } else
2678 ret = -EINVAL;
2679
2680 return ret;
2681}
2682
2683/* Adapted (ripped) from atmel.c */
2684static int at76_iw_handler_get_retry(struct net_device *netdev,
2685 struct iw_request_info *info,
2686 struct iw_param *retry, char *extra)
2687{
2688 struct at76_priv *priv = netdev_priv(netdev);
2689
2690 at76_dbg(DBG_IOCTL, "%s: SIOCGIWRETRY", netdev->name);
2691
2692 retry->disabled = 0; /* Can't be disabled */
2693 retry->flags = IW_RETRY_LIMIT;
2694 retry->value = priv->short_retry_limit;
2695
2696 return 0;
2697}
2698
2699static int at76_iw_handler_set_encode(struct net_device *netdev,
2700 struct iw_request_info *info,
2701 struct iw_point *encoding, char *extra)
2702{
2703 struct at76_priv *priv = netdev_priv(netdev);
2704 int index = (encoding->flags & IW_ENCODE_INDEX) - 1;
2705 int len = encoding->length;
2706
2707 at76_dbg(DBG_IOCTL, "%s: SIOCSIWENCODE - enc.flags %08x "
2708 "pointer %p len %d", netdev->name, encoding->flags,
2709 encoding->pointer, encoding->length);
2710 at76_dbg(DBG_IOCTL,
2711 "%s: SIOCSIWENCODE - old wepstate: enabled %s key_id %d "
2712 "auth_mode %s", netdev->name,
2713 (priv->wep_enabled) ? "true" : "false", priv->wep_key_id,
2714 (priv->auth_mode ==
2715 WLAN_AUTH_SHARED_KEY) ? "restricted" : "open");
2716
2717 /* take the old default key if index is invalid */
2718 if ((index < 0) || (index >= WEP_KEYS))
2719 index = priv->wep_key_id;
2720
2721 if (len > 0) {
2722 if (len > WEP_LARGE_KEY_LEN)
2723 len = WEP_LARGE_KEY_LEN;
2724
2725 memset(priv->wep_keys[index], 0, WEP_KEY_LEN);
2726 memcpy(priv->wep_keys[index], extra, len);
2727 priv->wep_keys_len[index] = (len <= WEP_SMALL_KEY_LEN) ?
2728 WEP_SMALL_KEY_LEN : WEP_LARGE_KEY_LEN;
2729 priv->wep_enabled = 1;
2730 }
2731
2732 priv->wep_key_id = index;
2733 priv->wep_enabled = ((encoding->flags & IW_ENCODE_DISABLED) == 0);
2734
2735 if (encoding->flags & IW_ENCODE_RESTRICTED)
2736 priv->auth_mode = WLAN_AUTH_SHARED_KEY;
2737 if (encoding->flags & IW_ENCODE_OPEN)
2738 priv->auth_mode = WLAN_AUTH_OPEN;
2739
2740 at76_dbg(DBG_IOCTL,
2741 "%s: SIOCSIWENCODE - new wepstate: enabled %s key_id %d "
2742 "key_len %d auth_mode %s", netdev->name,
2743 (priv->wep_enabled) ? "true" : "false", priv->wep_key_id + 1,
2744 priv->wep_keys_len[priv->wep_key_id],
2745 (priv->auth_mode ==
2746 WLAN_AUTH_SHARED_KEY) ? "restricted" : "open");
2747
2748 return -EIWCOMMIT;
2749}
2750
2751static int at76_iw_handler_get_encode(struct net_device *netdev,
2752 struct iw_request_info *info,
2753 struct iw_point *encoding, char *extra)
2754{
2755 struct at76_priv *priv = netdev_priv(netdev);
2756 int index = (encoding->flags & IW_ENCODE_INDEX) - 1;
2757
2758 if ((index < 0) || (index >= WEP_KEYS))
2759 index = priv->wep_key_id;
2760
2761 encoding->flags =
2762 (priv->auth_mode == WLAN_AUTH_SHARED_KEY) ?
2763 IW_ENCODE_RESTRICTED : IW_ENCODE_OPEN;
2764
2765 if (!priv->wep_enabled)
2766 encoding->flags |= IW_ENCODE_DISABLED;
2767
2768 if (encoding->pointer) {
2769 encoding->length = priv->wep_keys_len[index];
2770
2771 memcpy(extra, priv->wep_keys[index], priv->wep_keys_len[index]);
2772
2773 encoding->flags |= (index + 1);
2774 }
2775
2776 at76_dbg(DBG_IOCTL, "%s: SIOCGIWENCODE - enc.flags %08x "
2777 "pointer %p len %d", netdev->name, encoding->flags,
2778 encoding->pointer, encoding->length);
2779 at76_dbg(DBG_IOCTL,
2780 "%s: SIOCGIWENCODE - wepstate: enabled %s key_id %d "
2781 "key_len %d auth_mode %s", netdev->name,
2782 (priv->wep_enabled) ? "true" : "false", priv->wep_key_id + 1,
2783 priv->wep_keys_len[priv->wep_key_id],
2784 (priv->auth_mode ==
2785 WLAN_AUTH_SHARED_KEY) ? "restricted" : "open");
2786
2787 return 0;
2788}
2789
2790static int at76_iw_handler_set_power(struct net_device *netdev,
2791 struct iw_request_info *info,
2792 struct iw_param *prq, char *extra)
2793{
2794 int err = -EIWCOMMIT;
2795 struct at76_priv *priv = netdev_priv(netdev);
2796
2797 at76_dbg(DBG_IOCTL,
2798 "%s: SIOCSIWPOWER - disabled %s flags 0x%x value 0x%x",
2799 netdev->name, (prq->disabled) ? "true" : "false", prq->flags,
2800 prq->value);
2801
2802 if (prq->disabled)
2803 priv->pm_mode = AT76_PM_OFF;
2804 else {
2805 switch (prq->flags & IW_POWER_MODE) {
2806 case IW_POWER_ALL_R:
2807 case IW_POWER_ON:
2808 break;
2809 default:
2810 err = -EINVAL;
2811 goto exit;
2812 }
2813 if (prq->flags & IW_POWER_PERIOD)
2814 priv->pm_period = prq->value;
2815
2816 if (prq->flags & IW_POWER_TIMEOUT) {
2817 err = -EINVAL;
2818 goto exit;
2819 }
2820 priv->pm_mode = AT76_PM_ON;
2821 }
2822exit:
2823 return err;
2824}
2825
2826static int at76_iw_handler_get_power(struct net_device *netdev,
2827 struct iw_request_info *info,
2828 struct iw_param *power, char *extra)
2829{
2830 struct at76_priv *priv = netdev_priv(netdev);
2831
2832 power->disabled = (priv->pm_mode == AT76_PM_OFF);
2833 if (!power->disabled) {
2834 power->flags = IW_POWER_PERIOD | IW_POWER_ALL_R;
2835 power->value = priv->pm_period;
2836 }
2837
2838 at76_dbg(DBG_IOCTL, "%s: SIOCGIWPOWER - %s flags 0x%x value 0x%x",
2839 netdev->name, power->disabled ? "disabled" : "enabled",
2840 power->flags, power->value);
2841
2842 return 0;
2843}
2844
2845/*******************************************************************************
2846 * Private IOCTLS
2847 */
2848static int at76_iw_set_short_preamble(struct net_device *netdev,
2849 struct iw_request_info *info, char *name,
2850 char *extra)
2851{
2852 struct at76_priv *priv = netdev_priv(netdev);
2853 int val = *((int *)name);
2854 int ret = -EIWCOMMIT;
2855
2856 at76_dbg(DBG_IOCTL, "%s: AT76_SET_SHORT_PREAMBLE, %d",
2857 netdev->name, val);
2858
2859 if (val < PREAMBLE_TYPE_LONG || val > PREAMBLE_TYPE_AUTO)
2860 ret = -EINVAL;
2861 else
2862 priv->preamble_type = val;
2863
2864 return ret;
2865}
2866
2867static int at76_iw_get_short_preamble(struct net_device *netdev,
2868 struct iw_request_info *info,
2869 union iwreq_data *wrqu, char *extra)
2870{
2871 struct at76_priv *priv = netdev_priv(netdev);
2872
2873 snprintf(wrqu->name, sizeof(wrqu->name), "%s (%d)",
2874 preambles[priv->preamble_type], priv->preamble_type);
2875 return 0;
2876}
2877
2878static int at76_iw_set_debug(struct net_device *netdev,
2879 struct iw_request_info *info,
2880 struct iw_point *data, char *extra)
2881{
2882 char *ptr;
2883 u32 val;
2884
2885 if (data->length > 0) {
2886 val = simple_strtol(extra, &ptr, 0);
2887
2888 if (ptr == extra)
2889 val = DBG_DEFAULTS;
2890
2891 at76_dbg(DBG_IOCTL, "%s: AT76_SET_DEBUG input %d: %s -> 0x%x",
2892 netdev->name, data->length, extra, val);
2893 } else
2894 val = DBG_DEFAULTS;
2895
2896 at76_dbg(DBG_IOCTL, "%s: AT76_SET_DEBUG, old 0x%x, new 0x%x",
2897 netdev->name, at76_debug, val);
2898
2899 /* jal: some more output to pin down lockups */
2900 at76_dbg(DBG_IOCTL, "%s: netif running %d queue_stopped %d "
2901 "carrier_ok %d", netdev->name, netif_running(netdev),
2902 netif_queue_stopped(netdev), netif_carrier_ok(netdev));
2903
2904 at76_debug = val;
2905
2906 return 0;
2907}
2908
2909static int at76_iw_get_debug(struct net_device *netdev,
2910 struct iw_request_info *info,
2911 union iwreq_data *wrqu, char *extra)
2912{
2913 snprintf(wrqu->name, sizeof(wrqu->name), "0x%08x", at76_debug);
2914 return 0;
2915}
2916
2917static int at76_iw_set_powersave_mode(struct net_device *netdev,
2918 struct iw_request_info *info, char *name,
2919 char *extra)
2920{
2921 struct at76_priv *priv = netdev_priv(netdev);
2922 int val = *((int *)name);
2923 int ret = -EIWCOMMIT;
2924
2925 at76_dbg(DBG_IOCTL, "%s: AT76_SET_POWERSAVE_MODE, %d (%s)",
2926 netdev->name, val,
2927 val == AT76_PM_OFF ? "active" : val == AT76_PM_ON ? "save" :
2928 val == AT76_PM_SMART ? "smart save" : "<invalid>");
2929 if (val < AT76_PM_OFF || val > AT76_PM_SMART)
2930 ret = -EINVAL;
2931 else
2932 priv->pm_mode = val;
2933
2934 return ret;
2935}
2936
2937static int at76_iw_get_powersave_mode(struct net_device *netdev,
2938 struct iw_request_info *info,
2939 union iwreq_data *wrqu, char *extra)
2940{
2941 struct at76_priv *priv = netdev_priv(netdev);
2942 int *param = (int *)extra;
2943
2944 param[0] = priv->pm_mode;
2945 return 0;
2946}
2947
2948static int at76_iw_set_scan_times(struct net_device *netdev,
2949 struct iw_request_info *info, char *name,
2950 char *extra)
2951{
2952 struct at76_priv *priv = netdev_priv(netdev);
2953 int mint = *((int *)name);
2954 int maxt = *((int *)name + 1);
2955 int ret = -EIWCOMMIT;
2956
2957 at76_dbg(DBG_IOCTL, "%s: AT76_SET_SCAN_TIMES - min %d max %d",
2958 netdev->name, mint, maxt);
2959 if (mint <= 0 || maxt <= 0 || mint > maxt)
2960 ret = -EINVAL;
2961 else {
2962 priv->scan_min_time = mint;
2963 priv->scan_max_time = maxt;
2964 }
2965
2966 return ret;
2967}
2968
2969static int at76_iw_get_scan_times(struct net_device *netdev,
2970 struct iw_request_info *info,
2971 union iwreq_data *wrqu, char *extra)
2972{
2973 struct at76_priv *priv = netdev_priv(netdev);
2974 int *param = (int *)extra;
2975
2976 param[0] = priv->scan_min_time;
2977 param[1] = priv->scan_max_time;
2978 return 0;
2979}
2980
2981static int at76_iw_set_scan_mode(struct net_device *netdev,
2982 struct iw_request_info *info, char *name,
2983 char *extra)
2984{
2985 struct at76_priv *priv = netdev_priv(netdev);
2986 int val = *((int *)name);
2987 int ret = -EIWCOMMIT;
2988
2989 at76_dbg(DBG_IOCTL, "%s: AT76_SET_SCAN_MODE - mode %s",
2990 netdev->name, (val = SCAN_TYPE_ACTIVE) ? "active" :
2991 (val = SCAN_TYPE_PASSIVE) ? "passive" : "<invalid>");
2992
2993 if (val != SCAN_TYPE_ACTIVE && val != SCAN_TYPE_PASSIVE)
2994 ret = -EINVAL;
2995 else
2996 priv->scan_mode = val;
2997
2998 return ret;
2999}
3000
3001static int at76_iw_get_scan_mode(struct net_device *netdev,
3002 struct iw_request_info *info,
3003 union iwreq_data *wrqu, char *extra)
3004{
3005 struct at76_priv *priv = netdev_priv(netdev);
3006 int *param = (int *)extra;
3007
3008 param[0] = priv->scan_mode;
3009 return 0;
3010}
3011
3012#define AT76_SET_HANDLER(h, f) [h - SIOCIWFIRST] = (iw_handler) f
3013
3014/* Standard wireless handlers */
3015static const iw_handler at76_handlers[] = {
3016 AT76_SET_HANDLER(SIOCSIWCOMMIT, at76_iw_handler_commit),
3017 AT76_SET_HANDLER(SIOCGIWNAME, at76_iw_handler_get_name),
3018 AT76_SET_HANDLER(SIOCSIWFREQ, at76_iw_handler_set_freq),
3019 AT76_SET_HANDLER(SIOCGIWFREQ, at76_iw_handler_get_freq),
3020 AT76_SET_HANDLER(SIOCSIWMODE, at76_iw_handler_set_mode),
3021 AT76_SET_HANDLER(SIOCGIWMODE, at76_iw_handler_get_mode),
3022 AT76_SET_HANDLER(SIOCGIWRANGE, at76_iw_handler_get_range),
3023 AT76_SET_HANDLER(SIOCSIWSPY, at76_iw_handler_set_spy),
3024 AT76_SET_HANDLER(SIOCGIWSPY, at76_iw_handler_get_spy),
3025 AT76_SET_HANDLER(SIOCSIWTHRSPY, at76_iw_handler_set_thrspy),
3026 AT76_SET_HANDLER(SIOCGIWTHRSPY, at76_iw_handler_get_thrspy),
3027 AT76_SET_HANDLER(SIOCSIWAP, at76_iw_handler_set_wap),
3028 AT76_SET_HANDLER(SIOCGIWAP, at76_iw_handler_get_wap),
3029 AT76_SET_HANDLER(SIOCSIWSCAN, at76_iw_handler_set_scan),
3030 AT76_SET_HANDLER(SIOCGIWSCAN, at76_iw_handler_get_scan),
3031 AT76_SET_HANDLER(SIOCSIWESSID, at76_iw_handler_set_essid),
3032 AT76_SET_HANDLER(SIOCGIWESSID, at76_iw_handler_get_essid),
3033 AT76_SET_HANDLER(SIOCSIWRATE, at76_iw_handler_set_rate),
3034 AT76_SET_HANDLER(SIOCGIWRATE, at76_iw_handler_get_rate),
3035 AT76_SET_HANDLER(SIOCSIWRTS, at76_iw_handler_set_rts),
3036 AT76_SET_HANDLER(SIOCGIWRTS, at76_iw_handler_get_rts),
3037 AT76_SET_HANDLER(SIOCSIWFRAG, at76_iw_handler_set_frag),
3038 AT76_SET_HANDLER(SIOCGIWFRAG, at76_iw_handler_get_frag),
3039 AT76_SET_HANDLER(SIOCGIWTXPOW, at76_iw_handler_get_txpow),
3040 AT76_SET_HANDLER(SIOCSIWRETRY, at76_iw_handler_set_retry),
3041 AT76_SET_HANDLER(SIOCGIWRETRY, at76_iw_handler_get_retry),
3042 AT76_SET_HANDLER(SIOCSIWENCODE, at76_iw_handler_set_encode),
3043 AT76_SET_HANDLER(SIOCGIWENCODE, at76_iw_handler_get_encode),
3044 AT76_SET_HANDLER(SIOCSIWPOWER, at76_iw_handler_set_power),
3045 AT76_SET_HANDLER(SIOCGIWPOWER, at76_iw_handler_get_power)
3046};
3047
3048#define AT76_SET_PRIV(h, f) [h - SIOCIWFIRSTPRIV] = (iw_handler) f
3049
3050/* Private wireless handlers */
3051static const iw_handler at76_priv_handlers[] = {
3052 AT76_SET_PRIV(AT76_SET_SHORT_PREAMBLE, at76_iw_set_short_preamble),
3053 AT76_SET_PRIV(AT76_GET_SHORT_PREAMBLE, at76_iw_get_short_preamble),
3054 AT76_SET_PRIV(AT76_SET_DEBUG, at76_iw_set_debug),
3055 AT76_SET_PRIV(AT76_GET_DEBUG, at76_iw_get_debug),
3056 AT76_SET_PRIV(AT76_SET_POWERSAVE_MODE, at76_iw_set_powersave_mode),
3057 AT76_SET_PRIV(AT76_GET_POWERSAVE_MODE, at76_iw_get_powersave_mode),
3058 AT76_SET_PRIV(AT76_SET_SCAN_TIMES, at76_iw_set_scan_times),
3059 AT76_SET_PRIV(AT76_GET_SCAN_TIMES, at76_iw_get_scan_times),
3060 AT76_SET_PRIV(AT76_SET_SCAN_MODE, at76_iw_set_scan_mode),
3061 AT76_SET_PRIV(AT76_GET_SCAN_MODE, at76_iw_get_scan_mode),
3062};
3063
3064/* Names and arguments of private wireless handlers */
3065static const struct iw_priv_args at76_priv_args[] = {
3066 /* 0 - long, 1 - short */
3067 {AT76_SET_SHORT_PREAMBLE,
3068 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_preamble"},
3069
3070 {AT76_GET_SHORT_PREAMBLE,
3071 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 10, "get_preamble"},
3072
3073 /* we must pass the new debug mask as a string, because iwpriv cannot
3074 * parse hex numbers starting with 0x :-( */
3075 {AT76_SET_DEBUG,
3076 IW_PRIV_TYPE_CHAR | 10, 0, "set_debug"},
3077
3078 {AT76_GET_DEBUG,
3079 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 10, "get_debug"},
3080
3081 /* 1 - active, 2 - power save, 3 - smart power save */
3082 {AT76_SET_POWERSAVE_MODE,
3083 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_powersave"},
3084
3085 {AT76_GET_POWERSAVE_MODE,
3086 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_powersave"},
3087
3088 /* min_channel_time, max_channel_time */
3089 {AT76_SET_SCAN_TIMES,
3090 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "set_scan_times"},
3091
3092 {AT76_GET_SCAN_TIMES,
3093 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, "get_scan_times"},
3094
3095 /* 0 - active, 1 - passive scan */
3096 {AT76_SET_SCAN_MODE,
3097 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "set_scan_mode"},
3098
3099 {AT76_GET_SCAN_MODE,
3100 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "get_scan_mode"},
3101};
3102
3103static const struct iw_handler_def at76_handler_def = {
3104 .num_standard = ARRAY_SIZE(at76_handlers),
3105 .num_private = ARRAY_SIZE(at76_priv_handlers),
3106 .num_private_args = ARRAY_SIZE(at76_priv_args),
3107 .standard = at76_handlers,
3108 .private = at76_priv_handlers,
3109 .private_args = at76_priv_args,
3110 .get_wireless_stats = at76_get_wireless_stats,
3111};
3112
3113static const u8 snapsig[] = { 0xaa, 0xaa, 0x03 };
3114
3115/* RFC 1042 encapsulates Ethernet frames in 802.2 SNAP (0xaa, 0xaa, 0x03) with
3116 * a SNAP OID of 0 (0x00, 0x00, 0x00) */
3117static const u8 rfc1042sig[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
3118
3119static int at76_tx(struct sk_buff *skb, struct net_device *netdev)
3120{
3121 struct at76_priv *priv = netdev_priv(netdev);
3122 struct net_device_stats *stats = &priv->stats;
3123 int ret = 0;
3124 int wlen;
3125 int submit_len;
3126 struct at76_tx_buffer *tx_buffer = priv->bulk_out_buffer;
3127 struct ieee80211_hdr_3addr *i802_11_hdr =
3128 (struct ieee80211_hdr_3addr *)tx_buffer->packet;
3129 u8 *payload = i802_11_hdr->payload;
3130 struct ethhdr *eh = (struct ethhdr *)skb->data;
3131
3132 if (netif_queue_stopped(netdev)) {
3133 printk(KERN_ERR "%s: %s called while netdev is stopped\n",
3134 netdev->name, __func__);
3135 /* skip this packet */
3136 dev_kfree_skb(skb);
3137 return 0;
3138 }
3139
3140 if (priv->tx_urb->status == -EINPROGRESS) {
3141 printk(KERN_ERR "%s: %s called while tx urb is pending\n",
3142 netdev->name, __func__);
3143 /* skip this packet */
3144 dev_kfree_skb(skb);
3145 return 0;
3146 }
3147
3148 if (skb->len < ETH_HLEN) {
3149 printk(KERN_ERR "%s: %s: skb too short (%d)\n",
3150 netdev->name, __func__, skb->len);
3151 dev_kfree_skb(skb);
3152 return 0;
3153 }
3154
3155 at76_ledtrig_tx_activity(); /* tell ledtrigger we send a packet */
3156
3157 /* we can get rid of memcpy if we set netdev->hard_header_len to
3158 reserve enough space, but we would need to keep the skb around */
3159
3160 if (ntohs(eh->h_proto) <= ETH_DATA_LEN) {
3161 /* this is a 802.3 packet */
3162 if (skb->len >= ETH_HLEN + sizeof(rfc1042sig)
3163 && skb->data[ETH_HLEN] == rfc1042sig[0]
3164 && skb->data[ETH_HLEN + 1] == rfc1042sig[1]) {
3165 /* higher layer delivered SNAP header - keep it */
3166 memcpy(payload, skb->data + ETH_HLEN,
3167 skb->len - ETH_HLEN);
3168 wlen = IEEE80211_3ADDR_LEN + skb->len - ETH_HLEN;
3169 } else {
3170 printk(KERN_ERR "%s: dropping non-SNAP 802.2 packet "
3171 "(DSAP 0x%02x SSAP 0x%02x cntrl 0x%02x)\n",
3172 priv->netdev->name, skb->data[ETH_HLEN],
3173 skb->data[ETH_HLEN + 1],
3174 skb->data[ETH_HLEN + 2]);
3175 dev_kfree_skb(skb);
3176 return 0;
3177 }
3178 } else {
3179 /* add RFC 1042 header in front */
3180 memcpy(payload, rfc1042sig, sizeof(rfc1042sig));
3181 memcpy(payload + sizeof(rfc1042sig), &eh->h_proto,
3182 skb->len - offsetof(struct ethhdr, h_proto));
3183 wlen = IEEE80211_3ADDR_LEN + sizeof(rfc1042sig) + skb->len -
3184 offsetof(struct ethhdr, h_proto);
3185 }
3186
3187 /* make wireless header */
3188 i802_11_hdr->frame_ctl =
3189 cpu_to_le16(IEEE80211_FTYPE_DATA |
3190 (priv->wep_enabled ? IEEE80211_FCTL_PROTECTED : 0) |
3191 (priv->iw_mode ==
3192 IW_MODE_INFRA ? IEEE80211_FCTL_TODS : 0));
3193
3194 if (priv->iw_mode == IW_MODE_ADHOC) {
3195 memcpy(i802_11_hdr->addr1, eh->h_dest, ETH_ALEN);
3196 memcpy(i802_11_hdr->addr2, eh->h_source, ETH_ALEN);
3197 memcpy(i802_11_hdr->addr3, priv->bssid, ETH_ALEN);
3198 } else if (priv->iw_mode == IW_MODE_INFRA) {
3199 memcpy(i802_11_hdr->addr1, priv->bssid, ETH_ALEN);
3200 memcpy(i802_11_hdr->addr2, eh->h_source, ETH_ALEN);
3201 memcpy(i802_11_hdr->addr3, eh->h_dest, ETH_ALEN);
3202 }
3203
3204 i802_11_hdr->duration_id = cpu_to_le16(0);
3205 i802_11_hdr->seq_ctl = cpu_to_le16(0);
3206
3207 /* setup 'Atmel' header */
3208 tx_buffer->wlength = cpu_to_le16(wlen);
3209 tx_buffer->tx_rate = priv->txrate;
3210 /* for broadcast destination addresses, the firmware 0.100.x
3211 seems to choose the highest rate set with CMD_STARTUP in
3212 basic_rate_set replacing this value */
3213
3214 memset(tx_buffer->reserved, 0, sizeof(tx_buffer->reserved));
3215
3216 tx_buffer->padding = at76_calc_padding(wlen);
3217 submit_len = wlen + AT76_TX_HDRLEN + tx_buffer->padding;
3218
3219 at76_dbg(DBG_TX_DATA_CONTENT, "%s skb->data %s", priv->netdev->name,
3220 hex2str(skb->data, 32));
3221 at76_dbg(DBG_TX_DATA, "%s tx: wlen 0x%x pad 0x%x rate %d hdr %s",
3222 priv->netdev->name,
3223 le16_to_cpu(tx_buffer->wlength),
3224 tx_buffer->padding, tx_buffer->tx_rate,
3225 hex2str(i802_11_hdr, sizeof(*i802_11_hdr)));
3226 at76_dbg(DBG_TX_DATA_CONTENT, "%s payload %s", priv->netdev->name,
3227 hex2str(payload, 48));
3228
3229 /* send stuff */
3230 netif_stop_queue(netdev);
3231 netdev->trans_start = jiffies;
3232
3233 usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe, tx_buffer,
3234 submit_len, at76_tx_callback, priv);
3235 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
3236 if (ret) {
3237 stats->tx_errors++;
3238 printk(KERN_ERR "%s: error in tx submit urb: %d\n",
3239 netdev->name, ret);
3240 if (ret == -EINVAL)
3241 printk(KERN_ERR
3242 "%s: -EINVAL: tx urb %p hcpriv %p complete %p\n",
3243 priv->netdev->name, priv->tx_urb,
3244 priv->tx_urb->hcpriv, priv->tx_urb->complete);
3245 } else {
3246 stats->tx_bytes += skb->len;
3247 dev_kfree_skb(skb);
3248 }
3249
3250 return ret;
3251}
3252
3253static void at76_tx_timeout(struct net_device *netdev)
3254{
3255 struct at76_priv *priv = netdev_priv(netdev);
3256
3257 if (!priv)
3258 return;
3259 dev_warn(&netdev->dev, "tx timeout.");
3260
3261 usb_unlink_urb(priv->tx_urb);
3262 priv->stats.tx_errors++;
3263}
3264
1322static int at76_submit_rx_urb(struct at76_priv *priv) 3265static int at76_submit_rx_urb(struct at76_priv *priv)
1323{ 3266{
1324 int ret; 3267 int ret;
@@ -1327,7 +3270,7 @@ static int at76_submit_rx_urb(struct at76_priv *priv)
1327 3270
1328 if (!priv->rx_urb) { 3271 if (!priv->rx_urb) {
1329 printk(KERN_ERR "%s: %s: priv->rx_urb is NULL\n", 3272 printk(KERN_ERR "%s: %s: priv->rx_urb is NULL\n",
1330 wiphy_name(priv->hw->wiphy), __func__); 3273 priv->netdev->name, __func__);
1331 return -EFAULT; 3274 return -EFAULT;
1332 } 3275 }
1333 3276
@@ -1335,7 +3278,7 @@ static int at76_submit_rx_urb(struct at76_priv *priv)
1335 skb = dev_alloc_skb(sizeof(struct at76_rx_buffer)); 3278 skb = dev_alloc_skb(sizeof(struct at76_rx_buffer));
1336 if (!skb) { 3279 if (!skb) {
1337 printk(KERN_ERR "%s: cannot allocate rx skbuff\n", 3280 printk(KERN_ERR "%s: cannot allocate rx skbuff\n",
1338 wiphy_name(priv->hw->wiphy)); 3281 priv->netdev->name);
1339 ret = -ENOMEM; 3282 ret = -ENOMEM;
1340 goto exit; 3283 goto exit;
1341 } 3284 }
@@ -1355,18 +3298,110 @@ static int at76_submit_rx_urb(struct at76_priv *priv)
1355 "usb_submit_urb returned -ENODEV"); 3298 "usb_submit_urb returned -ENODEV");
1356 else 3299 else
1357 printk(KERN_ERR "%s: rx, usb_submit_urb failed: %d\n", 3300 printk(KERN_ERR "%s: rx, usb_submit_urb failed: %d\n",
1358 wiphy_name(priv->hw->wiphy), ret); 3301 priv->netdev->name, ret);
1359 } 3302 }
1360 3303
1361exit: 3304exit:
1362 if (ret < 0 && ret != -ENODEV) 3305 if (ret < 0 && ret != -ENODEV)
1363 printk(KERN_ERR "%s: cannot submit rx urb - please unload the " 3306 printk(KERN_ERR "%s: cannot submit rx urb - please unload the "
1364 "driver and/or power cycle the device\n", 3307 "driver and/or power cycle the device\n",
1365 wiphy_name(priv->hw->wiphy)); 3308 priv->netdev->name);
1366 3309
1367 return ret; 3310 return ret;
1368} 3311}
1369 3312
3313static int at76_open(struct net_device *netdev)
3314{
3315 struct at76_priv *priv = netdev_priv(netdev);
3316 int ret = 0;
3317
3318 at76_dbg(DBG_PROC_ENTRY, "%s(): entry", __func__);
3319
3320 if (mutex_lock_interruptible(&priv->mtx))
3321 return -EINTR;
3322
3323 /* if netdev->dev_addr != priv->mac_addr we must
3324 set the mac address in the device ! */
3325 if (compare_ether_addr(netdev->dev_addr, priv->mac_addr)) {
3326 if (at76_add_mac_address(priv, netdev->dev_addr) >= 0)
3327 at76_dbg(DBG_PROGRESS, "%s: set new MAC addr %s",
3328 netdev->name, mac2str(netdev->dev_addr));
3329 }
3330
3331 priv->scan_state = SCAN_IDLE;
3332 priv->last_scan = jiffies;
3333
3334 ret = at76_submit_rx_urb(priv);
3335 if (ret < 0) {
3336 printk(KERN_ERR "%s: open: submit_rx_urb failed: %d\n",
3337 netdev->name, ret);
3338 goto error;
3339 }
3340
3341 schedule_delayed_work(&priv->dwork_restart, 0);
3342
3343 at76_dbg(DBG_PROC_ENTRY, "%s(): end", __func__);
3344error:
3345 mutex_unlock(&priv->mtx);
3346 return ret < 0 ? ret : 0;
3347}
3348
3349static int at76_stop(struct net_device *netdev)
3350{
3351 struct at76_priv *priv = netdev_priv(netdev);
3352
3353 at76_dbg(DBG_DEVSTART, "%s: ENTER", __func__);
3354
3355 if (mutex_lock_interruptible(&priv->mtx))
3356 return -EINTR;
3357
3358 at76_quiesce(priv);
3359
3360 if (!priv->device_unplugged) {
3361 /* We are called by "ifconfig ethX down", not because the
3362 * device is not available anymore. */
3363 at76_set_radio(priv, 0);
3364
3365 /* We unlink rx_urb because at76_open() re-submits it.
3366 * If unplugged, at76_delete_device() takes care of it. */
3367 usb_kill_urb(priv->rx_urb);
3368 }
3369
3370 /* free the bss_list */
3371 at76_free_bss_list(priv);
3372
3373 mutex_unlock(&priv->mtx);
3374 at76_dbg(DBG_DEVSTART, "%s: EXIT", __func__);
3375
3376 return 0;
3377}
3378
3379static void at76_ethtool_get_drvinfo(struct net_device *netdev,
3380 struct ethtool_drvinfo *info)
3381{
3382 struct at76_priv *priv = netdev_priv(netdev);
3383
3384 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver));
3385 strncpy(info->version, DRIVER_VERSION, sizeof(info->version));
3386
3387 usb_make_path(priv->udev, info->bus_info, sizeof(info->bus_info));
3388
3389 snprintf(info->fw_version, sizeof(info->fw_version), "%d.%d.%d-%d",
3390 priv->fw_version.major, priv->fw_version.minor,
3391 priv->fw_version.patch, priv->fw_version.build);
3392}
3393
3394static u32 at76_ethtool_get_link(struct net_device *netdev)
3395{
3396 struct at76_priv *priv = netdev_priv(netdev);
3397 return priv->mac_state == MAC_CONNECTED;
3398}
3399
3400static struct ethtool_ops at76_ethtool_ops = {
3401 .get_drvinfo = at76_ethtool_get_drvinfo,
3402 .get_link = at76_ethtool_get_link,
3403};
3404
1370/* Download external firmware */ 3405/* Download external firmware */
1371static int at76_load_external_fw(struct usb_device *udev, struct fwentry *fwe) 3406static int at76_load_external_fw(struct usb_device *udev, struct fwentry *fwe)
1372{ 3407{
@@ -1463,6 +3498,406 @@ exit:
1463 return ret; 3498 return ret;
1464} 3499}
1465 3500
3501static int at76_match_essid(struct at76_priv *priv, struct bss_info *ptr)
3502{
3503 /* common criteria for both modi */
3504
3505 int ret = (priv->essid_size == 0 /* ANY ssid */ ||
3506 (priv->essid_size == ptr->ssid_len &&
3507 !memcmp(priv->essid, ptr->ssid, ptr->ssid_len)));
3508 if (!ret)
3509 at76_dbg(DBG_BSS_MATCH,
3510 "%s bss table entry %p: essid didn't match",
3511 priv->netdev->name, ptr);
3512 return ret;
3513}
3514
3515static inline int at76_match_mode(struct at76_priv *priv, struct bss_info *ptr)
3516{
3517 int ret;
3518
3519 if (priv->iw_mode == IW_MODE_ADHOC)
3520 ret = ptr->capa & WLAN_CAPABILITY_IBSS;
3521 else
3522 ret = ptr->capa & WLAN_CAPABILITY_ESS;
3523 if (!ret)
3524 at76_dbg(DBG_BSS_MATCH,
3525 "%s bss table entry %p: mode didn't match",
3526 priv->netdev->name, ptr);
3527 return ret;
3528}
3529
3530static int at76_match_rates(struct at76_priv *priv, struct bss_info *ptr)
3531{
3532 int i;
3533
3534 for (i = 0; i < ptr->rates_len; i++) {
3535 u8 rate = ptr->rates[i];
3536
3537 if (!(rate & 0x80))
3538 continue;
3539
3540 /* this is a basic rate we have to support
3541 (see IEEE802.11, ch. 7.3.2.2) */
3542 if (rate != (0x80 | hw_rates[0])
3543 && rate != (0x80 | hw_rates[1])
3544 && rate != (0x80 | hw_rates[2])
3545 && rate != (0x80 | hw_rates[3])) {
3546 at76_dbg(DBG_BSS_MATCH,
3547 "%s: bss table entry %p: basic rate %02x not "
3548 "supported", priv->netdev->name, ptr, rate);
3549 return 0;
3550 }
3551 }
3552
3553 /* if we use short preamble, the bss must support it */
3554 if (priv->preamble_type == PREAMBLE_TYPE_SHORT &&
3555 !(ptr->capa & WLAN_CAPABILITY_SHORT_PREAMBLE)) {
3556 at76_dbg(DBG_BSS_MATCH,
3557 "%s: %p does not support short preamble",
3558 priv->netdev->name, ptr);
3559 return 0;
3560 } else
3561 return 1;
3562}
3563
3564static inline int at76_match_wep(struct at76_priv *priv, struct bss_info *ptr)
3565{
3566 if (!priv->wep_enabled && ptr->capa & WLAN_CAPABILITY_PRIVACY) {
3567 /* we have disabled WEP, but the BSS signals privacy */
3568 at76_dbg(DBG_BSS_MATCH,
3569 "%s: bss table entry %p: requires encryption",
3570 priv->netdev->name, ptr);
3571 return 0;
3572 }
3573 /* otherwise if the BSS does not signal privacy it may well
3574 accept encrypted packets from us ... */
3575 return 1;
3576}
3577
3578static inline int at76_match_bssid(struct at76_priv *priv, struct bss_info *ptr)
3579{
3580 if (!priv->wanted_bssid_valid ||
3581 !compare_ether_addr(ptr->bssid, priv->wanted_bssid))
3582 return 1;
3583
3584 at76_dbg(DBG_BSS_MATCH,
3585 "%s: requested bssid - %s does not match",
3586 priv->netdev->name, mac2str(priv->wanted_bssid));
3587 at76_dbg(DBG_BSS_MATCH,
3588 " AP bssid - %s of bss table entry %p",
3589 mac2str(ptr->bssid), ptr);
3590 return 0;
3591}
3592
3593/**
3594 * at76_match_bss - try to find a matching bss in priv->bss
3595 *
3596 * last - last bss tried
3597 *
3598 * last == NULL signals a new round starting with priv->bss_list.next
3599 * this function must be called inside an acquired priv->bss_list_spinlock
3600 * otherwise the timeout on bss may remove the newly chosen entry
3601 */
3602static struct bss_info *at76_match_bss(struct at76_priv *priv,
3603 struct bss_info *last)
3604{
3605 struct bss_info *ptr = NULL;
3606 struct list_head *curr;
3607
3608 curr = last ? last->list.next : priv->bss_list.next;
3609 while (curr != &priv->bss_list) {
3610 ptr = list_entry(curr, struct bss_info, list);
3611 if (at76_match_essid(priv, ptr) && at76_match_mode(priv, ptr)
3612 && at76_match_wep(priv, ptr) && at76_match_rates(priv, ptr)
3613 && at76_match_bssid(priv, ptr))
3614 break;
3615 curr = curr->next;
3616 }
3617
3618 if (curr == &priv->bss_list)
3619 ptr = NULL;
3620 /* otherwise ptr points to the struct bss_info we have chosen */
3621
3622 at76_dbg(DBG_BSS_TABLE, "%s %s: returned %p", priv->netdev->name,
3623 __func__, ptr);
3624 return ptr;
3625}
3626
3627/* Start joining a matching BSS, or create own IBSS */
3628static void at76_work_join(struct work_struct *work)
3629{
3630 struct at76_priv *priv = container_of(work, struct at76_priv,
3631 work_join);
3632 int ret;
3633 unsigned long flags;
3634
3635 mutex_lock(&priv->mtx);
3636
3637 WARN_ON(priv->mac_state != MAC_JOINING);
3638 if (priv->mac_state != MAC_JOINING)
3639 goto exit;
3640
3641 /* secure the access to priv->curr_bss ! */
3642 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
3643 priv->curr_bss = at76_match_bss(priv, priv->curr_bss);
3644 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
3645
3646 if (!priv->curr_bss) {
3647 /* here we haven't found a matching (i)bss ... */
3648 if (priv->iw_mode == IW_MODE_ADHOC) {
3649 at76_set_mac_state(priv, MAC_OWN_IBSS);
3650 at76_start_ibss(priv);
3651 goto exit;
3652 }
3653 /* haven't found a matching BSS in infra mode - try again */
3654 at76_set_mac_state(priv, MAC_SCANNING);
3655 schedule_work(&priv->work_start_scan);
3656 goto exit;
3657 }
3658
3659 ret = at76_join_bss(priv, priv->curr_bss);
3660 if (ret < 0) {
3661 printk(KERN_ERR "%s: join_bss failed with %d\n",
3662 priv->netdev->name, ret);
3663 goto exit;
3664 }
3665
3666 ret = at76_wait_completion(priv, CMD_JOIN);
3667 if (ret != CMD_STATUS_COMPLETE) {
3668 if (ret != CMD_STATUS_TIME_OUT)
3669 printk(KERN_ERR "%s: join_bss completed with %d\n",
3670 priv->netdev->name, ret);
3671 else
3672 printk(KERN_INFO "%s: join_bss ssid %s timed out\n",
3673 priv->netdev->name,
3674 mac2str(priv->curr_bss->bssid));
3675
3676 /* retry next BSS immediately */
3677 schedule_work(&priv->work_join);
3678 goto exit;
3679 }
3680
3681 /* here we have joined the (I)BSS */
3682 if (priv->iw_mode == IW_MODE_ADHOC) {
3683 struct bss_info *bptr = priv->curr_bss;
3684 at76_set_mac_state(priv, MAC_CONNECTED);
3685 /* get ESSID, BSSID and channel for priv->curr_bss */
3686 priv->essid_size = bptr->ssid_len;
3687 memcpy(priv->essid, bptr->ssid, bptr->ssid_len);
3688 memcpy(priv->bssid, bptr->bssid, ETH_ALEN);
3689 priv->channel = bptr->channel;
3690 at76_iwevent_bss_connect(priv->netdev, bptr->bssid);
3691 netif_carrier_on(priv->netdev);
3692 netif_start_queue(priv->netdev);
3693 /* just to be sure */
3694 cancel_delayed_work(&priv->dwork_get_scan);
3695 cancel_delayed_work(&priv->dwork_auth);
3696 cancel_delayed_work(&priv->dwork_assoc);
3697 } else {
3698 /* send auth req */
3699 priv->retries = AUTH_RETRIES;
3700 at76_set_mac_state(priv, MAC_AUTH);
3701 at76_auth_req(priv, priv->curr_bss, 1, NULL);
3702 at76_dbg(DBG_MGMT_TIMER,
3703 "%s:%d: starting mgmt_timer + HZ", __func__, __LINE__);
3704 schedule_delayed_work(&priv->dwork_auth, AUTH_TIMEOUT);
3705 }
3706
3707exit:
3708 mutex_unlock(&priv->mtx);
3709}
3710
3711/* Reap scan results */
3712static void at76_dwork_get_scan(struct work_struct *work)
3713{
3714 int status;
3715 int ret;
3716 struct at76_priv *priv = container_of(work, struct at76_priv,
3717 dwork_get_scan.work);
3718
3719 mutex_lock(&priv->mtx);
3720 WARN_ON(priv->mac_state != MAC_SCANNING);
3721 if (priv->mac_state != MAC_SCANNING)
3722 goto exit;
3723
3724 status = at76_get_cmd_status(priv->udev, CMD_SCAN);
3725 if (status < 0) {
3726 printk(KERN_ERR "%s: %s: at76_get_cmd_status failed with %d\n",
3727 priv->netdev->name, __func__, status);
3728 status = CMD_STATUS_IN_PROGRESS;
3729 /* INFO: Hope it was a one off error - if not, scanning
3730 further down the line and stop this cycle */
3731 }
3732 at76_dbg(DBG_PROGRESS,
3733 "%s %s: got cmd_status %d (state %s, need_any %d)",
3734 priv->netdev->name, __func__, status,
3735 mac_states[priv->mac_state], priv->scan_need_any);
3736
3737 if (status != CMD_STATUS_COMPLETE) {
3738 if ((status != CMD_STATUS_IN_PROGRESS) &&
3739 (status != CMD_STATUS_IDLE))
3740 printk(KERN_ERR "%s: %s: Bad scan status: %s\n",
3741 priv->netdev->name, __func__,
3742 at76_get_cmd_status_string(status));
3743
3744 /* the first cmd status after scan start is always a IDLE ->
3745 start the timer to poll again until COMPLETED */
3746 at76_dbg(DBG_MGMT_TIMER,
3747 "%s:%d: starting mgmt_timer for %d ticks",
3748 __func__, __LINE__, SCAN_POLL_INTERVAL);
3749 schedule_delayed_work(&priv->dwork_get_scan,
3750 SCAN_POLL_INTERVAL);
3751 goto exit;
3752 }
3753
3754 if (at76_debug & DBG_BSS_TABLE)
3755 at76_dump_bss_table(priv);
3756
3757 if (priv->scan_need_any) {
3758 ret = at76_start_scan(priv, 0);
3759 if (ret < 0)
3760 printk(KERN_ERR
3761 "%s: %s: start_scan (ANY) failed with %d\n",
3762 priv->netdev->name, __func__, ret);
3763 at76_dbg(DBG_MGMT_TIMER,
3764 "%s:%d: starting mgmt_timer for %d ticks", __func__,
3765 __LINE__, SCAN_POLL_INTERVAL);
3766 schedule_delayed_work(&priv->dwork_get_scan,
3767 SCAN_POLL_INTERVAL);
3768 priv->scan_need_any = 0;
3769 } else {
3770 priv->scan_state = SCAN_COMPLETED;
3771 /* report the end of scan to user space */
3772 at76_iwevent_scan_complete(priv->netdev);
3773 at76_set_mac_state(priv, MAC_JOINING);
3774 schedule_work(&priv->work_join);
3775 }
3776
3777exit:
3778 mutex_unlock(&priv->mtx);
3779}
3780
3781/* Handle loss of beacons from the AP */
3782static void at76_dwork_beacon(struct work_struct *work)
3783{
3784 struct at76_priv *priv = container_of(work, struct at76_priv,
3785 dwork_beacon.work);
3786
3787 mutex_lock(&priv->mtx);
3788 if (priv->mac_state != MAC_CONNECTED || priv->iw_mode != IW_MODE_INFRA)
3789 goto exit;
3790
3791 /* We haven't received any beacons from out AP for BEACON_TIMEOUT */
3792 printk(KERN_INFO "%s: lost beacon bssid %s\n",
3793 priv->netdev->name, mac2str(priv->curr_bss->bssid));
3794
3795 netif_carrier_off(priv->netdev);
3796 netif_stop_queue(priv->netdev);
3797 at76_iwevent_bss_disconnect(priv->netdev);
3798 at76_set_mac_state(priv, MAC_SCANNING);
3799 schedule_work(&priv->work_start_scan);
3800
3801exit:
3802 mutex_unlock(&priv->mtx);
3803}
3804
3805/* Handle authentication response timeout */
3806static void at76_dwork_auth(struct work_struct *work)
3807{
3808 struct at76_priv *priv = container_of(work, struct at76_priv,
3809 dwork_auth.work);
3810
3811 mutex_lock(&priv->mtx);
3812 WARN_ON(priv->mac_state != MAC_AUTH);
3813 if (priv->mac_state != MAC_AUTH)
3814 goto exit;
3815
3816 at76_dbg(DBG_PROGRESS, "%s: authentication response timeout",
3817 priv->netdev->name);
3818
3819 if (priv->retries-- >= 0) {
3820 at76_auth_req(priv, priv->curr_bss, 1, NULL);
3821 at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer + HZ",
3822 __func__, __LINE__);
3823 schedule_delayed_work(&priv->dwork_auth, AUTH_TIMEOUT);
3824 } else {
3825 /* try to get next matching BSS */
3826 at76_set_mac_state(priv, MAC_JOINING);
3827 schedule_work(&priv->work_join);
3828 }
3829
3830exit:
3831 mutex_unlock(&priv->mtx);
3832}
3833
3834/* Handle association response timeout */
3835static void at76_dwork_assoc(struct work_struct *work)
3836{
3837 struct at76_priv *priv = container_of(work, struct at76_priv,
3838 dwork_assoc.work);
3839
3840 mutex_lock(&priv->mtx);
3841 WARN_ON(priv->mac_state != MAC_ASSOC);
3842 if (priv->mac_state != MAC_ASSOC)
3843 goto exit;
3844
3845 at76_dbg(DBG_PROGRESS, "%s: association response timeout",
3846 priv->netdev->name);
3847
3848 if (priv->retries-- >= 0) {
3849 at76_assoc_req(priv, priv->curr_bss);
3850 at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer + HZ",
3851 __func__, __LINE__);
3852 schedule_delayed_work(&priv->dwork_assoc, ASSOC_TIMEOUT);
3853 } else {
3854 /* try to get next matching BSS */
3855 at76_set_mac_state(priv, MAC_JOINING);
3856 schedule_work(&priv->work_join);
3857 }
3858
3859exit:
3860 mutex_unlock(&priv->mtx);
3861}
3862
3863/* Read new bssid in ad-hoc mode */
3864static void at76_work_new_bss(struct work_struct *work)
3865{
3866 struct at76_priv *priv = container_of(work, struct at76_priv,
3867 work_new_bss);
3868 int ret;
3869 struct mib_mac_mgmt mac_mgmt;
3870
3871 mutex_lock(&priv->mtx);
3872
3873 ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, &mac_mgmt,
3874 sizeof(struct mib_mac_mgmt));
3875 if (ret < 0) {
3876 printk(KERN_ERR "%s: at76_get_mib failed: %d\n",
3877 priv->netdev->name, ret);
3878 goto exit;
3879 }
3880
3881 at76_dbg(DBG_PROGRESS, "ibss_change = 0x%2x", mac_mgmt.ibss_change);
3882 memcpy(priv->bssid, mac_mgmt.current_bssid, ETH_ALEN);
3883 at76_dbg(DBG_PROGRESS, "using BSSID %s", mac2str(priv->bssid));
3884
3885 at76_iwevent_bss_connect(priv->netdev, priv->bssid);
3886
3887 priv->mib_buf.type = MIB_MAC_MGMT;
3888 priv->mib_buf.size = 1;
3889 priv->mib_buf.index = offsetof(struct mib_mac_mgmt, ibss_change);
3890 priv->mib_buf.data.byte = 0;
3891
3892 ret = at76_set_mib(priv, &priv->mib_buf);
3893 if (ret < 0)
3894 printk(KERN_ERR "%s: set_mib (ibss change ok) failed: %d\n",
3895 priv->netdev->name, ret);
3896
3897exit:
3898 mutex_unlock(&priv->mtx);
3899}
3900
1466static int at76_startup_device(struct at76_priv *priv) 3901static int at76_startup_device(struct at76_priv *priv)
1467{ 3902{
1468 struct at76_card_config *ccfg = &priv->card_config; 3903 struct at76_card_config *ccfg = &priv->card_config;
@@ -1470,14 +3905,14 @@ static int at76_startup_device(struct at76_priv *priv)
1470 3905
1471 at76_dbg(DBG_PARAMS, 3906 at76_dbg(DBG_PARAMS,
1472 "%s param: ssid %.*s (%s) mode %s ch %d wep %s key %d " 3907 "%s param: ssid %.*s (%s) mode %s ch %d wep %s key %d "
1473 "keylen %d", wiphy_name(priv->hw->wiphy), priv->essid_size, 3908 "keylen %d", priv->netdev->name, priv->essid_size, priv->essid,
1474 priv->essid, hex2str(priv->essid, IW_ESSID_MAX_SIZE), 3909 hex2str(priv->essid, IW_ESSID_MAX_SIZE),
1475 priv->iw_mode == IW_MODE_ADHOC ? "adhoc" : "infra", 3910 priv->iw_mode == IW_MODE_ADHOC ? "adhoc" : "infra",
1476 priv->channel, priv->wep_enabled ? "enabled" : "disabled", 3911 priv->channel, priv->wep_enabled ? "enabled" : "disabled",
1477 priv->wep_key_id, priv->wep_keys_len[priv->wep_key_id]); 3912 priv->wep_key_id, priv->wep_keys_len[priv->wep_key_id]);
1478 at76_dbg(DBG_PARAMS, 3913 at76_dbg(DBG_PARAMS,
1479 "%s param: preamble %s rts %d retry %d frag %d " 3914 "%s param: preamble %s rts %d retry %d frag %d "
1480 "txrate %s auth_mode %d", wiphy_name(priv->hw->wiphy), 3915 "txrate %s auth_mode %d", priv->netdev->name,
1481 preambles[priv->preamble_type], priv->rts_threshold, 3916 preambles[priv->preamble_type], priv->rts_threshold,
1482 priv->short_retry_limit, priv->frag_threshold, 3917 priv->short_retry_limit, priv->frag_threshold,
1483 priv->txrate == TX_RATE_1MBIT ? "1MBit" : priv->txrate == 3918 priv->txrate == TX_RATE_1MBIT ? "1MBit" : priv->txrate ==
@@ -1488,7 +3923,7 @@ static int at76_startup_device(struct at76_priv *priv)
1488 at76_dbg(DBG_PARAMS, 3923 at76_dbg(DBG_PARAMS,
1489 "%s param: pm_mode %d pm_period %d auth_mode %s " 3924 "%s param: pm_mode %d pm_period %d auth_mode %s "
1490 "scan_times %d %d scan_mode %s", 3925 "scan_times %d %d scan_mode %s",
1491 wiphy_name(priv->hw->wiphy), priv->pm_mode, priv->pm_period, 3926 priv->netdev->name, priv->pm_mode, priv->pm_period,
1492 priv->auth_mode == WLAN_AUTH_OPEN ? "open" : "shared_secret", 3927 priv->auth_mode == WLAN_AUTH_OPEN ? "open" : "shared_secret",
1493 priv->scan_min_time, priv->scan_max_time, 3928 priv->scan_min_time, priv->scan_max_time,
1494 priv->scan_mode == SCAN_TYPE_ACTIVE ? "active" : "passive"); 3929 priv->scan_mode == SCAN_TYPE_ACTIVE ? "active" : "passive");
@@ -1522,8 +3957,7 @@ static int at76_startup_device(struct at76_priv *priv)
1522 ccfg->ssid_len = priv->essid_size; 3957 ccfg->ssid_len = priv->essid_size;
1523 3958
1524 ccfg->wep_default_key_id = priv->wep_key_id; 3959 ccfg->wep_default_key_id = priv->wep_key_id;
1525 memcpy(ccfg->wep_default_key_value, priv->wep_keys, 3960 memcpy(ccfg->wep_default_key_value, priv->wep_keys, 4 * WEP_KEY_LEN);
1526 sizeof(priv->wep_keys));
1527 3961
1528 ccfg->short_preamble = priv->preamble_type; 3962 ccfg->short_preamble = priv->preamble_type;
1529 ccfg->beacon_period = cpu_to_le16(priv->beacon_period); 3963 ccfg->beacon_period = cpu_to_le16(priv->beacon_period);
@@ -1532,7 +3966,7 @@ static int at76_startup_device(struct at76_priv *priv)
1532 sizeof(struct at76_card_config)); 3966 sizeof(struct at76_card_config));
1533 if (ret < 0) { 3967 if (ret < 0) {
1534 printk(KERN_ERR "%s: at76_set_card_command failed: %d\n", 3968 printk(KERN_ERR "%s: at76_set_card_command failed: %d\n",
1535 wiphy_name(priv->hw->wiphy), ret); 3969 priv->netdev->name, ret);
1536 return ret; 3970 return ret;
1537 } 3971 }
1538 3972
@@ -1578,6 +4012,69 @@ static int at76_startup_device(struct at76_priv *priv)
1578 return 0; 4012 return 0;
1579} 4013}
1580 4014
4015/* Restart the interface */
4016static void at76_dwork_restart(struct work_struct *work)
4017{
4018 struct at76_priv *priv = container_of(work, struct at76_priv,
4019 dwork_restart.work);
4020
4021 mutex_lock(&priv->mtx);
4022
4023 netif_carrier_off(priv->netdev); /* stop netdev watchdog */
4024 netif_stop_queue(priv->netdev); /* stop tx data packets */
4025
4026 at76_startup_device(priv);
4027
4028 if (priv->iw_mode != IW_MODE_MONITOR) {
4029 priv->netdev->type = ARPHRD_ETHER;
4030 at76_set_mac_state(priv, MAC_SCANNING);
4031 schedule_work(&priv->work_start_scan);
4032 } else {
4033 priv->netdev->type = ARPHRD_IEEE80211_RADIOTAP;
4034 at76_start_monitor(priv);
4035 }
4036
4037 mutex_unlock(&priv->mtx);
4038}
4039
4040/* Initiate scanning */
4041static void at76_work_start_scan(struct work_struct *work)
4042{
4043 struct at76_priv *priv = container_of(work, struct at76_priv,
4044 work_start_scan);
4045 int ret;
4046
4047 mutex_lock(&priv->mtx);
4048
4049 WARN_ON(priv->mac_state != MAC_SCANNING);
4050 if (priv->mac_state != MAC_SCANNING)
4051 goto exit;
4052
4053 /* only clear the bss list when a scan is actively initiated,
4054 * otherwise simply rely on at76_bss_list_timeout */
4055 if (priv->scan_state == SCAN_IN_PROGRESS) {
4056 at76_free_bss_list(priv);
4057 priv->scan_need_any = 1;
4058 } else
4059 priv->scan_need_any = 0;
4060
4061 ret = at76_start_scan(priv, 1);
4062
4063 if (ret < 0)
4064 printk(KERN_ERR "%s: %s: start_scan failed with %d\n",
4065 priv->netdev->name, __func__, ret);
4066 else {
4067 at76_dbg(DBG_MGMT_TIMER,
4068 "%s:%d: starting mgmt_timer for %d ticks",
4069 __func__, __LINE__, SCAN_POLL_INTERVAL);
4070 schedule_delayed_work(&priv->dwork_get_scan,
4071 SCAN_POLL_INTERVAL);
4072 }
4073
4074exit:
4075 mutex_unlock(&priv->mtx);
4076}
4077
1581/* Enable or disable promiscuous mode */ 4078/* Enable or disable promiscuous mode */
1582static void at76_work_set_promisc(struct work_struct *work) 4079static void at76_work_set_promisc(struct work_struct *work)
1583{ 4080{
@@ -1595,7 +4092,7 @@ static void at76_work_set_promisc(struct work_struct *work)
1595 ret = at76_set_mib(priv, &priv->mib_buf); 4092 ret = at76_set_mib(priv, &priv->mib_buf);
1596 if (ret < 0) 4093 if (ret < 0)
1597 printk(KERN_ERR "%s: set_mib (promiscuous_mode) failed: %d\n", 4094 printk(KERN_ERR "%s: set_mib (promiscuous_mode) failed: %d\n",
1598 wiphy_name(priv->hw->wiphy), ret); 4095 priv->netdev->name, ret);
1599 4096
1600 mutex_unlock(&priv->mtx); 4097 mutex_unlock(&priv->mtx);
1601} 4098}
@@ -1611,759 +4108,1088 @@ static void at76_work_submit_rx(struct work_struct *work)
1611 mutex_unlock(&priv->mtx); 4108 mutex_unlock(&priv->mtx);
1612} 4109}
1613 4110
1614static void at76_rx_tasklet(unsigned long param) 4111/* We got an association response */
4112static void at76_rx_mgmt_assoc(struct at76_priv *priv,
4113 struct at76_rx_buffer *buf)
1615{ 4114{
1616 struct urb *urb = (struct urb *)param; 4115 struct ieee80211_assoc_response *resp =
1617 struct at76_priv *priv = urb->context; 4116 (struct ieee80211_assoc_response *)buf->packet;
1618 struct at76_rx_buffer *buf; 4117 u16 assoc_id = le16_to_cpu(resp->aid);
1619 struct ieee80211_rx_status rx_status = { 0 }; 4118 u16 status = le16_to_cpu(resp->status);
1620 4119
1621 if (priv->device_unplugged) { 4120 at76_dbg(DBG_RX_MGMT, "%s: rx AssocResp bssid %s capa 0x%04x status "
1622 at76_dbg(DBG_DEVSTART, "device unplugged"); 4121 "0x%04x assoc_id 0x%04x rates %s", priv->netdev->name,
1623 if (urb) 4122 mac2str(resp->header.addr3), le16_to_cpu(resp->capability),
1624 at76_dbg(DBG_DEVSTART, "urb status %d", urb->status); 4123 status, assoc_id, hex2str(resp->info_element->data,
4124 resp->info_element->len));
4125
4126 if (priv->mac_state != MAC_ASSOC) {
4127 printk(KERN_INFO "%s: AssocResp in state %s ignored\n",
4128 priv->netdev->name, mac_states[priv->mac_state]);
1625 return; 4129 return;
1626 } 4130 }
1627 4131
1628 if (!priv->rx_skb || !priv->rx_skb->data) 4132 BUG_ON(!priv->curr_bss);
1629 return; 4133
1630 4134 cancel_delayed_work(&priv->dwork_assoc);
1631 buf = (struct at76_rx_buffer *)priv->rx_skb->data; 4135 if (status == WLAN_STATUS_SUCCESS) {
1632 4136 struct bss_info *ptr = priv->curr_bss;
1633 if (urb->status != 0) { 4137 priv->assoc_id = assoc_id & 0x3fff;
1634 if (urb->status != -ENOENT && urb->status != -ECONNRESET) 4138 /* update iwconfig params */
1635 at76_dbg(DBG_URB, 4139 memcpy(priv->bssid, ptr->bssid, ETH_ALEN);
1636 "%s %s: - nonzero Rx bulk status received: %d", 4140 memcpy(priv->essid, ptr->ssid, ptr->ssid_len);
1637 __func__, wiphy_name(priv->hw->wiphy), 4141 priv->essid_size = ptr->ssid_len;
1638 urb->status); 4142 priv->channel = ptr->channel;
1639 return; 4143 schedule_work(&priv->work_assoc_done);
4144 } else {
4145 at76_set_mac_state(priv, MAC_JOINING);
4146 schedule_work(&priv->work_join);
1640 } 4147 }
4148}
1641 4149
1642 at76_dbg(DBG_RX_ATMEL_HDR, 4150/* Process disassociation request from the AP */
1643 "%s: rx frame: rate %d rssi %d noise %d link %d", 4151static void at76_rx_mgmt_disassoc(struct at76_priv *priv,
1644 wiphy_name(priv->hw->wiphy), buf->rx_rate, buf->rssi, 4152 struct at76_rx_buffer *buf)
1645 buf->noise_level, buf->link_quality); 4153{
1646 4154 struct ieee80211_disassoc *resp =
1647 skb_trim(priv->rx_skb, le16_to_cpu(buf->wlength) + AT76_RX_HDRLEN); 4155 (struct ieee80211_disassoc *)buf->packet;
1648 at76_dbg_dump(DBG_RX_DATA, &priv->rx_skb->data[AT76_RX_HDRLEN], 4156 struct ieee80211_hdr_3addr *mgmt = &resp->header;
1649 priv->rx_skb->len, "RX: len=%d", 4157
1650 (int)(priv->rx_skb->len - AT76_RX_HDRLEN)); 4158 at76_dbg(DBG_RX_MGMT,
4159 "%s: rx DisAssoc bssid %s reason 0x%04x destination %s",
4160 priv->netdev->name, mac2str(mgmt->addr3),
4161 le16_to_cpu(resp->reason), mac2str(mgmt->addr1));
4162
4163 /* We are not connected, ignore */
4164 if (priv->mac_state == MAC_SCANNING || priv->mac_state == MAC_INIT
4165 || !priv->curr_bss)
4166 return;
1651 4167
1652 rx_status.signal = buf->rssi; 4168 /* Not our BSSID, ignore */
1653 /* FIXME: is rate_idx still present in structure? */ 4169 if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid))
1654 rx_status.rate_idx = buf->rx_rate; 4170 return;
1655 rx_status.flag |= RX_FLAG_DECRYPTED;
1656 rx_status.flag |= RX_FLAG_IV_STRIPPED;
1657 4171
1658 skb_pull(priv->rx_skb, AT76_RX_HDRLEN); 4172 /* Not for our STA and not broadcast, ignore */
1659 at76_dbg(DBG_MAC80211, "calling ieee80211_rx_irqsafe(): %d/%d", 4173 if (compare_ether_addr(priv->netdev->dev_addr, mgmt->addr1)
1660 priv->rx_skb->len, priv->rx_skb->data_len); 4174 && !is_broadcast_ether_addr(mgmt->addr1))
1661 ieee80211_rx_irqsafe(priv->hw, priv->rx_skb, &rx_status); 4175 return;
1662 4176
1663 /* Use a new skb for the next receive */ 4177 if (priv->mac_state != MAC_ASSOC && priv->mac_state != MAC_CONNECTED
1664 priv->rx_skb = NULL; 4178 && priv->mac_state != MAC_JOINING) {
4179 printk(KERN_INFO "%s: DisAssoc in state %s ignored\n",
4180 priv->netdev->name, mac_states[priv->mac_state]);
4181 return;
4182 }
1665 4183
1666 at76_submit_rx_urb(priv); 4184 if (priv->mac_state == MAC_CONNECTED) {
4185 netif_carrier_off(priv->netdev);
4186 netif_stop_queue(priv->netdev);
4187 at76_iwevent_bss_disconnect(priv->netdev);
4188 }
4189 cancel_delayed_work(&priv->dwork_get_scan);
4190 cancel_delayed_work(&priv->dwork_beacon);
4191 cancel_delayed_work(&priv->dwork_auth);
4192 cancel_delayed_work(&priv->dwork_assoc);
4193 at76_set_mac_state(priv, MAC_JOINING);
4194 schedule_work(&priv->work_join);
1667} 4195}
1668 4196
1669/* Load firmware into kernel memory and parse it */ 4197static void at76_rx_mgmt_auth(struct at76_priv *priv,
1670static struct fwentry *at76_load_firmware(struct usb_device *udev, 4198 struct at76_rx_buffer *buf)
1671 enum board_type board_type)
1672{ 4199{
1673 int ret; 4200 struct ieee80211_auth *resp = (struct ieee80211_auth *)buf->packet;
1674 char *str; 4201 struct ieee80211_hdr_3addr *mgmt = &resp->header;
1675 struct at76_fw_header *fwh; 4202 int seq_nr = le16_to_cpu(resp->transaction);
1676 struct fwentry *fwe = &firmwares[board_type]; 4203 int alg = le16_to_cpu(resp->algorithm);
1677 4204 int status = le16_to_cpu(resp->status);
1678 mutex_lock(&fw_mutex); 4205
1679 4206 at76_dbg(DBG_RX_MGMT,
1680 if (fwe->loaded) { 4207 "%s: rx AuthFrame bssid %s alg %d seq_nr %d status %d "
1681 at76_dbg(DBG_FW, "re-using previously loaded fw"); 4208 "destination %s", priv->netdev->name, mac2str(mgmt->addr3),
1682 goto exit; 4209 alg, seq_nr, status, mac2str(mgmt->addr1));
4210
4211 if (alg == WLAN_AUTH_SHARED_KEY && seq_nr == 2)
4212 at76_dbg(DBG_RX_MGMT, "%s: AuthFrame challenge %s ...",
4213 priv->netdev->name, hex2str(resp->info_element, 18));
4214
4215 if (priv->mac_state != MAC_AUTH) {
4216 printk(KERN_INFO "%s: ignored AuthFrame in state %s\n",
4217 priv->netdev->name, mac_states[priv->mac_state]);
4218 return;
1683 } 4219 }
1684 4220 if (priv->auth_mode != alg) {
1685 at76_dbg(DBG_FW, "downloading firmware %s", fwe->fwname); 4221 printk(KERN_INFO "%s: ignored AuthFrame for alg %d\n",
1686 ret = request_firmware(&fwe->fw, fwe->fwname, &udev->dev); 4222 priv->netdev->name, alg);
1687 if (ret < 0) { 4223 return;
1688 dev_printk(KERN_ERR, &udev->dev, "firmware %s not found!\n",
1689 fwe->fwname);
1690 dev_printk(KERN_ERR, &udev->dev,
1691 "you may need to download the firmware from "
1692 "http://developer.berlios.de/projects/at76c503a/\n");
1693 goto exit;
1694 } 4224 }
1695 4225
1696 at76_dbg(DBG_FW, "got it."); 4226 BUG_ON(!priv->curr_bss);
1697 fwh = (struct at76_fw_header *)(fwe->fw->data);
1698 4227
1699 if (fwe->fw->size <= sizeof(*fwh)) { 4228 /* Not our BSSID or not for our STA, ignore */
1700 dev_printk(KERN_ERR, &udev->dev, 4229 if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid)
1701 "firmware is too short (0x%zx)\n", fwe->fw->size); 4230 || compare_ether_addr(priv->netdev->dev_addr, mgmt->addr1))
1702 goto exit; 4231 return;
4232
4233 cancel_delayed_work(&priv->dwork_auth);
4234 if (status != WLAN_STATUS_SUCCESS) {
4235 /* try to join next bss */
4236 at76_set_mac_state(priv, MAC_JOINING);
4237 schedule_work(&priv->work_join);
4238 return;
1703 } 4239 }
1704 4240
1705 /* CRC currently not checked */ 4241 if (priv->auth_mode == WLAN_AUTH_OPEN || seq_nr == 4) {
1706 fwe->board_type = le32_to_cpu(fwh->board_type); 4242 priv->retries = ASSOC_RETRIES;
1707 if (fwe->board_type != board_type) { 4243 at76_set_mac_state(priv, MAC_ASSOC);
1708 dev_printk(KERN_ERR, &udev->dev, 4244 at76_assoc_req(priv, priv->curr_bss);
1709 "board type mismatch, requested %u, got %u\n", 4245 at76_dbg(DBG_MGMT_TIMER,
1710 board_type, fwe->board_type); 4246 "%s:%d: starting mgmt_timer + HZ", __func__, __LINE__);
1711 goto exit; 4247 schedule_delayed_work(&priv->dwork_assoc, ASSOC_TIMEOUT);
4248 return;
1712 } 4249 }
1713 4250
1714 fwe->fw_version.major = fwh->major; 4251 WARN_ON(seq_nr != 2);
1715 fwe->fw_version.minor = fwh->minor; 4252 at76_auth_req(priv, priv->curr_bss, seq_nr + 1, resp->info_element);
1716 fwe->fw_version.patch = fwh->patch; 4253 at76_dbg(DBG_MGMT_TIMER, "%s:%d: starting mgmt_timer + HZ", __func__,
1717 fwe->fw_version.build = fwh->build; 4254 __LINE__);
4255 schedule_delayed_work(&priv->dwork_auth, AUTH_TIMEOUT);
4256}
1718 4257
1719 str = (char *)fwh + le32_to_cpu(fwh->str_offset); 4258static void at76_rx_mgmt_deauth(struct at76_priv *priv,
1720 fwe->intfw = (u8 *)fwh + le32_to_cpu(fwh->int_fw_offset); 4259 struct at76_rx_buffer *buf)
1721 fwe->intfw_size = le32_to_cpu(fwh->int_fw_len); 4260{
1722 fwe->extfw = (u8 *)fwh + le32_to_cpu(fwh->ext_fw_offset); 4261 struct ieee80211_disassoc *resp =
1723 fwe->extfw_size = le32_to_cpu(fwh->ext_fw_len); 4262 (struct ieee80211_disassoc *)buf->packet;
4263 struct ieee80211_hdr_3addr *mgmt = &resp->header;
4264
4265 at76_dbg(DBG_RX_MGMT | DBG_PROGRESS,
4266 "%s: rx DeAuth bssid %s reason 0x%04x destination %s",
4267 priv->netdev->name, mac2str(mgmt->addr3),
4268 le16_to_cpu(resp->reason), mac2str(mgmt->addr1));
4269
4270 if (priv->mac_state != MAC_AUTH && priv->mac_state != MAC_ASSOC
4271 && priv->mac_state != MAC_CONNECTED) {
4272 printk(KERN_INFO "%s: DeAuth in state %s ignored\n",
4273 priv->netdev->name, mac_states[priv->mac_state]);
4274 return;
4275 }
1724 4276
1725 fwe->loaded = 1; 4277 BUG_ON(!priv->curr_bss);
1726 4278
1727 dev_printk(KERN_DEBUG, &udev->dev, 4279 /* Not our BSSID, ignore */
1728 "using firmware %s (version %d.%d.%d-%d)\n", 4280 if (compare_ether_addr(mgmt->addr3, priv->curr_bss->bssid))
1729 fwe->fwname, fwh->major, fwh->minor, fwh->patch, fwh->build); 4281 return;
1730 4282
1731 at76_dbg(DBG_DEVSTART, "board %u, int %d:%d, ext %d:%d", board_type, 4283 /* Not for our STA and not broadcast, ignore */
1732 le32_to_cpu(fwh->int_fw_offset), le32_to_cpu(fwh->int_fw_len), 4284 if (compare_ether_addr(priv->netdev->dev_addr, mgmt->addr1)
1733 le32_to_cpu(fwh->ext_fw_offset), le32_to_cpu(fwh->ext_fw_len)); 4285 && !is_broadcast_ether_addr(mgmt->addr1))
1734 at76_dbg(DBG_DEVSTART, "firmware id %s", str); 4286 return;
1735 4287
1736exit: 4288 if (priv->mac_state == MAC_CONNECTED)
1737 mutex_unlock(&fw_mutex); 4289 at76_iwevent_bss_disconnect(priv->netdev);
1738 4290
1739 if (fwe->loaded) 4291 at76_set_mac_state(priv, MAC_JOINING);
1740 return fwe; 4292 schedule_work(&priv->work_join);
1741 else 4293 cancel_delayed_work(&priv->dwork_get_scan);
1742 return NULL; 4294 cancel_delayed_work(&priv->dwork_beacon);
4295 cancel_delayed_work(&priv->dwork_auth);
4296 cancel_delayed_work(&priv->dwork_assoc);
1743} 4297}
1744 4298
1745static void at76_mac80211_tx_callback(struct urb *urb) 4299static void at76_rx_mgmt_beacon(struct at76_priv *priv,
4300 struct at76_rx_buffer *buf)
1746{ 4301{
1747 struct at76_priv *priv = urb->context; 4302 int varpar_len;
1748 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(priv->tx_skb); 4303 /* beacon content */
4304 struct ieee80211_beacon *bdata = (struct ieee80211_beacon *)buf->packet;
4305 struct ieee80211_hdr_3addr *mgmt = &bdata->header;
4306
4307 struct list_head *lptr;
4308 struct bss_info *match; /* entry matching addr3 with its bssid */
4309 int new_entry = 0;
4310 int len;
4311 struct ieee80211_info_element *ie;
4312 int have_ssid = 0;
4313 int have_rates = 0;
4314 int have_channel = 0;
4315 int keep_going = 1;
4316 unsigned long flags;
4317
4318 spin_lock_irqsave(&priv->bss_list_spinlock, flags);
4319 if (priv->mac_state == MAC_CONNECTED) {
4320 /* in state MAC_CONNECTED we use the mgmt_timer to control
4321 the beacon of the BSS */
4322 BUG_ON(!priv->curr_bss);
4323
4324 if (!compare_ether_addr(priv->curr_bss->bssid, mgmt->addr3)) {
4325 /* We got our AP's beacon, defer the timeout handler.
4326 Kill pending work first, as schedule_delayed_work()
4327 won't do it. */
4328 cancel_delayed_work(&priv->dwork_beacon);
4329 schedule_delayed_work(&priv->dwork_beacon,
4330 BEACON_TIMEOUT);
4331 priv->curr_bss->rssi = buf->rssi;
4332 priv->beacons_received++;
4333 goto exit;
4334 }
4335 }
1749 4336
1750 at76_dbg(DBG_MAC80211, "%s()", __func__); 4337 /* look if we have this BSS already in the list */
4338 match = NULL;
1751 4339
1752 switch (urb->status) { 4340 if (!list_empty(&priv->bss_list)) {
1753 case 0: 4341 list_for_each(lptr, &priv->bss_list) {
1754 /* success */ 4342 struct bss_info *bss_ptr =
1755 /* FIXME: 4343 list_entry(lptr, struct bss_info, list);
1756 * is the frame really ACKed when tx_callback is called ? */ 4344 if (!compare_ether_addr(bss_ptr->bssid, mgmt->addr3)) {
1757 info->flags |= IEEE80211_TX_STAT_ACK; 4345 match = bss_ptr;
1758 break; 4346 break;
1759 case -ENOENT: 4347 }
1760 case -ECONNRESET: 4348 }
1761 /* fail, urb has been unlinked */
1762 /* FIXME: add error message */
1763 break;
1764 default:
1765 at76_dbg(DBG_URB, "%s - nonzero tx status received: %d",
1766 __func__, urb->status);
1767 break;
1768 } 4349 }
1769 4350
1770 memset(&info->status, 0, sizeof(info->status)); 4351 if (!match) {
4352 /* BSS not in the list - append it */
4353 match = kzalloc(sizeof(struct bss_info), GFP_ATOMIC);
4354 if (!match) {
4355 at76_dbg(DBG_BSS_TABLE,
4356 "%s: cannot kmalloc new bss info (%zd byte)",
4357 priv->netdev->name, sizeof(struct bss_info));
4358 goto exit;
4359 }
4360 new_entry = 1;
4361 list_add_tail(&match->list, &priv->bss_list);
4362 }
1771 4363
1772 ieee80211_tx_status_irqsafe(priv->hw, priv->tx_skb); 4364 match->capa = le16_to_cpu(bdata->capability);
4365 match->beacon_interval = le16_to_cpu(bdata->beacon_interval);
4366 match->rssi = buf->rssi;
4367 match->link_qual = buf->link_quality;
4368 match->noise_level = buf->noise_level;
4369 memcpy(match->bssid, mgmt->addr3, ETH_ALEN);
4370 at76_dbg(DBG_RX_BEACON, "%s: bssid %s", priv->netdev->name,
4371 mac2str(match->bssid));
4372
4373 ie = bdata->info_element;
4374
4375 /* length of var length beacon parameters */
4376 varpar_len = min_t(int, le16_to_cpu(buf->wlength) -
4377 sizeof(struct ieee80211_beacon),
4378 BEACON_MAX_DATA_LENGTH);
4379
4380 /* This routine steps through the bdata->data array to get
4381 * some useful information about the access point.
4382 * Currently, this implementation supports receipt of: SSID,
4383 * supported transfer rates and channel, in any order, with some
4384 * tolerance for intermittent unknown codes (although this
4385 * functionality may not be necessary as the useful information will
4386 * usually arrive in consecutively, but there have been some
4387 * reports of some of the useful information fields arriving in a
4388 * different order).
4389 * It does not support any more IE types although MFIE_TYPE_TIM may
4390 * be supported (on my AP at least).
4391 * The bdata->data array is about 1500 bytes long but only ~36 of those
4392 * bytes are useful, hence the have_ssid etc optimizations. */
4393
4394 while (keep_going &&
4395 ((&ie->data[ie->len] - (u8 *)bdata->info_element) <=
4396 varpar_len)) {
4397
4398 switch (ie->id) {
4399
4400 case MFIE_TYPE_SSID:
4401 if (have_ssid)
4402 break;
1773 4403
1774 priv->tx_skb = NULL; 4404 len = min_t(int, IW_ESSID_MAX_SIZE, ie->len);
1775 4405
1776 ieee80211_wake_queues(priv->hw); 4406 /* we copy only if this is a new entry,
1777} 4407 or the incoming SSID is not a hidden SSID. This
4408 will protect us from overwriting a real SSID read
4409 in a ProbeResponse with a hidden one from a
4410 following beacon. */
4411 if (!new_entry && at76_is_hidden_ssid(ie->data, len)) {
4412 have_ssid = 1;
4413 break;
4414 }
1778 4415
1779static int at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 4416 match->ssid_len = len;
1780{ 4417 memcpy(match->ssid, ie->data, len);
1781 struct at76_priv *priv = hw->priv; 4418 at76_dbg(DBG_RX_BEACON, "%s: SSID - %.*s",
1782 struct at76_tx_buffer *tx_buffer = priv->bulk_out_buffer; 4419 priv->netdev->name, len, match->ssid);
1783 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 4420 have_ssid = 1;
1784 int padding, submit_len, ret; 4421 break;
1785 4422
1786 at76_dbg(DBG_MAC80211, "%s()", __func__); 4423 case MFIE_TYPE_RATES:
4424 if (have_rates)
4425 break;
1787 4426
1788 if (priv->tx_urb->status == -EINPROGRESS) { 4427 match->rates_len =
1789 printk(KERN_ERR "%s: %s called while tx urb is pending\n", 4428 min_t(int, sizeof(match->rates), ie->len);
1790 wiphy_name(priv->hw->wiphy), __func__); 4429 memcpy(match->rates, ie->data, match->rates_len);
1791 return NETDEV_TX_BUSY; 4430 have_rates = 1;
1792 } 4431 at76_dbg(DBG_RX_BEACON, "%s: SUPPORTED RATES %s",
4432 priv->netdev->name,
4433 hex2str(ie->data, ie->len));
4434 break;
1793 4435
1794 ieee80211_stop_queues(hw); 4436 case MFIE_TYPE_DS_SET:
4437 if (have_channel)
4438 break;
1795 4439
1796 at76_ledtrig_tx_activity(); /* tell ledtrigger we send a packet */ 4440 match->channel = ie->data[0];
4441 have_channel = 1;
4442 at76_dbg(DBG_RX_BEACON, "%s: CHANNEL - %d",
4443 priv->netdev->name, match->channel);
4444 break;
1797 4445
1798 WARN_ON(priv->tx_skb != NULL); 4446 case MFIE_TYPE_CF_SET:
4447 case MFIE_TYPE_TIM:
4448 case MFIE_TYPE_IBSS_SET:
4449 default:
4450 at76_dbg(DBG_RX_BEACON, "%s: beacon IE id %d len %d %s",
4451 priv->netdev->name, ie->id, ie->len,
4452 hex2str(ie->data, ie->len));
4453 break;
4454 }
1799 4455
1800 priv->tx_skb = skb; 4456 /* advance to the next informational element */
1801 padding = at76_calc_padding(skb->len); 4457 next_ie(&ie);
1802 submit_len = AT76_TX_HDRLEN + skb->len + padding;
1803 4458
1804 /* setup 'Atmel' header */ 4459 /* Optimization: after all, the bdata->data array is
1805 memset(tx_buffer, 0, sizeof(*tx_buffer)); 4460 * varpar_len bytes long, whereas we get all of the useful
1806 tx_buffer->padding = padding; 4461 * information after only ~36 bytes, this saves us a lot of
1807 tx_buffer->wlength = cpu_to_le16(skb->len); 4462 * time (and trouble as the remaining portion of the array
1808 tx_buffer->tx_rate = ieee80211_get_tx_rate(hw, info)->hw_value; 4463 * could be full of junk)
1809 if (FIRMWARE_IS_WPA(priv->fw_version) && info->control.hw_key) { 4464 * Comment this out if you want to see what other information
1810 tx_buffer->key_id = (info->control.hw_key->keyidx); 4465 * comes from the AP - although little of it may be useful */
1811 tx_buffer->cipher_type = 4466 }
1812 priv->keys[info->control.hw_key->keyidx].cipher;
1813 tx_buffer->cipher_length =
1814 priv->keys[info->control.hw_key->keyidx].keylen;
1815 tx_buffer->reserved = 0;
1816 } else {
1817 tx_buffer->key_id = 0;
1818 tx_buffer->cipher_type = 0;
1819 tx_buffer->cipher_length = 0;
1820 tx_buffer->reserved = 0;
1821 };
1822 /* memset(tx_buffer->reserved, 0, sizeof(tx_buffer->reserved)); */
1823 memcpy(tx_buffer->packet, skb->data, skb->len);
1824 4467
1825 at76_dbg(DBG_TX_DATA, "%s tx: wlen 0x%x pad 0x%x rate %d hdr", 4468 at76_dbg(DBG_RX_BEACON, "%s: Finished processing beacon data",
1826 wiphy_name(priv->hw->wiphy), le16_to_cpu(tx_buffer->wlength), 4469 priv->netdev->name);
1827 tx_buffer->padding, tx_buffer->tx_rate);
1828 4470
1829 /* send stuff */ 4471 match->last_rx = jiffies; /* record last rx of beacon */
1830 at76_dbg_dump(DBG_TX_DATA_CONTENT, tx_buffer, submit_len,
1831 "%s(): tx_buffer %d bytes:", __func__, submit_len);
1832 usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe, tx_buffer,
1833 submit_len, at76_mac80211_tx_callback, priv);
1834 ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC);
1835 if (ret) {
1836 printk(KERN_ERR "%s: error in tx submit urb: %d\n",
1837 wiphy_name(priv->hw->wiphy), ret);
1838 if (ret == -EINVAL)
1839 printk(KERN_ERR
1840 "%s: -EINVAL: tx urb %p hcpriv %p complete %p\n",
1841 wiphy_name(priv->hw->wiphy), priv->tx_urb,
1842 priv->tx_urb->hcpriv, priv->tx_urb->complete);
1843 }
1844 4472
1845 return 0; 4473exit:
4474 spin_unlock_irqrestore(&priv->bss_list_spinlock, flags);
1846} 4475}
1847 4476
1848static int at76_mac80211_start(struct ieee80211_hw *hw) 4477/* Calculate the link level from a given rx_buffer */
4478static void at76_calc_level(struct at76_priv *priv, struct at76_rx_buffer *buf,
4479 struct iw_quality *qual)
1849{ 4480{
1850 struct at76_priv *priv = hw->priv; 4481 /* just a guess for now, might be different for other chips */
1851 int ret; 4482 int max_rssi = 42;
1852
1853 at76_dbg(DBG_MAC80211, "%s()", __func__);
1854 4483
1855 mutex_lock(&priv->mtx); 4484 qual->level = (buf->rssi * 100 / max_rssi);
1856 4485 if (qual->level > 100)
1857 ret = at76_submit_rx_urb(priv); 4486 qual->level = 100;
1858 if (ret < 0) { 4487 qual->updated |= IW_QUAL_LEVEL_UPDATED;
1859 printk(KERN_ERR "%s: open: submit_rx_urb failed: %d\n", 4488}
1860 wiphy_name(priv->hw->wiphy), ret);
1861 goto error;
1862 }
1863 4489
1864 at76_startup_device(priv); 4490/* Calculate the link quality from a given rx_buffer */
4491static void at76_calc_qual(struct at76_priv *priv, struct at76_rx_buffer *buf,
4492 struct iw_quality *qual)
4493{
4494 if (at76_is_intersil(priv->board_type))
4495 qual->qual = buf->link_quality;
4496 else {
4497 unsigned long elapsed;
1865 4498
1866 at76_start_monitor(priv); 4499 /* Update qual at most once a second */
4500 elapsed = jiffies - priv->beacons_last_qual;
4501 if (elapsed < 1 * HZ)
4502 return;
1867 4503
1868error: 4504 qual->qual = qual->level * priv->beacons_received *
1869 mutex_unlock(&priv->mtx); 4505 msecs_to_jiffies(priv->beacon_period) / elapsed;
1870 4506
1871 return 0; 4507 priv->beacons_last_qual = jiffies;
4508 priv->beacons_received = 0;
4509 }
4510 qual->qual = (qual->qual > 100) ? 100 : qual->qual;
4511 qual->updated |= IW_QUAL_QUAL_UPDATED;
1872} 4512}
1873 4513
1874static void at76_mac80211_stop(struct ieee80211_hw *hw) 4514/* Calculate the noise quality from a given rx_buffer */
4515static void at76_calc_noise(struct at76_priv *priv, struct at76_rx_buffer *buf,
4516 struct iw_quality *qual)
1875{ 4517{
1876 struct at76_priv *priv = hw->priv; 4518 qual->noise = 0;
1877 4519 qual->updated |= IW_QUAL_NOISE_INVALID;
1878 at76_dbg(DBG_MAC80211, "%s()", __func__); 4520}
1879
1880 mutex_lock(&priv->mtx);
1881 4521
1882 if (!priv->device_unplugged) { 4522static void at76_update_wstats(struct at76_priv *priv,
1883 /* We are called by "ifconfig ethX down", not because the 4523 struct at76_rx_buffer *buf)
1884 * device is not available anymore. */ 4524{
1885 if (at76_set_radio(priv, 0) == 1) 4525 struct iw_quality *qual = &priv->wstats.qual;
1886 at76_wait_completion(priv, CMD_RADIO_ON);
1887 4526
1888 /* We unlink rx_urb because at76_open() re-submits it. 4527 if (buf->rssi && priv->mac_state == MAC_CONNECTED) {
1889 * If unplugged, at76_delete_device() takes care of it. */ 4528 qual->updated = 0;
1890 usb_kill_urb(priv->rx_urb); 4529 at76_calc_level(priv, buf, qual);
4530 at76_calc_qual(priv, buf, qual);
4531 at76_calc_noise(priv, buf, qual);
4532 } else {
4533 qual->qual = 0;
4534 qual->level = 0;
4535 qual->noise = 0;
4536 qual->updated = IW_QUAL_ALL_INVALID;
1891 } 4537 }
1892
1893 mutex_unlock(&priv->mtx);
1894} 4538}
1895 4539
1896static int at76_add_interface(struct ieee80211_hw *hw, 4540static void at76_rx_mgmt(struct at76_priv *priv, struct at76_rx_buffer *buf)
1897 struct ieee80211_if_init_conf *conf)
1898{ 4541{
1899 struct at76_priv *priv = hw->priv; 4542 struct ieee80211_hdr_3addr *mgmt =
1900 int ret = 0; 4543 (struct ieee80211_hdr_3addr *)buf->packet;
4544 u16 framectl = le16_to_cpu(mgmt->frame_ctl);
4545
4546 /* update wstats */
4547 if (priv->mac_state != MAC_INIT && priv->mac_state != MAC_SCANNING) {
4548 /* jal: this is a dirty hack needed by Tim in ad-hoc mode */
4549 /* Data packets always seem to have a 0 link level, so we
4550 only read link quality info from management packets.
4551 Atmel driver actually averages the present, and previous
4552 values, we just present the raw value at the moment - TJS */
4553 if (priv->iw_mode == IW_MODE_ADHOC
4554 || (priv->curr_bss
4555 && !compare_ether_addr(mgmt->addr3,
4556 priv->curr_bss->bssid)))
4557 at76_update_wstats(priv, buf);
4558 }
1901 4559
1902 at76_dbg(DBG_MAC80211, "%s()", __func__); 4560 at76_dbg(DBG_RX_MGMT_CONTENT, "%s rx mgmt framectl 0x%x %s",
4561 priv->netdev->name, framectl,
4562 hex2str(mgmt, le16_to_cpu(buf->wlength)));
1903 4563
1904 mutex_lock(&priv->mtx); 4564 switch (framectl & IEEE80211_FCTL_STYPE) {
4565 case IEEE80211_STYPE_BEACON:
4566 case IEEE80211_STYPE_PROBE_RESP:
4567 at76_rx_mgmt_beacon(priv, buf);
4568 break;
4569
4570 case IEEE80211_STYPE_ASSOC_RESP:
4571 at76_rx_mgmt_assoc(priv, buf);
4572 break;
1905 4573
1906 switch (conf->type) { 4574 case IEEE80211_STYPE_DISASSOC:
1907 case NL80211_IFTYPE_STATION: 4575 at76_rx_mgmt_disassoc(priv, buf);
1908 priv->iw_mode = IW_MODE_INFRA;
1909 break; 4576 break;
4577
4578 case IEEE80211_STYPE_AUTH:
4579 at76_rx_mgmt_auth(priv, buf);
4580 break;
4581
4582 case IEEE80211_STYPE_DEAUTH:
4583 at76_rx_mgmt_deauth(priv, buf);
4584 break;
4585
1910 default: 4586 default:
1911 ret = -EOPNOTSUPP; 4587 printk(KERN_DEBUG "%s: ignoring frame with framectl 0x%04x\n",
1912 goto exit; 4588 priv->netdev->name, framectl);
1913 } 4589 }
1914 4590
1915exit: 4591 return;
1916 mutex_unlock(&priv->mtx);
1917
1918 return ret;
1919} 4592}
1920 4593
1921static void at76_remove_interface(struct ieee80211_hw *hw, 4594/* Convert the 802.11 header into an ethernet-style header, make skb
1922 struct ieee80211_if_init_conf *conf) 4595 * ready for consumption by netif_rx() */
4596static void at76_ieee80211_to_eth(struct sk_buff *skb, int iw_mode)
1923{ 4597{
1924 at76_dbg(DBG_MAC80211, "%s()", __func__); 4598 struct ieee80211_hdr_3addr *i802_11_hdr;
1925} 4599 struct ethhdr *eth_hdr_p;
4600 u8 *src_addr;
4601 u8 *dest_addr;
1926 4602
1927static int at76_join(struct at76_priv *priv) 4603 i802_11_hdr = (struct ieee80211_hdr_3addr *)skb->data;
1928{
1929 struct at76_req_join join;
1930 int ret;
1931 4604
1932 memset(&join, 0, sizeof(struct at76_req_join)); 4605 /* That would be the ethernet header if the hardware converted
1933 memcpy(join.essid, priv->essid, priv->essid_size); 4606 * the frame for us. Make sure the source and the destination
1934 join.essid_size = priv->essid_size; 4607 * match the 802.11 header. Which hardware does it? */
1935 memcpy(join.bssid, priv->bssid, ETH_ALEN); 4608 eth_hdr_p = (struct ethhdr *)skb_pull(skb, IEEE80211_3ADDR_LEN);
1936 join.bss_type = INFRASTRUCTURE_MODE;
1937 join.channel = priv->channel;
1938 join.timeout = cpu_to_le16(2000);
1939 4609
1940 at76_dbg(DBG_MAC80211, "%s: sending CMD_JOIN", __func__); 4610 dest_addr = i802_11_hdr->addr1;
1941 ret = at76_set_card_command(priv->udev, CMD_JOIN, &join, 4611 if (iw_mode == IW_MODE_ADHOC)
1942 sizeof(struct at76_req_join)); 4612 src_addr = i802_11_hdr->addr2;
4613 else
4614 src_addr = i802_11_hdr->addr3;
1943 4615
1944 if (ret < 0) { 4616 if (!compare_ether_addr(eth_hdr_p->h_source, src_addr) &&
1945 printk(KERN_ERR "%s: at76_set_card_command failed: %d\n", 4617 !compare_ether_addr(eth_hdr_p->h_dest, dest_addr))
1946 wiphy_name(priv->hw->wiphy), ret); 4618 /* Yes, we already have an ethernet header */
1947 return 0; 4619 skb_reset_mac_header(skb);
1948 } 4620 else {
4621 u16 len;
4622
4623 /* Need to build an ethernet header */
4624 if (!memcmp(skb->data, snapsig, sizeof(snapsig))) {
4625 /* SNAP frame - decapsulate, keep proto */
4626 skb_push(skb, offsetof(struct ethhdr, h_proto) -
4627 sizeof(rfc1042sig));
4628 len = 0;
4629 } else {
4630 /* 802.3 frame, proto is length */
4631 len = skb->len;
4632 skb_push(skb, ETH_HLEN);
4633 }
1949 4634
1950 ret = at76_wait_completion(priv, CMD_JOIN); 4635 skb_reset_mac_header(skb);
1951 at76_dbg(DBG_MAC80211, "%s: CMD_JOIN returned: 0x%02x", __func__, ret); 4636 eth_hdr_p = eth_hdr(skb);
1952 if (ret != CMD_STATUS_COMPLETE) { 4637 /* This needs to be done in this order (eth_hdr_p->h_dest may
1953 printk(KERN_ERR "%s: at76_wait_completion failed: %d\n", 4638 * overlap src_addr) */
1954 wiphy_name(priv->hw->wiphy), ret); 4639 memcpy(eth_hdr_p->h_source, src_addr, ETH_ALEN);
1955 return 0; 4640 memcpy(eth_hdr_p->h_dest, dest_addr, ETH_ALEN);
4641 if (len)
4642 eth_hdr_p->h_proto = htons(len);
1956 } 4643 }
1957 4644
1958 at76_set_tkip_bssid(priv, priv->bssid); 4645 skb->protocol = eth_type_trans(skb, skb->dev);
1959 at76_set_pm_mode(priv);
1960
1961 return 0;
1962} 4646}
1963 4647
1964static void at76_dwork_hw_scan(struct work_struct *work) 4648/* Check for fragmented data in priv->rx_skb. If the packet was no fragment
4649 or it was the last of a fragment set a skb containing the whole packet
4650 is returned for further processing. Otherwise we get NULL and are
4651 done and the packet is either stored inside the fragment buffer
4652 or thrown away. Every returned skb starts with the ieee802_11 header
4653 and contains _no_ FCS at the end */
4654static struct sk_buff *at76_check_for_rx_frags(struct at76_priv *priv)
1965{ 4655{
1966 struct at76_priv *priv = container_of(work, struct at76_priv, 4656 struct sk_buff *skb = priv->rx_skb;
1967 dwork_hw_scan.work); 4657 struct at76_rx_buffer *buf = (struct at76_rx_buffer *)skb->data;
1968 int ret; 4658 struct ieee80211_hdr_3addr *i802_11_hdr =
4659 (struct ieee80211_hdr_3addr *)buf->packet;
4660 /* seq_ctrl, fragment_number, sequence number of new packet */
4661 u16 sctl = le16_to_cpu(i802_11_hdr->seq_ctl);
4662 u16 fragnr = sctl & 0xf;
4663 u16 seqnr = sctl >> 4;
4664 u16 frame_ctl = le16_to_cpu(i802_11_hdr->frame_ctl);
1969 4665
1970 ret = at76_get_cmd_status(priv->udev, CMD_SCAN); 4666 /* Length including the IEEE802.11 header, but without the trailing
1971 at76_dbg(DBG_MAC80211, "%s: CMD_SCAN status 0x%02x", __func__, ret); 4667 * FCS and without the Atmel Rx header */
4668 int length = le16_to_cpu(buf->wlength) - IEEE80211_FCS_LEN;
1972 4669
1973 /* FIXME: add maximum time for scan to complete */ 4670 /* where does the data payload start in skb->data ? */
4671 u8 *data = i802_11_hdr->payload;
1974 4672
1975 if (ret != CMD_STATUS_COMPLETE) { 4673 /* length of payload, excl. the trailing FCS */
1976 queue_delayed_work(priv->hw->workqueue, &priv->dwork_hw_scan, 4674 int data_len = length - IEEE80211_3ADDR_LEN;
1977 SCAN_POLL_INTERVAL); 4675
1978 goto exit; 4676 int i;
4677 struct rx_data_buf *bptr, *optr;
4678 unsigned long oldest = ~0UL;
4679
4680 at76_dbg(DBG_RX_FRAGS,
4681 "%s: rx data frame_ctl %04x addr2 %s seq/frag %d/%d "
4682 "length %d data %d: %s ...", priv->netdev->name, frame_ctl,
4683 mac2str(i802_11_hdr->addr2), seqnr, fragnr, length, data_len,
4684 hex2str(data, 32));
4685
4686 at76_dbg(DBG_RX_FRAGS_SKB, "%s: incoming skb: head %p data %p "
4687 "tail %p end %p len %d", priv->netdev->name, skb->head,
4688 skb->data, skb_tail_pointer(skb), skb_end_pointer(skb),
4689 skb->len);
4690
4691 if (data_len < 0) {
4692 /* make sure data starts in the buffer */
4693 printk(KERN_INFO "%s: data frame too short\n",
4694 priv->netdev->name);
4695 return NULL;
1979 } 4696 }
1980 4697
1981 ieee80211_scan_completed(priv->hw); 4698 WARN_ON(length <= AT76_RX_HDRLEN);
4699 if (length <= AT76_RX_HDRLEN)
4700 return NULL;
1982 4701
1983 if (is_valid_ether_addr(priv->bssid)) { 4702 /* remove the at76_rx_buffer header - we don't need it anymore */
1984 ieee80211_wake_queues(priv->hw); 4703 /* we need the IEEE802.11 header (for the addresses) if this packet
1985 at76_join(priv); 4704 is the first of a chain */
4705 skb_pull(skb, AT76_RX_HDRLEN);
4706
4707 /* remove FCS at end */
4708 skb_trim(skb, length);
4709
4710 at76_dbg(DBG_RX_FRAGS_SKB, "%s: trimmed skb: head %p data %p tail %p "
4711 "end %p len %d data %p data_len %d", priv->netdev->name,
4712 skb->head, skb->data, skb_tail_pointer(skb),
4713 skb_end_pointer(skb), skb->len, data, data_len);
4714
4715 if (fragnr == 0 && !(frame_ctl & IEEE80211_FCTL_MOREFRAGS)) {
4716 /* unfragmented packet received */
4717 /* Use a new skb for the next receive */
4718 priv->rx_skb = NULL;
4719 at76_dbg(DBG_RX_FRAGS, "%s: unfragmented", priv->netdev->name);
4720 return skb;
1986 } 4721 }
1987 4722
1988 ieee80211_wake_queues(priv->hw); 4723 /* look if we've got a chain for the sender address.
4724 afterwards optr points to first free or the oldest entry,
4725 or, if i < NR_RX_DATA_BUF, bptr points to the entry for the
4726 sender address */
4727 /* determining the oldest entry doesn't cope with jiffies wrapping
4728 but I don't care to delete a young entry at these rare moments ... */
4729
4730 bptr = priv->rx_data;
4731 optr = NULL;
4732 for (i = 0; i < NR_RX_DATA_BUF; i++, bptr++) {
4733 if (!bptr->skb) {
4734 optr = bptr;
4735 oldest = 0UL;
4736 continue;
4737 }
1989 4738
1990exit: 4739 if (!compare_ether_addr(i802_11_hdr->addr2, bptr->sender))
1991 return; 4740 break;
1992}
1993 4741
1994static int at76_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) 4742 if (!optr) {
1995{ 4743 optr = bptr;
1996 struct at76_priv *priv = hw->priv; 4744 oldest = bptr->last_rx;
1997 struct at76_req_scan scan; 4745 } else if (bptr->last_rx < oldest)
1998 int ret; 4746 optr = bptr;
4747 }
1999 4748
2000 at76_dbg(DBG_MAC80211, "%s():", __func__); 4749 if (i < NR_RX_DATA_BUF) {
2001 at76_dbg_dump(DBG_MAC80211, ssid, len, "ssid %zd bytes:", len); 4750
4751 at76_dbg(DBG_RX_FRAGS, "%s: %d. cacheentry (seq/frag = %d/%d) "
4752 "matched sender addr",
4753 priv->netdev->name, i, bptr->seqnr, bptr->fragnr);
4754
4755 /* bptr points to an entry for the sender address */
4756 if (bptr->seqnr == seqnr) {
4757 int left;
4758 /* the fragment has the current sequence number */
4759 if (((bptr->fragnr + 1) & 0xf) != fragnr) {
4760 /* wrong fragment number -> ignore it */
4761 /* is & 0xf necessary above ??? */
4762 at76_dbg(DBG_RX_FRAGS,
4763 "%s: frag nr mismatch: %d + 1 != %d",
4764 priv->netdev->name, bptr->fragnr,
4765 fragnr);
4766 return NULL;
4767 }
4768 bptr->last_rx = jiffies;
4769 /* the next following fragment number ->
4770 add the data at the end */
4771
4772 /* for test only ??? */
4773 left = skb_tailroom(bptr->skb);
4774 if (left < data_len)
4775 printk(KERN_INFO
4776 "%s: only %d byte free (need %d)\n",
4777 priv->netdev->name, left, data_len);
4778 else
4779 memcpy(skb_put(bptr->skb, data_len), data,
4780 data_len);
4781
4782 bptr->fragnr = fragnr;
4783 if (frame_ctl & IEEE80211_FCTL_MOREFRAGS)
4784 return NULL;
4785
4786 /* this was the last fragment - send it */
4787 skb = bptr->skb;
4788 bptr->skb = NULL; /* free the entry */
4789 at76_dbg(DBG_RX_FRAGS, "%s: last frag of seq %d",
4790 priv->netdev->name, seqnr);
4791 return skb;
4792 }
2002 4793
2003 mutex_lock(&priv->mtx); 4794 /* got another sequence number */
4795 if (fragnr == 0) {
4796 /* it's the start of a new chain - replace the
4797 old one by this */
4798 /* bptr->sender has the correct value already */
4799 at76_dbg(DBG_RX_FRAGS,
4800 "%s: start of new seq %d, removing old seq %d",
4801 priv->netdev->name, seqnr, bptr->seqnr);
4802 bptr->seqnr = seqnr;
4803 bptr->fragnr = 0;
4804 bptr->last_rx = jiffies;
4805 /* swap bptr->skb and priv->rx_skb */
4806 skb = bptr->skb;
4807 bptr->skb = priv->rx_skb;
4808 priv->rx_skb = skb;
4809 } else {
4810 /* it from the middle of a new chain ->
4811 delete the old entry and skip the new one */
4812 at76_dbg(DBG_RX_FRAGS,
4813 "%s: middle of new seq %d (%d) "
4814 "removing old seq %d",
4815 priv->netdev->name, seqnr, fragnr,
4816 bptr->seqnr);
4817 dev_kfree_skb(bptr->skb);
4818 bptr->skb = NULL;
4819 }
4820 return NULL;
4821 }
2004 4822
2005 ieee80211_stop_queues(hw); 4823 /* if we didn't find a chain for the sender address, optr
4824 points either to the first free or the oldest entry */
2006 4825
2007 memset(&scan, 0, sizeof(struct at76_req_scan)); 4826 if (fragnr != 0) {
2008 memset(scan.bssid, 0xFF, ETH_ALEN); 4827 /* this is not the begin of a fragment chain ... */
2009 scan.scan_type = SCAN_TYPE_ACTIVE; 4828 at76_dbg(DBG_RX_FRAGS,
2010 if (priv->essid_size > 0) { 4829 "%s: no chain for non-first fragment (%d)",
2011 memcpy(scan.essid, ssid, len); 4830 priv->netdev->name, fragnr);
2012 scan.essid_size = len; 4831 return NULL;
2013 } 4832 }
2014 scan.min_channel_time = cpu_to_le16(priv->scan_min_time);
2015 scan.max_channel_time = cpu_to_le16(priv->scan_max_time);
2016 scan.probe_delay = cpu_to_le16(priv->scan_min_time * 1000);
2017 scan.international_scan = 0;
2018 4833
2019 at76_dbg(DBG_MAC80211, "%s: sending CMD_SCAN", __func__); 4834 BUG_ON(!optr);
2020 ret = at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan)); 4835 if (optr->skb) {
4836 /* swap the skb's */
4837 skb = optr->skb;
4838 optr->skb = priv->rx_skb;
4839 priv->rx_skb = skb;
2021 4840
2022 if (ret < 0) { 4841 at76_dbg(DBG_RX_FRAGS,
2023 err("CMD_SCAN failed: %d", ret); 4842 "%s: free old contents: sender %s seq/frag %d/%d",
2024 goto exit; 4843 priv->netdev->name, mac2str(optr->sender),
2025 } 4844 optr->seqnr, optr->fragnr);
2026 4845
2027 queue_delayed_work(priv->hw->workqueue, &priv->dwork_hw_scan, 4846 } else {
2028 SCAN_POLL_INTERVAL); 4847 /* take the skb from priv->rx_skb */
4848 optr->skb = priv->rx_skb;
4849 /* let at76_submit_rx_urb() allocate a new skb */
4850 priv->rx_skb = NULL;
2029 4851
2030exit: 4852 at76_dbg(DBG_RX_FRAGS, "%s: use a free entry",
2031 mutex_unlock(&priv->mtx); 4853 priv->netdev->name);
4854 }
4855 memcpy(optr->sender, i802_11_hdr->addr2, ETH_ALEN);
4856 optr->seqnr = seqnr;
4857 optr->fragnr = 0;
4858 optr->last_rx = jiffies;
2032 4859
2033 return 0; 4860 return NULL;
2034} 4861}
2035 4862
2036static int at76_config(struct ieee80211_hw *hw, u32 changed) 4863/* Rx interrupt: we expect the complete data buffer in priv->rx_skb */
4864static void at76_rx_data(struct at76_priv *priv)
2037{ 4865{
2038 struct at76_priv *priv = hw->priv; 4866 struct net_device *netdev = priv->netdev;
2039 struct ieee80211_conf *conf = &hw->conf; 4867 struct net_device_stats *stats = &priv->stats;
4868 struct sk_buff *skb = priv->rx_skb;
4869 struct at76_rx_buffer *buf = (struct at76_rx_buffer *)skb->data;
4870 struct ieee80211_hdr_3addr *i802_11_hdr;
4871 int length = le16_to_cpu(buf->wlength);
2040 4872
2041 at76_dbg(DBG_MAC80211, "%s(): channel %d radio %d", 4873 at76_dbg(DBG_RX_DATA, "%s received data packet: %s", netdev->name,
2042 __func__, conf->channel->hw_value, conf->radio_enabled); 4874 hex2str(skb->data, AT76_RX_HDRLEN));
2043 at76_dbg_dump(DBG_MAC80211, priv->essid, priv->essid_size, "ssid:");
2044 at76_dbg_dump(DBG_MAC80211, priv->bssid, ETH_ALEN, "bssid:");
2045 4875
2046 mutex_lock(&priv->mtx); 4876 at76_dbg(DBG_RX_DATA_CONTENT, "rx packet: %s",
4877 hex2str(skb->data + AT76_RX_HDRLEN, length));
2047 4878
2048 priv->channel = conf->channel->hw_value; 4879 skb = at76_check_for_rx_frags(priv);
4880 if (!skb)
4881 return;
2049 4882
2050 if (is_valid_ether_addr(priv->bssid)) { 4883 /* Atmel header and the FCS are already removed */
2051 at76_join(priv); 4884 i802_11_hdr = (struct ieee80211_hdr_3addr *)skb->data;
2052 ieee80211_wake_queues(priv->hw);
2053 } else {
2054 ieee80211_stop_queues(priv->hw);
2055 at76_start_monitor(priv);
2056 };
2057 4885
2058 mutex_unlock(&priv->mtx); 4886 skb->dev = netdev;
4887 skb->ip_summed = CHECKSUM_NONE; /* TODO: should check CRC */
2059 4888
2060 return 0; 4889 if (is_broadcast_ether_addr(i802_11_hdr->addr1)) {
2061} 4890 if (!compare_ether_addr(i802_11_hdr->addr1, netdev->broadcast))
4891 skb->pkt_type = PACKET_BROADCAST;
4892 else
4893 skb->pkt_type = PACKET_MULTICAST;
4894 } else if (compare_ether_addr(i802_11_hdr->addr1, netdev->dev_addr))
4895 skb->pkt_type = PACKET_OTHERHOST;
2062 4896
2063static int at76_config_interface(struct ieee80211_hw *hw, 4897 at76_ieee80211_to_eth(skb, priv->iw_mode);
2064 struct ieee80211_vif *vif,
2065 struct ieee80211_if_conf *conf)
2066{
2067 struct at76_priv *priv = hw->priv;
2068 4898
2069 at76_dbg_dump(DBG_MAC80211, conf->bssid, ETH_ALEN, "bssid:"); 4899 netdev->last_rx = jiffies;
4900 netif_rx(skb);
4901 stats->rx_packets++;
4902 stats->rx_bytes += length;
2070 4903
2071 mutex_lock(&priv->mtx); 4904 return;
4905}
2072 4906
2073 memcpy(priv->bssid, conf->bssid, ETH_ALEN); 4907static void at76_rx_monitor_mode(struct at76_priv *priv)
2074// memcpy(priv->essid, conf->ssid, conf->ssid_len); 4908{
2075// priv->essid_size = conf->ssid_len; 4909 struct at76_rx_radiotap *rt;
4910 u8 *payload;
4911 int skblen;
4912 struct net_device *netdev = priv->netdev;
4913 struct at76_rx_buffer *buf =
4914 (struct at76_rx_buffer *)priv->rx_skb->data;
4915 /* length including the IEEE802.11 header and the trailing FCS,
4916 but not at76_rx_buffer */
4917 int length = le16_to_cpu(buf->wlength);
4918 struct sk_buff *skb = priv->rx_skb;
4919 struct net_device_stats *stats = &priv->stats;
2076 4920
2077 if (is_valid_ether_addr(priv->bssid)) { 4921 if (length < IEEE80211_FCS_LEN) {
2078 /* mac80211 is joining a bss */ 4922 /* buffer contains no data */
2079 ieee80211_wake_queues(priv->hw); 4923 at76_dbg(DBG_MONITOR_MODE,
2080 at76_join(priv); 4924 "%s: MONITOR MODE: rx skb without data",
2081 } else 4925 priv->netdev->name);
2082 ieee80211_stop_queues(priv->hw); 4926 return;
4927 }
2083 4928
2084 mutex_unlock(&priv->mtx); 4929 skblen = sizeof(struct at76_rx_radiotap) + length;
2085 4930
2086 return 0; 4931 skb = dev_alloc_skb(skblen);
4932 if (!skb) {
4933 printk(KERN_ERR "%s: MONITOR MODE: dev_alloc_skb for radiotap "
4934 "header returned NULL\n", priv->netdev->name);
4935 return;
4936 }
4937
4938 skb_put(skb, skblen);
4939
4940 rt = (struct at76_rx_radiotap *)skb->data;
4941 payload = skb->data + sizeof(struct at76_rx_radiotap);
4942
4943 rt->rt_hdr.it_version = 0;
4944 rt->rt_hdr.it_pad = 0;
4945 rt->rt_hdr.it_len = cpu_to_le16(sizeof(struct at76_rx_radiotap));
4946 rt->rt_hdr.it_present = cpu_to_le32(AT76_RX_RADIOTAP_PRESENT);
4947
4948 rt->rt_tsft = cpu_to_le64(le32_to_cpu(buf->rx_time));
4949 rt->rt_rate = hw_rates[buf->rx_rate] & (~0x80);
4950 rt->rt_signal = buf->rssi;
4951 rt->rt_noise = buf->noise_level;
4952 rt->rt_flags = IEEE80211_RADIOTAP_F_FCS;
4953 if (buf->fragmentation)
4954 rt->rt_flags |= IEEE80211_RADIOTAP_F_FRAG;
4955
4956 memcpy(payload, buf->packet, length);
4957 skb->dev = netdev;
4958 skb->ip_summed = CHECKSUM_NONE;
4959 skb_reset_mac_header(skb);
4960 skb->pkt_type = PACKET_OTHERHOST;
4961 skb->protocol = htons(ETH_P_802_2);
4962
4963 netdev->last_rx = jiffies;
4964 netif_rx(skb);
4965 stats->rx_packets++;
4966 stats->rx_bytes += length;
2087} 4967}
2088 4968
2089/* must be atomic */ 4969/* Check if we spy on the sender address in buf and update stats */
2090static void at76_configure_filter(struct ieee80211_hw *hw, 4970static void at76_iwspy_update(struct at76_priv *priv,
2091 unsigned int changed_flags, 4971 struct at76_rx_buffer *buf)
2092 unsigned int *total_flags, int mc_count,
2093 struct dev_addr_list *mc_list)
2094{ 4972{
2095 struct at76_priv *priv = hw->priv; 4973 struct ieee80211_hdr_3addr *hdr =
2096 int flags; 4974 (struct ieee80211_hdr_3addr *)buf->packet;
2097 4975 struct iw_quality qual;
2098 at76_dbg(DBG_MAC80211, "%s(): changed_flags=0x%08x "
2099 "total_flags=0x%08x mc_count=%d",
2100 __func__, changed_flags, *total_flags, mc_count);
2101 4976
2102 flags = changed_flags & AT76_SUPPORTED_FILTERS; 4977 /* We can only set the level here */
2103 *total_flags = AT76_SUPPORTED_FILTERS; 4978 qual.updated = IW_QUAL_QUAL_INVALID | IW_QUAL_NOISE_INVALID;
4979 qual.level = 0;
4980 qual.noise = 0;
4981 at76_calc_level(priv, buf, &qual);
2104 4982
2105 /* FIXME: access to priv->promisc should be protected with 4983 spin_lock_bh(&priv->spy_spinlock);
2106 * priv->mtx, but it's impossible because this function needs to be
2107 * atomic */
2108 4984
2109 if (flags && !priv->promisc) { 4985 if (priv->spy_data.spy_number > 0)
2110 /* mac80211 wants us to enable promiscuous mode */ 4986 wireless_spy_update(priv->netdev, hdr->addr2, &qual);
2111 priv->promisc = 1;
2112 } else if (!flags && priv->promisc) {
2113 /* we need to disable promiscuous mode */
2114 priv->promisc = 0;
2115 } else
2116 return;
2117 4987
2118 queue_work(hw->workqueue, &priv->work_set_promisc); 4988 spin_unlock_bh(&priv->spy_spinlock);
2119} 4989}
2120 4990
2121static int at76_set_key_oldfw(struct ieee80211_hw *hw, enum set_key_cmd cmd, 4991static void at76_rx_tasklet(unsigned long param)
2122 const u8 *local_address, const u8 *address,
2123 struct ieee80211_key_conf *key)
2124{ 4992{
2125 struct at76_priv *priv = hw->priv; 4993 struct urb *urb = (struct urb *)param;
2126 4994 struct at76_priv *priv = urb->context;
2127 int i; 4995 struct net_device *netdev = priv->netdev;
2128 4996 struct at76_rx_buffer *buf;
2129 at76_dbg(DBG_MAC80211, "%s(): cmd %d key->alg %d key->keyidx %d " 4997 struct ieee80211_hdr_3addr *i802_11_hdr;
2130 "key->keylen %d", 4998 u16 frame_ctl;
2131 __func__, cmd, key->alg, key->keyidx, key->keylen);
2132 4999
2133 if (key->alg != ALG_WEP) 5000 if (priv->device_unplugged) {
2134 return -EOPNOTSUPP; 5001 at76_dbg(DBG_DEVSTART, "device unplugged");
5002 if (urb)
5003 at76_dbg(DBG_DEVSTART, "urb status %d", urb->status);
5004 return;
5005 }
2135 5006
2136 key->hw_key_idx = key->keyidx; 5007 if (!priv->rx_skb || !netdev || !priv->rx_skb->data)
5008 return;
2137 5009
2138 mutex_lock(&priv->mtx); 5010 buf = (struct at76_rx_buffer *)priv->rx_skb->data;
2139 5011
2140 switch (cmd) { 5012 i802_11_hdr = (struct ieee80211_hdr_3addr *)buf->packet;
2141 case SET_KEY:
2142 memcpy(priv->wep_keys[key->keyidx], key->key, key->keylen);
2143 priv->wep_keys_len[key->keyidx] = key->keylen;
2144 5013
2145 /* FIXME: find out how to do this properly */ 5014 frame_ctl = le16_to_cpu(i802_11_hdr->frame_ctl);
2146 priv->wep_key_id = key->keyidx;
2147 5015
2148 break; 5016 if (urb->status != 0) {
2149 case DISABLE_KEY: 5017 if (urb->status != -ENOENT && urb->status != -ECONNRESET)
2150 default: 5018 at76_dbg(DBG_URB,
2151 priv->wep_keys_len[key->keyidx] = 0; 5019 "%s %s: - nonzero Rx bulk status received: %d",
2152 break; 5020 __func__, netdev->name, urb->status);
5021 return;
2153 } 5022 }
2154 5023
2155 priv->wep_enabled = 0; 5024 at76_dbg(DBG_RX_ATMEL_HDR,
5025 "%s: rx frame: rate %d rssi %d noise %d link %d %s",
5026 priv->netdev->name, buf->rx_rate, buf->rssi, buf->noise_level,
5027 buf->link_quality, hex2str(i802_11_hdr, 48));
5028 if (priv->iw_mode == IW_MODE_MONITOR) {
5029 at76_rx_monitor_mode(priv);
5030 goto exit;
5031 }
2156 5032
2157 for (i = 0; i < WEP_KEYS; i++) { 5033 /* there is a new bssid around, accept it: */
2158 if (priv->wep_keys_len[i] != 0) 5034 if (buf->newbss && priv->iw_mode == IW_MODE_ADHOC) {
2159 priv->wep_enabled = 1; 5035 at76_dbg(DBG_PROGRESS, "%s: rx newbss", netdev->name);
5036 schedule_work(&priv->work_new_bss);
2160 } 5037 }
2161 5038
2162 at76_startup_device(priv); 5039 switch (frame_ctl & IEEE80211_FCTL_FTYPE) {
5040 case IEEE80211_FTYPE_DATA:
5041 at76_rx_data(priv);
5042 break;
2163 5043
2164 mutex_unlock(&priv->mtx); 5044 case IEEE80211_FTYPE_MGMT:
5045 /* jal: TODO: find out if we can update iwspy also on
5046 other frames than management (might depend on the
5047 radio chip / firmware version !) */
2165 5048
2166 return 0; 5049 at76_iwspy_update(priv, buf);
2167}
2168 5050
2169static int at76_set_key_newfw(struct ieee80211_hw *hw, enum set_key_cmd cmd, 5051 at76_rx_mgmt(priv, buf);
2170 const u8 *local_address, const u8 *address, 5052 break;
2171 struct ieee80211_key_conf *key)
2172{
2173 struct at76_priv *priv = hw->priv;
2174 int ret = -EOPNOTSUPP;
2175
2176 at76_dbg(DBG_MAC80211, "%s(): cmd %d key->alg %d key->keyidx %d "
2177 "key->keylen %d",
2178 __func__, cmd, key->alg, key->keyidx, key->keylen);
2179 5053
2180 mutex_lock(&priv->mtx); 5054 case IEEE80211_FTYPE_CTL:
5055 at76_dbg(DBG_RX_CTRL, "%s: ignored ctrl frame: %04x",
5056 priv->netdev->name, frame_ctl);
5057 break;
2181 5058
2182 priv->mib_buf.type = MIB_MAC_ENCRYPTION; 5059 default:
5060 printk(KERN_DEBUG "%s: ignoring frame with framectl 0x%04x\n",
5061 priv->netdev->name, frame_ctl);
5062 }
5063exit:
5064 at76_submit_rx_urb(priv);
5065}
2183 5066
2184 if (cmd == DISABLE_KEY) { 5067/* Load firmware into kernel memory and parse it */
2185 priv->mib_buf.size = CIPHER_KEY_LEN; 5068static struct fwentry *at76_load_firmware(struct usb_device *udev,
2186 priv->mib_buf.index = offsetof(struct mib_mac_encryption, 5069 enum board_type board_type)
2187 cipher_default_keyvalue[key->keyidx]); 5070{
2188 memset(priv->mib_buf.data.data, 0, CIPHER_KEY_LEN); 5071 int ret;
2189 if (at76_set_mib(priv, &priv->mib_buf) != CMD_STATUS_COMPLETE) 5072 char *str;
2190 ret = -EOPNOTSUPP; /* -EIO would be probably better */ 5073 struct at76_fw_header *fwh;
2191 else { 5074 struct fwentry *fwe = &firmwares[board_type];
2192 5075
2193 priv->keys[key->keyidx].cipher = CIPHER_NONE; 5076 mutex_lock(&fw_mutex);
2194 priv->keys[key->keyidx].keylen = 0;
2195 };
2196 if (priv->default_group_key == key->keyidx)
2197 priv->default_group_key = 0xff;
2198 5077
2199 if (priv->default_pairwise_key == key->keyidx) 5078 if (fwe->loaded) {
2200 priv->default_pairwise_key = 0xff; 5079 at76_dbg(DBG_FW, "re-using previously loaded fw");
2201 /* If default pairwise key is removed, fall back to
2202 * group key? */
2203 ret = 0;
2204 goto exit; 5080 goto exit;
2205 }; 5081 }
2206
2207 if (cmd == SET_KEY) {
2208 /* store key into MIB */
2209 priv->mib_buf.size = CIPHER_KEY_LEN;
2210 priv->mib_buf.index = offsetof(struct mib_mac_encryption,
2211 cipher_default_keyvalue[key->keyidx]);
2212 memset(priv->mib_buf.data.data, 0, CIPHER_KEY_LEN);
2213 memcpy(priv->mib_buf.data.data, key->key, key->keylen);
2214
2215 switch (key->alg) {
2216 case ALG_WEP:
2217 if (key->keylen == 5) {
2218 priv->keys[key->keyidx].cipher =
2219 CIPHER_WEP64;
2220 priv->keys[key->keyidx].keylen = 8;
2221 } else if (key->keylen == 13) {
2222 priv->keys[key->keyidx].cipher =
2223 CIPHER_WEP128;
2224 /* Firmware needs this */
2225 priv->keys[key->keyidx].keylen = 8;
2226 } else {
2227 ret = -EOPNOTSUPP;
2228 goto exit;
2229 };
2230 break;
2231 case ALG_TKIP:
2232 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC;
2233 priv->keys[key->keyidx].cipher = CIPHER_TKIP;
2234 priv->keys[key->keyidx].keylen = 12;
2235 break;
2236 5082
2237 case ALG_CCMP: 5083 at76_dbg(DBG_FW, "downloading firmware %s", fwe->fwname);
2238 if (!at76_is_505a(priv->board_type)) { 5084 ret = request_firmware(&fwe->fw, fwe->fwname, &udev->dev);
2239 ret = -EOPNOTSUPP; 5085 if (ret < 0) {
2240 goto exit; 5086 dev_printk(KERN_ERR, &udev->dev, "firmware %s not found!\n",
2241 }; 5087 fwe->fwname);
2242 key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; 5088 dev_printk(KERN_ERR, &udev->dev,
2243 priv->keys[key->keyidx].cipher = CIPHER_CCMP; 5089 "you may need to download the firmware from "
2244 priv->keys[key->keyidx].keylen = 16; 5090 "http://developer.berlios.de/projects/at76c503a/");
2245 break; 5091 goto exit;
5092 }
2246 5093
2247 default: 5094 at76_dbg(DBG_FW, "got it.");
2248 ret = -EOPNOTSUPP; 5095 fwh = (struct at76_fw_header *)(fwe->fw->data);
2249 goto exit;
2250 };
2251
2252 priv->mib_buf.data.data[38] = priv->keys[key->keyidx].cipher;
2253 priv->mib_buf.data.data[39] = 1; /* Taken from atmelwlandriver,
2254 not documented */
2255
2256 if (is_valid_ether_addr(address))
2257 /* Pairwise key */
2258 priv->mib_buf.data.data[39] |= (KEY_PAIRWISE | KEY_TX);
2259 else if (is_broadcast_ether_addr(address))
2260 /* Group key */
2261 priv->mib_buf.data.data[39] |= (KEY_TX);
2262 else /* Key used only for transmission ??? */
2263 priv->mib_buf.data.data[39] |= (KEY_TX);
2264
2265 if (at76_set_mib(priv, &priv->mib_buf) !=
2266 CMD_STATUS_COMPLETE) {
2267 ret = -EOPNOTSUPP; /* -EIO would be probably better */
2268 goto exit;
2269 };
2270 5096
2271 if ((key->alg == ALG_TKIP) || (key->alg == ALG_CCMP)) 5097 if (fwe->fw->size <= sizeof(*fwh)) {
2272 at76_reset_rsc(priv); 5098 dev_printk(KERN_ERR, &udev->dev,
5099 "firmware is too short (0x%zx)\n", fwe->fw->size);
5100 goto exit;
5101 }
2273 5102
2274 key->hw_key_idx = key->keyidx; 5103 /* CRC currently not checked */
5104 fwe->board_type = le32_to_cpu(fwh->board_type);
5105 if (fwe->board_type != board_type) {
5106 dev_printk(KERN_ERR, &udev->dev,
5107 "board type mismatch, requested %u, got %u\n",
5108 board_type, fwe->board_type);
5109 goto exit;
5110 }
2275 5111
2276 /* Set up default keys */ 5112 fwe->fw_version.major = fwh->major;
2277 if (is_broadcast_ether_addr(address)) 5113 fwe->fw_version.minor = fwh->minor;
2278 priv->default_group_key = key->keyidx; 5114 fwe->fw_version.patch = fwh->patch;
2279 if (is_valid_ether_addr(address)) 5115 fwe->fw_version.build = fwh->build;
2280 priv->default_pairwise_key = key->keyidx;
2281 5116
2282 /* Set up encryption MIBs */ 5117 str = (char *)fwh + le32_to_cpu(fwh->str_offset);
5118 fwe->intfw = (u8 *)fwh + le32_to_cpu(fwh->int_fw_offset);
5119 fwe->intfw_size = le32_to_cpu(fwh->int_fw_len);
5120 fwe->extfw = (u8 *)fwh + le32_to_cpu(fwh->ext_fw_offset);
5121 fwe->extfw_size = le32_to_cpu(fwh->ext_fw_len);
2283 5122
2284 /* first block of settings */ 5123 fwe->loaded = 1;
2285 priv->mib_buf.size = 3;
2286 priv->mib_buf.index = offsetof(struct mib_mac_encryption,
2287 privacy_invoked);
2288 priv->mib_buf.data.data[0] = 1; /* privacy_invoked */
2289 priv->mib_buf.data.data[1] = priv->default_pairwise_key;
2290 priv->mib_buf.data.data[2] = priv->default_group_key;
2291 5124
2292 ret = at76_set_mib(priv, &priv->mib_buf); 5125 dev_printk(KERN_DEBUG, &udev->dev,
2293 if (ret != CMD_STATUS_COMPLETE) 5126 "using firmware %s (version %d.%d.%d-%d)\n",
2294 goto exit; 5127 fwe->fwname, fwh->major, fwh->minor, fwh->patch, fwh->build);
2295 5128
2296 /* second block of settings */ 5129 at76_dbg(DBG_DEVSTART, "board %u, int %d:%d, ext %d:%d", board_type,
2297 priv->mib_buf.size = 3; 5130 le32_to_cpu(fwh->int_fw_offset), le32_to_cpu(fwh->int_fw_len),
2298 priv->mib_buf.index = offsetof(struct mib_mac_encryption, 5131 le32_to_cpu(fwh->ext_fw_offset), le32_to_cpu(fwh->ext_fw_len));
2299 exclude_unencrypted); 5132 at76_dbg(DBG_DEVSTART, "firmware id %s", str);
2300 priv->mib_buf.data.data[0] = 1; /* exclude_unencrypted */
2301 priv->mib_buf.data.data[1] = 0; /* wep_encryption_type */
2302 priv->mib_buf.data.data[2] = 0; /* ckip_key_permutation */
2303 5133
2304 ret = at76_set_mib(priv, &priv->mib_buf);
2305 if (ret != CMD_STATUS_COMPLETE)
2306 goto exit;
2307 ret = 0;
2308 };
2309exit: 5134exit:
2310 at76_dump_mib_mac_encryption(priv); 5135 mutex_unlock(&fw_mutex);
2311 mutex_unlock(&priv->mtx);
2312 return ret;
2313}
2314
2315static int at76_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2316 const u8 *local_address, const u8 *address,
2317 struct ieee80211_key_conf *key)
2318{
2319 struct at76_priv *priv = hw->priv;
2320
2321 at76_dbg(DBG_MAC80211, "%s(): cmd %d key->alg %d key->keyidx %d "
2322 "key->keylen %d",
2323 __func__, cmd, key->alg, key->keyidx, key->keylen);
2324 5136
2325 if (FIRMWARE_IS_WPA(priv->fw_version)) 5137 if (fwe->loaded)
2326 return at76_set_key_newfw(hw, cmd, local_address, address, key); 5138 return fwe;
2327 else 5139 else
2328 return at76_set_key_oldfw(hw, cmd, local_address, address, key); 5140 return NULL;
2329
2330} 5141}
2331 5142
2332static const struct ieee80211_ops at76_ops = {
2333 .tx = at76_mac80211_tx,
2334 .add_interface = at76_add_interface,
2335 .remove_interface = at76_remove_interface,
2336 .config = at76_config,
2337 .config_interface = at76_config_interface,
2338 .configure_filter = at76_configure_filter,
2339 .start = at76_mac80211_start,
2340 .stop = at76_mac80211_stop,
2341 .hw_scan = at76_hw_scan,
2342 .set_key = at76_set_key,
2343};
2344
2345/* Allocate network device and initialize private data */ 5143/* Allocate network device and initialize private data */
2346static struct at76_priv *at76_alloc_new_device(struct usb_device *udev) 5144static struct at76_priv *at76_alloc_new_device(struct usb_device *udev)
2347{ 5145{
2348 struct ieee80211_hw *hw; 5146 struct net_device *netdev;
2349 struct at76_priv *priv; 5147 struct at76_priv *priv;
5148 int i;
2350 5149
2351 hw = ieee80211_alloc_hw(sizeof(struct at76_priv), &at76_ops); 5150 /* allocate memory for our device state and initialize it */
2352 if (!hw) { 5151 netdev = alloc_etherdev(sizeof(struct at76_priv));
2353 printk(KERN_ERR DRIVER_NAME ": could not register" 5152 if (!netdev) {
2354 " ieee80211_hw\n"); 5153 dev_printk(KERN_ERR, &udev->dev, "out of memory\n");
2355 return NULL; 5154 return NULL;
2356 } 5155 }
2357 5156
2358 priv = hw->priv; 5157 priv = netdev_priv(netdev);
2359 priv->hw = hw;
2360 5158
2361 priv->udev = udev; 5159 priv->udev = udev;
5160 priv->netdev = netdev;
2362 5161
2363 mutex_init(&priv->mtx); 5162 mutex_init(&priv->mtx);
5163 INIT_WORK(&priv->work_assoc_done, at76_work_assoc_done);
5164 INIT_WORK(&priv->work_join, at76_work_join);
5165 INIT_WORK(&priv->work_new_bss, at76_work_new_bss);
5166 INIT_WORK(&priv->work_start_scan, at76_work_start_scan);
2364 INIT_WORK(&priv->work_set_promisc, at76_work_set_promisc); 5167 INIT_WORK(&priv->work_set_promisc, at76_work_set_promisc);
2365 INIT_WORK(&priv->work_submit_rx, at76_work_submit_rx); 5168 INIT_WORK(&priv->work_submit_rx, at76_work_submit_rx);
2366 INIT_DELAYED_WORK(&priv->dwork_hw_scan, at76_dwork_hw_scan); 5169 INIT_DELAYED_WORK(&priv->dwork_restart, at76_dwork_restart);
5170 INIT_DELAYED_WORK(&priv->dwork_get_scan, at76_dwork_get_scan);
5171 INIT_DELAYED_WORK(&priv->dwork_beacon, at76_dwork_beacon);
5172 INIT_DELAYED_WORK(&priv->dwork_auth, at76_dwork_auth);
5173 INIT_DELAYED_WORK(&priv->dwork_assoc, at76_dwork_assoc);
5174
5175 spin_lock_init(&priv->mgmt_spinlock);
5176 priv->next_mgmt_bulk = NULL;
5177 priv->mac_state = MAC_INIT;
5178
5179 /* initialize empty BSS list */
5180 priv->curr_bss = NULL;
5181 INIT_LIST_HEAD(&priv->bss_list);
5182 spin_lock_init(&priv->bss_list_spinlock);
5183
5184 init_timer(&priv->bss_list_timer);
5185 priv->bss_list_timer.data = (unsigned long)priv;
5186 priv->bss_list_timer.function = at76_bss_list_timeout;
5187
5188 spin_lock_init(&priv->spy_spinlock);
5189
5190 /* mark all rx data entries as unused */
5191 for (i = 0; i < NR_RX_DATA_BUF; i++)
5192 priv->rx_data[i].skb = NULL;
2367 5193
2368 priv->rx_tasklet.func = at76_rx_tasklet; 5194 priv->rx_tasklet.func = at76_rx_tasklet;
2369 priv->rx_tasklet.data = 0; 5195 priv->rx_tasklet.data = 0;
@@ -2371,9 +5197,6 @@ static struct at76_priv *at76_alloc_new_device(struct usb_device *udev)
2371 priv->pm_mode = AT76_PM_OFF; 5197 priv->pm_mode = AT76_PM_OFF;
2372 priv->pm_period = 0; 5198 priv->pm_period = 0;
2373 5199
2374 /* unit us */
2375 priv->hw->channel_change_time = 100000;
2376
2377 return priv; 5200 return priv;
2378} 5201}
2379 5202
@@ -2436,42 +5259,11 @@ static int at76_alloc_urbs(struct at76_priv *priv,
2436 return 0; 5259 return 0;
2437} 5260}
2438 5261
2439static struct ieee80211_rate at76_rates[] = {
2440 { .bitrate = 10, .hw_value = TX_RATE_1MBIT, },
2441 { .bitrate = 20, .hw_value = TX_RATE_2MBIT, },
2442 { .bitrate = 55, .hw_value = TX_RATE_5_5MBIT, },
2443 { .bitrate = 110, .hw_value = TX_RATE_11MBIT, },
2444};
2445
2446static struct ieee80211_channel at76_channels[] = {
2447 { .center_freq = 2412, .hw_value = 1 },
2448 { .center_freq = 2417, .hw_value = 2 },
2449 { .center_freq = 2422, .hw_value = 3 },
2450 { .center_freq = 2427, .hw_value = 4 },
2451 { .center_freq = 2432, .hw_value = 5 },
2452 { .center_freq = 2437, .hw_value = 6 },
2453 { .center_freq = 2442, .hw_value = 7 },
2454 { .center_freq = 2447, .hw_value = 8 },
2455 { .center_freq = 2452, .hw_value = 9 },
2456 { .center_freq = 2457, .hw_value = 10 },
2457 { .center_freq = 2462, .hw_value = 11 },
2458 { .center_freq = 2467, .hw_value = 12 },
2459 { .center_freq = 2472, .hw_value = 13 },
2460 { .center_freq = 2484, .hw_value = 14 }
2461};
2462
2463static struct ieee80211_supported_band at76_supported_band = {
2464 .channels = at76_channels,
2465 .n_channels = ARRAY_SIZE(at76_channels),
2466 .bitrates = at76_rates,
2467 .n_bitrates = ARRAY_SIZE(at76_rates),
2468};
2469
2470/* Register network device and initialize the hardware */ 5262/* Register network device and initialize the hardware */
2471static int at76_init_new_device(struct at76_priv *priv, 5263static int at76_init_new_device(struct at76_priv *priv,
2472 struct usb_interface *interface) 5264 struct usb_interface *interface)
2473{ 5265{
2474 struct device *dev = &interface->dev; 5266 struct net_device *netdev = priv->netdev;
2475 int ret; 5267 int ret;
2476 5268
2477 /* set up the endpoint information */ 5269 /* set up the endpoint information */
@@ -2487,11 +5279,14 @@ static int at76_init_new_device(struct at76_priv *priv,
2487 /* MAC address */ 5279 /* MAC address */
2488 ret = at76_get_hw_config(priv); 5280 ret = at76_get_hw_config(priv);
2489 if (ret < 0) { 5281 if (ret < 0) {
2490 dev_err(dev, "cannot get MAC address\n"); 5282 dev_printk(KERN_ERR, &interface->dev,
5283 "cannot get MAC address\n");
2491 goto exit; 5284 goto exit;
2492 } 5285 }
2493 5286
2494 priv->domain = at76_get_reg_domain(priv->regulatory_domain); 5287 priv->domain = at76_get_reg_domain(priv->regulatory_domain);
5288 /* init. netdev->dev_addr */
5289 memcpy(netdev->dev_addr, priv->mac_addr, ETH_ALEN);
2495 5290
2496 priv->channel = DEF_CHANNEL; 5291 priv->channel = DEF_CHANNEL;
2497 priv->iw_mode = IW_MODE_INFRA; 5292 priv->iw_mode = IW_MODE_INFRA;
@@ -2501,54 +5296,47 @@ static int at76_init_new_device(struct at76_priv *priv,
2501 priv->txrate = TX_RATE_AUTO; 5296 priv->txrate = TX_RATE_AUTO;
2502 priv->preamble_type = PREAMBLE_TYPE_LONG; 5297 priv->preamble_type = PREAMBLE_TYPE_LONG;
2503 priv->beacon_period = 100; 5298 priv->beacon_period = 100;
5299 priv->beacons_last_qual = jiffies;
2504 priv->auth_mode = WLAN_AUTH_OPEN; 5300 priv->auth_mode = WLAN_AUTH_OPEN;
2505 priv->scan_min_time = DEF_SCAN_MIN_TIME; 5301 priv->scan_min_time = DEF_SCAN_MIN_TIME;
2506 priv->scan_max_time = DEF_SCAN_MAX_TIME; 5302 priv->scan_max_time = DEF_SCAN_MAX_TIME;
2507 priv->scan_mode = SCAN_TYPE_ACTIVE; 5303 priv->scan_mode = SCAN_TYPE_ACTIVE;
2508 priv->default_pairwise_key = 0xff;
2509 priv->default_group_key = 0xff;
2510
2511 /* mac80211 initialisation */
2512 priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &at76_supported_band;
2513 5304
2514 if (FIRMWARE_IS_WPA(priv->fw_version) && 5305 netdev->flags &= ~IFF_MULTICAST; /* not yet or never */
2515 (at76_is_503rfmd(priv->board_type) || 5306 netdev->open = at76_open;
2516 at76_is_505(priv->board_type))) 5307 netdev->stop = at76_stop;
2517 priv->hw->flags = IEEE80211_HW_SIGNAL_UNSPEC; 5308 netdev->get_stats = at76_get_stats;
2518 else 5309 netdev->ethtool_ops = &at76_ethtool_ops;
2519 priv->hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 5310
2520 IEEE80211_HW_SIGNAL_UNSPEC; 5311 /* Add pointers to enable iwspy support. */
2521 5312 priv->wireless_data.spy_data = &priv->spy_data;
2522 priv->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 5313 netdev->wireless_data = &priv->wireless_data;
2523 5314
2524 SET_IEEE80211_DEV(priv->hw, &interface->dev); 5315 netdev->hard_start_xmit = at76_tx;
2525 SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); 5316 netdev->tx_timeout = at76_tx_timeout;
2526 5317 netdev->watchdog_timeo = 2 * HZ;
2527 ret = ieee80211_register_hw(priv->hw); 5318 netdev->wireless_handlers = &at76_handler_def;
5319 netdev->set_multicast_list = at76_set_multicast;
5320 netdev->set_mac_address = at76_set_mac_address;
5321 dev_alloc_name(netdev, "wlan%d");
5322
5323 ret = register_netdev(priv->netdev);
2528 if (ret) { 5324 if (ret) {
2529 dev_err(dev, "cannot register mac80211 hw (status %d)!\n", ret); 5325 dev_printk(KERN_ERR, &interface->dev,
5326 "cannot register netdevice (status %d)!\n", ret);
2530 goto exit; 5327 goto exit;
2531 } 5328 }
5329 priv->netdev_registered = 1;
2532 5330
2533 priv->mac80211_registered = 1; 5331 printk(KERN_INFO "%s: USB %s, MAC %s, firmware %d.%d.%d-%d\n",
5332 netdev->name, dev_name(&interface->dev), mac2str(priv->mac_addr),
5333 priv->fw_version.major, priv->fw_version.minor,
5334 priv->fw_version.patch, priv->fw_version.build);
5335 printk(KERN_INFO "%s: regulatory domain 0x%02x: %s\n", netdev->name,
5336 priv->regulatory_domain, priv->domain->name);
2534 5337
2535 dev_info(dev, "%s: USB %s, MAC %s, firmware %d.%d.%d-%d\n", 5338 /* we let this timer run the whole time this driver instance lives */
2536 wiphy_name(priv->hw->wiphy), 5339 mod_timer(&priv->bss_list_timer, jiffies + BSS_LIST_TIMEOUT);
2537 dev_name(&interface->dev), mac2str(priv->mac_addr),
2538 priv->fw_version.major, priv->fw_version.minor,
2539 priv->fw_version.patch, priv->fw_version.build);
2540 dev_info(dev, "%s: regulatory domain 0x%02x: %s\n",
2541 wiphy_name(priv->hw->wiphy),
2542 priv->regulatory_domain, priv->domain->name);
2543 dev_info(dev, "%s: WPA support: ", wiphy_name(priv->hw->wiphy));
2544 if (!FIRMWARE_IS_WPA(priv->fw_version))
2545 printk("none\n");
2546 else {
2547 if (!at76_is_505a(priv->board_type))
2548 printk("TKIP\n");
2549 else
2550 printk("TKIP, AES/CCMP\n");
2551 };
2552 5340
2553exit: 5341exit:
2554 return ret; 5342 return ret;
@@ -2556,13 +5344,15 @@ exit:
2556 5344
2557static void at76_delete_device(struct at76_priv *priv) 5345static void at76_delete_device(struct at76_priv *priv)
2558{ 5346{
5347 int i;
5348
2559 at76_dbg(DBG_PROC_ENTRY, "%s: ENTER", __func__); 5349 at76_dbg(DBG_PROC_ENTRY, "%s: ENTER", __func__);
2560 5350
2561 /* The device is gone, don't bother turning it off */ 5351 /* The device is gone, don't bother turning it off */
2562 priv->device_unplugged = 1; 5352 priv->device_unplugged = 1;
2563 5353
2564 if (priv->mac80211_registered) 5354 if (priv->netdev_registered)
2565 ieee80211_unregister_hw(priv->hw); 5355 unregister_netdev(priv->netdev);
2566 5356
2567 /* assuming we used keventd, it must quiesce too */ 5357 /* assuming we used keventd, it must quiesce too */
2568 flush_scheduled_work(); 5358 flush_scheduled_work();
@@ -2583,11 +5373,25 @@ static void at76_delete_device(struct at76_priv *priv)
2583 if (priv->rx_skb) 5373 if (priv->rx_skb)
2584 kfree_skb(priv->rx_skb); 5374 kfree_skb(priv->rx_skb);
2585 5375
5376 at76_free_bss_list(priv);
5377 del_timer_sync(&priv->bss_list_timer);
5378 cancel_delayed_work(&priv->dwork_get_scan);
5379 cancel_delayed_work(&priv->dwork_beacon);
5380 cancel_delayed_work(&priv->dwork_auth);
5381 cancel_delayed_work(&priv->dwork_assoc);
5382
5383 if (priv->mac_state == MAC_CONNECTED)
5384 at76_iwevent_bss_disconnect(priv->netdev);
5385
5386 for (i = 0; i < NR_RX_DATA_BUF; i++)
5387 if (priv->rx_data[i].skb) {
5388 dev_kfree_skb(priv->rx_data[i].skb);
5389 priv->rx_data[i].skb = NULL;
5390 }
2586 usb_put_dev(priv->udev); 5391 usb_put_dev(priv->udev);
2587 5392
2588 at76_dbg(DBG_PROC_ENTRY, "%s: before freeing priv/ieee80211_hw", 5393 at76_dbg(DBG_PROC_ENTRY, "%s: before freeing priv/netdev", __func__);
2589 __func__); 5394 free_netdev(priv->netdev); /* priv is in netdev */
2590 ieee80211_free_hw(priv->hw);
2591 5395
2592 at76_dbg(DBG_PROC_ENTRY, "%s: EXIT", __func__); 5396 at76_dbg(DBG_PROC_ENTRY, "%s: EXIT", __func__);
2593} 5397}
@@ -2621,8 +5425,8 @@ static int at76_probe(struct usb_interface *interface,
2621 we get 204 with 2.4.23, Fiberline FL-WL240u (505A+RFMD2958) ??? */ 5425 we get 204 with 2.4.23, Fiberline FL-WL240u (505A+RFMD2958) ??? */
2622 5426
2623 if (op_mode == OPMODE_HW_CONFIG_MODE) { 5427 if (op_mode == OPMODE_HW_CONFIG_MODE) {
2624 dev_err(&interface->dev, 5428 dev_printk(KERN_ERR, &interface->dev,
2625 "cannot handle a device in HW_CONFIG_MODE\n"); 5429 "cannot handle a device in HW_CONFIG_MODE\n");
2626 ret = -EBUSY; 5430 ret = -EBUSY;
2627 goto error; 5431 goto error;
2628 } 5432 }
@@ -2630,12 +5434,13 @@ static int at76_probe(struct usb_interface *interface,
2630 if (op_mode != OPMODE_NORMAL_NIC_WITH_FLASH 5434 if (op_mode != OPMODE_NORMAL_NIC_WITH_FLASH
2631 && op_mode != OPMODE_NORMAL_NIC_WITHOUT_FLASH) { 5435 && op_mode != OPMODE_NORMAL_NIC_WITHOUT_FLASH) {
2632 /* download internal firmware part */ 5436 /* download internal firmware part */
2633 dev_dbg(&interface->dev, "downloading internal firmware\n"); 5437 dev_printk(KERN_DEBUG, &interface->dev,
5438 "downloading internal firmware\n");
2634 ret = at76_load_internal_fw(udev, fwe); 5439 ret = at76_load_internal_fw(udev, fwe);
2635 if (ret < 0) { 5440 if (ret < 0) {
2636 dev_err(&interface->dev, 5441 dev_printk(KERN_ERR, &interface->dev,
2637 "error %d downloading internal firmware\n", 5442 "error %d downloading internal firmware\n",
2638 ret); 5443 ret);
2639 goto error; 5444 goto error;
2640 } 5445 }
2641 usb_put_dev(udev); 5446 usb_put_dev(udev);
@@ -2660,7 +5465,8 @@ static int at76_probe(struct usb_interface *interface,
2660 need_ext_fw = 1; 5465 need_ext_fw = 1;
2661 5466
2662 if (need_ext_fw) { 5467 if (need_ext_fw) {
2663 dev_dbg(&interface->dev, "downloading external firmware\n"); 5468 dev_printk(KERN_DEBUG, &interface->dev,
5469 "downloading external firmware\n");
2664 5470
2665 ret = at76_load_external_fw(udev, fwe); 5471 ret = at76_load_external_fw(udev, fwe);
2666 if (ret) 5472 if (ret)
@@ -2669,8 +5475,8 @@ static int at76_probe(struct usb_interface *interface,
2669 /* Re-check firmware version */ 5475 /* Re-check firmware version */
2670 ret = at76_get_mib(udev, MIB_FW_VERSION, &fwv, sizeof(fwv)); 5476 ret = at76_get_mib(udev, MIB_FW_VERSION, &fwv, sizeof(fwv));
2671 if (ret < 0) { 5477 if (ret < 0) {
2672 dev_err(&interface->dev, 5478 dev_printk(KERN_ERR, &interface->dev,
2673 "error %d getting firmware version\n", ret); 5479 "error %d getting firmware version\n", ret);
2674 goto error; 5480 goto error;
2675 } 5481 }
2676 } 5482 }
@@ -2681,6 +5487,7 @@ static int at76_probe(struct usb_interface *interface,
2681 goto error; 5487 goto error;
2682 } 5488 }
2683 5489
5490 SET_NETDEV_DEV(priv->netdev, &interface->dev);
2684 usb_set_intfdata(interface, priv); 5491 usb_set_intfdata(interface, priv);
2685 5492
2686 memcpy(&priv->fw_version, &fwv, sizeof(struct mib_fw_version)); 5493 memcpy(&priv->fw_version, &fwv, sizeof(struct mib_fw_version));
@@ -2708,7 +5515,7 @@ static void at76_disconnect(struct usb_interface *interface)
2708 if (!priv) 5515 if (!priv)
2709 return; 5516 return;
2710 5517
2711 printk(KERN_INFO "%s: disconnecting\n", wiphy_name(priv->hw->wiphy)); 5518 printk(KERN_INFO "%s: disconnecting\n", priv->netdev->name);
2712 at76_delete_device(priv); 5519 at76_delete_device(priv);
2713 dev_printk(KERN_INFO, &interface->dev, "disconnected\n"); 5520 dev_printk(KERN_INFO, &interface->dev, "disconnected\n");
2714} 5521}
@@ -2764,8 +5571,5 @@ MODULE_AUTHOR("Alex <alex@foogod.com>");
2764MODULE_AUTHOR("Nick Jones"); 5571MODULE_AUTHOR("Nick Jones");
2765MODULE_AUTHOR("Balint Seeber <n0_5p4m_p13453@hotmail.com>"); 5572MODULE_AUTHOR("Balint Seeber <n0_5p4m_p13453@hotmail.com>");
2766MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>"); 5573MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>");
2767MODULE_AUTHOR("Guido Guenther <agx@sigxcpu.org>");
2768MODULE_AUTHOR("Kalle Valo <kalle.valo@iki.fi>");
2769MODULE_AUTHOR("Milan Plzik <milan.plzik@gmail.com>");
2770MODULE_DESCRIPTION(DRIVER_DESC); 5574MODULE_DESCRIPTION(DRIVER_DESC);
2771MODULE_LICENSE("GPL"); 5575MODULE_LICENSE("GPL");
diff --git a/drivers/staging/at76_usb/at76_usb.h b/drivers/staging/at76_usb/at76_usb.h
index 8bb352f16d4..b20be9da1fa 100644
--- a/drivers/staging/at76_usb/at76_usb.h
+++ b/drivers/staging/at76_usb/at76_usb.h
@@ -34,6 +34,23 @@ enum board_type {
34 BOARD_505AMX = 8 34 BOARD_505AMX = 8
35}; 35};
36 36
37/* our private ioctl's */
38/* preamble length (0 - long, 1 - short, 2 - auto) */
39#define AT76_SET_SHORT_PREAMBLE (SIOCIWFIRSTPRIV + 0)
40#define AT76_GET_SHORT_PREAMBLE (SIOCIWFIRSTPRIV + 1)
41/* which debug channels are enabled */
42#define AT76_SET_DEBUG (SIOCIWFIRSTPRIV + 2)
43#define AT76_GET_DEBUG (SIOCIWFIRSTPRIV + 3)
44/* power save mode (incl. the Atmel proprietary smart save mode) */
45#define AT76_SET_POWERSAVE_MODE (SIOCIWFIRSTPRIV + 4)
46#define AT76_GET_POWERSAVE_MODE (SIOCIWFIRSTPRIV + 5)
47/* min and max channel times for scan */
48#define AT76_SET_SCAN_TIMES (SIOCIWFIRSTPRIV + 6)
49#define AT76_GET_SCAN_TIMES (SIOCIWFIRSTPRIV + 7)
50/* scan mode (0 - active, 1 - passive) */
51#define AT76_SET_SCAN_MODE (SIOCIWFIRSTPRIV + 8)
52#define AT76_GET_SCAN_MODE (SIOCIWFIRSTPRIV + 9)
53
37#define CMD_STATUS_IDLE 0x00 54#define CMD_STATUS_IDLE 0x00
38#define CMD_STATUS_COMPLETE 0x01 55#define CMD_STATUS_COMPLETE 0x01
39#define CMD_STATUS_UNKNOWN 0x02 56#define CMD_STATUS_UNKNOWN 0x02
@@ -65,7 +82,6 @@ enum board_type {
65#define MIB_MAC 0x03 82#define MIB_MAC 0x03
66#define MIB_MAC_MGMT 0x05 83#define MIB_MAC_MGMT 0x05
67#define MIB_MAC_WEP 0x06 84#define MIB_MAC_WEP 0x06
68#define MIB_MAC_ENCRYPTION 0x06
69#define MIB_PHY 0x07 85#define MIB_PHY 0x07
70#define MIB_FW_VERSION 0x08 86#define MIB_FW_VERSION 0x08
71#define MIB_MDOMAIN 0x09 87#define MIB_MDOMAIN 0x09
@@ -90,26 +106,6 @@ enum board_type {
90#define AT76_PM_ON 2 106#define AT76_PM_ON 2
91#define AT76_PM_SMART 3 107#define AT76_PM_SMART 3
92 108
93/* cipher values for encryption keys */
94#define CIPHER_NONE 0 /* this value is only guessed */
95#define CIPHER_WEP64 1
96#define CIPHER_TKIP 2
97#define CIPHER_CCMP 3
98#define CIPHER_CCX 4 /* for consistency sake only */
99#define CIPHER_WEP128 5
100
101/* bit flags key types for encryption keys */
102#define KEY_PAIRWISE 2
103#define KEY_TX 4
104
105#define CIPHER_KEYS (4)
106#define CIPHER_KEY_LEN (40)
107
108struct key_config {
109 u8 cipher;
110 u8 keylen;
111};
112
113struct hwcfg_r505 { 109struct hwcfg_r505 {
114 u8 cr39_values[14]; 110 u8 cr39_values[14];
115 u8 reserved1[14]; 111 u8 reserved1[14];
@@ -151,9 +147,6 @@ union at76_hwcfg {
151 147
152#define WEP_SMALL_KEY_LEN (40 / 8) 148#define WEP_SMALL_KEY_LEN (40 / 8)
153#define WEP_LARGE_KEY_LEN (104 / 8) 149#define WEP_LARGE_KEY_LEN (104 / 8)
154#define WEP_KEYS (4)
155
156
157 150
158struct at76_card_config { 151struct at76_card_config {
159 u8 exclude_unencrypted; 152 u8 exclude_unencrypted;
@@ -168,7 +161,7 @@ struct at76_card_config {
168 u8 privacy_invoked; 161 u8 privacy_invoked;
169 u8 wep_default_key_id; /* 0..3 */ 162 u8 wep_default_key_id; /* 0..3 */
170 u8 current_ssid[32]; 163 u8 current_ssid[32];
171 u8 wep_default_key_value[4][WEP_LARGE_KEY_LEN]; 164 u8 wep_default_key_value[4][WEP_KEY_LEN];
172 u8 ssid_len; 165 u8 ssid_len;
173 u8 short_preamble; 166 u8 short_preamble;
174 __le16 beacon_period; 167 __le16 beacon_period;
@@ -193,7 +186,7 @@ struct at76_rx_buffer {
193 u8 link_quality; 186 u8 link_quality;
194 u8 noise_level; 187 u8 noise_level;
195 __le32 rx_time; 188 __le32 rx_time;
196 u8 packet[IEEE80211_MAX_FRAG_THRESHOLD]; 189 u8 packet[IEEE80211_FRAME_LEN + IEEE80211_FCS_LEN];
197} __attribute__((packed)); 190} __attribute__((packed));
198 191
199/* Length of Atmel-specific Tx header before 802.11 frame */ 192/* Length of Atmel-specific Tx header before 802.11 frame */
@@ -203,11 +196,8 @@ struct at76_tx_buffer {
203 __le16 wlength; 196 __le16 wlength;
204 u8 tx_rate; 197 u8 tx_rate;
205 u8 padding; 198 u8 padding;
206 u8 key_id; 199 u8 reserved[4];
207 u8 cipher_type; 200 u8 packet[IEEE80211_FRAME_LEN + IEEE80211_FCS_LEN];
208 u8 cipher_length;
209 u8 reserved;
210 u8 packet[IEEE80211_MAX_FRAG_THRESHOLD];
211} __attribute__((packed)); 201} __attribute__((packed));
212 202
213/* defines for scan_type below */ 203/* defines for scan_type below */
@@ -254,7 +244,6 @@ struct set_mib_buffer {
254 u8 byte; 244 u8 byte;
255 __le16 word; 245 __le16 word;
256 u8 addr[ETH_ALEN]; 246 u8 addr[ETH_ALEN];
257 u8 data[256]; /* we need more space for mib_mac_encryption */
258 } data; 247 } data;
259} __attribute__((packed)); 248} __attribute__((packed));
260 249
@@ -328,24 +317,10 @@ struct mib_mac_wep {
328 u8 exclude_unencrypted; 317 u8 exclude_unencrypted;
329 __le32 wep_icv_error_count; 318 __le32 wep_icv_error_count;
330 __le32 wep_excluded_count; 319 __le32 wep_excluded_count;
331 u8 wep_default_keyvalue[WEP_KEYS][WEP_LARGE_KEY_LEN]; 320 u8 wep_default_keyvalue[WEP_KEYS][WEP_KEY_LEN];
332 u8 encryption_level; /* 1 for 40bit, 2 for 104bit encryption */ 321 u8 encryption_level; /* 1 for 40bit, 2 for 104bit encryption */
333} __attribute__((packed)); 322} __attribute__((packed));
334 323
335struct mib_mac_encryption {
336 u8 cipher_default_keyvalue[CIPHER_KEYS][CIPHER_KEY_LEN];
337 u8 tkip_bssid[6];
338 u8 privacy_invoked;
339 u8 cipher_default_key_id;
340 u8 cipher_default_group_key_id;
341 u8 exclude_unencrypted;
342 u8 wep_encryption_type;
343 u8 ckip_key_permutation; /* bool */
344 __le32 wep_icv_error_count;
345 __le32 wep_excluded_count;
346 u8 key_rsc[CIPHER_KEYS][8];
347} __attribute__((packed));
348
349struct mib_phy { 324struct mib_phy {
350 __le32 ed_threshold; 325 __le32 ed_threshold;
351 326
@@ -389,6 +364,16 @@ struct at76_fw_header {
389 __le32 ext_fw_len; /* external firmware image length */ 364 __le32 ext_fw_len; /* external firmware image length */
390} __attribute__((packed)); 365} __attribute__((packed));
391 366
367enum mac_state {
368 MAC_INIT,
369 MAC_SCANNING,
370 MAC_AUTH,
371 MAC_ASSOC,
372 MAC_JOINING,
373 MAC_CONNECTED,
374 MAC_OWN_IBSS
375};
376
392/* a description of a regulatory domain and the allowed channels */ 377/* a description of a regulatory domain and the allowed channels */
393struct reg_domain { 378struct reg_domain {
394 u16 code; 379 u16 code;
@@ -396,6 +381,47 @@ struct reg_domain {
396 u32 channel_map; /* if bit N is set, channel (N+1) is allowed */ 381 u32 channel_map; /* if bit N is set, channel (N+1) is allowed */
397}; 382};
398 383
384/* how long do we keep a (I)BSS in the bss_list in jiffies
385 this should be long enough for the user to retrieve the table
386 (by iwlist ?) after the device started, because all entries from
387 other channels than the one the device locks on get removed, too */
388#define BSS_LIST_TIMEOUT (120 * HZ)
389/* struct to store BSS info found during scan */
390#define BSS_LIST_MAX_RATE_LEN 32 /* 32 rates should be enough ... */
391
392struct bss_info {
393 struct list_head list;
394
395 u8 bssid[ETH_ALEN]; /* bssid */
396 u8 ssid[IW_ESSID_MAX_SIZE]; /* essid */
397 u8 ssid_len; /* length of ssid above */
398 u8 channel;
399 u16 capa; /* BSS capabilities */
400 u16 beacon_interval; /* beacon interval, Kus (1024 microseconds) */
401 u8 rates[BSS_LIST_MAX_RATE_LEN]; /* supported rates in units of
402 500 kbps, ORed with 0x80 for
403 basic rates */
404 u8 rates_len;
405
406 /* quality of received beacon */
407 u8 rssi;
408 u8 link_qual;
409 u8 noise_level;
410
411 unsigned long last_rx; /* time (jiffies) of last beacon received */
412};
413
414/* a rx data buffer to collect rx fragments */
415struct rx_data_buf {
416 u8 sender[ETH_ALEN]; /* sender address */
417 u16 seqnr; /* sequence number */
418 u16 fragnr; /* last fragment received */
419 unsigned long last_rx; /* jiffies of last rx */
420 struct sk_buff *skb; /* == NULL if entry is free */
421};
422
423#define NR_RX_DATA_BUF 8
424
399/* Data for one loaded firmware file */ 425/* Data for one loaded firmware file */
400struct fwentry { 426struct fwentry {
401 const char *const fwname; 427 const char *const fwname;
@@ -412,9 +438,11 @@ struct fwentry {
412 438
413struct at76_priv { 439struct at76_priv {
414 struct usb_device *udev; /* USB device pointer */ 440 struct usb_device *udev; /* USB device pointer */
441 struct net_device *netdev; /* net device pointer */
442 struct net_device_stats stats; /* net device stats */
443 struct iw_statistics wstats; /* wireless stats */
415 444
416 struct sk_buff *rx_skb; /* skbuff for receiving data */ 445 struct sk_buff *rx_skb; /* skbuff for receiving data */
417 struct sk_buff *tx_skb; /* skbuff for transmitting data */
418 void *bulk_out_buffer; /* buffer for sending data */ 446 void *bulk_out_buffer; /* buffer for sending data */
419 447
420 struct urb *tx_urb; /* URB for sending data */ 448 struct urb *tx_urb; /* URB for sending data */
@@ -426,17 +454,26 @@ struct at76_priv {
426 struct mutex mtx; /* locks this structure */ 454 struct mutex mtx; /* locks this structure */
427 455
428 /* work queues */ 456 /* work queues */
457 struct work_struct work_assoc_done;
458 struct work_struct work_join;
459 struct work_struct work_new_bss;
460 struct work_struct work_start_scan;
429 struct work_struct work_set_promisc; 461 struct work_struct work_set_promisc;
430 struct work_struct work_submit_rx; 462 struct work_struct work_submit_rx;
431 struct delayed_work dwork_hw_scan; 463 struct delayed_work dwork_restart;
464 struct delayed_work dwork_get_scan;
465 struct delayed_work dwork_beacon;
466 struct delayed_work dwork_auth;
467 struct delayed_work dwork_assoc;
432 468
433 struct tasklet_struct rx_tasklet; 469 struct tasklet_struct rx_tasklet;
434 470
435 /* the WEP stuff */ 471 /* the WEP stuff */
436 int wep_enabled; /* 1 if WEP is enabled */ 472 int wep_enabled; /* 1 if WEP is enabled */
437 int wep_key_id; /* key id to be used */ 473 int wep_key_id; /* key id to be used */
438 u8 wep_keys[WEP_KEYS][WEP_LARGE_KEY_LEN]; /* WEP keys */ 474 u8 wep_keys[WEP_KEYS][WEP_KEY_LEN]; /* the four WEP keys,
439 u8 wep_keys_len[WEP_KEYS]; /* length of WEP keys */ 475 5 or 13 bytes are used */
476 u8 wep_keys_len[WEP_KEYS]; /* the length of the above keys */
440 477
441 int channel; 478 int channel;
442 int iw_mode; 479 int iw_mode;
@@ -458,13 +495,44 @@ struct at76_priv {
458 int scan_mode; /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */ 495 int scan_mode; /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */
459 int scan_need_any; /* if set, need to scan for any ESSID */ 496 int scan_need_any; /* if set, need to scan for any ESSID */
460 497
498 /* the list we got from scanning */
499 spinlock_t bss_list_spinlock; /* protects bss_list operations */
500 struct list_head bss_list; /* list of BSS we got beacons from */
501 struct timer_list bss_list_timer; /* timer to purge old entries
502 from bss_list */
503 struct bss_info *curr_bss; /* current BSS */
461 u16 assoc_id; /* current association ID, if associated */ 504 u16 assoc_id; /* current association ID, if associated */
462 505
506 u8 wanted_bssid[ETH_ALEN];
507 int wanted_bssid_valid; /* != 0 if wanted_bssid is to be used */
508
509 /* some data for infrastructure mode only */
510 spinlock_t mgmt_spinlock; /* this spinlock protects access to
511 next_mgmt_bulk */
512
513 struct at76_tx_buffer *next_mgmt_bulk; /* pending management msg to
514 send via bulk out */
515 enum mac_state mac_state;
516 enum {
517 SCAN_IDLE,
518 SCAN_IN_PROGRESS,
519 SCAN_COMPLETED
520 } scan_state;
521 time_t last_scan;
522
523 int retries; /* remaining retries in case of timeout when
524 * sending AuthReq or AssocReq */
463 u8 pm_mode; /* power management mode */ 525 u8 pm_mode; /* power management mode */
464 u32 pm_period; /* power management period in microseconds */ 526 u32 pm_period; /* power management period in microseconds */
465 527
466 struct reg_domain const *domain; /* reg domain description */ 528 struct reg_domain const *domain; /* reg domain description */
467 529
530 /* iwspy support */
531 spinlock_t spy_spinlock;
532 struct iw_spy_data spy_data;
533
534 struct iw_public_data wireless_data;
535
468 /* These fields contain HW config provided by the device (not all of 536 /* These fields contain HW config provided by the device (not all of
469 * these fields are used by all board types) */ 537 * these fields are used by all board types) */
470 u8 mac_addr[ETH_ALEN]; 538 u8 mac_addr[ETH_ALEN];
@@ -472,6 +540,9 @@ struct at76_priv {
472 540
473 struct at76_card_config card_config; 541 struct at76_card_config card_config;
474 542
543 /* store rx fragments until complete */
544 struct rx_data_buf rx_data[NR_RX_DATA_BUF];
545
475 enum board_type board_type; 546 enum board_type board_type;
476 struct mib_fw_version fw_version; 547 struct mib_fw_version fw_version;
477 548
@@ -479,20 +550,58 @@ struct at76_priv {
479 unsigned int netdev_registered:1; 550 unsigned int netdev_registered:1;
480 struct set_mib_buffer mib_buf; /* global buffer for set_mib calls */ 551 struct set_mib_buffer mib_buf; /* global buffer for set_mib calls */
481 552
553 /* beacon counting */
482 int beacon_period; /* period of mgmt beacons, Kus */ 554 int beacon_period; /* period of mgmt beacons, Kus */
555 int beacons_received;
556 unsigned long beacons_last_qual; /* time we restarted counting
557 beacons */
558};
483 559
484 struct ieee80211_hw *hw; 560struct at76_rx_radiotap {
485 int mac80211_registered; 561 struct ieee80211_radiotap_header rt_hdr;
486 562 __le64 rt_tsft;
487 struct key_config keys[4]; /* installed key types */ 563 u8 rt_flags;
488 u8 default_pairwise_key; 564 u8 rt_rate;
489 u8 default_group_key; 565 s8 rt_signal;
566 s8 rt_noise;
490}; 567};
491 568
492#define AT76_SUPPORTED_FILTERS FIF_PROMISC_IN_BSS 569#define AT76_RX_RADIOTAP_PRESENT \
570 ((1 << IEEE80211_RADIOTAP_TSFT) | \
571 (1 << IEEE80211_RADIOTAP_FLAGS) | \
572 (1 << IEEE80211_RADIOTAP_RATE) | \
573 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \
574 (1 << IEEE80211_RADIOTAP_DB_ANTNOISE))
575
576#define BEACON_MAX_DATA_LENGTH 1500
577
578/* the maximum size of an AssocReq packet */
579#define ASSOCREQ_MAX_SIZE \
580 (AT76_TX_HDRLEN + sizeof(struct ieee80211_assoc_request) + \
581 1 + 1 + IW_ESSID_MAX_SIZE + 1 + 1 + 4)
582
583/* for shared secret auth, add the challenge text size */
584#define AUTH_FRAME_SIZE (AT76_TX_HDRLEN + sizeof(struct ieee80211_auth))
585
586/* Maximal number of AuthReq retries */
587#define AUTH_RETRIES 3
493 588
589/* Maximal number of AssocReq retries */
590#define ASSOC_RETRIES 3
591
592/* Beacon timeout in managed mode when we are connected */
593#define BEACON_TIMEOUT (10 * HZ)
594
595/* Timeout for authentication response */
596#define AUTH_TIMEOUT (1 * HZ)
597
598/* Timeout for association response */
599#define ASSOC_TIMEOUT (1 * HZ)
600
601/* Polling interval when scan is running */
494#define SCAN_POLL_INTERVAL (HZ / 4) 602#define SCAN_POLL_INTERVAL (HZ / 4)
495 603
604/* Command completion timeout */
496#define CMD_COMPLETION_TIMEOUT (5 * HZ) 605#define CMD_COMPLETION_TIMEOUT (5 * HZ)
497 606
498#define DEF_RTS_THRESHOLD 1536 607#define DEF_RTS_THRESHOLD 1536
@@ -502,6 +611,8 @@ struct at76_priv {
502#define DEF_SCAN_MIN_TIME 10 611#define DEF_SCAN_MIN_TIME 10
503#define DEF_SCAN_MAX_TIME 120 612#define DEF_SCAN_MAX_TIME 120
504 613
614#define MAX_RTS_THRESHOLD (MAX_FRAG_THRESHOLD + 1)
615
505/* the max padding size for tx in bytes (see calc_padding) */ 616/* the max padding size for tx in bytes (see calc_padding) */
506#define MAX_PADDING_SIZE 53 617#define MAX_PADDING_SIZE 53
507 618
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index 5ffe269c238..ab69c1bf36a 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -622,7 +622,7 @@ static int set_ctrl_bits(void)
622} 622}
623 623
624/* sets ctrl & data port bits according to current signals values */ 624/* sets ctrl & data port bits according to current signals values */
625static void set_bits(void) 625static void panel_set_bits(void)
626{ 626{
627 set_data_bits(); 627 set_data_bits();
628 set_ctrl_bits(); 628 set_ctrl_bits();
@@ -707,12 +707,12 @@ static void lcd_send_serial(int byte)
707 */ 707 */
708 for (bit = 0; bit < 8; bit++) { 708 for (bit = 0; bit < 8; bit++) {
709 bits.cl = BIT_CLR; /* CLK low */ 709 bits.cl = BIT_CLR; /* CLK low */
710 set_bits(); 710 panel_set_bits();
711 bits.da = byte & 1; 711 bits.da = byte & 1;
712 set_bits(); 712 panel_set_bits();
713 udelay(2); /* maintain the data during 2 us before CLK up */ 713 udelay(2); /* maintain the data during 2 us before CLK up */
714 bits.cl = BIT_SET; /* CLK high */ 714 bits.cl = BIT_SET; /* CLK high */
715 set_bits(); 715 panel_set_bits();
716 udelay(1); /* maintain the strobe during 1 us */ 716 udelay(1); /* maintain the strobe during 1 us */
717 byte >>= 1; 717 byte >>= 1;
718 } 718 }
@@ -727,7 +727,7 @@ static void lcd_backlight(int on)
727 /* The backlight is activated by seting the AUTOFEED line to +5V */ 727 /* The backlight is activated by seting the AUTOFEED line to +5V */
728 spin_lock(&pprt_lock); 728 spin_lock(&pprt_lock);
729 bits.bl = on; 729 bits.bl = on;
730 set_bits(); 730 panel_set_bits();
731 spin_unlock(&pprt_lock); 731 spin_unlock(&pprt_lock);
732} 732}
733 733
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 8bcde8cde55..b2ceb4aff23 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_USB_MON) += mon/
11obj-$(CONFIG_PCI) += host/ 11obj-$(CONFIG_PCI) += host/
12obj-$(CONFIG_USB_EHCI_HCD) += host/ 12obj-$(CONFIG_USB_EHCI_HCD) += host/
13obj-$(CONFIG_USB_ISP116X_HCD) += host/ 13obj-$(CONFIG_USB_ISP116X_HCD) += host/
14obj-$(CONFIG_USB_ISP1760_HCD) += host/
14obj-$(CONFIG_USB_OHCI_HCD) += host/ 15obj-$(CONFIG_USB_OHCI_HCD) += host/
15obj-$(CONFIG_USB_UHCI_HCD) += host/ 16obj-$(CONFIG_USB_UHCI_HCD) += host/
16obj-$(CONFIG_USB_FHCI_HCD) += host/ 17obj-$(CONFIG_USB_FHCI_HCD) += host/
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 97ba4a985ed..326dd7f65ee 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1349,9 +1349,6 @@ static struct usb_device_id acm_ids[] = {
1349 { USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */ 1349 { USB_DEVICE(0x0e8d, 0x0003), /* FIREFLY, MediaTek Inc; andrey.arapov@gmail.com */
1350 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1350 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1351 }, 1351 },
1352 { USB_DEVICE(0x0e8d, 0x3329), /* i-blue 747, Qstarz BT-Q1000, Holux M-241 */
1353 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1354 },
1355 { USB_DEVICE(0x0e8d, 0x3329), /* MediaTek Inc GPS */ 1352 { USB_DEVICE(0x0e8d, 0x3329), /* MediaTek Inc GPS */
1356 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1353 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1357 }, 1354 },
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index d6c5bcd4006..d701bf4698d 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -1622,6 +1622,8 @@ static int qe_ep_disable(struct usb_ep *_ep)
1622 nuke(ep, -ESHUTDOWN); 1622 nuke(ep, -ESHUTDOWN);
1623 ep->desc = NULL; 1623 ep->desc = NULL;
1624 ep->stopped = 1; 1624 ep->stopped = 1;
1625 ep->tx_req = NULL;
1626 qe_ep_reset(udc, ep->epnum);
1625 spin_unlock_irqrestore(&udc->lock, flags); 1627 spin_unlock_irqrestore(&udc->lock, flags);
1626 1628
1627 cpm_muram_free(cpm_muram_offset(ep->rxbase)); 1629 cpm_muram_free(cpm_muram_offset(ep->rxbase));
@@ -1681,14 +1683,11 @@ static void qe_free_request(struct usb_ep *_ep, struct usb_request *_req)
1681 kfree(req); 1683 kfree(req);
1682} 1684}
1683 1685
1684/* queues (submits) an I/O request to an endpoint */ 1686static int __qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req)
1685static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
1686 gfp_t gfp_flags)
1687{ 1687{
1688 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep); 1688 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep);
1689 struct qe_req *req = container_of(_req, struct qe_req, req); 1689 struct qe_req *req = container_of(_req, struct qe_req, req);
1690 struct qe_udc *udc; 1690 struct qe_udc *udc;
1691 unsigned long flags;
1692 int reval; 1691 int reval;
1693 1692
1694 udc = ep->udc; 1693 udc = ep->udc;
@@ -1732,7 +1731,7 @@ static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
1732 list_add_tail(&req->queue, &ep->queue); 1731 list_add_tail(&req->queue, &ep->queue);
1733 dev_vdbg(udc->dev, "gadget have request in %s! %d\n", 1732 dev_vdbg(udc->dev, "gadget have request in %s! %d\n",
1734 ep->name, req->req.length); 1733 ep->name, req->req.length);
1735 spin_lock_irqsave(&udc->lock, flags); 1734
1736 /* push the request to device */ 1735 /* push the request to device */
1737 if (ep_is_in(ep)) 1736 if (ep_is_in(ep))
1738 reval = ep_req_send(ep, req); 1737 reval = ep_req_send(ep, req);
@@ -1748,11 +1747,24 @@ static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
1748 if (ep->dir == USB_DIR_OUT) 1747 if (ep->dir == USB_DIR_OUT)
1749 reval = ep_req_receive(ep, req); 1748 reval = ep_req_receive(ep, req);
1750 1749
1751 spin_unlock_irqrestore(&udc->lock, flags);
1752
1753 return 0; 1750 return 0;
1754} 1751}
1755 1752
1753/* queues (submits) an I/O request to an endpoint */
1754static int qe_ep_queue(struct usb_ep *_ep, struct usb_request *_req,
1755 gfp_t gfp_flags)
1756{
1757 struct qe_ep *ep = container_of(_ep, struct qe_ep, ep);
1758 struct qe_udc *udc = ep->udc;
1759 unsigned long flags;
1760 int ret;
1761
1762 spin_lock_irqsave(&udc->lock, flags);
1763 ret = __qe_ep_queue(_ep, _req);
1764 spin_unlock_irqrestore(&udc->lock, flags);
1765 return ret;
1766}
1767
1756/* dequeues (cancels, unlinks) an I/O request from an endpoint */ 1768/* dequeues (cancels, unlinks) an I/O request from an endpoint */
1757static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) 1769static int qe_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
1758{ 1770{
@@ -2008,7 +2020,7 @@ static void ch9getstatus(struct qe_udc *udc, u8 request_type, u16 value,
2008 udc->ep0_dir = USB_DIR_IN; 2020 udc->ep0_dir = USB_DIR_IN;
2009 2021
2010 /* data phase */ 2022 /* data phase */
2011 status = qe_ep_queue(&ep->ep, &req->req, GFP_ATOMIC); 2023 status = __qe_ep_queue(&ep->ep, &req->req);
2012 2024
2013 if (status == 0) 2025 if (status == 0)
2014 return; 2026 return;
@@ -2151,6 +2163,9 @@ static int reset_irq(struct qe_udc *udc)
2151{ 2163{
2152 unsigned char i; 2164 unsigned char i;
2153 2165
2166 if (udc->usb_state == USB_STATE_DEFAULT)
2167 return 0;
2168
2154 qe_usb_disable(); 2169 qe_usb_disable();
2155 out_8(&udc->usb_regs->usb_usadr, 0); 2170 out_8(&udc->usb_regs->usb_usadr, 0);
2156 2171
@@ -2442,8 +2457,12 @@ static int __devinit qe_udc_reg_init(struct qe_udc *udc)
2442 struct usb_ctlr __iomem *qe_usbregs; 2457 struct usb_ctlr __iomem *qe_usbregs;
2443 qe_usbregs = udc->usb_regs; 2458 qe_usbregs = udc->usb_regs;
2444 2459
2445 /* Init the usb register */ 2460 /* Spec says that we must enable the USB controller to change mode. */
2446 out_8(&qe_usbregs->usb_usmod, 0x01); 2461 out_8(&qe_usbregs->usb_usmod, 0x01);
2462 /* Mode changed, now disable it, since muram isn't initialized yet. */
2463 out_8(&qe_usbregs->usb_usmod, 0x00);
2464
2465 /* Initialize the rest. */
2447 out_be16(&qe_usbregs->usb_usbmr, 0); 2466 out_be16(&qe_usbregs->usb_usbmr, 0);
2448 out_8(&qe_usbregs->usb_uscom, 0); 2467 out_8(&qe_usbregs->usb_uscom, 0);
2449 out_be16(&qe_usbregs->usb_usber, USBER_ALL_CLEAR); 2468 out_be16(&qe_usbregs->usb_usber, USBER_ALL_CLEAR);
@@ -2604,6 +2623,10 @@ static int __devinit qe_udc_probe(struct of_device *ofdev,
2604 (unsigned long)udc_controller); 2623 (unsigned long)udc_controller);
2605 /* request irq and disable DR */ 2624 /* request irq and disable DR */
2606 udc_controller->usb_irq = irq_of_parse_and_map(np, 0); 2625 udc_controller->usb_irq = irq_of_parse_and_map(np, 0);
2626 if (!udc_controller->usb_irq) {
2627 ret = -EINVAL;
2628 goto err_noirq;
2629 }
2607 2630
2608 ret = request_irq(udc_controller->usb_irq, qe_udc_irq, 0, 2631 ret = request_irq(udc_controller->usb_irq, qe_udc_irq, 0,
2609 driver_name, udc_controller); 2632 driver_name, udc_controller);
@@ -2625,6 +2648,8 @@ static int __devinit qe_udc_probe(struct of_device *ofdev,
2625err6: 2648err6:
2626 free_irq(udc_controller->usb_irq, udc_controller); 2649 free_irq(udc_controller->usb_irq, udc_controller);
2627err5: 2650err5:
2651 irq_dispose_mapping(udc_controller->usb_irq);
2652err_noirq:
2628 if (udc_controller->nullmap) { 2653 if (udc_controller->nullmap) {
2629 dma_unmap_single(udc_controller->gadget.dev.parent, 2654 dma_unmap_single(udc_controller->gadget.dev.parent,
2630 udc_controller->nullp, 256, 2655 udc_controller->nullp, 256,
@@ -2648,7 +2673,7 @@ err2:
2648 iounmap(udc_controller->usb_regs); 2673 iounmap(udc_controller->usb_regs);
2649err1: 2674err1:
2650 kfree(udc_controller); 2675 kfree(udc_controller);
2651 2676 udc_controller = NULL;
2652 return ret; 2677 return ret;
2653} 2678}
2654 2679
@@ -2710,6 +2735,7 @@ static int __devexit qe_udc_remove(struct of_device *ofdev)
2710 kfree(ep->txframe); 2735 kfree(ep->txframe);
2711 2736
2712 free_irq(udc_controller->usb_irq, udc_controller); 2737 free_irq(udc_controller->usb_irq, udc_controller);
2738 irq_dispose_mapping(udc_controller->usb_irq);
2713 2739
2714 tasklet_kill(&udc_controller->rx_tasklet); 2740 tasklet_kill(&udc_controller->rx_tasklet);
2715 2741
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
index 537f953bd7f..6d106e74265 100644
--- a/drivers/usb/serial/aircable.c
+++ b/drivers/usb/serial/aircable.c
@@ -621,9 +621,9 @@ static int __init aircable_init(void)
621 goto failed_usb_register; 621 goto failed_usb_register;
622 return 0; 622 return 0;
623 623
624failed_serial_register:
625 usb_serial_deregister(&aircable_device);
626failed_usb_register: 624failed_usb_register:
625 usb_serial_deregister(&aircable_device);
626failed_serial_register:
627 return retval; 627 return retval;
628} 628}
629 629
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 75597337583..f92f4d77337 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -662,6 +662,7 @@ static struct usb_device_id id_table_combined [] = {
662 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) }, 662 { USB_DEVICE(FTDI_VID, FTDI_DOMINTELL_DUSB_PID) },
663 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) }, 663 { USB_DEVICE(ALTI2_VID, ALTI2_N3_PID) },
664 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) }, 664 { USB_DEVICE(FTDI_VID, DIEBOLD_BCS_SE923_PID) },
665 { USB_DEVICE(FTDI_VID, FTDI_NDI_HUC_PID) },
665 { }, /* Optional parameter entry */ 666 { }, /* Optional parameter entry */
666 { } /* Terminating entry */ 667 { } /* Terminating entry */
667}; 668};
@@ -1064,8 +1065,10 @@ static int set_serial_info(struct tty_struct *tty,
1064 1065
1065 if (!capable(CAP_SYS_ADMIN)) { 1066 if (!capable(CAP_SYS_ADMIN)) {
1066 if (((new_serial.flags & ~ASYNC_USR_MASK) != 1067 if (((new_serial.flags & ~ASYNC_USR_MASK) !=
1067 (priv->flags & ~ASYNC_USR_MASK))) 1068 (priv->flags & ~ASYNC_USR_MASK))) {
1069 unlock_kernel();
1068 return -EPERM; 1070 return -EPERM;
1071 }
1069 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) | 1072 priv->flags = ((priv->flags & ~ASYNC_USR_MASK) |
1070 (new_serial.flags & ASYNC_USR_MASK)); 1073 (new_serial.flags & ASYNC_USR_MASK));
1071 priv->custom_divisor = new_serial.custom_divisor; 1074 priv->custom_divisor = new_serial.custom_divisor;
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 1b62eff475d..e300c840f8c 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -844,6 +844,9 @@
844#define TML_VID 0x1B91 /* Vendor ID */ 844#define TML_VID 0x1B91 /* Vendor ID */
845#define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */ 845#define TML_USB_SERIAL_PID 0x0064 /* USB - Serial Converter */
846 846
847/* NDI Polaris System */
848#define FTDI_NDI_HUC_PID 0xDA70
849
847/* Propox devices */ 850/* Propox devices */
848#define FTDI_PROPOX_JTAGCABLEII_PID 0xD738 851#define FTDI_PROPOX_JTAGCABLEII_PID 0xD738
849 852
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 6c89da9c6fe..bfd0b68cecc 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -199,14 +199,15 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
199#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 199#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400
200 200
201/* FUTURE NOVATEL PRODUCTS */ 201/* FUTURE NOVATEL PRODUCTS */
202#define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000 202#define NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED 0X6000
203#define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000 203#define NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED 0X6001
204#define NOVATELWIRELESS_PRODUCT_EMBEDDED_1 0x8000 204#define NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED 0X7000
205#define NOVATELWIRELESS_PRODUCT_GLOBAL_1 0x9000 205#define NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED 0X7001
206#define NOVATELWIRELESS_PRODUCT_EVDO_2 0x6001 206#define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED 0X8000
207#define NOVATELWIRELESS_PRODUCT_HSPA_2 0x7001 207#define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED 0X8001
208#define NOVATELWIRELESS_PRODUCT_EMBEDDED_2 0x8001 208#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED 0X9000
209#define NOVATELWIRELESS_PRODUCT_GLOBAL_2 0x9001 209#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED 0X9001
210#define NOVATELWIRELESS_PRODUCT_GLOBAL 0XA001
210 211
211/* AMOI PRODUCTS */ 212/* AMOI PRODUCTS */
212#define AMOI_VENDOR_ID 0x1614 213#define AMOI_VENDOR_ID 0x1614
@@ -216,6 +217,27 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
216 217
217#define DELL_VENDOR_ID 0x413C 218#define DELL_VENDOR_ID 0x413C
218 219
220/* Dell modems */
221#define DELL_PRODUCT_5700_MINICARD 0x8114
222#define DELL_PRODUCT_5500_MINICARD 0x8115
223#define DELL_PRODUCT_5505_MINICARD 0x8116
224#define DELL_PRODUCT_5700_EXPRESSCARD 0x8117
225#define DELL_PRODUCT_5510_EXPRESSCARD 0x8118
226
227#define DELL_PRODUCT_5700_MINICARD_SPRINT 0x8128
228#define DELL_PRODUCT_5700_MINICARD_TELUS 0x8129
229
230#define DELL_PRODUCT_5720_MINICARD_VZW 0x8133
231#define DELL_PRODUCT_5720_MINICARD_SPRINT 0x8134
232#define DELL_PRODUCT_5720_MINICARD_TELUS 0x8135
233#define DELL_PRODUCT_5520_MINICARD_CINGULAR 0x8136
234#define DELL_PRODUCT_5520_MINICARD_GENERIC_L 0x8137
235#define DELL_PRODUCT_5520_MINICARD_GENERIC_I 0x8138
236
237#define DELL_PRODUCT_5730_MINICARD_SPRINT 0x8180
238#define DELL_PRODUCT_5730_MINICARD_TELUS 0x8181
239#define DELL_PRODUCT_5730_MINICARD_VZW 0x8182
240
219#define KYOCERA_VENDOR_ID 0x0c88 241#define KYOCERA_VENDOR_ID 0x0c88
220#define KYOCERA_PRODUCT_KPC650 0x17da 242#define KYOCERA_PRODUCT_KPC650 0x17da
221#define KYOCERA_PRODUCT_KPC680 0x180a 243#define KYOCERA_PRODUCT_KPC680 0x180a
@@ -274,12 +296,6 @@ static int option_send_setup(struct tty_struct *tty, struct usb_serial_port *po
274#define ERICSSON_VENDOR_ID 0x0bdb 296#define ERICSSON_VENDOR_ID 0x0bdb
275#define ERICSSON_PRODUCT_F3507G 0x1900 297#define ERICSSON_PRODUCT_F3507G 0x1900
276 298
277/* Pantech products */
278#define PANTECH_VENDOR_ID 0x106c
279#define PANTECH_PRODUCT_PC5740 0x3701
280#define PANTECH_PRODUCT_PC5750 0x3702 /* PX-500 */
281#define PANTECH_PRODUCT_UM150 0x3711
282
283static struct usb_device_id option_ids[] = { 299static struct usb_device_id option_ids[] = {
284 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 300 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
285 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 301 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
@@ -395,31 +411,37 @@ static struct usb_device_id option_ids[] = {
395 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */ 411 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */
396 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ 412 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */
397 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ 413 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */
398 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */ 414 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_FULLSPEED) }, /* Novatel EVDO product */
399 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */ 415 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_FULLSPEED) }, /* Novatel HSPA product */
400 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */ 416 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_FULLSPEED) }, /* Novatel EVDO Embedded product */
401 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_GLOBAL_1) }, /* Novatel Global product */ 417 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED) }, /* Novatel HSPA Embedded product */
402 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_2) }, /* Novatel EVDO product */ 418 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_HIGHSPEED) }, /* Novatel EVDO product */
403 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_2) }, /* Novatel HSPA product */ 419 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_HIGHSPEED) }, /* Novatel HSPA product */
404 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_2) }, /* Novatel Embedded product */ 420 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED) }, /* Novatel EVDO Embedded product */
405 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_GLOBAL_2) }, /* Novatel Global product */ 421 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED) }, /* Novatel HSPA Embedded product */
422 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_GLOBAL) }, /* Novatel Global product */
406 423
407 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) }, 424 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) },
408 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) }, 425 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) },
409 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H02) }, 426 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H02) },
410 427
411 { USB_DEVICE(DELL_VENDOR_ID, 0x8114) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */ 428 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite EV620 CDMA/EV-DO */
412 { USB_DEVICE(DELL_VENDOR_ID, 0x8115) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ 429 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5500_MINICARD) }, /* Dell Wireless 5500 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */
413 { USB_DEVICE(DELL_VENDOR_ID, 0x8116) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */ 430 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5505_MINICARD) }, /* Dell Wireless 5505 Mobile Broadband HSDPA Mini-Card == Novatel Expedite EU740 HSDPA/3G */
414 { USB_DEVICE(DELL_VENDOR_ID, 0x8117) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */ 431 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_EXPRESSCARD) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO ExpressCard == Novatel Merlin XV620 CDMA/EV-DO */
415 { USB_DEVICE(DELL_VENDOR_ID, 0x8118) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */ 432 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5510_EXPRESSCARD) }, /* Dell Wireless 5510 Mobile Broadband HSDPA ExpressCard == Novatel Merlin XU870 HSDPA/3G */
416 { USB_DEVICE(DELL_VENDOR_ID, 0x8128) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */ 433 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD_SPRINT) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite E720 CDMA/EV-DO */
417 { USB_DEVICE(DELL_VENDOR_ID, 0x8129) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite ET620 CDMA/EV-DO */ 434 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5700_MINICARD_TELUS) }, /* Dell Wireless 5700 Mobile Broadband CDMA/EVDO Mini-Card == Novatel Expedite ET620 CDMA/EV-DO */
418 { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ 435 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_VZW) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
419 { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ 436 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_SPRINT) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
420 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ 437 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5720_MINICARD_TELUS) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
421 { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */ 438 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_CINGULAR) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */
422 { USB_DEVICE(DELL_VENDOR_ID, 0x8147) }, /* Dell Wireless 5530 Mobile Broadband (3G HSPA) Mini-Card */ 439 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_L) }, /* Dell Wireless HSDPA 5520 */
440 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5520_MINICARD_GENERIC_I) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */
441 { USB_DEVICE(DELL_VENDOR_ID, 0x8147) }, /* Dell Wireless 5530 Mobile Broadband (3G HSPA) Mini-Card */
442 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
443 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
444 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
423 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ 445 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */
424 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 446 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
425 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, 447 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) },
@@ -488,9 +510,6 @@ static struct usb_device_id option_ids[] = {
488 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) }, 510 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_MF628) },
489 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) }, 511 { USB_DEVICE(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH) },
490 { USB_DEVICE(ERICSSON_VENDOR_ID, ERICSSON_PRODUCT_F3507G) }, 512 { USB_DEVICE(ERICSSON_VENDOR_ID, ERICSSON_PRODUCT_F3507G) },
491 { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5740) },
492 { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_PC5750) },
493 { USB_DEVICE(PANTECH_VENDOR_ID, PANTECH_PRODUCT_UM150) },
494 { } /* Terminating entry */ 513 { } /* Terminating entry */
495}; 514};
496MODULE_DEVICE_TABLE(usb, option_ids); 515MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index baf591137b8..2620bf6fe5e 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -176,7 +176,7 @@ static unsigned int product_5052_count;
176/* the array dimension is the number of default entries plus */ 176/* the array dimension is the number of default entries plus */
177/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */ 177/* TI_EXTRA_VID_PID_COUNT user defined entries plus 1 terminating */
178/* null entry */ 178/* null entry */
179static struct usb_device_id ti_id_table_3410[7+TI_EXTRA_VID_PID_COUNT+1] = { 179static struct usb_device_id ti_id_table_3410[10+TI_EXTRA_VID_PID_COUNT+1] = {
180 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 180 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
181 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 181 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
182 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) }, 182 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -185,9 +185,11 @@ static struct usb_device_id ti_id_table_3410[7+TI_EXTRA_VID_PID_COUNT+1] = {
185 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) }, 185 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_PRODUCT_ID) },
186 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) }, 186 { USB_DEVICE(MTS_VENDOR_ID, MTS_EDGE_PRODUCT_ID) },
187 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) }, 187 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
188 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
189 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
188}; 190};
189 191
190static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = { 192static struct usb_device_id ti_id_table_5052[5+TI_EXTRA_VID_PID_COUNT+1] = {
191 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) }, 193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
192 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) }, 194 { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
193 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 195 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -195,7 +197,7 @@ static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
195 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) }, 197 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
196}; 198};
197 199
198static struct usb_device_id ti_id_table_combined[6+2*TI_EXTRA_VID_PID_COUNT+1] = { 200static struct usb_device_id ti_id_table_combined[14+2*TI_EXTRA_VID_PID_COUNT+1] = {
199 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) }, 201 { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
200 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) }, 202 { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
201 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) }, 203 { USB_DEVICE(MTS_VENDOR_ID, MTS_GSM_NO_FW_PRODUCT_ID) },
@@ -208,6 +210,8 @@ static struct usb_device_id ti_id_table_combined[6+2*TI_EXTRA_VID_PID_COUNT+1] =
208 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) }, 210 { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
209 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) }, 211 { USB_DEVICE(TI_VENDOR_ID, TI_5052_FIRMWARE_PRODUCT_ID) },
210 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) }, 212 { USB_DEVICE(IBM_VENDOR_ID, IBM_4543_PRODUCT_ID) },
213 { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) },
214 { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) },
211 { } 215 { }
212}; 216};
213 217
diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
index b7ea5dbadee..f323c602585 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.h
+++ b/drivers/usb/serial/ti_usb_3410_5052.h
@@ -30,6 +30,8 @@
30#define IBM_VENDOR_ID 0x04b3 30#define IBM_VENDOR_ID 0x04b3
31#define TI_3410_PRODUCT_ID 0x3410 31#define TI_3410_PRODUCT_ID 0x3410
32#define IBM_4543_PRODUCT_ID 0x4543 32#define IBM_4543_PRODUCT_ID 0x4543
33#define IBM_454B_PRODUCT_ID 0x454b
34#define IBM_454C_PRODUCT_ID 0x454c
33#define TI_3410_EZ430_ID 0xF430 /* TI ez430 development tool */ 35#define TI_3410_EZ430_ID 0xF430 /* TI ez430 development tool */
34#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */ 36#define TI_5052_BOOT_PRODUCT_ID 0x5052 /* no EEPROM, no firmware */
35#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */ 37#define TI_5152_BOOT_PRODUCT_ID 0x5152 /* no EEPROM, no firmware */
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 2a42b862aa9..727c506417c 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -64,6 +64,7 @@
64 */ 64 */
65#define VENDOR_ID_NOKIA 0x0421 65#define VENDOR_ID_NOKIA 0x0421
66#define VENDOR_ID_NIKON 0x04b0 66#define VENDOR_ID_NIKON 0x04b0
67#define VENDOR_ID_PENTAX 0x0a17
67#define VENDOR_ID_MOTOROLA 0x22b8 68#define VENDOR_ID_MOTOROLA 0x22b8
68 69
69/*********************************************************************** 70/***********************************************************************
@@ -158,6 +159,7 @@ static int slave_configure(struct scsi_device *sdev)
158 switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) { 159 switch (le16_to_cpu(us->pusb_dev->descriptor.idVendor)) {
159 case VENDOR_ID_NOKIA: 160 case VENDOR_ID_NOKIA:
160 case VENDOR_ID_NIKON: 161 case VENDOR_ID_NIKON:
162 case VENDOR_ID_PENTAX:
161 case VENDOR_ID_MOTOROLA: 163 case VENDOR_ID_MOTOROLA:
162 if (!(us->fflags & (US_FL_FIX_CAPACITY | 164 if (!(us->fflags & (US_FL_FIX_CAPACITY |
163 US_FL_CAPACITY_OK))) 165 US_FL_CAPACITY_OK)))
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 1d5438e6363..fb65d221ced 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -558,32 +558,10 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb)
558 558
559 if (srb->result == SAM_STAT_GOOD && scsi_get_resid(srb) == 0) { 559 if (srb->result == SAM_STAT_GOOD && scsi_get_resid(srb) == 0) {
560 560
561 /* The command succeeded. If the capacity is odd 561 /* The command succeeded. We know this device doesn't
562 * (i.e., if the sector number is even) then the 562 * have the last-sector bug, so stop checking it.
563 * "always-even" heuristic would be wrong for this
564 * device. Issue a WARN() so that the kerneloops.org
565 * project will be notified and we will then know to
566 * mark the device with a CAPACITY_OK flag. Hopefully
567 * this will occur for only a few devices.
568 *
569 * Use the sign of us->last_sector_hacks to tell whether
570 * the warning has already been issued; we don't need
571 * more than one warning per device.
572 */ 563 */
573 if (!(sector & 1) && us->use_last_sector_hacks > 0) { 564 us->use_last_sector_hacks = 0;
574 unsigned vid = le16_to_cpu(
575 us->pusb_dev->descriptor.idVendor);
576 unsigned pid = le16_to_cpu(
577 us->pusb_dev->descriptor.idProduct);
578 unsigned rev = le16_to_cpu(
579 us->pusb_dev->descriptor.bcdDevice);
580
581 WARN(1, "%s: Successful last sector success at %u, "
582 "device %04x:%04x:%04x\n",
583 sdkp->disk->disk_name, sector,
584 vid, pid, rev);
585 us->use_last_sector_hacks = -1;
586 }
587 565
588 } else { 566 } else {
589 /* The command failed. Allow up to 3 retries in case this 567 /* The command failed. Allow up to 3 retries in case this
@@ -599,14 +577,6 @@ static void last_sector_hacks(struct us_data *us, struct scsi_cmnd *srb)
599 srb->result = SAM_STAT_CHECK_CONDITION; 577 srb->result = SAM_STAT_CHECK_CONDITION;
600 memcpy(srb->sense_buffer, record_not_found, 578 memcpy(srb->sense_buffer, record_not_found,
601 sizeof(record_not_found)); 579 sizeof(record_not_found));
602
603 /* In theory we might want to issue a WARN() here if the
604 * capacity is even, since it could indicate the device
605 * has the READ CAPACITY bug _and_ the real capacity is
606 * odd. But it could also indicate that the device
607 * simply can't access its last sector, a failure mode
608 * which is surprisingly common. So no warning.
609 */
610 } 580 }
611 581
612 done: 582 done:
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 69269f73956..50dc33a6065 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1214,7 +1214,7 @@ UNUSUAL_DEV( 0x07c4, 0xa400, 0x0000, 0xffff,
1214 "Datafab", 1214 "Datafab",
1215 "KECF-USB", 1215 "KECF-USB",
1216 US_SC_DEVICE, US_PR_DEVICE, NULL, 1216 US_SC_DEVICE, US_PR_DEVICE, NULL,
1217 US_FL_FIX_INQUIRY ), 1217 US_FL_FIX_INQUIRY | US_FL_FIX_CAPACITY ),
1218 1218
1219/* Reported by Rauch Wolke <rauchwolke@gmx.net> */ 1219/* Reported by Rauch Wolke <rauchwolke@gmx.net> */
1220UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff, 1220UNUSUAL_DEV( 0x07c4, 0xa4a5, 0x0000, 0xffff,
@@ -1354,21 +1354,6 @@ UNUSUAL_DEV( 0x0a17, 0x0004, 0x1000, 0x1000,
1354 US_SC_DEVICE, US_PR_DEVICE, NULL, 1354 US_SC_DEVICE, US_PR_DEVICE, NULL,
1355 US_FL_FIX_INQUIRY ), 1355 US_FL_FIX_INQUIRY ),
1356 1356
1357
1358/* Submitted by Per Winkvist <per.winkvist@uk.com> */
1359UNUSUAL_DEV( 0x0a17, 0x006, 0x0000, 0xffff,
1360 "Pentax",
1361 "Optio S/S4",
1362 US_SC_DEVICE, US_PR_DEVICE, NULL,
1363 US_FL_FIX_INQUIRY ),
1364
1365/* Reported by Jaak Ristioja <Ristioja@gmail.com> */
1366UNUSUAL_DEV( 0x0a17, 0x006e, 0x0100, 0x0100,
1367 "Pentax",
1368 "K10D",
1369 US_SC_DEVICE, US_PR_DEVICE, NULL,
1370 US_FL_FIX_CAPACITY ),
1371
1372/* These are virtual windows driver CDs, which the zd1211rw driver 1357/* These are virtual windows driver CDs, which the zd1211rw driver
1373 * automatically converts into WLAN devices. */ 1358 * automatically converts into WLAN devices. */
1374UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101, 1359UNUSUAL_DEV( 0x0ace, 0x2011, 0x0101, 0x0101,
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index f0267706cb4..bf0af660df8 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -1054,9 +1054,10 @@ config FB_RIVA_BACKLIGHT
1054 1054
1055config FB_I810 1055config FB_I810
1056 tristate "Intel 810/815 support (EXPERIMENTAL)" 1056 tristate "Intel 810/815 support (EXPERIMENTAL)"
1057 depends on FB && EXPERIMENTAL && PCI && X86_32 1057 depends on EXPERIMENTAL && PCI && X86_32
1058 select AGP 1058 select AGP
1059 select AGP_INTEL 1059 select AGP_INTEL
1060 select FB
1060 select FB_MODE_HELPERS 1061 select FB_MODE_HELPERS
1061 select FB_CFB_FILLRECT 1062 select FB_CFB_FILLRECT
1062 select FB_CFB_COPYAREA 1063 select FB_CFB_COPYAREA
@@ -1119,7 +1120,8 @@ config FB_CARILLO_RANCH
1119 1120
1120config FB_INTEL 1121config FB_INTEL
1121 tristate "Intel 830M/845G/852GM/855GM/865G/915G/945G/945GM/965G/965GM support (EXPERIMENTAL)" 1122 tristate "Intel 830M/845G/852GM/855GM/865G/915G/945G/945GM/965G/965GM support (EXPERIMENTAL)"
1122 depends on FB && EXPERIMENTAL && PCI && X86 1123 depends on EXPERIMENTAL && PCI && X86
1124 select FB
1123 select AGP 1125 select AGP
1124 select AGP_INTEL 1126 select AGP_INTEL
1125 select FB_MODE_HELPERS 1127 select FB_MODE_HELPERS
diff --git a/drivers/video/bfin-t350mcqb-fb.c b/drivers/video/bfin-t350mcqb-fb.c
index 2a423d3a2a8..90cfddabf1f 100644
--- a/drivers/video/bfin-t350mcqb-fb.c
+++ b/drivers/video/bfin-t350mcqb-fb.c
@@ -447,7 +447,7 @@ static irqreturn_t bfin_t350mcqb_irq_error(int irq, void *dev_id)
447 return IRQ_HANDLED; 447 return IRQ_HANDLED;
448} 448}
449 449
450static int __init bfin_t350mcqb_probe(struct platform_device *pdev) 450static int __devinit bfin_t350mcqb_probe(struct platform_device *pdev)
451{ 451{
452 struct bfin_t350mcqbfb_info *info; 452 struct bfin_t350mcqbfb_info *info;
453 struct fb_info *fbinfo; 453 struct fb_info *fbinfo;
diff --git a/drivers/video/geode/gx1fb_core.c b/drivers/video/geode/gx1fb_core.c
index 751e491ca8c..f20eff8c4a8 100644
--- a/drivers/video/geode/gx1fb_core.c
+++ b/drivers/video/geode/gx1fb_core.c
@@ -136,13 +136,10 @@ static int gx1fb_set_par(struct fb_info *info)
136{ 136{
137 struct geodefb_par *par = info->par; 137 struct geodefb_par *par = info->par;
138 138
139 if (info->var.bits_per_pixel == 16) { 139 if (info->var.bits_per_pixel == 16)
140 info->fix.visual = FB_VISUAL_TRUECOLOR; 140 info->fix.visual = FB_VISUAL_TRUECOLOR;
141 fb_dealloc_cmap(&info->cmap); 141 else
142 } else {
143 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 142 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
144 fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
145 }
146 143
147 info->fix.line_length = gx1_line_delta(info->var.xres, info->var.bits_per_pixel); 144 info->fix.line_length = gx1_line_delta(info->var.xres, info->var.bits_per_pixel);
148 145
@@ -315,6 +312,10 @@ static struct fb_info * __init gx1fb_init_fbinfo(struct device *dev)
315 if (!par->panel_x) 312 if (!par->panel_x)
316 par->enable_crt = 1; /* fall back to CRT if no panel is specified */ 313 par->enable_crt = 1; /* fall back to CRT if no panel is specified */
317 314
315 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
316 framebuffer_release(info);
317 return NULL;
318 }
318 return info; 319 return info;
319} 320}
320 321
@@ -374,8 +375,11 @@ static int __init gx1fb_probe(struct pci_dev *pdev, const struct pci_device_id *
374 release_mem_region(gx1_gx_base() + 0x8300, 0x100); 375 release_mem_region(gx1_gx_base() + 0x8300, 0x100);
375 } 376 }
376 377
377 if (info) 378 if (info) {
379 fb_dealloc_cmap(&info->cmap);
378 framebuffer_release(info); 380 framebuffer_release(info);
381 }
382
379 return ret; 383 return ret;
380} 384}
381 385
@@ -395,6 +399,7 @@ static void gx1fb_remove(struct pci_dev *pdev)
395 iounmap(par->dc_regs); 399 iounmap(par->dc_regs);
396 release_mem_region(gx1_gx_base() + 0x8300, 0x100); 400 release_mem_region(gx1_gx_base() + 0x8300, 0x100);
397 401
402 fb_dealloc_cmap(&info->cmap);
398 pci_set_drvdata(pdev, NULL); 403 pci_set_drvdata(pdev, NULL);
399 404
400 framebuffer_release(info); 405 framebuffer_release(info);
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index 48411892631..2552cac39e1 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -171,13 +171,10 @@ static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
171 171
172static int gxfb_set_par(struct fb_info *info) 172static int gxfb_set_par(struct fb_info *info)
173{ 173{
174 if (info->var.bits_per_pixel > 8) { 174 if (info->var.bits_per_pixel > 8)
175 info->fix.visual = FB_VISUAL_TRUECOLOR; 175 info->fix.visual = FB_VISUAL_TRUECOLOR;
176 fb_dealloc_cmap(&info->cmap); 176 else
177 } else {
178 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 177 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
179 fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
180 }
181 178
182 info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel); 179 info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel);
183 180
@@ -331,6 +328,11 @@ static struct fb_info * __init gxfb_init_fbinfo(struct device *dev)
331 328
332 info->var.grayscale = 0; 329 info->var.grayscale = 0;
333 330
331 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
332 framebuffer_release(info);
333 return NULL;
334 }
335
334 return info; 336 return info;
335} 337}
336 338
@@ -443,8 +445,10 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
443 pci_release_region(pdev, 1); 445 pci_release_region(pdev, 1);
444 } 446 }
445 447
446 if (info) 448 if (info) {
449 fb_dealloc_cmap(&info->cmap);
447 framebuffer_release(info); 450 framebuffer_release(info);
451 }
448 return ret; 452 return ret;
449} 453}
450 454
@@ -467,6 +471,7 @@ static void gxfb_remove(struct pci_dev *pdev)
467 iounmap(par->gp_regs); 471 iounmap(par->gp_regs);
468 pci_release_region(pdev, 1); 472 pci_release_region(pdev, 1);
469 473
474 fb_dealloc_cmap(&info->cmap);
470 pci_set_drvdata(pdev, NULL); 475 pci_set_drvdata(pdev, NULL);
471 476
472 framebuffer_release(info); 477 framebuffer_release(info);
diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
index b965ecdbc60..889cbe39e58 100644
--- a/drivers/video/geode/lxfb_core.c
+++ b/drivers/video/geode/lxfb_core.c
@@ -278,13 +278,10 @@ static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
278 278
279static int lxfb_set_par(struct fb_info *info) 279static int lxfb_set_par(struct fb_info *info)
280{ 280{
281 if (info->var.bits_per_pixel > 8) { 281 if (info->var.bits_per_pixel > 8)
282 info->fix.visual = FB_VISUAL_TRUECOLOR; 282 info->fix.visual = FB_VISUAL_TRUECOLOR;
283 fb_dealloc_cmap(&info->cmap); 283 else
284 } else {
285 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 284 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
286 fb_alloc_cmap(&info->cmap, 1<<info->var.bits_per_pixel, 0);
287 }
288 285
289 info->fix.line_length = lx_get_pitch(info->var.xres, 286 info->fix.line_length = lx_get_pitch(info->var.xres,
290 info->var.bits_per_pixel); 287 info->var.bits_per_pixel);
@@ -451,6 +448,11 @@ static struct fb_info * __init lxfb_init_fbinfo(struct device *dev)
451 448
452 info->pseudo_palette = (void *)par + sizeof(struct lxfb_par); 449 info->pseudo_palette = (void *)par + sizeof(struct lxfb_par);
453 450
451 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
452 framebuffer_release(info);
453 return NULL;
454 }
455
454 info->var.grayscale = 0; 456 info->var.grayscale = 0;
455 457
456 return info; 458 return info;
@@ -579,8 +581,10 @@ err:
579 pci_release_region(pdev, 3); 581 pci_release_region(pdev, 3);
580 } 582 }
581 583
582 if (info) 584 if (info) {
585 fb_dealloc_cmap(&info->cmap);
583 framebuffer_release(info); 586 framebuffer_release(info);
587 }
584 588
585 return ret; 589 return ret;
586} 590}
@@ -604,6 +608,7 @@ static void lxfb_remove(struct pci_dev *pdev)
604 iounmap(par->vp_regs); 608 iounmap(par->vp_regs);
605 pci_release_region(pdev, 3); 609 pci_release_region(pdev, 3);
606 610
611 fb_dealloc_cmap(&info->cmap);
607 pci_set_drvdata(pdev, NULL); 612 pci_set_drvdata(pdev, NULL);
608 framebuffer_release(info); 613 framebuffer_release(info);
609} 614}
diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 2c8dff9f77d..1ed3d554e37 100644
--- a/drivers/w1/slaves/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -115,7 +115,7 @@ static struct w1_therm_family_converter w1_therm_families[] = {
115 115
116static inline int w1_DS18B20_convert_temp(u8 rom[9]) 116static inline int w1_DS18B20_convert_temp(u8 rom[9])
117{ 117{
118 s16 t = (rom[1] << 8) | rom[0]; 118 int t = ((s16)rom[1] << 8) | rom[0];
119 t = t*1000/16; 119 t = t*1000/16;
120 return t; 120 return t;
121} 121}
diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c
index bf92802f2bb..36e221beedc 100644
--- a/drivers/watchdog/rdc321x_wdt.c
+++ b/drivers/watchdog/rdc321x_wdt.c
@@ -37,7 +37,7 @@
37#include <linux/io.h> 37#include <linux/io.h>
38#include <linux/uaccess.h> 38#include <linux/uaccess.h>
39 39
40#include <asm/mach-rdc321x/rdc321x_defs.h> 40#include <asm/rdc321x_defs.h>
41 41
42#define RDC_WDT_MASK 0x80000000 /* Mask */ 42#define RDC_WDT_MASK 0x80000000 /* Mask */
43#define RDC_WDT_EN 0x00800000 /* Enable bit */ 43#define RDC_WDT_EN 0x00800000 /* Enable bit */
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 3141e149d59..30963af5dba 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -30,6 +30,7 @@
30 30
31#include <asm/ptrace.h> 31#include <asm/ptrace.h>
32#include <asm/irq.h> 32#include <asm/irq.h>
33#include <asm/idle.h>
33#include <asm/sync_bitops.h> 34#include <asm/sync_bitops.h>
34#include <asm/xen/hypercall.h> 35#include <asm/xen/hypercall.h>
35#include <asm/xen/hypervisor.h> 36#include <asm/xen/hypervisor.h>
@@ -51,27 +52,43 @@ static DEFINE_PER_CPU(int, virq_to_irq[NR_VIRQS]) = {[0 ... NR_VIRQS-1] = -1};
51/* IRQ <-> IPI mapping */ 52/* IRQ <-> IPI mapping */
52static DEFINE_PER_CPU(int, ipi_to_irq[XEN_NR_IPIS]) = {[0 ... XEN_NR_IPIS-1] = -1}; 53static DEFINE_PER_CPU(int, ipi_to_irq[XEN_NR_IPIS]) = {[0 ... XEN_NR_IPIS-1] = -1};
53 54
54/* Packed IRQ information: binding type, sub-type index, and event channel. */ 55/* Interrupt types. */
55struct packed_irq 56enum xen_irq_type {
56{ 57 IRQT_UNBOUND = 0,
57 unsigned short evtchn;
58 unsigned char index;
59 unsigned char type;
60};
61
62static struct packed_irq irq_info[NR_IRQS];
63
64/* Binding types. */
65enum {
66 IRQT_UNBOUND,
67 IRQT_PIRQ, 58 IRQT_PIRQ,
68 IRQT_VIRQ, 59 IRQT_VIRQ,
69 IRQT_IPI, 60 IRQT_IPI,
70 IRQT_EVTCHN 61 IRQT_EVTCHN
71}; 62};
72 63
73/* Convenient shorthand for packed representation of an unbound IRQ. */ 64/*
74#define IRQ_UNBOUND mk_irq_info(IRQT_UNBOUND, 0, 0) 65 * Packed IRQ information:
66 * type - enum xen_irq_type
67 * event channel - irq->event channel mapping
68 * cpu - cpu this event channel is bound to
69 * index - type-specific information:
70 * PIRQ - vector, with MSB being "needs EIO"
71 * VIRQ - virq number
72 * IPI - IPI vector
73 * EVTCHN -
74 */
75struct irq_info
76{
77 enum xen_irq_type type; /* type */
78 unsigned short evtchn; /* event channel */
79 unsigned short cpu; /* cpu bound */
80
81 union {
82 unsigned short virq;
83 enum ipi_vector ipi;
84 struct {
85 unsigned short gsi;
86 unsigned short vector;
87 } pirq;
88 } u;
89};
90
91static struct irq_info irq_info[NR_IRQS];
75 92
76static int evtchn_to_irq[NR_EVENT_CHANNELS] = { 93static int evtchn_to_irq[NR_EVENT_CHANNELS] = {
77 [0 ... NR_EVENT_CHANNELS-1] = -1 94 [0 ... NR_EVENT_CHANNELS-1] = -1
@@ -84,10 +101,6 @@ static inline unsigned long *cpu_evtchn_mask(int cpu)
84{ 101{
85 return cpu_evtchn_mask_p[cpu].bits; 102 return cpu_evtchn_mask_p[cpu].bits;
86} 103}
87static u8 cpu_evtchn[NR_EVENT_CHANNELS];
88
89/* Reference counts for bindings to IRQs. */
90static int irq_bindcount[NR_IRQS];
91 104
92/* Xen will never allocate port zero for any purpose. */ 105/* Xen will never allocate port zero for any purpose. */
93#define VALID_EVTCHN(chn) ((chn) != 0) 106#define VALID_EVTCHN(chn) ((chn) != 0)
@@ -95,27 +108,108 @@ static int irq_bindcount[NR_IRQS];
95static struct irq_chip xen_dynamic_chip; 108static struct irq_chip xen_dynamic_chip;
96 109
97/* Constructor for packed IRQ information. */ 110/* Constructor for packed IRQ information. */
98static inline struct packed_irq mk_irq_info(u32 type, u32 index, u32 evtchn) 111static struct irq_info mk_unbound_info(void)
112{
113 return (struct irq_info) { .type = IRQT_UNBOUND };
114}
115
116static struct irq_info mk_evtchn_info(unsigned short evtchn)
117{
118 return (struct irq_info) { .type = IRQT_EVTCHN, .evtchn = evtchn,
119 .cpu = 0 };
120}
121
122static struct irq_info mk_ipi_info(unsigned short evtchn, enum ipi_vector ipi)
123{
124 return (struct irq_info) { .type = IRQT_IPI, .evtchn = evtchn,
125 .cpu = 0, .u.ipi = ipi };
126}
127
128static struct irq_info mk_virq_info(unsigned short evtchn, unsigned short virq)
99{ 129{
100 return (struct packed_irq) { evtchn, index, type }; 130 return (struct irq_info) { .type = IRQT_VIRQ, .evtchn = evtchn,
131 .cpu = 0, .u.virq = virq };
132}
133
134static struct irq_info mk_pirq_info(unsigned short evtchn,
135 unsigned short gsi, unsigned short vector)
136{
137 return (struct irq_info) { .type = IRQT_PIRQ, .evtchn = evtchn,
138 .cpu = 0, .u.pirq = { .gsi = gsi, .vector = vector } };
101} 139}
102 140
103/* 141/*
104 * Accessors for packed IRQ information. 142 * Accessors for packed IRQ information.
105 */ 143 */
106static inline unsigned int evtchn_from_irq(int irq) 144static struct irq_info *info_for_irq(unsigned irq)
107{ 145{
108 return irq_info[irq].evtchn; 146 return &irq_info[irq];
109} 147}
110 148
111static inline unsigned int index_from_irq(int irq) 149static unsigned int evtchn_from_irq(unsigned irq)
112{ 150{
113 return irq_info[irq].index; 151 return info_for_irq(irq)->evtchn;
114} 152}
115 153
116static inline unsigned int type_from_irq(int irq) 154static enum ipi_vector ipi_from_irq(unsigned irq)
117{ 155{
118 return irq_info[irq].type; 156 struct irq_info *info = info_for_irq(irq);
157
158 BUG_ON(info == NULL);
159 BUG_ON(info->type != IRQT_IPI);
160
161 return info->u.ipi;
162}
163
164static unsigned virq_from_irq(unsigned irq)
165{
166 struct irq_info *info = info_for_irq(irq);
167
168 BUG_ON(info == NULL);
169 BUG_ON(info->type != IRQT_VIRQ);
170
171 return info->u.virq;
172}
173
174static unsigned gsi_from_irq(unsigned irq)
175{
176 struct irq_info *info = info_for_irq(irq);
177
178 BUG_ON(info == NULL);
179 BUG_ON(info->type != IRQT_PIRQ);
180
181 return info->u.pirq.gsi;
182}
183
184static unsigned vector_from_irq(unsigned irq)
185{
186 struct irq_info *info = info_for_irq(irq);
187
188 BUG_ON(info == NULL);
189 BUG_ON(info->type != IRQT_PIRQ);
190
191 return info->u.pirq.vector;
192}
193
194static enum xen_irq_type type_from_irq(unsigned irq)
195{
196 return info_for_irq(irq)->type;
197}
198
199static unsigned cpu_from_irq(unsigned irq)
200{
201 return info_for_irq(irq)->cpu;
202}
203
204static unsigned int cpu_from_evtchn(unsigned int evtchn)
205{
206 int irq = evtchn_to_irq[evtchn];
207 unsigned ret = 0;
208
209 if (irq != -1)
210 ret = cpu_from_irq(irq);
211
212 return ret;
119} 213}
120 214
121static inline unsigned long active_evtchns(unsigned int cpu, 215static inline unsigned long active_evtchns(unsigned int cpu,
@@ -136,10 +230,10 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)
136 cpumask_copy(irq_to_desc(irq)->affinity, cpumask_of(cpu)); 230 cpumask_copy(irq_to_desc(irq)->affinity, cpumask_of(cpu));
137#endif 231#endif
138 232
139 __clear_bit(chn, cpu_evtchn_mask(cpu_evtchn[chn])); 233 __clear_bit(chn, cpu_evtchn_mask(cpu_from_irq(irq)));
140 __set_bit(chn, cpu_evtchn_mask(cpu)); 234 __set_bit(chn, cpu_evtchn_mask(cpu));
141 235
142 cpu_evtchn[chn] = cpu; 236 irq_info[irq].cpu = cpu;
143} 237}
144 238
145static void init_evtchn_cpu_bindings(void) 239static void init_evtchn_cpu_bindings(void)
@@ -154,15 +248,9 @@ static void init_evtchn_cpu_bindings(void)
154 } 248 }
155#endif 249#endif
156 250
157 memset(cpu_evtchn, 0, sizeof(cpu_evtchn));
158 memset(cpu_evtchn_mask(0), ~0, sizeof(cpu_evtchn_mask(0))); 251 memset(cpu_evtchn_mask(0), ~0, sizeof(cpu_evtchn_mask(0)));
159} 252}
160 253
161static inline unsigned int cpu_from_evtchn(unsigned int evtchn)
162{
163 return cpu_evtchn[evtchn];
164}
165
166static inline void clear_evtchn(int port) 254static inline void clear_evtchn(int port)
167{ 255{
168 struct shared_info *s = HYPERVISOR_shared_info; 256 struct shared_info *s = HYPERVISOR_shared_info;
@@ -240,9 +328,8 @@ static int find_unbound_irq(void)
240 int irq; 328 int irq;
241 struct irq_desc *desc; 329 struct irq_desc *desc;
242 330
243 /* Only allocate from dynirq range */
244 for (irq = 0; irq < nr_irqs; irq++) 331 for (irq = 0; irq < nr_irqs; irq++)
245 if (irq_bindcount[irq] == 0) 332 if (irq_info[irq].type == IRQT_UNBOUND)
246 break; 333 break;
247 334
248 if (irq == nr_irqs) 335 if (irq == nr_irqs)
@@ -252,6 +339,8 @@ static int find_unbound_irq(void)
252 if (WARN_ON(desc == NULL)) 339 if (WARN_ON(desc == NULL))
253 return -1; 340 return -1;
254 341
342 dynamic_irq_init(irq);
343
255 return irq; 344 return irq;
256} 345}
257 346
@@ -266,16 +355,13 @@ int bind_evtchn_to_irq(unsigned int evtchn)
266 if (irq == -1) { 355 if (irq == -1) {
267 irq = find_unbound_irq(); 356 irq = find_unbound_irq();
268 357
269 dynamic_irq_init(irq);
270 set_irq_chip_and_handler_name(irq, &xen_dynamic_chip, 358 set_irq_chip_and_handler_name(irq, &xen_dynamic_chip,
271 handle_level_irq, "event"); 359 handle_level_irq, "event");
272 360
273 evtchn_to_irq[evtchn] = irq; 361 evtchn_to_irq[evtchn] = irq;
274 irq_info[irq] = mk_irq_info(IRQT_EVTCHN, 0, evtchn); 362 irq_info[irq] = mk_evtchn_info(evtchn);
275 } 363 }
276 364
277 irq_bindcount[irq]++;
278
279 spin_unlock(&irq_mapping_update_lock); 365 spin_unlock(&irq_mapping_update_lock);
280 366
281 return irq; 367 return irq;
@@ -290,12 +376,12 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
290 spin_lock(&irq_mapping_update_lock); 376 spin_lock(&irq_mapping_update_lock);
291 377
292 irq = per_cpu(ipi_to_irq, cpu)[ipi]; 378 irq = per_cpu(ipi_to_irq, cpu)[ipi];
379
293 if (irq == -1) { 380 if (irq == -1) {
294 irq = find_unbound_irq(); 381 irq = find_unbound_irq();
295 if (irq < 0) 382 if (irq < 0)
296 goto out; 383 goto out;
297 384
298 dynamic_irq_init(irq);
299 set_irq_chip_and_handler_name(irq, &xen_dynamic_chip, 385 set_irq_chip_and_handler_name(irq, &xen_dynamic_chip,
300 handle_level_irq, "ipi"); 386 handle_level_irq, "ipi");
301 387
@@ -306,15 +392,12 @@ static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu)
306 evtchn = bind_ipi.port; 392 evtchn = bind_ipi.port;
307 393
308 evtchn_to_irq[evtchn] = irq; 394 evtchn_to_irq[evtchn] = irq;
309 irq_info[irq] = mk_irq_info(IRQT_IPI, ipi, evtchn); 395 irq_info[irq] = mk_ipi_info(evtchn, ipi);
310
311 per_cpu(ipi_to_irq, cpu)[ipi] = irq; 396 per_cpu(ipi_to_irq, cpu)[ipi] = irq;
312 397
313 bind_evtchn_to_cpu(evtchn, cpu); 398 bind_evtchn_to_cpu(evtchn, cpu);
314 } 399 }
315 400
316 irq_bindcount[irq]++;
317
318 out: 401 out:
319 spin_unlock(&irq_mapping_update_lock); 402 spin_unlock(&irq_mapping_update_lock);
320 return irq; 403 return irq;
@@ -340,20 +423,17 @@ static int bind_virq_to_irq(unsigned int virq, unsigned int cpu)
340 423
341 irq = find_unbound_irq(); 424 irq = find_unbound_irq();
342 425
343 dynamic_irq_init(irq);
344 set_irq_chip_and_handler_name(irq, &xen_dynamic_chip, 426 set_irq_chip_and_handler_name(irq, &xen_dynamic_chip,
345 handle_level_irq, "virq"); 427 handle_level_irq, "virq");
346 428
347 evtchn_to_irq[evtchn] = irq; 429 evtchn_to_irq[evtchn] = irq;
348 irq_info[irq] = mk_irq_info(IRQT_VIRQ, virq, evtchn); 430 irq_info[irq] = mk_virq_info(evtchn, virq);
349 431
350 per_cpu(virq_to_irq, cpu)[virq] = irq; 432 per_cpu(virq_to_irq, cpu)[virq] = irq;
351 433
352 bind_evtchn_to_cpu(evtchn, cpu); 434 bind_evtchn_to_cpu(evtchn, cpu);
353 } 435 }
354 436
355 irq_bindcount[irq]++;
356
357 spin_unlock(&irq_mapping_update_lock); 437 spin_unlock(&irq_mapping_update_lock);
358 438
359 return irq; 439 return irq;
@@ -366,7 +446,7 @@ static void unbind_from_irq(unsigned int irq)
366 446
367 spin_lock(&irq_mapping_update_lock); 447 spin_lock(&irq_mapping_update_lock);
368 448
369 if ((--irq_bindcount[irq] == 0) && VALID_EVTCHN(evtchn)) { 449 if (VALID_EVTCHN(evtchn)) {
370 close.port = evtchn; 450 close.port = evtchn;
371 if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0) 451 if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0)
372 BUG(); 452 BUG();
@@ -374,11 +454,11 @@ static void unbind_from_irq(unsigned int irq)
374 switch (type_from_irq(irq)) { 454 switch (type_from_irq(irq)) {
375 case IRQT_VIRQ: 455 case IRQT_VIRQ:
376 per_cpu(virq_to_irq, cpu_from_evtchn(evtchn)) 456 per_cpu(virq_to_irq, cpu_from_evtchn(evtchn))
377 [index_from_irq(irq)] = -1; 457 [virq_from_irq(irq)] = -1;
378 break; 458 break;
379 case IRQT_IPI: 459 case IRQT_IPI:
380 per_cpu(ipi_to_irq, cpu_from_evtchn(evtchn)) 460 per_cpu(ipi_to_irq, cpu_from_evtchn(evtchn))
381 [index_from_irq(irq)] = -1; 461 [ipi_from_irq(irq)] = -1;
382 break; 462 break;
383 default: 463 default:
384 break; 464 break;
@@ -388,7 +468,7 @@ static void unbind_from_irq(unsigned int irq)
388 bind_evtchn_to_cpu(evtchn, 0); 468 bind_evtchn_to_cpu(evtchn, 0);
389 469
390 evtchn_to_irq[evtchn] = -1; 470 evtchn_to_irq[evtchn] = -1;
391 irq_info[irq] = IRQ_UNBOUND; 471 irq_info[irq] = mk_unbound_info();
392 472
393 dynamic_irq_cleanup(irq); 473 dynamic_irq_cleanup(irq);
394 } 474 }
@@ -506,8 +586,8 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
506 for(i = 0; i < NR_EVENT_CHANNELS; i++) { 586 for(i = 0; i < NR_EVENT_CHANNELS; i++) {
507 if (sync_test_bit(i, sh->evtchn_pending)) { 587 if (sync_test_bit(i, sh->evtchn_pending)) {
508 printk(" %d: event %d -> irq %d\n", 588 printk(" %d: event %d -> irq %d\n",
509 cpu_evtchn[i], i, 589 cpu_from_evtchn(i), i,
510 evtchn_to_irq[i]); 590 evtchn_to_irq[i]);
511 } 591 }
512 } 592 }
513 593
@@ -516,7 +596,6 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
516 return IRQ_HANDLED; 596 return IRQ_HANDLED;
517} 597}
518 598
519
520/* 599/*
521 * Search the CPUs pending events bitmasks. For each one found, map 600 * Search the CPUs pending events bitmasks. For each one found, map
522 * the event number to an irq, and feed it into do_IRQ() for 601 * the event number to an irq, and feed it into do_IRQ() for
@@ -529,11 +608,15 @@ irqreturn_t xen_debug_interrupt(int irq, void *dev_id)
529void xen_evtchn_do_upcall(struct pt_regs *regs) 608void xen_evtchn_do_upcall(struct pt_regs *regs)
530{ 609{
531 int cpu = get_cpu(); 610 int cpu = get_cpu();
611 struct pt_regs *old_regs = set_irq_regs(regs);
532 struct shared_info *s = HYPERVISOR_shared_info; 612 struct shared_info *s = HYPERVISOR_shared_info;
533 struct vcpu_info *vcpu_info = __get_cpu_var(xen_vcpu); 613 struct vcpu_info *vcpu_info = __get_cpu_var(xen_vcpu);
534 static DEFINE_PER_CPU(unsigned, nesting_count); 614 static DEFINE_PER_CPU(unsigned, nesting_count);
535 unsigned count; 615 unsigned count;
536 616
617 exit_idle();
618 irq_enter();
619
537 do { 620 do {
538 unsigned long pending_words; 621 unsigned long pending_words;
539 622
@@ -558,7 +641,7 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
558 int irq = evtchn_to_irq[port]; 641 int irq = evtchn_to_irq[port];
559 642
560 if (irq != -1) 643 if (irq != -1)
561 xen_do_IRQ(irq, regs); 644 handle_irq(irq, regs);
562 } 645 }
563 } 646 }
564 647
@@ -569,12 +652,17 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
569 } while(count != 1); 652 } while(count != 1);
570 653
571out: 654out:
655 irq_exit();
656 set_irq_regs(old_regs);
657
572 put_cpu(); 658 put_cpu();
573} 659}
574 660
575/* Rebind a new event channel to an existing irq. */ 661/* Rebind a new event channel to an existing irq. */
576void rebind_evtchn_irq(int evtchn, int irq) 662void rebind_evtchn_irq(int evtchn, int irq)
577{ 663{
664 struct irq_info *info = info_for_irq(irq);
665
578 /* Make sure the irq is masked, since the new event channel 666 /* Make sure the irq is masked, since the new event channel
579 will also be masked. */ 667 will also be masked. */
580 disable_irq(irq); 668 disable_irq(irq);
@@ -584,11 +672,11 @@ void rebind_evtchn_irq(int evtchn, int irq)
584 /* After resume the irq<->evtchn mappings are all cleared out */ 672 /* After resume the irq<->evtchn mappings are all cleared out */
585 BUG_ON(evtchn_to_irq[evtchn] != -1); 673 BUG_ON(evtchn_to_irq[evtchn] != -1);
586 /* Expect irq to have been bound before, 674 /* Expect irq to have been bound before,
587 so the bindcount should be non-0 */ 675 so there should be a proper type */
588 BUG_ON(irq_bindcount[irq] == 0); 676 BUG_ON(info->type == IRQT_UNBOUND);
589 677
590 evtchn_to_irq[evtchn] = irq; 678 evtchn_to_irq[evtchn] = irq;
591 irq_info[irq] = mk_irq_info(IRQT_EVTCHN, 0, evtchn); 679 irq_info[irq] = mk_evtchn_info(evtchn);
592 680
593 spin_unlock(&irq_mapping_update_lock); 681 spin_unlock(&irq_mapping_update_lock);
594 682
@@ -698,8 +786,7 @@ static void restore_cpu_virqs(unsigned int cpu)
698 if ((irq = per_cpu(virq_to_irq, cpu)[virq]) == -1) 786 if ((irq = per_cpu(virq_to_irq, cpu)[virq]) == -1)
699 continue; 787 continue;
700 788
701 BUG_ON(irq_info[irq].type != IRQT_VIRQ); 789 BUG_ON(virq_from_irq(irq) != virq);
702 BUG_ON(irq_info[irq].index != virq);
703 790
704 /* Get a new binding from Xen. */ 791 /* Get a new binding from Xen. */
705 bind_virq.virq = virq; 792 bind_virq.virq = virq;
@@ -711,7 +798,7 @@ static void restore_cpu_virqs(unsigned int cpu)
711 798
712 /* Record the new mapping. */ 799 /* Record the new mapping. */
713 evtchn_to_irq[evtchn] = irq; 800 evtchn_to_irq[evtchn] = irq;
714 irq_info[irq] = mk_irq_info(IRQT_VIRQ, virq, evtchn); 801 irq_info[irq] = mk_virq_info(evtchn, virq);
715 bind_evtchn_to_cpu(evtchn, cpu); 802 bind_evtchn_to_cpu(evtchn, cpu);
716 803
717 /* Ready for use. */ 804 /* Ready for use. */
@@ -728,8 +815,7 @@ static void restore_cpu_ipis(unsigned int cpu)
728 if ((irq = per_cpu(ipi_to_irq, cpu)[ipi]) == -1) 815 if ((irq = per_cpu(ipi_to_irq, cpu)[ipi]) == -1)
729 continue; 816 continue;
730 817
731 BUG_ON(irq_info[irq].type != IRQT_IPI); 818 BUG_ON(ipi_from_irq(irq) != ipi);
732 BUG_ON(irq_info[irq].index != ipi);
733 819
734 /* Get a new binding from Xen. */ 820 /* Get a new binding from Xen. */
735 bind_ipi.vcpu = cpu; 821 bind_ipi.vcpu = cpu;
@@ -740,7 +826,7 @@ static void restore_cpu_ipis(unsigned int cpu)
740 826
741 /* Record the new mapping. */ 827 /* Record the new mapping. */
742 evtchn_to_irq[evtchn] = irq; 828 evtchn_to_irq[evtchn] = irq;
743 irq_info[irq] = mk_irq_info(IRQT_IPI, ipi, evtchn); 829 irq_info[irq] = mk_ipi_info(evtchn, ipi);
744 bind_evtchn_to_cpu(evtchn, cpu); 830 bind_evtchn_to_cpu(evtchn, cpu);
745 831
746 /* Ready for use. */ 832 /* Ready for use. */
@@ -820,8 +906,11 @@ void xen_irq_resume(void)
820 906
821static struct irq_chip xen_dynamic_chip __read_mostly = { 907static struct irq_chip xen_dynamic_chip __read_mostly = {
822 .name = "xen-dyn", 908 .name = "xen-dyn",
909
910 .disable = disable_dynirq,
823 .mask = disable_dynirq, 911 .mask = disable_dynirq,
824 .unmask = enable_dynirq, 912 .unmask = enable_dynirq,
913
825 .ack = ack_dynirq, 914 .ack = ack_dynirq,
826 .set_affinity = set_affinity_irq, 915 .set_affinity = set_affinity_irq,
827 .retrigger = retrigger_dynirq, 916 .retrigger = retrigger_dynirq,
@@ -841,9 +930,5 @@ void __init xen_init_IRQ(void)
841 for (i = 0; i < NR_EVENT_CHANNELS; i++) 930 for (i = 0; i < NR_EVENT_CHANNELS; i++)
842 mask_evtchn(i); 931 mask_evtchn(i);
843 932
844 /* Dynamic IRQ space is currently unbound. Zero the refcnts. */
845 for (i = 0; i < nr_irqs; i++)
846 irq_bindcount[i] = 0;
847
848 irq_ctx_init(smp_processor_id()); 933 irq_ctx_init(smp_processor_id());
849} 934}
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 551177c0011..35443cc4b9a 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1530,8 +1530,7 @@ again:
1530 * for higher level blocks, try not to allocate blocks 1530 * for higher level blocks, try not to allocate blocks
1531 * with the block and the parent locks held. 1531 * with the block and the parent locks held.
1532 */ 1532 */
1533 if (level > 0 && !prealloc_block.objectid && 1533 if (level > 0 && !prealloc_block.objectid) {
1534 btrfs_path_lock_waiting(p, level)) {
1535 u32 size = b->len; 1534 u32 size = b->len;
1536 u64 hint = b->start; 1535 u64 hint = b->start;
1537 1536
diff --git a/fs/btrfs/locking.c b/fs/btrfs/locking.c
index 68fd9ccf180..9ebe9385129 100644
--- a/fs/btrfs/locking.c
+++ b/fs/btrfs/locking.c
@@ -236,25 +236,3 @@ int btrfs_tree_locked(struct extent_buffer *eb)
236 return test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags) || 236 return test_bit(EXTENT_BUFFER_BLOCKING, &eb->bflags) ||
237 spin_is_locked(&eb->lock); 237 spin_is_locked(&eb->lock);
238} 238}
239
240/*
241 * btrfs_search_slot uses this to decide if it should drop its locks
242 * before doing something expensive like allocating free blocks for cow.
243 */
244int btrfs_path_lock_waiting(struct btrfs_path *path, int level)
245{
246 int i;
247 struct extent_buffer *eb;
248
249 for (i = level; i <= level + 1 && i < BTRFS_MAX_LEVEL; i++) {
250 eb = path->nodes[i];
251 if (!eb)
252 break;
253 smp_mb();
254 if (spin_is_contended(&eb->lock) ||
255 waitqueue_active(&eb->lock_wq))
256 return 1;
257 }
258 return 0;
259}
260
diff --git a/fs/btrfs/locking.h b/fs/btrfs/locking.h
index d92e707f587..6bb0afbff92 100644
--- a/fs/btrfs/locking.h
+++ b/fs/btrfs/locking.h
@@ -26,8 +26,6 @@ int btrfs_tree_locked(struct extent_buffer *eb);
26int btrfs_try_tree_lock(struct extent_buffer *eb); 26int btrfs_try_tree_lock(struct extent_buffer *eb);
27int btrfs_try_spin_lock(struct extent_buffer *eb); 27int btrfs_try_spin_lock(struct extent_buffer *eb);
28 28
29int btrfs_path_lock_waiting(struct btrfs_path *path, int level);
30
31void btrfs_set_lock_blocking(struct extent_buffer *eb); 29void btrfs_set_lock_blocking(struct extent_buffer *eb);
32void btrfs_clear_lock_blocking(struct extent_buffer *eb); 30void btrfs_clear_lock_blocking(struct extent_buffer *eb);
33#endif 31#endif
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index da8bdeaa2e6..7c6e3606f0e 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1185,9 +1185,12 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
1185 es = sbi->s_es; 1185 es = sbi->s_es;
1186 if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) != 1186 if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) !=
1187 (old_mount_opt & EXT2_MOUNT_XIP)) && 1187 (old_mount_opt & EXT2_MOUNT_XIP)) &&
1188 invalidate_inodes(sb)) 1188 invalidate_inodes(sb)) {
1189 ext2_warning(sb, __func__, "busy inodes while remounting "\ 1189 ext2_warning(sb, __func__, "refusing change of xip flag "
1190 "xip remain in cache (no functional problem)"); 1190 "with busy inodes while remounting");
1191 sbi->s_mount_opt &= ~EXT2_MOUNT_XIP;
1192 sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP;
1193 }
1191 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) 1194 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
1192 return 0; 1195 return 0;
1193 if (*flags & MS_RDONLY) { 1196 if (*flags & MS_RDONLY) {
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index b70d90e08a3..4a970411a45 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -2428,12 +2428,13 @@ static void ext3_write_super (struct super_block * sb)
2428 2428
2429static int ext3_sync_fs(struct super_block *sb, int wait) 2429static int ext3_sync_fs(struct super_block *sb, int wait)
2430{ 2430{
2431 sb->s_dirt = 0; 2431 tid_t target;
2432 if (wait)
2433 ext3_force_commit(sb);
2434 else
2435 journal_start_commit(EXT3_SB(sb)->s_journal, NULL);
2436 2432
2433 sb->s_dirt = 0;
2434 if (journal_start_commit(EXT3_SB(sb)->s_journal, &target)) {
2435 if (wait)
2436 log_wait_commit(EXT3_SB(sb)->s_journal, target);
2437 }
2437 return 0; 2438 return 0;
2438} 2439}
2439 2440
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 6903d37af03..9b800d97a68 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -108,7 +108,8 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
108 108
109 if (hugetlb_reserve_pages(inode, 109 if (hugetlb_reserve_pages(inode,
110 vma->vm_pgoff >> huge_page_order(h), 110 vma->vm_pgoff >> huge_page_order(h),
111 len >> huge_page_shift(h), vma)) 111 len >> huge_page_shift(h), vma,
112 vma->vm_flags))
112 goto out; 113 goto out;
113 114
114 ret = 0; 115 ret = 0;
@@ -947,7 +948,7 @@ static int can_do_hugetlb_shm(void)
947 can_do_mlock()); 948 can_do_mlock());
948} 949}
949 950
950struct file *hugetlb_file_setup(const char *name, size_t size) 951struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag)
951{ 952{
952 int error = -ENOMEM; 953 int error = -ENOMEM;
953 struct file *file; 954 struct file *file;
@@ -981,7 +982,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size)
981 982
982 error = -ENOMEM; 983 error = -ENOMEM;
983 if (hugetlb_reserve_pages(inode, 0, 984 if (hugetlb_reserve_pages(inode, 0,
984 size >> huge_page_shift(hstate_inode(inode)), NULL)) 985 size >> huge_page_shift(hstate_inode(inode)), NULL,
986 acctflag))
985 goto out_inode; 987 goto out_inode;
986 988
987 d_instantiate(dentry, inode); 989 d_instantiate(dentry, inode);
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 9e4fa52d7dc..e79c07812af 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -427,7 +427,7 @@ int __log_space_left(journal_t *journal)
427} 427}
428 428
429/* 429/*
430 * Called under j_state_lock. Returns true if a transaction was started. 430 * Called under j_state_lock. Returns true if a transaction commit was started.
431 */ 431 */
432int __log_start_commit(journal_t *journal, tid_t target) 432int __log_start_commit(journal_t *journal, tid_t target)
433{ 433{
@@ -495,7 +495,8 @@ int journal_force_commit_nested(journal_t *journal)
495 495
496/* 496/*
497 * Start a commit of the current running transaction (if any). Returns true 497 * Start a commit of the current running transaction (if any). Returns true
498 * if a transaction was started, and fills its tid in at *ptid 498 * if a transaction is going to be committed (or is currently already
499 * committing), and fills its tid in at *ptid
499 */ 500 */
500int journal_start_commit(journal_t *journal, tid_t *ptid) 501int journal_start_commit(journal_t *journal, tid_t *ptid)
501{ 502{
@@ -505,15 +506,19 @@ int journal_start_commit(journal_t *journal, tid_t *ptid)
505 if (journal->j_running_transaction) { 506 if (journal->j_running_transaction) {
506 tid_t tid = journal->j_running_transaction->t_tid; 507 tid_t tid = journal->j_running_transaction->t_tid;
507 508
508 ret = __log_start_commit(journal, tid); 509 __log_start_commit(journal, tid);
509 if (ret && ptid) 510 /* There's a running transaction and we've just made sure
511 * it's commit has been scheduled. */
512 if (ptid)
510 *ptid = tid; 513 *ptid = tid;
511 } else if (journal->j_committing_transaction && ptid) { 514 ret = 1;
515 } else if (journal->j_committing_transaction) {
512 /* 516 /*
513 * If ext3_write_super() recently started a commit, then we 517 * If ext3_write_super() recently started a commit, then we
514 * have to wait for completion of that transaction 518 * have to wait for completion of that transaction
515 */ 519 */
516 *ptid = journal->j_committing_transaction->t_tid; 520 if (ptid)
521 *ptid = journal->j_committing_transaction->t_tid;
517 ret = 1; 522 ret = 1;
518 } 523 }
519 spin_unlock(&journal->j_state_lock); 524 spin_unlock(&journal->j_state_lock);
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 6063a8e4b9f..763b78a6e9d 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -427,7 +427,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
427 goto out; 427 goto out;
428 case -EAGAIN: 428 case -EAGAIN:
429 ret = nlm_lck_denied; 429 ret = nlm_lck_denied;
430 goto out; 430 break;
431 case FILE_LOCK_DEFERRED: 431 case FILE_LOCK_DEFERRED:
432 if (wait) 432 if (wait)
433 break; 433 break;
@@ -443,6 +443,10 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
443 goto out; 443 goto out;
444 } 444 }
445 445
446 ret = nlm_lck_denied;
447 if (!wait)
448 goto out;
449
446 ret = nlm_lck_blocked; 450 ret = nlm_lck_blocked;
447 451
448 /* Append to list of blocked */ 452 /* Append to list of blocked */
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index cd16d6e668c..d797e119e3d 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -222,7 +222,7 @@ static inline struct crypto_tfm *crypto_shash_tfm(struct crypto_shash *tfm)
222 222
223static inline void crypto_free_shash(struct crypto_shash *tfm) 223static inline void crypto_free_shash(struct crypto_shash *tfm)
224{ 224{
225 crypto_free_tfm(crypto_shash_tfm(tfm)); 225 crypto_destroy_tfm(tfm, crypto_shash_tfm(tfm));
226} 226}
227 227
228static inline unsigned int crypto_shash_alignmask( 228static inline unsigned int crypto_shash_alignmask(
diff --git a/include/drm/i915_drm.h b/include/drm/i915_drm.h
index b3bcf72dc65..912cd52db96 100644
--- a/include/drm/i915_drm.h
+++ b/include/drm/i915_drm.h
@@ -261,6 +261,7 @@ typedef struct drm_i915_irq_wait {
261#define I915_PARAM_LAST_DISPATCH 3 261#define I915_PARAM_LAST_DISPATCH 3
262#define I915_PARAM_CHIPSET_ID 4 262#define I915_PARAM_CHIPSET_ID 4
263#define I915_PARAM_HAS_GEM 5 263#define I915_PARAM_HAS_GEM 5
264#define I915_PARAM_NUM_FENCES_AVAIL 6
264 265
265typedef struct drm_i915_getparam { 266typedef struct drm_i915_getparam {
266 int param; 267 int param;
@@ -272,6 +273,7 @@ typedef struct drm_i915_getparam {
272#define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1 273#define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1
273#define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2 274#define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
274#define I915_SETPARAM_ALLOW_BATCHBUFFER 3 275#define I915_SETPARAM_ALLOW_BATCHBUFFER 3
276#define I915_SETPARAM_NUM_USED_FENCES 4
275 277
276typedef struct drm_i915_setparam { 278typedef struct drm_i915_setparam {
277 int param; 279 int param;
diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index e4e8e117d27..499900d0cee 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -378,6 +378,7 @@ struct cgroup_subsys {
378 * - initiating hotplug events 378 * - initiating hotplug events
379 */ 379 */
380 struct mutex hierarchy_mutex; 380 struct mutex hierarchy_mutex;
381 struct lock_class_key subsys_key;
381 382
382 /* 383 /*
383 * Link to parent, and list entry in parent's children. 384 * Link to parent, and list entry in parent's children.
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 3bacd71509f..1f2e9020acc 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -552,7 +552,12 @@ struct crypto_tfm *crypto_alloc_tfm(const char *alg_name,
552 const struct crypto_type *frontend, 552 const struct crypto_type *frontend,
553 u32 type, u32 mask); 553 u32 type, u32 mask);
554struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask); 554struct crypto_tfm *crypto_alloc_base(const char *alg_name, u32 type, u32 mask);
555void crypto_free_tfm(struct crypto_tfm *tfm); 555void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm);
556
557static inline void crypto_free_tfm(struct crypto_tfm *tfm)
558{
559 return crypto_destroy_tfm(tfm, tfm);
560}
556 561
557int alg_test(const char *driver, const char *alg, u32 type, u32 mask); 562int alg_test(const char *driver, const char *alg, u32 type, u32 mask);
558 563
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index 3e0f64c335c..3e68469c188 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -282,6 +282,18 @@ static inline void dmaengine_put(void)
282} 282}
283#endif 283#endif
284 284
285#ifdef CONFIG_NET_DMA
286#define net_dmaengine_get() dmaengine_get()
287#define net_dmaengine_put() dmaengine_put()
288#else
289static inline void net_dmaengine_get(void)
290{
291}
292static inline void net_dmaengine_put(void)
293{
294}
295#endif
296
285dma_cookie_t dma_async_memcpy_buf_to_buf(struct dma_chan *chan, 297dma_cookie_t dma_async_memcpy_buf_to_buf(struct dma_chan *chan,
286 void *dest, void *src, size_t len); 298 void *dest, void *src, size_t len);
287dma_cookie_t dma_async_memcpy_buf_to_pg(struct dma_chan *chan, 299dma_cookie_t dma_async_memcpy_buf_to_pg(struct dma_chan *chan,
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index f1d2fba19ea..03be7f29ca0 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -33,7 +33,8 @@ unsigned long hugetlb_total_pages(void);
33int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, 33int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
34 unsigned long address, int write_access); 34 unsigned long address, int write_access);
35int hugetlb_reserve_pages(struct inode *inode, long from, long to, 35int hugetlb_reserve_pages(struct inode *inode, long from, long to,
36 struct vm_area_struct *vma); 36 struct vm_area_struct *vma,
37 int acctflags);
37void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed); 38void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed);
38 39
39extern unsigned long hugepages_treat_as_movable; 40extern unsigned long hugepages_treat_as_movable;
@@ -138,7 +139,7 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
138 139
139extern const struct file_operations hugetlbfs_file_operations; 140extern const struct file_operations hugetlbfs_file_operations;
140extern struct vm_operations_struct hugetlb_vm_ops; 141extern struct vm_operations_struct hugetlb_vm_ops;
141struct file *hugetlb_file_setup(const char *name, size_t); 142struct file *hugetlb_file_setup(const char *name, size_t, int);
142int hugetlb_get_quota(struct address_space *mapping, long delta); 143int hugetlb_get_quota(struct address_space *mapping, long delta);
143void hugetlb_put_quota(struct address_space *mapping, long delta); 144void hugetlb_put_quota(struct address_space *mapping, long delta);
144 145
@@ -158,9 +159,9 @@ static inline void set_file_hugepages(struct file *file)
158} 159}
159#else /* !CONFIG_HUGETLBFS */ 160#else /* !CONFIG_HUGETLBFS */
160 161
161#define is_file_hugepages(file) 0 162#define is_file_hugepages(file) 0
162#define set_file_hugepages(file) BUG() 163#define set_file_hugepages(file) BUG()
163#define hugetlb_file_setup(name,size) ERR_PTR(-ENOSYS) 164#define hugetlb_file_setup(name,size,acctflag) ERR_PTR(-ENOSYS)
164 165
165#endif /* !CONFIG_HUGETLBFS */ 166#endif /* !CONFIG_HUGETLBFS */
166 167
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index ea0ea1a4c36..e752d973fa2 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -48,12 +48,11 @@ extern struct fs_struct init_fs;
48 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \ 48 .posix_timers = LIST_HEAD_INIT(sig.posix_timers), \
49 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \ 49 .cpu_timers = INIT_CPU_TIMERS(sig.cpu_timers), \
50 .rlim = INIT_RLIMITS, \ 50 .rlim = INIT_RLIMITS, \
51 .cputime = { .totals = { \ 51 .cputimer = { \
52 .utime = cputime_zero, \ 52 .cputime = INIT_CPUTIME, \
53 .stime = cputime_zero, \ 53 .running = 0, \
54 .sum_exec_runtime = 0, \ 54 .lock = __SPIN_LOCK_UNLOCKED(sig.cputimer.lock), \
55 .lock = __SPIN_LOCK_UNLOCKED(sig.cputime.totals.lock), \ 55 }, \
56 }, }, \
57} 56}
58 57
59extern struct nsproxy init_nsproxy; 58extern struct nsproxy init_nsproxy;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index e8ddc98b840..323561582c1 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1129,8 +1129,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1129 unsigned long flag, unsigned long pgoff); 1129 unsigned long flag, unsigned long pgoff);
1130extern unsigned long mmap_region(struct file *file, unsigned long addr, 1130extern unsigned long mmap_region(struct file *file, unsigned long addr,
1131 unsigned long len, unsigned long flags, 1131 unsigned long len, unsigned long flags,
1132 unsigned int vm_flags, unsigned long pgoff, 1132 unsigned int vm_flags, unsigned long pgoff);
1133 int accountable);
1134 1133
1135static inline unsigned long do_mmap(struct file *file, unsigned long addr, 1134static inline unsigned long do_mmap(struct file *file, unsigned long addr,
1136 unsigned long len, unsigned long prot, 1135 unsigned long len, unsigned long prot,
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 28b3f505f18..f0a50b20e8a 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -443,7 +443,6 @@ struct pacct_struct {
443 * @utime: time spent in user mode, in &cputime_t units 443 * @utime: time spent in user mode, in &cputime_t units
444 * @stime: time spent in kernel mode, in &cputime_t units 444 * @stime: time spent in kernel mode, in &cputime_t units
445 * @sum_exec_runtime: total time spent on the CPU, in nanoseconds 445 * @sum_exec_runtime: total time spent on the CPU, in nanoseconds
446 * @lock: lock for fields in this struct
447 * 446 *
448 * This structure groups together three kinds of CPU time that are 447 * This structure groups together three kinds of CPU time that are
449 * tracked for threads and thread groups. Most things considering 448 * tracked for threads and thread groups. Most things considering
@@ -454,23 +453,33 @@ struct task_cputime {
454 cputime_t utime; 453 cputime_t utime;
455 cputime_t stime; 454 cputime_t stime;
456 unsigned long long sum_exec_runtime; 455 unsigned long long sum_exec_runtime;
457 spinlock_t lock;
458}; 456};
459/* Alternate field names when used to cache expirations. */ 457/* Alternate field names when used to cache expirations. */
460#define prof_exp stime 458#define prof_exp stime
461#define virt_exp utime 459#define virt_exp utime
462#define sched_exp sum_exec_runtime 460#define sched_exp sum_exec_runtime
463 461
462#define INIT_CPUTIME \
463 (struct task_cputime) { \
464 .utime = cputime_zero, \
465 .stime = cputime_zero, \
466 .sum_exec_runtime = 0, \
467 }
468
464/** 469/**
465 * struct thread_group_cputime - thread group interval timer counts 470 * struct thread_group_cputimer - thread group interval timer counts
466 * @totals: thread group interval timers; substructure for 471 * @cputime: thread group interval timers.
467 * uniprocessor kernel, per-cpu for SMP kernel. 472 * @running: non-zero when there are timers running and
473 * @cputime receives updates.
474 * @lock: lock for fields in this struct.
468 * 475 *
469 * This structure contains the version of task_cputime, above, that is 476 * This structure contains the version of task_cputime, above, that is
470 * used for thread group CPU clock calculations. 477 * used for thread group CPU timer calculations.
471 */ 478 */
472struct thread_group_cputime { 479struct thread_group_cputimer {
473 struct task_cputime totals; 480 struct task_cputime cputime;
481 int running;
482 spinlock_t lock;
474}; 483};
475 484
476/* 485/*
@@ -519,10 +528,10 @@ struct signal_struct {
519 cputime_t it_prof_incr, it_virt_incr; 528 cputime_t it_prof_incr, it_virt_incr;
520 529
521 /* 530 /*
522 * Thread group totals for process CPU clocks. 531 * Thread group totals for process CPU timers.
523 * See thread_group_cputime(), et al, for details. 532 * See thread_group_cputimer(), et al, for details.
524 */ 533 */
525 struct thread_group_cputime cputime; 534 struct thread_group_cputimer cputimer;
526 535
527 /* Earliest-expiration cache. */ 536 /* Earliest-expiration cache. */
528 struct task_cputime cputime_expires; 537 struct task_cputime cputime_expires;
@@ -559,7 +568,7 @@ struct signal_struct {
559 * Live threads maintain their own counters and add to these 568 * Live threads maintain their own counters and add to these
560 * in __exit_signal, except for the group leader. 569 * in __exit_signal, except for the group leader.
561 */ 570 */
562 cputime_t cutime, cstime; 571 cputime_t utime, stime, cutime, cstime;
563 cputime_t gtime; 572 cputime_t gtime;
564 cputime_t cgtime; 573 cputime_t cgtime;
565 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw; 574 unsigned long nvcsw, nivcsw, cnvcsw, cnivcsw;
@@ -568,6 +577,14 @@ struct signal_struct {
568 struct task_io_accounting ioac; 577 struct task_io_accounting ioac;
569 578
570 /* 579 /*
580 * Cumulative ns of schedule CPU time fo dead threads in the
581 * group, not including a zombie group leader, (This only differs
582 * from jiffies_to_ns(utime + stime) if sched_clock uses something
583 * other than jiffies.)
584 */
585 unsigned long long sum_sched_runtime;
586
587 /*
571 * We don't bother to synchronize most readers of this at all, 588 * We don't bother to synchronize most readers of this at all,
572 * because there is no reader checking a limit that actually needs 589 * because there is no reader checking a limit that actually needs
573 * to get both rlim_cur and rlim_max atomically, and either one 590 * to get both rlim_cur and rlim_max atomically, and either one
@@ -2195,27 +2212,14 @@ static inline int spin_needbreak(spinlock_t *lock)
2195/* 2212/*
2196 * Thread group CPU time accounting. 2213 * Thread group CPU time accounting.
2197 */ 2214 */
2198 2215void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times);
2199static inline 2216void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times);
2200void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
2201{
2202 struct task_cputime *totals = &tsk->signal->cputime.totals;
2203 unsigned long flags;
2204
2205 spin_lock_irqsave(&totals->lock, flags);
2206 *times = *totals;
2207 spin_unlock_irqrestore(&totals->lock, flags);
2208}
2209 2217
2210static inline void thread_group_cputime_init(struct signal_struct *sig) 2218static inline void thread_group_cputime_init(struct signal_struct *sig)
2211{ 2219{
2212 sig->cputime.totals = (struct task_cputime){ 2220 sig->cputimer.cputime = INIT_CPUTIME;
2213 .utime = cputime_zero, 2221 spin_lock_init(&sig->cputimer.lock);
2214 .stime = cputime_zero, 2222 sig->cputimer.running = 0;
2215 .sum_exec_runtime = 0,
2216 };
2217
2218 spin_lock_init(&sig->cputime.totals.lock);
2219} 2223}
2220 2224
2221static inline void thread_group_cputime_free(struct signal_struct *sig) 2225static inline void thread_group_cputime_free(struct signal_struct *sig)
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 715196b09d6..bbacb7baa44 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -176,6 +176,12 @@ static inline void init_call_single_data(void)
176#define put_cpu() preempt_enable() 176#define put_cpu() preempt_enable()
177#define put_cpu_no_resched() preempt_enable_no_resched() 177#define put_cpu_no_resched() preempt_enable_no_resched()
178 178
179/*
180 * Callback to arch code if there's nosmp or maxcpus=0 on the
181 * boot command line:
182 */
183extern void arch_disable_smp_support(void);
184
179void smp_setup_processor_id(void); 185void smp_setup_processor_id(void);
180 186
181#endif /* __LINUX_SMP_H */ 187#endif /* __LINUX_SMP_H */
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index e0c0fccced4..a0c66a2e00a 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -124,7 +124,12 @@ do { \
124#ifdef CONFIG_GENERIC_LOCKBREAK 124#ifdef CONFIG_GENERIC_LOCKBREAK
125#define spin_is_contended(lock) ((lock)->break_lock) 125#define spin_is_contended(lock) ((lock)->break_lock)
126#else 126#else
127
128#ifdef __raw_spin_is_contended
127#define spin_is_contended(lock) __raw_spin_is_contended(&(lock)->raw_lock) 129#define spin_is_contended(lock) __raw_spin_is_contended(&(lock)->raw_lock)
130#else
131#define spin_is_contended(lock) (((void)(lock), 0))
132#endif /*__raw_spin_is_contended*/
128#endif 133#endif
129 134
130/** 135/**
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 0eda02ff241..f9f900cfd06 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -95,13 +95,13 @@ struct old_linux_dirent;
95#define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__) 95#define __SC_TEST5(t5, a5, ...) __SC_TEST(t5); __SC_TEST4(__VA_ARGS__)
96#define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__) 96#define __SC_TEST6(t6, a6, ...) __SC_TEST(t6); __SC_TEST5(__VA_ARGS__)
97 97
98#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void) 98#define SYSCALL_DEFINE0(name) asmlinkage long sys_##name(void)
99#define SYSCALL_DEFINE1(...) SYSCALL_DEFINEx(1, __VA_ARGS__) 99#define SYSCALL_DEFINE1(name, ...) SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
100#define SYSCALL_DEFINE2(...) SYSCALL_DEFINEx(2, __VA_ARGS__) 100#define SYSCALL_DEFINE2(name, ...) SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
101#define SYSCALL_DEFINE3(...) SYSCALL_DEFINEx(3, __VA_ARGS__) 101#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
102#define SYSCALL_DEFINE4(...) SYSCALL_DEFINEx(4, __VA_ARGS__) 102#define SYSCALL_DEFINE4(name, ...) SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
103#define SYSCALL_DEFINE5(...) SYSCALL_DEFINEx(5, __VA_ARGS__) 103#define SYSCALL_DEFINE5(name, ...) SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
104#define SYSCALL_DEFINE6(...) SYSCALL_DEFINEx(6, __VA_ARGS__) 104#define SYSCALL_DEFINE6(name, ...) SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
105 105
106#ifdef CONFIG_PPC64 106#ifdef CONFIG_PPC64
107#define SYSCALL_ALIAS(alias, name) \ 107#define SYSCALL_ALIAS(alias, name) \
@@ -121,21 +121,21 @@ struct old_linux_dirent;
121 121
122#define SYSCALL_DEFINE(name) static inline long SYSC_##name 122#define SYSCALL_DEFINE(name) static inline long SYSC_##name
123#define SYSCALL_DEFINEx(x, name, ...) \ 123#define SYSCALL_DEFINEx(x, name, ...) \
124 asmlinkage long sys_##name(__SC_DECL##x(__VA_ARGS__)); \ 124 asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__)); \
125 static inline long SYSC_##name(__SC_DECL##x(__VA_ARGS__)); \ 125 static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__)); \
126 asmlinkage long SyS_##name(__SC_LONG##x(__VA_ARGS__)) \ 126 asmlinkage long SyS##name(__SC_LONG##x(__VA_ARGS__)) \
127 { \ 127 { \
128 __SC_TEST##x(__VA_ARGS__); \ 128 __SC_TEST##x(__VA_ARGS__); \
129 return (long) SYSC_##name(__SC_CAST##x(__VA_ARGS__)); \ 129 return (long) SYSC##name(__SC_CAST##x(__VA_ARGS__)); \
130 } \ 130 } \
131 SYSCALL_ALIAS(sys_##name, SyS_##name); \ 131 SYSCALL_ALIAS(sys##name, SyS##name); \
132 static inline long SYSC_##name(__SC_DECL##x(__VA_ARGS__)) 132 static inline long SYSC##name(__SC_DECL##x(__VA_ARGS__))
133 133
134#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */ 134#else /* CONFIG_HAVE_SYSCALL_WRAPPERS */
135 135
136#define SYSCALL_DEFINE(name) asmlinkage long sys_##name 136#define SYSCALL_DEFINE(name) asmlinkage long sys_##name
137#define SYSCALL_DEFINEx(x, name, ...) \ 137#define SYSCALL_DEFINEx(x, name, ...) \
138 asmlinkage long sys_##name(__SC_DECL##x(__VA_ARGS__)) 138 asmlinkage long sys##name(__SC_DECL##x(__VA_ARGS__))
139 139
140#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */ 140#endif /* CONFIG_HAVE_SYSCALL_WRAPPERS */
141 141
diff --git a/init/main.c b/init/main.c
index bfe4fb0c984..6441083f827 100644
--- a/init/main.c
+++ b/init/main.c
@@ -136,14 +136,14 @@ unsigned int __initdata setup_max_cpus = NR_CPUS;
136 * greater than 0, limits the maximum number of CPUs activated in 136 * greater than 0, limits the maximum number of CPUs activated in
137 * SMP mode to <NUM>. 137 * SMP mode to <NUM>.
138 */ 138 */
139#ifndef CONFIG_X86_IO_APIC 139
140static inline void disable_ioapic_setup(void) {}; 140void __weak arch_disable_smp_support(void) { }
141#endif
142 141
143static int __init nosmp(char *str) 142static int __init nosmp(char *str)
144{ 143{
145 setup_max_cpus = 0; 144 setup_max_cpus = 0;
146 disable_ioapic_setup(); 145 arch_disable_smp_support();
146
147 return 0; 147 return 0;
148} 148}
149 149
@@ -153,14 +153,14 @@ static int __init maxcpus(char *str)
153{ 153{
154 get_option(&str, &setup_max_cpus); 154 get_option(&str, &setup_max_cpus);
155 if (setup_max_cpus == 0) 155 if (setup_max_cpus == 0)
156 disable_ioapic_setup(); 156 arch_disable_smp_support();
157 157
158 return 0; 158 return 0;
159} 159}
160 160
161early_param("maxcpus", maxcpus); 161early_param("maxcpus", maxcpus);
162#else 162#else
163#define setup_max_cpus NR_CPUS 163const unsigned int setup_max_cpus = NR_CPUS;
164#endif 164#endif
165 165
166/* 166/*
diff --git a/ipc/shm.c b/ipc/shm.c
index f8f69fad3a2..05d51d2a792 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -340,6 +340,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
340 struct file * file; 340 struct file * file;
341 char name[13]; 341 char name[13];
342 int id; 342 int id;
343 int acctflag = 0;
343 344
344 if (size < SHMMIN || size > ns->shm_ctlmax) 345 if (size < SHMMIN || size > ns->shm_ctlmax)
345 return -EINVAL; 346 return -EINVAL;
@@ -364,11 +365,12 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
364 365
365 sprintf (name, "SYSV%08x", key); 366 sprintf (name, "SYSV%08x", key);
366 if (shmflg & SHM_HUGETLB) { 367 if (shmflg & SHM_HUGETLB) {
367 /* hugetlb_file_setup takes care of mlock user accounting */ 368 /* hugetlb_file_setup applies strict accounting */
368 file = hugetlb_file_setup(name, size); 369 if (shmflg & SHM_NORESERVE)
370 acctflag = VM_NORESERVE;
371 file = hugetlb_file_setup(name, size, acctflag);
369 shp->mlock_user = current_user(); 372 shp->mlock_user = current_user();
370 } else { 373 } else {
371 int acctflag = 0;
372 /* 374 /*
373 * Do not allow no accounting for OVERCOMMIT_NEVER, even 375 * Do not allow no accounting for OVERCOMMIT_NEVER, even
374 * if it's asked for. 376 * if it's asked for.
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 5a54ff42874..e14db9c089b 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2351,7 +2351,7 @@ static void cgroup_lock_hierarchy(struct cgroupfs_root *root)
2351 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) { 2351 for (i = 0; i < CGROUP_SUBSYS_COUNT; i++) {
2352 struct cgroup_subsys *ss = subsys[i]; 2352 struct cgroup_subsys *ss = subsys[i];
2353 if (ss->root == root) 2353 if (ss->root == root)
2354 mutex_lock_nested(&ss->hierarchy_mutex, i); 2354 mutex_lock(&ss->hierarchy_mutex);
2355 } 2355 }
2356} 2356}
2357 2357
@@ -2637,6 +2637,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss)
2637 BUG_ON(!list_empty(&init_task.tasks)); 2637 BUG_ON(!list_empty(&init_task.tasks));
2638 2638
2639 mutex_init(&ss->hierarchy_mutex); 2639 mutex_init(&ss->hierarchy_mutex);
2640 lockdep_set_class(&ss->hierarchy_mutex, &ss->subsys_key);
2640 ss->active = 1; 2641 ss->active = 1;
2641} 2642}
2642 2643
diff --git a/kernel/exit.c b/kernel/exit.c
index 70612c19ac9..167e1e3ad7c 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -118,6 +118,8 @@ static void __exit_signal(struct task_struct *tsk)
118 * We won't ever get here for the group leader, since it 118 * We won't ever get here for the group leader, since it
119 * will have been the last reference on the signal_struct. 119 * will have been the last reference on the signal_struct.
120 */ 120 */
121 sig->utime = cputime_add(sig->utime, task_utime(tsk));
122 sig->stime = cputime_add(sig->stime, task_stime(tsk));
121 sig->gtime = cputime_add(sig->gtime, task_gtime(tsk)); 123 sig->gtime = cputime_add(sig->gtime, task_gtime(tsk));
122 sig->min_flt += tsk->min_flt; 124 sig->min_flt += tsk->min_flt;
123 sig->maj_flt += tsk->maj_flt; 125 sig->maj_flt += tsk->maj_flt;
@@ -126,6 +128,7 @@ static void __exit_signal(struct task_struct *tsk)
126 sig->inblock += task_io_get_inblock(tsk); 128 sig->inblock += task_io_get_inblock(tsk);
127 sig->oublock += task_io_get_oublock(tsk); 129 sig->oublock += task_io_get_oublock(tsk);
128 task_io_accounting_add(&sig->ioac, &tsk->ioac); 130 task_io_accounting_add(&sig->ioac, &tsk->ioac);
131 sig->sum_sched_runtime += tsk->se.sum_exec_runtime;
129 sig = NULL; /* Marker for below. */ 132 sig = NULL; /* Marker for below. */
130 } 133 }
131 134
diff --git a/kernel/fork.c b/kernel/fork.c
index c078438ba6f..8de303bdd4e 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -856,13 +856,14 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
856 sig->tty_old_pgrp = NULL; 856 sig->tty_old_pgrp = NULL;
857 sig->tty = NULL; 857 sig->tty = NULL;
858 858
859 sig->cutime = sig->cstime = cputime_zero; 859 sig->utime = sig->stime = sig->cutime = sig->cstime = cputime_zero;
860 sig->gtime = cputime_zero; 860 sig->gtime = cputime_zero;
861 sig->cgtime = cputime_zero; 861 sig->cgtime = cputime_zero;
862 sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0; 862 sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0;
863 sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0; 863 sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0;
864 sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0; 864 sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0;
865 task_io_accounting_init(&sig->ioac); 865 task_io_accounting_init(&sig->ioac);
866 sig->sum_sched_runtime = 0;
866 taskstats_tgid_init(sig); 867 taskstats_tgid_init(sig);
867 868
868 task_lock(current->group_leader); 869 task_lock(current->group_leader);
@@ -1099,7 +1100,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1099#ifdef CONFIG_DEBUG_MUTEXES 1100#ifdef CONFIG_DEBUG_MUTEXES
1100 p->blocked_on = NULL; /* not blocked yet */ 1101 p->blocked_on = NULL; /* not blocked yet */
1101#endif 1102#endif
1102 if (unlikely(ptrace_reparented(current))) 1103 if (unlikely(current->ptrace))
1103 ptrace_fork(p, clone_flags); 1104 ptrace_fork(p, clone_flags);
1104 1105
1105 /* Perform scheduler related setup. Assign this task to a CPU. */ 1106 /* Perform scheduler related setup. Assign this task to a CPU. */
diff --git a/kernel/itimer.c b/kernel/itimer.c
index 6a5fe93dd8b..58762f7077e 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -62,7 +62,7 @@ int do_getitimer(int which, struct itimerval *value)
62 struct task_cputime cputime; 62 struct task_cputime cputime;
63 cputime_t utime; 63 cputime_t utime;
64 64
65 thread_group_cputime(tsk, &cputime); 65 thread_group_cputimer(tsk, &cputime);
66 utime = cputime.utime; 66 utime = cputime.utime;
67 if (cputime_le(cval, utime)) { /* about to fire */ 67 if (cputime_le(cval, utime)) { /* about to fire */
68 cval = jiffies_to_cputime(1); 68 cval = jiffies_to_cputime(1);
@@ -82,7 +82,7 @@ int do_getitimer(int which, struct itimerval *value)
82 struct task_cputime times; 82 struct task_cputime times;
83 cputime_t ptime; 83 cputime_t ptime;
84 84
85 thread_group_cputime(tsk, &times); 85 thread_group_cputimer(tsk, &times);
86 ptime = cputime_add(times.utime, times.stime); 86 ptime = cputime_add(times.utime, times.stime);
87 if (cputime_le(cval, ptime)) { /* about to fire */ 87 if (cputime_le(cval, ptime)) { /* about to fire */
88 cval = jiffies_to_cputime(1); 88 cval = jiffies_to_cputime(1);
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index fa07da94d7b..2313a4cc14e 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -230,6 +230,71 @@ static int cpu_clock_sample(const clockid_t which_clock, struct task_struct *p,
230 return 0; 230 return 0;
231} 231}
232 232
233void thread_group_cputime(struct task_struct *tsk, struct task_cputime *times)
234{
235 struct sighand_struct *sighand;
236 struct signal_struct *sig;
237 struct task_struct *t;
238
239 *times = INIT_CPUTIME;
240
241 rcu_read_lock();
242 sighand = rcu_dereference(tsk->sighand);
243 if (!sighand)
244 goto out;
245
246 sig = tsk->signal;
247
248 t = tsk;
249 do {
250 times->utime = cputime_add(times->utime, t->utime);
251 times->stime = cputime_add(times->stime, t->stime);
252 times->sum_exec_runtime += t->se.sum_exec_runtime;
253
254 t = next_thread(t);
255 } while (t != tsk);
256
257 times->utime = cputime_add(times->utime, sig->utime);
258 times->stime = cputime_add(times->stime, sig->stime);
259 times->sum_exec_runtime += sig->sum_sched_runtime;
260out:
261 rcu_read_unlock();
262}
263
264static void update_gt_cputime(struct task_cputime *a, struct task_cputime *b)
265{
266 if (cputime_gt(b->utime, a->utime))
267 a->utime = b->utime;
268
269 if (cputime_gt(b->stime, a->stime))
270 a->stime = b->stime;
271
272 if (b->sum_exec_runtime > a->sum_exec_runtime)
273 a->sum_exec_runtime = b->sum_exec_runtime;
274}
275
276void thread_group_cputimer(struct task_struct *tsk, struct task_cputime *times)
277{
278 struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
279 struct task_cputime sum;
280 unsigned long flags;
281
282 spin_lock_irqsave(&cputimer->lock, flags);
283 if (!cputimer->running) {
284 cputimer->running = 1;
285 /*
286 * The POSIX timer interface allows for absolute time expiry
287 * values through the TIMER_ABSTIME flag, therefore we have
288 * to synchronize the timer to the clock every time we start
289 * it.
290 */
291 thread_group_cputime(tsk, &sum);
292 update_gt_cputime(&cputimer->cputime, &sum);
293 }
294 *times = cputimer->cputime;
295 spin_unlock_irqrestore(&cputimer->lock, flags);
296}
297
233/* 298/*
234 * Sample a process (thread group) clock for the given group_leader task. 299 * Sample a process (thread group) clock for the given group_leader task.
235 * Must be called with tasklist_lock held for reading. 300 * Must be called with tasklist_lock held for reading.
@@ -457,7 +522,7 @@ void posix_cpu_timers_exit_group(struct task_struct *tsk)
457{ 522{
458 struct task_cputime cputime; 523 struct task_cputime cputime;
459 524
460 thread_group_cputime(tsk, &cputime); 525 thread_group_cputimer(tsk, &cputime);
461 cleanup_timers(tsk->signal->cpu_timers, 526 cleanup_timers(tsk->signal->cpu_timers,
462 cputime.utime, cputime.stime, cputime.sum_exec_runtime); 527 cputime.utime, cputime.stime, cputime.sum_exec_runtime);
463} 528}
@@ -964,6 +1029,19 @@ static void check_thread_timers(struct task_struct *tsk,
964 } 1029 }
965} 1030}
966 1031
1032static void stop_process_timers(struct task_struct *tsk)
1033{
1034 struct thread_group_cputimer *cputimer = &tsk->signal->cputimer;
1035 unsigned long flags;
1036
1037 if (!cputimer->running)
1038 return;
1039
1040 spin_lock_irqsave(&cputimer->lock, flags);
1041 cputimer->running = 0;
1042 spin_unlock_irqrestore(&cputimer->lock, flags);
1043}
1044
967/* 1045/*
968 * Check for any per-thread CPU timers that have fired and move them 1046 * Check for any per-thread CPU timers that have fired and move them
969 * off the tsk->*_timers list onto the firing list. Per-thread timers 1047 * off the tsk->*_timers list onto the firing list. Per-thread timers
@@ -987,13 +1065,15 @@ static void check_process_timers(struct task_struct *tsk,
987 sig->rlim[RLIMIT_CPU].rlim_cur == RLIM_INFINITY && 1065 sig->rlim[RLIMIT_CPU].rlim_cur == RLIM_INFINITY &&
988 list_empty(&timers[CPUCLOCK_VIRT]) && 1066 list_empty(&timers[CPUCLOCK_VIRT]) &&
989 cputime_eq(sig->it_virt_expires, cputime_zero) && 1067 cputime_eq(sig->it_virt_expires, cputime_zero) &&
990 list_empty(&timers[CPUCLOCK_SCHED])) 1068 list_empty(&timers[CPUCLOCK_SCHED])) {
1069 stop_process_timers(tsk);
991 return; 1070 return;
1071 }
992 1072
993 /* 1073 /*
994 * Collect the current process totals. 1074 * Collect the current process totals.
995 */ 1075 */
996 thread_group_cputime(tsk, &cputime); 1076 thread_group_cputimer(tsk, &cputime);
997 utime = cputime.utime; 1077 utime = cputime.utime;
998 ptime = cputime_add(utime, cputime.stime); 1078 ptime = cputime_add(utime, cputime.stime);
999 sum_sched_runtime = cputime.sum_exec_runtime; 1079 sum_sched_runtime = cputime.sum_exec_runtime;
@@ -1259,7 +1339,7 @@ static inline int fastpath_timer_check(struct task_struct *tsk)
1259 if (!task_cputime_zero(&sig->cputime_expires)) { 1339 if (!task_cputime_zero(&sig->cputime_expires)) {
1260 struct task_cputime group_sample; 1340 struct task_cputime group_sample;
1261 1341
1262 thread_group_cputime(tsk, &group_sample); 1342 thread_group_cputimer(tsk, &group_sample);
1263 if (task_cputime_expired(&group_sample, &sig->cputime_expires)) 1343 if (task_cputime_expired(&group_sample, &sig->cputime_expires))
1264 return 1; 1344 return 1;
1265 } 1345 }
@@ -1329,6 +1409,33 @@ void run_posix_cpu_timers(struct task_struct *tsk)
1329} 1409}
1330 1410
1331/* 1411/*
1412 * Sample a process (thread group) timer for the given group_leader task.
1413 * Must be called with tasklist_lock held for reading.
1414 */
1415static int cpu_timer_sample_group(const clockid_t which_clock,
1416 struct task_struct *p,
1417 union cpu_time_count *cpu)
1418{
1419 struct task_cputime cputime;
1420
1421 thread_group_cputimer(p, &cputime);
1422 switch (CPUCLOCK_WHICH(which_clock)) {
1423 default:
1424 return -EINVAL;
1425 case CPUCLOCK_PROF:
1426 cpu->cpu = cputime_add(cputime.utime, cputime.stime);
1427 break;
1428 case CPUCLOCK_VIRT:
1429 cpu->cpu = cputime.utime;
1430 break;
1431 case CPUCLOCK_SCHED:
1432 cpu->sched = cputime.sum_exec_runtime + task_delta_exec(p);
1433 break;
1434 }
1435 return 0;
1436}
1437
1438/*
1332 * Set one of the process-wide special case CPU timers. 1439 * Set one of the process-wide special case CPU timers.
1333 * The tsk->sighand->siglock must be held by the caller. 1440 * The tsk->sighand->siglock must be held by the caller.
1334 * The *newval argument is relative and we update it to be absolute, *oldval 1441 * The *newval argument is relative and we update it to be absolute, *oldval
@@ -1341,7 +1448,7 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
1341 struct list_head *head; 1448 struct list_head *head;
1342 1449
1343 BUG_ON(clock_idx == CPUCLOCK_SCHED); 1450 BUG_ON(clock_idx == CPUCLOCK_SCHED);
1344 cpu_clock_sample_group(clock_idx, tsk, &now); 1451 cpu_timer_sample_group(clock_idx, tsk, &now);
1345 1452
1346 if (oldval) { 1453 if (oldval) {
1347 if (!cputime_eq(*oldval, cputime_zero)) { 1454 if (!cputime_eq(*oldval, cputime_zero)) {
diff --git a/kernel/profile.c b/kernel/profile.c
index 784933acf5b..7724e0409ba 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -114,12 +114,15 @@ int __ref profile_init(void)
114 if (!slab_is_available()) { 114 if (!slab_is_available()) {
115 prof_buffer = alloc_bootmem(buffer_bytes); 115 prof_buffer = alloc_bootmem(buffer_bytes);
116 alloc_bootmem_cpumask_var(&prof_cpu_mask); 116 alloc_bootmem_cpumask_var(&prof_cpu_mask);
117 cpumask_copy(prof_cpu_mask, cpu_possible_mask);
117 return 0; 118 return 0;
118 } 119 }
119 120
120 if (!alloc_cpumask_var(&prof_cpu_mask, GFP_KERNEL)) 121 if (!alloc_cpumask_var(&prof_cpu_mask, GFP_KERNEL))
121 return -ENOMEM; 122 return -ENOMEM;
122 123
124 cpumask_copy(prof_cpu_mask, cpu_possible_mask);
125
123 prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL); 126 prof_buffer = kzalloc(buffer_bytes, GFP_KERNEL);
124 if (prof_buffer) 127 if (prof_buffer)
125 return 0; 128 return 0;
diff --git a/kernel/sched.c b/kernel/sched.c
index fc17fd91ab5..61245b8d0f1 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -2266,16 +2266,6 @@ static int try_to_wake_up(struct task_struct *p, unsigned int state, int sync)
2266 if (!sched_feat(SYNC_WAKEUPS)) 2266 if (!sched_feat(SYNC_WAKEUPS))
2267 sync = 0; 2267 sync = 0;
2268 2268
2269 if (!sync) {
2270 if (current->se.avg_overlap < sysctl_sched_migration_cost &&
2271 p->se.avg_overlap < sysctl_sched_migration_cost)
2272 sync = 1;
2273 } else {
2274 if (current->se.avg_overlap >= sysctl_sched_migration_cost ||
2275 p->se.avg_overlap >= sysctl_sched_migration_cost)
2276 sync = 0;
2277 }
2278
2279#ifdef CONFIG_SMP 2269#ifdef CONFIG_SMP
2280 if (sched_feat(LB_WAKEUP_UPDATE)) { 2270 if (sched_feat(LB_WAKEUP_UPDATE)) {
2281 struct sched_domain *sd; 2271 struct sched_domain *sd;
@@ -3890,19 +3880,24 @@ int select_nohz_load_balancer(int stop_tick)
3890 int cpu = smp_processor_id(); 3880 int cpu = smp_processor_id();
3891 3881
3892 if (stop_tick) { 3882 if (stop_tick) {
3893 cpumask_set_cpu(cpu, nohz.cpu_mask);
3894 cpu_rq(cpu)->in_nohz_recently = 1; 3883 cpu_rq(cpu)->in_nohz_recently = 1;
3895 3884
3896 /* 3885 if (!cpu_active(cpu)) {
3897 * If we are going offline and still the leader, give up! 3886 if (atomic_read(&nohz.load_balancer) != cpu)
3898 */ 3887 return 0;
3899 if (!cpu_active(cpu) && 3888
3900 atomic_read(&nohz.load_balancer) == cpu) { 3889 /*
3890 * If we are going offline and still the leader,
3891 * give up!
3892 */
3901 if (atomic_cmpxchg(&nohz.load_balancer, cpu, -1) != cpu) 3893 if (atomic_cmpxchg(&nohz.load_balancer, cpu, -1) != cpu)
3902 BUG(); 3894 BUG();
3895
3903 return 0; 3896 return 0;
3904 } 3897 }
3905 3898
3899 cpumask_set_cpu(cpu, nohz.cpu_mask);
3900
3906 /* time for ilb owner also to sleep */ 3901 /* time for ilb owner also to sleep */
3907 if (cpumask_weight(nohz.cpu_mask) == num_online_cpus()) { 3902 if (cpumask_weight(nohz.cpu_mask) == num_online_cpus()) {
3908 if (atomic_read(&nohz.load_balancer) == cpu) 3903 if (atomic_read(&nohz.load_balancer) == cpu)
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index a7e50ba185a..0566f2a03c4 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1191,15 +1191,20 @@ wake_affine(struct sched_domain *this_sd, struct rq *this_rq,
1191 int idx, unsigned long load, unsigned long this_load, 1191 int idx, unsigned long load, unsigned long this_load,
1192 unsigned int imbalance) 1192 unsigned int imbalance)
1193{ 1193{
1194 struct task_struct *curr = this_rq->curr;
1195 struct task_group *tg;
1194 unsigned long tl = this_load; 1196 unsigned long tl = this_load;
1195 unsigned long tl_per_task; 1197 unsigned long tl_per_task;
1196 struct task_group *tg;
1197 unsigned long weight; 1198 unsigned long weight;
1198 int balanced; 1199 int balanced;
1199 1200
1200 if (!(this_sd->flags & SD_WAKE_AFFINE) || !sched_feat(AFFINE_WAKEUPS)) 1201 if (!(this_sd->flags & SD_WAKE_AFFINE) || !sched_feat(AFFINE_WAKEUPS))
1201 return 0; 1202 return 0;
1202 1203
1204 if (sync && (curr->se.avg_overlap > sysctl_sched_migration_cost ||
1205 p->se.avg_overlap > sysctl_sched_migration_cost))
1206 sync = 0;
1207
1203 /* 1208 /*
1204 * If sync wakeup then subtract the (maximum possible) 1209 * If sync wakeup then subtract the (maximum possible)
1205 * effect of the currently running task from the load 1210 * effect of the currently running task from the load
@@ -1426,7 +1431,9 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int sync)
1426 if (!sched_feat(WAKEUP_PREEMPT)) 1431 if (!sched_feat(WAKEUP_PREEMPT))
1427 return; 1432 return;
1428 1433
1429 if (sched_feat(WAKEUP_OVERLAP) && sync) { 1434 if (sched_feat(WAKEUP_OVERLAP) && (sync ||
1435 (se->avg_overlap < sysctl_sched_migration_cost &&
1436 pse->avg_overlap < sysctl_sched_migration_cost))) {
1430 resched_task(curr); 1437 resched_task(curr);
1431 return; 1438 return;
1432 } 1439 }
diff --git a/kernel/sched_stats.h b/kernel/sched_stats.h
index 8ab0cef8eca..a8f93dd374e 100644
--- a/kernel/sched_stats.h
+++ b/kernel/sched_stats.h
@@ -296,19 +296,21 @@ sched_info_switch(struct task_struct *prev, struct task_struct *next)
296static inline void account_group_user_time(struct task_struct *tsk, 296static inline void account_group_user_time(struct task_struct *tsk,
297 cputime_t cputime) 297 cputime_t cputime)
298{ 298{
299 struct task_cputime *times; 299 struct thread_group_cputimer *cputimer;
300 struct signal_struct *sig;
301 300
302 /* tsk == current, ensure it is safe to use ->signal */ 301 /* tsk == current, ensure it is safe to use ->signal */
303 if (unlikely(tsk->exit_state)) 302 if (unlikely(tsk->exit_state))
304 return; 303 return;
305 304
306 sig = tsk->signal; 305 cputimer = &tsk->signal->cputimer;
307 times = &sig->cputime.totals;
308 306
309 spin_lock(&times->lock); 307 if (!cputimer->running)
310 times->utime = cputime_add(times->utime, cputime); 308 return;
311 spin_unlock(&times->lock); 309
310 spin_lock(&cputimer->lock);
311 cputimer->cputime.utime =
312 cputime_add(cputimer->cputime.utime, cputime);
313 spin_unlock(&cputimer->lock);
312} 314}
313 315
314/** 316/**
@@ -324,19 +326,21 @@ static inline void account_group_user_time(struct task_struct *tsk,
324static inline void account_group_system_time(struct task_struct *tsk, 326static inline void account_group_system_time(struct task_struct *tsk,
325 cputime_t cputime) 327 cputime_t cputime)
326{ 328{
327 struct task_cputime *times; 329 struct thread_group_cputimer *cputimer;
328 struct signal_struct *sig;
329 330
330 /* tsk == current, ensure it is safe to use ->signal */ 331 /* tsk == current, ensure it is safe to use ->signal */
331 if (unlikely(tsk->exit_state)) 332 if (unlikely(tsk->exit_state))
332 return; 333 return;
333 334
334 sig = tsk->signal; 335 cputimer = &tsk->signal->cputimer;
335 times = &sig->cputime.totals; 336
337 if (!cputimer->running)
338 return;
336 339
337 spin_lock(&times->lock); 340 spin_lock(&cputimer->lock);
338 times->stime = cputime_add(times->stime, cputime); 341 cputimer->cputime.stime =
339 spin_unlock(&times->lock); 342 cputime_add(cputimer->cputime.stime, cputime);
343 spin_unlock(&cputimer->lock);
340} 344}
341 345
342/** 346/**
@@ -352,7 +356,7 @@ static inline void account_group_system_time(struct task_struct *tsk,
352static inline void account_group_exec_runtime(struct task_struct *tsk, 356static inline void account_group_exec_runtime(struct task_struct *tsk,
353 unsigned long long ns) 357 unsigned long long ns)
354{ 358{
355 struct task_cputime *times; 359 struct thread_group_cputimer *cputimer;
356 struct signal_struct *sig; 360 struct signal_struct *sig;
357 361
358 sig = tsk->signal; 362 sig = tsk->signal;
@@ -361,9 +365,12 @@ static inline void account_group_exec_runtime(struct task_struct *tsk,
361 if (unlikely(!sig)) 365 if (unlikely(!sig))
362 return; 366 return;
363 367
364 times = &sig->cputime.totals; 368 cputimer = &sig->cputimer;
369
370 if (!cputimer->running)
371 return;
365 372
366 spin_lock(&times->lock); 373 spin_lock(&cputimer->lock);
367 times->sum_exec_runtime += ns; 374 cputimer->cputime.sum_exec_runtime += ns;
368 spin_unlock(&times->lock); 375 spin_unlock(&cputimer->lock);
369} 376}
diff --git a/kernel/signal.c b/kernel/signal.c
index b6b36768b75..2a74fe87c0d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1367,7 +1367,6 @@ int do_notify_parent(struct task_struct *tsk, int sig)
1367 struct siginfo info; 1367 struct siginfo info;
1368 unsigned long flags; 1368 unsigned long flags;
1369 struct sighand_struct *psig; 1369 struct sighand_struct *psig;
1370 struct task_cputime cputime;
1371 int ret = sig; 1370 int ret = sig;
1372 1371
1373 BUG_ON(sig == -1); 1372 BUG_ON(sig == -1);
@@ -1397,9 +1396,10 @@ int do_notify_parent(struct task_struct *tsk, int sig)
1397 info.si_uid = __task_cred(tsk)->uid; 1396 info.si_uid = __task_cred(tsk)->uid;
1398 rcu_read_unlock(); 1397 rcu_read_unlock();
1399 1398
1400 thread_group_cputime(tsk, &cputime); 1399 info.si_utime = cputime_to_clock_t(cputime_add(tsk->utime,
1401 info.si_utime = cputime_to_jiffies(cputime.utime); 1400 tsk->signal->utime));
1402 info.si_stime = cputime_to_jiffies(cputime.stime); 1401 info.si_stime = cputime_to_clock_t(cputime_add(tsk->stime,
1402 tsk->signal->stime));
1403 1403
1404 info.si_status = tsk->exit_code & 0x7f; 1404 info.si_status = tsk->exit_code & 0x7f;
1405 if (tsk->exit_code & 0x80) 1405 if (tsk->exit_code & 0x80)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 790f9d78566..c5ef44ff850 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -101,6 +101,7 @@ static int two = 2;
101 101
102static int zero; 102static int zero;
103static int one = 1; 103static int one = 1;
104static unsigned long one_ul = 1;
104static int one_hundred = 100; 105static int one_hundred = 100;
105 106
106/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 107/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
@@ -974,7 +975,7 @@ static struct ctl_table vm_table[] = {
974 .mode = 0644, 975 .mode = 0644,
975 .proc_handler = &dirty_background_bytes_handler, 976 .proc_handler = &dirty_background_bytes_handler,
976 .strategy = &sysctl_intvec, 977 .strategy = &sysctl_intvec,
977 .extra1 = &one, 978 .extra1 = &one_ul,
978 }, 979 },
979 { 980 {
980 .ctl_name = VM_DIRTY_RATIO, 981 .ctl_name = VM_DIRTY_RATIO,
@@ -995,7 +996,7 @@ static struct ctl_table vm_table[] = {
995 .mode = 0644, 996 .mode = 0644,
996 .proc_handler = &dirty_bytes_handler, 997 .proc_handler = &dirty_bytes_handler,
997 .strategy = &sysctl_intvec, 998 .strategy = &sysctl_intvec,
998 .extra1 = &one, 999 .extra1 = &one_ul,
999 }, 1000 },
1000 { 1001 {
1001 .procname = "dirty_writeback_centisecs", 1002 .procname = "dirty_writeback_centisecs",
diff --git a/mm/fremap.c b/mm/fremap.c
index 736ba7f3306..b6ec85abbb3 100644
--- a/mm/fremap.c
+++ b/mm/fremap.c
@@ -198,7 +198,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
198 flags &= MAP_NONBLOCK; 198 flags &= MAP_NONBLOCK;
199 get_file(file); 199 get_file(file);
200 addr = mmap_region(file, start, size, 200 addr = mmap_region(file, start, size,
201 flags, vma->vm_flags, pgoff, 1); 201 flags, vma->vm_flags, pgoff);
202 fput(file); 202 fput(file);
203 if (IS_ERR_VALUE(addr)) { 203 if (IS_ERR_VALUE(addr)) {
204 err = addr; 204 err = addr;
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 618e9830408..107da3d809a 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2269,12 +2269,18 @@ void hugetlb_change_protection(struct vm_area_struct *vma,
2269 2269
2270int hugetlb_reserve_pages(struct inode *inode, 2270int hugetlb_reserve_pages(struct inode *inode,
2271 long from, long to, 2271 long from, long to,
2272 struct vm_area_struct *vma) 2272 struct vm_area_struct *vma,
2273 int acctflag)
2273{ 2274{
2274 long ret, chg; 2275 long ret, chg;
2275 struct hstate *h = hstate_inode(inode); 2276 struct hstate *h = hstate_inode(inode);
2276 2277
2277 if (vma && vma->vm_flags & VM_NORESERVE) 2278 /*
2279 * Only apply hugepage reservation if asked. At fault time, an
2280 * attempt will be made for VM_NORESERVE to allocate a page
2281 * and filesystem quota without using reserves
2282 */
2283 if (acctflag & VM_NORESERVE)
2278 return 0; 2284 return 0;
2279 2285
2280 /* 2286 /*
@@ -2299,13 +2305,31 @@ int hugetlb_reserve_pages(struct inode *inode,
2299 if (chg < 0) 2305 if (chg < 0)
2300 return chg; 2306 return chg;
2301 2307
2308 /* There must be enough filesystem quota for the mapping */
2302 if (hugetlb_get_quota(inode->i_mapping, chg)) 2309 if (hugetlb_get_quota(inode->i_mapping, chg))
2303 return -ENOSPC; 2310 return -ENOSPC;
2311
2312 /*
2313 * Check enough hugepages are available for the reservation.
2314 * Hand back the quota if there are not
2315 */
2304 ret = hugetlb_acct_memory(h, chg); 2316 ret = hugetlb_acct_memory(h, chg);
2305 if (ret < 0) { 2317 if (ret < 0) {
2306 hugetlb_put_quota(inode->i_mapping, chg); 2318 hugetlb_put_quota(inode->i_mapping, chg);
2307 return ret; 2319 return ret;
2308 } 2320 }
2321
2322 /*
2323 * Account for the reservations made. Shared mappings record regions
2324 * that have reservations as they are shared by multiple VMAs.
2325 * When the last VMA disappears, the region map says how much
2326 * the reservation was and the page cache tells how much of
2327 * the reservation was consumed. Private mappings are per-VMA and
2328 * only the consumed reservations are tracked. When the VMA
2329 * disappears, the original reservation is the VMA size and the
2330 * consumed reservations are stored in the map. Hence, nothing
2331 * else has to be done for private mappings here
2332 */
2309 if (!vma || vma->vm_flags & VM_SHARED) 2333 if (!vma || vma->vm_flags & VM_SHARED)
2310 region_add(&inode->i_mapping->private_list, from, to); 2334 region_add(&inode->i_mapping->private_list, from, to);
2311 return 0; 2335 return 0;
diff --git a/mm/migrate.c b/mm/migrate.c
index 2bb4e1d6352..a9eff3f092f 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1129,7 +1129,7 @@ int migrate_vmas(struct mm_struct *mm, const nodemask_t *to,
1129 struct vm_area_struct *vma; 1129 struct vm_area_struct *vma;
1130 int err = 0; 1130 int err = 0;
1131 1131
1132 for(vma = mm->mmap; vma->vm_next && !err; vma = vma->vm_next) { 1132 for (vma = mm->mmap; vma && !err; vma = vma->vm_next) {
1133 if (vma->vm_ops && vma->vm_ops->migrate) { 1133 if (vma->vm_ops && vma->vm_ops->migrate) {
1134 err = vma->vm_ops->migrate(vma, to, from, flags); 1134 err = vma->vm_ops->migrate(vma, to, from, flags);
1135 if (err) 1135 if (err)
diff --git a/mm/mlock.c b/mm/mlock.c
index 028ec482fdd..037161d61b4 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -311,7 +311,10 @@ long mlock_vma_pages_range(struct vm_area_struct *vma,
311 is_vm_hugetlb_page(vma) || 311 is_vm_hugetlb_page(vma) ||
312 vma == get_gate_vma(current))) { 312 vma == get_gate_vma(current))) {
313 313
314 return __mlock_vma_pages_range(vma, start, end, 1); 314 __mlock_vma_pages_range(vma, start, end, 1);
315
316 /* Hide errors from mmap() and other callers */
317 return 0;
315 } 318 }
316 319
317 /* 320 /*
diff --git a/mm/mmap.c b/mm/mmap.c
index 214b6a258ee..00ced3ee49a 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -918,7 +918,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
918 struct inode *inode; 918 struct inode *inode;
919 unsigned int vm_flags; 919 unsigned int vm_flags;
920 int error; 920 int error;
921 int accountable = 1;
922 unsigned long reqprot = prot; 921 unsigned long reqprot = prot;
923 922
924 /* 923 /*
@@ -1019,8 +1018,6 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1019 return -EPERM; 1018 return -EPERM;
1020 vm_flags &= ~VM_MAYEXEC; 1019 vm_flags &= ~VM_MAYEXEC;
1021 } 1020 }
1022 if (is_file_hugepages(file))
1023 accountable = 0;
1024 1021
1025 if (!file->f_op || !file->f_op->mmap) 1022 if (!file->f_op || !file->f_op->mmap)
1026 return -ENODEV; 1023 return -ENODEV;
@@ -1053,8 +1050,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
1053 if (error) 1050 if (error)
1054 return error; 1051 return error;
1055 1052
1056 return mmap_region(file, addr, len, flags, vm_flags, pgoff, 1053 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
1057 accountable);
1058} 1054}
1059EXPORT_SYMBOL(do_mmap_pgoff); 1055EXPORT_SYMBOL(do_mmap_pgoff);
1060 1056
@@ -1092,17 +1088,23 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
1092 1088
1093/* 1089/*
1094 * We account for memory if it's a private writeable mapping, 1090 * We account for memory if it's a private writeable mapping,
1095 * and VM_NORESERVE wasn't set. 1091 * not hugepages and VM_NORESERVE wasn't set.
1096 */ 1092 */
1097static inline int accountable_mapping(unsigned int vm_flags) 1093static inline int accountable_mapping(struct file *file, unsigned int vm_flags)
1098{ 1094{
1095 /*
1096 * hugetlb has its own accounting separate from the core VM
1097 * VM_HUGETLB may not be set yet so we cannot check for that flag.
1098 */
1099 if (file && is_file_hugepages(file))
1100 return 0;
1101
1099 return (vm_flags & (VM_NORESERVE | VM_SHARED | VM_WRITE)) == VM_WRITE; 1102 return (vm_flags & (VM_NORESERVE | VM_SHARED | VM_WRITE)) == VM_WRITE;
1100} 1103}
1101 1104
1102unsigned long mmap_region(struct file *file, unsigned long addr, 1105unsigned long mmap_region(struct file *file, unsigned long addr,
1103 unsigned long len, unsigned long flags, 1106 unsigned long len, unsigned long flags,
1104 unsigned int vm_flags, unsigned long pgoff, 1107 unsigned int vm_flags, unsigned long pgoff)
1105 int accountable)
1106{ 1108{
1107 struct mm_struct *mm = current->mm; 1109 struct mm_struct *mm = current->mm;
1108 struct vm_area_struct *vma, *prev; 1110 struct vm_area_struct *vma, *prev;
@@ -1128,18 +1130,22 @@ munmap_back:
1128 1130
1129 /* 1131 /*
1130 * Set 'VM_NORESERVE' if we should not account for the 1132 * Set 'VM_NORESERVE' if we should not account for the
1131 * memory use of this mapping. We only honor MAP_NORESERVE 1133 * memory use of this mapping.
1132 * if we're allowed to overcommit memory.
1133 */ 1134 */
1134 if ((flags & MAP_NORESERVE) && sysctl_overcommit_memory != OVERCOMMIT_NEVER) 1135 if ((flags & MAP_NORESERVE)) {
1135 vm_flags |= VM_NORESERVE; 1136 /* We honor MAP_NORESERVE if allowed to overcommit */
1136 if (!accountable) 1137 if (sysctl_overcommit_memory != OVERCOMMIT_NEVER)
1137 vm_flags |= VM_NORESERVE; 1138 vm_flags |= VM_NORESERVE;
1139
1140 /* hugetlb applies strict overcommit unless MAP_NORESERVE */
1141 if (file && is_file_hugepages(file))
1142 vm_flags |= VM_NORESERVE;
1143 }
1138 1144
1139 /* 1145 /*
1140 * Private writable mapping: check memory availability 1146 * Private writable mapping: check memory availability
1141 */ 1147 */
1142 if (accountable_mapping(vm_flags)) { 1148 if (accountable_mapping(file, vm_flags)) {
1143 charged = len >> PAGE_SHIFT; 1149 charged = len >> PAGE_SHIFT;
1144 if (security_vm_enough_memory(charged)) 1150 if (security_vm_enough_memory(charged))
1145 return -ENOMEM; 1151 return -ENOMEM;
@@ -2078,12 +2084,8 @@ void exit_mmap(struct mm_struct *mm)
2078 unsigned long end; 2084 unsigned long end;
2079 2085
2080 /* mm's last user has gone, and its about to be pulled down */ 2086 /* mm's last user has gone, and its about to be pulled down */
2081 arch_exit_mmap(mm);
2082 mmu_notifier_release(mm); 2087 mmu_notifier_release(mm);
2083 2088
2084 if (!mm->mmap) /* Can happen if dup_mmap() received an OOM */
2085 return;
2086
2087 if (mm->locked_vm) { 2089 if (mm->locked_vm) {
2088 vma = mm->mmap; 2090 vma = mm->mmap;
2089 while (vma) { 2091 while (vma) {
@@ -2092,7 +2094,13 @@ void exit_mmap(struct mm_struct *mm)
2092 vma = vma->vm_next; 2094 vma = vma->vm_next;
2093 } 2095 }
2094 } 2096 }
2097
2098 arch_exit_mmap(mm);
2099
2095 vma = mm->mmap; 2100 vma = mm->mmap;
2101 if (!vma) /* Can happen if dup_mmap() received an OOM */
2102 return;
2103
2096 lru_add_drain(); 2104 lru_add_drain();
2097 flush_cache_mm(mm); 2105 flush_cache_mm(mm);
2098 tlb = tlb_gather_mmu(mm, 1); 2106 tlb = tlb_gather_mmu(mm, 1);
diff --git a/mm/mprotect.c b/mm/mprotect.c
index abe2694e13f..258197b76fb 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -151,10 +151,11 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
151 /* 151 /*
152 * If we make a private mapping writable we increase our commit; 152 * If we make a private mapping writable we increase our commit;
153 * but (without finer accounting) cannot reduce our commit if we 153 * but (without finer accounting) cannot reduce our commit if we
154 * make it unwritable again. 154 * make it unwritable again. hugetlb mapping were accounted for
155 * even if read-only so there is no need to account for them here
155 */ 156 */
156 if (newflags & VM_WRITE) { 157 if (newflags & VM_WRITE) {
157 if (!(oldflags & (VM_ACCOUNT|VM_WRITE| 158 if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_HUGETLB|
158 VM_SHARED|VM_NORESERVE))) { 159 VM_SHARED|VM_NORESERVE))) {
159 charged = nrpages; 160 charged = nrpages;
160 if (security_vm_enough_memory(charged)) 161 if (security_vm_enough_memory(charged))
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index dc32dae01e5..3c84128596b 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -209,7 +209,7 @@ int dirty_bytes_handler(struct ctl_table *table, int write,
209 struct file *filp, void __user *buffer, size_t *lenp, 209 struct file *filp, void __user *buffer, size_t *lenp,
210 loff_t *ppos) 210 loff_t *ppos)
211{ 211{
212 int old_bytes = vm_dirty_bytes; 212 unsigned long old_bytes = vm_dirty_bytes;
213 int ret; 213 int ret;
214 214
215 ret = proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos); 215 ret = proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos);
@@ -1051,20 +1051,23 @@ continue_unlock:
1051 } 1051 }
1052 } 1052 }
1053 1053
1054 if (nr_to_write > 0) 1054 if (nr_to_write > 0) {
1055 nr_to_write--; 1055 nr_to_write--;
1056 else if (wbc->sync_mode == WB_SYNC_NONE) { 1056 if (nr_to_write == 0 &&
1057 /* 1057 wbc->sync_mode == WB_SYNC_NONE) {
1058 * We stop writing back only if we are not 1058 /*
1059 * doing integrity sync. In case of integrity 1059 * We stop writing back only if we are
1060 * sync we have to keep going because someone 1060 * not doing integrity sync. In case of
1061 * may be concurrently dirtying pages, and we 1061 * integrity sync we have to keep going
1062 * might have synced a lot of newly appeared 1062 * because someone may be concurrently
1063 * dirty pages, but have not synced all of the 1063 * dirtying pages, and we might have
1064 * old dirty pages. 1064 * synced a lot of newly appeared dirty
1065 */ 1065 * pages, but have not synced all of the
1066 done = 1; 1066 * old dirty pages.
1067 break; 1067 */
1068 done = 1;
1069 break;
1070 }
1068 } 1071 }
1069 1072
1070 if (wbc->nonblocking && bdi_write_congested(bdi)) { 1073 if (wbc->nonblocking && bdi_write_congested(bdi)) {
@@ -1076,7 +1079,7 @@ continue_unlock:
1076 pagevec_release(&pvec); 1079 pagevec_release(&pvec);
1077 cond_resched(); 1080 cond_resched();
1078 } 1081 }
1079 if (!cycled) { 1082 if (!cycled && !done) {
1080 /* 1083 /*
1081 * range_cyclic: 1084 * range_cyclic:
1082 * We hit the last page and there is more work to be done: wrap 1085 * We hit the last page and there is more work to be done: wrap
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 7006a11350c..ceecfbb143f 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -114,7 +114,8 @@ static int __init_refok init_section_page_cgroup(unsigned long pfn)
114 nid = page_to_nid(pfn_to_page(pfn)); 114 nid = page_to_nid(pfn_to_page(pfn));
115 table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION; 115 table_size = sizeof(struct page_cgroup) * PAGES_PER_SECTION;
116 if (slab_is_available()) { 116 if (slab_is_available()) {
117 base = kmalloc_node(table_size, GFP_KERNEL, nid); 117 base = kmalloc_node(table_size,
118 GFP_KERNEL | __GFP_NOWARN, nid);
118 if (!base) 119 if (!base)
119 base = vmalloc_node(table_size, nid); 120 base = vmalloc_node(table_size, nid);
120 } else { 121 } else {
diff --git a/mm/rmap.c b/mm/rmap.c
index ac4af8cffbf..16521664010 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1072,7 +1072,8 @@ static int try_to_unmap_file(struct page *page, int unlock, int migration)
1072 spin_lock(&mapping->i_mmap_lock); 1072 spin_lock(&mapping->i_mmap_lock);
1073 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) { 1073 vma_prio_tree_foreach(vma, &iter, &mapping->i_mmap, pgoff, pgoff) {
1074 if (MLOCK_PAGES && unlikely(unlock)) { 1074 if (MLOCK_PAGES && unlikely(unlock)) {
1075 if (!(vma->vm_flags & VM_LOCKED)) 1075 if (!((vma->vm_flags & VM_LOCKED) &&
1076 page_mapped_in_vma(page, vma)))
1076 continue; /* must visit all vmas */ 1077 continue; /* must visit all vmas */
1077 ret = SWAP_MLOCK; 1078 ret = SWAP_MLOCK;
1078 } else { 1079 } else {
diff --git a/mm/slab.c b/mm/slab.c
index ddc41f337d5..4d00855629c 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4457,3 +4457,4 @@ size_t ksize(const void *objp)
4457 4457
4458 return obj_size(virt_to_cache(objp)); 4458 return obj_size(virt_to_cache(objp));
4459} 4459}
4460EXPORT_SYMBOL(ksize);
diff --git a/mm/slob.c b/mm/slob.c
index bf7e8fc3aed..52bc8a2bd9e 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -521,6 +521,7 @@ size_t ksize(const void *block)
521 } else 521 } else
522 return sp->page.private; 522 return sp->page.private;
523} 523}
524EXPORT_SYMBOL(ksize);
524 525
525struct kmem_cache { 526struct kmem_cache {
526 unsigned int size, align; 527 unsigned int size, align;
diff --git a/mm/slub.c b/mm/slub.c
index bdc9abb08a2..0280eee6cf3 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -2736,6 +2736,7 @@ size_t ksize(const void *object)
2736 */ 2736 */
2737 return s->size; 2737 return s->size;
2738} 2738}
2739EXPORT_SYMBOL(ksize);
2739 2740
2740void kfree(const void *x) 2741void kfree(const void *x)
2741{ 2742{
diff --git a/net/9p/protocol.c b/net/9p/protocol.c
index dcd7666824b..fc70147c771 100644
--- a/net/9p/protocol.c
+++ b/net/9p/protocol.c
@@ -29,6 +29,7 @@
29#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/uaccess.h> 30#include <linux/uaccess.h>
31#include <linux/sched.h> 31#include <linux/sched.h>
32#include <linux/types.h>
32#include <net/9p/9p.h> 33#include <net/9p/9p.h>
33#include <net/9p/client.h> 34#include <net/9p/client.h>
34#include "protocol.h" 35#include "protocol.h"
@@ -160,29 +161,32 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
160 break; 161 break;
161 case 'w':{ 162 case 'w':{
162 int16_t *val = va_arg(ap, int16_t *); 163 int16_t *val = va_arg(ap, int16_t *);
163 if (pdu_read(pdu, val, sizeof(*val))) { 164 __le16 le_val;
165 if (pdu_read(pdu, &le_val, sizeof(le_val))) {
164 errcode = -EFAULT; 166 errcode = -EFAULT;
165 break; 167 break;
166 } 168 }
167 *val = cpu_to_le16(*val); 169 *val = le16_to_cpu(le_val);
168 } 170 }
169 break; 171 break;
170 case 'd':{ 172 case 'd':{
171 int32_t *val = va_arg(ap, int32_t *); 173 int32_t *val = va_arg(ap, int32_t *);
172 if (pdu_read(pdu, val, sizeof(*val))) { 174 __le32 le_val;
175 if (pdu_read(pdu, &le_val, sizeof(le_val))) {
173 errcode = -EFAULT; 176 errcode = -EFAULT;
174 break; 177 break;
175 } 178 }
176 *val = cpu_to_le32(*val); 179 *val = le32_to_cpu(le_val);
177 } 180 }
178 break; 181 break;
179 case 'q':{ 182 case 'q':{
180 int64_t *val = va_arg(ap, int64_t *); 183 int64_t *val = va_arg(ap, int64_t *);
181 if (pdu_read(pdu, val, sizeof(*val))) { 184 __le64 le_val;
185 if (pdu_read(pdu, &le_val, sizeof(le_val))) {
182 errcode = -EFAULT; 186 errcode = -EFAULT;
183 break; 187 break;
184 } 188 }
185 *val = cpu_to_le64(*val); 189 *val = le64_to_cpu(le_val);
186 } 190 }
187 break; 191 break;
188 case 's':{ 192 case 's':{
@@ -362,19 +366,19 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap)
362 } 366 }
363 break; 367 break;
364 case 'w':{ 368 case 'w':{
365 int16_t val = va_arg(ap, int); 369 __le16 val = cpu_to_le16(va_arg(ap, int));
366 if (pdu_write(pdu, &val, sizeof(val))) 370 if (pdu_write(pdu, &val, sizeof(val)))
367 errcode = -EFAULT; 371 errcode = -EFAULT;
368 } 372 }
369 break; 373 break;
370 case 'd':{ 374 case 'd':{
371 int32_t val = va_arg(ap, int32_t); 375 __le32 val = cpu_to_le32(va_arg(ap, int32_t));
372 if (pdu_write(pdu, &val, sizeof(val))) 376 if (pdu_write(pdu, &val, sizeof(val)))
373 errcode = -EFAULT; 377 errcode = -EFAULT;
374 } 378 }
375 break; 379 break;
376 case 'q':{ 380 case 'q':{
377 int64_t val = va_arg(ap, int64_t); 381 __le64 val = cpu_to_le64(va_arg(ap, int64_t));
378 if (pdu_write(pdu, &val, sizeof(val))) 382 if (pdu_write(pdu, &val, sizeof(val)))
379 errcode = -EFAULT; 383 errcode = -EFAULT;
380 } 384 }
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index bdd9ccea17c..d2c27c808d3 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -67,6 +67,11 @@ static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
67{ 67{
68 struct net_device *indev; 68 struct net_device *indev;
69 69
70 if (skb_warn_if_lro(skb)) {
71 kfree_skb(skb);
72 return;
73 }
74
70 indev = skb->dev; 75 indev = skb->dev;
71 skb->dev = to->dev; 76 skb->dev = to->dev;
72 skb_forward_csum(skb); 77 skb_forward_csum(skb);
@@ -89,7 +94,7 @@ void br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
89/* called with rcu_read_lock */ 94/* called with rcu_read_lock */
90void br_forward(const struct net_bridge_port *to, struct sk_buff *skb) 95void br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
91{ 96{
92 if (!skb_warn_if_lro(skb) && should_deliver(to, skb)) { 97 if (should_deliver(to, skb)) {
93 __br_forward(to, skb); 98 __br_forward(to, skb);
94 return; 99 return;
95 } 100 }
diff --git a/net/core/dev.c b/net/core/dev.c
index 5379b0c1190..a17e0066236 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1090,7 +1090,7 @@ int dev_open(struct net_device *dev)
1090 /* 1090 /*
1091 * Enable NET_DMA 1091 * Enable NET_DMA
1092 */ 1092 */
1093 dmaengine_get(); 1093 net_dmaengine_get();
1094 1094
1095 /* 1095 /*
1096 * Initialize multicasting status 1096 * Initialize multicasting status
@@ -1172,7 +1172,7 @@ int dev_close(struct net_device *dev)
1172 /* 1172 /*
1173 * Shutdown NET_DMA 1173 * Shutdown NET_DMA
1174 */ 1174 */
1175 dmaengine_put(); 1175 net_dmaengine_put();
1176 1176
1177 return 0; 1177 return 0;
1178} 1178}
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index f66c58df895..278a142d104 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1994,8 +1994,8 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
1994 if (!net_eq(neigh_parms_net(p), net)) 1994 if (!net_eq(neigh_parms_net(p), net))
1995 continue; 1995 continue;
1996 1996
1997 if (nidx++ < neigh_skip) 1997 if (nidx < neigh_skip)
1998 continue; 1998 goto next;
1999 1999
2000 if (neightbl_fill_param_info(skb, tbl, p, 2000 if (neightbl_fill_param_info(skb, tbl, p,
2001 NETLINK_CB(cb->skb).pid, 2001 NETLINK_CB(cb->skb).pid,
@@ -2003,6 +2003,8 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
2003 RTM_NEWNEIGHTBL, 2003 RTM_NEWNEIGHTBL,
2004 NLM_F_MULTI) <= 0) 2004 NLM_F_MULTI) <= 0)
2005 goto out; 2005 goto out;
2006 next:
2007 nidx++;
2006 } 2008 }
2007 2009
2008 neigh_skip = 0; 2010 neigh_skip = 0;
@@ -2082,12 +2084,10 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
2082 if (h > s_h) 2084 if (h > s_h)
2083 s_idx = 0; 2085 s_idx = 0;
2084 for (n = tbl->hash_buckets[h], idx = 0; n; n = n->next) { 2086 for (n = tbl->hash_buckets[h], idx = 0; n; n = n->next) {
2085 int lidx;
2086 if (dev_net(n->dev) != net) 2087 if (dev_net(n->dev) != net)
2087 continue; 2088 continue;
2088 lidx = idx++; 2089 if (idx < s_idx)
2089 if (lidx < s_idx) 2090 goto next;
2090 continue;
2091 if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid, 2091 if (neigh_fill_info(skb, n, NETLINK_CB(cb->skb).pid,
2092 cb->nlh->nlmsg_seq, 2092 cb->nlh->nlmsg_seq,
2093 RTM_NEWNEIGH, 2093 RTM_NEWNEIGH,
@@ -2096,6 +2096,8 @@ static int neigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb,
2096 rc = -1; 2096 rc = -1;
2097 goto out; 2097 goto out;
2098 } 2098 }
2099 next:
2100 idx++;
2099 } 2101 }
2100 } 2102 }
2101 read_unlock_bh(&tbl->lock); 2103 read_unlock_bh(&tbl->lock);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index cc3a0a06c00..c47c989cb1f 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1234,8 +1234,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
1234 struct udphdr *uh; 1234 struct udphdr *uh;
1235 unsigned short ulen; 1235 unsigned short ulen;
1236 struct rtable *rt = (struct rtable*)skb->dst; 1236 struct rtable *rt = (struct rtable*)skb->dst;
1237 __be32 saddr = ip_hdr(skb)->saddr; 1237 __be32 saddr, daddr;
1238 __be32 daddr = ip_hdr(skb)->daddr;
1239 struct net *net = dev_net(skb->dev); 1238 struct net *net = dev_net(skb->dev);
1240 1239
1241 /* 1240 /*
@@ -1259,6 +1258,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
1259 if (udp4_csum_init(skb, uh, proto)) 1258 if (udp4_csum_init(skb, uh, proto))
1260 goto csum_error; 1259 goto csum_error;
1261 1260
1261 saddr = ip_hdr(skb)->saddr;
1262 daddr = ip_hdr(skb)->daddr;
1263
1262 if (rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST)) 1264 if (rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST))
1263 return __udp4_lib_mcast_deliver(net, skb, uh, 1265 return __udp4_lib_mcast_deliver(net, skb, uh,
1264 saddr, daddr, udptable); 1266 saddr, daddr, udptable);
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index c62dd247774..7712578bdc6 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -323,17 +323,21 @@ static struct ip6_flowlabel *
323fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval, 323fl_create(struct net *net, struct in6_flowlabel_req *freq, char __user *optval,
324 int optlen, int *err_p) 324 int optlen, int *err_p)
325{ 325{
326 struct ip6_flowlabel *fl; 326 struct ip6_flowlabel *fl = NULL;
327 int olen; 327 int olen;
328 int addr_type; 328 int addr_type;
329 int err; 329 int err;
330 330
331 olen = optlen - CMSG_ALIGN(sizeof(*freq));
332 err = -EINVAL;
333 if (olen > 64 * 1024)
334 goto done;
335
331 err = -ENOMEM; 336 err = -ENOMEM;
332 fl = kzalloc(sizeof(*fl), GFP_KERNEL); 337 fl = kzalloc(sizeof(*fl), GFP_KERNEL);
333 if (fl == NULL) 338 if (fl == NULL)
334 goto done; 339 goto done;
335 340
336 olen = optlen - CMSG_ALIGN(sizeof(*freq));
337 if (olen > 0) { 341 if (olen > 0) {
338 struct msghdr msg; 342 struct msghdr msg;
339 struct flowi flowi; 343 struct flowi flowi;
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 58e2b0d9375..d994c55a5b1 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -249,8 +249,8 @@ static struct ip6_tnl *ip6_tnl_create(struct net *net, struct ip6_tnl_parm *p)
249 } 249 }
250 250
251 t = netdev_priv(dev); 251 t = netdev_priv(dev);
252 ip6_tnl_dev_init(dev);
253 t->parms = *p; 252 t->parms = *p;
253 ip6_tnl_dev_init(dev);
254 254
255 if ((err = register_netdevice(dev)) < 0) 255 if ((err = register_netdevice(dev)) < 0)
256 goto failed_free; 256 goto failed_free;
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index c455cf4ee75..c323643ffcf 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -49,8 +49,19 @@ static bool icmpv6_pkt_to_tuple(const struct sk_buff *skb,
49static const u_int8_t invmap[] = { 49static const u_int8_t invmap[] = {
50 [ICMPV6_ECHO_REQUEST - 128] = ICMPV6_ECHO_REPLY + 1, 50 [ICMPV6_ECHO_REQUEST - 128] = ICMPV6_ECHO_REPLY + 1,
51 [ICMPV6_ECHO_REPLY - 128] = ICMPV6_ECHO_REQUEST + 1, 51 [ICMPV6_ECHO_REPLY - 128] = ICMPV6_ECHO_REQUEST + 1,
52 [ICMPV6_NI_QUERY - 128] = ICMPV6_NI_QUERY + 1, 52 [ICMPV6_NI_QUERY - 128] = ICMPV6_NI_REPLY + 1,
53 [ICMPV6_NI_REPLY - 128] = ICMPV6_NI_REPLY +1 53 [ICMPV6_NI_REPLY - 128] = ICMPV6_NI_QUERY +1
54};
55
56static const u_int8_t noct_valid_new[] = {
57 [ICMPV6_MGM_QUERY - 130] = 1,
58 [ICMPV6_MGM_REPORT -130] = 1,
59 [ICMPV6_MGM_REDUCTION - 130] = 1,
60 [NDISC_ROUTER_SOLICITATION - 130] = 1,
61 [NDISC_ROUTER_ADVERTISEMENT - 130] = 1,
62 [NDISC_NEIGHBOUR_SOLICITATION - 130] = 1,
63 [NDISC_NEIGHBOUR_ADVERTISEMENT - 130] = 1,
64 [ICMPV6_MLD2_REPORT - 130] = 1
54}; 65};
55 66
56static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple, 67static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,
@@ -178,6 +189,7 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
178{ 189{
179 const struct icmp6hdr *icmp6h; 190 const struct icmp6hdr *icmp6h;
180 struct icmp6hdr _ih; 191 struct icmp6hdr _ih;
192 int type;
181 193
182 icmp6h = skb_header_pointer(skb, dataoff, sizeof(_ih), &_ih); 194 icmp6h = skb_header_pointer(skb, dataoff, sizeof(_ih), &_ih);
183 if (icmp6h == NULL) { 195 if (icmp6h == NULL) {
@@ -194,6 +206,15 @@ icmpv6_error(struct net *net, struct sk_buff *skb, unsigned int dataoff,
194 return -NF_ACCEPT; 206 return -NF_ACCEPT;
195 } 207 }
196 208
209 type = icmp6h->icmp6_type - 130;
210 if (type >= 0 && type < sizeof(noct_valid_new) &&
211 noct_valid_new[type]) {
212 skb->nfct = &nf_conntrack_untracked.ct_general;
213 skb->nfctinfo = IP_CT_NEW;
214 nf_conntrack_get(skb->nfct);
215 return NF_ACCEPT;
216 }
217
197 /* is not error message ? */ 218 /* is not error message ? */
198 if (icmp6h->icmp6_type >= 128) 219 if (icmp6h->icmp6_type >= 128)
199 return NF_ACCEPT; 220 return NF_ACCEPT;
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index c32a7e8e3a1..cb78aa00399 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -434,7 +434,7 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
434 } else 434 } else
435 return NOTIFY_DONE; 435 return NOTIFY_DONE;
436 436
437 if (!nfnetlink_has_listeners(group)) 437 if (!item->report && !nfnetlink_has_listeners(group))
438 return NOTIFY_DONE; 438 return NOTIFY_DONE;
439 439
440 skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); 440 skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
@@ -1215,6 +1215,16 @@ ctnetlink_create_conntrack(struct nlattr *cda[],
1215 } 1215 }
1216 } 1216 }
1217 1217
1218#ifdef CONFIG_NF_NAT_NEEDED
1219 if (cda[CTA_NAT_SEQ_ADJ_ORIG] || cda[CTA_NAT_SEQ_ADJ_REPLY]) {
1220 err = ctnetlink_change_nat_seq_adj(ct, cda);
1221 if (err < 0) {
1222 rcu_read_unlock();
1223 goto err;
1224 }
1225 }
1226#endif
1227
1218 if (cda[CTA_PROTOINFO]) { 1228 if (cda[CTA_PROTOINFO]) {
1219 err = ctnetlink_change_protoinfo(ct, cda); 1229 err = ctnetlink_change_protoinfo(ct, cda);
1220 if (err < 0) { 1230 if (err < 0) {
@@ -1492,7 +1502,8 @@ static int ctnetlink_expect_event(struct notifier_block *this,
1492 } else 1502 } else
1493 return NOTIFY_DONE; 1503 return NOTIFY_DONE;
1494 1504
1495 if (!nfnetlink_has_listeners(NFNLGRP_CONNTRACK_EXP_NEW)) 1505 if (!item->report &&
1506 !nfnetlink_has_listeners(NFNLGRP_CONNTRACK_EXP_NEW))
1496 return NOTIFY_DONE; 1507 return NOTIFY_DONE;
1497 1508
1498 skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC); 1509 skb = alloc_skb(NLMSG_GOODSIZE, GFP_ATOMIC);
diff --git a/net/netfilter/xt_sctp.c b/net/netfilter/xt_sctp.c
index e223cb43ae8..a189ada9128 100644
--- a/net/netfilter/xt_sctp.c
+++ b/net/netfilter/xt_sctp.c
@@ -105,7 +105,7 @@ match_packet(const struct sk_buff *skb,
105 105
106 switch (chunk_match_type) { 106 switch (chunk_match_type) {
107 case SCTP_CHUNK_MATCH_ALL: 107 case SCTP_CHUNK_MATCH_ALL:
108 return SCTP_CHUNKMAP_IS_CLEAR(info->chunkmap); 108 return SCTP_CHUNKMAP_IS_CLEAR(chunkmapcopy);
109 case SCTP_CHUNK_MATCH_ANY: 109 case SCTP_CHUNK_MATCH_ANY:
110 return false; 110 return false;
111 case SCTP_CHUNK_MATCH_ONLY: 111 case SCTP_CHUNK_MATCH_ONLY:
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index d7d2bed7a69..eac5e7bb736 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -284,13 +284,13 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
284 if (IS_ERR(trans)) { 284 if (IS_ERR(trans)) {
285 call = ERR_CAST(trans); 285 call = ERR_CAST(trans);
286 trans = NULL; 286 trans = NULL;
287 goto out; 287 goto out_notrans;
288 } 288 }
289 } else { 289 } else {
290 trans = rx->trans; 290 trans = rx->trans;
291 if (!trans) { 291 if (!trans) {
292 call = ERR_PTR(-ENOTCONN); 292 call = ERR_PTR(-ENOTCONN);
293 goto out; 293 goto out_notrans;
294 } 294 }
295 atomic_inc(&trans->usage); 295 atomic_inc(&trans->usage);
296 } 296 }
@@ -315,6 +315,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
315 rxrpc_put_bundle(trans, bundle); 315 rxrpc_put_bundle(trans, bundle);
316out: 316out:
317 rxrpc_put_transport(trans); 317 rxrpc_put_transport(trans);
318out_notrans:
318 release_sock(&rx->sk); 319 release_sock(&rx->sk);
319 _leave(" = %p", call); 320 _leave(" = %p", call);
320 return call; 321 return call;
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 8bb83a100ed..0f11870116d 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1827,6 +1827,40 @@ sub reset_state {
1827 $state = 0; 1827 $state = 0;
1828} 1828}
1829 1829
1830sub syscall_munge() {
1831 my $void = 0;
1832
1833 $prototype =~ s@[\r\n\t]+@ @gos; # strip newlines/CR's/tabs
1834## if ($prototype =~ m/SYSCALL_DEFINE0\s*\(\s*(a-zA-Z0-9_)*\s*\)/) {
1835 if ($prototype =~ m/SYSCALL_DEFINE0/) {
1836 $void = 1;
1837## $prototype = "long sys_$1(void)";
1838 }
1839
1840 $prototype =~ s/SYSCALL_DEFINE.*\(/long sys_/; # fix return type & func name
1841 if ($prototype =~ m/long (sys_.*?),/) {
1842 $prototype =~ s/,/\(/;
1843 } elsif ($void) {
1844 $prototype =~ s/\)/\(void\)/;
1845 }
1846
1847 # now delete all of the odd-number commas in $prototype
1848 # so that arg types & arg names don't have a comma between them
1849 my $count = 0;
1850 my $len = length($prototype);
1851 if ($void) {
1852 $len = 0; # skip the for-loop
1853 }
1854 for (my $ix = 0; $ix < $len; $ix++) {
1855 if (substr($prototype, $ix, 1) eq ',') {
1856 $count++;
1857 if ($count % 2 == 1) {
1858 substr($prototype, $ix, 1) = ' ';
1859 }
1860 }
1861 }
1862}
1863
1830sub process_state3_function($$) { 1864sub process_state3_function($$) {
1831 my $x = shift; 1865 my $x = shift;
1832 my $file = shift; 1866 my $file = shift;
@@ -1839,11 +1873,15 @@ sub process_state3_function($$) {
1839 elsif ($x =~ /([^\{]*)/) { 1873 elsif ($x =~ /([^\{]*)/) {
1840 $prototype .= $1; 1874 $prototype .= $1;
1841 } 1875 }
1876
1842 if (($x =~ /\{/) || ($x =~ /\#\s*define/) || ($x =~ /;/)) { 1877 if (($x =~ /\{/) || ($x =~ /\#\s*define/) || ($x =~ /;/)) {
1843 $prototype =~ s@/\*.*?\*/@@gos; # strip comments. 1878 $prototype =~ s@/\*.*?\*/@@gos; # strip comments.
1844 $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's. 1879 $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's.
1845 $prototype =~ s@^\s+@@gos; # strip leading spaces 1880 $prototype =~ s@^\s+@@gos; # strip leading spaces
1846 dump_function($prototype,$file); 1881 if ($prototype =~ /SYSCALL_DEFINE/) {
1882 syscall_munge();
1883 }
1884 dump_function($prototype, $file);
1847 reset_state(); 1885 reset_state();
1848 } 1886 }
1849} 1887}
diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c
index 89096e811a4..772901e41ec 100644
--- a/sound/arm/aaci.c
+++ b/sound/arm/aaci.c
@@ -90,7 +90,7 @@ static void aaci_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
90 */ 90 */
91 do { 91 do {
92 v = readl(aaci->base + AACI_SLFR); 92 v = readl(aaci->base + AACI_SLFR);
93 } while ((v & (SLFR_1TXB|SLFR_2TXB)) && timeout--); 93 } while ((v & (SLFR_1TXB|SLFR_2TXB)) && --timeout);
94 94
95 if (!timeout) 95 if (!timeout)
96 dev_err(&aaci->dev->dev, 96 dev_err(&aaci->dev->dev,
@@ -126,7 +126,7 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
126 */ 126 */
127 do { 127 do {
128 v = readl(aaci->base + AACI_SLFR); 128 v = readl(aaci->base + AACI_SLFR);
129 } while ((v & SLFR_1TXB) && timeout--); 129 } while ((v & SLFR_1TXB) && --timeout);
130 130
131 if (!timeout) { 131 if (!timeout) {
132 dev_err(&aaci->dev->dev, "timeout on slot 1 TX busy\n"); 132 dev_err(&aaci->dev->dev, "timeout on slot 1 TX busy\n");
@@ -147,7 +147,7 @@ static unsigned short aaci_ac97_read(struct snd_ac97 *ac97, unsigned short reg)
147 do { 147 do {
148 cond_resched(); 148 cond_resched();
149 v = readl(aaci->base + AACI_SLFR) & (SLFR_1RXV|SLFR_2RXV); 149 v = readl(aaci->base + AACI_SLFR) & (SLFR_1RXV|SLFR_2RXV);
150 } while ((v != (SLFR_1RXV|SLFR_2RXV)) && timeout--); 150 } while ((v != (SLFR_1RXV|SLFR_2RXV)) && --timeout);
151 151
152 if (!timeout) { 152 if (!timeout) {
153 dev_err(&aaci->dev->dev, "timeout on RX valid\n"); 153 dev_err(&aaci->dev->dev, "timeout on RX valid\n");
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
index 0bcf14640fd..84714a65e5c 100644
--- a/sound/drivers/Kconfig
+++ b/sound/drivers/Kconfig
@@ -33,7 +33,7 @@ if SND_DRIVERS
33 33
34config SND_PCSP 34config SND_PCSP
35 tristate "PC-Speaker support (READ HELP!)" 35 tristate "PC-Speaker support (READ HELP!)"
36 depends on PCSPKR_PLATFORM && X86_PC && HIGH_RES_TIMERS 36 depends on PCSPKR_PLATFORM && X86 && HIGH_RES_TIMERS
37 depends on INPUT 37 depends on INPUT
38 depends on EXPERIMENTAL 38 depends on EXPERIMENTAL
39 select SND_PCM 39 select SND_PCM