ia64/linux-2.6.18-xen.hg

changeset 240:3e8752eb6d9c

Apply patch for 2.6.18.8.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Wed Oct 03 10:00:44 2007 +0100 (2007-10-03)
parents aafef975e518
children 24f70cb16e0a
files Documentation/dontdiff Documentation/sysctl/vm.txt Makefile arch/alpha/Kconfig arch/arm/kernel/calls.S arch/i386/Kconfig.cpu arch/i386/kernel/alternative.c arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c arch/i386/kernel/microcode.c arch/i386/kernel/smpboot.c arch/i386/mm/boot_ioremap.c arch/i386/pci/irq.c arch/ia64/kernel/acpi.c arch/ia64/kernel/numa.c arch/ia64/kernel/topology.c arch/ia64/sn/kernel/bte.c arch/m32r/kernel/entry.S arch/powerpc/Kconfig arch/powerpc/configs/pseries_defconfig arch/powerpc/kernel/traps.c arch/ppc/kernel/traps.c arch/s390/Kconfig arch/s390/lib/Makefile arch/s390/lib/div64.c arch/s390/lib/uaccess.S arch/s390/lib/uaccess64.S arch/sh/kernel/process.c arch/sparc/kernel/entry.S arch/sparc64/kernel/central.c arch/sparc64/kernel/entry.S arch/sparc64/kernel/of_device.c arch/sparc64/kernel/pci_common.c arch/sparc64/kernel/pci_iommu.c arch/sparc64/kernel/pci_sabre.c arch/sparc64/kernel/prom.c arch/sparc64/kernel/time.c arch/sparc64/mm/init.c arch/um/Kconfig arch/um/Makefile-x86_64 arch/um/include/common-offsets.h arch/um/include/kern_util.h arch/um/include/sysdep-i386/kernel-offsets.h arch/um/include/sysdep-x86_64/kernel-offsets.h arch/um/os-Linux/process.c arch/um/os-Linux/sys-i386/tls.c arch/um/os-Linux/tls.c arch/um/sys-x86_64/stub_segv.c arch/x86_64/ia32/ptrace32.c arch/x86_64/kernel/entry.S arch/x86_64/kernel/pci-calgary.c arch/x86_64/kernel/process.c arch/x86_64/kernel/setup.c arch/x86_64/kernel/setup64.c arch/x86_64/kernel/time.c block/elevator.c block/ll_rw_blk.c block/scsi_ioctl.c drivers/block/DAC960.c drivers/block/cciss.c drivers/block/cpqarray.c drivers/char/agp/generic.c drivers/char/agp/intel-agp.c drivers/char/hw_random/intel-rng.c drivers/char/ipmi/ipmi_si_intf.c drivers/char/isicom.c drivers/char/mem.c drivers/char/rtc.c drivers/char/watchdog/sc1200wdt.c drivers/clocksource/scx200_hrt.c drivers/cpufreq/cpufreq_stats.c drivers/i2c/chips/ds1337.c drivers/ide/pci/generic.c drivers/ide/ppc/pmac.c drivers/ieee1394/ohci1394.c drivers/infiniband/core/mad.c drivers/infiniband/hw/mthca/mthca_cq.c drivers/infiniband/hw/mthca/mthca_mad.c drivers/infiniband/hw/mthca/mthca_qp.c drivers/infiniband/hw/mthca/mthca_srq.c drivers/infiniband/ulp/ipoib/ipoib_ib.c drivers/infiniband/ulp/srp/ib_srp.c drivers/infiniband/ulp/srp/ib_srp.h drivers/input/mouse/psmouse-base.c drivers/isdn/capi/capidrv.c drivers/isdn/hisax/config.c drivers/isdn/i4l/isdn_common.c drivers/isdn/icn/icn.c drivers/isdn/isdnloop/isdnloop.c drivers/isdn/pcbit/drv.c drivers/macintosh/via-pmu-backlight.c drivers/md/dm-crypt.c drivers/md/dm-snap.c drivers/md/md.c drivers/md/multipath.c drivers/md/raid10.c drivers/media/Kconfig drivers/media/dvb/b2c2/flexcop-fe-tuner.c drivers/media/dvb/dvb-core/dvb_net.c drivers/media/dvb/frontends/cx24123.c drivers/media/dvb/frontends/dvb-pll.c drivers/media/dvb/frontends/lgdt330x.c drivers/media/video/cx88/cx88-cards.c drivers/media/video/cx88/cx88-dvb.c drivers/media/video/ks0127.c drivers/media/video/msp3400-driver.c drivers/media/video/msp3400-driver.h drivers/media/video/msp3400-kthreads.c drivers/media/video/pvrusb2/Kconfig drivers/media/video/pvrusb2/pvrusb2-ctrl.c drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h drivers/media/video/pvrusb2/pvrusb2-hdw.c drivers/media/video/pvrusb2/pvrusb2-v4l2.c drivers/media/video/saa7134/saa7134-dvb.c drivers/media/video/tuner-simple.c drivers/media/video/tuner-types.c drivers/media/video/tveeprom.c drivers/media/video/usbvideo/quickcam_messenger.h drivers/media/video/video-buf.c drivers/media/video/videodev.c drivers/net/bonding/bond_main.c drivers/net/e1000/e1000_main.c drivers/net/forcedeth.c drivers/net/lp486e.c drivers/net/mv643xx_eth.c drivers/net/sky2.c drivers/net/sky2.h drivers/net/sunhme.c drivers/net/tg3.c drivers/net/wireless/bcm43xx/bcm43xx.h drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c drivers/net/wireless/bcm43xx/bcm43xx_debugfs.h drivers/net/wireless/bcm43xx/bcm43xx_dma.c drivers/net/wireless/bcm43xx/bcm43xx_dma.h drivers/net/wireless/bcm43xx/bcm43xx_leds.c drivers/net/wireless/bcm43xx/bcm43xx_main.c drivers/net/wireless/bcm43xx/bcm43xx_main.h drivers/net/wireless/bcm43xx/bcm43xx_phy.c drivers/net/wireless/bcm43xx/bcm43xx_pio.c drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c drivers/net/wireless/bcm43xx/bcm43xx_wx.c drivers/net/wireless/bcm43xx/bcm43xx_xmit.h drivers/net/wireless/zd1211rw/zd_chip.c drivers/pci/pci-sysfs.c drivers/pci/quirks.c drivers/pcmcia/ds.c drivers/rtc/rtc-max6902.c drivers/rtc/rtc-pcf8563.c drivers/scsi/aic7xxx/aic7xxx_osm.c drivers/scsi/sata_mv.c drivers/scsi/scsi_lib.c drivers/serial/serial_core.c drivers/serial/serial_cs.c drivers/usb/class/usblp.c drivers/usb/core/devio.c drivers/usb/core/notify.c drivers/usb/core/usb.h drivers/usb/gadget/ether.c drivers/usb/input/hid-core.c drivers/usb/input/hid-input.c drivers/usb/input/hid.h drivers/usb/input/usbtouchscreen.c drivers/video/fbmem.c drivers/video/fbsysfs.c drivers/video/nvidia/nv_hw.c drivers/video/nvidia/nv_setup.c drivers/video/nvidia/nv_type.h drivers/video/nvidia/nvidia.c fs/buffer.c fs/cifs/CHANGES fs/cifs/file.c fs/cifs/inode.c fs/compat.c fs/ext2/super.c fs/ext3/super.c fs/fuse/dir.c fs/fuse/file.c fs/fuse/inode.c fs/hfs/super.c fs/jbd/commit.c fs/jfs/jfs_imap.c fs/nfs/dir.c fs/nfsd/nfs2acl.c fs/splice.c fs/sysfs/file.c include/Kbuild include/asm-alpha/Kbuild include/asm-arm/elf.h include/asm-arm/page.h include/asm-arm/unistd.h include/asm-arm26/Kbuild include/asm-cris/Kbuild include/asm-cris/arch-v10/Kbuild include/asm-cris/arch-v32/Kbuild include/asm-cris/byteorder.h include/asm-cris/elf.h include/asm-cris/page.h include/asm-cris/posix_types.h include/asm-cris/unistd.h include/asm-generic/Kbuild include/asm-generic/Kbuild.asm include/asm-generic/audit_change_attr.h include/asm-generic/audit_dir_write.h include/asm-h8300/page.h include/asm-i386/Kbuild include/asm-ia64/Kbuild include/asm-ia64/numa.h include/asm-m32r/page.h include/asm-m32r/ptrace.h include/asm-m32r/sigcontext.h include/asm-m32r/signal.h include/asm-m32r/unistd.h include/asm-m32r/user.h include/asm-m68knommu/page.h include/asm-powerpc/Kbuild include/asm-powerpc/current.h include/asm-powerpc/ptrace.h include/asm-s390/Kbuild include/asm-s390/div64.h include/asm-sh/page.h include/asm-sh/ptrace.h include/asm-sh64/page.h include/asm-sh64/shmparam.h include/asm-sh64/signal.h include/asm-sh64/user.h include/asm-sparc/Kbuild include/asm-sparc/page.h include/asm-sparc/unistd.h include/asm-sparc64/Kbuild include/asm-sparc64/futex.h include/asm-sparc64/page.h include/asm-sparc64/shmparam.h include/asm-sparc64/unistd.h include/asm-um/Kbuild include/asm-v850/page.h include/asm-v850/param.h include/asm-x86_64/Kbuild include/asm-x86_64/system.h include/linux/Kbuild include/linux/byteorder/Kbuild include/linux/dvb/Kbuild include/linux/mmzone.h include/linux/netfilter/Kbuild include/linux/netfilter_arp/Kbuild include/linux/netfilter_bridge/Kbuild include/linux/netfilter_ipv4.h include/linux/netfilter_ipv4/Kbuild include/linux/netfilter_ipv6/Kbuild include/linux/nfsd/Kbuild include/linux/raid/Kbuild include/linux/scx200.h include/linux/serial_core.h include/linux/stddef.h include/linux/sunrpc/Kbuild include/linux/swap.h include/linux/sysctl.h include/linux/tc_act/Kbuild include/linux/tc_ematch/Kbuild include/linux/ufs_fs.h include/media/cx2341x.h include/mtd/Kbuild include/rdma/Kbuild include/scsi/Kbuild include/sound/Kbuild include/video/Kbuild init/Kconfig kernel/module.c kernel/posix-cpu-timers.c kernel/sched.c kernel/softirq.c kernel/sysctl.c kernel/taskstats.c lib/audit.c mm/memory.c mm/migrate.c mm/mincore.c mm/msync.c mm/page_alloc.c mm/shmem.c mm/slab.c mm/truncate.c mm/vmscan.c mm/vmstat.c net/bluetooth/cmtp/capi.c net/bluetooth/hci_sock.c net/bluetooth/rfcomm/tty.c net/bridge/br_ioctl.c net/bridge/netfilter/ebtables.c net/core/dev.c net/core/skbuff.c net/core/sock.c net/dccp/ipv6.c net/decnet/af_decnet.c net/ieee80211/softmac/ieee80211softmac_io.c net/ieee80211/softmac/ieee80211softmac_scan.c net/ipv4/ipvs/ip_vs_core.c net/ipv4/netfilter.c net/ipv4/netfilter/arp_tables.c net/ipv4/netfilter/ip_conntrack_helper_h323.c net/ipv4/netfilter/ip_nat_standalone.c net/ipv4/netfilter/ip_tables.c net/ipv4/netfilter/iptable_mangle.c net/ipv4/route.c net/ipv4/tcp.c net/ipv4/tcp_cubic.c net/ipv4/tcp_input.c net/ipv4/udp.c net/ipv4/xfrm4_policy.c net/ipv6/ip6_flowlabel.c net/ipv6/ipv6_sockglue.c net/ipv6/netfilter/ip6_tables.c net/ipv6/tcp_ipv6.c net/ipv6/udp.c net/irda/irttp.c net/netfilter/Kconfig net/sched/act_gact.c net/sched/act_police.c net/sched/cls_api.c net/sched/cls_basic.c net/sched/sch_api.c net/sched/sch_generic.c net/sctp/input.c net/sunrpc/svcsock.c security/seclvl.c sound/core/control.c sound/core/hwdep.c sound/core/info.c sound/core/rtctimer.c sound/pci/au88x0/au88x0.c sound/pci/emu10k1/emu10k1_main.c sound/ppc/keywest.c sound/usb/usx2y/usbusx2yaudio.c sound/usb/usx2y/usx2yhwdeppcm.c
line diff
     1.1 --- a/Documentation/dontdiff	Tue Oct 02 09:52:15 2007 +0100
     1.2 +++ b/Documentation/dontdiff	Wed Oct 03 10:00:44 2007 +0100
     1.3 @@ -135,6 +135,7 @@ tags
     1.4  times.h*
     1.5  tkparse
     1.6  trix_boot.h
     1.7 +utsrelease.h*
     1.8  version.h*
     1.9  vmlinux
    1.10  vmlinux-*
     2.1 --- a/Documentation/sysctl/vm.txt	Tue Oct 02 09:52:15 2007 +0100
     2.2 +++ b/Documentation/sysctl/vm.txt	Wed Oct 03 10:00:44 2007 +0100
     2.3 @@ -29,6 +29,7 @@ Currently, these files are in /proc/sys/
     2.4  - drop-caches
     2.5  - zone_reclaim_mode
     2.6  - min_unmapped_ratio
     2.7 +- min_slab_ratio
     2.8  - panic_on_oom
     2.9  
    2.10  ==============================================================
    2.11 @@ -138,7 +139,6 @@ This is value ORed together of
    2.12  1	= Zone reclaim on
    2.13  2	= Zone reclaim writes dirty pages out
    2.14  4	= Zone reclaim swaps pages
    2.15 -8	= Also do a global slab reclaim pass
    2.16  
    2.17  zone_reclaim_mode is set during bootup to 1 if it is determined that pages
    2.18  from remote zones will cause a measurable performance reduction. The
    2.19 @@ -162,18 +162,13 @@ Allowing regular swap effectively restri
    2.20  node unless explicitly overridden by memory policies or cpuset
    2.21  configurations.
    2.22  
    2.23 -It may be advisable to allow slab reclaim if the system makes heavy
    2.24 -use of files and builds up large slab caches. However, the slab
    2.25 -shrink operation is global, may take a long time and free slabs
    2.26 -in all nodes of the system.
    2.27 -
    2.28  =============================================================
    2.29  
    2.30  min_unmapped_ratio:
    2.31  
    2.32  This is available only on NUMA kernels.
    2.33  
    2.34 -A percentage of the file backed pages in each zone.  Zone reclaim will only
    2.35 +A percentage of the total pages in each zone.  Zone reclaim will only
    2.36  occur if more than this percentage of pages are file backed and unmapped.
    2.37  This is to insure that a minimal amount of local pages is still available for
    2.38  file I/O even if the node is overallocated.
    2.39 @@ -182,6 +177,24 @@ The default is 1 percent.
    2.40  
    2.41  =============================================================
    2.42  
    2.43 +min_slab_ratio:
    2.44 +
    2.45 +This is available only on NUMA kernels.
    2.46 +
    2.47 +A percentage of the total pages in each zone.  On Zone reclaim
    2.48 +(fallback from the local zone occurs) slabs will be reclaimed if more
    2.49 +than this percentage of pages in a zone are reclaimable slab pages.
    2.50 +This insures that the slab growth stays under control even in NUMA
    2.51 +systems that rarely perform global reclaim.
    2.52 +
    2.53 +The default is 5 percent.
    2.54 +
    2.55 +Note that slab reclaim is triggered in a per zone / node fashion.
    2.56 +The process of reclaiming slab memory is currently not node specific
    2.57 +and may not be fast.
    2.58 +
    2.59 +=============================================================
    2.60 +
    2.61  panic_on_oom
    2.62  
    2.63  This enables or disables panic on out-of-memory feature.  If this is set to 1,
     3.1 --- a/Makefile	Tue Oct 02 09:52:15 2007 +0100
     3.2 +++ b/Makefile	Wed Oct 03 10:00:44 2007 +0100
     3.3 @@ -1,7 +1,7 @@
     3.4  VERSION = 2
     3.5  PATCHLEVEL = 6
     3.6  SUBLEVEL = 18
     3.7 -EXTRAVERSION =
     3.8 +EXTRAVERSION = .8
     3.9  NAME=Avast! A bilge rat!
    3.10  
    3.11  # *DOCUMENTATION*
    3.12 @@ -894,6 +894,9 @@ export INSTALL_HDR_PATH
    3.13  
    3.14  PHONY += headers_install
    3.15  headers_install: include/linux/version.h
    3.16 +	@if [ ! -r include/asm-$(ARCH)/Kbuild ]; then \
    3.17 +	  echo '*** Error: Headers not exportable for this architecture ($(ARCH))'; \
    3.18 +	  exit 1 ; fi
    3.19  	$(Q)unifdef -Ux /dev/null
    3.20  	$(Q)rm -rf $(INSTALL_HDR_PATH)/include
    3.21  	$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.headersinst obj=include
    3.22 @@ -1076,13 +1079,17 @@ help:
    3.23  	@echo  '  cscope	  - Generate cscope index'
    3.24  	@echo  '  kernelrelease	  - Output the release version string'
    3.25  	@echo  '  kernelversion	  - Output the version stored in Makefile'
    3.26 -	@echo  '  headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'
    3.27 +	@if [ -r include/asm-$(ARCH)/Kbuild ]; then \
    3.28 +	 echo  '  headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \
    3.29 +	 fi
    3.30  	@echo  '                    (default: $(INSTALL_HDR_PATH))'
    3.31  	@echo  ''
    3.32  	@echo  'Static analysers'
    3.33  	@echo  '  checkstack      - Generate a list of stack hogs'
    3.34  	@echo  '  namespacecheck  - Name space analysis on compiled kernel'
    3.35 -	@echo  '  headers_check   - Sanity check on exported headers'
    3.36 +	@if [ -r include/asm-$(ARCH)/Kbuild ]; then \
    3.37 +	 echo  '  headers_check   - Sanity check on exported headers'; \
    3.38 +	 fi
    3.39  	@echo  ''
    3.40  	@echo  'Kernel packaging:'
    3.41  	@$(MAKE) $(build)=$(package-dir) help
     4.1 --- a/arch/alpha/Kconfig	Tue Oct 02 09:52:15 2007 +0100
     4.2 +++ b/arch/alpha/Kconfig	Wed Oct 03 10:00:44 2007 +0100
     4.3 @@ -381,7 +381,7 @@ config ALPHA_EV56
     4.4  
     4.5  config ALPHA_EV56
     4.6  	prompt "EV56 CPU (speed >= 333MHz)?"
     4.7 -	depends on ALPHA_NORITAKE && ALPHA_PRIMO
     4.8 +	depends on ALPHA_NORITAKE || ALPHA_PRIMO
     4.9  
    4.10  config ALPHA_EV56
    4.11  	prompt "EV56 CPU (speed >= 400MHz)?"
     5.1 --- a/arch/arm/kernel/calls.S	Tue Oct 02 09:52:15 2007 +0100
     5.2 +++ b/arch/arm/kernel/calls.S	Wed Oct 03 10:00:44 2007 +0100
     5.3 @@ -331,6 +331,19 @@
     5.4  		CALL(sys_mbind)
     5.5  /* 320 */	CALL(sys_get_mempolicy)
     5.6  		CALL(sys_set_mempolicy)
     5.7 +		CALL(sys_openat)
     5.8 +		CALL(sys_mkdirat)
     5.9 +		CALL(sys_mknodat)
    5.10 +/* 325 */	CALL(sys_fchownat)
    5.11 +		CALL(sys_futimesat)
    5.12 +		CALL(sys_fstatat64)
    5.13 +		CALL(sys_unlinkat)
    5.14 +		CALL(sys_renameat)
    5.15 +/* 330 */	CALL(sys_linkat)
    5.16 +		CALL(sys_symlinkat)
    5.17 +		CALL(sys_readlinkat)
    5.18 +		CALL(sys_fchmodat)
    5.19 +		CALL(sys_faccessat)
    5.20  #ifndef syscalls_counted
    5.21  .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
    5.22  #define syscalls_counted
     6.1 --- a/arch/i386/Kconfig.cpu	Tue Oct 02 09:52:15 2007 +0100
     6.2 +++ b/arch/i386/Kconfig.cpu	Wed Oct 03 10:00:44 2007 +0100
     6.3 @@ -7,6 +7,7 @@ choice
     6.4  
     6.5  config M386
     6.6  	bool "386"
     6.7 +	depends on !UML
     6.8  	---help---
     6.9  	  This is the processor type of your CPU. This information is used for
    6.10  	  optimizing purposes. In order to compile a kernel that can run on
    6.11 @@ -301,7 +302,7 @@ config X86_USE_PPRO_CHECKSUM
    6.12  
    6.13  config X86_USE_3DNOW
    6.14  	bool
    6.15 -	depends on MCYRIXIII || MK7 || MGEODE_LX
    6.16 +	depends on (MCYRIXIII || MK7 || MGEODE_LX) && !UML
    6.17  	default y
    6.18  
    6.19  config X86_OOSTORE
     7.1 --- a/arch/i386/kernel/alternative.c	Tue Oct 02 09:52:15 2007 +0100
     7.2 +++ b/arch/i386/kernel/alternative.c	Wed Oct 03 10:00:44 2007 +0100
     7.3 @@ -344,6 +344,7 @@ void alternatives_smp_switch(int smp)
     7.4  
     7.5  void __init alternative_instructions(void)
     7.6  {
     7.7 +	unsigned long flags;
     7.8  	if (no_replacement) {
     7.9  		printk(KERN_INFO "(SMP-)alternatives turned off\n");
    7.10  		free_init_pages("SMP alternatives",
    7.11 @@ -351,6 +352,8 @@ void __init alternative_instructions(voi
    7.12  				(unsigned long)__smp_alt_end);
    7.13  		return;
    7.14  	}
    7.15 +
    7.16 +	local_irq_save(flags);
    7.17  	apply_alternatives(__alt_instructions, __alt_instructions_end);
    7.18  
    7.19  	/* switch to patch-once-at-boottime-only mode and free the
    7.20 @@ -386,4 +389,5 @@ void __init alternative_instructions(voi
    7.21  		alternatives_smp_switch(0);
    7.22  	}
    7.23  #endif
    7.24 +	local_irq_restore(flags);
    7.25  }
     8.1 --- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c	Tue Oct 02 09:52:15 2007 +0100
     8.2 +++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c	Wed Oct 03 10:00:44 2007 +0100
     8.3 @@ -560,7 +560,6 @@ static struct cpufreq_driver acpi_cpufre
     8.4  	.name	= "acpi-cpufreq",
     8.5  	.owner	= THIS_MODULE,
     8.6  	.attr	= acpi_cpufreq_attr,
     8.7 -	.flags	= CPUFREQ_STICKY,
     8.8  };
     8.9  
    8.10  
    8.11 @@ -571,7 +570,7 @@ acpi_cpufreq_init (void)
    8.12  
    8.13  	acpi_cpufreq_early_init_acpi();
    8.14  
    8.15 - 	return cpufreq_register_driver(&acpi_cpufreq_driver);
    8.16 +	return cpufreq_register_driver(&acpi_cpufreq_driver);
    8.17  }
    8.18  
    8.19  
     9.1 --- a/arch/i386/kernel/microcode.c	Tue Oct 02 09:52:15 2007 +0100
     9.2 +++ b/arch/i386/kernel/microcode.c	Wed Oct 03 10:00:44 2007 +0100
     9.3 @@ -250,14 +250,14 @@ static int find_matching_ucodes (void)
     9.4  		}
     9.5  
     9.6  		total_size = get_totalsize(&mc_header);
     9.7 -		if ((cursor + total_size > user_buffer_size) || (total_size < DEFAULT_UCODE_TOTALSIZE)) {
     9.8 +		if (cursor + total_size > user_buffer_size) {
     9.9  			printk(KERN_ERR "microcode: error! Bad data in microcode data file\n");
    9.10  			error = -EINVAL;
    9.11  			goto out;
    9.12  		}
    9.13  
    9.14  		data_size = get_datasize(&mc_header);
    9.15 -		if ((data_size + MC_HEADER_SIZE > total_size) || (data_size < DEFAULT_UCODE_DATASIZE)) {
    9.16 +		if (data_size + MC_HEADER_SIZE > total_size) {
    9.17  			printk(KERN_ERR "microcode: error! Bad data in microcode data file\n");
    9.18  			error = -EINVAL;
    9.19  			goto out;
    9.20 @@ -460,11 +460,6 @@ static ssize_t microcode_write (struct f
    9.21  {
    9.22  	ssize_t ret;
    9.23  
    9.24 -	if (len < DEFAULT_UCODE_TOTALSIZE) {
    9.25 -		printk(KERN_ERR "microcode: not enough data\n"); 
    9.26 -		return -EINVAL;
    9.27 -	}
    9.28 -
    9.29  	if ((len >> PAGE_SHIFT) > num_physpages) {
    9.30  		printk(KERN_ERR "microcode: too much data (max %ld pages)\n", num_physpages);
    9.31  		return -EINVAL;
    10.1 --- a/arch/i386/kernel/smpboot.c	Tue Oct 02 09:52:15 2007 +0100
    10.2 +++ b/arch/i386/kernel/smpboot.c	Wed Oct 03 10:00:44 2007 +0100
    10.3 @@ -642,9 +642,13 @@ static void map_cpu_to_logical_apicid(vo
    10.4  {
    10.5  	int cpu = smp_processor_id();
    10.6  	int apicid = logical_smp_processor_id();
    10.7 +	int node = apicid_to_node(apicid);
    10.8 +
    10.9 +	if (!node_online(node))
   10.10 +		node = first_online_node;
   10.11  
   10.12  	cpu_2_logical_apicid[cpu] = apicid;
   10.13 -	map_cpu_to_node(cpu, apicid_to_node(apicid));
   10.14 +	map_cpu_to_node(cpu, node);
   10.15  }
   10.16  
   10.17  static void unmap_cpu_to_logical_apicid(int cpu)
    11.1 --- a/arch/i386/mm/boot_ioremap.c	Tue Oct 02 09:52:15 2007 +0100
    11.2 +++ b/arch/i386/mm/boot_ioremap.c	Wed Oct 03 10:00:44 2007 +0100
    11.3 @@ -29,8 +29,11 @@
    11.4   */
    11.5  
    11.6  #define BOOT_PTE_PTRS (PTRS_PER_PTE*2)
    11.7 -#define boot_pte_index(address) \
    11.8 -	     (((address) >> PAGE_SHIFT) & (BOOT_PTE_PTRS - 1))
    11.9 +
   11.10 +static unsigned long boot_pte_index(unsigned long vaddr)
   11.11 +{
   11.12 +	return __pa(vaddr) >> PAGE_SHIFT;
   11.13 +}
   11.14  
   11.15  static inline boot_pte_t* boot_vaddr_to_pte(void *address)
   11.16  {
    12.1 --- a/arch/i386/pci/irq.c	Tue Oct 02 09:52:15 2007 +0100
    12.2 +++ b/arch/i386/pci/irq.c	Wed Oct 03 10:00:44 2007 +0100
    12.3 @@ -255,13 +255,13 @@ static int pirq_via_set(struct pci_dev *
    12.4   */
    12.5  static int pirq_via586_get(struct pci_dev *router, struct pci_dev *dev, int pirq)
    12.6  {
    12.7 -	static const unsigned int pirqmap[4] = { 3, 2, 5, 1 };
    12.8 +	static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
    12.9  	return read_config_nybble(router, 0x55, pirqmap[pirq-1]);
   12.10  }
   12.11  
   12.12  static int pirq_via586_set(struct pci_dev *router, struct pci_dev *dev, int pirq, int irq)
   12.13  {
   12.14 -	static const unsigned int pirqmap[4] = { 3, 2, 5, 1 };
   12.15 +	static const unsigned int pirqmap[5] = { 3, 2, 5, 1, 1 };
   12.16  	write_config_nybble(router, 0x55, pirqmap[pirq-1], irq);
   12.17  	return 1;
   12.18  }
    13.1 --- a/arch/ia64/kernel/acpi.c	Tue Oct 02 09:52:15 2007 +0100
    13.2 +++ b/arch/ia64/kernel/acpi.c	Wed Oct 03 10:00:44 2007 +0100
    13.3 @@ -777,16 +777,19 @@ int acpi_map_cpu2node(acpi_handle handle
    13.4  {
    13.5  #ifdef CONFIG_ACPI_NUMA
    13.6  	int pxm_id;
    13.7 +	int nid;
    13.8  
    13.9  	pxm_id = acpi_get_pxm(handle);
   13.10 -
   13.11  	/*
   13.12 -	 * Assuming that the container driver would have set the proximity
   13.13 -	 * domain and would have initialized pxm_to_node(pxm_id) && pxm_flag
   13.14 +	 * We don't have cpu-only-node hotadd. But if the system equips
   13.15 +	 * SRAT table, pxm is already found and node is ready.
   13.16 +  	 * So, just pxm_to_nid(pxm) is OK.
   13.17 +	 * This code here is for the system which doesn't have full SRAT
   13.18 +  	 * table for possible cpus.
   13.19  	 */
   13.20 -	node_cpuid[cpu].nid = (pxm_id < 0) ? 0 : pxm_to_node(pxm_id);
   13.21 -
   13.22 +	nid = acpi_map_pxm_to_node(pxm_id);
   13.23  	node_cpuid[cpu].phys_id = physid;
   13.24 +	node_cpuid[cpu].nid = nid;
   13.25  #endif
   13.26  	return (0);
   13.27  }
    14.1 --- a/arch/ia64/kernel/numa.c	Tue Oct 02 09:52:15 2007 +0100
    14.2 +++ b/arch/ia64/kernel/numa.c	Wed Oct 03 10:00:44 2007 +0100
    14.3 @@ -29,6 +29,36 @@ EXPORT_SYMBOL(cpu_to_node_map);
    14.4  
    14.5  cpumask_t node_to_cpu_mask[MAX_NUMNODES] __cacheline_aligned;
    14.6  
    14.7 +void __cpuinit map_cpu_to_node(int cpu, int nid)
    14.8 +{
    14.9 +	int oldnid;
   14.10 +	if (nid < 0) { /* just initialize by zero */
   14.11 +		cpu_to_node_map[cpu] = 0;
   14.12 +		return;
   14.13 +	}
   14.14 +	/* sanity check first */
   14.15 +	oldnid = cpu_to_node_map[cpu];
   14.16 +	if (cpu_isset(cpu, node_to_cpu_mask[oldnid])) {
   14.17 +		return; /* nothing to do */
   14.18 +	}
   14.19 +	/* we don't have cpu-driven node hot add yet...
   14.20 +	   In usual case, node is created from SRAT at boot time. */
   14.21 +	if (!node_online(nid))
   14.22 +		nid = first_online_node;
   14.23 +	cpu_to_node_map[cpu] = nid;
   14.24 +	cpu_set(cpu, node_to_cpu_mask[nid]);
   14.25 +	return;
   14.26 +}
   14.27 +
   14.28 +void __cpuinit unmap_cpu_from_node(int cpu, int nid)
   14.29 +{
   14.30 +	WARN_ON(!cpu_isset(cpu, node_to_cpu_mask[nid]));
   14.31 +	WARN_ON(cpu_to_node_map[cpu] != nid);
   14.32 +	cpu_to_node_map[cpu] = 0;
   14.33 +	cpu_clear(cpu, node_to_cpu_mask[nid]);
   14.34 +}
   14.35 +
   14.36 +
   14.37  /**
   14.38   * build_cpu_to_node_map - setup cpu to node and node to cpumask arrays
   14.39   *
   14.40 @@ -49,8 +79,6 @@ void __init build_cpu_to_node_map(void)
   14.41  				node = node_cpuid[i].nid;
   14.42  				break;
   14.43  			}
   14.44 -		cpu_to_node_map[cpu] = (node >= 0) ? node : 0;
   14.45 -		if (node >= 0)
   14.46 -			cpu_set(cpu, node_to_cpu_mask[node]);
   14.47 +		map_cpu_to_node(cpu, node);
   14.48  	}
   14.49  }
    15.1 --- a/arch/ia64/kernel/topology.c	Tue Oct 02 09:52:15 2007 +0100
    15.2 +++ b/arch/ia64/kernel/topology.c	Wed Oct 03 10:00:44 2007 +0100
    15.3 @@ -36,6 +36,7 @@ int arch_register_cpu(int num)
    15.4  	 */
    15.5  	if (!can_cpei_retarget() && is_cpu_cpei_target(num))
    15.6  		sysfs_cpus[num].cpu.no_control = 1;
    15.7 +	map_cpu_to_node(num, node_cpuid[num].nid);
    15.8  #endif
    15.9  
   15.10  	return register_cpu(&sysfs_cpus[num].cpu, num);
   15.11 @@ -45,7 +46,8 @@ int arch_register_cpu(int num)
   15.12  
   15.13  void arch_unregister_cpu(int num)
   15.14  {
   15.15 -	return unregister_cpu(&sysfs_cpus[num].cpu);
   15.16 +	unregister_cpu(&sysfs_cpus[num].cpu);
   15.17 +	unmap_cpu_from_node(num, cpu_to_node(num));
   15.18  }
   15.19  EXPORT_SYMBOL(arch_register_cpu);
   15.20  EXPORT_SYMBOL(arch_unregister_cpu);
    16.1 --- a/arch/ia64/sn/kernel/bte.c	Tue Oct 02 09:52:15 2007 +0100
    16.2 +++ b/arch/ia64/sn/kernel/bte.c	Wed Oct 03 10:00:44 2007 +0100
    16.3 @@ -382,14 +382,13 @@ bte_result_t bte_unaligned_copy(u64 src,
    16.4  		 * bcopy to the destination.
    16.5  		 */
    16.6  
    16.7 -		/* Add the leader from source */
    16.8 -		headBteLen = len + (src & L1_CACHE_MASK);
    16.9 -		/* Add the trailing bytes from footer. */
   16.10 -		headBteLen += L1_CACHE_BYTES - (headBteLen & L1_CACHE_MASK);
   16.11 -		headBteSource = src & ~L1_CACHE_MASK;
   16.12  		headBcopySrcOffset = src & L1_CACHE_MASK;
   16.13  		headBcopyDest = dest;
   16.14  		headBcopyLen = len;
   16.15 +
   16.16 +		headBteSource = src - headBcopySrcOffset;
   16.17 +		/* Add the leading and trailing bytes from source */
   16.18 +		headBteLen = L1_CACHE_ALIGN(len + headBcopySrcOffset);
   16.19  	}
   16.20  
   16.21  	if (headBcopyLen > 0) {
    17.1 --- a/arch/m32r/kernel/entry.S	Tue Oct 02 09:52:15 2007 +0100
    17.2 +++ b/arch/m32r/kernel/entry.S	Wed Oct 03 10:00:44 2007 +0100
    17.3 @@ -23,35 +23,35 @@
    17.4   *	updated in fork.c:copy_thread, signal.c:do_signal,
    17.5   *	ptrace.c and ptrace.h
    17.6   *
    17.7 - * M32Rx/M32R2				M32R
    17.8 - *       @(sp)      - r4		ditto
    17.9 - *       @(0x04,sp) - r5		ditto
   17.10 - *       @(0x08,sp) - r6		ditto
   17.11 - *       @(0x0c,sp) - *pt_regs		ditto
   17.12 - *       @(0x10,sp) - r0		ditto
   17.13 - *       @(0x14,sp) - r1		ditto
   17.14 - *       @(0x18,sp) - r2		ditto
   17.15 - *       @(0x1c,sp) - r3		ditto
   17.16 - *       @(0x20,sp) - r7		ditto
   17.17 - *       @(0x24,sp) - r8		ditto
   17.18 - *       @(0x28,sp) - r9		ditto
   17.19 - *       @(0x2c,sp) - r10		ditto
   17.20 - *       @(0x30,sp) - r11		ditto
   17.21 - *       @(0x34,sp) - r12		ditto
   17.22 - *       @(0x38,sp) - syscall_nr	ditto
   17.23 - *       @(0x3c,sp) - acc0h		@(0x3c,sp) - acch
   17.24 - *       @(0x40,sp) - acc0l		@(0x40,sp) - accl
   17.25 - *       @(0x44,sp) - acc1h		@(0x44,sp) - dummy_acc1h
   17.26 - *       @(0x48,sp) - acc1l		@(0x48,sp) - dummy_acc1l
   17.27 - *       @(0x4c,sp) - psw		ditto
   17.28 - *       @(0x50,sp) - bpc		ditto
   17.29 - *       @(0x54,sp) - bbpsw		ditto
   17.30 - *       @(0x58,sp) - bbpc		ditto
   17.31 - *       @(0x5c,sp) - spu (cr3)		ditto
   17.32 - *       @(0x60,sp) - fp (r13)		ditto
   17.33 - *       @(0x64,sp) - lr (r14)		ditto
   17.34 - *       @(0x68,sp) - spi (cr2)		ditto
   17.35 - *       @(0x6c,sp) - orig_r0		ditto
   17.36 + * M32R/M32Rx/M32R2
   17.37 + *       @(sp)      - r4
   17.38 + *       @(0x04,sp) - r5
   17.39 + *       @(0x08,sp) - r6
   17.40 + *       @(0x0c,sp) - *pt_regs
   17.41 + *       @(0x10,sp) - r0
   17.42 + *       @(0x14,sp) - r1
   17.43 + *       @(0x18,sp) - r2
   17.44 + *       @(0x1c,sp) - r3
   17.45 + *       @(0x20,sp) - r7
   17.46 + *       @(0x24,sp) - r8
   17.47 + *       @(0x28,sp) - r9
   17.48 + *       @(0x2c,sp) - r10
   17.49 + *       @(0x30,sp) - r11
   17.50 + *       @(0x34,sp) - r12
   17.51 + *       @(0x38,sp) - syscall_nr
   17.52 + *       @(0x3c,sp) - acc0h
   17.53 + *       @(0x40,sp) - acc0l
   17.54 + *       @(0x44,sp) - acc1h		; ISA_DSP_LEVEL2 only
   17.55 + *       @(0x48,sp) - acc1l		; ISA_DSP_LEVEL2 only
   17.56 + *       @(0x4c,sp) - psw
   17.57 + *       @(0x50,sp) - bpc
   17.58 + *       @(0x54,sp) - bbpsw
   17.59 + *       @(0x58,sp) - bbpc
   17.60 + *       @(0x5c,sp) - spu (cr3)
   17.61 + *       @(0x60,sp) - fp (r13)
   17.62 + *       @(0x64,sp) - lr (r14)
   17.63 + *       @(0x68,sp) - spi (cr2)
   17.64 + *       @(0x6c,sp) - orig_r0
   17.65   */
   17.66  
   17.67  #include <linux/linkage.h>
   17.68 @@ -95,17 +95,10 @@
   17.69  #define R11(reg)		@(0x30,reg)
   17.70  #define R12(reg)		@(0x34,reg)
   17.71  #define SYSCALL_NR(reg)		@(0x38,reg)
   17.72 -#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
   17.73  #define ACC0H(reg)		@(0x3C,reg)
   17.74  #define ACC0L(reg)		@(0x40,reg)
   17.75  #define ACC1H(reg)		@(0x44,reg)
   17.76  #define ACC1L(reg)		@(0x48,reg)
   17.77 -#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
   17.78 -#define ACCH(reg)		@(0x3C,reg)
   17.79 -#define ACCL(reg)		@(0x40,reg)
   17.80 -#else
   17.81 -#error unknown isa configuration
   17.82 -#endif
   17.83  #define PSW(reg)		@(0x4C,reg)
   17.84  #define BPC(reg)		@(0x50,reg)
   17.85  #define BBPSW(reg)		@(0x54,reg)
    18.1 --- a/arch/powerpc/Kconfig	Tue Oct 02 09:52:15 2007 +0100
    18.2 +++ b/arch/powerpc/Kconfig	Wed Oct 03 10:00:44 2007 +0100
    18.3 @@ -740,6 +740,15 @@ config ARCH_MEMORY_PROBE
    18.4  	def_bool y
    18.5  	depends on MEMORY_HOTPLUG
    18.6  
    18.7 +# Some NUMA nodes have memory ranges that span
    18.8 +# other nodes.  Even though a pfn is valid and
    18.9 +# between a node's start and end pfns, it may not
   18.10 +# reside on that node.  See memmap_init_zone()
   18.11 +# for details.
   18.12 +config NODES_SPAN_OTHER_NODES
   18.13 +	def_bool y
   18.14 +	depends on NEED_MULTIPLE_NODES
   18.15 +
   18.16  config PPC_64K_PAGES
   18.17  	bool "64k page size"
   18.18  	depends on PPC64
    19.1 --- a/arch/powerpc/configs/pseries_defconfig	Tue Oct 02 09:52:15 2007 +0100
    19.2 +++ b/arch/powerpc/configs/pseries_defconfig	Wed Oct 03 10:00:44 2007 +0100
    19.3 @@ -184,6 +184,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
    19.4  CONFIG_MIGRATION=y
    19.5  CONFIG_RESOURCES_64BIT=y
    19.6  CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
    19.7 +CONFIG_NODES_SPAN_OTHER_NODES=y
    19.8  # CONFIG_PPC_64K_PAGES is not set
    19.9  CONFIG_SCHED_SMT=y
   19.10  CONFIG_PROC_DEVICETREE=y
    20.1 --- a/arch/powerpc/kernel/traps.c	Tue Oct 02 09:52:15 2007 +0100
    20.2 +++ b/arch/powerpc/kernel/traps.c	Wed Oct 03 10:00:44 2007 +0100
    20.3 @@ -818,7 +818,7 @@ void __kprobes program_check_exception(s
    20.4  
    20.5  void alignment_exception(struct pt_regs *regs)
    20.6  {
    20.7 -	int fixed = 0;
    20.8 +	int sig, code, fixed = 0;
    20.9  
   20.10  	/* we don't implement logging of alignment exceptions */
   20.11  	if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS))
   20.12 @@ -832,14 +832,16 @@ void alignment_exception(struct pt_regs 
   20.13  
   20.14  	/* Operand address was bad */
   20.15  	if (fixed == -EFAULT) {
   20.16 -		if (user_mode(regs))
   20.17 -			_exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar);
   20.18 -		else
   20.19 -			/* Search exception table */
   20.20 -			bad_page_fault(regs, regs->dar, SIGSEGV);
   20.21 -		return;
   20.22 +		sig = SIGSEGV;
   20.23 +		code = SEGV_ACCERR;
   20.24 +	} else {
   20.25 +		sig = SIGBUS;
   20.26 +		code = BUS_ADRALN;
   20.27  	}
   20.28 -	_exception(SIGBUS, regs, BUS_ADRALN, regs->dar);
   20.29 +	if (user_mode(regs))
   20.30 +		_exception(sig, regs, code, regs->dar);
   20.31 +	else
   20.32 +		bad_page_fault(regs, regs->dar, sig);
   20.33  }
   20.34  
   20.35  void StackOverflow(struct pt_regs *regs)
    21.1 --- a/arch/ppc/kernel/traps.c	Tue Oct 02 09:52:15 2007 +0100
    21.2 +++ b/arch/ppc/kernel/traps.c	Wed Oct 03 10:00:44 2007 +0100
    21.3 @@ -708,7 +708,7 @@ void single_step_exception(struct pt_reg
    21.4  
    21.5  void alignment_exception(struct pt_regs *regs)
    21.6  {
    21.7 -	int fixed;
    21.8 +	int sig, code, fixed = 0;
    21.9  
   21.10  	fixed = fix_alignment(regs);
   21.11  	if (fixed == 1) {
   21.12 @@ -717,14 +717,16 @@ void alignment_exception(struct pt_regs 
   21.13  		return;
   21.14  	}
   21.15  	if (fixed == -EFAULT) {
   21.16 -		/* fixed == -EFAULT means the operand address was bad */
   21.17 -		if (user_mode(regs))
   21.18 -			_exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar);
   21.19 -		else
   21.20 -			bad_page_fault(regs, regs->dar, SIGSEGV);
   21.21 -		return;
   21.22 +		sig = SIGSEGV;
   21.23 +		code = SEGV_ACCERR;
   21.24 +	} else {
   21.25 +		sig = SIGBUS;
   21.26 +		code = BUS_ADRALN;
   21.27  	}
   21.28 -	_exception(SIGBUS, regs, BUS_ADRALN, regs->dar);
   21.29 +	if (user_mode(regs))
   21.30 +		_exception(sig, regs, code, regs->dar);
   21.31 +	else
   21.32 +		bad_page_fault(regs, regs->dar, sig);
   21.33  }
   21.34  
   21.35  void StackOverflow(struct pt_regs *regs)
    22.1 --- a/arch/s390/Kconfig	Tue Oct 02 09:52:15 2007 +0100
    22.2 +++ b/arch/s390/Kconfig	Wed Oct 03 10:00:44 2007 +0100
    22.3 @@ -51,6 +51,10 @@ config 64BIT
    22.4  	  Select this option if you have a 64 bit IBM zSeries machine
    22.5  	  and want to use the 64 bit addressing mode.
    22.6  
    22.7 +config 32BIT
    22.8 +	bool
    22.9 +	default y if !64BIT
   22.10 +
   22.11  config SMP
   22.12  	bool "Symmetric multi-processing support"
   22.13  	---help---
    23.1 --- a/arch/s390/lib/Makefile	Tue Oct 02 09:52:15 2007 +0100
    23.2 +++ b/arch/s390/lib/Makefile	Wed Oct 03 10:00:44 2007 +0100
    23.3 @@ -7,3 +7,4 @@ EXTRA_AFLAGS := -traditional
    23.4  lib-y += delay.o string.o
    23.5  lib-y += $(if $(CONFIG_64BIT),uaccess64.o,uaccess.o)
    23.6  lib-$(CONFIG_SMP) += spinlock.o
    23.7 +lib-$(CONFIG_32BIT) += div64.o
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/arch/s390/lib/div64.c	Wed Oct 03 10:00:44 2007 +0100
    24.3 @@ -0,0 +1,151 @@
    24.4 +/*
    24.5 + *  arch/s390/lib/div64.c
    24.6 + *
    24.7 + *  __div64_32 implementation for 31 bit.
    24.8 + *
    24.9 + *    Copyright (C) IBM Corp. 2006
   24.10 + *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
   24.11 + */
   24.12 +
   24.13 +#include <linux/types.h>
   24.14 +#include <linux/module.h>
   24.15 +
   24.16 +#ifdef CONFIG_MARCH_G5
   24.17 +
   24.18 +/*
   24.19 + * Function to divide an unsigned 64 bit integer by an unsigned
   24.20 + * 31 bit integer using signed 64/32 bit division.
   24.21 + */
   24.22 +static uint32_t __div64_31(uint64_t *n, uint32_t base)
   24.23 +{
   24.24 +	register uint32_t reg2 asm("2");
   24.25 +	register uint32_t reg3 asm("3");
   24.26 +	uint32_t *words = (uint32_t *) n;
   24.27 +	uint32_t tmp;
   24.28 +
   24.29 +	/* Special case base==1, remainder = 0, quotient = n */
   24.30 +	if (base == 1)
   24.31 +		return 0;
   24.32 +	/*
   24.33 +	 * Special case base==0 will cause a fixed point divide exception
   24.34 +	 * on the dr instruction and may not happen anyway. For the
   24.35 +	 * following calculation we can assume base > 1. The first
   24.36 +	 * signed 64 / 32 bit division with an upper half of 0 will
   24.37 +	 * give the correct upper half of the 64 bit quotient.
   24.38 +	 */
   24.39 +	reg2 = 0UL;
   24.40 +	reg3 = words[0];
   24.41 +	asm volatile(
   24.42 +		"	dr	%0,%2\n"
   24.43 +		: "+d" (reg2), "+d" (reg3) : "d" (base) : "cc" );
   24.44 +	words[0] = reg3;
   24.45 +	reg3 = words[1];
   24.46 +	/*
   24.47 +	 * To get the lower half of the 64 bit quotient and the 32 bit
   24.48 +	 * remainder we have to use a little trick. Since we only have
   24.49 +	 * a signed division the quotient can get too big. To avoid this
   24.50 +	 * the 64 bit dividend is halved, then the signed division will
   24.51 +	 * work. Afterwards the quotient and the remainder are doubled.
   24.52 +	 * If the last bit of the dividend has been one the remainder
   24.53 +	 * is increased by one then checked against the base. If the
   24.54 +	 * remainder has overflown subtract base and increase the
   24.55 +	 * quotient. Simple, no ?
   24.56 +	 */
   24.57 +	asm volatile(
   24.58 +		"	nr	%2,%1\n"
   24.59 +		"	srdl	%0,1\n"
   24.60 +		"	dr	%0,%3\n"
   24.61 +		"	alr	%0,%0\n"
   24.62 +		"	alr	%1,%1\n"
   24.63 +		"	alr	%0,%2\n"
   24.64 +		"	clr	%0,%3\n"
   24.65 +		"	jl	0f\n"
   24.66 +		"	slr	%0,%3\n"
   24.67 +		"	alr	%1,%2\n"
   24.68 +		"0:\n"
   24.69 +		: "+d" (reg2), "+d" (reg3), "=d" (tmp)
   24.70 +		: "d" (base), "2" (1UL) : "cc" );
   24.71 +	words[1] = reg3;
   24.72 +	return reg2;
   24.73 +}
   24.74 +
   24.75 +/*
   24.76 + * Function to divide an unsigned 64 bit integer by an unsigned
   24.77 + * 32 bit integer using the unsigned 64/31 bit division.
   24.78 + */
   24.79 +uint32_t __div64_32(uint64_t *n, uint32_t base)
   24.80 +{
   24.81 +	uint32_t r;
   24.82 +
   24.83 +	/*
   24.84 +	 * If the most significant bit of base is set, divide n by
   24.85 +	 * (base/2). That allows to use 64/31 bit division and gives a
   24.86 +	 * good approximation of the result: n = (base/2)*q + r. The
   24.87 +	 * result needs to be corrected with two simple transformations.
   24.88 +	 * If base is already < 2^31-1 __div64_31 can be used directly.
   24.89 +	 */
   24.90 +	r = __div64_31(n, ((signed) base < 0) ? (base/2) : base);
   24.91 +	if ((signed) base < 0) {
   24.92 +		uint64_t q = *n;
   24.93 +		/*
   24.94 +		 * First transformation:
   24.95 +		 * n = (base/2)*q + r
   24.96 +		 *   = ((base/2)*2)*(q/2) + ((q&1) ? (base/2) : 0) + r
   24.97 +		 * Since r < (base/2), r + (base/2) < base.
   24.98 +		 * With q1 = (q/2) and r1 = r + ((q&1) ? (base/2) : 0)
   24.99 +		 * n = ((base/2)*2)*q1 + r1 with r1 < base.
  24.100 +		 */
  24.101 +		if (q & 1)
  24.102 +			r += base/2;
  24.103 +		q >>= 1;
  24.104 +		/*
  24.105 +		 * Second transformation. ((base/2)*2) could have lost the
  24.106 +		 * last bit.
  24.107 +		 * n = ((base/2)*2)*q1 + r1
  24.108 +		 *   = base*q1 - ((base&1) ? q1 : 0) + r1
  24.109 +		 */
  24.110 +		if (base & 1) {
  24.111 +			int64_t rx = r - q;
  24.112 +			/*
  24.113 +			 * base is >= 2^31. The worst case for the while
  24.114 +			 * loop is n=2^64-1 base=2^31+1. That gives a
  24.115 +			 * maximum for q=(2^64-1)/2^31 = 0x1ffffffff. Since
  24.116 +			 * base >= 2^31 the loop is finished after a maximum
  24.117 +			 * of three iterations.
  24.118 +			 */
  24.119 +			while (rx < 0) {
  24.120 +				rx += base;
  24.121 +				q--;
  24.122 +			}
  24.123 +			r = rx;
  24.124 +		}
  24.125 +		*n = q;
  24.126 +	}
  24.127 +	return r;
  24.128 +}
  24.129 +
  24.130 +#else /* MARCH_G5 */
  24.131 +
  24.132 +uint32_t __div64_32(uint64_t *n, uint32_t base)
  24.133 +{
  24.134 +	register uint32_t reg2 asm("2");
  24.135 +	register uint32_t reg3 asm("3");
  24.136 +	uint32_t *words = (uint32_t *) n;
  24.137 +
  24.138 +	reg2 = 0UL;
  24.139 +	reg3 = words[0];
  24.140 +	asm volatile(
  24.141 +		"	dlr	%0,%2\n"
  24.142 +		: "+d" (reg2), "+d" (reg3) : "d" (base) : "cc" );
  24.143 +	words[0] = reg3;
  24.144 +	reg3 = words[1];
  24.145 +	asm volatile(
  24.146 +		"	dlr	%0,%2\n"
  24.147 +		: "+d" (reg2), "+d" (reg3) : "d" (base) : "cc" );
  24.148 +	words[1] = reg3;
  24.149 +	return reg2;
  24.150 +}
  24.151 +
  24.152 +#endif /* MARCH_G5 */
  24.153 +
  24.154 +EXPORT_SYMBOL(__div64_32);
    25.1 --- a/arch/s390/lib/uaccess.S	Tue Oct 02 09:52:15 2007 +0100
    25.2 +++ b/arch/s390/lib/uaccess.S	Wed Oct 03 10:00:44 2007 +0100
    25.3 @@ -40,7 +40,17 @@ 4:	lhi	%r0,-4096
    25.4  	# move with the reduced length which is < 256
    25.5  5:	mvcp	0(%r5,%r2),0(%r4),%r0
    25.6  	slr	%r3,%r5
    25.7 -6:	lr	%r2,%r3
    25.8 +	alr	%r2,%r5
    25.9 +6:	lr	%r5,%r3		# copy remaining size
   25.10 +	ahi	%r5,-1		# subtract 1 for xc loop
   25.11 +	bras	%r4,8f
   25.12 +	xc	0(1,%r2),0(%r2)
   25.13 +7:	xc	0(256,%r2),0(%r2)
   25.14 +	la	%r2,256(%r2)
   25.15 +8:	ahi	%r5,-256
   25.16 +	jnm	7b
   25.17 +	ex	%r5,0(%r4)
   25.18 +9:	lr	%r2,%r3
   25.19  	br	%r14
   25.20          .section __ex_table,"a"
   25.21  	.long	0b,4b
    26.1 --- a/arch/s390/lib/uaccess64.S	Tue Oct 02 09:52:15 2007 +0100
    26.2 +++ b/arch/s390/lib/uaccess64.S	Wed Oct 03 10:00:44 2007 +0100
    26.3 @@ -40,7 +40,17 @@ 4:	lghi	%r0,-4096
    26.4  	# move with the reduced length which is < 256
    26.5  5:	mvcp	0(%r5,%r2),0(%r4),%r0
    26.6  	slgr	%r3,%r5
    26.7 -6:	lgr	%r2,%r3
    26.8 +	algr	%r2,%r5
    26.9 +6:	lgr	%r5,%r3		# copy remaining size
   26.10 +	aghi	%r5,-1		# subtract 1 for xc loop
   26.11 +	bras	%r4,8f
   26.12 +	xc	0(1,%r2),0(%r2)
   26.13 +7:	xc	0(256,%r2),0(%r2)
   26.14 +	la	%r2,256(%r2)
   26.15 +8:	aghi	%r5,-256
   26.16 +	jnm	7b
   26.17 +	ex	%r5,0(%r4)
   26.18 +9:	lgr	%r2,%r3
   26.19  	br	%r14
   26.20          .section __ex_table,"a"
   26.21  	.quad	0b,4b
    27.1 --- a/arch/sh/kernel/process.c	Tue Oct 02 09:52:15 2007 +0100
    27.2 +++ b/arch/sh/kernel/process.c	Wed Oct 03 10:00:44 2007 +0100
    27.3 @@ -26,6 +26,7 @@
    27.4  #include <asm/uaccess.h>
    27.5  #include <asm/mmu_context.h>
    27.6  #include <asm/elf.h>
    27.7 +#include <asm/ubc.h>
    27.8  
    27.9  static int hlt_counter=0;
   27.10  
    28.1 --- a/arch/sparc/kernel/entry.S	Tue Oct 02 09:52:15 2007 +0100
    28.2 +++ b/arch/sparc/kernel/entry.S	Wed Oct 03 10:00:44 2007 +0100
    28.3 @@ -32,13 +32,12 @@
    28.4  #include <asm/mxcc.h>
    28.5  #include <asm/thread_info.h>
    28.6  #include <asm/param.h>
    28.7 +#include <asm/unistd.h>
    28.8  
    28.9  #include <asm/asmmacro.h>
   28.10  
   28.11  #define curptr      g6
   28.12  
   28.13 -#define NR_SYSCALLS 300      /* Each OS is different... */
   28.14 -
   28.15  /* These are just handy. */
   28.16  #define _SV	save	%sp, -STACKFRAME_SZ, %sp
   28.17  #define _RS     restore 
    29.1 --- a/arch/sparc64/kernel/central.c	Tue Oct 02 09:52:15 2007 +0100
    29.2 +++ b/arch/sparc64/kernel/central.c	Wed Oct 03 10:00:44 2007 +0100
    29.3 @@ -126,6 +126,10 @@ static void probe_other_fhcs(void)
    29.4  		int board;
    29.5  		u32 tmp;
    29.6  
    29.7 +		if (dp->parent &&
    29.8 +		    dp->parent->parent != NULL)
    29.9 +			continue;
   29.10 +
   29.11  		fhc = (struct linux_fhc *)
   29.12  			central_alloc_bootmem(sizeof(struct linux_fhc));
   29.13  		if (fhc == NULL)
    30.1 --- a/arch/sparc64/kernel/entry.S	Tue Oct 02 09:52:15 2007 +0100
    30.2 +++ b/arch/sparc64/kernel/entry.S	Wed Oct 03 10:00:44 2007 +0100
    30.3 @@ -22,11 +22,10 @@
    30.4  #include <asm/auxio.h>
    30.5  #include <asm/sfafsr.h>
    30.6  #include <asm/pil.h>
    30.7 +#include <asm/unistd.h>
    30.8  
    30.9  #define curptr      g6
   30.10  
   30.11 -#define NR_SYSCALLS 300      /* Each OS is different... */
   30.12 -
   30.13  	.text
   30.14  	.align		32
   30.15  
    31.1 --- a/arch/sparc64/kernel/of_device.c	Tue Oct 02 09:52:15 2007 +0100
    31.2 +++ b/arch/sparc64/kernel/of_device.c	Wed Oct 03 10:00:44 2007 +0100
    31.3 @@ -398,16 +398,22 @@ static void of_bus_sbus_count_cells(stru
    31.4  		*sizec = 1;
    31.5  }
    31.6  
    31.7 -static int of_bus_sbus_map(u32 *addr, const u32 *range, int na, int ns, int pna)
    31.8 +/*
    31.9 + * FHC/Central bus specific translator.
   31.10 + *
   31.11 + * This is just needed to hard-code the address and size cell
   31.12 + * counts.  'fhc' and 'central' nodes lack the #address-cells and
   31.13 + * #size-cells properties, and if you walk to the root on such
   31.14 + * Enterprise boxes all you'll get is a #size-cells of 2 which is
   31.15 + * not what we want to use.
   31.16 + */
   31.17 +static int of_bus_fhc_match(struct device_node *np)
   31.18  {
   31.19 -	return of_bus_default_map(addr, range, na, ns, pna);
   31.20 +	return !strcmp(np->name, "fhc") ||
   31.21 +		!strcmp(np->name, "central");
   31.22  }
   31.23  
   31.24 -static unsigned int of_bus_sbus_get_flags(u32 *addr)
   31.25 -{
   31.26 -	return IORESOURCE_MEM;
   31.27 -}
   31.28 -
   31.29 +#define of_bus_fhc_count_cells of_bus_sbus_count_cells
   31.30  
   31.31  /*
   31.32   * Array of bus specific translators
   31.33 @@ -429,8 +435,17 @@ static struct of_bus of_busses[] = {
   31.34  		.addr_prop_name = "reg",
   31.35  		.match = of_bus_sbus_match,
   31.36  		.count_cells = of_bus_sbus_count_cells,
   31.37 -		.map = of_bus_sbus_map,
   31.38 -		.get_flags = of_bus_sbus_get_flags,
   31.39 +		.map = of_bus_default_map,
   31.40 +		.get_flags = of_bus_default_get_flags,
   31.41 +	},
   31.42 +	/* FHC */
   31.43 +	{
   31.44 +		.name = "fhc",
   31.45 +		.addr_prop_name = "reg",
   31.46 +		.match = of_bus_fhc_match,
   31.47 +		.count_cells = of_bus_fhc_count_cells,
   31.48 +		.map = of_bus_default_map,
   31.49 +		.get_flags = of_bus_default_get_flags,
   31.50  	},
   31.51  	/* Default */
   31.52  	{
    32.1 --- a/arch/sparc64/kernel/pci_common.c	Tue Oct 02 09:52:15 2007 +0100
    32.2 +++ b/arch/sparc64/kernel/pci_common.c	Wed Oct 03 10:00:44 2007 +0100
    32.3 @@ -330,19 +330,6 @@ static struct resource *
    32.4  	return res;
    32.5  }
    32.6  
    32.7 -static int __init pdev_resource_collisions_expected(struct pci_dev *pdev)
    32.8 -{
    32.9 -	if (pdev->vendor != PCI_VENDOR_ID_SUN)
   32.10 -		return 0;
   32.11 -
   32.12 -	if (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS ||
   32.13 -	    pdev->device == PCI_DEVICE_ID_SUN_RIO_1394 ||
   32.14 -	    pdev->device == PCI_DEVICE_ID_SUN_RIO_USB)
   32.15 -		return 1;
   32.16 -
   32.17 -	return 0;
   32.18 -}
   32.19 -
   32.20  static void __init pdev_record_assignments(struct pci_pbm_info *pbm,
   32.21  					   struct pci_dev *pdev)
   32.22  {
   32.23 @@ -400,19 +387,23 @@ static void __init pdev_record_assignmen
   32.24  		pbm->parent->resource_adjust(pdev, res, root);
   32.25  
   32.26  		if (request_resource(root, res) < 0) {
   32.27 +			int rnum;
   32.28 +
   32.29  			/* OK, there is some conflict.  But this is fine
   32.30  			 * since we'll reassign it in the fixup pass.
   32.31  			 *
   32.32 -			 * We notify the user that OBP made an error if it
   32.33 -			 * is a case we don't expect.
   32.34 +			 * Do not print the warning for ROM resources
   32.35 +			 * as such a conflict is quite common and
   32.36 +			 * harmless as the ROM bar is disabled.
   32.37  			 */
   32.38 -			if (!pdev_resource_collisions_expected(pdev)) {
   32.39 -				printk(KERN_ERR "PCI: Address space collision on region %ld "
   32.40 +			rnum = (res - &pdev->resource[0]);
   32.41 +			if (rnum != PCI_ROM_RESOURCE)
   32.42 +				printk(KERN_ERR "PCI: Resource collision, "
   32.43 +				       "region %d "
   32.44  				       "[%016lx:%016lx] of device %s\n",
   32.45 -				       (res - &pdev->resource[0]),
   32.46 +				       rnum,
   32.47  				       res->start, res->end,
   32.48  				       pci_name(pdev));
   32.49 -			}
   32.50  		}
   32.51  	}
   32.52  }
    33.1 --- a/arch/sparc64/kernel/pci_iommu.c	Tue Oct 02 09:52:15 2007 +0100
    33.2 +++ b/arch/sparc64/kernel/pci_iommu.c	Wed Oct 03 10:00:44 2007 +0100
    33.3 @@ -281,7 +281,7 @@ static void pci_4u_free_consistent(struc
    33.4  
    33.5  	spin_lock_irqsave(&iommu->lock, flags);
    33.6  
    33.7 -	free_npages(iommu, dvma, npages);
    33.8 +	free_npages(iommu, dvma - iommu->page_table_map_base, npages);
    33.9  
   33.10  	spin_unlock_irqrestore(&iommu->lock, flags);
   33.11  
    34.1 --- a/arch/sparc64/kernel/pci_sabre.c	Tue Oct 02 09:52:15 2007 +0100
    34.2 +++ b/arch/sparc64/kernel/pci_sabre.c	Wed Oct 03 10:00:44 2007 +0100
    34.3 @@ -1196,7 +1196,7 @@ static void pbm_register_toplevel_resour
    34.4  					    &pbm->mem_space);
    34.5  }
    34.6  
    34.7 -static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp, u32 dma_begin)
    34.8 +static void sabre_pbm_init(struct pci_controller_info *p, struct device_node *dp, u32 dma_start, u32 dma_end)
    34.9  {
   34.10  	struct pci_pbm_info *pbm;
   34.11  	struct device_node *node;
   34.12 @@ -1261,6 +1261,8 @@ static void sabre_pbm_init(struct pci_co
   34.13  		node = node->sibling;
   34.14  	}
   34.15  	if (simbas_found == 0) {
   34.16 +		struct resource *rp;
   34.17 +
   34.18  		/* No APBs underneath, probably this is a hummingbird
   34.19  		 * system.
   34.20  		 */
   34.21 @@ -1302,8 +1304,10 @@ static void sabre_pbm_init(struct pci_co
   34.22  		pbm->io_space.end   = pbm->io_space.start + (1UL << 24) - 1UL;
   34.23  		pbm->io_space.flags = IORESOURCE_IO;
   34.24  
   34.25 -		pbm->mem_space.start = p->pbm_A.controller_regs + SABRE_MEMSPACE;
   34.26 -		pbm->mem_space.end   = pbm->mem_space.start + (unsigned long)dma_begin - 1UL;
   34.27 +		pbm->mem_space.start =
   34.28 +			(p->pbm_A.controller_regs + SABRE_MEMSPACE);
   34.29 +		pbm->mem_space.end =
   34.30 +			(pbm->mem_space.start + ((1UL << 32UL) - 1UL));
   34.31  		pbm->mem_space.flags = IORESOURCE_MEM;
   34.32  
   34.33  		if (request_resource(&ioport_resource, &pbm->io_space) < 0) {
   34.34 @@ -1315,6 +1319,17 @@ static void sabre_pbm_init(struct pci_co
   34.35  			prom_halt();
   34.36  		}
   34.37  
   34.38 +		rp = kmalloc(sizeof(*rp), GFP_KERNEL);
   34.39 +		if (!rp) {
   34.40 +			prom_printf("Cannot allocate IOMMU resource.\n");
   34.41 +			prom_halt();
   34.42 +		}
   34.43 +		rp->name = "IOMMU";
   34.44 +		rp->start = pbm->mem_space.start + (unsigned long) dma_start;
   34.45 +		rp->end = pbm->mem_space.start + (unsigned long) dma_end - 1UL;
   34.46 +		rp->flags = IORESOURCE_BUSY;
   34.47 +		request_resource(&pbm->mem_space, rp);
   34.48 +
   34.49  		pci_register_legacy_regions(&pbm->io_space,
   34.50  					    &pbm->mem_space);
   34.51  	}
   34.52 @@ -1450,5 +1465,5 @@ void sabre_init(struct device_node *dp, 
   34.53  	/*
   34.54  	 * Look for APB underneath.
   34.55  	 */
   34.56 -	sabre_pbm_init(p, dp, vdma[0]);
   34.57 +	sabre_pbm_init(p, dp, vdma[0], vdma[0] + vdma[1]);
   34.58  }
    35.1 --- a/arch/sparc64/kernel/prom.c	Tue Oct 02 09:52:15 2007 +0100
    35.2 +++ b/arch/sparc64/kernel/prom.c	Wed Oct 03 10:00:44 2007 +0100
    35.3 @@ -1080,23 +1080,22 @@ static void sun4v_vdev_irq_trans_init(st
    35.4  
    35.5  static void irq_trans_init(struct device_node *dp)
    35.6  {
    35.7 +#ifdef CONFIG_PCI
    35.8  	const char *model;
    35.9 -#ifdef CONFIG_PCI
   35.10  	int i;
   35.11  #endif
   35.12  
   35.13 +#ifdef CONFIG_PCI
   35.14  	model = of_get_property(dp, "model", NULL);
   35.15  	if (!model)
   35.16  		model = of_get_property(dp, "compatible", NULL);
   35.17 -	if (!model)
   35.18 -		return;
   35.19 +	if (model) {
   35.20 +		for (i = 0; i < ARRAY_SIZE(pci_irq_trans_table); i++) {
   35.21 +			struct irq_trans *t = &pci_irq_trans_table[i];
   35.22  
   35.23 -#ifdef CONFIG_PCI
   35.24 -	for (i = 0; i < ARRAY_SIZE(pci_irq_trans_table); i++) {
   35.25 -		struct irq_trans *t = &pci_irq_trans_table[i];
   35.26 -
   35.27 -		if (!strcmp(model, t->name))
   35.28 -			return t->init(dp);
   35.29 +			if (!strcmp(model, t->name))
   35.30 +				return t->init(dp);
   35.31 +		}
   35.32  	}
   35.33  #endif
   35.34  #ifdef CONFIG_SBUS
   35.35 @@ -1104,8 +1103,9 @@ static void irq_trans_init(struct device
   35.36  	    !strcmp(dp->name, "sbi"))
   35.37  		return sbus_irq_trans_init(dp);
   35.38  #endif
   35.39 -	if (!strcmp(dp->name, "central"))
   35.40 -		return central_irq_trans_init(dp->child);
   35.41 +	if (!strcmp(dp->name, "fhc") &&
   35.42 +	    !strcmp(dp->parent->name, "central"))
   35.43 +		return central_irq_trans_init(dp);
   35.44  	if (!strcmp(dp->name, "virtual-devices"))
   35.45  		return sun4v_vdev_irq_trans_init(dp);
   35.46  }
   35.47 @@ -1517,7 +1517,7 @@ static char * __init get_one_property(ph
   35.48  	return buf;
   35.49  }
   35.50  
   35.51 -static struct device_node * __init create_node(phandle node)
   35.52 +static struct device_node * __init create_node(phandle node, struct device_node *parent)
   35.53  {
   35.54  	struct device_node *dp;
   35.55  
   35.56 @@ -1526,6 +1526,7 @@ static struct device_node * __init creat
   35.57  
   35.58  	dp = prom_early_alloc(sizeof(*dp));
   35.59  	dp->unique_id = unique_id++;
   35.60 +	dp->parent = parent;
   35.61  
   35.62  	kref_init(&dp->kref);
   35.63  
   35.64 @@ -1544,12 +1545,11 @@ static struct device_node * __init build
   35.65  {
   35.66  	struct device_node *dp;
   35.67  
   35.68 -	dp = create_node(node);
   35.69 +	dp = create_node(node, parent);
   35.70  	if (dp) {
   35.71  		*(*nextp) = dp;
   35.72  		*nextp = &dp->allnext;
   35.73  
   35.74 -		dp->parent = parent;
   35.75  		dp->path_component_name = build_path_component(dp);
   35.76  		dp->full_name = build_full_name(dp);
   35.77  
   35.78 @@ -1565,7 +1565,7 @@ void __init prom_build_devicetree(void)
   35.79  {
   35.80  	struct device_node **nextp;
   35.81  
   35.82 -	allnodes = create_node(prom_root_node);
   35.83 +	allnodes = create_node(prom_root_node, NULL);
   35.84  	allnodes->path_component_name = "";
   35.85  	allnodes->full_name = "/";
   35.86  
    36.1 --- a/arch/sparc64/kernel/time.c	Tue Oct 02 09:52:15 2007 +0100
    36.2 +++ b/arch/sparc64/kernel/time.c	Wed Oct 03 10:00:44 2007 +0100
    36.3 @@ -983,7 +983,7 @@ static struct time_interpolator sparc64_
    36.4  };
    36.5  
    36.6  /* The quotient formula is taken from the IA64 port. */
    36.7 -#define SPARC64_NSEC_PER_CYC_SHIFT	30UL
    36.8 +#define SPARC64_NSEC_PER_CYC_SHIFT	10UL
    36.9  void __init time_init(void)
   36.10  {
   36.11  	unsigned long clock = sparc64_init_timers();
    37.1 --- a/arch/sparc64/mm/init.c	Tue Oct 02 09:52:15 2007 +0100
    37.2 +++ b/arch/sparc64/mm/init.c	Wed Oct 03 10:00:44 2007 +0100
    37.3 @@ -920,8 +920,7 @@ static unsigned long __init bootmem_init
    37.4  	if (sparc_ramdisk_image || sparc_ramdisk_image64) {
    37.5  		unsigned long ramdisk_image = sparc_ramdisk_image ?
    37.6  			sparc_ramdisk_image : sparc_ramdisk_image64;
    37.7 -		if (ramdisk_image >= (unsigned long)_end - 2 * PAGE_SIZE)
    37.8 -			ramdisk_image -= KERNBASE;
    37.9 +		ramdisk_image -= KERNBASE;
   37.10  		initrd_start = ramdisk_image + phys_base;
   37.11  		initrd_end = initrd_start + sparc_ramdisk_size;
   37.12  		if (initrd_end > end_of_phys_memory) {
    38.1 --- a/arch/um/Kconfig	Tue Oct 02 09:52:15 2007 +0100
    38.2 +++ b/arch/um/Kconfig	Wed Oct 03 10:00:44 2007 +0100
    38.3 @@ -1,3 +1,8 @@
    38.4 +config DEFCONFIG_LIST
    38.5 +	string
    38.6 +	option defconfig_list
    38.7 +	default "arch/$ARCH/defconfig"
    38.8 +
    38.9  # UML uses the generic IRQ sugsystem
   38.10  config GENERIC_HARDIRQS
   38.11  	bool
    39.1 --- a/arch/um/Makefile-x86_64	Tue Oct 02 09:52:15 2007 +0100
    39.2 +++ b/arch/um/Makefile-x86_64	Wed Oct 03 10:00:44 2007 +0100
    39.3 @@ -1,7 +1,7 @@
    39.4  # Copyright 2003 - 2004 Pathscale, Inc
    39.5  # Released under the GPL
    39.6  
    39.7 -core-y += arch/um/sys-x86_64/
    39.8 +core-y += arch/um/sys-x86_64/ arch/x86_64/crypto/
    39.9  START := 0x60000000
   39.10  
   39.11  #We #undef __x86_64__ for kernelspace, not for userspace where
    40.1 --- a/arch/um/include/common-offsets.h	Tue Oct 02 09:52:15 2007 +0100
    40.2 +++ b/arch/um/include/common-offsets.h	Wed Oct 03 10:00:44 2007 +0100
    40.3 @@ -15,3 +15,4 @@ DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG);
    40.4  DEFINE(UM_ELF_CLASS, ELF_CLASS);
    40.5  DEFINE(UM_ELFCLASS32, ELFCLASS32);
    40.6  DEFINE(UM_ELFCLASS64, ELFCLASS64);
    40.7 +DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx));
    41.1 --- a/arch/um/include/kern_util.h	Tue Oct 02 09:52:15 2007 +0100
    41.2 +++ b/arch/um/include/kern_util.h	Wed Oct 03 10:00:44 2007 +0100
    41.3 @@ -6,7 +6,6 @@
    41.4  #ifndef __KERN_UTIL_H__
    41.5  #define __KERN_UTIL_H__
    41.6  
    41.7 -#include "linux/threads.h"
    41.8  #include "sysdep/ptrace.h"
    41.9  #include "sysdep/faultinfo.h"
   41.10  
    42.1 --- a/arch/um/include/sysdep-i386/kernel-offsets.h	Tue Oct 02 09:52:15 2007 +0100
    42.2 +++ b/arch/um/include/sysdep-i386/kernel-offsets.h	Wed Oct 03 10:00:44 2007 +0100
    42.3 @@ -1,6 +1,7 @@
    42.4  #include <linux/stddef.h>
    42.5  #include <linux/sched.h>
    42.6  #include <linux/elf.h>
    42.7 +#include <linux/crypto.h>
    42.8  #include <asm/mman.h>
    42.9  
   42.10  #define DEFINE(sym, val) \
    43.1 --- a/arch/um/include/sysdep-x86_64/kernel-offsets.h	Tue Oct 02 09:52:15 2007 +0100
    43.2 +++ b/arch/um/include/sysdep-x86_64/kernel-offsets.h	Wed Oct 03 10:00:44 2007 +0100
    43.3 @@ -2,6 +2,7 @@
    43.4  #include <linux/sched.h>
    43.5  #include <linux/time.h>
    43.6  #include <linux/elf.h>
    43.7 +#include <linux/crypto.h>
    43.8  #include <asm/page.h>
    43.9  #include <asm/mman.h>
   43.10  
    44.1 --- a/arch/um/os-Linux/process.c	Tue Oct 02 09:52:15 2007 +0100
    44.2 +++ b/arch/um/os-Linux/process.c	Wed Oct 03 10:00:44 2007 +0100
    44.3 @@ -141,11 +141,9 @@ void os_usr1_process(int pid)
    44.4   * syscalls, and also breaks with clone(), which does not unshare the TLS.
    44.5   */
    44.6  
    44.7 -inline _syscall0(pid_t, getpid)
    44.8 -
    44.9  int os_getpid(void)
   44.10  {
   44.11 -	return(getpid());
   44.12 +	return syscall(__NR_getpid);
   44.13  }
   44.14  
   44.15  int os_getpgrp(void)
    45.1 --- a/arch/um/os-Linux/sys-i386/tls.c	Tue Oct 02 09:52:15 2007 +0100
    45.2 +++ b/arch/um/os-Linux/sys-i386/tls.c	Wed Oct 03 10:00:44 2007 +0100
    45.3 @@ -1,10 +1,10 @@
    45.4  #include <errno.h>
    45.5 +#include <sys/syscall.h>
    45.6 +#include <unistd.h>
    45.7  #include <linux/unistd.h>
    45.8  #include "sysdep/tls.h"
    45.9  #include "user_util.h"
   45.10  
   45.11 -static _syscall1(int, get_thread_area, user_desc_t *, u_info);
   45.12 -
   45.13  /* Checks whether host supports TLS, and sets *tls_min according to the value
   45.14   * valid on the host.
   45.15   * i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */
   45.16 @@ -17,7 +17,7 @@ void check_host_supports_tls(int *suppor
   45.17  		user_desc_t info;
   45.18  		info.entry_number = val[i];
   45.19  
   45.20 -		if (get_thread_area(&info) == 0) {
   45.21 +		if(syscall(__NR_get_thread_area, &info) == 0){
   45.22  			*tls_min = val[i];
   45.23  			*supports_tls = 1;
   45.24  			return;
    46.1 --- a/arch/um/os-Linux/tls.c	Tue Oct 02 09:52:15 2007 +0100
    46.2 +++ b/arch/um/os-Linux/tls.c	Wed Oct 03 10:00:44 2007 +0100
    46.3 @@ -1,6 +1,8 @@
    46.4  #include <errno.h>
    46.5  #include <sys/ptrace.h>
    46.6 +#include <sys/syscall.h>
    46.7  #include <asm/ldt.h>
    46.8 +#include <unistd.h>
    46.9  #include "sysdep/tls.h"
   46.10  #include "uml-config.h"
   46.11  
   46.12 @@ -48,14 +50,11 @@ int os_get_thread_area(user_desc_t *info
   46.13  #ifdef UML_CONFIG_MODE_TT
   46.14  #include "linux/unistd.h"
   46.15  
   46.16 -static _syscall1(int, get_thread_area, user_desc_t *, u_info);
   46.17 -static _syscall1(int, set_thread_area, user_desc_t *, u_info);
   46.18 -
   46.19  int do_set_thread_area_tt(user_desc_t *info)
   46.20  {
   46.21  	int ret;
   46.22  
   46.23 -	ret = set_thread_area(info);
   46.24 +	ret = syscall(__NR_set_thread_area, info);
   46.25  	if (ret < 0) {
   46.26  		ret = -errno;
   46.27  	}
   46.28 @@ -66,7 +65,7 @@ int do_get_thread_area_tt(user_desc_t *i
   46.29  {
   46.30  	int ret;
   46.31  
   46.32 -	ret = get_thread_area(info);
   46.33 +	ret = syscall(__NR_get_thread_area, info);
   46.34  	if (ret < 0) {
   46.35  		ret = -errno;
   46.36  	}
    47.1 --- a/arch/um/sys-x86_64/stub_segv.c	Tue Oct 02 09:52:15 2007 +0100
    47.2 +++ b/arch/um/sys-x86_64/stub_segv.c	Wed Oct 03 10:00:44 2007 +0100
    47.3 @@ -5,7 +5,6 @@
    47.4  
    47.5  #include <stddef.h>
    47.6  #include <signal.h>
    47.7 -#include <linux/compiler.h>
    47.8  #include <asm/unistd.h>
    47.9  #include "uml-config.h"
   47.10  #include "sysdep/sigcontext.h"
    48.1 --- a/arch/x86_64/ia32/ptrace32.c	Tue Oct 02 09:52:15 2007 +0100
    48.2 +++ b/arch/x86_64/ia32/ptrace32.c	Wed Oct 03 10:00:44 2007 +0100
    48.3 @@ -239,6 +239,7 @@ asmlinkage long sys32_ptrace(long reques
    48.4  	case PTRACE_SINGLESTEP:
    48.5  	case PTRACE_DETACH:
    48.6  	case PTRACE_SYSCALL:
    48.7 +	case PTRACE_OLDSETOPTIONS:
    48.8  	case PTRACE_SETOPTIONS:
    48.9  		return sys_ptrace(request, pid, addr, data); 
   48.10  
    49.1 --- a/arch/x86_64/kernel/entry.S	Tue Oct 02 09:52:15 2007 +0100
    49.2 +++ b/arch/x86_64/kernel/entry.S	Wed Oct 03 10:00:44 2007 +0100
    49.3 @@ -146,6 +146,10 @@ 1:
    49.4  /* rdi:	prev */	
    49.5  ENTRY(ret_from_fork)
    49.6  	CFI_DEFAULT_STACK
    49.7 +	push kernel_eflags(%rip)
    49.8 +	CFI_ADJUST_CFA_OFFSET 4
    49.9 +	popf				# reset kernel eflags
   49.10 +	CFI_ADJUST_CFA_OFFSET -4
   49.11  	call schedule_tail
   49.12  	GET_THREAD_INFO(%rcx)
   49.13  	testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%rcx)
    50.1 --- a/arch/x86_64/kernel/pci-calgary.c	Tue Oct 02 09:52:15 2007 +0100
    50.2 +++ b/arch/x86_64/kernel/pci-calgary.c	Wed Oct 03 10:00:44 2007 +0100
    50.3 @@ -759,7 +759,16 @@ static inline unsigned int __init locate
    50.4  	int rionodeid;
    50.5  	u32 address;
    50.6  
    50.7 -	rionodeid = (dev->bus->number % 15 > 4) ? 3 : 2;
    50.8 +	/*
    50.9 +	 * Each Calgary has four busses. The first four busses (first Calgary)
   50.10 +	 * have RIO node ID 2, then the next four (second Calgary) have RIO
   50.11 +	 * node ID 3, the next four (third Calgary) have node ID 2 again, etc.
   50.12 +	 * We use a gross hack - relying on the dev->bus->number ordering,
   50.13 +	 * modulo 14 - to decide which Calgary a given bus is on. Busses 0, 1,
   50.14 +	 * 2 and 4 are on the first Calgary (id 2), 6, 8, a and c are on the
   50.15 +	 * second (id 3), and then it repeats modulo 14.
   50.16 + 	 */
   50.17 +	rionodeid = (dev->bus->number % 14 > 4) ? 3 : 2;
   50.18  	/*
   50.19  	 * register space address calculation as follows:
   50.20  	 * FE0MB-8MB*OneBasedChassisNumber+1MB*(RioNodeId-ChassisBase)
   50.21 @@ -767,7 +776,7 @@ static inline unsigned int __init locate
   50.22  	 * RioNodeId is 2 for first Calgary, 3 for second Calgary
   50.23  	 */
   50.24  	address = START_ADDRESS	-
   50.25 -		(0x800000 * (ONE_BASED_CHASSIS_NUM + dev->bus->number / 15)) +
   50.26 +		(0x800000 * (ONE_BASED_CHASSIS_NUM + dev->bus->number / 14)) +
   50.27  		(0x100000) * (rionodeid - CHASSIS_BASE);
   50.28  	return address;
   50.29  }
    51.1 --- a/arch/x86_64/kernel/process.c	Tue Oct 02 09:52:15 2007 +0100
    51.2 +++ b/arch/x86_64/kernel/process.c	Wed Oct 03 10:00:44 2007 +0100
    51.3 @@ -571,6 +571,9 @@ out:
    51.4  		prev->gsindex = gsindex;
    51.5  	}
    51.6  
    51.7 +	/* Must be after DS reload */
    51.8 +	unlazy_fpu(prev_p);
    51.9 +
   51.10  	/* 
   51.11  	 * Switch the PDA and FPU contexts.
   51.12  	 */
   51.13 @@ -578,10 +581,6 @@ out:
   51.14  	write_pda(oldrsp, next->userrsp); 
   51.15  	write_pda(pcurrent, next_p); 
   51.16  
   51.17 -	/* This must be here to ensure both math_state_restore() and
   51.18 -	   kernel_fpu_begin() work consistently. 
   51.19 -	   And the AMD workaround requires it to be after DS reload. */
   51.20 -	unlazy_fpu(prev_p);
   51.21  	write_pda(kernelstack,
   51.22  		  task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET);
   51.23  
    52.1 --- a/arch/x86_64/kernel/setup.c	Tue Oct 02 09:52:15 2007 +0100
    52.2 +++ b/arch/x86_64/kernel/setup.c	Wed Oct 03 10:00:44 2007 +0100
    52.3 @@ -1010,7 +1010,10 @@ static void __cpuinit init_intel(struct 
    52.4  	if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
    52.5  	    (c->x86 == 0x6 && c->x86_model >= 0x0e))
    52.6  		set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
    52.7 -	set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
    52.8 +	if (c->x86 == 15)
    52.9 +		set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
   52.10 +	else
   52.11 +		clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
   52.12   	c->x86_max_cores = intel_num_cpu_cores(c);
   52.13  
   52.14  	srat_detect_node();
    53.1 --- a/arch/x86_64/kernel/setup64.c	Tue Oct 02 09:52:15 2007 +0100
    53.2 +++ b/arch/x86_64/kernel/setup64.c	Wed Oct 03 10:00:44 2007 +0100
    53.3 @@ -178,6 +178,8 @@ void __cpuinit check_efer(void)
    53.4          }       
    53.5  }
    53.6  
    53.7 +unsigned long kernel_eflags;
    53.8 +
    53.9  /*
   53.10   * cpu_init() initializes state that is per-CPU. Some data is already
   53.11   * initialized (naturally) in the bootstrap process, such as the GDT
   53.12 @@ -290,4 +292,6 @@ void __cpuinit cpu_init (void)
   53.13  	set_debugreg(0UL, 7);
   53.14  
   53.15  	fpu_init(); 
   53.16 +
   53.17 +	raw_local_save_flags(kernel_eflags);
   53.18  }
    54.1 --- a/arch/x86_64/kernel/time.c	Tue Oct 02 09:52:15 2007 +0100
    54.2 +++ b/arch/x86_64/kernel/time.c	Wed Oct 03 10:00:44 2007 +0100
    54.3 @@ -960,7 +960,7 @@ void __init time_init(void)
    54.4   	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
    54.5  #ifdef CONFIG_ACPI
    54.6  		/* But TSC doesn't tick in C3 so don't use it there */
    54.7 -		if (acpi_fadt.length > 0 && acpi_fadt.plvl3_lat < 100)
    54.8 +		if (acpi_fadt.length > 0 && acpi_fadt.plvl3_lat < 1000)
    54.9  			return 1;
   54.10  #endif
   54.11   		return 0;
    55.1 --- a/block/elevator.c	Tue Oct 02 09:52:15 2007 +0100
    55.2 +++ b/block/elevator.c	Wed Oct 03 10:00:44 2007 +0100
    55.3 @@ -892,7 +892,7 @@ ssize_t elv_iosched_show(request_queue_t
    55.4  	struct list_head *entry;
    55.5  	int len = 0;
    55.6  
    55.7 -	spin_lock_irq(q->queue_lock);
    55.8 +	spin_lock_irq(&elv_list_lock);
    55.9  	list_for_each(entry, &elv_list) {
   55.10  		struct elevator_type *__e;
   55.11  
   55.12 @@ -902,7 +902,7 @@ ssize_t elv_iosched_show(request_queue_t
   55.13  		else
   55.14  			len += sprintf(name+len, "%s ", __e->elevator_name);
   55.15  	}
   55.16 -	spin_unlock_irq(q->queue_lock);
   55.17 +	spin_unlock_irq(&elv_list_lock);
   55.18  
   55.19  	len += sprintf(len+name, "\n");
   55.20  	return len;
    56.1 --- a/block/ll_rw_blk.c	Tue Oct 02 09:52:15 2007 +0100
    56.2 +++ b/block/ll_rw_blk.c	Wed Oct 03 10:00:44 2007 +0100
    56.3 @@ -3021,6 +3021,7 @@ void generic_make_request(struct bio *bi
    56.4  {
    56.5  	request_queue_t *q;
    56.6  	sector_t maxsector;
    56.7 +	sector_t old_sector;
    56.8  	int ret, nr_sectors = bio_sectors(bio);
    56.9  	dev_t old_dev;
   56.10  
   56.11 @@ -3049,7 +3050,7 @@ void generic_make_request(struct bio *bi
   56.12  	 * NOTE: we don't repeat the blk_size check for each new device.
   56.13  	 * Stacking drivers are expected to know what they are doing.
   56.14  	 */
   56.15 -	maxsector = -1;
   56.16 +	old_sector = -1;
   56.17  	old_dev = 0;
   56.18  	do {
   56.19  		char b[BDEVNAME_SIZE];
   56.20 @@ -3083,15 +3084,30 @@ end_io:
   56.21  		 */
   56.22  		blk_partition_remap(bio);
   56.23  
   56.24 -		if (maxsector != -1)
   56.25 +		if (old_sector != -1)
   56.26  			blk_add_trace_remap(q, bio, old_dev, bio->bi_sector, 
   56.27 -					    maxsector);
   56.28 +					    old_sector);
   56.29  
   56.30  		blk_add_trace_bio(q, bio, BLK_TA_QUEUE);
   56.31  
   56.32 -		maxsector = bio->bi_sector;
   56.33 +		old_sector = bio->bi_sector;
   56.34  		old_dev = bio->bi_bdev->bd_dev;
   56.35  
   56.36 +		maxsector = bio->bi_bdev->bd_inode->i_size >> 9;
   56.37 +		if (maxsector) {
   56.38 +			sector_t sector = bio->bi_sector;
   56.39 +
   56.40 +			if (maxsector < nr_sectors || maxsector - nr_sectors < sector) {
   56.41 +				/*
   56.42 +				 * This may well happen - partitions are not checked
   56.43 +				 * to make sure they are within the size of the
   56.44 +				 * whole device.
   56.45 +				 */
   56.46 +				handle_bad_sector(bio);
   56.47 +				goto end_io;
   56.48 +			}
   56.49 +		}
   56.50 +
   56.51  		ret = q->make_request_fn(q, bio);
   56.52  	} while (ret);
   56.53  }
    57.1 --- a/block/scsi_ioctl.c	Tue Oct 02 09:52:15 2007 +0100
    57.2 +++ b/block/scsi_ioctl.c	Wed Oct 03 10:00:44 2007 +0100
    57.3 @@ -246,10 +246,10 @@ static int sg_io(struct file *file, requ
    57.4  		switch (hdr->dxfer_direction) {
    57.5  		default:
    57.6  			return -EINVAL;
    57.7 -		case SG_DXFER_TO_FROM_DEV:
    57.8  		case SG_DXFER_TO_DEV:
    57.9  			writing = 1;
   57.10  			break;
   57.11 +		case SG_DXFER_TO_FROM_DEV:
   57.12  		case SG_DXFER_FROM_DEV:
   57.13  			break;
   57.14  		}
   57.15 @@ -286,9 +286,8 @@ static int sg_io(struct file *file, requ
   57.16  	 * fill in request structure
   57.17  	 */
   57.18  	rq->cmd_len = hdr->cmd_len;
   57.19 +	memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
   57.20  	memcpy(rq->cmd, cmd, hdr->cmd_len);
   57.21 -	if (sizeof(rq->cmd) != hdr->cmd_len)
   57.22 -		memset(rq->cmd + hdr->cmd_len, 0, sizeof(rq->cmd) - hdr->cmd_len);
   57.23  
   57.24  	memset(sense, 0, sizeof(sense));
   57.25  	rq->sense = sense;
    58.1 --- a/drivers/block/DAC960.c	Tue Oct 02 09:52:15 2007 +0100
    58.2 +++ b/drivers/block/DAC960.c	Wed Oct 03 10:00:44 2007 +0100
    58.3 @@ -7115,7 +7115,7 @@ static struct pci_device_id DAC960_id_ta
    58.4  	{
    58.5  		.vendor 	= PCI_VENDOR_ID_MYLEX,
    58.6  		.device		= PCI_DEVICE_ID_MYLEX_DAC960_GEM,
    58.7 -		.subvendor	= PCI_ANY_ID,
    58.8 +		.subvendor	= PCI_VENDOR_ID_MYLEX,
    58.9  		.subdevice	= PCI_ANY_ID,
   58.10  		.driver_data	= (unsigned long) &DAC960_GEM_privdata,
   58.11  	},
    59.1 --- a/drivers/block/cciss.c	Tue Oct 02 09:52:15 2007 +0100
    59.2 +++ b/drivers/block/cciss.c	Wed Oct 03 10:00:44 2007 +0100
    59.3 @@ -1302,6 +1302,12 @@ static void cciss_softirq_done(struct re
    59.4  
    59.5  	complete_buffers(rq->bio, rq->errors);
    59.6  
    59.7 +	if (blk_fs_request(rq)) {
    59.8 +		const int rw = rq_data_dir(rq);
    59.9 +
   59.10 +		disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
   59.11 +	}
   59.12 +
   59.13  #ifdef CCISS_DEBUG
   59.14  	printk("Done with %p\n", rq);
   59.15  #endif				/* CCISS_DEBUG */
    60.1 --- a/drivers/block/cpqarray.c	Tue Oct 02 09:52:15 2007 +0100
    60.2 +++ b/drivers/block/cpqarray.c	Wed Oct 03 10:00:44 2007 +0100
    60.3 @@ -1000,6 +1000,7 @@ static inline void complete_buffers(stru
    60.4   */
    60.5  static inline void complete_command(cmdlist_t *cmd, int timeout)
    60.6  {
    60.7 +	struct request *rq = cmd->rq;
    60.8  	int ok=1;
    60.9  	int i, ddir;
   60.10  
   60.11 @@ -1031,12 +1032,18 @@ static inline void complete_command(cmdl
   60.12                  pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr,
   60.13  				cmd->req.sg[i].size, ddir);
   60.14  
   60.15 -	complete_buffers(cmd->rq->bio, ok);
   60.16 +	complete_buffers(rq->bio, ok);
   60.17  
   60.18 -	add_disk_randomness(cmd->rq->rq_disk);
   60.19 +	if (blk_fs_request(rq)) {
   60.20 +		const int rw = rq_data_dir(rq);
   60.21  
   60.22 -        DBGPX(printk("Done with %p\n", cmd->rq););
   60.23 -	end_that_request_last(cmd->rq, ok ? 1 : -EIO);
   60.24 +		disk_stat_add(rq->rq_disk, sectors[rw], rq->nr_sectors);
   60.25 +	}
   60.26 +
   60.27 +	add_disk_randomness(rq->rq_disk);
   60.28 +
   60.29 +	DBGPX(printk("Done with %p\n", rq););
   60.30 +	end_that_request_last(rq, ok ? 1 : -EIO);
   60.31  }
   60.32  
   60.33  /*
    61.1 --- a/drivers/char/agp/generic.c	Tue Oct 02 09:52:15 2007 +0100
    61.2 +++ b/drivers/char/agp/generic.c	Wed Oct 03 10:00:44 2007 +0100
    61.3 @@ -1020,7 +1020,7 @@ void *agp_generic_alloc_page(struct agp_
    61.4  {
    61.5  	struct page * page;
    61.6  
    61.7 -	page = alloc_page(GFP_KERNEL);
    61.8 +	page = alloc_page(GFP_KERNEL | GFP_DMA32);
    61.9  	if (page == NULL)
   61.10  		return NULL;
   61.11  
    62.1 --- a/drivers/char/agp/intel-agp.c	Tue Oct 02 09:52:15 2007 +0100
    62.2 +++ b/drivers/char/agp/intel-agp.c	Wed Oct 03 10:00:44 2007 +0100
    62.3 @@ -160,7 +160,7 @@ static void *i8xx_alloc_pages(void)
    62.4  {
    62.5  	struct page * page;
    62.6  
    62.7 -	page = alloc_pages(GFP_KERNEL, 2);
    62.8 +	page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2);
    62.9  	if (page == NULL)
   62.10  		return NULL;
   62.11  
    63.1 --- a/drivers/char/hw_random/intel-rng.c	Tue Oct 02 09:52:15 2007 +0100
    63.2 +++ b/drivers/char/hw_random/intel-rng.c	Wed Oct 03 10:00:44 2007 +0100
    63.3 @@ -50,6 +50,43 @@
    63.4  #define INTEL_RNG_ADDR_LEN			3
    63.5  
    63.6  /*
    63.7 + * LPC bridge PCI config space registers
    63.8 + */
    63.9 +#define FWH_DEC_EN1_REG_OLD			0xe3
   63.10 +#define FWH_DEC_EN1_REG_NEW			0xd9 /* high byte of 16-bit register */
   63.11 +#define FWH_F8_EN_MASK				0x80
   63.12 +
   63.13 +#define BIOS_CNTL_REG_OLD			0x4e
   63.14 +#define BIOS_CNTL_REG_NEW			0xdc
   63.15 +#define BIOS_CNTL_WRITE_ENABLE_MASK		0x01
   63.16 +#define BIOS_CNTL_LOCK_ENABLE_MASK		0x02
   63.17 +
   63.18 +/*
   63.19 + * Magic address at which Intel Firmware Hubs get accessed
   63.20 + */
   63.21 +#define INTEL_FWH_ADDR				0xffff0000
   63.22 +#define INTEL_FWH_ADDR_LEN			2
   63.23 +
   63.24 +/*
   63.25 + * Intel Firmware Hub command codes (write to any address inside the device)
   63.26 + */
   63.27 +#define INTEL_FWH_RESET_CMD			0xff /* aka READ_ARRAY */
   63.28 +#define INTEL_FWH_READ_ID_CMD			0x90
   63.29 +
   63.30 +/*
   63.31 + * Intel Firmware Hub Read ID command result addresses
   63.32 + */
   63.33 +#define INTEL_FWH_MANUFACTURER_CODE_ADDRESS	0x000000
   63.34 +#define INTEL_FWH_DEVICE_CODE_ADDRESS		0x000001
   63.35 +
   63.36 +/*
   63.37 + * Intel Firmware Hub Read ID command result values
   63.38 + */
   63.39 +#define INTEL_FWH_MANUFACTURER_CODE		0x89
   63.40 +#define INTEL_FWH_DEVICE_CODE_8M		0xac
   63.41 +#define INTEL_FWH_DEVICE_CODE_4M		0xad
   63.42 +
   63.43 +/*
   63.44   * Data for PCI driver interface
   63.45   *
   63.46   * This data only exists for exporting the supported
   63.47 @@ -58,12 +95,50 @@
   63.48   * want to register another driver on the same PCI id.
   63.49   */
   63.50  static const struct pci_device_id pci_tbl[] = {
   63.51 -	{ 0x8086, 0x2418, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
   63.52 -	{ 0x8086, 0x2428, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
   63.53 -	{ 0x8086, 0x2430, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
   63.54 -	{ 0x8086, 0x2448, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
   63.55 -	{ 0x8086, 0x244e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
   63.56 -	{ 0x8086, 0x245e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, },
   63.57 +/* AA
   63.58 +	{ 0x8086, 0x2418, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, */
   63.59 +	{ 0x8086, 0x2410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* AA */
   63.60 +/* AB
   63.61 +	{ 0x8086, 0x2428, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, */
   63.62 +	{ 0x8086, 0x2420, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* AB */
   63.63 +/* ??
   63.64 +	{ 0x8086, 0x2430, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, */
   63.65 +/* BAM, CAM, DBM, FBM, GxM
   63.66 +	{ 0x8086, 0x2448, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, */
   63.67 +	{ 0x8086, 0x244c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* BAM */
   63.68 +	{ 0x8086, 0x248c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CAM */
   63.69 +	{ 0x8086, 0x24cc, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* DBM */
   63.70 +	{ 0x8086, 0x2641, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* FBM */
   63.71 +	{ 0x8086, 0x27b9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* GxM */
   63.72 +	{ 0x8086, 0x27bd, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* GxM DH */
   63.73 +/* BA, CA, DB, Ex, 6300, Fx, 631x/632x, Gx
   63.74 +	{ 0x8086, 0x244e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, */
   63.75 +	{ 0x8086, 0x2440, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* BA */
   63.76 +	{ 0x8086, 0x2480, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* CA */
   63.77 +	{ 0x8086, 0x24c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* DB */
   63.78 +	{ 0x8086, 0x24d0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Ex */
   63.79 +	{ 0x8086, 0x25a1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 6300 */
   63.80 +	{ 0x8086, 0x2640, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Fx */
   63.81 +	{ 0x8086, 0x2670, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.82 +	{ 0x8086, 0x2671, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.83 +	{ 0x8086, 0x2672, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.84 +	{ 0x8086, 0x2673, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.85 +	{ 0x8086, 0x2674, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.86 +	{ 0x8086, 0x2675, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.87 +	{ 0x8086, 0x2676, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.88 +	{ 0x8086, 0x2677, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.89 +	{ 0x8086, 0x2678, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.90 +	{ 0x8086, 0x2679, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.91 +	{ 0x8086, 0x267a, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.92 +	{ 0x8086, 0x267b, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.93 +	{ 0x8086, 0x267c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.94 +	{ 0x8086, 0x267d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.95 +	{ 0x8086, 0x267e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.96 +	{ 0x8086, 0x267f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* 631x/632x */
   63.97 +	{ 0x8086, 0x27b8, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* Gx */
   63.98 +/* E
   63.99 +	{ 0x8086, 0x245e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, */
  63.100 +	{ 0x8086, 0x2450, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* E  */
  63.101  	{ 0, },	/* terminate list */
  63.102  };
  63.103  MODULE_DEVICE_TABLE(pci, pci_tbl);
  63.104 @@ -138,22 +213,115 @@ static struct hwrng intel_rng = {
  63.105  };
  63.106  
  63.107  
  63.108 +#ifdef CONFIG_SMP
  63.109 +static char __initdata waitflag;
  63.110 +
  63.111 +static void __init intel_init_wait(void *unused)
  63.112 +{
  63.113 +	while (waitflag)
  63.114 +		cpu_relax();
  63.115 +}
  63.116 +#endif
  63.117 +
  63.118  static int __init mod_init(void)
  63.119  {
  63.120  	int err = -ENODEV;
  63.121 +	unsigned i;
  63.122 +	struct pci_dev *dev = NULL;
  63.123  	void __iomem *mem;
  63.124 -	u8 hw_status;
  63.125 +	unsigned long flags;
  63.126 +	u8 bios_cntl_off, fwh_dec_en1_off;
  63.127 +	u8 bios_cntl_val = 0xff, fwh_dec_en1_val = 0xff;
  63.128 +	u8 hw_status, mfc, dvc;
  63.129  
  63.130 -	if (!pci_dev_present(pci_tbl))
  63.131 +	for (i = 0; !dev && pci_tbl[i].vendor; ++i)
  63.132 +		dev = pci_get_device(pci_tbl[i].vendor, pci_tbl[i].device, NULL);
  63.133 +
  63.134 +	if (!dev)
  63.135  		goto out; /* Device not found. */
  63.136  
  63.137 +	/* Check for Intel 82802 */
  63.138 +	if (dev->device < 0x2640) {
  63.139 +		fwh_dec_en1_off = FWH_DEC_EN1_REG_OLD;
  63.140 +		bios_cntl_off = BIOS_CNTL_REG_OLD;
  63.141 +	} else {
  63.142 +		fwh_dec_en1_off = FWH_DEC_EN1_REG_NEW;
  63.143 +		bios_cntl_off = BIOS_CNTL_REG_NEW;
  63.144 +	}
  63.145 +
  63.146 +	pci_read_config_byte(dev, fwh_dec_en1_off, &fwh_dec_en1_val);
  63.147 +	pci_read_config_byte(dev, bios_cntl_off, &bios_cntl_val);
  63.148 +
  63.149 +	mem = ioremap_nocache(INTEL_FWH_ADDR, INTEL_FWH_ADDR_LEN);
  63.150 +	if (mem == NULL) {
  63.151 +		pci_dev_put(dev);
  63.152 +		err = -EBUSY;
  63.153 +		goto out;
  63.154 +	}
  63.155 +
  63.156 +	/*
  63.157 +	 * Since the BIOS code/data is going to disappear from its normal
  63.158 +	 * location with the Read ID command, all activity on the system
  63.159 +	 * must be stopped until the state is back to normal.
  63.160 +	 */
  63.161 +#ifdef CONFIG_SMP
  63.162 +	set_mb(waitflag, 1);
  63.163 +	if (smp_call_function(intel_init_wait, NULL, 1, 0) != 0) {
  63.164 +		set_mb(waitflag, 0);
  63.165 +		pci_dev_put(dev);
  63.166 +		printk(KERN_ERR PFX "cannot run on all processors\n");
  63.167 +		err = -EAGAIN;
  63.168 +		goto err_unmap;
  63.169 +	}
  63.170 +#endif
  63.171 +	local_irq_save(flags);
  63.172 +
  63.173 +	if (!(fwh_dec_en1_val & FWH_F8_EN_MASK))
  63.174 +		pci_write_config_byte(dev,
  63.175 +		                      fwh_dec_en1_off,
  63.176 +		                      fwh_dec_en1_val | FWH_F8_EN_MASK);
  63.177 +	if (!(bios_cntl_val &
  63.178 +	      (BIOS_CNTL_LOCK_ENABLE_MASK|BIOS_CNTL_WRITE_ENABLE_MASK)))
  63.179 +		pci_write_config_byte(dev,
  63.180 +		                      bios_cntl_off,
  63.181 +		                      bios_cntl_val | BIOS_CNTL_WRITE_ENABLE_MASK);
  63.182 +
  63.183 +	writeb(INTEL_FWH_RESET_CMD, mem);
  63.184 +	writeb(INTEL_FWH_READ_ID_CMD, mem);
  63.185 +	mfc = readb(mem + INTEL_FWH_MANUFACTURER_CODE_ADDRESS);
  63.186 +	dvc = readb(mem + INTEL_FWH_DEVICE_CODE_ADDRESS);
  63.187 +	writeb(INTEL_FWH_RESET_CMD, mem);
  63.188 +
  63.189 +	if (!(bios_cntl_val &
  63.190 +	      (BIOS_CNTL_LOCK_ENABLE_MASK|BIOS_CNTL_WRITE_ENABLE_MASK)))
  63.191 +		pci_write_config_byte(dev, bios_cntl_off, bios_cntl_val);
  63.192 +	if (!(fwh_dec_en1_val & FWH_F8_EN_MASK))
  63.193 +		pci_write_config_byte(dev, fwh_dec_en1_off, fwh_dec_en1_val);
  63.194 +
  63.195 +	local_irq_restore(flags);
  63.196 +#ifdef CONFIG_SMP
  63.197 +	/* Tell other CPUs to resume. */
  63.198 +	set_mb(waitflag, 0);
  63.199 +#endif
  63.200 +
  63.201 +	iounmap(mem);
  63.202 +	pci_dev_put(dev);
  63.203 +
  63.204 +	if (mfc != INTEL_FWH_MANUFACTURER_CODE ||
  63.205 +	    (dvc != INTEL_FWH_DEVICE_CODE_8M &&
  63.206 +	     dvc != INTEL_FWH_DEVICE_CODE_4M)) {
  63.207 +		printk(KERN_ERR PFX "FWH not detected\n");
  63.208 +		err = -ENODEV;
  63.209 +		goto out;
  63.210 +	}
  63.211 +
  63.212  	err = -ENOMEM;
  63.213  	mem = ioremap(INTEL_RNG_ADDR, INTEL_RNG_ADDR_LEN);
  63.214  	if (!mem)
  63.215  		goto out;
  63.216  	intel_rng.priv = (unsigned long)mem;
  63.217  
  63.218 -	/* Check for Intel 82802 */
  63.219 +	/* Check for Random Number Generator */
  63.220  	err = -ENODEV;
  63.221  	hw_status = hwstatus_get(mem);
  63.222  	if ((hw_status & INTEL_RNG_PRESENT) == 0)
    64.1 --- a/drivers/char/ipmi/ipmi_si_intf.c	Tue Oct 02 09:52:15 2007 +0100
    64.2 +++ b/drivers/char/ipmi/ipmi_si_intf.c	Wed Oct 03 10:00:44 2007 +0100
    64.3 @@ -1845,7 +1845,7 @@ static int ipmi_pci_resume(struct pci_de
    64.4  
    64.5  static struct pci_device_id ipmi_pci_devices[] = {
    64.6  	{ PCI_DEVICE(PCI_HP_VENDOR_ID, PCI_MMC_DEVICE_ID) },
    64.7 -	{ PCI_DEVICE_CLASS(PCI_ERMC_CLASSCODE, PCI_ERMC_CLASSCODE) }
    64.8 +	{ PCI_DEVICE_CLASS(PCI_ERMC_CLASSCODE, PCI_ERMC_CLASSCODE_MASK) }
    64.9  };
   64.10  MODULE_DEVICE_TABLE(pci, ipmi_pci_devices);
   64.11  
    65.1 --- a/drivers/char/isicom.c	Tue Oct 02 09:52:15 2007 +0100
    65.2 +++ b/drivers/char/isicom.c	Wed Oct 03 10:00:44 2007 +0100
    65.3 @@ -1062,11 +1062,12 @@ static void isicom_shutdown_port(struct 
    65.4  static void isicom_close(struct tty_struct *tty, struct file *filp)
    65.5  {
    65.6  	struct isi_port *port = tty->driver_data;
    65.7 -	struct isi_board *card = port->card;
    65.8 +	struct isi_board *card;
    65.9  	unsigned long flags;
   65.10  
   65.11  	if (!port)
   65.12  		return;
   65.13 +	card = port->card;
   65.14  	if (isicom_paranoia_check(port, tty->name, "isicom_close"))
   65.15  		return;
   65.16  
    66.1 --- a/drivers/char/mem.c	Tue Oct 02 09:52:15 2007 +0100
    66.2 +++ b/drivers/char/mem.c	Wed Oct 03 10:00:44 2007 +0100
    66.3 @@ -618,7 +618,8 @@ static inline size_t read_zero_pagealign
    66.4  			count = size;
    66.5  
    66.6  		zap_page_range(vma, addr, count, NULL);
    66.7 -        	zeromap_page_range(vma, addr, count, PAGE_COPY);
    66.8 +        	if (zeromap_page_range(vma, addr, count, PAGE_COPY))
    66.9 +			break;
   66.10  
   66.11  		size -= count;
   66.12  		buf += count;
   66.13 @@ -685,11 +686,14 @@ out:
   66.14  
   66.15  static int mmap_zero(struct file * file, struct vm_area_struct * vma)
   66.16  {
   66.17 +	int err;
   66.18 +
   66.19  	if (vma->vm_flags & VM_SHARED)
   66.20  		return shmem_zero_setup(vma);
   66.21 -	if (zeromap_page_range(vma, vma->vm_start, vma->vm_end - vma->vm_start, vma->vm_page_prot))
   66.22 -		return -EAGAIN;
   66.23 -	return 0;
   66.24 +	err = zeromap_page_range(vma, vma->vm_start,
   66.25 +			vma->vm_end - vma->vm_start, vma->vm_page_prot);
   66.26 +	BUG_ON(err == -EEXIST);
   66.27 +	return err;
   66.28  }
   66.29  #else /* CONFIG_MMU */
   66.30  static ssize_t read_zero(struct file * file, char * buf, 
    67.1 --- a/drivers/char/rtc.c	Tue Oct 02 09:52:15 2007 +0100
    67.2 +++ b/drivers/char/rtc.c	Wed Oct 03 10:00:44 2007 +0100
    67.3 @@ -209,11 +209,12 @@ static const unsigned char days_in_mo[] 
    67.4   */
    67.5  static inline unsigned char rtc_is_updating(void)
    67.6  {
    67.7 +	unsigned long flags;
    67.8  	unsigned char uip;
    67.9  
   67.10 -	spin_lock_irq(&rtc_lock);
   67.11 +	spin_lock_irqsave(&rtc_lock, flags);
   67.12  	uip = (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP);
   67.13 -	spin_unlock_irq(&rtc_lock);
   67.14 +	spin_unlock_irqrestore(&rtc_lock, flags);
   67.15  	return uip;
   67.16  }
   67.17  
    68.1 --- a/drivers/char/watchdog/sc1200wdt.c	Tue Oct 02 09:52:15 2007 +0100
    68.2 +++ b/drivers/char/watchdog/sc1200wdt.c	Wed Oct 03 10:00:44 2007 +0100
    68.3 @@ -392,7 +392,7 @@ static int __init sc1200wdt_init(void)
    68.4  	if (io == -1) {
    68.5  		printk(KERN_ERR PFX "io parameter must be specified\n");
    68.6  		ret = -EINVAL;
    68.7 -		goto out_clean;
    68.8 +		goto out_pnp;
    68.9  	}
   68.10  
   68.11  #if defined CONFIG_PNP
   68.12 @@ -405,7 +405,7 @@ static int __init sc1200wdt_init(void)
   68.13  	if (!request_region(io, io_len, SC1200_MODULE_NAME)) {
   68.14  		printk(KERN_ERR PFX "Unable to register IO port %#x\n", io);
   68.15  		ret = -EBUSY;
   68.16 -		goto out_clean;
   68.17 +		goto out_pnp;
   68.18  	}
   68.19  
   68.20  	ret = sc1200wdt_probe();
   68.21 @@ -435,6 +435,11 @@ out_rbt:
   68.22  out_io:
   68.23  	release_region(io, io_len);
   68.24  
   68.25 +out_pnp:
   68.26 +#if defined CONFIG_PNP
   68.27 +	if (isapnp)
   68.28 +		pnp_unregister_driver(&scl200wdt_pnp_driver);
   68.29 +#endif
   68.30  	goto out_clean;
   68.31  }
   68.32  
    69.1 --- a/drivers/clocksource/scx200_hrt.c	Tue Oct 02 09:52:15 2007 +0100
    69.2 +++ b/drivers/clocksource/scx200_hrt.c	Wed Oct 03 10:00:44 2007 +0100
    69.3 @@ -63,7 +63,7 @@ static struct clocksource cs_hrt = {
    69.4  
    69.5  static int __init init_hrt_clocksource(void)
    69.6  {
    69.7 -	/* Make sure scx200 has initializedd the configuration block */
    69.8 +	/* Make sure scx200 has initialized the configuration block */
    69.9  	if (!scx200_cb_present())
   69.10  		return -ENODEV;
   69.11  
   69.12 @@ -76,7 +76,7 @@ static int __init init_hrt_clocksource(v
   69.13  	}
   69.14  
   69.15  	/* write timer config */
   69.16 -	outb(HR_TMEN | (mhz27) ? HR_TMCLKSEL : 0,
   69.17 +	outb(HR_TMEN | (mhz27 ? HR_TMCLKSEL : 0),
   69.18  	     scx200_cb_base + SCx200_TMCNFG_OFFSET);
   69.19  
   69.20  	if (mhz27) {
    70.1 --- a/drivers/cpufreq/cpufreq_stats.c	Tue Oct 02 09:52:15 2007 +0100
    70.2 +++ b/drivers/cpufreq/cpufreq_stats.c	Wed Oct 03 10:00:44 2007 +0100
    70.3 @@ -350,12 +350,10 @@ static int
    70.4  	}
    70.5  
    70.6  	register_hotcpu_notifier(&cpufreq_stat_cpu_notifier);
    70.7 -	lock_cpu_hotplug();
    70.8  	for_each_online_cpu(cpu) {
    70.9  		cpufreq_stat_cpu_callback(&cpufreq_stat_cpu_notifier, CPU_ONLINE,
   70.10  			(void *)(long)cpu);
   70.11  	}
   70.12 -	unlock_cpu_hotplug();
   70.13  	return 0;
   70.14  }
   70.15  static void
    71.1 --- a/drivers/i2c/chips/ds1337.c	Tue Oct 02 09:52:15 2007 +0100
    71.2 +++ b/drivers/i2c/chips/ds1337.c	Wed Oct 03 10:00:44 2007 +0100
    71.3 @@ -347,13 +347,19 @@ static void ds1337_init_client(struct i2
    71.4  
    71.5  	if ((status & 0x80) || (control & 0x80)) {
    71.6  		/* RTC not running */
    71.7 -		u8 buf[16];
    71.8 +		u8 buf[1+16];	/* First byte is interpreted as address */
    71.9  		struct i2c_msg msg[1];
   71.10  
   71.11  		dev_dbg(&client->dev, "%s: RTC not running!\n", __FUNCTION__);
   71.12  
   71.13  		/* Initialize all, including STATUS and CONTROL to zero */
   71.14  		memset(buf, 0, sizeof(buf));
   71.15 +
   71.16 +		/* Write valid values in the date/time registers */
   71.17 +		buf[1+DS1337_REG_DAY] = 1;
   71.18 +		buf[1+DS1337_REG_DATE] = 1;
   71.19 +		buf[1+DS1337_REG_MONTH] = 1;
   71.20 +
   71.21  		msg[0].addr = client->addr;
   71.22  		msg[0].flags = 0;
   71.23  		msg[0].len = sizeof(buf);
    72.1 --- a/drivers/ide/pci/generic.c	Tue Oct 02 09:52:15 2007 +0100
    72.2 +++ b/drivers/ide/pci/generic.c	Wed Oct 03 10:00:44 2007 +0100
    72.3 @@ -242,13 +242,17 @@ static int __devinit generic_init_one(st
    72.4  	    (!(PCI_FUNC(dev->devfn) & 1)))
    72.5  		goto out;
    72.6  
    72.7 -	if (dev->vendor == PCI_VENDOR_ID_JMICRON && PCI_FUNC(dev->devfn) != 1)
    72.8 -		goto out;
    72.9 +	if (dev->vendor == PCI_VENDOR_ID_JMICRON) {
   72.10 +		if (dev->device != PCI_DEVICE_ID_JMICRON_JMB368 && PCI_FUNC(dev->devfn) != 1)
   72.11 +			goto out;
   72.12 +	}
   72.13  
   72.14 -	pci_read_config_word(dev, PCI_COMMAND, &command);
   72.15 -	if (!(command & PCI_COMMAND_IO)) {
   72.16 -		printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name);
   72.17 -		goto out;
   72.18 +	if (dev->vendor != PCI_VENDOR_ID_JMICRON) {
   72.19 +		pci_read_config_word(dev, PCI_COMMAND, &command);
   72.20 +		if (!(command & PCI_COMMAND_IO)) {
   72.21 +			printk(KERN_INFO "Skipping disabled %s IDE controller.\n", d->name);
   72.22 +			goto out;
   72.23 +		}
   72.24  	}
   72.25  	ret = ide_setup_pci_device(dev, d);
   72.26  out:
    73.1 --- a/drivers/ide/ppc/pmac.c	Tue Oct 02 09:52:15 2007 +0100
    73.2 +++ b/drivers/ide/ppc/pmac.c	Wed Oct 03 10:00:44 2007 +0100
    73.3 @@ -1326,7 +1326,7 @@ pmac_ide_macio_attach(struct macio_dev *
    73.4  	if (macio_irq_count(mdev) == 0) {
    73.5  		printk(KERN_WARNING "ide%d: no intrs for device %s, using 13\n",
    73.6  			i, mdev->ofdev.node->full_name);
    73.7 -		irq = 13;
    73.8 +		irq = irq_create_mapping(NULL, 13);
    73.9  	} else
   73.10  		irq = macio_irq(mdev, 0);
   73.11  
    74.1 --- a/drivers/ieee1394/ohci1394.c	Tue Oct 02 09:52:15 2007 +0100
    74.2 +++ b/drivers/ieee1394/ohci1394.c	Wed Oct 03 10:00:44 2007 +0100
    74.3 @@ -3218,6 +3218,19 @@ static int __devinit ohci1394_pci_probe(
    74.4  	struct ti_ohci *ohci;	/* shortcut to currently handled device */
    74.5  	resource_size_t ohci_base;
    74.6  
    74.7 +#ifdef CONFIG_PPC_PMAC
    74.8 +	/* Necessary on some machines if ohci1394 was loaded/ unloaded before */
    74.9 +	if (machine_is(powermac)) {
   74.10 +		struct device_node *of_node = pci_device_to_OF_node(dev);
   74.11 +
   74.12 +		if (of_node) {
   74.13 +			pmac_call_feature(PMAC_FTR_1394_CABLE_POWER, of_node,
   74.14 +					  0, 1);
   74.15 +			pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 1);
   74.16 +		}
   74.17 +	}
   74.18 +#endif /* CONFIG_PPC_PMAC */
   74.19 +
   74.20          if (pci_enable_device(dev))
   74.21  		FAIL(-ENXIO, "Failed to enable OHCI hardware");
   74.22          pci_set_master(dev);
   74.23 @@ -3506,11 +3519,9 @@ static void ohci1394_pci_remove(struct p
   74.24  #endif
   74.25  
   74.26  #ifdef CONFIG_PPC_PMAC
   74.27 -	/* On UniNorth, power down the cable and turn off the chip
   74.28 -	 * clock when the module is removed to save power on
   74.29 -	 * laptops. Turning it back ON is done by the arch code when
   74.30 -	 * pci_enable_device() is called */
   74.31 -	{
   74.32 +	/* On UniNorth, power down the cable and turn off the chip clock
   74.33 +	 * to save power on laptops */
   74.34 +	if (machine_is(powermac)) {
   74.35  		struct device_node* of_node;
   74.36  
   74.37  		of_node = pci_device_to_OF_node(ohci->dev);
    75.1 --- a/drivers/infiniband/core/mad.c	Tue Oct 02 09:52:15 2007 +0100
    75.2 +++ b/drivers/infiniband/core/mad.c	Wed Oct 03 10:00:44 2007 +0100
    75.3 @@ -1750,7 +1750,7 @@ ib_find_send_mad(struct ib_mad_agent_pri
    75.4  		     */
    75.5  		    (is_direct(wc->recv_buf.mad->mad_hdr.mgmt_class) ||
    75.6  		     rcv_has_same_gid(mad_agent_priv, wr, wc)))
    75.7 -			return wr;
    75.8 +			return (wr->status == IB_WC_SUCCESS) ? wr : NULL;
    75.9  	}
   75.10  
   75.11  	/*
    76.1 --- a/drivers/infiniband/hw/mthca/mthca_cq.c	Tue Oct 02 09:52:15 2007 +0100
    76.2 +++ b/drivers/infiniband/hw/mthca/mthca_cq.c	Wed Oct 03 10:00:44 2007 +0100
    76.3 @@ -39,6 +39,8 @@
    76.4  #include <linux/init.h>
    76.5  #include <linux/hardirq.h>
    76.6  
    76.7 +#include <asm/io.h>
    76.8 +
    76.9  #include <rdma/ib_pack.h>
   76.10  
   76.11  #include "mthca_dev.h"
   76.12 @@ -210,6 +212,11 @@ static inline void update_cons_index(str
   76.13  		mthca_write64(doorbell,
   76.14  			      dev->kar + MTHCA_CQ_DOORBELL,
   76.15  			      MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
   76.16 +		/*
   76.17 +		 * Make sure doorbells don't leak out of CQ spinlock
   76.18 +		 * and reach the HCA out of order:
   76.19 +		 */
   76.20 +		mmiowb();
   76.21  	}
   76.22  }
   76.23  
    77.1 --- a/drivers/infiniband/hw/mthca/mthca_mad.c	Tue Oct 02 09:52:15 2007 +0100
    77.2 +++ b/drivers/infiniband/hw/mthca/mthca_mad.c	Wed Oct 03 10:00:44 2007 +0100
    77.3 @@ -119,7 +119,7 @@ static void smp_snoop(struct ib_device *
    77.4  
    77.5  			mthca_update_rate(to_mdev(ibdev), port_num);
    77.6  			update_sm_ah(to_mdev(ibdev), port_num,
    77.7 -				     be16_to_cpu(pinfo->lid),
    77.8 +				     be16_to_cpu(pinfo->sm_lid),
    77.9  				     pinfo->neighbormtu_mastersmsl & 0xf);
   77.10  
   77.11  			event.device           = ibdev;
    78.1 --- a/drivers/infiniband/hw/mthca/mthca_qp.c	Tue Oct 02 09:52:15 2007 +0100
    78.2 +++ b/drivers/infiniband/hw/mthca/mthca_qp.c	Wed Oct 03 10:00:44 2007 +0100
    78.3 @@ -39,6 +39,8 @@
    78.4  #include <linux/string.h>
    78.5  #include <linux/slab.h>
    78.6  
    78.7 +#include <asm/io.h>
    78.8 +
    78.9  #include <rdma/ib_verbs.h>
   78.10  #include <rdma/ib_cache.h>
   78.11  #include <rdma/ib_pack.h>
   78.12 @@ -1730,6 +1732,11 @@ out:
   78.13  		mthca_write64(doorbell,
   78.14  			      dev->kar + MTHCA_SEND_DOORBELL,
   78.15  			      MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
   78.16 +		/*
   78.17 +		 * Make sure doorbells don't leak out of SQ spinlock
   78.18 +		 * and reach the HCA out of order:
   78.19 +		 */
   78.20 +		mmiowb();
   78.21  	}
   78.22  
   78.23  	qp->sq.next_ind = ind;
   78.24 @@ -1849,6 +1856,12 @@ out:
   78.25  	qp->rq.next_ind = ind;
   78.26  	qp->rq.head    += nreq;
   78.27  
   78.28 +	/*
   78.29 +	 * Make sure doorbells don't leak out of RQ spinlock and reach
   78.30 +	 * the HCA out of order:
   78.31 +	 */
   78.32 +	mmiowb();
   78.33 +
   78.34  	spin_unlock_irqrestore(&qp->rq.lock, flags);
   78.35  	return err;
   78.36  }
   78.37 @@ -2110,6 +2123,12 @@ out:
   78.38  			      MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
   78.39  	}
   78.40  
   78.41 +	/*
   78.42 +	 * Make sure doorbells don't leak out of SQ spinlock and reach
   78.43 +	 * the HCA out of order:
   78.44 +	 */
   78.45 +	mmiowb();
   78.46 +
   78.47  	spin_unlock_irqrestore(&qp->sq.lock, flags);
   78.48  	return err;
   78.49  }
    79.1 --- a/drivers/infiniband/hw/mthca/mthca_srq.c	Tue Oct 02 09:52:15 2007 +0100
    79.2 +++ b/drivers/infiniband/hw/mthca/mthca_srq.c	Wed Oct 03 10:00:44 2007 +0100
    79.3 @@ -35,6 +35,8 @@
    79.4  #include <linux/slab.h>
    79.5  #include <linux/string.h>
    79.6  
    79.7 +#include <asm/io.h>
    79.8 +
    79.9  #include "mthca_dev.h"
   79.10  #include "mthca_cmd.h"
   79.11  #include "mthca_memfree.h"
   79.12 @@ -593,6 +595,12 @@ int mthca_tavor_post_srq_recv(struct ib_
   79.13  			      MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
   79.14  	}
   79.15  
   79.16 +	/*
   79.17 +	 * Make sure doorbells don't leak out of SRQ spinlock and
   79.18 +	 * reach the HCA out of order:
   79.19 +	 */
   79.20 +	mmiowb();
   79.21 +
   79.22  	spin_unlock_irqrestore(&srq->lock, flags);
   79.23  	return err;
   79.24  }
    80.1 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c	Tue Oct 02 09:52:15 2007 +0100
    80.2 +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c	Wed Oct 03 10:00:44 2007 +0100
    80.3 @@ -619,8 +619,10 @@ void ipoib_ib_dev_flush(void *_dev)
    80.4  	 * The device could have been brought down between the start and when
    80.5  	 * we get here, don't bring it back up if it's not configured up
    80.6  	 */
    80.7 -	if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
    80.8 +	if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
    80.9  		ipoib_ib_dev_up(dev);
   80.10 +		ipoib_mcast_restart_task(dev);
   80.11 +	}
   80.12  
   80.13  	mutex_lock(&priv->vlan_mutex);
   80.14  
    81.1 --- a/drivers/infiniband/ulp/srp/ib_srp.c	Tue Oct 02 09:52:15 2007 +0100
    81.2 +++ b/drivers/infiniband/ulp/srp/ib_srp.c	Wed Oct 03 10:00:44 2007 +0100
    81.3 @@ -1851,7 +1851,7 @@ static void srp_add_one(struct ib_device
    81.4  	 */
    81.5  	srp_dev->fmr_page_shift = max(9, ffs(dev_attr->page_size_cap) - 1);
    81.6  	srp_dev->fmr_page_size  = 1 << srp_dev->fmr_page_shift;
    81.7 -	srp_dev->fmr_page_mask  = ~((unsigned long) srp_dev->fmr_page_size - 1);
    81.8 +	srp_dev->fmr_page_mask  = ~((u64) srp_dev->fmr_page_size - 1);
    81.9  
   81.10  	INIT_LIST_HEAD(&srp_dev->dev_list);
   81.11  
    82.1 --- a/drivers/infiniband/ulp/srp/ib_srp.h	Tue Oct 02 09:52:15 2007 +0100
    82.2 +++ b/drivers/infiniband/ulp/srp/ib_srp.h	Wed Oct 03 10:00:44 2007 +0100
    82.3 @@ -87,7 +87,7 @@ struct srp_device {
    82.4  	struct ib_fmr_pool     *fmr_pool;
    82.5  	int			fmr_page_shift;
    82.6  	int			fmr_page_size;
    82.7 -	unsigned long		fmr_page_mask;
    82.8 +	u64			fmr_page_mask;
    82.9  };
   82.10  
   82.11  struct srp_host {
    83.1 --- a/drivers/input/mouse/psmouse-base.c	Tue Oct 02 09:52:15 2007 +0100
    83.2 +++ b/drivers/input/mouse/psmouse-base.c	Wed Oct 03 10:00:44 2007 +0100
    83.3 @@ -1332,20 +1332,22 @@ ssize_t psmouse_attr_set_helper(struct d
    83.4  
    83.5  static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char *buf)
    83.6  {
    83.7 -	unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset);
    83.8 +	unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
    83.9  
   83.10 -	return sprintf(buf, "%lu\n", *field);
   83.11 +	return sprintf(buf, "%u\n", *field);
   83.12  }
   83.13  
   83.14  static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count)
   83.15  {
   83.16 -	unsigned long *field = (unsigned long *)((char *)psmouse + (size_t)offset);
   83.17 +	unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
   83.18  	unsigned long value;
   83.19  	char *rest;
   83.20  
   83.21  	value = simple_strtoul(buf, &rest, 10);
   83.22  	if (*rest)
   83.23  		return -EINVAL;
   83.24 +	if ((unsigned int)value != value)
   83.25 +		return -EINVAL;
   83.26  
   83.27  	*field = value;
   83.28  
    84.1 --- a/drivers/isdn/capi/capidrv.c	Tue Oct 02 09:52:15 2007 +0100
    84.2 +++ b/drivers/isdn/capi/capidrv.c	Wed Oct 03 10:00:44 2007 +0100
    84.3 @@ -1907,7 +1907,8 @@ static int if_readstat(u8 __user *buf, i
    84.4  	}
    84.5  
    84.6  	for (p=buf, count=0; count < len; p++, count++) {
    84.7 -		put_user(*card->q931_read++, p);
    84.8 +		if (put_user(*card->q931_read++, p))
    84.9 +			return -EFAULT;
   84.10  	        if (card->q931_read > card->q931_end)
   84.11  	                card->q931_read = card->q931_buf;
   84.12  	}
    85.1 --- a/drivers/isdn/hisax/config.c	Tue Oct 02 09:52:15 2007 +0100
    85.2 +++ b/drivers/isdn/hisax/config.c	Wed Oct 03 10:00:44 2007 +0100
    85.3 @@ -631,7 +631,8 @@ static int HiSax_readstatus(u_char __use
    85.4  		count = cs->status_end - cs->status_read + 1;
    85.5  		if (count >= len)
    85.6  			count = len;
    85.7 -		copy_to_user(p, cs->status_read, count);
    85.8 +		if (copy_to_user(p, cs->status_read, count))
    85.9 +			return -EFAULT;
   85.10  		cs->status_read += count;
   85.11  		if (cs->status_read > cs->status_end)
   85.12  			cs->status_read = cs->status_buf;
   85.13 @@ -642,7 +643,8 @@ static int HiSax_readstatus(u_char __use
   85.14  				cnt = HISAX_STATUS_BUFSIZE;
   85.15  			else
   85.16  				cnt = count;
   85.17 -			copy_to_user(p, cs->status_read, cnt);
   85.18 +			if (copy_to_user(p, cs->status_read, cnt))
   85.19 +				return -EFAULT;
   85.20  			p += cnt;
   85.21  			cs->status_read += cnt % HISAX_STATUS_BUFSIZE;
   85.22  			count -= cnt;
    86.1 --- a/drivers/isdn/i4l/isdn_common.c	Tue Oct 02 09:52:15 2007 +0100
    86.2 +++ b/drivers/isdn/i4l/isdn_common.c	Wed Oct 03 10:00:44 2007 +0100
    86.3 @@ -1134,9 +1134,12 @@ isdn_read(struct file *file, char __user
    86.4  		if (dev->drv[drvidx]->interface->readstat) {
    86.5  			if (count > dev->drv[drvidx]->stavail)
    86.6  				count = dev->drv[drvidx]->stavail;
    86.7 -			len = dev->drv[drvidx]->interface->
    86.8 -				readstat(buf, count, drvidx,
    86.9 -					 isdn_minor2chan(minor));
   86.10 +			len = dev->drv[drvidx]->interface->readstat(buf, count,
   86.11 +						drvidx, isdn_minor2chan(minor));
   86.12 +			if (len < 0) {
   86.13 +				retval = len;
   86.14 +				goto out;
   86.15 +			}
   86.16  		} else {
   86.17  			len = 0;
   86.18  		}
    87.1 --- a/drivers/isdn/icn/icn.c	Tue Oct 02 09:52:15 2007 +0100
    87.2 +++ b/drivers/isdn/icn/icn.c	Wed Oct 03 10:00:44 2007 +0100
    87.3 @@ -1010,7 +1010,8 @@ icn_readstatus(u_char __user *buf, int l
    87.4  	for (p = buf, count = 0; count < len; p++, count++) {
    87.5  		if (card->msg_buf_read == card->msg_buf_write)
    87.6  			return count;
    87.7 -		put_user(*card->msg_buf_read++, p);
    87.8 +		if (put_user(*card->msg_buf_read++, p))
    87.9 +			return -EFAULT;
   87.10  		if (card->msg_buf_read > card->msg_buf_end)
   87.11  			card->msg_buf_read = card->msg_buf;
   87.12  	}
    88.1 --- a/drivers/isdn/isdnloop/isdnloop.c	Tue Oct 02 09:52:15 2007 +0100
    88.2 +++ b/drivers/isdn/isdnloop/isdnloop.c	Wed Oct 03 10:00:44 2007 +0100
    88.3 @@ -451,7 +451,8 @@ isdnloop_readstatus(u_char __user *buf, 
    88.4  	for (p = buf, count = 0; count < len; p++, count++) {
    88.5  		if (card->msg_buf_read == card->msg_buf_write)
    88.6  			return count;
    88.7 -		put_user(*card->msg_buf_read++, p);
    88.8 +		if (put_user(*card->msg_buf_read++, p))
    88.9 +			return -EFAULT;
   88.10  		if (card->msg_buf_read > card->msg_buf_end)
   88.11  			card->msg_buf_read = card->msg_buf;
   88.12  	}
    89.1 --- a/drivers/isdn/pcbit/drv.c	Tue Oct 02 09:52:15 2007 +0100
    89.2 +++ b/drivers/isdn/pcbit/drv.c	Wed Oct 03 10:00:44 2007 +0100
    89.3 @@ -725,23 +725,27 @@ static int pcbit_stat(u_char __user *buf
    89.4  
    89.5  	if (stat_st < stat_end)
    89.6  	{
    89.7 -		copy_to_user(buf, statbuf + stat_st, len);
    89.8 +		if (copy_to_user(buf, statbuf + stat_st, len))
    89.9 +			return -EFAULT;
   89.10  		stat_st += len;	   
   89.11  	}
   89.12  	else
   89.13  	{
   89.14  		if (len > STATBUF_LEN - stat_st)
   89.15  		{
   89.16 -			copy_to_user(buf, statbuf + stat_st, 
   89.17 -				       STATBUF_LEN - stat_st);
   89.18 -			copy_to_user(buf, statbuf, 
   89.19 -				       len - (STATBUF_LEN - stat_st));
   89.20 +			if (copy_to_user(buf, statbuf + stat_st,
   89.21 +				       STATBUF_LEN - stat_st))
   89.22 +				return -EFAULT;
   89.23 +			if (copy_to_user(buf, statbuf,
   89.24 +				       len - (STATBUF_LEN - stat_st)))
   89.25 +				return -EFAULT;
   89.26  
   89.27  			stat_st = len - (STATBUF_LEN - stat_st);
   89.28  		}
   89.29  		else
   89.30  		{
   89.31 -			copy_to_user(buf, statbuf + stat_st, len);
   89.32 +			if (copy_to_user(buf, statbuf + stat_st, len))
   89.33 +				return -EFAULT;
   89.34  
   89.35  			stat_st += len;
   89.36  			
    90.1 --- a/drivers/macintosh/via-pmu-backlight.c	Tue Oct 02 09:52:15 2007 +0100
    90.2 +++ b/drivers/macintosh/via-pmu-backlight.c	Wed Oct 03 10:00:44 2007 +0100
    90.3 @@ -16,7 +16,7 @@
    90.4  #define MAX_PMU_LEVEL 0xFF
    90.5  
    90.6  static struct backlight_properties pmu_backlight_data;
    90.7 -static spinlock_t pmu_backlight_lock;
    90.8 +static DEFINE_SPINLOCK(pmu_backlight_lock);
    90.9  static int sleeping;
   90.10  static u8 bl_curve[FB_BACKLIGHT_LEVELS];
   90.11  
    91.1 --- a/drivers/md/dm-crypt.c	Tue Oct 02 09:52:15 2007 +0100
    91.2 +++ b/drivers/md/dm-crypt.c	Wed Oct 03 10:00:44 2007 +0100
    91.3 @@ -717,13 +717,15 @@ static int crypt_endio(struct bio *bio, 
    91.4  	if (bio->bi_size)
    91.5  		return 1;
    91.6  
    91.7 +	if (!bio_flagged(bio, BIO_UPTODATE) && !error)
    91.8 +		error = -EIO;
    91.9 +
   91.10  	bio_put(bio);
   91.11  
   91.12  	/*
   91.13  	 * successful reads are decrypted by the worker thread
   91.14  	 */
   91.15 -	if ((bio_data_dir(bio) == READ)
   91.16 -	    && bio_flagged(bio, BIO_UPTODATE)) {
   91.17 +	if (bio_data_dir(io->bio) == READ && !error) {
   91.18  		kcryptd_queue_io(io);
   91.19  		return 0;
   91.20  	}
    92.1 --- a/drivers/md/dm-snap.c	Tue Oct 02 09:52:15 2007 +0100
    92.2 +++ b/drivers/md/dm-snap.c	Wed Oct 03 10:00:44 2007 +0100
    92.3 @@ -691,6 +691,7 @@ static void pending_complete(struct pend
    92.4  
    92.5  		free_exception(e);
    92.6  
    92.7 +		remove_exception(&pe->e);
    92.8  		error_snapshot_bios(pe);
    92.9  		goto out;
   92.10  	}
    93.1 --- a/drivers/md/md.c	Tue Oct 02 09:52:15 2007 +0100
    93.2 +++ b/drivers/md/md.c	Wed Oct 03 10:00:44 2007 +0100
    93.3 @@ -1994,6 +1994,7 @@ static mdk_rdev_t *md_import_device(dev_
    93.4  	kobject_init(&rdev->kobj);
    93.5  
    93.6  	rdev->desc_nr = -1;
    93.7 +	rdev->saved_raid_disk = -1;
    93.8  	rdev->flags = 0;
    93.9  	rdev->data_offset = 0;
   93.10  	rdev->sb_events = 0;
   93.11 @@ -3867,6 +3868,7 @@ static int hot_add_disk(mddev_t * mddev,
   93.12  	}
   93.13  	clear_bit(In_sync, &rdev->flags);
   93.14  	rdev->desc_nr = -1;
   93.15 +	rdev->saved_raid_disk = -1;
   93.16  	err = bind_rdev_to_array(rdev, mddev);
   93.17  	if (err)
   93.18  		goto abort_export;
    94.1 --- a/drivers/md/multipath.c	Tue Oct 02 09:52:15 2007 +0100
    94.2 +++ b/drivers/md/multipath.c	Wed Oct 03 10:00:44 2007 +0100
    94.3 @@ -480,7 +480,7 @@ static int multipath_run (mddev_t *mddev
    94.4  			mdname(mddev));
    94.5  		goto out_free_conf;
    94.6  	}
    94.7 -	mddev->degraded = conf->raid_disks = conf->working_disks;
    94.8 +	mddev->degraded = conf->raid_disks - conf->working_disks;
    94.9  
   94.10  	conf->pool = mempool_create_kzalloc_pool(NR_RESERVED_BUFS,
   94.11  						 sizeof(struct multipath_bh));
    95.1 --- a/drivers/md/raid10.c	Tue Oct 02 09:52:15 2007 +0100
    95.2 +++ b/drivers/md/raid10.c	Wed Oct 03 10:00:44 2007 +0100
    95.3 @@ -2042,7 +2042,7 @@ static int run(mddev_t *mddev)
    95.4  		disk = conf->mirrors + i;
    95.5  
    95.6  		if (!disk->rdev ||
    95.7 -		    !test_bit(In_sync, &rdev->flags)) {
    95.8 +		    !test_bit(In_sync, &disk->rdev->flags)) {
    95.9  			disk->head_position = 0;
   95.10  			mddev->degraded++;
   95.11  		}
    96.1 --- a/drivers/media/Kconfig	Tue Oct 02 09:52:15 2007 +0100
    96.2 +++ b/drivers/media/Kconfig	Wed Oct 03 10:00:44 2007 +0100
    96.3 @@ -54,6 +54,7 @@ config VIDEO_V4L1_COMPAT
    96.4  
    96.5  config VIDEO_V4L2
    96.6  	bool
    96.7 +	depends on VIDEO_DEV
    96.8  	default y
    96.9  
   96.10  source "drivers/media/video/Kconfig"
    97.1 --- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c	Tue Oct 02 09:52:15 2007 +0100
    97.2 +++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c	Wed Oct 03 10:00:44 2007 +0100
    97.3 @@ -527,7 +527,7 @@ int flexcop_frontend_init(struct flexcop
    97.4  	/* try the air atsc 2nd generation (nxt2002) */
    97.5  	if ((fc->fe = nxt200x_attach(&samsung_tbmv_config, &fc->i2c_adap)) != NULL) {
    97.6  		fc->dev_type          = FC_AIR_ATSC2;
    97.7 -		dvb_pll_attach(fc->fe, 0x61, &fc->i2c_adap, &dvb_pll_samsung_tbmv);
    97.8 +		dvb_pll_attach(fc->fe, 0x61, NULL, &dvb_pll_samsung_tbmv);
    97.9  		info("found the nxt2002 at i2c address: 0x%02x",samsung_tbmv_config.demod_address);
   97.10  	} else
   97.11  	/* try the air atsc 3nd generation (lgdt3303) */
    98.1 --- a/drivers/media/dvb/dvb-core/dvb_net.c	Tue Oct 02 09:52:15 2007 +0100
    98.2 +++ b/drivers/media/dvb/dvb-core/dvb_net.c	Wed Oct 03 10:00:44 2007 +0100
    98.3 @@ -604,7 +604,7 @@ static void dvb_net_ule( struct net_devi
    98.4  				{ &utype, sizeof utype },
    98.5  				{ priv->ule_skb->data, priv->ule_skb->len - 4 }
    98.6  			};
    98.7 -			unsigned long ule_crc = ~0L, expected_crc;
    98.8 +			u32 ule_crc = ~0L, expected_crc;
    98.9  			if (priv->ule_dbit) {
   98.10  				/* Set D-bit for CRC32 verification,
   98.11  				 * if it was set originally. */
   98.12 @@ -617,7 +617,7 @@ static void dvb_net_ule( struct net_devi
   98.13  				       *((u8 *)priv->ule_skb->tail - 2) << 8 |
   98.14  				       *((u8 *)priv->ule_skb->tail - 1);
   98.15  			if (ule_crc != expected_crc) {
   98.16 -				printk(KERN_WARNING "%lu: CRC32 check FAILED: %#lx / %#lx, SNDU len %d type %#x, ts_remain %d, next 2: %x.\n",
   98.17 +				printk(KERN_WARNING "%lu: CRC32 check FAILED: %08x / %08x, SNDU len %d type %#x, ts_remain %d, next 2: %x.\n",
   98.18  				       priv->ts_count, ule_crc, expected_crc, priv->ule_sndu_len, priv->ule_sndu_type, ts_remain, ts_remain > 2 ? *(unsigned short *)from_where : 0);
   98.19  
   98.20  #ifdef ULE_DEBUG
    99.1 --- a/drivers/media/dvb/frontends/cx24123.c	Tue Oct 02 09:52:15 2007 +0100
    99.2 +++ b/drivers/media/dvb/frontends/cx24123.c	Wed Oct 03 10:00:44 2007 +0100
    99.3 @@ -549,8 +549,8 @@ static int cx24123_pll_calculate(struct 
    99.4  	ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff;
    99.5  	adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f;
    99.6  
    99.7 -	if (adiv == 0)
    99.8 -		ndiv++;
    99.9 +	if (adiv == 0 && ndiv > 0)
   99.10 +		ndiv--;
   99.11  
   99.12  	/* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */
   99.13  	state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv;
   100.1 --- a/drivers/media/dvb/frontends/dvb-pll.c	Tue Oct 02 09:52:15 2007 +0100
   100.2 +++ b/drivers/media/dvb/frontends/dvb-pll.c	Wed Oct 03 10:00:44 2007 +0100
   100.3 @@ -493,6 +493,9 @@ static int dvb_pll_sleep(struct dvb_fron
   100.4  	int i;
   100.5  	int result;
   100.6  
   100.7 +	if (priv->i2c == NULL)
   100.8 +		return -EINVAL;
   100.9 +
  100.10  	for (i = 0; i < priv->pll_desc->count; i++) {
  100.11  		if (priv->pll_desc->entries[i].limit == 0)
  100.12  			break;
   101.1 --- a/drivers/media/dvb/frontends/lgdt330x.c	Tue Oct 02 09:52:15 2007 +0100
   101.2 +++ b/drivers/media/dvb/frontends/lgdt330x.c	Wed Oct 03 10:00:44 2007 +0100
   101.3 @@ -435,9 +435,6 @@ static int lgdt3302_read_status(struct d
   101.4  		/* Test signal does not exist flag */
   101.5  		/* as well as the AGC lock flag.   */
   101.6  		*status |= FE_HAS_SIGNAL;
   101.7 -	} else {
   101.8 -		/* Without a signal all other status bits are meaningless */
   101.9 -		return 0;
  101.10  	}
  101.11  
  101.12  	/*
  101.13 @@ -500,9 +497,6 @@ static int lgdt3303_read_status(struct d
  101.14  		/* Test input signal does not exist flag */
  101.15  		/* as well as the AGC lock flag.   */
  101.16  		*status |= FE_HAS_SIGNAL;
  101.17 -	} else {
  101.18 -		/* Without a signal all other status bits are meaningless */
  101.19 -		return 0;
  101.20  	}
  101.21  
  101.22  	/* Carrier Recovery Lock Status Register */
   102.1 --- a/drivers/media/video/cx88/cx88-cards.c	Tue Oct 02 09:52:15 2007 +0100
   102.2 +++ b/drivers/media/video/cx88/cx88-cards.c	Wed Oct 03 10:00:44 2007 +0100
   102.3 @@ -1465,7 +1465,7 @@ const unsigned int cx88_idcount = ARRAY_
   102.4  /* ----------------------------------------------------------------------- */
   102.5  /* some leadtek specific stuff                                             */
   102.6  
   102.7 -static void __devinit leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
   102.8 +static void leadtek_eeprom(struct cx88_core *core, u8 *eeprom_data)
   102.9  {
  102.10  	/* This is just for the "Winfast 2000XP Expert" board ATM; I don't have data on
  102.11  	 * any others.
   103.1 --- a/drivers/media/video/cx88/cx88-dvb.c	Tue Oct 02 09:52:15 2007 +0100
   103.2 +++ b/drivers/media/video/cx88/cx88-dvb.c	Wed Oct 03 10:00:44 2007 +0100
   103.3 @@ -576,7 +576,7 @@ static int dvb_register(struct cx8802_de
   103.4  						 &dev->core->i2c_adap);
   103.5  		if (dev->dvb.frontend != NULL) {
   103.6  			dvb_pll_attach(dev->dvb.frontend, 0x60,
   103.7 -				       &dev->core->i2c_adap,
   103.8 +				       NULL,
   103.9  				       &dvb_pll_thomson_dtt7579);
  103.10  			break;
  103.11  		}
  103.12 @@ -587,7 +587,7 @@ static int dvb_register(struct cx8802_de
  103.13  						   &dev->core->i2c_adap);
  103.14  		if (dev->dvb.frontend != NULL) {
  103.15  			dvb_pll_attach(dev->dvb.frontend, 0x60,
  103.16 -				       &dev->core->i2c_adap,
  103.17 +				       NULL,
  103.18  				       &dvb_pll_thomson_dtt7579);
  103.19  		}
  103.20  #endif
  103.21 @@ -600,7 +600,7 @@ static int dvb_register(struct cx8802_de
  103.22  						 &dev->core->i2c_adap);
  103.23  		if (dev->dvb.frontend != NULL) {
  103.24  			dvb_pll_attach(dev->dvb.frontend, 0x61,
  103.25 -				       &dev->core->i2c_adap,
  103.26 +				       NULL,
  103.27  				       &dvb_pll_thomson_dtt7579);
  103.28  			break;
  103.29  		}
  103.30 @@ -611,7 +611,7 @@ static int dvb_register(struct cx8802_de
  103.31  						   &dev->core->i2c_adap);
  103.32  		if (dev->dvb.frontend != NULL) {
  103.33  			dvb_pll_attach(dev->dvb.frontend, 0x61,
  103.34 -				       &dev->core->i2c_adap,
  103.35 +				       NULL,
  103.36  				       &dvb_pll_thomson_dtt7579);
  103.37  		}
  103.38  #endif
  103.39 @@ -623,7 +623,7 @@ static int dvb_register(struct cx8802_de
  103.40  						 &dev->core->i2c_adap);
  103.41  		if (dev->dvb.frontend != NULL) {
  103.42  			dvb_pll_attach(dev->dvb.frontend, 0x61,
  103.43 -				       &dev->core->i2c_adap,
  103.44 +				       NULL,
  103.45  				       &dvb_pll_lg_z201);
  103.46  		}
  103.47  		break;
  103.48 @@ -634,7 +634,7 @@ static int dvb_register(struct cx8802_de
  103.49  						 &dev->core->i2c_adap);
  103.50  		if (dev->dvb.frontend != NULL) {
  103.51  			dvb_pll_attach(dev->dvb.frontend, 0x61,
  103.52 -				       &dev->core->i2c_adap,
  103.53 +				       NULL,
  103.54  				       &dvb_pll_unknown_1);
  103.55  		}
  103.56  		break;
  103.57 @@ -757,7 +757,7 @@ static int dvb_register(struct cx8802_de
  103.58  						 &dev->core->i2c_adap);
  103.59  		if (dev->dvb.frontend != NULL) {
  103.60  			dvb_pll_attach(dev->dvb.frontend, 0x61,
  103.61 -				       &dev->core->i2c_adap,
  103.62 +				       NULL,
  103.63  				       &dvb_pll_tuv1236d);
  103.64  		}
  103.65  		break;
   104.1 --- a/drivers/media/video/ks0127.c	Tue Oct 02 09:52:15 2007 +0100
   104.2 +++ b/drivers/media/video/ks0127.c	Wed Oct 03 10:00:44 2007 +0100
   104.3 @@ -712,13 +712,13 @@ static int ks0127_command(struct i2c_cli
   104.4  		*iarg = 0;
   104.5  		status = ks0127_read(ks, KS_STAT);
   104.6  		if (!(status & 0x20))		 /* NOVID not set */
   104.7 -			*iarg = (*iarg & DECODER_STATUS_GOOD);
   104.8 +			*iarg = (*iarg | DECODER_STATUS_GOOD);
   104.9  		if ((status & 0x01))		      /* CLOCK set */
  104.10 -			*iarg = (*iarg & DECODER_STATUS_COLOR);
  104.11 +			*iarg = (*iarg | DECODER_STATUS_COLOR);
  104.12  		if ((status & 0x08))		   /* PALDET set */
  104.13 -			*iarg = (*iarg & DECODER_STATUS_PAL);
  104.14 +			*iarg = (*iarg | DECODER_STATUS_PAL);
  104.15  		else
  104.16 -			*iarg = (*iarg & DECODER_STATUS_NTSC);
  104.17 +			*iarg = (*iarg | DECODER_STATUS_NTSC);
  104.18  		break;
  104.19  
  104.20  	//Catch any unknown command
   105.1 --- a/drivers/media/video/msp3400-driver.c	Tue Oct 02 09:52:15 2007 +0100
   105.2 +++ b/drivers/media/video/msp3400-driver.c	Wed Oct 03 10:00:44 2007 +0100
   105.3 @@ -904,6 +904,8 @@ static int msp_attach(struct i2c_adapter
   105.4  	state->has_virtual_dolby_surround = msp_revision == 'G' && msp_prod_lo == 1;
   105.5  	/* Has Virtual Dolby Surround & Dolby Pro Logic: only in msp34x2 */
   105.6  	state->has_dolby_pro_logic = msp_revision == 'G' && msp_prod_lo == 2;
   105.7 +	/* The msp343xG supports BTSC only and cannot do Automatic Standard Detection. */
   105.8 +	state->force_btsc = msp_family == 3 && msp_revision == 'G' && msp_prod_hi == 3;
   105.9  
  105.10  	state->opmode = opmode;
  105.11  	if (state->opmode == OPMODE_AUTO) {
   106.1 --- a/drivers/media/video/msp3400-driver.h	Tue Oct 02 09:52:15 2007 +0100
   106.2 +++ b/drivers/media/video/msp3400-driver.h	Wed Oct 03 10:00:44 2007 +0100
   106.3 @@ -64,6 +64,7 @@ struct msp_state {
   106.4  	u8 has_sound_processing;
   106.5  	u8 has_virtual_dolby_surround;
   106.6  	u8 has_dolby_pro_logic;
   106.7 +	u8 force_btsc;
   106.8  
   106.9  	int radio;
  106.10  	int opmode;
   107.1 --- a/drivers/media/video/msp3400-kthreads.c	Tue Oct 02 09:52:15 2007 +0100
   107.2 +++ b/drivers/media/video/msp3400-kthreads.c	Wed Oct 03 10:00:44 2007 +0100
   107.3 @@ -960,9 +960,10 @@ int msp34xxg_thread(void *data)
   107.4  
   107.5  		/* setup the chip*/
   107.6  		msp34xxg_reset(client);
   107.7 -		state->std = state->radio ? 0x40 : msp_standard;
   107.8 +		state->std = state->radio ? 0x40 :
   107.9 +			(state->force_btsc && msp_standard == 1) ? 32 : msp_standard;
  107.10 +		msp_write_dem(client, 0x20, state->std);
  107.11  		/* start autodetect */
  107.12 -		msp_write_dem(client, 0x20, state->std);
  107.13  		if (state->std != 1)
  107.14  			goto unmute;
  107.15  
   108.1 --- a/drivers/media/video/pvrusb2/Kconfig	Tue Oct 02 09:52:15 2007 +0100
   108.2 +++ b/drivers/media/video/pvrusb2/Kconfig	Wed Oct 03 10:00:44 2007 +0100
   108.3 @@ -25,14 +25,9 @@ config VIDEO_PVRUSB2_24XXX
   108.4  	  form "24xxx" (leading prefix of "24" followed by 3 digits).
   108.5  	  To see if you may need this option, examine the white
   108.6  	  sticker on the underside of your device.  Enabling this
   108.7 -	  option will not harm support for older devices, however it
   108.8 -	  is a separate option because of the experimental nature of
   108.9 -	  this new feature.
  108.10 +	  option will not harm support for older devices.
  108.11  
  108.12 -	  If you are in doubt, say N.
  108.13 -
  108.14 -	  Note: This feature is _very_ experimental.  You have been
  108.15 -	  warned.
  108.16 +	  If you are in doubt, say Y.
  108.17  
  108.18  config VIDEO_PVRUSB2_SYSFS
  108.19  	bool "pvrusb2 sysfs support (EXPERIMENTAL)"
   109.1 --- a/drivers/media/video/pvrusb2/pvrusb2-ctrl.c	Tue Oct 02 09:52:15 2007 +0100
   109.2 +++ b/drivers/media/video/pvrusb2/pvrusb2-ctrl.c	Wed Oct 03 10:00:44 2007 +0100
   109.3 @@ -43,12 +43,17 @@ int pvr2_ctrl_set_mask_value(struct pvr2
   109.4  			if (cptr->info->type == pvr2_ctl_bitmask) {
   109.5  				mask &= cptr->info->def.type_bitmask.valid_bits;
   109.6  			} else if (cptr->info->type == pvr2_ctl_int) {
   109.7 -				if (val < cptr->info->def.type_int.min_value) {
   109.8 -					break;
   109.9 +				int lim;
  109.10 +				lim = cptr->info->def.type_int.min_value;
  109.11 +				if (cptr->info->get_min_value) {
  109.12 +					cptr->info->get_min_value(cptr,&lim);
  109.13  				}
  109.14 -				if (val > cptr->info->def.type_int.max_value) {
  109.15 -					break;
  109.16 +				if (val < lim) break;
  109.17 +				lim = cptr->info->def.type_int.max_value;
  109.18 +				if (cptr->info->get_max_value) {
  109.19 +					cptr->info->get_max_value(cptr,&lim);
  109.20  				}
  109.21 +				if (val > lim) break;
  109.22  			} else if (cptr->info->type == pvr2_ctl_enum) {
  109.23  				if (val >= cptr->info->def.type_enum.count) {
  109.24  					break;
  109.25 @@ -91,7 +96,9 @@ int pvr2_ctrl_get_max(struct pvr2_ctrl *
  109.26  	int ret = 0;
  109.27  	if (!cptr) return 0;
  109.28  	LOCK_TAKE(cptr->hdw->big_lock); do {
  109.29 -		if (cptr->info->type == pvr2_ctl_int) {
  109.30 +		if (cptr->info->get_max_value) {
  109.31 +			cptr->info->get_max_value(cptr,&ret);
  109.32 +		} else if (cptr->info->type == pvr2_ctl_int) {
  109.33  			ret = cptr->info->def.type_int.max_value;
  109.34  		}
  109.35  	} while(0); LOCK_GIVE(cptr->hdw->big_lock);
  109.36 @@ -105,7 +112,9 @@ int pvr2_ctrl_get_min(struct pvr2_ctrl *
  109.37  	int ret = 0;
  109.38  	if (!cptr) return 0;
  109.39  	LOCK_TAKE(cptr->hdw->big_lock); do {
  109.40 -		if (cptr->info->type == pvr2_ctl_int) {
  109.41 +		if (cptr->info->get_min_value) {
  109.42 +			cptr->info->get_min_value(cptr,&ret);
  109.43 +		} else if (cptr->info->type == pvr2_ctl_int) {
  109.44  			ret = cptr->info->def.type_int.min_value;
  109.45  		}
  109.46  	} while(0); LOCK_GIVE(cptr->hdw->big_lock);
   110.1 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h	Tue Oct 02 09:52:15 2007 +0100
   110.2 +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw-internal.h	Wed Oct 03 10:00:44 2007 +0100
   110.3 @@ -107,6 +107,8 @@ struct pvr2_ctl_info {
   110.4  
   110.5  	/* Control's implementation */
   110.6  	pvr2_ctlf_get_value get_value;      /* Get its value */
   110.7 +	pvr2_ctlf_get_value get_min_value;  /* Get minimum allowed value */
   110.8 +	pvr2_ctlf_get_value get_max_value;  /* Get maximum allowed value */
   110.9  	pvr2_ctlf_set_value set_value;      /* Set its value */
  110.10  	pvr2_ctlf_val_to_sym val_to_sym;    /* Custom convert value->symbol */
  110.11  	pvr2_ctlf_sym_to_val sym_to_val;    /* Custom convert symbol->value */
   111.1 --- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c	Tue Oct 02 09:52:15 2007 +0100
   111.2 +++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c	Wed Oct 03 10:00:44 2007 +0100
   111.3 @@ -362,6 +362,30 @@ static int ctrl_freq_set(struct pvr2_ctr
   111.4  	return 0;
   111.5  }
   111.6  
   111.7 +#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
   111.8 +static int ctrl_hres_max_get(struct pvr2_ctrl *cptr,int *vp)
   111.9 +{
  111.10 +	/* If we're dealing with a 24xxx device, force the horizontal
  111.11 +	   maximum to be 720 no matter what, since we can't get the device
  111.12 +	   to work properly with any other value.  Otherwise just return
  111.13 +	   the normal value. */
  111.14 +	*vp = cptr->info->def.type_int.max_value;
  111.15 +	if (cptr->hdw->hdw_type == PVR2_HDW_TYPE_24XXX) *vp = 720;
  111.16 +	return 0;
  111.17 +}
  111.18 +
  111.19 +static int ctrl_hres_min_get(struct pvr2_ctrl *cptr,int *vp)
  111.20 +{
  111.21 +	/* If we're dealing with a 24xxx device, force the horizontal
  111.22 +	   minimum to be 720 no matter what, since we can't get the device
  111.23 +	   to work properly with any other value.  Otherwise just return
  111.24 +	   the normal value. */
  111.25 +	*vp = cptr->info->def.type_int.min_value;
  111.26 +	if (cptr->hdw->hdw_type == PVR2_HDW_TYPE_24XXX) *vp = 720;
  111.27 +	return 0;
  111.28 +}
  111.29 +#endif
  111.30 +
  111.31  static int ctrl_cx2341x_is_dirty(struct pvr2_ctrl *cptr)
  111.32  {
  111.33  	return cptr->hdw->enc_stale != 0;
  111.34 @@ -720,6 +744,12 @@ static const struct pvr2_ctl_info contro
  111.35  		.default_value = 720,
  111.36  		DEFREF(res_hor),
  111.37  		DEFINT(320,720),
  111.38 +#ifdef CONFIG_VIDEO_PVRUSB2_24XXX
  111.39 +		/* Hook in check for clamp on horizontal resolution in
  111.40 +		   order to avoid unsolved problem involving cx25840. */
  111.41 +		.get_max_value = ctrl_hres_max_get,
  111.42 +		.get_min_value = ctrl_hres_min_get,
  111.43 +#endif
  111.44  	},{
  111.45  		.desc = "Vertical capture resolution",
  111.46  		.name = "resolution_ver",
   112.1 --- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c	Tue Oct 02 09:52:15 2007 +0100
   112.2 +++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c	Wed Oct 03 10:00:44 2007 +0100
   112.3 @@ -22,6 +22,7 @@
   112.4  
   112.5  #include <linux/kernel.h>
   112.6  #include <linux/version.h>
   112.7 +#include <linux/videodev.h>
   112.8  #include "pvrusb2-context.h"
   112.9  #include "pvrusb2-hdw.h"
  112.10  #include "pvrusb2.h"
  112.11 @@ -31,25 +32,21 @@
  112.12  #include <linux/videodev2.h>
  112.13  #include <media/v4l2-common.h>
  112.14  
  112.15 +/* Mike Isely <isely@pobox.com> 23-Sep-2006 - This function is prototyped
  112.16 + * only for V4L1 but is implemented regardless of the V4L1 compatibility
  112.17 + * option state.  V4L2 has no replacement for this and we need it.  For now
  112.18 + * copy the prototype here so we can avoid the compiler warning. */
  112.19 +extern struct video_device* video_devdata(struct file*);
  112.20 +
  112.21  struct pvr2_v4l2_dev;
  112.22  struct pvr2_v4l2_fh;
  112.23  struct pvr2_v4l2;
  112.24  
  112.25 -/* V4L no longer provide the ability to set / get a private context pointer
  112.26 -   (i.e. video_get_drvdata / video_set_drvdata), which means we have to
  112.27 -   concoct our own context locating mechanism.  Supposedly this is intended
  112.28 -   to simplify driver implementation.  It's not clear to me how that can
  112.29 -   possibly be true.  Our solution here is to maintain a lookup table of
  112.30 -   our context instances, indexed by the minor device number of the V4L
  112.31 -   device.  See pvr2_v4l2_open() for some implications of this approach. */
  112.32 -static struct pvr2_v4l2_dev *devices[256];
  112.33 -static DEFINE_MUTEX(device_lock);
  112.34  
  112.35  struct pvr2_v4l2_dev {
  112.36  	struct pvr2_v4l2 *v4lp;
  112.37  	struct video_device *vdev;
  112.38  	struct pvr2_context_stream *stream;
  112.39 -	int ctxt_idx;
  112.40  	enum pvr2_config config;
  112.41  };
  112.42  
  112.43 @@ -459,18 +456,26 @@ static int pvr2_v4l2_do_ioctl(struct ino
  112.44  		ret = 0;
  112.45  		switch(vf->type) {
  112.46  		case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
  112.47 +			int lmin,lmax;
  112.48 +			struct pvr2_ctrl *hcp,*vcp;
  112.49  			int h = vf->fmt.pix.height;
  112.50  			int w = vf->fmt.pix.width;
  112.51 +			hcp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_HRES);
  112.52 +			vcp = pvr2_hdw_get_ctrl_by_id(hdw,PVR2_CID_VRES);
  112.53  
  112.54 -			if (h < 200) {
  112.55 -				h = 200;
  112.56 -			} else if (h > 625) {
  112.57 -				h = 625;
  112.58 +			lmin = pvr2_ctrl_get_min(hcp);
  112.59 +			lmax = pvr2_ctrl_get_max(hcp);
  112.60 +			if (w < lmin) {
  112.61 +				w = lmin;
  112.62 +			} else if (w > lmax) {
  112.63 +				w = lmax;
  112.64  			}
  112.65 -			if (w < 320) {
  112.66 -				w = 320;
  112.67 -			} else if (w > 720) {
  112.68 -				w = 720;
  112.69 +			lmin = pvr2_ctrl_get_min(vcp);
  112.70 +			lmax = pvr2_ctrl_get_max(vcp);
  112.71 +			if (h < lmin) {
  112.72 +				h = lmin;
  112.73 +			} else if (h > lmax) {
  112.74 +				h = lmax;
  112.75  			}
  112.76  
  112.77  			memcpy(vf, &pvr_format[PVR_FORMAT_PIX],
  112.78 @@ -479,14 +484,8 @@ static int pvr2_v4l2_do_ioctl(struct ino
  112.79  			vf->fmt.pix.height = h;
  112.80  
  112.81  			if (cmd == VIDIOC_S_FMT) {
  112.82 -				pvr2_ctrl_set_value(
  112.83 -					pvr2_hdw_get_ctrl_by_id(hdw,
  112.84 -								PVR2_CID_HRES),
  112.85 -					vf->fmt.pix.width);
  112.86 -				pvr2_ctrl_set_value(
  112.87 -					pvr2_hdw_get_ctrl_by_id(hdw,
  112.88 -								PVR2_CID_VRES),
  112.89 -					vf->fmt.pix.height);
  112.90 +				pvr2_ctrl_set_value(hcp,vf->fmt.pix.width);
  112.91 +				pvr2_ctrl_set_value(vcp,vf->fmt.pix.height);
  112.92  			}
  112.93  		} break;
  112.94  		case V4L2_BUF_TYPE_VBI_CAPTURE:
  112.95 @@ -703,12 +702,6 @@ static void pvr2_v4l2_dev_destroy(struct
  112.96  {
  112.97  	printk(KERN_INFO "pvrusb2: unregistering device video%d [%s]\n",
  112.98  	       dip->vdev->minor,pvr2_config_get_name(dip->config));
  112.99 -	if (dip->ctxt_idx >= 0) {
 112.100 -		mutex_lock(&device_lock);
 112.101 -		devices[dip->ctxt_idx] = NULL;
 112.102 -		dip->ctxt_idx = -1;
 112.103 -		mutex_unlock(&device_lock);
 112.104 -	}
 112.105  	video_unregister_device(dip->vdev);
 112.106  }
 112.107  
 112.108 @@ -800,33 +793,10 @@ static int pvr2_v4l2_open(struct inode *
 112.109  	struct pvr2_v4l2 *vp;
 112.110  	struct pvr2_hdw *hdw;
 112.111  
 112.112 -	mutex_lock(&device_lock);
 112.113 -	/* MCI 7-Jun-2006 Even though we're just doing what amounts to an
 112.114 -	   atomic read of the device mapping array here, we still need the
 112.115 -	   mutex.  The problem is that there is a tiny race possible when
 112.116 -	   we register the device.  We can't update the device mapping
 112.117 -	   array until after the device has been registered, owing to the
 112.118 -	   fact that we can't know the minor device number until after the
 112.119 -	   registration succeeds.  And if another thread tries to open the
 112.120 -	   device in the window of time after registration but before the
 112.121 -	   map is updated, then it will get back an erroneous null pointer
 112.122 -	   and the open will result in a spurious failure.  The only way to
 112.123 -	   prevent that is to (a) be inside the mutex here before we access
 112.124 -	   the array, and (b) cover the entire registration process later
 112.125 -	   on with this same mutex.  Thus if we get inside the mutex here,
 112.126 -	   then we can be assured that the registration process actually
 112.127 -	   completed correctly.  This is an unhappy complication from the
 112.128 -	   use of global data in a driver that lives in a preemptible
 112.129 -	   environment.  It sure would be nice if the video device itself
 112.130 -	   had a means for storing and retrieving a local context pointer.
 112.131 -	   Oh wait.  It did.  But now it's gone.  Silly me. */
 112.132  	{
 112.133 -		unsigned int midx = iminor(file->f_dentry->d_inode);
 112.134 -		if (midx < sizeof(devices)/sizeof(devices[0])) {
 112.135 -			dip = devices[midx];
 112.136 -		}
 112.137 +		struct video_device *vdev = video_devdata(file);
 112.138 +		dip = (struct pvr2_v4l2_dev *)video_get_drvdata(vdev);
 112.139  	}
 112.140 -	mutex_unlock(&device_lock);
 112.141  
 112.142  	if (!dip) return -ENODEV; /* Should be impossible but I'm paranoid */
 112.143  
 112.144 @@ -1066,7 +1036,7 @@ static void pvr2_v4l2_dev_init(struct pv
 112.145  
 112.146  	memcpy(dip->vdev,&vdev_template,sizeof(vdev_template));
 112.147  	dip->vdev->release = video_device_release;
 112.148 -	mutex_lock(&device_lock);
 112.149 +	video_set_drvdata(dip->vdev,dip);
 112.150  
 112.151  	mindevnum = -1;
 112.152  	unit_number = pvr2_hdw_get_unit_number(vp->channel.mc_head->hdw);
 112.153 @@ -1081,12 +1051,6 @@ static void pvr2_v4l2_dev_init(struct pv
 112.154  		       dip->vdev->minor,pvr2_config_get_name(dip->config));
 112.155  	}
 112.156  
 112.157 -	if ((dip->vdev->minor < sizeof(devices)/sizeof(devices[0])) &&
 112.158 -	    (devices[dip->vdev->minor] == NULL)) {
 112.159 -		dip->ctxt_idx = dip->vdev->minor;
 112.160 -		devices[dip->ctxt_idx] = dip;
 112.161 -	}
 112.162 -	mutex_unlock(&device_lock);
 112.163  
 112.164  	pvr2_hdw_v4l_store_minor_number(vp->channel.mc_head->hdw,
 112.165  					dip->vdev->minor);
 112.166 @@ -1100,7 +1064,6 @@ struct pvr2_v4l2 *pvr2_v4l2_create(struc
 112.167  	vp = kmalloc(sizeof(*vp),GFP_KERNEL);
 112.168  	if (!vp) return vp;
 112.169  	memset(vp,0,sizeof(*vp));
 112.170 -	vp->video_dev.ctxt_idx = -1;
 112.171  	pvr2_channel_init(&vp->channel,mnp);
 112.172  	pvr2_trace(PVR2_TRACE_STRUCT,"Creating pvr2_v4l2 id=%p",vp);
 112.173  
   113.1 --- a/drivers/media/video/saa7134/saa7134-dvb.c	Tue Oct 02 09:52:15 2007 +0100
   113.2 +++ b/drivers/media/video/saa7134/saa7134-dvb.c	Wed Oct 03 10:00:44 2007 +0100
   113.3 @@ -1158,13 +1158,13 @@ static int dvb_init(struct saa7134_dev *
   113.4  	case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
   113.5  		dev->dvb.frontend = nxt200x_attach(&avertvhda180, &dev->i2c_adap);
   113.6  		if (dev->dvb.frontend) {
   113.7 -			dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->i2c_adap, &dvb_pll_tdhu2);
   113.8 +			dvb_pll_attach(dev->dvb.frontend, 0x61, NULL, &dvb_pll_tdhu2);
   113.9  		}
  113.10  		break;
  113.11  	case SAA7134_BOARD_KWORLD_ATSC110:
  113.12  		dev->dvb.frontend = nxt200x_attach(&kworldatsc110, &dev->i2c_adap);
  113.13  		if (dev->dvb.frontend) {
  113.14 -			dvb_pll_attach(dev->dvb.frontend, 0x61, &dev->i2c_adap, &dvb_pll_tuv1236d);
  113.15 +			dvb_pll_attach(dev->dvb.frontend, 0x61, NULL, &dvb_pll_tuv1236d);
  113.16  		}
  113.17  		break;
  113.18  #endif
   114.1 --- a/drivers/media/video/tuner-simple.c	Tue Oct 02 09:52:15 2007 +0100
   114.2 +++ b/drivers/media/video/tuner-simple.c	Wed Oct 03 10:00:44 2007 +0100
   114.3 @@ -108,6 +108,7 @@ static int tuner_stereo(struct i2c_clien
   114.4  		case TUNER_PHILIPS_FM1216ME_MK3:
   114.5  		case TUNER_PHILIPS_FM1236_MK3:
   114.6  		case TUNER_PHILIPS_FM1256_IH3:
   114.7 +		case TUNER_LG_NTSC_TAPE:
   114.8  			stereo = ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
   114.9  			break;
  114.10  		default:
  114.11 @@ -419,6 +420,7 @@ static void default_set_radio_freq(struc
  114.12  	case TUNER_PHILIPS_FM1216ME_MK3:
  114.13  	case TUNER_PHILIPS_FM1236_MK3:
  114.14  	case TUNER_PHILIPS_FMD1216ME_MK3:
  114.15 +	case TUNER_LG_NTSC_TAPE:
  114.16  		buffer[3] = 0x19;
  114.17  		break;
  114.18  	case TUNER_TNF_5335MF:
   115.1 --- a/drivers/media/video/tuner-types.c	Tue Oct 02 09:52:15 2007 +0100
   115.2 +++ b/drivers/media/video/tuner-types.c	Wed Oct 03 10:00:44 2007 +0100
   115.3 @@ -671,16 +671,6 @@ static struct tuner_params tuner_panason
   115.4  	},
   115.5  };
   115.6  
   115.7 -/* ------------ TUNER_LG_NTSC_TAPE - LGINNOTEK NTSC ------------ */
   115.8 -
   115.9 -static struct tuner_params tuner_lg_ntsc_tape_params[] = {
  115.10 -	{
  115.11 -		.type   = TUNER_PARAM_TYPE_NTSC,
  115.12 -		.ranges = tuner_fm1236_mk3_ntsc_ranges,
  115.13 -		.count  = ARRAY_SIZE(tuner_fm1236_mk3_ntsc_ranges),
  115.14 -	},
  115.15 -};
  115.16 -
  115.17  /* ------------ TUNER_TNF_8831BGFF - Philips PAL ------------ */
  115.18  
  115.19  static struct tuner_range tuner_tnf_8831bgff_pal_ranges[] = {
  115.20 @@ -1331,8 +1321,8 @@ struct tunertype tuners[] = {
  115.21  	},
  115.22  	[TUNER_LG_NTSC_TAPE] = { /* LGINNOTEK NTSC */
  115.23  		.name   = "LG NTSC (TAPE series)",
  115.24 -		.params = tuner_lg_ntsc_tape_params,
  115.25 -		.count  = ARRAY_SIZE(tuner_lg_ntsc_tape_params),
  115.26 +		.params = tuner_fm1236_mk3_params,
  115.27 +		.count  = ARRAY_SIZE(tuner_fm1236_mk3_params),
  115.28  	},
  115.29  	[TUNER_TNF_8831BGFF] = { /* Philips PAL */
  115.30  		.name   = "Tenna TNF 8831 BGFF)",
   116.1 --- a/drivers/media/video/tveeprom.c	Tue Oct 02 09:52:15 2007 +0100
   116.2 +++ b/drivers/media/video/tveeprom.c	Wed Oct 03 10:00:44 2007 +0100
   116.3 @@ -184,7 +184,7 @@ hauppauge_tuner[] =
   116.4  	{ TUNER_ABSENT,        "Thompson DTT757"},
   116.5  	/* 80-89 */
   116.6  	{ TUNER_ABSENT,        "Philips FQ1216LME MK3"},
   116.7 -	{ TUNER_ABSENT,        "LG TAPC G701D"},
   116.8 +	{ TUNER_LG_PAL_NEW_TAPC, "LG TAPC G701D"},
   116.9  	{ TUNER_LG_NTSC_NEW_TAPC, "LG TAPC H791F"},
  116.10  	{ TUNER_LG_PAL_NEW_TAPC, "TCL 2002MB 3"},
  116.11  	{ TUNER_LG_PAL_NEW_TAPC, "TCL 2002MI 3"},
   117.1 --- a/drivers/media/video/usbvideo/quickcam_messenger.h	Tue Oct 02 09:52:15 2007 +0100
   117.2 +++ b/drivers/media/video/usbvideo/quickcam_messenger.h	Wed Oct 03 10:00:44 2007 +0100
   117.3 @@ -35,27 +35,13 @@ struct rgb {
   117.4  };
   117.5  
   117.6  struct bayL0 {
   117.7 -#ifdef __BIG_ENDIAN
   117.8 -	u8 r;
   117.9 -	u8 g;
  117.10 -#elif __LITTLE_ENDIAN
  117.11  	u8 g;
  117.12  	u8 r;
  117.13 -#else
  117.14 -#error not byte order defined
  117.15 -#endif
  117.16  };
  117.17  
  117.18  struct bayL1 {
  117.19 -#ifdef __BIG_ENDIAN
  117.20 -	u8 g;
  117.21 -	u8 b;
  117.22 -#elif __LITTLE_ENDIAN
  117.23  	u8 b;
  117.24  	u8 g;
  117.25 -#else
  117.26 -#error not byte order defined
  117.27 -#endif
  117.28  };
  117.29  
  117.30  struct cam_size {
   118.1 --- a/drivers/media/video/video-buf.c	Tue Oct 02 09:52:15 2007 +0100
   118.2 +++ b/drivers/media/video/video-buf.c	Wed Oct 03 10:00:44 2007 +0100
   118.3 @@ -695,6 +695,7 @@ videobuf_qbuf(struct videobuf_queue *q,
   118.4  		goto done;
   118.5  	}
   118.6  	if (buf->state == STATE_QUEUED ||
   118.7 +	    buf->state == STATE_PREPARED ||
   118.8  	    buf->state == STATE_ACTIVE) {
   118.9  		dprintk(1,"qbuf: buffer is already queued or active.\n");
  118.10  		goto done;
   119.1 --- a/drivers/media/video/videodev.c	Tue Oct 02 09:52:15 2007 +0100
   119.2 +++ b/drivers/media/video/videodev.c	Wed Oct 03 10:00:44 2007 +0100
   119.3 @@ -739,13 +739,13 @@ static int __video_do_ioctl(struct inode
   119.4  	case VIDIOC_DQBUF:
   119.5  	{
   119.6  		struct v4l2_buffer *p=arg;
   119.7 -		if (!vfd->vidioc_qbuf)
   119.8 +		if (!vfd->vidioc_dqbuf)
   119.9  			break;
  119.10  		ret = check_fmt (vfd, p->type);
  119.11  		if (ret)
  119.12  			break;
  119.13  
  119.14 -		ret=vfd->vidioc_qbuf(file, fh, p);
  119.15 +		ret=vfd->vidioc_dqbuf(file, fh, p);
  119.16  		if (!ret)
  119.17  			dbgbuf(cmd,vfd,p);
  119.18  		break;
  119.19 @@ -836,7 +836,7 @@ static int __video_do_ioctl(struct inode
  119.20  			break;
  119.21  		}
  119.22  
  119.23 -		if (index<=0 || index >= vfd->tvnormsize) {
  119.24 +		if (index < 0 || index >= vfd->tvnormsize) {
  119.25  			ret=-EINVAL;
  119.26  			break;
  119.27  		}
   120.1 --- a/drivers/net/bonding/bond_main.c	Tue Oct 02 09:52:15 2007 +0100
   120.2 +++ b/drivers/net/bonding/bond_main.c	Wed Oct 03 10:00:44 2007 +0100
   120.3 @@ -3547,7 +3547,7 @@ static int bond_do_ioctl(struct net_devi
   120.4  			mii->val_out = 0;
   120.5  			read_lock_bh(&bond->lock);
   120.6  			read_lock(&bond->curr_slave_lock);
   120.7 -			if (bond->curr_active_slave) {
   120.8 +			if (netif_carrier_ok(bond->dev)) {
   120.9  				mii->val_out = BMSR_LSTATUS;
  120.10  			}
  120.11  			read_unlock(&bond->curr_slave_lock);
   121.1 --- a/drivers/net/e1000/e1000_main.c	Tue Oct 02 09:52:15 2007 +0100
   121.2 +++ b/drivers/net/e1000/e1000_main.c	Wed Oct 03 10:00:44 2007 +0100
   121.3 @@ -4683,6 +4683,9 @@ e1000_suspend(struct pci_dev *pdev, pm_m
   121.4  	if (adapter->hw.phy_type == e1000_phy_igp_3)
   121.5  		e1000_phy_powerdown_workaround(&adapter->hw);
   121.6  
   121.7 +	if (netif_running(netdev))
   121.8 +		e1000_free_irq(adapter);
   121.9 +
  121.10  	/* Release control of h/w to f/w.  If f/w is AMT enabled, this
  121.11  	 * would have already happened in close and is redundant. */
  121.12  	e1000_release_hw_control(adapter);
  121.13 @@ -4710,6 +4713,10 @@ e1000_resume(struct pci_dev *pdev)
  121.14  	pci_enable_wake(pdev, PCI_D3hot, 0);
  121.15  	pci_enable_wake(pdev, PCI_D3cold, 0);
  121.16  
  121.17 +	if (netif_running(netdev) && (ret_val = e1000_request_irq(adapter)))
  121.18 +		return ret_val;
  121.19 +
  121.20 +	e1000_power_up_phy(adapter);
  121.21  	e1000_reset(adapter);
  121.22  	E1000_WRITE_REG(&adapter->hw, WUS, ~0);
  121.23  
   122.1 --- a/drivers/net/forcedeth.c	Tue Oct 02 09:52:15 2007 +0100
   122.2 +++ b/drivers/net/forcedeth.c	Wed Oct 03 10:00:44 2007 +0100
   122.3 @@ -2692,11 +2692,13 @@ static int nv_request_irq(struct net_dev
   122.4  	}
   122.5  	if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) {
   122.6  		if ((ret = pci_enable_msi(np->pci_dev)) == 0) {
   122.7 +			pci_intx(np->pci_dev, 0);
   122.8  			np->msi_flags |= NV_MSI_ENABLED;
   122.9  			if ((!intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq, IRQF_SHARED, dev->name, dev) != 0) ||
  122.10  			    (intr_test && request_irq(np->pci_dev->irq, &nv_nic_irq_test, IRQF_SHARED, dev->name, dev) != 0)) {
  122.11  				printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret);
  122.12  				pci_disable_msi(np->pci_dev);
  122.13 +				pci_intx(np->pci_dev, 1);
  122.14  				np->msi_flags &= ~NV_MSI_ENABLED;
  122.15  				goto out_err;
  122.16  			}
  122.17 @@ -2739,6 +2741,7 @@ static void nv_free_irq(struct net_devic
  122.18  		free_irq(np->pci_dev->irq, dev);
  122.19  		if (np->msi_flags & NV_MSI_ENABLED) {
  122.20  			pci_disable_msi(np->pci_dev);
  122.21 +			pci_intx(np->pci_dev, 1);
  122.22  			np->msi_flags &= ~NV_MSI_ENABLED;
  122.23  		}
  122.24  	}
   123.1 --- a/drivers/net/lp486e.c	Tue Oct 02 09:52:15 2007 +0100
   123.2 +++ b/drivers/net/lp486e.c	Wed Oct 03 10:00:44 2007 +0100
   123.3 @@ -442,16 +442,16 @@ init_rx_bufs(struct net_device *dev, int
   123.4  		if (rbd) {
   123.5  			rbd->pad = 0;
   123.6  			rbd->count = 0;
   123.7 -			rbd->skb = dev_alloc_skb(RX_SKB_SIZE);
   123.8 +			rbd->skb = dev_alloc_skb(RX_SKBSIZE);
   123.9  			if (!rbd->skb) {
  123.10  				printk("dev_alloc_skb failed");
  123.11  			}
  123.12  			rbd->next = rfd->rbd;
  123.13  			if (i) {
  123.14  				rfd->rbd->prev = rbd;
  123.15 -				rbd->size = RX_SKB_SIZE;
  123.16 +				rbd->size = RX_SKBSIZE;
  123.17  			} else {
  123.18 -				rbd->size = (RX_SKB_SIZE | RBD_EL);
  123.19 +				rbd->size = (RX_SKBSIZE | RBD_EL);
  123.20  				lp->rbd_tail = rbd;
  123.21  			}
  123.22  
   124.1 --- a/drivers/net/mv643xx_eth.c	Tue Oct 02 09:52:15 2007 +0100
   124.2 +++ b/drivers/net/mv643xx_eth.c	Wed Oct 03 10:00:44 2007 +0100
   124.3 @@ -385,7 +385,7 @@ static int mv643xx_eth_receive_queue(str
   124.4  	struct pkt_info pkt_info;
   124.5  
   124.6  	while (budget-- > 0 && eth_port_receive(mp, &pkt_info) == ETH_OK) {
   124.7 -		dma_unmap_single(NULL, pkt_info.buf_ptr, RX_SKB_SIZE,
   124.8 +		dma_unmap_single(NULL, pkt_info.buf_ptr, ETH_RX_SKB_SIZE,
   124.9  							DMA_FROM_DEVICE);
  124.10  		mp->rx_desc_count--;
  124.11  		received_packets++;
   125.1 --- a/drivers/net/sky2.c	Tue Oct 02 09:52:15 2007 +0100
   125.2 +++ b/drivers/net/sky2.c	Wed Oct 03 10:00:44 2007 +0100
   125.3 @@ -106,6 +106,7 @@ static const struct pci_device_id sky2_i
   125.4  	{ PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) },
   125.5  	{ PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) },
   125.6  	{ PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) },	/* DGE-560T */
   125.7 +	{ PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) }, 	/* DGE-550SX */
   125.8  	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) },
   125.9  	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) },
  125.10  	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) },
  125.11 @@ -117,10 +118,17 @@ static const struct pci_device_id sky2_i
  125.12  	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) },
  125.13  	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) },
  125.14  	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) },
  125.15 +	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) },
  125.16  	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) },
  125.17  	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) },
  125.18  	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) },
  125.19  	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) },
  125.20 +	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) },
  125.21 +	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4365) },
  125.22 +	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) },
  125.23 +	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) },
  125.24 +	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) },
  125.25 +	{ PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) },
  125.26  	{ 0 }
  125.27  };
  125.28  
  125.29 @@ -670,7 +678,7 @@ static void sky2_mac_init(struct sky2_hw
  125.30  	sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON);
  125.31  
  125.32  	if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
  125.33 -		sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8);
  125.34 +		sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 512/8);
  125.35  		sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
  125.36  		if (hw->dev[port]->mtu > ETH_DATA_LEN) {
  125.37  			/* set Tx GMAC FIFO Almost Empty Threshold */
  125.38 @@ -682,16 +690,10 @@ static void sky2_mac_init(struct sky2_hw
  125.39  
  125.40  }
  125.41  
  125.42 -/* Assign Ram Buffer allocation.
  125.43 - * start and end are in units of 4k bytes
  125.44 - * ram registers are in units of 64bit words
  125.45 - */
  125.46 -static void sky2_ramset(struct sky2_hw *hw, u16 q, u8 startk, u8 endk)
  125.47 +/* Assign Ram Buffer allocation in units of 64bit (8 bytes) */
  125.48 +static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end)
  125.49  {
  125.50 -	u32 start, end;
  125.51 -
  125.52 -	start = startk * 4096/8;
  125.53 -	end = (endk * 4096/8) - 1;
  125.54 +	pr_debug(PFX "q %d %#x %#x\n", q, start, end);
  125.55  
  125.56  	sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR);
  125.57  	sky2_write32(hw, RB_ADDR(q, RB_START), start);
  125.58 @@ -700,7 +702,7 @@ static void sky2_ramset(struct sky2_hw *
  125.59  	sky2_write32(hw, RB_ADDR(q, RB_RP), start);
  125.60  
  125.61  	if (q == Q_R1 || q == Q_R2) {
  125.62 -		u32 space = (endk - startk) * 4096/8;
  125.63 +		u32 space = end - start + 1;
  125.64  		u32 tp = space - space/4;
  125.65  
  125.66  		/* On receive queue's set the thresholds
  125.67 @@ -1082,19 +1084,16 @@ static int sky2_up(struct net_device *de
  125.68  
  125.69  	sky2_mac_init(hw, port);
  125.70  
  125.71 -	/* Determine available ram buffer space (in 4K blocks).
  125.72 -	 * Note: not sure about the FE setting below yet
  125.73 -	 */
  125.74 -	if (hw->chip_id == CHIP_ID_YUKON_FE)
  125.75 -		ramsize = 4;
  125.76 +	/* Determine available ram buffer space in qwords.  */
  125.77 +	ramsize = sky2_read8(hw, B2_E_0) * 4096/8;
  125.78 +
  125.79 +	if (ramsize > 6*1024/8)
  125.80 +		rxspace = ramsize - (ramsize + 2) / 3;
  125.81  	else
  125.82 -		ramsize = sky2_read8(hw, B2_E_0);
  125.83 -
  125.84 -	/* Give transmitter one third (rounded up) */
  125.85 -	rxspace = ramsize - (ramsize + 2) / 3;
  125.86 -
  125.87 -	sky2_ramset(hw, rxqaddr[port], 0, rxspace);
  125.88 -	sky2_ramset(hw, txqaddr[port], rxspace, ramsize);
  125.89 +		rxspace = ramsize / 2;
  125.90 +
  125.91 +	sky2_ramset(hw, rxqaddr[port], 0, rxspace-1);
  125.92 +	sky2_ramset(hw, txqaddr[port], rxspace, ramsize-1);
  125.93  
  125.94  	/* Make sure SyncQ is disabled */
  125.95  	sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
  125.96 @@ -1421,6 +1420,11 @@ static int sky2_down(struct net_device *
  125.97  	/* Stop more packets from being queued */
  125.98  	netif_stop_queue(dev);
  125.99  
 125.100 +	/* Disable port IRQ */
 125.101 +	imask = sky2_read32(hw, B0_IMSK);
 125.102 +	imask &= ~portirq_msk[port];
 125.103 +	sky2_write32(hw, B0_IMSK, imask);
 125.104 +
 125.105  	sky2_phy_reset(hw, port);
 125.106  
 125.107  	/* Stop transmitter */
 125.108 @@ -1464,11 +1468,6 @@ static int sky2_down(struct net_device *
 125.109  	sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
 125.110  	sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET);
 125.111  
 125.112 -	/* Disable port IRQ */
 125.113 -	imask = sky2_read32(hw, B0_IMSK);
 125.114 -	imask &= ~portirq_msk[port];
 125.115 -	sky2_write32(hw, B0_IMSK, imask);
 125.116 -
 125.117  	/* turn off LED's */
 125.118  	sky2_write16(hw, B0_Y2LED, LED_STAT_OFF);
 125.119  
 125.120 @@ -1679,13 +1678,13 @@ static void sky2_phy_intr(struct sky2_hw
 125.121  	struct sky2_port *sky2 = netdev_priv(dev);
 125.122  	u16 istatus, phystat;
 125.123  
 125.124 +	if (!netif_running(dev))
 125.125 +		return;
 125.126 +
 125.127  	spin_lock(&sky2->phy_lock);
 125.128  	istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT);
 125.129  	phystat = gm_phy_read(hw, port, PHY_MARV_PHY_STAT);
 125.130  
 125.131 -	if (!netif_running(dev))
 125.132 -		goto out;
 125.133 -
 125.134  	if (netif_msg_intr(sky2))
 125.135  		printk(KERN_INFO PFX "%s: phy interrupt status 0x%x 0x%x\n",
 125.136  		       sky2->netdev->name, istatus, phystat);
 125.137 @@ -2737,6 +2736,14 @@ static int sky2_set_mac_address(struct n
 125.138  	return 0;
 125.139  }
 125.140  
 125.141 +static void inline sky2_add_filter(u8 filter[8], const u8 *addr)
 125.142 +{
 125.143 +	u32 bit;
 125.144 +
 125.145 +	bit = ether_crc(ETH_ALEN, addr) & 63;
 125.146 +	filter[bit >> 3] |= 1 << (bit & 7);
 125.147 +}
 125.148 +
 125.149  static void sky2_set_multicast(struct net_device *dev)
 125.150  {
 125.151  	struct sky2_port *sky2 = netdev_priv(dev);
 125.152 @@ -2745,6 +2752,7 @@ static void sky2_set_multicast(struct ne
 125.153  	struct dev_mc_list *list = dev->mc_list;
 125.154  	u16 reg;
 125.155  	u8 filter[8];
 125.156 +	static const u8 pause_mc_addr[ETH_ALEN] = { 0x1, 0x80, 0xc2, 0x0, 0x0, 0x1 };
 125.157  
 125.158  	memset(filter, 0, sizeof(filter));
 125.159  
 125.160 @@ -2755,16 +2763,17 @@ static void sky2_set_multicast(struct ne
 125.161  		reg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA);
 125.162  	else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > 16)	/* all multicast */
 125.163  		memset(filter, 0xff, sizeof(filter));
 125.164 -	else if (dev->mc_count == 0)	/* no multicast */
 125.165 +	else if (dev->mc_count == 0 && !sky2->rx_pause)
 125.166  		reg &= ~GM_RXCR_MCF_ENA;
 125.167  	else {
 125.168  		int i;
 125.169  		reg |= GM_RXCR_MCF_ENA;
 125.170  
 125.171 -		for (i = 0; list && i < dev->mc_count; i++, list = list->next) {
 125.172 -			u32 bit = ether_crc(ETH_ALEN, list->dmi_addr) & 0x3f;
 125.173 -			filter[bit / 8] |= 1 << (bit % 8);
 125.174 -		}
 125.175 +		if (sky2->rx_pause)
 125.176 +			sky2_add_filter(filter, pause_mc_addr);
 125.177 +
 125.178 +		for (i = 0; list && i < dev->mc_count; i++, list = list->next)
 125.179 +			sky2_add_filter(filter, list->dmi_addr);
 125.180  	}
 125.181  
 125.182  	gma_write16(hw, port, GM_MC_ADDR_H1,
 125.183 @@ -3200,6 +3209,8 @@ static int __devinit sky2_test_msi(struc
 125.184  	struct pci_dev *pdev = hw->pdev;
 125.185  	int err;
 125.186  
 125.187 +	init_waitqueue_head (&hw->msi_wait);
 125.188 +
 125.189  	sky2_write32(hw, B0_IMSK, Y2_IS_IRQ_SW);
 125.190  
 125.191  	err = request_irq(pdev->irq, sky2_test_intr, IRQF_SHARED, DRV_NAME, hw);
 125.192 @@ -3209,18 +3220,15 @@ static int __devinit sky2_test_msi(struc
 125.193  		return err;
 125.194  	}
 125.195  
 125.196 -	init_waitqueue_head (&hw->msi_wait);
 125.197 -
 125.198  	sky2_write8(hw, B0_CTST, CS_ST_SW_IRQ);
 125.199 -	wmb();
 125.200 +	sky2_read8(hw, B0_CTST);
 125.201  
 125.202  	wait_event_timeout(hw->msi_wait, hw->msi_detected, HZ/10);
 125.203  
 125.204  	if (!hw->msi_detected) {
 125.205  		/* MSI test failed, go back to INTx mode */
 125.206 -		printk(KERN_WARNING PFX "%s: No interrupt was generated using MSI, "
 125.207 -		       "switching to INTx mode. Please report this failure to "
 125.208 -		       "the PCI maintainer and include system chipset information.\n",
 125.209 +		printk(KERN_INFO PFX "%s: No interrupt generated using MSI, "
 125.210 +		       "switching to INTx mode.\n",
 125.211  		       pci_name(pdev));
 125.212  
 125.213  		err = -EOPNOTSUPP;
 125.214 @@ -3228,6 +3236,7 @@ static int __devinit sky2_test_msi(struc
 125.215  	}
 125.216  
 125.217  	sky2_write32(hw, B0_IMSK, 0);
 125.218 +	sky2_read32(hw, B0_IMSK);
 125.219  
 125.220  	free_irq(pdev->irq, hw);
 125.221  
   126.1 --- a/drivers/net/sky2.h	Tue Oct 02 09:52:15 2007 +0100
   126.2 +++ b/drivers/net/sky2.h	Wed Oct 03 10:00:44 2007 +0100
   126.3 @@ -1566,7 +1566,7 @@ enum {
   126.4  
   126.5  	GMR_FS_ANY_ERR	= GMR_FS_RX_FF_OV | GMR_FS_CRC_ERR |
   126.6  			  GMR_FS_FRAGMENT | GMR_FS_LONG_ERR |
   126.7 -		  	  GMR_FS_MII_ERR | GMR_FS_BAD_FC | GMR_FS_GOOD_FC |
   126.8 +		  	  GMR_FS_MII_ERR | GMR_FS_GOOD_FC | GMR_FS_BAD_FC |
   126.9  			  GMR_FS_UN_SIZE | GMR_FS_JABBER,
  126.10  };
  126.11  
   127.1 --- a/drivers/net/sunhme.c	Tue Oct 02 09:52:15 2007 +0100
   127.2 +++ b/drivers/net/sunhme.c	Wed Oct 03 10:00:44 2007 +0100
   127.3 @@ -3012,6 +3012,11 @@ static int __devinit happy_meal_pci_prob
   127.4  #endif
   127.5  
   127.6  	err = -ENODEV;
   127.7 +
   127.8 +	if (pci_enable_device(pdev))
   127.9 +		goto err_out;
  127.10 +	pci_set_master(pdev);
  127.11 +
  127.12  	if (!strcmp(prom_name, "SUNW,qfe") || !strcmp(prom_name, "qfe")) {
  127.13  		qp = quattro_pci_find(pdev);
  127.14  		if (qp == NULL)
   128.1 --- a/drivers/net/tg3.c	Tue Oct 02 09:52:15 2007 +0100
   128.2 +++ b/drivers/net/tg3.c	Wed Oct 03 10:00:44 2007 +0100
   128.3 @@ -6889,8 +6889,10 @@ static int tg3_open(struct net_device *d
   128.4  	tg3_full_lock(tp, 0);
   128.5  
   128.6  	err = tg3_set_power_state(tp, PCI_D0);
   128.7 -	if (err)
   128.8 +	if (err) {
   128.9 +		tg3_full_unlock(tp);
  128.10  		return err;
  128.11 +	}
  128.12  
  128.13  	tg3_disable_ints(tp);
  128.14  	tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
   129.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx.h	Tue Oct 02 09:52:15 2007 +0100
   129.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx.h	Wed Oct 03 10:00:44 2007 +0100
   129.3 @@ -21,7 +21,7 @@
   129.4  #define PFX				KBUILD_MODNAME ": "
   129.5  
   129.6  #define BCM43xx_SWITCH_CORE_MAX_RETRIES	50
   129.7 -#define BCM43xx_IRQWAIT_MAX_RETRIES	50
   129.8 +#define BCM43xx_IRQWAIT_MAX_RETRIES	100
   129.9  
  129.10  #define BCM43xx_IO_SIZE			8192
  129.11  
  129.12 @@ -33,14 +33,18 @@
  129.13  #define BCM43xx_PCICFG_ICR		0x94
  129.14  
  129.15  /* MMIO offsets */
  129.16 -#define BCM43xx_MMIO_DMA1_REASON	0x20
  129.17 -#define BCM43xx_MMIO_DMA1_IRQ_MASK	0x24
  129.18 -#define BCM43xx_MMIO_DMA2_REASON	0x28
  129.19 -#define BCM43xx_MMIO_DMA2_IRQ_MASK	0x2C
  129.20 -#define BCM43xx_MMIO_DMA3_REASON	0x30
  129.21 -#define BCM43xx_MMIO_DMA3_IRQ_MASK	0x34
  129.22 -#define BCM43xx_MMIO_DMA4_REASON	0x38
  129.23 -#define BCM43xx_MMIO_DMA4_IRQ_MASK	0x3C
  129.24 +#define BCM43xx_MMIO_DMA0_REASON	0x20
  129.25 +#define BCM43xx_MMIO_DMA0_IRQ_MASK	0x24
  129.26 +#define BCM43xx_MMIO_DMA1_REASON	0x28
  129.27 +#define BCM43xx_MMIO_DMA1_IRQ_MASK	0x2C
  129.28 +#define BCM43xx_MMIO_DMA2_REASON	0x30
  129.29 +#define BCM43xx_MMIO_DMA2_IRQ_MASK	0x34
  129.30 +#define BCM43xx_MMIO_DMA3_REASON	0x38
  129.31 +#define BCM43xx_MMIO_DMA3_IRQ_MASK	0x3C
  129.32 +#define BCM43xx_MMIO_DMA4_REASON	0x40
  129.33 +#define BCM43xx_MMIO_DMA4_IRQ_MASK	0x44
  129.34 +#define BCM43xx_MMIO_DMA5_REASON	0x48
  129.35 +#define BCM43xx_MMIO_DMA5_IRQ_MASK	0x4C
  129.36  #define BCM43xx_MMIO_STATUS_BITFIELD	0x120
  129.37  #define BCM43xx_MMIO_STATUS2_BITFIELD	0x124
  129.38  #define BCM43xx_MMIO_GEN_IRQ_REASON	0x128
  129.39 @@ -56,14 +60,27 @@
  129.40  #define BCM43xx_MMIO_XMITSTAT_1		0x174
  129.41  #define BCM43xx_MMIO_REV3PLUS_TSF_LOW	0x180 /* core rev >= 3 only */
  129.42  #define BCM43xx_MMIO_REV3PLUS_TSF_HIGH	0x184 /* core rev >= 3 only */
  129.43 -#define BCM43xx_MMIO_DMA1_BASE		0x200
  129.44 -#define BCM43xx_MMIO_DMA2_BASE		0x220
  129.45 -#define BCM43xx_MMIO_DMA3_BASE		0x240
  129.46 -#define BCM43xx_MMIO_DMA4_BASE		0x260
  129.47 +
  129.48 +/* 32-bit DMA */
  129.49 +#define BCM43xx_MMIO_DMA32_BASE0	0x200
  129.50 +#define BCM43xx_MMIO_DMA32_BASE1	0x220
  129.51 +#define BCM43xx_MMIO_DMA32_BASE2	0x240
  129.52 +#define BCM43xx_MMIO_DMA32_BASE3	0x260
  129.53 +#define BCM43xx_MMIO_DMA32_BASE4	0x280
  129.54 +#define BCM43xx_MMIO_DMA32_BASE5	0x2A0
  129.55 +/* 64-bit DMA */
  129.56 +#define BCM43xx_MMIO_DMA64_BASE0	0x200
  129.57 +#define BCM43xx_MMIO_DMA64_BASE1	0x240
  129.58 +#define BCM43xx_MMIO_DMA64_BASE2	0x280
  129.59 +#define BCM43xx_MMIO_DMA64_BASE3	0x2C0
  129.60 +#define BCM43xx_MMIO_DMA64_BASE4	0x300
  129.61 +#define BCM43xx_MMIO_DMA64_BASE5	0x340
  129.62 +/* PIO */
  129.63  #define BCM43xx_MMIO_PIO1_BASE		0x300
  129.64  #define BCM43xx_MMIO_PIO2_BASE		0x310
  129.65  #define BCM43xx_MMIO_PIO3_BASE		0x320
  129.66  #define BCM43xx_MMIO_PIO4_BASE		0x330
  129.67 +
  129.68  #define BCM43xx_MMIO_PHY_VER		0x3E0
  129.69  #define BCM43xx_MMIO_PHY_RADIO		0x3E2
  129.70  #define BCM43xx_MMIO_ANTENNA		0x3E8
  129.71 @@ -233,8 +250,14 @@
  129.72  #define BCM43xx_SBTMSTATELOW_FORCE_GATE_CLOCK	0x20000
  129.73  
  129.74  /* sbtmstatehigh state flags */
  129.75 -#define BCM43xx_SBTMSTATEHIGH_SERROR		0x1
  129.76 -#define BCM43xx_SBTMSTATEHIGH_BUSY		0x4
  129.77 +#define BCM43xx_SBTMSTATEHIGH_SERROR		0x00000001
  129.78 +#define BCM43xx_SBTMSTATEHIGH_BUSY		0x00000004
  129.79 +#define BCM43xx_SBTMSTATEHIGH_TIMEOUT		0x00000020
  129.80 +#define BCM43xx_SBTMSTATEHIGH_COREFLAGS		0x1FFF0000
  129.81 +#define BCM43xx_SBTMSTATEHIGH_DMA64BIT		0x10000000
  129.82 +#define BCM43xx_SBTMSTATEHIGH_GATEDCLK		0x20000000
  129.83 +#define BCM43xx_SBTMSTATEHIGH_BISTFAILED	0x40000000
  129.84 +#define BCM43xx_SBTMSTATEHIGH_BISTCOMPLETE	0x80000000
  129.85  
  129.86  /* sbimstate flags */
  129.87  #define BCM43xx_SBIMSTATE_IB_ERROR		0x20000
  129.88 @@ -283,6 +306,13 @@
  129.89  #define BCM43xx_SBF_TIME_UPDATE		0x10000000
  129.90  #define BCM43xx_SBF_80000000		0x80000000 /*FIXME: fix name*/
  129.91  
  129.92 +/* Microcode */
  129.93 +#define BCM43xx_UCODE_REVISION		0x0000
  129.94 +#define BCM43xx_UCODE_PATCHLEVEL	0x0002
  129.95 +#define BCM43xx_UCODE_DATE		0x0004
  129.96 +#define BCM43xx_UCODE_TIME		0x0006
  129.97 +#define BCM43xx_UCODE_STATUS		0x0040
  129.98 +
  129.99  /* MicrocodeFlagsBitfield (addr + lo-word values?)*/
 129.100  #define BCM43xx_UCODEFLAGS_OFFSET	0x005E
 129.101  
 129.102 @@ -504,6 +534,12 @@ struct bcm43xx_phyinfo {
 129.103  	 * This lock is only used by bcm43xx_phy_{un}lock()
 129.104  	 */
 129.105  	spinlock_t lock;
 129.106 +
 129.107 +	/* Firmware. */
 129.108 +	const struct firmware *ucode;
 129.109 +	const struct firmware *pcm;
 129.110 +	const struct firmware *initvals0;
 129.111 +	const struct firmware *initvals1;
 129.112  };
 129.113  
 129.114  
 129.115 @@ -568,8 +604,11 @@ struct bcm43xx_dma {
 129.116  	struct bcm43xx_dmaring *tx_ring1;
 129.117  	struct bcm43xx_dmaring *tx_ring2;
 129.118  	struct bcm43xx_dmaring *tx_ring3;
 129.119 +	struct bcm43xx_dmaring *tx_ring4;
 129.120 +	struct bcm43xx_dmaring *tx_ring5;
 129.121 +
 129.122  	struct bcm43xx_dmaring *rx_ring0;
 129.123 -	struct bcm43xx_dmaring *rx_ring1; /* only available on core.rev < 5 */
 129.124 +	struct bcm43xx_dmaring *rx_ring3; /* only available on core.rev < 5 */
 129.125  };
 129.126  
 129.127  /* Data structures for PIO transmission, per 80211 core. */
 129.128 @@ -593,12 +632,14 @@ struct bcm43xx_coreinfo {
 129.129  	u8 available:1,
 129.130  	   enabled:1,
 129.131  	   initialized:1;
 129.132 -	/** core_id ID number */
 129.133 -	u16 id;
 129.134  	/** core_rev revision number */
 129.135  	u8 rev;
 129.136  	/** Index number for _switch_core() */
 129.137  	u8 index;
 129.138 +	/** core_id ID number */
 129.139 +	u16 id;
 129.140 +	/** Core-specific data. */
 129.141 +	void *priv;
 129.142  };
 129.143  
 129.144  /* Additional information for each 80211 core. */
 129.145 @@ -647,7 +688,23 @@ enum {
 129.146  	BCM43xx_STAT_RESTARTING,	/* controller_restart() called. */
 129.147  };
 129.148  #define bcm43xx_status(bcm)		atomic_read(&(bcm)->init_status)
 129.149 -#define bcm43xx_set_status(bcm, stat)	atomic_set(&(bcm)->init_status, (stat))
 129.150 +#define bcm43xx_set_status(bcm, stat)	do {			\
 129.151 +		atomic_set(&(bcm)->init_status, (stat));	\
 129.152 +		smp_wmb();					\
 129.153 +					} while (0)
 129.154 +
 129.155 +/*    *** THEORY OF LOCKING ***
 129.156 + *
 129.157 + * We have two different locks in the bcm43xx driver.
 129.158 + * => bcm->mutex:    General sleeping mutex. Protects struct bcm43xx_private
 129.159 + *                   and the device registers. This mutex does _not_ protect
 129.160 + *                   against concurrency from the IRQ handler.
 129.161 + * => bcm->irq_lock: IRQ spinlock. Protects against IRQ handler concurrency.
 129.162 + *
 129.163 + * Please note that, if you only take the irq_lock, you are not protected
 129.164 + * against concurrency from the periodic work handlers.
 129.165 + * Most times you want to take _both_ locks.
 129.166 + */
 129.167  
 129.168  struct bcm43xx_private {
 129.169  	struct ieee80211_device *ieee;
 129.170 @@ -659,7 +716,6 @@ struct bcm43xx_private {
 129.171  
 129.172  	void __iomem *mmio_addr;
 129.173  
 129.174 -	/* Locking, see "theory of locking" text below. */
 129.175  	spinlock_t irq_lock;
 129.176  	struct mutex mutex;
 129.177  
 129.178 @@ -691,6 +747,7 @@ struct bcm43xx_private {
 129.179  	struct bcm43xx_sprominfo sprom;
 129.180  #define BCM43xx_NR_LEDS		4
 129.181  	struct bcm43xx_led leds[BCM43xx_NR_LEDS];
 129.182 +	spinlock_t leds_lock;
 129.183  
 129.184  	/* The currently active core. */
 129.185  	struct bcm43xx_coreinfo *current_core;
 129.186 @@ -708,10 +765,6 @@ struct bcm43xx_private {
 129.187  	struct bcm43xx_coreinfo core_80211[ BCM43xx_MAX_80211_CORES ];
 129.188  	/* Additional information, specific to the 80211 cores. */
 129.189  	struct bcm43xx_coreinfo_80211 core_80211_ext[ BCM43xx_MAX_80211_CORES ];
 129.190 -	/* Index of the current 80211 core. If current_core is not
 129.191 -	 * an 80211 core, this is -1.
 129.192 -	 */
 129.193 -	int current_80211_core_idx;
 129.194  	/* Number of available 80211 cores. */
 129.195  	int nr_80211_available;
 129.196  
 129.197 @@ -719,11 +772,13 @@ struct bcm43xx_private {
 129.198  
 129.199  	/* Reason code of the last interrupt. */
 129.200  	u32 irq_reason;
 129.201 -	u32 dma_reason[4];
 129.202 +	u32 dma_reason[6];
 129.203  	/* saved irq enable/disable state bitfield. */
 129.204  	u32 irq_savedstate;
 129.205  	/* Link Quality calculation context. */
 129.206  	struct bcm43xx_noise_calculation noisecalc;
 129.207 +	/* if > 0 MAC is suspended. if == 0 MAC is enabled. */
 129.208 +	int mac_suspended;
 129.209  
 129.210  	/* Threshold values. */
 129.211  	//TODO: The RTS thr has to be _used_. Currently, it is only set via WX.
 129.212 @@ -746,12 +801,6 @@ struct bcm43xx_private {
 129.213  	struct bcm43xx_key key[54];
 129.214  	u8 default_key_idx;
 129.215  
 129.216 -	/* Firmware. */
 129.217 -	const struct firmware *ucode;
 129.218 -	const struct firmware *pcm;
 129.219 -	const struct firmware *initvals0;
 129.220 -	const struct firmware *initvals1;
 129.221 -
 129.222  	/* Random Number Generator. */
 129.223  	struct hwrng rng;
 129.224  	char rng_name[20 + 1];
 129.225 @@ -763,55 +812,6 @@ struct bcm43xx_private {
 129.226  };
 129.227  
 129.228  
 129.229 -/*    *** THEORY OF LOCKING ***
 129.230 - *
 129.231 - * We have two different locks in the bcm43xx driver.
 129.232 - * => bcm->mutex:    General sleeping mutex. Protects struct bcm43xx_private
 129.233 - *                   and the device registers.
 129.234 - * => bcm->irq_lock: IRQ spinlock. Protects against IRQ handler concurrency.
 129.235 - *
 129.236 - * We have three types of helper function pairs to utilize these locks.
 129.237 - *     (Always use the helper functions.)
 129.238 - * 1) bcm43xx_{un}lock_noirq():
 129.239 - *     Takes bcm->mutex. Does _not_ protect against IRQ concurrency,
 129.240 - *     so it is almost always unsafe, if device IRQs are enabled.
 129.241 - *     So only use this, if device IRQs are masked.
 129.242 - *     Locking may sleep.
 129.243 - *     You can sleep within the critical section.
 129.244 - * 2) bcm43xx_{un}lock_irqonly():
 129.245 - *     Takes bcm->irq_lock. Does _not_ protect against
 129.246 - *     bcm43xx_lock_noirq() critical sections.
 129.247 - *     Does only protect against the IRQ handler path and other
 129.248 - *     irqonly() critical sections.
 129.249 - *     Locking does not sleep.
 129.250 - *     You must not sleep within the critical section.
 129.251 - * 3) bcm43xx_{un}lock_irqsafe():
 129.252 - *     This is the cummulative lock and takes both, mutex and irq_lock.
 129.253 - *     Protects against noirq() and irqonly() critical sections (and
 129.254 - *     the IRQ handler path).
 129.255 - *     Locking may sleep.
 129.256 - *     You must not sleep within the critical section.
 129.257 - */
 129.258 -
 129.259 -/* Lock type 1 */
 129.260 -#define bcm43xx_lock_noirq(bcm)		mutex_lock(&(bcm)->mutex)
 129.261 -#define bcm43xx_unlock_noirq(bcm)	mutex_unlock(&(bcm)->mutex)
 129.262 -/* Lock type 2 */
 129.263 -#define bcm43xx_lock_irqonly(bcm, flags)	\
 129.264 -	spin_lock_irqsave(&(bcm)->irq_lock, flags)
 129.265 -#define bcm43xx_unlock_irqonly(bcm, flags)	\
 129.266 -	spin_unlock_irqrestore(&(bcm)->irq_lock, flags)
 129.267 -/* Lock type 3 */
 129.268 -#define bcm43xx_lock_irqsafe(bcm, flags) do {	\
 129.269 -	bcm43xx_lock_noirq(bcm);		\
 129.270 -	bcm43xx_lock_irqonly(bcm, flags);	\
 129.271 -		} while (0)
 129.272 -#define bcm43xx_unlock_irqsafe(bcm, flags) do {	\
 129.273 -	bcm43xx_unlock_irqonly(bcm, flags);	\
 129.274 -	bcm43xx_unlock_noirq(bcm);		\
 129.275 -		} while (0)
 129.276 -
 129.277 -
 129.278  static inline
 129.279  struct bcm43xx_private * bcm43xx_priv(struct net_device *dev)
 129.280  {
 129.281 @@ -863,34 +863,33 @@ int bcm43xx_using_pio(struct bcm43xx_pri
 129.282   * any of these functions.
 129.283   */
 129.284  static inline
 129.285 +struct bcm43xx_coreinfo_80211 *
 129.286 +bcm43xx_current_80211_priv(struct bcm43xx_private *bcm)
 129.287 +{
 129.288 +	assert(bcm->current_core->id == BCM43xx_COREID_80211);
 129.289 +	return bcm->current_core->priv;
 129.290 +}
 129.291 +static inline
 129.292  struct bcm43xx_pio * bcm43xx_current_pio(struct bcm43xx_private *bcm)
 129.293  {
 129.294  	assert(bcm43xx_using_pio(bcm));
 129.295 -	assert(bcm->current_80211_core_idx >= 0);
 129.296 -	assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);
 129.297 -	return &(bcm->core_80211_ext[bcm->current_80211_core_idx].pio);
 129.298 +	return &(bcm43xx_current_80211_priv(bcm)->pio);
 129.299  }
 129.300  static inline
 129.301  struct bcm43xx_dma * bcm43xx_current_dma(struct bcm43xx_private *bcm)
 129.302  {
 129.303  	assert(!bcm43xx_using_pio(bcm));
 129.304 -	assert(bcm->current_80211_core_idx >= 0);
 129.305 -	assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);
 129.306 -	return &(bcm->core_80211_ext[bcm->current_80211_core_idx].dma);
 129.307 +	return &(bcm43xx_current_80211_priv(bcm)->dma);
 129.308  }
 129.309  static inline
 129.310  struct bcm43xx_phyinfo * bcm43xx_current_phy(struct bcm43xx_private *bcm)
 129.311  {
 129.312 -	assert(bcm->current_80211_core_idx >= 0);
 129.313 -	assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);
 129.314 -	return &(bcm->core_80211_ext[bcm->current_80211_core_idx].phy);
 129.315 +	return &(bcm43xx_current_80211_priv(bcm)->phy);
 129.316  }
 129.317  static inline
 129.318  struct bcm43xx_radioinfo * bcm43xx_current_radio(struct bcm43xx_private *bcm)
 129.319  {
 129.320 -	assert(bcm->current_80211_core_idx >= 0);
 129.321 -	assert(bcm->current_80211_core_idx < BCM43xx_MAX_80211_CORES);
 129.322 -	return &(bcm->core_80211_ext[bcm->current_80211_core_idx].radio);
 129.323 +	return &(bcm43xx_current_80211_priv(bcm)->radio);
 129.324  }
 129.325  
 129.326  
   130.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c	Tue Oct 02 09:52:15 2007 +0100
   130.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c	Wed Oct 03 10:00:44 2007 +0100
   130.3 @@ -77,7 +77,8 @@ static ssize_t devinfo_read_file(struct 
   130.4  
   130.5  	down(&big_buffer_sem);
   130.6  
   130.7 -	bcm43xx_lock_irqsafe(bcm, flags);
   130.8 +	mutex_lock(&bcm->mutex);
   130.9 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  130.10  	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
  130.11  		fappend("Board not initialized.\n");
  130.12  		goto out;
  130.13 @@ -121,7 +122,8 @@ static ssize_t devinfo_read_file(struct 
  130.14  	fappend("\n");
  130.15  
  130.16  out:
  130.17 -	bcm43xx_unlock_irqsafe(bcm, flags);
  130.18 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  130.19 +	mutex_unlock(&bcm->mutex);
  130.20  	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
  130.21  	up(&big_buffer_sem);
  130.22  	return res;
  130.23 @@ -159,7 +161,8 @@ static ssize_t spromdump_read_file(struc
  130.24  	unsigned long flags;
  130.25  
  130.26  	down(&big_buffer_sem);
  130.27 -	bcm43xx_lock_irqsafe(bcm, flags);
  130.28 +	mutex_lock(&bcm->mutex);
  130.29 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  130.30  	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
  130.31  		fappend("Board not initialized.\n");
  130.32  		goto out;
  130.33 @@ -169,7 +172,8 @@ static ssize_t spromdump_read_file(struc
  130.34  	fappend("boardflags: 0x%04x\n", bcm->sprom.boardflags);
  130.35  
  130.36  out:
  130.37 -	bcm43xx_unlock_irqsafe(bcm, flags);
  130.38 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  130.39 +	mutex_unlock(&bcm->mutex);
  130.40  	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
  130.41  	up(&big_buffer_sem);
  130.42  	return res;
  130.43 @@ -188,7 +192,8 @@ static ssize_t tsf_read_file(struct file
  130.44  	u64 tsf;
  130.45  
  130.46  	down(&big_buffer_sem);
  130.47 -	bcm43xx_lock_irqsafe(bcm, flags);
  130.48 +	mutex_lock(&bcm->mutex);
  130.49 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  130.50  	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
  130.51  		fappend("Board not initialized.\n");
  130.52  		goto out;
  130.53 @@ -199,7 +204,8 @@ static ssize_t tsf_read_file(struct file
  130.54  		(unsigned int)(tsf & 0xFFFFFFFFULL));
  130.55  
  130.56  out:
  130.57 -	bcm43xx_unlock_irqsafe(bcm, flags);
  130.58 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  130.59 +	mutex_unlock(&bcm->mutex);
  130.60  	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
  130.61  	up(&big_buffer_sem);
  130.62  	return res;
  130.63 @@ -221,7 +227,8 @@ static ssize_t tsf_write_file(struct fil
  130.64  	        res = -EFAULT;
  130.65  		goto out_up;
  130.66  	}
  130.67 -	bcm43xx_lock_irqsafe(bcm, flags);
  130.68 +	mutex_lock(&bcm->mutex);
  130.69 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  130.70  	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
  130.71  		printk(KERN_INFO PFX "debugfs: Board not initialized.\n");
  130.72  		res = -EFAULT;
  130.73 @@ -237,7 +244,8 @@ static ssize_t tsf_write_file(struct fil
  130.74  	res = buf_size;
  130.75  	
  130.76  out_unlock:
  130.77 -	bcm43xx_unlock_irqsafe(bcm, flags);
  130.78 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  130.79 +	mutex_unlock(&bcm->mutex);
  130.80  out_up:
  130.81  	up(&big_buffer_sem);
  130.82  	return res;
  130.83 @@ -258,7 +266,8 @@ static ssize_t txstat_read_file(struct f
  130.84  	int i, cnt, j = 0;
  130.85  
  130.86  	down(&big_buffer_sem);
  130.87 -	bcm43xx_lock_irqsafe(bcm, flags);
  130.88 +	mutex_lock(&bcm->mutex);
  130.89 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  130.90  
  130.91  	fappend("Last %d logged xmitstatus blobs (Latest first):\n\n",
  130.92  		BCM43xx_NR_LOGGED_XMITSTATUS);
  130.93 @@ -294,14 +303,51 @@ static ssize_t txstat_read_file(struct f
  130.94  			i = BCM43xx_NR_LOGGED_XMITSTATUS - 1;
  130.95  	}
  130.96  
  130.97 -	bcm43xx_unlock_irqsafe(bcm, flags);
  130.98 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  130.99  	res = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
 130.100 -	bcm43xx_lock_irqsafe(bcm, flags);
 130.101 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 130.102  	if (*ppos == pos) {
 130.103  		/* Done. Drop the copied data. */
 130.104  		e->xmitstatus_printing = 0;
 130.105  	}
 130.106 -	bcm43xx_unlock_irqsafe(bcm, flags);
 130.107 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 130.108 +	mutex_unlock(&bcm->mutex);
 130.109 +	up(&big_buffer_sem);
 130.110 +	return res;
 130.111 +}
 130.112 +
 130.113 +static ssize_t restart_write_file(struct file *file, const char __user *user_buf,
 130.114 +				  size_t count, loff_t *ppos)
 130.115 +{
 130.116 +	struct bcm43xx_private *bcm = file->private_data;
 130.117 +	char *buf = really_big_buffer;
 130.118 +	ssize_t buf_size;
 130.119 +	ssize_t res;
 130.120 +	unsigned long flags;
 130.121 +
 130.122 +	buf_size = min(count, sizeof (really_big_buffer) - 1);
 130.123 +	down(&big_buffer_sem);
 130.124 +	if (copy_from_user(buf, user_buf, buf_size)) {
 130.125 +	        res = -EFAULT;
 130.126 +		goto out_up;
 130.127 +	}
 130.128 +	mutex_lock(&(bcm)->mutex);
 130.129 +	spin_lock_irqsave(&(bcm)->irq_lock, flags);
 130.130 +	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED) {
 130.131 +		printk(KERN_INFO PFX "debugfs: Board not initialized.\n");
 130.132 +		res = -EFAULT;
 130.133 +		goto out_unlock;
 130.134 +	}
 130.135 +	if (count > 0 && buf[0] == '1') {
 130.136 +		bcm43xx_controller_restart(bcm, "manually restarted");
 130.137 +		res = count;
 130.138 +	} else
 130.139 +		res = -EINVAL;
 130.140 +
 130.141 +out_unlock:
 130.142 +	spin_unlock_irqrestore(&(bcm)->irq_lock, flags);
 130.143 +	mutex_unlock(&(bcm)->mutex);
 130.144 +out_up:
 130.145  	up(&big_buffer_sem);
 130.146  	return res;
 130.147  }
 130.148 @@ -339,6 +385,11 @@ static struct file_operations txstat_fop
 130.149  	.open = open_file_generic,
 130.150  };
 130.151  
 130.152 +static struct file_operations restart_fops = {
 130.153 +	.write = restart_write_file,
 130.154 +	.open = open_file_generic,
 130.155 +};
 130.156 +
 130.157  
 130.158  void bcm43xx_debugfs_add_device(struct bcm43xx_private *bcm)
 130.159  {
 130.160 @@ -390,6 +441,10 @@ void bcm43xx_debugfs_add_device(struct b
 130.161  						bcm, &txstat_fops);
 130.162  	if (!e->dentry_txstat)
 130.163  		printk(KERN_ERR PFX "debugfs: creating \"tx_status\" for \"%s\" failed!\n", devdir);
 130.164 +	e->dentry_restart = debugfs_create_file("restart", 0222, e->subdir,
 130.165 +						bcm, &restart_fops);
 130.166 +	if (!e->dentry_restart)
 130.167 +		printk(KERN_ERR PFX "debugfs: creating \"restart\" for \"%s\" failed!\n", devdir);
 130.168  }
 130.169  
 130.170  void bcm43xx_debugfs_remove_device(struct bcm43xx_private *bcm)
 130.171 @@ -405,6 +460,7 @@ void bcm43xx_debugfs_remove_device(struc
 130.172  	debugfs_remove(e->dentry_devinfo);
 130.173  	debugfs_remove(e->dentry_tsf);
 130.174  	debugfs_remove(e->dentry_txstat);
 130.175 +	debugfs_remove(e->dentry_restart);
 130.176  	debugfs_remove(e->subdir);
 130.177  	kfree(e->xmitstatus_buffer);
 130.178  	kfree(e->xmitstatus_print_buffer);
   131.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.h	Tue Oct 02 09:52:15 2007 +0100
   131.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.h	Wed Oct 03 10:00:44 2007 +0100
   131.3 @@ -20,6 +20,7 @@ struct bcm43xx_dfsentry {
   131.4  	struct dentry *dentry_spromdump;
   131.5  	struct dentry *dentry_tsf;
   131.6  	struct dentry *dentry_txstat;
   131.7 +	struct dentry *dentry_restart;
   131.8  
   131.9  	struct bcm43xx_private *bcm;
  131.10  
   132.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c	Tue Oct 02 09:52:15 2007 +0100
   132.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c	Wed Oct 03 10:00:44 2007 +0100
   132.3 @@ -4,7 +4,7 @@
   132.4  
   132.5    DMA ringbuffer and descriptor allocation/management
   132.6  
   132.7 -  Copyright (c) 2005 Michael Buesch <mbuesch@freenet.de>
   132.8 +  Copyright (c) 2005, 2006 Michael Buesch <mbuesch@freenet.de>
   132.9  
  132.10    Some code in this file is derived from the b44.c driver
  132.11    Copyright (C) 2002 David S. Miller
  132.12 @@ -109,6 +109,35 @@ void return_slot(struct bcm43xx_dmaring 
  132.13  	}
  132.14  }
  132.15  
  132.16 +u16 bcm43xx_dmacontroller_base(int dma64bit, int controller_idx)
  132.17 +{
  132.18 +	static const u16 map64[] = {
  132.19 +		BCM43xx_MMIO_DMA64_BASE0,
  132.20 +		BCM43xx_MMIO_DMA64_BASE1,
  132.21 +		BCM43xx_MMIO_DMA64_BASE2,
  132.22 +		BCM43xx_MMIO_DMA64_BASE3,
  132.23 +		BCM43xx_MMIO_DMA64_BASE4,
  132.24 +		BCM43xx_MMIO_DMA64_BASE5,
  132.25 +	};
  132.26 +	static const u16 map32[] = {
  132.27 +		BCM43xx_MMIO_DMA32_BASE0,
  132.28 +		BCM43xx_MMIO_DMA32_BASE1,
  132.29 +		BCM43xx_MMIO_DMA32_BASE2,
  132.30 +		BCM43xx_MMIO_DMA32_BASE3,
  132.31 +		BCM43xx_MMIO_DMA32_BASE4,
  132.32 +		BCM43xx_MMIO_DMA32_BASE5,
  132.33 +	};
  132.34 +
  132.35 +	if (dma64bit) {
  132.36 +		assert(controller_idx >= 0 &&
  132.37 +		       controller_idx < ARRAY_SIZE(map64));
  132.38 +		return map64[controller_idx];
  132.39 +	}
  132.40 +	assert(controller_idx >= 0 &&
  132.41 +	       controller_idx < ARRAY_SIZE(map32));
  132.42 +	return map32[controller_idx];
  132.43 +}
  132.44 +
  132.45  static inline
  132.46  dma_addr_t map_descbuffer(struct bcm43xx_dmaring *ring,
  132.47  			  unsigned char *buf,
  132.48 @@ -172,7 +201,6 @@ void sync_descbuffer_for_device(struct b
  132.49  /* Unmap and free a descriptor buffer. */
  132.50  static inline
  132.51  void free_descriptor_buffer(struct bcm43xx_dmaring *ring,
  132.52 -			    struct bcm43xx_dmadesc *desc,
  132.53  			    struct bcm43xx_dmadesc_meta *meta,
  132.54  			    int irq_context)
  132.55  {
  132.56 @@ -188,23 +216,13 @@ static int alloc_ringmemory(struct bcm43
  132.57  {
  132.58  	struct device *dev = &(ring->bcm->pci_dev->dev);
  132.59  
  132.60 -	ring->vbase = dma_alloc_coherent(dev, BCM43xx_DMA_RINGMEMSIZE,
  132.61 -					 &(ring->dmabase), GFP_KERNEL);
  132.62 -	if (!ring->vbase) {
  132.63 +	ring->descbase = dma_alloc_coherent(dev, BCM43xx_DMA_RINGMEMSIZE,
  132.64 +					    &(ring->dmabase), GFP_KERNEL);
  132.65 +	if (!ring->descbase) {
  132.66  		printk(KERN_ERR PFX "DMA ringmemory allocation failed\n");
  132.67  		return -ENOMEM;
  132.68  	}
  132.69 -	if (ring->dmabase + BCM43xx_DMA_RINGMEMSIZE > BCM43xx_DMA_BUSADDRMAX) {
  132.70 -		printk(KERN_ERR PFX ">>>FATAL ERROR<<<  DMA RINGMEMORY >1G "
  132.71 -				    "(0x%llx, len: %lu)\n",
  132.72 -				(unsigned long long)ring->dmabase,
  132.73 -				BCM43xx_DMA_RINGMEMSIZE);
  132.74 -		dma_free_coherent(dev, BCM43xx_DMA_RINGMEMSIZE,
  132.75 -				  ring->vbase, ring->dmabase);
  132.76 -		return -ENOMEM;
  132.77 -	}
  132.78 -	assert(!(ring->dmabase & 0x000003FF));
  132.79 -	memset(ring->vbase, 0, BCM43xx_DMA_RINGMEMSIZE);
  132.80 +	memset(ring->descbase, 0, BCM43xx_DMA_RINGMEMSIZE);
  132.81  
  132.82  	return 0;
  132.83  }
  132.84 @@ -214,26 +232,34 @@ static void free_ringmemory(struct bcm43
  132.85  	struct device *dev = &(ring->bcm->pci_dev->dev);
  132.86  
  132.87  	dma_free_coherent(dev, BCM43xx_DMA_RINGMEMSIZE,
  132.88 -			  ring->vbase, ring->dmabase);
  132.89 +			  ring->descbase, ring->dmabase);
  132.90  }
  132.91  
  132.92  /* Reset the RX DMA channel */
  132.93  int bcm43xx_dmacontroller_rx_reset(struct bcm43xx_private *bcm,
  132.94 -				   u16 mmio_base)
  132.95 +				   u16 mmio_base, int dma64)
  132.96  {
  132.97  	int i;
  132.98  	u32 value;
  132.99 +	u16 offset;
 132.100  
 132.101 -	bcm43xx_write32(bcm,
 132.102 -			mmio_base + BCM43xx_DMA_RX_CONTROL,
 132.103 -			0x00000000);
 132.104 +	offset = dma64 ? BCM43xx_DMA64_RXCTL : BCM43xx_DMA32_RXCTL;
 132.105 +	bcm43xx_write32(bcm, mmio_base + offset, 0);
 132.106  	for (i = 0; i < 1000; i++) {
 132.107 -		value = bcm43xx_read32(bcm,
 132.108 -				       mmio_base + BCM43xx_DMA_RX_STATUS);
 132.109 -		value &= BCM43xx_DMA_RXSTAT_STAT_MASK;
 132.110 -		if (value == BCM43xx_DMA_RXSTAT_STAT_DISABLED) {
 132.111 -			i = -1;
 132.112 -			break;
 132.113 +		offset = dma64 ? BCM43xx_DMA64_RXSTATUS : BCM43xx_DMA32_RXSTATUS;
 132.114 +		value = bcm43xx_read32(bcm, mmio_base + offset);
 132.115 +		if (dma64) {
 132.116 +			value &= BCM43xx_DMA64_RXSTAT;
 132.117 +			if (value == BCM43xx_DMA64_RXSTAT_DISABLED) {
 132.118 +				i = -1;
 132.119 +				break;
 132.120 +			}
 132.121 +		} else {
 132.122 +			value &= BCM43xx_DMA32_RXSTATE;
 132.123 +			if (value == BCM43xx_DMA32_RXSTAT_DISABLED) {
 132.124 +				i = -1;
 132.125 +				break;
 132.126 +			}
 132.127  		}
 132.128  		udelay(10);
 132.129  	}
 132.130 @@ -247,31 +273,47 @@ int bcm43xx_dmacontroller_rx_reset(struc
 132.131  
 132.132  /* Reset the RX DMA channel */
 132.133  int bcm43xx_dmacontroller_tx_reset(struct bcm43xx_private *bcm,
 132.134 -				   u16 mmio_base)
 132.135 +				   u16 mmio_base, int dma64)
 132.136  {
 132.137  	int i;
 132.138  	u32 value;
 132.139 +	u16 offset;
 132.140  
 132.141  	for (i = 0; i < 1000; i++) {
 132.142 -		value = bcm43xx_read32(bcm,
 132.143 -				       mmio_base + BCM43xx_DMA_TX_STATUS);
 132.144 -		value &= BCM43xx_DMA_TXSTAT_STAT_MASK;
 132.145 -		if (value == BCM43xx_DMA_TXSTAT_STAT_DISABLED ||
 132.146 -		    value == BCM43xx_DMA_TXSTAT_STAT_IDLEWAIT ||
 132.147 -		    value == BCM43xx_DMA_TXSTAT_STAT_STOPPED)
 132.148 -			break;
 132.149 +		offset = dma64 ? BCM43xx_DMA64_TXSTATUS : BCM43xx_DMA32_TXSTATUS;
 132.150 +		value = bcm43xx_read32(bcm, mmio_base + offset);
 132.151 +		if (dma64) {
 132.152 +			value &= BCM43xx_DMA64_TXSTAT;
 132.153 +			if (value == BCM43xx_DMA64_TXSTAT_DISABLED ||
 132.154 +			    value == BCM43xx_DMA64_TXSTAT_IDLEWAIT ||
 132.155 +			    value == BCM43xx_DMA64_TXSTAT_STOPPED)
 132.156 +				break;
 132.157 +		} else {
 132.158 +			value &= BCM43xx_DMA32_TXSTATE;
 132.159 +			if (value == BCM43xx_DMA32_TXSTAT_DISABLED ||
 132.160 +			    value == BCM43xx_DMA32_TXSTAT_IDLEWAIT ||
 132.161 +			    value == BCM43xx_DMA32_TXSTAT_STOPPED)
 132.162 +				break;
 132.163 +		}
 132.164  		udelay(10);
 132.165  	}
 132.166 -	bcm43xx_write32(bcm,
 132.167 -			mmio_base + BCM43xx_DMA_TX_CONTROL,
 132.168 -			0x00000000);
 132.169 +	offset = dma64 ? BCM43xx_DMA64_TXCTL : BCM43xx_DMA32_TXCTL;
 132.170 +	bcm43xx_write32(bcm, mmio_base + offset, 0);
 132.171  	for (i = 0; i < 1000; i++) {
 132.172 -		value = bcm43xx_read32(bcm,
 132.173 -				       mmio_base + BCM43xx_DMA_TX_STATUS);
 132.174 -		value &= BCM43xx_DMA_TXSTAT_STAT_MASK;
 132.175 -		if (value == BCM43xx_DMA_TXSTAT_STAT_DISABLED) {
 132.176 -			i = -1;
 132.177 -			break;
 132.178 +		offset = dma64 ? BCM43xx_DMA64_TXSTATUS : BCM43xx_DMA32_TXSTATUS;
 132.179 +		value = bcm43xx_read32(bcm, mmio_base + offset);
 132.180 +		if (dma64) {
 132.181 +			value &= BCM43xx_DMA64_TXSTAT;
 132.182 +			if (value == BCM43xx_DMA64_TXSTAT_DISABLED) {
 132.183 +				i = -1;
 132.184 +				break;
 132.185 +			}
 132.186 +		} else {
 132.187 +			value &= BCM43xx_DMA32_TXSTATE;
 132.188 +			if (value == BCM43xx_DMA32_TXSTAT_DISABLED) {
 132.189 +				i = -1;
 132.190 +				break;
 132.191 +			}
 132.192  		}
 132.193  		udelay(10);
 132.194  	}
 132.195 @@ -285,47 +327,98 @@ int bcm43xx_dmacontroller_tx_reset(struc
 132.196  	return 0;
 132.197  }
 132.198  
 132.199 +static void fill_descriptor(struct bcm43xx_dmaring *ring,
 132.200 +			    struct bcm43xx_dmadesc_generic *desc,
 132.201 +			    dma_addr_t dmaaddr,
 132.202 +			    u16 bufsize,
 132.203 +			    int start, int end, int irq)
 132.204 +{
 132.205 +	int slot;
 132.206 +
 132.207 +	slot = bcm43xx_dma_desc2idx(ring, desc);
 132.208 +	assert(slot >= 0 && slot < ring->nr_slots);
 132.209 +
 132.210 +	if (ring->dma64) {
 132.211 +		u32 ctl0 = 0, ctl1 = 0;
 132.212 +		u32 addrlo, addrhi;
 132.213 +		u32 addrext;
 132.214 +
 132.215 +		addrlo = (u32)(dmaaddr & 0xFFFFFFFF);
 132.216 +		addrhi = (((u64)dmaaddr >> 32) & ~BCM43xx_DMA64_ROUTING);
 132.217 +		addrext = (((u64)dmaaddr >> 32) >> BCM43xx_DMA64_ROUTING_SHIFT);
 132.218 +		addrhi |= ring->routing;
 132.219 +		if (slot == ring->nr_slots - 1)
 132.220 +			ctl0 |= BCM43xx_DMA64_DCTL0_DTABLEEND;
 132.221 +		if (start)
 132.222 +			ctl0 |= BCM43xx_DMA64_DCTL0_FRAMESTART;
 132.223 +		if (end)
 132.224 +			ctl0 |= BCM43xx_DMA64_DCTL0_FRAMEEND;
 132.225 +		if (irq)
 132.226 +			ctl0 |= BCM43xx_DMA64_DCTL0_IRQ;
 132.227 +		ctl1 |= (bufsize - ring->frameoffset)
 132.228 +			& BCM43xx_DMA64_DCTL1_BYTECNT;
 132.229 +		ctl1 |= (addrext << BCM43xx_DMA64_DCTL1_ADDREXT_SHIFT)
 132.230 +			& BCM43xx_DMA64_DCTL1_ADDREXT_MASK;
 132.231 +
 132.232 +		desc->dma64.control0 = cpu_to_le32(ctl0);
 132.233 +		desc->dma64.control1 = cpu_to_le32(ctl1);
 132.234 +		desc->dma64.address_low = cpu_to_le32(addrlo);
 132.235 +		desc->dma64.address_high = cpu_to_le32(addrhi);
 132.236 +	} else {
 132.237 +		u32 ctl;
 132.238 +		u32 addr;
 132.239 +		u32 addrext;
 132.240 +
 132.241 +		addr = (u32)(dmaaddr & ~BCM43xx_DMA32_ROUTING);
 132.242 +		addrext = (u32)(dmaaddr & BCM43xx_DMA32_ROUTING)
 132.243 +			   >> BCM43xx_DMA32_ROUTING_SHIFT;
 132.244 +		addr |= ring->routing;
 132.245 +		ctl = (bufsize - ring->frameoffset)
 132.246 +		      & BCM43xx_DMA32_DCTL_BYTECNT;
 132.247 +		if (slot == ring->nr_slots - 1)
 132.248 +			ctl |= BCM43xx_DMA32_DCTL_DTABLEEND;
 132.249 +		if (start)
 132.250 +			ctl |= BCM43xx_DMA32_DCTL_FRAMESTART;
 132.251 +		if (end)
 132.252 +			ctl |= BCM43xx_DMA32_DCTL_FRAMEEND;
 132.253 +		if (irq)
 132.254 +			ctl |= BCM43xx_DMA32_DCTL_IRQ;
 132.255 +		ctl |= (addrext << BCM43xx_DMA32_DCTL_ADDREXT_SHIFT)
 132.256 +		       & BCM43xx_DMA32_DCTL_ADDREXT_MASK;
 132.257 +
 132.258 +		desc->dma32.control = cpu_to_le32(ctl);
 132.259 +		desc->dma32.address = cpu_to_le32(addr);
 132.260 +	}
 132.261 +}
 132.262 +
 132.263  static int setup_rx_descbuffer(struct bcm43xx_dmaring *ring,
 132.264 -			       struct bcm43xx_dmadesc *desc,
 132.265 +			       struct bcm43xx_dmadesc_generic *desc,
 132.266  			       struct bcm43xx_dmadesc_meta *meta,
 132.267  			       gfp_t gfp_flags)
 132.268  {
 132.269  	struct bcm43xx_rxhdr *rxhdr;
 132.270 +	struct bcm43xx_hwxmitstatus *xmitstat;
 132.271  	dma_addr_t dmaaddr;
 132.272 -	u32 desc_addr;
 132.273 -	u32 desc_ctl;
 132.274 -	const int slot = (int)(desc - ring->vbase);
 132.275  	struct sk_buff *skb;
 132.276  
 132.277 -	assert(slot >= 0 && slot < ring->nr_slots);
 132.278  	assert(!ring->tx);
 132.279  
 132.280  	skb = __dev_alloc_skb(ring->rx_buffersize, gfp_flags);
 132.281  	if (unlikely(!skb))
 132.282  		return -ENOMEM;
 132.283  	dmaaddr = map_descbuffer(ring, skb->data, ring->rx_buffersize, 0);
 132.284 -	if (unlikely(dmaaddr + ring->rx_buffersize > BCM43xx_DMA_BUSADDRMAX)) {
 132.285 -		unmap_descbuffer(ring, dmaaddr, ring->rx_buffersize, 0);
 132.286 -		dev_kfree_skb_any(skb);
 132.287 -		printk(KERN_ERR PFX ">>>FATAL ERROR<<<  DMA RX SKB >1G "
 132.288 -				    "(0x%llx, len: %u)\n",
 132.289 -			(unsigned long long)dmaaddr, ring->rx_buffersize);
 132.290 -		return -ENOMEM;
 132.291 -	}
 132.292  	meta->skb = skb;
 132.293  	meta->dmaaddr = dmaaddr;
 132.294  	skb->dev = ring->bcm->net_dev;
 132.295 -	desc_addr = (u32)(dmaaddr + ring->memoffset);
 132.296 -	desc_ctl = (BCM43xx_DMADTOR_BYTECNT_MASK &
 132.297 -		    (u32)(ring->rx_buffersize - ring->frameoffset));
 132.298 -	if (slot == ring->nr_slots - 1)
 132.299 -		desc_ctl |= BCM43xx_DMADTOR_DTABLEEND;
 132.300 -	set_desc_addr(desc, desc_addr);
 132.301 -	set_desc_ctl(desc, desc_ctl);
 132.302 +
 132.303 +	fill_descriptor(ring, desc, dmaaddr,
 132.304 +			ring->rx_buffersize, 0, 0, 0);
 132.305  
 132.306  	rxhdr = (struct bcm43xx_rxhdr *)(skb->data);
 132.307  	rxhdr->frame_length = 0;
 132.308  	rxhdr->flags1 = 0;
 132.309 +	xmitstat = (struct bcm43xx_hwxmitstatus *)(skb->data);
 132.310 +	xmitstat->cookie = 0;
 132.311  
 132.312  	return 0;
 132.313  }
 132.314 @@ -336,17 +429,17 @@ static int setup_rx_descbuffer(struct bc
 132.315  static int alloc_initial_descbuffers(struct bcm43xx_dmaring *ring)
 132.316  {
 132.317  	int i, err = -ENOMEM;
 132.318 -	struct bcm43xx_dmadesc *desc;
 132.319 +	struct bcm43xx_dmadesc_generic *desc;
 132.320  	struct bcm43xx_dmadesc_meta *meta;
 132.321  
 132.322  	for (i = 0; i < ring->nr_slots; i++) {
 132.323 -		desc = ring->vbase + i;
 132.324 -		meta = ring->meta + i;
 132.325 +		desc = bcm43xx_dma_idx2desc(ring, i, &meta);
 132.326  
 132.327  		err = setup_rx_descbuffer(ring, desc, meta, GFP_KERNEL);
 132.328  		if (err)
 132.329  			goto err_unwind;
 132.330  	}
 132.331 +	mb();
 132.332  	ring->used_slots = ring->nr_slots;
 132.333  	err = 0;
 132.334  out:
 132.335 @@ -354,8 +447,7 @@ out:
 132.336  
 132.337  err_unwind:
 132.338  	for (i--; i >= 0; i--) {
 132.339 -		desc = ring->vbase + i;
 132.340 -		meta = ring->meta + i;
 132.341 +		desc = bcm43xx_dma_idx2desc(ring, i, &meta);
 132.342  
 132.343  		unmap_descbuffer(ring, meta->dmaaddr, ring->rx_buffersize, 0);
 132.344  		dev_kfree_skb(meta->skb);
 132.345 @@ -371,27 +463,67 @@ static int dmacontroller_setup(struct bc
 132.346  {
 132.347  	int err = 0;
 132.348  	u32 value;
 132.349 +	u32 addrext;
 132.350  
 132.351  	if (ring->tx) {
 132.352 -		/* Set Transmit Control register to "transmit enable" */
 132.353 -		bcm43xx_dma_write(ring, BCM43xx_DMA_TX_CONTROL,
 132.354 -				  BCM43xx_DMA_TXCTRL_ENABLE);
 132.355 -		/* Set Transmit Descriptor ring address. */
 132.356 -		bcm43xx_dma_write(ring, BCM43xx_DMA_TX_DESC_RING,
 132.357 -				  ring->dmabase + ring->memoffset);
 132.358 +		if (ring->dma64) {
 132.359 +			u64 ringbase = (u64)(ring->dmabase);
 132.360 +
 132.361 +			addrext = ((ringbase >> 32) >> BCM43xx_DMA64_ROUTING_SHIFT);
 132.362 +			value = BCM43xx_DMA64_TXENABLE;
 132.363 +			value |= (addrext << BCM43xx_DMA64_TXADDREXT_SHIFT)
 132.364 +				& BCM43xx_DMA64_TXADDREXT_MASK;
 132.365 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_TXCTL, value);
 132.366 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_TXRINGLO,
 132.367 +					(ringbase & 0xFFFFFFFF));
 132.368 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_TXRINGHI,
 132.369 +					((ringbase >> 32) & ~BCM43xx_DMA64_ROUTING)
 132.370 +					| ring->routing);
 132.371 +		} else {
 132.372 +			u32 ringbase = (u32)(ring->dmabase);
 132.373 +
 132.374 +			addrext = (ringbase >> BCM43xx_DMA32_ROUTING_SHIFT);
 132.375 +			value = BCM43xx_DMA32_TXENABLE;
 132.376 +			value |= (addrext << BCM43xx_DMA32_TXADDREXT_SHIFT)
 132.377 +				& BCM43xx_DMA32_TXADDREXT_MASK;
 132.378 +			bcm43xx_dma_write(ring, BCM43xx_DMA32_TXCTL, value);
 132.379 +			bcm43xx_dma_write(ring, BCM43xx_DMA32_TXRING,
 132.380 +					(ringbase & ~BCM43xx_DMA32_ROUTING)
 132.381 +					| ring->routing);
 132.382 +		}
 132.383  	} else {
 132.384  		err = alloc_initial_descbuffers(ring);
 132.385  		if (err)
 132.386  			goto out;
 132.387 -		/* Set Receive Control "receive enable" and frame offset */
 132.388 -		value = (ring->frameoffset << BCM43xx_DMA_RXCTRL_FRAMEOFF_SHIFT);
 132.389 -		value |= BCM43xx_DMA_RXCTRL_ENABLE;
 132.390 -		bcm43xx_dma_write(ring, BCM43xx_DMA_RX_CONTROL, value);
 132.391 -		/* Set Receive Descriptor ring address. */
 132.392 -		bcm43xx_dma_write(ring, BCM43xx_DMA_RX_DESC_RING,
 132.393 -				  ring->dmabase + ring->memoffset);
 132.394 -		/* Init the descriptor pointer. */
 132.395 -		bcm43xx_dma_write(ring, BCM43xx_DMA_RX_DESC_INDEX, 200);
 132.396 +		if (ring->dma64) {
 132.397 +			u64 ringbase = (u64)(ring->dmabase);
 132.398 +
 132.399 +			addrext = ((ringbase >> 32) >> BCM43xx_DMA64_ROUTING_SHIFT);
 132.400 +			value = (ring->frameoffset << BCM43xx_DMA64_RXFROFF_SHIFT);
 132.401 +			value |= BCM43xx_DMA64_RXENABLE;
 132.402 +			value |= (addrext << BCM43xx_DMA64_RXADDREXT_SHIFT)
 132.403 +				& BCM43xx_DMA64_RXADDREXT_MASK;
 132.404 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_RXCTL, value);
 132.405 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_RXRINGLO,
 132.406 +					(ringbase & 0xFFFFFFFF));
 132.407 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_RXRINGHI,
 132.408 +					((ringbase >> 32) & ~BCM43xx_DMA64_ROUTING)
 132.409 +					| ring->routing);
 132.410 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_RXINDEX, 200);
 132.411 +		} else {
 132.412 +			u32 ringbase = (u32)(ring->dmabase);
 132.413 +
 132.414 +			addrext = (ringbase >> BCM43xx_DMA32_ROUTING_SHIFT);
 132.415 +			value = (ring->frameoffset << BCM43xx_DMA32_RXFROFF_SHIFT);
 132.416 +			value |= BCM43xx_DMA32_RXENABLE;
 132.417 +			value |= (addrext << BCM43xx_DMA32_RXADDREXT_SHIFT)
 132.418 +				& BCM43xx_DMA32_RXADDREXT_MASK;
 132.419 +			bcm43xx_dma_write(ring, BCM43xx_DMA32_RXCTL, value);
 132.420 +			bcm43xx_dma_write(ring, BCM43xx_DMA32_RXRING,
 132.421 +					(ringbase & ~BCM43xx_DMA32_ROUTING)
 132.422 +					| ring->routing);
 132.423 +			bcm43xx_dma_write(ring, BCM43xx_DMA32_RXINDEX, 200);
 132.424 +		}
 132.425  	}
 132.426  
 132.427  out:
 132.428 @@ -402,27 +534,32 @@ out:
 132.429  static void dmacontroller_cleanup(struct bcm43xx_dmaring *ring)
 132.430  {
 132.431  	if (ring->tx) {
 132.432 -		bcm43xx_dmacontroller_tx_reset(ring->bcm, ring->mmio_base);
 132.433 -		/* Zero out Transmit Descriptor ring address. */
 132.434 -		bcm43xx_dma_write(ring, BCM43xx_DMA_TX_DESC_RING, 0);
 132.435 +		bcm43xx_dmacontroller_tx_reset(ring->bcm, ring->mmio_base, ring->dma64);
 132.436 +		if (ring->dma64) {
 132.437 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_TXRINGLO, 0);
 132.438 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_TXRINGHI, 0);
 132.439 +		} else
 132.440 +			bcm43xx_dma_write(ring, BCM43xx_DMA32_TXRING, 0);
 132.441  	} else {
 132.442 -		bcm43xx_dmacontroller_rx_reset(ring->bcm, ring->mmio_base);
 132.443 -		/* Zero out Receive Descriptor ring address. */
 132.444 -		bcm43xx_dma_write(ring, BCM43xx_DMA_RX_DESC_RING, 0);
 132.445 +		bcm43xx_dmacontroller_rx_reset(ring->bcm, ring->mmio_base, ring->dma64);
 132.446 +		if (ring->dma64) {
 132.447 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_RXRINGLO, 0);
 132.448 +			bcm43xx_dma_write(ring, BCM43xx_DMA64_RXRINGHI, 0);
 132.449 +		} else
 132.450 +			bcm43xx_dma_write(ring, BCM43xx_DMA32_RXRING, 0);
 132.451  	}
 132.452  }
 132.453  
 132.454  static void free_all_descbuffers(struct bcm43xx_dmaring *ring)
 132.455  {
 132.456 -	struct bcm43xx_dmadesc *desc;
 132.457 +	struct bcm43xx_dmadesc_generic *desc;
 132.458  	struct bcm43xx_dmadesc_meta *meta;
 132.459  	int i;
 132.460  
 132.461  	if (!ring->used_slots)
 132.462  		return;
 132.463  	for (i = 0; i < ring->nr_slots; i++) {
 132.464 -		desc = ring->vbase + i;
 132.465 -		meta = ring->meta + i;
 132.466 +		desc = bcm43xx_dma_idx2desc(ring, i, &meta);
 132.467  
 132.468  		if (!meta->skb) {
 132.469  			assert(ring->tx);
 132.470 @@ -430,62 +567,67 @@ static void free_all_descbuffers(struct 
 132.471  		}
 132.472  		if (ring->tx) {
 132.473  			unmap_descbuffer(ring, meta->dmaaddr,
 132.474 -					 meta->skb->len, 1);
 132.475 +					meta->skb->len, 1);
 132.476  		} else {
 132.477  			unmap_descbuffer(ring, meta->dmaaddr,
 132.478 -					 ring->rx_buffersize, 0);
 132.479 +					ring->rx_buffersize, 0);
 132.480  		}
 132.481 -		free_descriptor_buffer(ring, desc, meta, 0);
 132.482 +		free_descriptor_buffer(ring, meta, 0);
 132.483  	}
 132.484  }
 132.485  
 132.486  /* Main initialization function. */
 132.487  static
 132.488  struct bcm43xx_dmaring * bcm43xx_setup_dmaring(struct bcm43xx_private *bcm,
 132.489 -					       u16 dma_controller_base,
 132.490 -					       int nr_descriptor_slots,
 132.491 -					       int tx)
 132.492 +					       int controller_index,
 132.493 +					       int for_tx,
 132.494 +					       int dma64)
 132.495  {
 132.496  	struct bcm43xx_dmaring *ring;
 132.497  	int err;
 132.498 +	int nr_slots;
 132.499  
 132.500  	ring = kzalloc(sizeof(*ring), GFP_KERNEL);
 132.501  	if (!ring)
 132.502  		goto out;
 132.503  
 132.504 -	ring->meta = kzalloc(sizeof(*ring->meta) * nr_descriptor_slots,
 132.505 +	nr_slots = BCM43xx_RXRING_SLOTS;
 132.506 +	if (for_tx)
 132.507 +		nr_slots = BCM43xx_TXRING_SLOTS;
 132.508 +
 132.509 +	ring->meta = kcalloc(nr_slots, sizeof(struct bcm43xx_dmadesc_meta),
 132.510  			     GFP_KERNEL);
 132.511  	if (!ring->meta)
 132.512  		goto err_kfree_ring;
 132.513  
 132.514 -	ring->memoffset = BCM43xx_DMA_DMABUSADDROFFSET;
 132.515 +	ring->routing = BCM43xx_DMA32_CLIENTTRANS;
 132.516 +	if (dma64)
 132.517 +		ring->routing = BCM43xx_DMA64_CLIENTTRANS;
 132.518  #ifdef CONFIG_BCM947XX
 132.519  	if (bcm->pci_dev->bus->number == 0)
 132.520 -		ring->memoffset = 0;
 132.521 +		ring->routing = dma64 ? BCM43xx_DMA64_NOTRANS : BCM43xx_DMA32_NOTRANS;
 132.522  #endif
 132.523  
 132.524  	ring->bcm = bcm;
 132.525 -	ring->nr_slots = nr_descriptor_slots;
 132.526 +	ring->nr_slots = nr_slots;
 132.527  	ring->suspend_mark = ring->nr_slots * BCM43xx_TXSUSPEND_PERCENT / 100;
 132.528  	ring->resume_mark = ring->nr_slots * BCM43xx_TXRESUME_PERCENT / 100;
 132.529  	assert(ring->suspend_mark < ring->resume_mark);
 132.530 -	ring->mmio_base = dma_controller_base;
 132.531 -	if (tx) {
 132.532 +	ring->mmio_base = bcm43xx_dmacontroller_base(dma64, controller_index);
 132.533 +	ring->index = controller_index;
 132.534 +	ring->dma64 = !!dma64;
 132.535 +	if (for_tx) {
 132.536  		ring->tx = 1;
 132.537  		ring->current_slot = -1;
 132.538  	} else {
 132.539 -		switch (dma_controller_base) {
 132.540 -		case BCM43xx_MMIO_DMA1_BASE:
 132.541 -			ring->rx_buffersize = BCM43xx_DMA1_RXBUFFERSIZE;
 132.542 -			ring->frameoffset = BCM43xx_DMA1_RX_FRAMEOFFSET;
 132.543 -			break;
 132.544 -		case BCM43xx_MMIO_DMA4_BASE:
 132.545 -			ring->rx_buffersize = BCM43xx_DMA4_RXBUFFERSIZE;
 132.546 -			ring->frameoffset = BCM43xx_DMA4_RX_FRAMEOFFSET;
 132.547 -			break;
 132.548 -		default:
 132.549 +		if (ring->index == 0) {
 132.550 +			ring->rx_buffersize = BCM43xx_DMA0_RX_BUFFERSIZE;
 132.551 +			ring->frameoffset = BCM43xx_DMA0_RX_FRAMEOFFSET;
 132.552 +		} else if (ring->index == 3) {
 132.553 +			ring->rx_buffersize = BCM43xx_DMA3_RX_BUFFERSIZE;
 132.554 +			ring->frameoffset = BCM43xx_DMA3_RX_FRAMEOFFSET;
 132.555 +		} else
 132.556  			assert(0);
 132.557 -		}
 132.558  	}
 132.559  
 132.560  	err = alloc_ringmemory(ring);
 132.561 @@ -514,7 +656,8 @@ static void bcm43xx_destroy_dmaring(stru
 132.562  	if (!ring)
 132.563  		return;
 132.564  
 132.565 -	dprintk(KERN_INFO PFX "DMA 0x%04x (%s) max used slots: %d/%d\n",
 132.566 +	dprintk(KERN_INFO PFX "DMA-%s 0x%04X (%s) max used slots: %d/%d\n",
 132.567 +		(ring->dma64) ? "64" : "32",
 132.568  		ring->mmio_base,
 132.569  		(ring->tx) ? "TX" : "RX",
 132.570  		ring->max_used_slots, ring->nr_slots);
 132.571 @@ -537,10 +680,15 @@ void bcm43xx_dma_free(struct bcm43xx_pri
 132.572  		return;
 132.573  	dma = bcm43xx_current_dma(bcm);
 132.574  
 132.575 -	bcm43xx_destroy_dmaring(dma->rx_ring1);
 132.576 -	dma->rx_ring1 = NULL;
 132.577 +	bcm43xx_destroy_dmaring(dma->rx_ring3);
 132.578 +	dma->rx_ring3 = NULL;
 132.579  	bcm43xx_destroy_dmaring(dma->rx_ring0);
 132.580  	dma->rx_ring0 = NULL;
 132.581 +
 132.582 +	bcm43xx_destroy_dmaring(dma->tx_ring5);
 132.583 +	dma->tx_ring5 = NULL;
 132.584 +	bcm43xx_destroy_dmaring(dma->tx_ring4);
 132.585 +	dma->tx_ring4 = NULL;
 132.586  	bcm43xx_destroy_dmaring(dma->tx_ring3);
 132.587  	dma->tx_ring3 = NULL;
 132.588  	bcm43xx_destroy_dmaring(dma->tx_ring2);
 132.589 @@ -556,48 +704,59 @@ int bcm43xx_dma_init(struct bcm43xx_priv
 132.590  	struct bcm43xx_dma *dma = bcm43xx_current_dma(bcm);
 132.591  	struct bcm43xx_dmaring *ring;
 132.592  	int err = -ENOMEM;
 132.593 +	int dma64 = 0;
 132.594 +	u32 sbtmstatehi;
 132.595 +
 132.596 +	sbtmstatehi = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATEHIGH);
 132.597 +	if (sbtmstatehi & BCM43xx_SBTMSTATEHIGH_DMA64BIT)
 132.598 +		dma64 = 1;
 132.599  
 132.600  	/* setup TX DMA channels. */
 132.601 -	ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA1_BASE,
 132.602 -				     BCM43xx_TXRING_SLOTS, 1);
 132.603 +	ring = bcm43xx_setup_dmaring(bcm, 0, 1, dma64);
 132.604  	if (!ring)
 132.605  		goto out;
 132.606  	dma->tx_ring0 = ring;
 132.607  
 132.608 -	ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA2_BASE,
 132.609 -				     BCM43xx_TXRING_SLOTS, 1);
 132.610 +	ring = bcm43xx_setup_dmaring(bcm, 1, 1, dma64);
 132.611  	if (!ring)
 132.612  		goto err_destroy_tx0;
 132.613  	dma->tx_ring1 = ring;
 132.614  
 132.615 -	ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA3_BASE,
 132.616 -				     BCM43xx_TXRING_SLOTS, 1);
 132.617 +	ring = bcm43xx_setup_dmaring(bcm, 2, 1, dma64);
 132.618  	if (!ring)
 132.619  		goto err_destroy_tx1;
 132.620  	dma->tx_ring2 = ring;
 132.621  
 132.622 -	ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA4_BASE,
 132.623 -				     BCM43xx_TXRING_SLOTS, 1);
 132.624 +	ring = bcm43xx_setup_dmaring(bcm, 3, 1, dma64);
 132.625  	if (!ring)
 132.626  		goto err_destroy_tx2;
 132.627  	dma->tx_ring3 = ring;
 132.628  
 132.629 -	/* setup RX DMA channels. */
 132.630 -	ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA1_BASE,
 132.631 -				     BCM43xx_RXRING_SLOTS, 0);
 132.632 +	ring = bcm43xx_setup_dmaring(bcm, 4, 1, dma64);
 132.633  	if (!ring)
 132.634  		goto err_destroy_tx3;
 132.635 +	dma->tx_ring4 = ring;
 132.636 +
 132.637 +	ring = bcm43xx_setup_dmaring(bcm, 5, 1, dma64);
 132.638 +	if (!ring)
 132.639 +		goto err_destroy_tx4;
 132.640 +	dma->tx_ring5 = ring;
 132.641 +
 132.642 +	/* setup RX DMA channels. */
 132.643 +	ring = bcm43xx_setup_dmaring(bcm, 0, 0, dma64);
 132.644 +	if (!ring)
 132.645 +		goto err_destroy_tx5;
 132.646  	dma->rx_ring0 = ring;
 132.647  
 132.648  	if (bcm->current_core->rev < 5) {
 132.649 -		ring = bcm43xx_setup_dmaring(bcm, BCM43xx_MMIO_DMA4_BASE,
 132.650 -					     BCM43xx_RXRING_SLOTS, 0);
 132.651 +		ring = bcm43xx_setup_dmaring(bcm, 3, 0, dma64);
 132.652  		if (!ring)
 132.653  			goto err_destroy_rx0;
 132.654 -		dma->rx_ring1 = ring;
 132.655 +		dma->rx_ring3 = ring;
 132.656  	}
 132.657  
 132.658 -	dprintk(KERN_INFO PFX "DMA initialized\n");
 132.659 +	dprintk(KERN_INFO PFX "%s DMA initialized\n",
 132.660 +			dma64 ? "64-bit" : "32-bit");
 132.661  	err = 0;
 132.662  out:
 132.663  	return err;
 132.664 @@ -605,6 +764,12 @@ out:
 132.665  err_destroy_rx0:
 132.666  	bcm43xx_destroy_dmaring(dma->rx_ring0);
 132.667  	dma->rx_ring0 = NULL;
 132.668 +err_destroy_tx5:
 132.669 +	bcm43xx_destroy_dmaring(dma->tx_ring5);
 132.670 +	dma->tx_ring5 = NULL;
 132.671 +err_destroy_tx4:
 132.672 +	bcm43xx_destroy_dmaring(dma->tx_ring4);
 132.673 +	dma->tx_ring4 = NULL;
 132.674  err_destroy_tx3:
 132.675  	bcm43xx_destroy_dmaring(dma->tx_ring3);
 132.676  	dma->tx_ring3 = NULL;
 132.677 @@ -624,7 +789,7 @@ err_destroy_tx0:
 132.678  static u16 generate_cookie(struct bcm43xx_dmaring *ring,
 132.679  			   int slot)
 132.680  {
 132.681 -	u16 cookie = 0xF000;
 132.682 +	u16 cookie = 0x1000;
 132.683  
 132.684  	/* Use the upper 4 bits of the cookie as
 132.685  	 * DMA controller ID and store the slot number
 132.686 @@ -632,21 +797,25 @@ static u16 generate_cookie(struct bcm43x
 132.687  	 * Note that the cookie must never be 0, as this
 132.688  	 * is a special value used in RX path.
 132.689  	 */
 132.690 -	switch (ring->mmio_base) {
 132.691 -	default:
 132.692 -		assert(0);
 132.693 -	case BCM43xx_MMIO_DMA1_BASE:
 132.694 +	switch (ring->index) {
 132.695 +	case 0:
 132.696  		cookie = 0xA000;
 132.697  		break;
 132.698 -	case BCM43xx_MMIO_DMA2_BASE:
 132.699 +	case 1:
 132.700  		cookie = 0xB000;
 132.701  		break;
 132.702 -	case BCM43xx_MMIO_DMA3_BASE:
 132.703 +	case 2:
 132.704  		cookie = 0xC000;
 132.705  		break;
 132.706 -	case BCM43xx_MMIO_DMA4_BASE:
 132.707 +	case 3:
 132.708  		cookie = 0xD000;
 132.709  		break;
 132.710 +	case 4:
 132.711 +		cookie = 0xE000;
 132.712 +		break;
 132.713 +	case 5:
 132.714 +		cookie = 0xF000;
 132.715 +		break;
 132.716  	}
 132.717  	assert(((u16)slot & 0xF000) == 0x0000);
 132.718  	cookie |= (u16)slot;
 132.719 @@ -675,6 +844,12 @@ struct bcm43xx_dmaring * parse_cookie(st
 132.720  	case 0xD000:
 132.721  		ring = dma->tx_ring3;
 132.722  		break;
 132.723 +	case 0xE000:
 132.724 +		ring = dma->tx_ring4;
 132.725 +		break;
 132.726 +	case 0xF000:
 132.727 +		ring = dma->tx_ring5;
 132.728 +		break;
 132.729  	default:
 132.730  		assert(0);
 132.731  	}
 132.732 @@ -687,6 +862,9 @@ struct bcm43xx_dmaring * parse_cookie(st
 132.733  static void dmacontroller_poke_tx(struct bcm43xx_dmaring *ring,
 132.734  				  int slot)
 132.735  {
 132.736 +	u16 offset;
 132.737 +	int descsize;
 132.738 +
 132.739  	/* Everything is ready to start. Buffers are DMA mapped and
 132.740  	 * associated with slots.
 132.741  	 * "slot" is the last slot of the new frame we want to transmit.
 132.742 @@ -694,25 +872,26 @@ static void dmacontroller_poke_tx(struct
 132.743  	 */
 132.744  	wmb();
 132.745  	slot = next_slot(ring, slot);
 132.746 -	bcm43xx_dma_write(ring, BCM43xx_DMA_TX_DESC_INDEX,
 132.747 -			  (u32)(slot * sizeof(struct bcm43xx_dmadesc)));
 132.748 +	offset = (ring->dma64) ? BCM43xx_DMA64_TXINDEX : BCM43xx_DMA32_TXINDEX;
 132.749 +	descsize = (ring->dma64) ? sizeof(struct bcm43xx_dmadesc64)
 132.750 +		: sizeof(struct bcm43xx_dmadesc32);
 132.751 +	bcm43xx_dma_write(ring, offset,
 132.752 +			(u32)(slot * descsize));
 132.753  }
 132.754  
 132.755 -static int dma_tx_fragment(struct bcm43xx_dmaring *ring,
 132.756 -			   struct sk_buff *skb,
 132.757 -			   u8 cur_frag)
 132.758 +static void dma_tx_fragment(struct bcm43xx_dmaring *ring,
 132.759 +			    struct sk_buff *skb,
 132.760 +			    u8 cur_frag)
 132.761  {
 132.762  	int slot;
 132.763 -	struct bcm43xx_dmadesc *desc;
 132.764 +	struct bcm43xx_dmadesc_generic *desc;
 132.765  	struct bcm43xx_dmadesc_meta *meta;
 132.766 -	u32 desc_ctl;
 132.767 -	u32 desc_addr;
 132.768 +	dma_addr_t dmaaddr;
 132.769  
 132.770  	assert(skb_shinfo(skb)->nr_frags == 0);
 132.771  
 132.772  	slot = request_slot(ring);
 132.773 -	desc = ring->vbase + slot;
 132.774 -	meta = ring->meta + slot;
 132.775 +	desc = bcm43xx_dma_idx2desc(ring, slot, &meta);
 132.776  
 132.777  	/* Add a device specific TX header. */
 132.778  	assert(skb_headroom(skb) >= sizeof(struct bcm43xx_txhdr));
 132.779 @@ -729,29 +908,14 @@ static int dma_tx_fragment(struct bcm43x
 132.780  			       generate_cookie(ring, slot));
 132.781  
 132.782  	meta->skb = skb;
 132.783 -	meta->dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1);
 132.784 -	if (unlikely(meta->dmaaddr + skb->len > BCM43xx_DMA_BUSADDRMAX)) {
 132.785 -		return_slot(ring, slot);
 132.786 -		printk(KERN_ERR PFX ">>>FATAL ERROR<<<  DMA TX SKB >1G "
 132.787 -				    "(0x%llx, len: %u)\n",
 132.788 -			(unsigned long long)meta->dmaaddr, skb->len);
 132.789 -		return -ENOMEM;
 132.790 -	}
 132.791 +	dmaaddr = map_descbuffer(ring, skb->data, skb->len, 1);
 132.792 +	meta->dmaaddr = dmaaddr;
 132.793  
 132.794 -	desc_addr = (u32)(meta->dmaaddr + ring->memoffset);
 132.795 -	desc_ctl = BCM43xx_DMADTOR_FRAMESTART | BCM43xx_DMADTOR_FRAMEEND;
 132.796 -	desc_ctl |= BCM43xx_DMADTOR_COMPIRQ;
 132.797 -	desc_ctl |= (BCM43xx_DMADTOR_BYTECNT_MASK &
 132.798 -		     (u32)(meta->skb->len - ring->frameoffset));
 132.799 -	if (slot == ring->nr_slots - 1)
 132.800 -		desc_ctl |= BCM43xx_DMADTOR_DTABLEEND;
 132.801 +	fill_descriptor(ring, desc, dmaaddr,
 132.802 +			skb->len, 1, 1, 1);
 132.803  
 132.804 -	set_desc_ctl(desc, desc_ctl);
 132.805 -	set_desc_addr(desc, desc_addr);
 132.806  	/* Now transfer the whole frame. */
 132.807  	dmacontroller_poke_tx(ring, slot);
 132.808 -
 132.809 -	return 0;
 132.810  }
 132.811  
 132.812  int bcm43xx_dma_tx(struct bcm43xx_private *bcm,
 132.813 @@ -781,7 +945,6 @@ int bcm43xx_dma_tx(struct bcm43xx_privat
 132.814  		/* Take skb from ieee80211_txb_free */
 132.815  		txb->fragments[i] = NULL;
 132.816  		dma_tx_fragment(ring, skb, i);
 132.817 -		//TODO: handle failure of dma_tx_fragment
 132.818  	}
 132.819  	ieee80211_txb_free(txb);
 132.820  
 132.821 @@ -792,23 +955,28 @@ void bcm43xx_dma_handle_xmitstatus(struc
 132.822  				   struct bcm43xx_xmitstatus *status)
 132.823  {
 132.824  	struct bcm43xx_dmaring *ring;
 132.825 -	struct bcm43xx_dmadesc *desc;
 132.826 +	struct bcm43xx_dmadesc_generic *desc;
 132.827  	struct bcm43xx_dmadesc_meta *meta;
 132.828  	int is_last_fragment;
 132.829  	int slot;
 132.830 +	u32 tmp;
 132.831  
 132.832  	ring = parse_cookie(bcm, status->cookie, &slot);
 132.833  	assert(ring);
 132.834  	assert(ring->tx);
 132.835 -	assert(get_desc_ctl(ring->vbase + slot) & BCM43xx_DMADTOR_FRAMESTART);
 132.836  	while (1) {
 132.837  		assert(slot >= 0 && slot < ring->nr_slots);
 132.838 -		desc = ring->vbase + slot;
 132.839 -		meta = ring->meta + slot;
 132.840 +		desc = bcm43xx_dma_idx2desc(ring, slot, &meta);
 132.841  
 132.842 -		is_last_fragment = !!(get_desc_ctl(desc) & BCM43xx_DMADTOR_FRAMEEND);
 132.843 +		if (ring->dma64) {
 132.844 +			tmp = le32_to_cpu(desc->dma64.control0);
 132.845 +			is_last_fragment = !!(tmp & BCM43xx_DMA64_DCTL0_FRAMEEND);
 132.846 +		} else {
 132.847 +			tmp = le32_to_cpu(desc->dma32.control);
 132.848 +			is_last_fragment = !!(tmp & BCM43xx_DMA32_DCTL_FRAMEEND);
 132.849 +		}
 132.850  		unmap_descbuffer(ring, meta->dmaaddr, meta->skb->len, 1);
 132.851 -		free_descriptor_buffer(ring, desc, meta, 1);
 132.852 +		free_descriptor_buffer(ring, meta, 1);
 132.853  		/* Everything belonging to the slot is unmapped
 132.854  		 * and freed, so we can return it.
 132.855  		 */
 132.856 @@ -824,7 +992,7 @@ void bcm43xx_dma_handle_xmitstatus(struc
 132.857  static void dma_rx(struct bcm43xx_dmaring *ring,
 132.858  		   int *slot)
 132.859  {
 132.860 -	struct bcm43xx_dmadesc *desc;
 132.861 +	struct bcm43xx_dmadesc_generic *desc;
 132.862  	struct bcm43xx_dmadesc_meta *meta;
 132.863  	struct bcm43xx_rxhdr *rxhdr;
 132.864  	struct sk_buff *skb;
 132.865 @@ -832,13 +1000,12 @@ static void dma_rx(struct bcm43xx_dmarin
 132.866  	int err;
 132.867  	dma_addr_t dmaaddr;
 132.868  
 132.869 -	desc = ring->vbase + *slot;
 132.870 -	meta = ring->meta + *slot;
 132.871 +	desc = bcm43xx_dma_idx2desc(ring, *slot, &meta);
 132.872  
 132.873  	sync_descbuffer_for_cpu(ring, meta->dmaaddr, ring->rx_buffersize);
 132.874  	skb = meta->skb;
 132.875  
 132.876 -	if (ring->mmio_base == BCM43xx_MMIO_DMA4_BASE) {
 132.877 +	if (ring->index == 3) {
 132.878  		/* We received an xmit status. */
 132.879  		struct bcm43xx_hwxmitstatus *hw = (struct bcm43xx_hwxmitstatus *)skb->data;
 132.880  		struct bcm43xx_xmitstatus stat;
 132.881 @@ -894,8 +1061,7 @@ static void dma_rx(struct bcm43xx_dmarin
 132.882  		s32 tmp = len;
 132.883  
 132.884  		while (1) {
 132.885 -			desc = ring->vbase + *slot;
 132.886 -			meta = ring->meta + *slot;
 132.887 +			desc = bcm43xx_dma_idx2desc(ring, *slot, &meta);
 132.888  			/* recycle the descriptor buffer. */
 132.889  			sync_descbuffer_for_device(ring, meta->dmaaddr,
 132.890  						   ring->rx_buffersize);
 132.891 @@ -906,8 +1072,8 @@ static void dma_rx(struct bcm43xx_dmarin
 132.892  				break;
 132.893  		}
 132.894  		printkl(KERN_ERR PFX "DMA RX buffer too small "
 132.895 -				     "(len: %u, buffer: %u, nr-dropped: %d)\n",
 132.896 -		        len, ring->rx_buffersize, cnt);
 132.897 +			"(len: %u, buffer: %u, nr-dropped: %d)\n",
 132.898 +			len, ring->rx_buffersize, cnt);
 132.899  		goto drop;
 132.900  	}
 132.901  	len -= IEEE80211_FCS_LEN;
 132.902 @@ -945,9 +1111,15 @@ void bcm43xx_dma_rx(struct bcm43xx_dmari
 132.903  #endif
 132.904  
 132.905  	assert(!ring->tx);
 132.906 -	status = bcm43xx_dma_read(ring, BCM43xx_DMA_RX_STATUS);
 132.907 -	descptr = (status & BCM43xx_DMA_RXSTAT_DPTR_MASK);
 132.908 -	current_slot = descptr / sizeof(struct bcm43xx_dmadesc);
 132.909 +	if (ring->dma64) {
 132.910 +		status = bcm43xx_dma_read(ring, BCM43xx_DMA64_RXSTATUS);
 132.911 +		descptr = (status & BCM43xx_DMA64_RXSTATDPTR);
 132.912 +		current_slot = descptr / sizeof(struct bcm43xx_dmadesc64);
 132.913 +	} else {
 132.914 +		status = bcm43xx_dma_read(ring, BCM43xx_DMA32_RXSTATUS);
 132.915 +		descptr = (status & BCM43xx_DMA32_RXDPTR);
 132.916 +		current_slot = descptr / sizeof(struct bcm43xx_dmadesc32);
 132.917 +	}
 132.918  	assert(current_slot >= 0 && current_slot < ring->nr_slots);
 132.919  
 132.920  	slot = ring->current_slot;
 132.921 @@ -958,8 +1130,13 @@ void bcm43xx_dma_rx(struct bcm43xx_dmari
 132.922  			ring->max_used_slots = used_slots;
 132.923  #endif
 132.924  	}
 132.925 -	bcm43xx_dma_write(ring, BCM43xx_DMA_RX_DESC_INDEX,
 132.926 -			  (u32)(slot * sizeof(struct bcm43xx_dmadesc)));
 132.927 +	if (ring->dma64) {
 132.928 +		bcm43xx_dma_write(ring, BCM43xx_DMA64_RXINDEX,
 132.929 +				(u32)(slot * sizeof(struct bcm43xx_dmadesc64)));
 132.930 +	} else {
 132.931 +		bcm43xx_dma_write(ring, BCM43xx_DMA32_RXINDEX,
 132.932 +				(u32)(slot * sizeof(struct bcm43xx_dmadesc32)));
 132.933 +	}
 132.934  	ring->current_slot = slot;
 132.935  }
 132.936  
 132.937 @@ -967,16 +1144,28 @@ void bcm43xx_dma_tx_suspend(struct bcm43
 132.938  {
 132.939  	assert(ring->tx);
 132.940  	bcm43xx_power_saving_ctl_bits(ring->bcm, -1, 1);
 132.941 -	bcm43xx_dma_write(ring, BCM43xx_DMA_TX_CONTROL,
 132.942 -			  bcm43xx_dma_read(ring, BCM43xx_DMA_TX_CONTROL)
 132.943 -			  | BCM43xx_DMA_TXCTRL_SUSPEND);
 132.944 +	if (ring->dma64) {
 132.945 +		bcm43xx_dma_write(ring, BCM43xx_DMA64_TXCTL,
 132.946 +				bcm43xx_dma_read(ring, BCM43xx_DMA64_TXCTL)
 132.947 +				| BCM43xx_DMA64_TXSUSPEND);
 132.948 +	} else {
 132.949 +		bcm43xx_dma_write(ring, BCM43xx_DMA32_TXCTL,
 132.950 +				bcm43xx_dma_read(ring, BCM43xx_DMA32_TXCTL)
 132.951 +				| BCM43xx_DMA32_TXSUSPEND);
 132.952 +	}
 132.953  }
 132.954  
 132.955  void bcm43xx_dma_tx_resume(struct bcm43xx_dmaring *ring)
 132.956  {
 132.957  	assert(ring->tx);
 132.958 -	bcm43xx_dma_write(ring, BCM43xx_DMA_TX_CONTROL,
 132.959 -			  bcm43xx_dma_read(ring, BCM43xx_DMA_TX_CONTROL)
 132.960 -			  & ~BCM43xx_DMA_TXCTRL_SUSPEND);
 132.961 +	if (ring->dma64) {
 132.962 +		bcm43xx_dma_write(ring, BCM43xx_DMA64_TXCTL,
 132.963 +				bcm43xx_dma_read(ring, BCM43xx_DMA64_TXCTL)
 132.964 +				& ~BCM43xx_DMA64_TXSUSPEND);
 132.965 +	} else {
 132.966 +		bcm43xx_dma_write(ring, BCM43xx_DMA32_TXCTL,
 132.967 +				bcm43xx_dma_read(ring, BCM43xx_DMA32_TXCTL)
 132.968 +				& ~BCM43xx_DMA32_TXSUSPEND);
 132.969 +	}
 132.970  	bcm43xx_power_saving_ctl_bits(ring->bcm, -1, -1);
 132.971  }
   133.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h	Tue Oct 02 09:52:15 2007 +0100
   133.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h	Wed Oct 03 10:00:44 2007 +0100
   133.3 @@ -14,63 +14,179 @@
   133.4  #define BCM43xx_DMAIRQ_NONFATALMASK	(1 << 13)
   133.5  #define BCM43xx_DMAIRQ_RX_DONE		(1 << 16)
   133.6  
   133.7 -/* DMA controller register offsets. (relative to BCM43xx_DMA#_BASE) */
   133.8 -#define BCM43xx_DMA_TX_CONTROL		0x00
   133.9 -#define BCM43xx_DMA_TX_DESC_RING	0x04
  133.10 -#define BCM43xx_DMA_TX_DESC_INDEX	0x08
  133.11 -#define BCM43xx_DMA_TX_STATUS		0x0c
  133.12 -#define BCM43xx_DMA_RX_CONTROL		0x10
  133.13 -#define BCM43xx_DMA_RX_DESC_RING	0x14
  133.14 -#define BCM43xx_DMA_RX_DESC_INDEX	0x18
  133.15 -#define BCM43xx_DMA_RX_STATUS		0x1c
  133.16  
  133.17 -/* DMA controller channel control word values. */
  133.18 -#define BCM43xx_DMA_TXCTRL_ENABLE		(1 << 0)
  133.19 -#define BCM43xx_DMA_TXCTRL_SUSPEND		(1 << 1)
  133.20 -#define BCM43xx_DMA_TXCTRL_LOOPBACK		(1 << 2)
  133.21 -#define BCM43xx_DMA_TXCTRL_FLUSH		(1 << 4)
  133.22 -#define BCM43xx_DMA_RXCTRL_ENABLE		(1 << 0)
  133.23 -#define BCM43xx_DMA_RXCTRL_FRAMEOFF_MASK	0x000000fe
  133.24 -#define BCM43xx_DMA_RXCTRL_FRAMEOFF_SHIFT	1
  133.25 -#define BCM43xx_DMA_RXCTRL_PIO			(1 << 8)
  133.26 -/* DMA controller channel status word values. */
  133.27 -#define BCM43xx_DMA_TXSTAT_DPTR_MASK		0x00000fff
  133.28 -#define BCM43xx_DMA_TXSTAT_STAT_MASK		0x0000f000
  133.29 -#define BCM43xx_DMA_TXSTAT_STAT_DISABLED	0x00000000
  133.30 -#define BCM43xx_DMA_TXSTAT_STAT_ACTIVE		0x00001000
  133.31 -#define BCM43xx_DMA_TXSTAT_STAT_IDLEWAIT	0x00002000
  133.32 -#define BCM43xx_DMA_TXSTAT_STAT_STOPPED		0x00003000
  133.33 -#define BCM43xx_DMA_TXSTAT_STAT_SUSP		0x00004000
  133.34 -#define BCM43xx_DMA_TXSTAT_ERROR_MASK		0x000f0000
  133.35 -#define BCM43xx_DMA_TXSTAT_FLUSHED		(1 << 20)
  133.36 -#define BCM43xx_DMA_RXSTAT_DPTR_MASK		0x00000fff
  133.37 -#define BCM43xx_DMA_RXSTAT_STAT_MASK		0x0000f000
  133.38 -#define BCM43xx_DMA_RXSTAT_STAT_DISABLED	0x00000000
  133.39 -#define BCM43xx_DMA_RXSTAT_STAT_ACTIVE		0x00001000
  133.40 -#define BCM43xx_DMA_RXSTAT_STAT_IDLEWAIT	0x00002000
  133.41 -#define BCM43xx_DMA_RXSTAT_STAT_RESERVED	0x00003000
  133.42 -#define BCM43xx_DMA_RXSTAT_STAT_ERRORS		0x00004000
  133.43 -#define BCM43xx_DMA_RXSTAT_ERROR_MASK		0x000f0000
  133.44 +/*** 32-bit DMA Engine. ***/
  133.45  
  133.46 -/* DMA descriptor control field values. */
  133.47 -#define BCM43xx_DMADTOR_BYTECNT_MASK		0x00001fff
  133.48 -#define BCM43xx_DMADTOR_DTABLEEND		(1 << 28) /* End of descriptor table */
  133.49 -#define BCM43xx_DMADTOR_COMPIRQ			(1 << 29) /* IRQ on completion request */
  133.50 -#define BCM43xx_DMADTOR_FRAMEEND		(1 << 30)
  133.51 -#define BCM43xx_DMADTOR_FRAMESTART		(1 << 31)
  133.52 +/* 32-bit DMA controller registers. */
  133.53 +#define BCM43xx_DMA32_TXCTL				0x00
  133.54 +#define		BCM43xx_DMA32_TXENABLE			0x00000001
  133.55 +#define		BCM43xx_DMA32_TXSUSPEND			0x00000002
  133.56 +#define		BCM43xx_DMA32_TXLOOPBACK		0x00000004
  133.57 +#define		BCM43xx_DMA32_TXFLUSH			0x00000010
  133.58 +#define		BCM43xx_DMA32_TXADDREXT_MASK		0x00030000
  133.59 +#define		BCM43xx_DMA32_TXADDREXT_SHIFT		16
  133.60 +#define BCM43xx_DMA32_TXRING				0x04
  133.61 +#define BCM43xx_DMA32_TXINDEX				0x08
  133.62 +#define BCM43xx_DMA32_TXSTATUS				0x0C
  133.63 +#define		BCM43xx_DMA32_TXDPTR			0x00000FFF
  133.64 +#define		BCM43xx_DMA32_TXSTATE			0x0000F000
  133.65 +#define			BCM43xx_DMA32_TXSTAT_DISABLED	0x00000000
  133.66 +#define			BCM43xx_DMA32_TXSTAT_ACTIVE	0x00001000
  133.67 +#define			BCM43xx_DMA32_TXSTAT_IDLEWAIT	0x00002000
  133.68 +#define			BCM43xx_DMA32_TXSTAT_STOPPED	0x00003000
  133.69 +#define			BCM43xx_DMA32_TXSTAT_SUSP	0x00004000
  133.70 +#define		BCM43xx_DMA32_TXERROR			0x000F0000
  133.71 +#define			BCM43xx_DMA32_TXERR_NOERR	0x00000000
  133.72 +#define			BCM43xx_DMA32_TXERR_PROT	0x00010000
  133.73 +#define			BCM43xx_DMA32_TXERR_UNDERRUN	0x00020000
  133.74 +#define			BCM43xx_DMA32_TXERR_BUFREAD	0x00030000
  133.75 +#define			BCM43xx_DMA32_TXERR_DESCREAD	0x00040000
  133.76 +#define		BCM43xx_DMA32_TXACTIVE			0xFFF00000
  133.77 +#define BCM43xx_DMA32_RXCTL				0x10
  133.78 +#define		BCM43xx_DMA32_RXENABLE			0x00000001
  133.79 +#define		BCM43xx_DMA32_RXFROFF_MASK		0x000000FE
  133.80 +#define		BCM43xx_DMA32_RXFROFF_SHIFT		1
  133.81 +#define		BCM43xx_DMA32_RXDIRECTFIFO		0x00000100
  133.82 +#define		BCM43xx_DMA32_RXADDREXT_MASK		0x00030000
  133.83 +#define		BCM43xx_DMA32_RXADDREXT_SHIFT		16
  133.84 +#define BCM43xx_DMA32_RXRING				0x14
  133.85 +#define BCM43xx_DMA32_RXINDEX				0x18
  133.86 +#define BCM43xx_DMA32_RXSTATUS				0x1C
  133.87 +#define		BCM43xx_DMA32_RXDPTR			0x00000FFF
  133.88 +#define		BCM43xx_DMA32_RXSTATE			0x0000F000
  133.89 +#define			BCM43xx_DMA32_RXSTAT_DISABLED	0x00000000
  133.90 +#define			BCM43xx_DMA32_RXSTAT_ACTIVE	0x00001000
  133.91 +#define			BCM43xx_DMA32_RXSTAT_IDLEWAIT	0x00002000
  133.92 +#define			BCM43xx_DMA32_RXSTAT_STOPPED	0x00003000
  133.93 +#define		BCM43xx_DMA32_RXERROR			0x000F0000
  133.94 +#define			BCM43xx_DMA32_RXERR_NOERR	0x00000000
  133.95 +#define			BCM43xx_DMA32_RXERR_PROT	0x00010000
  133.96 +#define			BCM43xx_DMA32_RXERR_OVERFLOW	0x00020000
  133.97 +#define			BCM43xx_DMA32_RXERR_BUFWRITE	0x00030000
  133.98 +#define			BCM43xx_DMA32_RXERR_DESCREAD	0x00040000
  133.99 +#define		BCM43xx_DMA32_RXACTIVE			0xFFF00000
 133.100 +
 133.101 +/* 32-bit DMA descriptor. */
 133.102 +struct bcm43xx_dmadesc32 {
 133.103 +	__le32 control;
 133.104 +	__le32 address;
 133.105 +} __attribute__((__packed__));
 133.106 +#define BCM43xx_DMA32_DCTL_BYTECNT		0x00001FFF
 133.107 +#define BCM43xx_DMA32_DCTL_ADDREXT_MASK		0x00030000
 133.108 +#define BCM43xx_DMA32_DCTL_ADDREXT_SHIFT	16
 133.109 +#define BCM43xx_DMA32_DCTL_DTABLEEND		0x10000000
 133.110 +#define BCM43xx_DMA32_DCTL_IRQ			0x20000000
 133.111 +#define BCM43xx_DMA32_DCTL_FRAMEEND		0x40000000
 133.112 +#define BCM43xx_DMA32_DCTL_FRAMESTART		0x80000000
 133.113 +
 133.114 +/* Address field Routing value. */
 133.115 +#define BCM43xx_DMA32_ROUTING			0xC0000000
 133.116 +#define BCM43xx_DMA32_ROUTING_SHIFT		30
 133.117 +#define		BCM43xx_DMA32_NOTRANS		0x00000000
 133.118 +#define		BCM43xx_DMA32_CLIENTTRANS	0x40000000
 133.119 +
 133.120 +
 133.121 +
 133.122 +/*** 64-bit DMA Engine. ***/
 133.123 +
 133.124 +/* 64-bit DMA controller registers. */
 133.125 +#define BCM43xx_DMA64_TXCTL				0x00
 133.126 +#define		BCM43xx_DMA64_TXENABLE			0x00000001
 133.127 +#define		BCM43xx_DMA64_TXSUSPEND			0x00000002
 133.128 +#define		BCM43xx_DMA64_TXLOOPBACK		0x00000004
 133.129 +#define		BCM43xx_DMA64_TXFLUSH			0x00000010
 133.130 +#define		BCM43xx_DMA64_TXADDREXT_MASK		0x00030000
 133.131 +#define		BCM43xx_DMA64_TXADDREXT_SHIFT		16
 133.132 +#define BCM43xx_DMA64_TXINDEX				0x04
 133.133 +#define BCM43xx_DMA64_TXRINGLO				0x08
 133.134 +#define BCM43xx_DMA64_TXRINGHI				0x0C
 133.135 +#define BCM43xx_DMA64_TXSTATUS				0x10
 133.136 +#define		BCM43xx_DMA64_TXSTATDPTR		0x00001FFF
 133.137 +#define		BCM43xx_DMA64_TXSTAT			0xF0000000
 133.138 +#define			BCM43xx_DMA64_TXSTAT_DISABLED	0x00000000
 133.139 +#define			BCM43xx_DMA64_TXSTAT_ACTIVE	0x10000000
 133.140 +#define			BCM43xx_DMA64_TXSTAT_IDLEWAIT	0x20000000
 133.141 +#define			BCM43xx_DMA64_TXSTAT_STOPPED	0x30000000
 133.142 +#define			BCM43xx_DMA64_TXSTAT_SUSP	0x40000000
 133.143 +#define BCM43xx_DMA64_TXERROR				0x14
 133.144 +#define		BCM43xx_DMA64_TXERRDPTR			0x0001FFFF
 133.145 +#define		BCM43xx_DMA64_TXERR			0xF0000000
 133.146 +#define			BCM43xx_DMA64_TXERR_NOERR	0x00000000
 133.147 +#define			BCM43xx_DMA64_TXERR_PROT	0x10000000
 133.148 +#define			BCM43xx_DMA64_TXERR_UNDERRUN	0x20000000
 133.149 +#define			BCM43xx_DMA64_TXERR_TRANSFER	0x30000000
 133.150 +#define			BCM43xx_DMA64_TXERR_DESCREAD	0x40000000
 133.151 +#define			BCM43xx_DMA64_TXERR_CORE	0x50000000
 133.152 +#define BCM43xx_DMA64_RXCTL				0x20
 133.153 +#define		BCM43xx_DMA64_RXENABLE			0x00000001
 133.154 +#define		BCM43xx_DMA64_RXFROFF_MASK		0x000000FE
 133.155 +#define		BCM43xx_DMA64_RXFROFF_SHIFT		1
 133.156 +#define		BCM43xx_DMA64_RXDIRECTFIFO		0x00000100
 133.157 +#define		BCM43xx_DMA64_RXADDREXT_MASK		0x00030000
 133.158 +#define		BCM43xx_DMA64_RXADDREXT_SHIFT		16
 133.159 +#define BCM43xx_DMA64_RXINDEX				0x24
 133.160 +#define BCM43xx_DMA64_RXRINGLO				0x28
 133.161 +#define BCM43xx_DMA64_RXRINGHI				0x2C
 133.162 +#define BCM43xx_DMA64_RXSTATUS				0x30
 133.163 +#define		BCM43xx_DMA64_RXSTATDPTR		0x00001FFF
 133.164 +#define		BCM43xx_DMA64_RXSTAT			0xF0000000
 133.165 +#define			BCM43xx_DMA64_RXSTAT_DISABLED	0x00000000
 133.166 +#define			BCM43xx_DMA64_RXSTAT_ACTIVE	0x10000000
 133.167 +#define			BCM43xx_DMA64_RXSTAT_IDLEWAIT	0x20000000
 133.168 +#define			BCM43xx_DMA64_RXSTAT_STOPPED	0x30000000
 133.169 +#define			BCM43xx_DMA64_RXSTAT_SUSP	0x40000000
 133.170 +#define BCM43xx_DMA64_RXERROR				0x34
 133.171 +#define		BCM43xx_DMA64_RXERRDPTR			0x0001FFFF
 133.172 +#define		BCM43xx_DMA64_RXERR			0xF0000000
 133.173 +#define			BCM43xx_DMA64_RXERR_NOERR	0x00000000
 133.174 +#define			BCM43xx_DMA64_RXERR_PROT	0x10000000
 133.175 +#define			BCM43xx_DMA64_RXERR_UNDERRUN	0x20000000
 133.176 +#define			BCM43xx_DMA64_RXERR_TRANSFER	0x30000000
 133.177 +#define			BCM43xx_DMA64_RXERR_DESCREAD	0x40000000
 133.178 +#define			BCM43xx_DMA64_RXERR_CORE	0x50000000
 133.179 +
 133.180 +/* 64-bit DMA descriptor. */
 133.181 +struct bcm43xx_dmadesc64 {
 133.182 +	__le32 control0;
 133.183 +	__le32 control1;
 133.184 +	__le32 address_low;
 133.185 +	__le32 address_high;
 133.186 +} __attribute__((__packed__));
 133.187 +#define BCM43xx_DMA64_DCTL0_DTABLEEND		0x10000000
 133.188 +#define BCM43xx_DMA64_DCTL0_IRQ			0x20000000
 133.189 +#define BCM43xx_DMA64_DCTL0_FRAMEEND		0x40000000
 133.190 +#define BCM43xx_DMA64_DCTL0_FRAMESTART		0x80000000
 133.191 +#define BCM43xx_DMA64_DCTL1_BYTECNT		0x00001FFF
 133.192 +#define BCM43xx_DMA64_DCTL1_ADDREXT_MASK	0x00030000
 133.193 +#define BCM43xx_DMA64_DCTL1_ADDREXT_SHIFT	16
 133.194 +
 133.195 +/* Address field Routing value. */
 133.196 +#define BCM43xx_DMA64_ROUTING			0xC0000000
 133.197 +#define BCM43xx_DMA64_ROUTING_SHIFT		30
 133.198 +#define		BCM43xx_DMA64_NOTRANS		0x00000000
 133.199 +#define		BCM43xx_DMA64_CLIENTTRANS	0x80000000
 133.200 +
 133.201 +
 133.202 +
 133.203 +struct bcm43xx_dmadesc_generic {
 133.204 +	union {
 133.205 +		struct bcm43xx_dmadesc32 dma32;
 133.206 +		struct bcm43xx_dmadesc64 dma64;
 133.207 +	} __attribute__((__packed__));
 133.208 +} __attribute__((__packed__));
 133.209 +
 133.210  
 133.211  /* Misc DMA constants */
 133.212  #define BCM43xx_DMA_RINGMEMSIZE		PAGE_SIZE
 133.213 -#define BCM43xx_DMA_BUSADDRMAX		0x3FFFFFFF
 133.214 -#define BCM43xx_DMA_DMABUSADDROFFSET	(1 << 30)
 133.215 -#define BCM43xx_DMA1_RX_FRAMEOFFSET	30
 133.216 -#define BCM43xx_DMA4_RX_FRAMEOFFSET	0
 133.217 +#define BCM43xx_DMA0_RX_FRAMEOFFSET	30
 133.218 +#define BCM43xx_DMA3_RX_FRAMEOFFSET	0
 133.219 +
 133.220  
 133.221  /* DMA engine tuning knobs */
 133.222  #define BCM43xx_TXRING_SLOTS		512
 133.223  #define BCM43xx_RXRING_SLOTS		64
 133.224 -#define BCM43xx_DMA1_RXBUFFERSIZE	(2304 + 100)
 133.225 -#define BCM43xx_DMA4_RXBUFFERSIZE	16
 133.226 +#define BCM43xx_DMA0_RX_BUFFERSIZE	(2304 + 100)
 133.227 +#define BCM43xx_DMA3_RX_BUFFERSIZE	16
 133.228  /* Suspend the tx queue, if less than this percent slots are free. */
 133.229  #define BCM43xx_TXSUSPEND_PERCENT	20
 133.230  /* Resume the tx queue, if more than this percent slots are free. */
 133.231 @@ -86,17 +202,6 @@ struct bcm43xx_private;
 133.232  struct bcm43xx_xmitstatus;
 133.233  
 133.234  
 133.235 -struct bcm43xx_dmadesc {
 133.236 -	__le32 _control;
 133.237 -	__le32 _address;
 133.238 -} __attribute__((__packed__));
 133.239 -
 133.240 -/* Macros to access the bcm43xx_dmadesc struct */
 133.241 -#define get_desc_ctl(desc)		le32_to_cpu((desc)->_control)
 133.242 -#define set_desc_ctl(desc, ctl)		do { (desc)->_control = cpu_to_le32(ctl); } while (0)
 133.243 -#define get_desc_addr(desc)		le32_to_cpu((desc)->_address)
 133.244 -#define set_desc_addr(desc, addr)	do { (desc)->_address = cpu_to_le32(addr); } while (0)
 133.245 -
 133.246  struct bcm43xx_dmadesc_meta {
 133.247  	/* The kernel DMA-able buffer. */
 133.248  	struct sk_buff *skb;
 133.249 @@ -105,15 +210,14 @@ struct bcm43xx_dmadesc_meta {
 133.250  };
 133.251  
 133.252  struct bcm43xx_dmaring {
 133.253 -	struct bcm43xx_private *bcm;
 133.254  	/* Kernel virtual base address of the ring memory. */
 133.255 -	struct bcm43xx_dmadesc *vbase;
 133.256 -	/* DMA memory offset */
 133.257 -	dma_addr_t memoffset;
 133.258 +	void *descbase;
 133.259 +	/* Meta data about all descriptors. */
 133.260 +	struct bcm43xx_dmadesc_meta *meta;
 133.261 +	/* DMA Routing value. */
 133.262 +	u32 routing;
 133.263  	/* (Unadjusted) DMA base bus-address of the ring memory. */
 133.264  	dma_addr_t dmabase;
 133.265 -	/* Meta data about all descriptors. */
 133.266 -	struct bcm43xx_dmadesc_meta *meta;
 133.267  	/* Number of descriptor slots in the ring. */
 133.268  	int nr_slots;
 133.269  	/* Number of used descriptor slots. */
 133.270 @@ -127,12 +231,17 @@ struct bcm43xx_dmaring {
 133.271  	u32 frameoffset;
 133.272  	/* Descriptor buffer size. */
 133.273  	u16 rx_buffersize;
 133.274 -	/* The MMIO base register of the DMA controller, this
 133.275 -	 * ring is posted to.
 133.276 -	 */
 133.277 +	/* The MMIO base register of the DMA controller. */
 133.278  	u16 mmio_base;
 133.279 -	u8 tx:1,	/* TRUE, if this is a TX ring. */
 133.280 -	   suspended:1;	/* TRUE, if transfers are suspended on this ring. */
 133.281 +	/* DMA controller index number (0-5). */
 133.282 +	int index;
 133.283 +	/* Boolean. Is this a TX ring? */
 133.284 +	u8 tx;
 133.285 +	/* Boolean. 64bit DMA if true, 32bit DMA otherwise. */
 133.286 +	u8 dma64;
 133.287 +	/* Boolean. Are transfers suspended on this ring? */
 133.288 +	u8 suspended;
 133.289 +	struct bcm43xx_private *bcm;
 133.290  #ifdef CONFIG_BCM43XX_DEBUG
 133.291  	/* Maximum number of used slots. */
 133.292  	int max_used_slots;
 133.293 @@ -141,6 +250,34 @@ struct bcm43xx_dmaring {
 133.294  
 133.295  
 133.296  static inline
 133.297 +int bcm43xx_dma_desc2idx(struct bcm43xx_dmaring *ring,
 133.298 +			 struct bcm43xx_dmadesc_generic *desc)
 133.299 +{
 133.300 +	if (ring->dma64) {
 133.301 +		struct bcm43xx_dmadesc64 *dd64 = ring->descbase;
 133.302 +		return (int)(&(desc->dma64) - dd64);
 133.303 +	} else {
 133.304 +		struct bcm43xx_dmadesc32 *dd32 = ring->descbase;
 133.305 +		return (int)(&(desc->dma32) - dd32);
 133.306 +	}
 133.307 +}
 133.308 +
 133.309 +static inline
 133.310 +struct bcm43xx_dmadesc_generic * bcm43xx_dma_idx2desc(struct bcm43xx_dmaring *ring,
 133.311 +						      int slot,
 133.312 +						      struct bcm43xx_dmadesc_meta **meta)
 133.313 +{
 133.314 +	*meta = &(ring->meta[slot]);
 133.315 +	if (ring->dma64) {
 133.316 +		struct bcm43xx_dmadesc64 *dd64 = ring->descbase;
 133.317 +		return (struct bcm43xx_dmadesc_generic *)(&(dd64[slot]));
 133.318 +	} else {
 133.319 +		struct bcm43xx_dmadesc32 *dd32 = ring->descbase;
 133.320 +		return (struct bcm43xx_dmadesc_generic *)(&(dd32[slot]));
 133.321 +	}
 133.322 +}
 133.323 +
 133.324 +static inline
 133.325  u32 bcm43xx_dma_read(struct bcm43xx_dmaring *ring,
 133.326  		     u16 offset)
 133.327  {
 133.328 @@ -159,9 +296,13 @@ int bcm43xx_dma_init(struct bcm43xx_priv
 133.329  void bcm43xx_dma_free(struct bcm43xx_private *bcm);
 133.330  
 133.331  int bcm43xx_dmacontroller_rx_reset(struct bcm43xx_private *bcm,
 133.332 -				   u16 dmacontroller_mmio_base);
 133.333 +				   u16 dmacontroller_mmio_base,
 133.334 +				   int dma64);
 133.335  int bcm43xx_dmacontroller_tx_reset(struct bcm43xx_private *bcm,
 133.336 -				   u16 dmacontroller_mmio_base);
 133.337 +				   u16 dmacontroller_mmio_base,
 133.338 +				   int dma64);
 133.339 +
 133.340 +u16 bcm43xx_dmacontroller_base(int dma64bit, int dmacontroller_idx);
 133.341  
 133.342  void bcm43xx_dma_tx_suspend(struct bcm43xx_dmaring *ring);
 133.343  void bcm43xx_dma_tx_resume(struct bcm43xx_dmaring *ring);
 133.344 @@ -173,7 +314,6 @@ int bcm43xx_dma_tx(struct bcm43xx_privat
 133.345  		   struct ieee80211_txb *txb);
 133.346  void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring);
 133.347  
 133.348 -
 133.349  #else /* CONFIG_BCM43XX_DMA */
 133.350  
 133.351  
 133.352 @@ -188,13 +328,15 @@ void bcm43xx_dma_free(struct bcm43xx_pri
 133.353  }
 133.354  static inline
 133.355  int bcm43xx_dmacontroller_rx_reset(struct bcm43xx_private *bcm,
 133.356 -				   u16 dmacontroller_mmio_base)
 133.357 +				   u16 dmacontroller_mmio_base,
 133.358 +				   int dma64)
 133.359  {
 133.360  	return 0;
 133.361  }
 133.362  static inline
 133.363  int bcm43xx_dmacontroller_tx_reset(struct bcm43xx_private *bcm,
 133.364 -				   u16 dmacontroller_mmio_base)
 133.365 +				   u16 dmacontroller_mmio_base,
 133.366 +				   int dma64)
 133.367  {
 133.368  	return 0;
 133.369  }
   134.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_leds.c	Tue Oct 02 09:52:15 2007 +0100
   134.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_leds.c	Wed Oct 03 10:00:44 2007 +0100
   134.3 @@ -51,12 +51,12 @@ static void bcm43xx_led_blink(unsigned l
   134.4  	struct bcm43xx_private *bcm = led->bcm;
   134.5  	unsigned long flags;
   134.6  
   134.7 -	bcm43xx_lock_irqonly(bcm, flags);
   134.8 +	spin_lock_irqsave(&bcm->leds_lock, flags);
   134.9  	if (led->blink_interval) {
  134.10  		bcm43xx_led_changestate(led);
  134.11  		mod_timer(&led->blink_timer, jiffies + led->blink_interval);
  134.12  	}
  134.13 -	bcm43xx_unlock_irqonly(bcm, flags);
  134.14 +	spin_unlock_irqrestore(&bcm->leds_lock, flags);
  134.15  }
  134.16  
  134.17  static void bcm43xx_led_blink_start(struct bcm43xx_led *led,
  134.18 @@ -177,7 +177,9 @@ void bcm43xx_leds_update(struct bcm43xx_
  134.19  	int i, turn_on;
  134.20  	unsigned long interval = 0;
  134.21  	u16 ledctl;
  134.22 +	unsigned long flags;
  134.23  
  134.24 +	spin_lock_irqsave(&bcm->leds_lock, flags);
  134.25  	ledctl = bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL);
  134.26  	for (i = 0; i < BCM43xx_NR_LEDS; i++) {
  134.27  		led = &(bcm->leds[i]);
  134.28 @@ -266,6 +268,7 @@ void bcm43xx_leds_update(struct bcm43xx_
  134.29  			ledctl &= ~(1 << i);
  134.30  	}
  134.31  	bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl);
  134.32 +	spin_unlock_irqrestore(&bcm->leds_lock, flags);
  134.33  }
  134.34  
  134.35  void bcm43xx_leds_switch_all(struct bcm43xx_private *bcm, int on)
  134.36 @@ -274,7 +277,9 @@ void bcm43xx_leds_switch_all(struct bcm4
  134.37  	u16 ledctl;
  134.38  	int i;
  134.39  	int bit_on;
  134.40 +	unsigned long flags;
  134.41  
  134.42 +	spin_lock_irqsave(&bcm->leds_lock, flags);
  134.43  	ledctl = bcm43xx_read16(bcm, BCM43xx_MMIO_GPIO_CONTROL);
  134.44  	for (i = 0; i < BCM43xx_NR_LEDS; i++) {
  134.45  		led = &(bcm->leds[i]);
  134.46 @@ -290,4 +295,5 @@ void bcm43xx_leds_switch_all(struct bcm4
  134.47  			ledctl &= ~(1 << i);
  134.48  	}
  134.49  	bcm43xx_write16(bcm, BCM43xx_MMIO_GPIO_CONTROL, ledctl);
  134.50 +	spin_unlock_irqrestore(&bcm->leds_lock, flags);
  134.51  }
   135.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c	Tue Oct 02 09:52:15 2007 +0100
   135.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c	Wed Oct 03 10:00:44 2007 +0100
   135.3 @@ -509,23 +509,20 @@ static void bcm43xx_synchronize_irq(stru
   135.4  }
   135.5  
   135.6  /* Make sure we don't receive more data from the device. */
   135.7 -static int bcm43xx_disable_interrupts_sync(struct bcm43xx_private *bcm, u32 *oldstate)
   135.8 +static int bcm43xx_disable_interrupts_sync(struct bcm43xx_private *bcm)
   135.9  {
  135.10  	unsigned long flags;
  135.11 -	u32 old;
  135.12 -
  135.13 -	bcm43xx_lock_irqonly(bcm, flags);
  135.14 +
  135.15 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  135.16  	if (unlikely(bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED)) {
  135.17 -		bcm43xx_unlock_irqonly(bcm, flags);
  135.18 +		spin_unlock_irqrestore(&bcm->irq_lock, flags);
  135.19  		return -EBUSY;
  135.20  	}
  135.21 -	old = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
  135.22 -	bcm43xx_unlock_irqonly(bcm, flags);
  135.23 +	bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
  135.24 +	bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_MASK); /* flush */
  135.25 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  135.26  	bcm43xx_synchronize_irq(bcm);
  135.27  
  135.28 -	if (oldstate)
  135.29 -		*oldstate = old;
  135.30 -
  135.31  	return 0;
  135.32  }
  135.33  
  135.34 @@ -537,7 +534,6 @@ static int bcm43xx_read_radioinfo(struct
  135.35  	u16 manufact;
  135.36  	u16 version;
  135.37  	u8 revision;
  135.38 -	s8 i;
  135.39  
  135.40  	if (bcm->chip_id == 0x4317) {
  135.41  		if (bcm->chip_rev == 0x00)
  135.42 @@ -580,20 +576,11 @@ static int bcm43xx_read_radioinfo(struct
  135.43  	radio->version = version;
  135.44  	radio->revision = revision;
  135.45  
  135.46 -	/* Set default attenuation values. */
  135.47 -	radio->baseband_atten = bcm43xx_default_baseband_attenuation(bcm);
  135.48 -	radio->radio_atten = bcm43xx_default_radio_attenuation(bcm);
  135.49 -	radio->txctl1 = bcm43xx_default_txctl1(bcm);
  135.50 -	radio->txctl2 = 0xFFFF;
  135.51  	if (phy->type == BCM43xx_PHYTYPE_A)
  135.52  		radio->txpower_desired = bcm->sprom.maxpower_aphy;
  135.53  	else
  135.54  		radio->txpower_desired = bcm->sprom.maxpower_bgphy;
  135.55  
  135.56 -	/* Initialize the in-memory nrssi Lookup Table. */
  135.57 -	for (i = 0; i < 64; i++)
  135.58 -		radio->nrssi_lt[i] = i;
  135.59 -
  135.60  	return 0;
  135.61  
  135.62  err_unsupported_radio:
  135.63 @@ -1250,10 +1237,6 @@ int bcm43xx_switch_core(struct bcm43xx_p
  135.64  		goto out;
  135.65  
  135.66  	bcm->current_core = new_core;
  135.67 -	bcm->current_80211_core_idx = -1;
  135.68 -	if (new_core->id == BCM43xx_COREID_80211)
  135.69 -		bcm->current_80211_core_idx = (int)(new_core - &(bcm->core_80211[0]));
  135.70 -
  135.71  out:
  135.72  	return err;
  135.73  }
  135.74 @@ -1389,6 +1372,7 @@ void bcm43xx_wireless_core_reset(struct 
  135.75  	if ((bcm43xx_core_enabled(bcm)) &&
  135.76  	    !bcm43xx_using_pio(bcm)) {
  135.77  //FIXME: Do we _really_ want #ifndef CONFIG_BCM947XX here?
  135.78 +#if 0
  135.79  #ifndef CONFIG_BCM947XX
  135.80  		/* reset all used DMA controllers. */
  135.81  		bcm43xx_dmacontroller_tx_reset(bcm, BCM43xx_MMIO_DMA1_BASE);
  135.82 @@ -1399,6 +1383,7 @@ void bcm43xx_wireless_core_reset(struct 
  135.83  		if (bcm->current_core->rev < 5)
  135.84  			bcm43xx_dmacontroller_rx_reset(bcm, BCM43xx_MMIO_DMA4_BASE);
  135.85  #endif
  135.86 +#endif
  135.87  	}
  135.88  	if (bcm43xx_status(bcm) == BCM43xx_STAT_SHUTTINGDOWN) {
  135.89  		bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD,
  135.90 @@ -1423,43 +1408,23 @@ static void bcm43xx_wireless_core_disabl
  135.91  	bcm43xx_core_disable(bcm, 0);
  135.92  }
  135.93  
  135.94 -/* Mark the current 80211 core inactive.
  135.95 - * "active_80211_core" is the other 80211 core, which is used.
  135.96 - */
  135.97 -static int bcm43xx_wireless_core_mark_inactive(struct bcm43xx_private *bcm,
  135.98 -					       struct bcm43xx_coreinfo *active_80211_core)
  135.99 +/* Mark the current 80211 core inactive. */
 135.100 +static void bcm43xx_wireless_core_mark_inactive(struct bcm43xx_private *bcm)
 135.101  {
 135.102  	u32 sbtmstatelow;
 135.103 -	struct bcm43xx_coreinfo *old_core;
 135.104 -	int err = 0;
 135.105  
 135.106  	bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
 135.107  	bcm43xx_radio_turn_off(bcm);
 135.108  	sbtmstatelow = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW);
 135.109 -	sbtmstatelow &= ~0x200a0000;
 135.110 -	sbtmstatelow |= 0xa0000;
 135.111 +	sbtmstatelow &= 0xDFF5FFFF;
 135.112 +	sbtmstatelow |= 0x000A0000;
 135.113  	bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow);
 135.114  	udelay(1);
 135.115  	sbtmstatelow = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW);
 135.116 -	sbtmstatelow &= ~0xa0000;
 135.117 -	sbtmstatelow |= 0x80000;
 135.118 +	sbtmstatelow &= 0xFFF5FFFF;
 135.119 +	sbtmstatelow |= 0x00080000;
 135.120  	bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow);
 135.121  	udelay(1);
 135.122 -
 135.123 -	if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_G) {
 135.124 -		old_core = bcm->current_core;
 135.125 -		err = bcm43xx_switch_core(bcm, active_80211_core);
 135.126 -		if (err)
 135.127 -			goto out;
 135.128 -		sbtmstatelow = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW);
 135.129 -		sbtmstatelow &= ~0x20000000;
 135.130 -		sbtmstatelow |= 0x20000000;
 135.131 -		bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow);
 135.132 -		err = bcm43xx_switch_core(bcm, old_core);
 135.133 -	}
 135.134 -
 135.135 -out:
 135.136 -	return err;
 135.137  }
 135.138  
 135.139  static void handle_irq_transmit_status(struct bcm43xx_private *bcm)
 135.140 @@ -1484,12 +1449,10 @@ static void handle_irq_transmit_status(s
 135.141  
 135.142  		bcm43xx_debugfs_log_txstat(bcm, &stat);
 135.143  
 135.144 -		if (stat.flags & BCM43xx_TXSTAT_FLAG_IGNORE)
 135.145 +		if (stat.flags & BCM43xx_TXSTAT_FLAG_AMPDU)
 135.146  			continue;
 135.147 -		if (!(stat.flags & BCM43xx_TXSTAT_FLAG_ACK)) {
 135.148 -			//TODO: packet was not acked (was lost)
 135.149 -		}
 135.150 -		//TODO: There are more (unknown) flags to test. see bcm43xx_main.h
 135.151 +		if (stat.flags & BCM43xx_TXSTAT_FLAG_INTER)
 135.152 +			continue;
 135.153  
 135.154  		if (bcm43xx_using_pio(bcm))
 135.155  			bcm43xx_pio_handle_xmitstatus(bcm, &stat);
 135.156 @@ -1498,6 +1461,23 @@ static void handle_irq_transmit_status(s
 135.157  	}
 135.158  }
 135.159  
 135.160 +static void drain_txstatus_queue(struct bcm43xx_private *bcm)
 135.161 +{
 135.162 +	u32 dummy;
 135.163 +
 135.164 +	if (bcm->current_core->rev < 5)
 135.165 +		return;
 135.166 +	/* Read all entries from the microcode TXstatus FIFO
 135.167 +	 * and throw them away.
 135.168 +	 */
 135.169 +	while (1) {
 135.170 +		dummy = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_0);
 135.171 +		if (!dummy)
 135.172 +			break;
 135.173 +		dummy = bcm43xx_read32(bcm, BCM43xx_MMIO_XMITSTAT_1);
 135.174 +	}
 135.175 +}
 135.176 +
 135.177  static void bcm43xx_generate_noise_sample(struct bcm43xx_private *bcm)
 135.178  {
 135.179  	bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x408, 0x7F7F);
 135.180 @@ -1581,17 +1561,7 @@ static void handle_irq_noise(struct bcm4
 135.181  		else
 135.182  			average -= 48;
 135.183  
 135.184 -/* FIXME: This is wrong, but people want fancy stats. well... */
 135.185 -bcm->stats.noise = average;
 135.186 -		if (average > -65)
 135.187 -			bcm->stats.link_quality = 0;
 135.188 -		else if (average > -75)
 135.189 -			bcm->stats.link_quality = 1;
 135.190 -		else if (average > -85)
 135.191 -			bcm->stats.link_quality = 2;
 135.192 -		else
 135.193 -			bcm->stats.link_quality = 3;
 135.194 -//		dprintk(KERN_INFO PFX "Link Quality: %u (avg was %d)\n", bcm->stats.link_quality, average);
 135.195 +		bcm->stats.noise = average;
 135.196  drop_calculation:
 135.197  		bcm->noisecalc.calculation_running = 0;
 135.198  		return;
 135.199 @@ -1709,8 +1679,9 @@ static void handle_irq_beacon(struct bcm
 135.200  static void bcm43xx_interrupt_tasklet(struct bcm43xx_private *bcm)
 135.201  {
 135.202  	u32 reason;
 135.203 -	u32 dma_reason[4];
 135.204 -	int activity = 0;
 135.205 +	u32 dma_reason[6];
 135.206 +	u32 merged_dma_reason = 0;
 135.207 +	int i, activity = 0;
 135.208  	unsigned long flags;
 135.209  
 135.210  #ifdef CONFIG_BCM43XX_DEBUG
 135.211 @@ -1720,12 +1691,12 @@ static void bcm43xx_interrupt_tasklet(st
 135.212  # define bcmirq_handled(irq)	do { /* nothing */ } while (0)
 135.213  #endif /* CONFIG_BCM43XX_DEBUG*/
 135.214  
 135.215 -	bcm43xx_lock_irqonly(bcm, flags);
 135.216 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 135.217  	reason = bcm->irq_reason;
 135.218 -	dma_reason[0] = bcm->dma_reason[0];
 135.219 -	dma_reason[1] = bcm->dma_reason[1];
 135.220 -	dma_reason[2] = bcm->dma_reason[2];
 135.221 -	dma_reason[3] = bcm->dma_reason[3];
 135.222 +	for (i = 5; i >= 0; i--) {
 135.223 +		dma_reason[i] = bcm->dma_reason[i];
 135.224 +		merged_dma_reason |= dma_reason[i];
 135.225 +	}
 135.226  
 135.227  	if (unlikely(reason & BCM43xx_IRQ_XMIT_ERROR)) {
 135.228  		/* TX error. We get this when Template Ram is written in wrong endianess
 135.229 @@ -1736,27 +1707,25 @@ static void bcm43xx_interrupt_tasklet(st
 135.230  		printkl(KERN_ERR PFX "FATAL ERROR: BCM43xx_IRQ_XMIT_ERROR\n");
 135.231  		bcmirq_handled(BCM43xx_IRQ_XMIT_ERROR);
 135.232  	}
 135.233 -	if (unlikely((dma_reason[0] & BCM43xx_DMAIRQ_FATALMASK) |
 135.234 -		     (dma_reason[1] & BCM43xx_DMAIRQ_FATALMASK) |
 135.235 -		     (dma_reason[2] & BCM43xx_DMAIRQ_FATALMASK) |
 135.236 -		     (dma_reason[3] & BCM43xx_DMAIRQ_FATALMASK))) {
 135.237 +	if (unlikely(merged_dma_reason & BCM43xx_DMAIRQ_FATALMASK)) {
 135.238  		printkl(KERN_ERR PFX "FATAL ERROR: Fatal DMA error: "
 135.239 -				     "0x%08X, 0x%08X, 0x%08X, 0x%08X\n",
 135.240 +				     "0x%08X, 0x%08X, 0x%08X, "
 135.241 +				     "0x%08X, 0x%08X, 0x%08X\n",
 135.242  		        dma_reason[0], dma_reason[1],
 135.243 -			dma_reason[2], dma_reason[3]);
 135.244 +			dma_reason[2], dma_reason[3],
 135.245 +			dma_reason[4], dma_reason[5]);
 135.246  		bcm43xx_controller_restart(bcm, "DMA error");
 135.247  		mmiowb();
 135.248 -		bcm43xx_unlock_irqonly(bcm, flags);
 135.249 +		spin_unlock_irqrestore(&bcm->irq_lock, flags);
 135.250  		return;
 135.251  	}
 135.252 -	if (unlikely((dma_reason[0] & BCM43xx_DMAIRQ_NONFATALMASK) |
 135.253 -		     (dma_reason[1] & BCM43xx_DMAIRQ_NONFATALMASK) |
 135.254 -		     (dma_reason[2] & BCM43xx_DMAIRQ_NONFATALMASK) |
 135.255 -		     (dma_reason[3] & BCM43xx_DMAIRQ_NONFATALMASK))) {
 135.256 +	if (unlikely(merged_dma_reason & BCM43xx_DMAIRQ_NONFATALMASK)) {
 135.257  		printkl(KERN_ERR PFX "DMA error: "
 135.258 -				     "0x%08X, 0x%08X, 0x%08X, 0x%08X\n",
 135.259 +				     "0x%08X, 0x%08X, 0x%08X, "
 135.260 +				     "0x%08X, 0x%08X, 0x%08X\n",
 135.261  		        dma_reason[0], dma_reason[1],
 135.262 -			dma_reason[2], dma_reason[3]);
 135.263 +			dma_reason[2], dma_reason[3],
 135.264 +			dma_reason[4], dma_reason[5]);
 135.265  	}
 135.266  
 135.267  	if (reason & BCM43xx_IRQ_PS) {
 135.268 @@ -1791,8 +1760,6 @@ static void bcm43xx_interrupt_tasklet(st
 135.269  	}
 135.270  
 135.271  	/* Check the DMA reason registers for received data. */
 135.272 -	assert(!(dma_reason[1] & BCM43xx_DMAIRQ_RX_DONE));
 135.273 -	assert(!(dma_reason[2] & BCM43xx_DMAIRQ_RX_DONE));
 135.274  	if (dma_reason[0] & BCM43xx_DMAIRQ_RX_DONE) {
 135.275  		if (bcm43xx_using_pio(bcm))
 135.276  			bcm43xx_pio_rx(bcm43xx_current_pio(bcm)->queue0);
 135.277 @@ -1800,13 +1767,17 @@ static void bcm43xx_interrupt_tasklet(st
 135.278  			bcm43xx_dma_rx(bcm43xx_current_dma(bcm)->rx_ring0);
 135.279  		/* We intentionally don't set "activity" to 1, here. */
 135.280  	}
 135.281 +	assert(!(dma_reason[1] & BCM43xx_DMAIRQ_RX_DONE));
 135.282 +	assert(!(dma_reason[2] & BCM43xx_DMAIRQ_RX_DONE));
 135.283  	if (dma_reason[3] & BCM43xx_DMAIRQ_RX_DONE) {
 135.284  		if (bcm43xx_using_pio(bcm))
 135.285  			bcm43xx_pio_rx(bcm43xx_current_pio(bcm)->queue3);
 135.286  		else
 135.287 -			bcm43xx_dma_rx(bcm43xx_current_dma(bcm)->rx_ring1);
 135.288 +			bcm43xx_dma_rx(bcm43xx_current_dma(bcm)->rx_ring3);
 135.289  		activity = 1;
 135.290  	}
 135.291 +	assert(!(dma_reason[4] & BCM43xx_DMAIRQ_RX_DONE));
 135.292 +	assert(!(dma_reason[5] & BCM43xx_DMAIRQ_RX_DONE));
 135.293  	bcmirq_handled(BCM43xx_IRQ_RX);
 135.294  
 135.295  	if (reason & BCM43xx_IRQ_XMIT_STATUS) {
 135.296 @@ -1834,7 +1805,7 @@ static void bcm43xx_interrupt_tasklet(st
 135.297  		bcm43xx_leds_update(bcm, activity);
 135.298  	bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate);
 135.299  	mmiowb();
 135.300 -	bcm43xx_unlock_irqonly(bcm, flags);
 135.301 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 135.302  }
 135.303  
 135.304  static void pio_irq_workaround(struct bcm43xx_private *bcm,
 135.305 @@ -1863,14 +1834,18 @@ static void bcm43xx_interrupt_ack(struct
 135.306  
 135.307  	bcm43xx_write32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON, reason);
 135.308  
 135.309 +	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA0_REASON,
 135.310 +			bcm->dma_reason[0]);
 135.311  	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA1_REASON,
 135.312 -			bcm->dma_reason[0]);
 135.313 -	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA2_REASON,
 135.314  			bcm->dma_reason[1]);
 135.315 -	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA3_REASON,
 135.316 +	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA2_REASON,
 135.317  			bcm->dma_reason[2]);
 135.318 +	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA3_REASON,
 135.319 +			bcm->dma_reason[3]);
 135.320  	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA4_REASON,
 135.321 -			bcm->dma_reason[3]);
 135.322 +			bcm->dma_reason[4]);
 135.323 +	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA5_REASON,
 135.324 +			bcm->dma_reason[5]);
 135.325  }
 135.326  
 135.327  /* Interrupt handler top-half */
 135.328 @@ -1885,14 +1860,8 @@ static irqreturn_t bcm43xx_interrupt_han
 135.329  
 135.330  	spin_lock(&bcm->irq_lock);
 135.331  
 135.332 -	/* Only accept IRQs, if we are initialized properly.
 135.333 -	 * This avoids an RX race while initializing.
 135.334 -	 * We should probably not enable IRQs before we are initialized
 135.335 -	 * completely, but some careful work is needed to fix this. I think it
 135.336 -	 * is best to stay with this cheap workaround for now... .
 135.337 -	 */
 135.338 -	if (unlikely(bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED))
 135.339 -		goto out;
 135.340 +	assert(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);
 135.341 +	assert(bcm->current_core->id == BCM43xx_COREID_80211);
 135.342  
 135.343  	reason = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
 135.344  	if (reason == 0xffffffff) {
 135.345 @@ -1904,14 +1873,18 @@ static irqreturn_t bcm43xx_interrupt_han
 135.346  	if (!reason)
 135.347  		goto out;
 135.348  
 135.349 -	bcm->dma_reason[0] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA1_REASON)
 135.350 -			     & 0x0001dc00;
 135.351 -	bcm->dma_reason[1] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA2_REASON)
 135.352 -			     & 0x0000dc00;
 135.353 -	bcm->dma_reason[2] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA3_REASON)
 135.354 -			     & 0x0000dc00;
 135.355 -	bcm->dma_reason[3] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA4_REASON)
 135.356 -			     & 0x0001dc00;
 135.357 +	bcm->dma_reason[0] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA0_REASON)
 135.358 +			     & 0x0001DC00;
 135.359 +	bcm->dma_reason[1] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA1_REASON)
 135.360 +			     & 0x0000DC00;
 135.361 +	bcm->dma_reason[2] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA2_REASON)
 135.362 +			     & 0x0000DC00;
 135.363 +	bcm->dma_reason[3] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA3_REASON)
 135.364 +			     & 0x0001DC00;
 135.365 +	bcm->dma_reason[4] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA4_REASON)
 135.366 +			     & 0x0000DC00;
 135.367 +	bcm->dma_reason[5] = bcm43xx_read32(bcm, BCM43xx_MMIO_DMA5_REASON)
 135.368 +			     & 0x0000DC00;
 135.369  
 135.370  	bcm43xx_interrupt_ack(bcm, reason);
 135.371  
 135.372 @@ -1930,16 +1903,18 @@ out:
 135.373  
 135.374  static void bcm43xx_release_firmware(struct bcm43xx_private *bcm, int force)
 135.375  {
 135.376 +	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
 135.377 +
 135.378  	if (bcm->firmware_norelease && !force)
 135.379  		return; /* Suspending or controller reset. */
 135.380 -	release_firmware(bcm->ucode);
 135.381 -	bcm->ucode = NULL;
 135.382 -	release_firmware(bcm->pcm);
 135.383 -	bcm->pcm = NULL;
 135.384 -	release_firmware(bcm->initvals0);
 135.385 -	bcm->initvals0 = NULL;
 135.386 -	release_firmware(bcm->initvals1);
 135.387 -	bcm->initvals1 = NULL;
 135.388 +	release_firmware(phy->ucode);
 135.389 +	phy->ucode = NULL;
 135.390 +	release_firmware(phy->pcm);
 135.391 +	phy->pcm = NULL;
 135.392 +	release_firmware(phy->initvals0);
 135.393 +	phy->initvals0 = NULL;
 135.394 +	release_firmware(phy->initvals1);
 135.395 +	phy->initvals1 = NULL;
 135.396  }
 135.397  
 135.398  static int bcm43xx_request_firmware(struct bcm43xx_private *bcm)
 135.399 @@ -1950,11 +1925,11 @@ static int bcm43xx_request_firmware(stru
 135.400  	int nr;
 135.401  	char buf[22 + sizeof(modparam_fwpostfix) - 1] = { 0 };
 135.402  
 135.403 -	if (!bcm->ucode) {
 135.404 +	if (!phy->ucode) {
 135.405  		snprintf(buf, ARRAY_SIZE(buf), "bcm43xx_microcode%d%s.fw",
 135.406  			 (rev >= 5 ? 5 : rev),
 135.407  			 modparam_fwpostfix);
 135.408 -		err = request_firmware(&bcm->ucode, buf, &bcm->pci_dev->dev);
 135.409 +		err = request_firmware(&phy->ucode, buf, &bcm->pci_dev->dev);
 135.410  		if (err) {
 135.411  			printk(KERN_ERR PFX 
 135.412  			       "Error: Microcode \"%s\" not available or load failed.\n",
 135.413 @@ -1963,12 +1938,12 @@ static int bcm43xx_request_firmware(stru
 135.414  		}
 135.415  	}
 135.416  
 135.417 -	if (!bcm->pcm) {
 135.418 +	if (!phy->pcm) {
 135.419  		snprintf(buf, ARRAY_SIZE(buf),
 135.420  			 "bcm43xx_pcm%d%s.fw",
 135.421  			 (rev < 5 ? 4 : 5),
 135.422  			 modparam_fwpostfix);
 135.423 -		err = request_firmware(&bcm->pcm, buf, &bcm->pci_dev->dev);
 135.424 +		err = request_firmware(&phy->pcm, buf, &bcm->pci_dev->dev);
 135.425  		if (err) {
 135.426  			printk(KERN_ERR PFX
 135.427  			       "Error: PCM \"%s\" not available or load failed.\n",
 135.428 @@ -1977,7 +1952,7 @@ static int bcm43xx_request_firmware(stru
 135.429  		}
 135.430  	}
 135.431  
 135.432 -	if (!bcm->initvals0) {
 135.433 +	if (!phy->initvals0) {
 135.434  		if (rev == 2 || rev == 4) {
 135.435  			switch (phy->type) {
 135.436  			case BCM43xx_PHYTYPE_A:
 135.437 @@ -2008,20 +1983,20 @@ static int bcm43xx_request_firmware(stru
 135.438  		snprintf(buf, ARRAY_SIZE(buf), "bcm43xx_initval%02d%s.fw",
 135.439  			 nr, modparam_fwpostfix);
 135.440  
 135.441 -		err = request_firmware(&bcm->initvals0, buf, &bcm->pci_dev->dev);
 135.442 +		err = request_firmware(&phy->initvals0, buf, &bcm->pci_dev->dev);
 135.443  		if (err) {
 135.444  			printk(KERN_ERR PFX 
 135.445  			       "Error: InitVals \"%s\" not available or load failed.\n",
 135.446  			        buf);
 135.447  			goto error;
 135.448  		}
 135.449 -		if (bcm->initvals0->size % sizeof(struct bcm43xx_initval)) {
 135.450 +		if (phy->initvals0->size % sizeof(struct bcm43xx_initval)) {
 135.451  			printk(KERN_ERR PFX "InitVals fileformat error.\n");
 135.452  			goto error;
 135.453  		}
 135.454  	}
 135.455  
 135.456 -	if (!bcm->initvals1) {
 135.457 +	if (!phy->initvals1) {
 135.458  		if (rev >= 5) {
 135.459  			u32 sbtmstatehigh;
 135.460  
 135.461 @@ -2043,14 +2018,14 @@ static int bcm43xx_request_firmware(stru
 135.462  			snprintf(buf, ARRAY_SIZE(buf), "bcm43xx_initval%02d%s.fw",
 135.463  				 nr, modparam_fwpostfix);
 135.464  
 135.465 -			err = request_firmware(&bcm->initvals1, buf, &bcm->pci_dev->dev);
 135.466 +			err = request_firmware(&phy->initvals1, buf, &bcm->pci_dev->dev);
 135.467  			if (err) {
 135.468  				printk(KERN_ERR PFX 
 135.469  				       "Error: InitVals \"%s\" not available or load failed.\n",
 135.470  			        	buf);
 135.471  				goto error;
 135.472  			}
 135.473 -			if (bcm->initvals1->size % sizeof(struct bcm43xx_initval)) {
 135.474 +			if (phy->initvals1->size % sizeof(struct bcm43xx_initval)) {
 135.475  				printk(KERN_ERR PFX "InitVals fileformat error.\n");
 135.476  				goto error;
 135.477  			}
 135.478 @@ -2070,12 +2045,13 @@ err_noinitval:
 135.479  
 135.480  static void bcm43xx_upload_microcode(struct bcm43xx_private *bcm)
 135.481  {
 135.482 +	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
 135.483  	const u32 *data;
 135.484  	unsigned int i, len;
 135.485  
 135.486  	/* Upload Microcode. */
 135.487 -	data = (u32 *)(bcm->ucode->data);
 135.488 -	len = bcm->ucode->size / sizeof(u32);
 135.489 +	data = (u32 *)(phy->ucode->data);
 135.490 +	len = phy->ucode->size / sizeof(u32);
 135.491  	bcm43xx_shm_control_word(bcm, BCM43xx_SHM_UCODE, 0x0000);
 135.492  	for (i = 0; i < len; i++) {
 135.493  		bcm43xx_write32(bcm, BCM43xx_MMIO_SHM_DATA,
 135.494 @@ -2084,8 +2060,8 @@ static void bcm43xx_upload_microcode(str
 135.495  	}
 135.496  
 135.497  	/* Upload PCM data. */
 135.498 -	data = (u32 *)(bcm->pcm->data);
 135.499 -	len = bcm->pcm->size / sizeof(u32);
 135.500 +	data = (u32 *)(phy->pcm->data);
 135.501 +	len = phy->pcm->size / sizeof(u32);
 135.502  	bcm43xx_shm_control_word(bcm, BCM43xx_SHM_PCM, 0x01ea);
 135.503  	bcm43xx_write32(bcm, BCM43xx_MMIO_SHM_DATA, 0x00004000);
 135.504  	bcm43xx_shm_control_word(bcm, BCM43xx_SHM_PCM, 0x01eb);
 135.505 @@ -2131,15 +2107,16 @@ err_format:
 135.506  
 135.507  static int bcm43xx_upload_initvals(struct bcm43xx_private *bcm)
 135.508  {
 135.509 +	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
 135.510  	int err;
 135.511  
 135.512 -	err = bcm43xx_write_initvals(bcm, (struct bcm43xx_initval *)bcm->initvals0->data,
 135.513 -				     bcm->initvals0->size / sizeof(struct bcm43xx_initval));
 135.514 +	err = bcm43xx_write_initvals(bcm, (struct bcm43xx_initval *)phy->initvals0->data,
 135.515 +				     phy->initvals0->size / sizeof(struct bcm43xx_initval));
 135.516  	if (err)
 135.517  		goto out;
 135.518 -	if (bcm->initvals1) {
 135.519 -		err = bcm43xx_write_initvals(bcm, (struct bcm43xx_initval *)bcm->initvals1->data,
 135.520 -					     bcm->initvals1->size / sizeof(struct bcm43xx_initval));
 135.521 +	if (phy->initvals1) {
 135.522 +		err = bcm43xx_write_initvals(bcm, (struct bcm43xx_initval *)phy->initvals1->data,
 135.523 +					     phy->initvals1->size / sizeof(struct bcm43xx_initval));
 135.524  		if (err)
 135.525  			goto out;
 135.526  	}
 135.527 @@ -2156,9 +2133,7 @@ static struct pci_device_id bcm43xx_47xx
 135.528  
 135.529  static int bcm43xx_initialize_irq(struct bcm43xx_private *bcm)
 135.530  {
 135.531 -	int res;
 135.532 -	unsigned int i;
 135.533 -	u32 data;
 135.534 +	int err;
 135.535  
 135.536  	bcm->irq = bcm->pci_dev->irq;
 135.537  #ifdef CONFIG_BCM947XX
 135.538 @@ -2175,32 +2150,12 @@ static int bcm43xx_initialize_irq(struct
 135.539  		}
 135.540  	}
 135.541  #endif
 135.542 -	res = request_irq(bcm->irq, bcm43xx_interrupt_handler,
 135.543 +	err = request_irq(bcm->irq, bcm43xx_interrupt_handler,
 135.544  			  IRQF_SHARED, KBUILD_MODNAME, bcm);
 135.545 -	if (res) {
 135.546 +	if (err)
 135.547  		printk(KERN_ERR PFX "Cannot register IRQ%d\n", bcm->irq);
 135.548 -		return -ENODEV;
 135.549 -	}
 135.550 -	bcm43xx_write32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON, 0xffffffff);
 135.551 -	bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, 0x00020402);
 135.552 -	i = 0;
 135.553 -	while (1) {
 135.554 -		data = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
 135.555 -		if (data == BCM43xx_IRQ_READY)
 135.556 -			break;
 135.557 -		i++;
 135.558 -		if (i >= BCM43xx_IRQWAIT_MAX_RETRIES) {
 135.559 -			printk(KERN_ERR PFX "Card IRQ register not responding. "
 135.560 -					    "Giving up.\n");
 135.561 -			free_irq(bcm->irq, bcm);
 135.562 -			return -ENODEV;
 135.563 -		}
 135.564 -		udelay(10);
 135.565 -	}
 135.566 -	// dummy read
 135.567 -	bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
 135.568 -
 135.569 -	return 0;
 135.570 +
 135.571 +	return err;
 135.572  }
 135.573  
 135.574  /* Switch to the core used to write the GPIO register.
 135.575 @@ -2298,13 +2253,17 @@ static int bcm43xx_gpio_cleanup(struct b
 135.576  /* http://bcm-specs.sipsolutions.net/EnableMac */
 135.577  void bcm43xx_mac_enable(struct bcm43xx_private *bcm)
 135.578  {
 135.579 -	bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD,
 135.580 -	                bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD)
 135.581 -			| BCM43xx_SBF_MAC_ENABLED);
 135.582 -	bcm43xx_write32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON, BCM43xx_IRQ_READY);
 135.583 -	bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); /* dummy read */
 135.584 -	bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON); /* dummy read */
 135.585 -	bcm43xx_power_saving_ctl_bits(bcm, -1, -1);
 135.586 +	bcm->mac_suspended--;
 135.587 +	assert(bcm->mac_suspended >= 0);
 135.588 +	if (bcm->mac_suspended == 0) {
 135.589 +		bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD,
 135.590 +		                bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD)
 135.591 +				| BCM43xx_SBF_MAC_ENABLED);
 135.592 +		bcm43xx_write32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON, BCM43xx_IRQ_READY);
 135.593 +		bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); /* dummy read */
 135.594 +		bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON); /* dummy read */
 135.595 +		bcm43xx_power_saving_ctl_bits(bcm, -1, -1);
 135.596 +	}
 135.597  }
 135.598  
 135.599  /* http://bcm-specs.sipsolutions.net/SuspendMAC */
 135.600 @@ -2313,18 +2272,23 @@ void bcm43xx_mac_suspend(struct bcm43xx_
 135.601  	int i;
 135.602  	u32 tmp;
 135.603  
 135.604 -	bcm43xx_power_saving_ctl_bits(bcm, -1, 1);
 135.605 -	bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD,
 135.606 -	                bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD)
 135.607 -			& ~BCM43xx_SBF_MAC_ENABLED);
 135.608 -	bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON); /* dummy read */
 135.609 -	for (i = 100000; i; i--) {
 135.610 -		tmp = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
 135.611 -		if (tmp & BCM43xx_IRQ_READY)
 135.612 -			return;
 135.613 -		udelay(10);
 135.614 +	assert(bcm->mac_suspended >= 0);
 135.615 +	if (bcm->mac_suspended == 0) {
 135.616 +		bcm43xx_power_saving_ctl_bits(bcm, -1, 1);
 135.617 +		bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD,
 135.618 +		                bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD)
 135.619 +				& ~BCM43xx_SBF_MAC_ENABLED);
 135.620 +		bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON); /* dummy read */
 135.621 +		for (i = 10000; i; i--) {
 135.622 +			tmp = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
 135.623 +			if (tmp & BCM43xx_IRQ_READY)
 135.624 +				goto out;
 135.625 +			udelay(1);
 135.626 +		}
 135.627 +		printkl(KERN_ERR PFX "MAC suspend failed\n");
 135.628  	}
 135.629 -	printkl(KERN_ERR PFX "MAC suspend failed\n");
 135.630 +out:
 135.631 +	bcm->mac_suspended++;
 135.632  }
 135.633  
 135.634  void bcm43xx_set_iwmode(struct bcm43xx_private *bcm,
 135.635 @@ -2394,7 +2358,6 @@ static void bcm43xx_chip_cleanup(struct 
 135.636  	if (!modparam_noleds)
 135.637  		bcm43xx_leds_exit(bcm);
 135.638  	bcm43xx_gpio_cleanup(bcm);
 135.639 -	free_irq(bcm->irq, bcm);
 135.640  	bcm43xx_release_firmware(bcm, 0);
 135.641  }
 135.642  
 135.643 @@ -2406,7 +2369,7 @@ static int bcm43xx_chip_init(struct bcm4
 135.644  	struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
 135.645  	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
 135.646  	int err;
 135.647 -	int tmp;
 135.648 +	int i, tmp;
 135.649  	u32 value32;
 135.650  	u16 value16;
 135.651  
 135.652 @@ -2419,13 +2382,53 @@ static int bcm43xx_chip_init(struct bcm4
 135.653  		goto out;
 135.654  	bcm43xx_upload_microcode(bcm);
 135.655  
 135.656 -	err = bcm43xx_initialize_irq(bcm);
 135.657 -	if (err)
 135.658 +	bcm43xx_write32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON, 0xFFFFFFFF);
 135.659 +	bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, 0x00020402);
 135.660 +	i = 0;
 135.661 +	while (1) {
 135.662 +		value32 = bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON);
 135.663 +		if (value32 == BCM43xx_IRQ_READY)
 135.664 +			break;
 135.665 +		i++;
 135.666 +		if (i >= BCM43xx_IRQWAIT_MAX_RETRIES) {
 135.667 +			printk(KERN_ERR PFX "IRQ_READY timeout\n");
 135.668 +			err = -ENODEV;
 135.669 +			goto err_release_fw;
 135.670 +		}
 135.671 +		udelay(10);
 135.672 +	}
 135.673 +	bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON); /* dummy read */
 135.674 +
 135.675 +	value16 = bcm43xx_shm_read16(bcm, BCM43xx_SHM_SHARED,
 135.676 +				     BCM43xx_UCODE_REVISION);
 135.677 +
 135.678 +	dprintk(KERN_INFO PFX "Microcode rev 0x%x, pl 0x%x "
 135.679 +		"(20%.2i-%.2i-%.2i  %.2i:%.2i:%.2i)\n", value16,
 135.680 +		bcm43xx_shm_read16(bcm, BCM43xx_SHM_SHARED,
 135.681 +				   BCM43xx_UCODE_PATCHLEVEL),
 135.682 +		(bcm43xx_shm_read16(bcm, BCM43xx_SHM_SHARED,
 135.683 +				    BCM43xx_UCODE_DATE) >> 12) & 0xf,
 135.684 +		(bcm43xx_shm_read16(bcm, BCM43xx_SHM_SHARED,
 135.685 +				    BCM43xx_UCODE_DATE) >> 8) & 0xf,
 135.686 +		bcm43xx_shm_read16(bcm, BCM43xx_SHM_SHARED,
 135.687 +				   BCM43xx_UCODE_DATE) & 0xff,
 135.688 +		(bcm43xx_shm_read16(bcm, BCM43xx_SHM_SHARED,
 135.689 +				   BCM43xx_UCODE_TIME) >> 11) & 0x1f,
 135.690 +		(bcm43xx_shm_read16(bcm, BCM43xx_SHM_SHARED,
 135.691 +				   BCM43xx_UCODE_TIME) >> 5) & 0x3f,
 135.692 +		bcm43xx_shm_read16(bcm, BCM43xx_SHM_SHARED,
 135.693 +				   BCM43xx_UCODE_TIME) & 0x1f);
 135.694 +
 135.695 +	if ( value16 > 0x128 ) {
 135.696 +		dprintk(KERN_ERR PFX
 135.697 +			"Firmware: no support for microcode rev > 0x128\n");
 135.698 +		err = -1;
 135.699  		goto err_release_fw;
 135.700 +	}
 135.701  
 135.702  	err = bcm43xx_gpio_init(bcm);
 135.703  	if (err)
 135.704 -		goto err_free_irq;
 135.705 +		goto err_release_fw;
 135.706  
 135.707  	err = bcm43xx_upload_initvals(bcm);
 135.708  	if (err)
 135.709 @@ -2489,10 +2492,12 @@ static int bcm43xx_chip_init(struct bcm4
 135.710  		bcm43xx_write32(bcm, 0x018C, 0x02000000);
 135.711  	}
 135.712  	bcm43xx_write32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON, 0x00004000);
 135.713 -	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA1_IRQ_MASK, 0x0001DC00);
 135.714 +	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA0_IRQ_MASK, 0x0001DC00);
 135.715 +	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA1_IRQ_MASK, 0x0000DC00);
 135.716  	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA2_IRQ_MASK, 0x0000DC00);
 135.717 -	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA3_IRQ_MASK, 0x0000DC00);
 135.718 -	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA4_IRQ_MASK, 0x0001DC00);
 135.719 +	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA3_IRQ_MASK, 0x0001DC00);
 135.720 +	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA4_IRQ_MASK, 0x0000DC00);
 135.721 +	bcm43xx_write32(bcm, BCM43xx_MMIO_DMA5_IRQ_MASK, 0x0000DC00);
 135.722  
 135.723  	value32 = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW);
 135.724  	value32 |= 0x00100000;
 135.725 @@ -2509,8 +2514,6 @@ err_radio_off:
 135.726  	bcm43xx_radio_turn_off(bcm);
 135.727  err_gpio_cleanup:
 135.728  	bcm43xx_gpio_cleanup(bcm);
 135.729 -err_free_irq:
 135.730 -	free_irq(bcm->irq, bcm);
 135.731  err_release_fw:
 135.732  	bcm43xx_release_firmware(bcm, 1);
 135.733  	goto out;
 135.734 @@ -2550,11 +2553,9 @@ static void bcm43xx_init_struct_phyinfo(
 135.735  {
 135.736  	/* Initialize a "phyinfo" structure. The structure is already
 135.737  	 * zeroed out.
 135.738 +	 * This is called on insmod time to initialize members.
 135.739  	 */
 135.740 -	phy->antenna_diversity = 0xFFFF;
 135.741  	phy->savedpctlreg = 0xFFFF;
 135.742 -	phy->minlowsig[0] = 0xFFFF;
 135.743 -	phy->minlowsig[1] = 0xFFFF;
 135.744  	spin_lock_init(&phy->lock);
 135.745  }
 135.746  
 135.747 @@ -2562,14 +2563,11 @@ static void bcm43xx_init_struct_radioinf
 135.748  {
 135.749  	/* Initialize a "radioinfo" structure. The structure is already
 135.750  	 * zeroed out.
 135.751 +	 * This is called on insmod time to initialize members.
 135.752  	 */
 135.753  	radio->interfmode = BCM43xx_RADIO_INTERFMODE_NONE;
 135.754  	radio->channel = 0xFF;
 135.755  	radio->initial_channel = 0xFF;
 135.756 -	radio->lofcal = 0xFFFF;
 135.757 -	radio->initval = 0xFFFF;
 135.758 -	radio->nrssi[0] = -1000;
 135.759 -	radio->nrssi[1] = -1000;
 135.760  }
 135.761  
 135.762  static int bcm43xx_probe_cores(struct bcm43xx_private *bcm)
 135.763 @@ -2587,7 +2585,6 @@ static int bcm43xx_probe_cores(struct bc
 135.764  				    * BCM43xx_MAX_80211_CORES);
 135.765  	memset(&bcm->core_80211_ext, 0, sizeof(struct bcm43xx_coreinfo_80211)
 135.766  					* BCM43xx_MAX_80211_CORES);
 135.767 -	bcm->current_80211_core_idx = -1;
 135.768  	bcm->nr_80211_available = 0;
 135.769  	bcm->current_core = NULL;
 135.770  	bcm->active_80211_core = NULL;
 135.771 @@ -2757,6 +2754,7 @@ static int bcm43xx_probe_cores(struct bc
 135.772  				goto out;
 135.773  			}
 135.774  			bcm->nr_80211_available++;
 135.775 +			core->priv = ext_80211;
 135.776  			bcm43xx_init_struct_phyinfo(&ext_80211->phy);
 135.777  			bcm43xx_init_struct_radioinfo(&ext_80211->radio);
 135.778  			break;
 135.779 @@ -2857,7 +2855,8 @@ static void bcm43xx_wireless_core_cleanu
 135.780  }
 135.781  
 135.782  /* http://bcm-specs.sipsolutions.net/80211Init */
 135.783 -static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm)
 135.784 +static int bcm43xx_wireless_core_init(struct bcm43xx_private *bcm,
 135.785 +				      int active_wlcore)
 135.786  {
 135.787  	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
 135.788  	struct bcm43xx_radioinfo *radio = bcm43xx_current_radio(bcm);
 135.789 @@ -2939,19 +2938,26 @@ static int bcm43xx_wireless_core_init(st
 135.790  	if (bcm->current_core->rev >= 5)
 135.791  		bcm43xx_write16(bcm, 0x043C, 0x000C);
 135.792  
 135.793 -	if (bcm43xx_using_pio(bcm))
 135.794 -		err = bcm43xx_pio_init(bcm);
 135.795 -	else
 135.796 -		err = bcm43xx_dma_init(bcm);
 135.797 -	if (err)
 135.798 -		goto err_chip_cleanup;
 135.799 +	if (active_wlcore) {
 135.800 +		if (bcm43xx_using_pio(bcm))
 135.801 +			err = bcm43xx_pio_init(bcm);
 135.802 +		else
 135.803 +			err = bcm43xx_dma_init(bcm);
 135.804 +		if (err)
 135.805 +			goto err_chip_cleanup;
 135.806 +	}
 135.807  	bcm43xx_write16(bcm, 0x0612, 0x0050);
 135.808  	bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x0416, 0x0050);
 135.809  	bcm43xx_shm_write16(bcm, BCM43xx_SHM_SHARED, 0x0414, 0x01F4);
 135.810  
 135.811 -	bcm43xx_mac_enable(bcm);
 135.812 -	bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate);
 135.813 -
 135.814 +	if (active_wlcore) {
 135.815 +		if (radio->initial_channel != 0xFF)
 135.816 +			bcm43xx_radio_selectchannel(bcm, radio->initial_channel, 0);
 135.817 +	}
 135.818 +
 135.819 +	/* Don't enable MAC/IRQ here, as it will race with the IRQ handler.
 135.820 +	 * We enable it later.
 135.821 +	 */
 135.822  	bcm->current_core->initialized = 1;
 135.823  out:
 135.824  	return err;
 135.825 @@ -3066,11 +3072,6 @@ out:
 135.826  	return err;
 135.827  }
 135.828  
 135.829 -static void bcm43xx_softmac_init(struct bcm43xx_private *bcm)
 135.830 -{
 135.831 -	ieee80211softmac_start(bcm->net_dev);
 135.832 -}
 135.833 -
 135.834  static void bcm43xx_periodic_every120sec(struct bcm43xx_private *bcm)
 135.835  {
 135.836  	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
 135.837 @@ -3178,51 +3179,51 @@ static void bcm43xx_periodic_work_handle
 135.838  	int badness;
 135.839  
 135.840  	badness = estimate_periodic_work_badness(bcm->periodic_state);
 135.841 +	mutex_lock(&bcm->mutex);
 135.842 +
 135.843 +	/* We must fake a started transmission here, as we are going to
 135.844 +	 * disable TX. If we wouldn't fake a TX, it would be possible to
 135.845 +	 * trigger the netdev watchdog, if the last real TX is already
 135.846 +	 * some time on the past (slightly less than 5secs)
 135.847 +	 */
 135.848 +	bcm->net_dev->trans_start = jiffies;
 135.849 +	netif_tx_disable(bcm->net_dev);
 135.850 +
 135.851 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 135.852  	if (badness > BADNESS_LIMIT) {
 135.853  		/* Periodic work will take a long time, so we want it to
 135.854  		 * be preemtible.
 135.855  		 */
 135.856 -		bcm43xx_lock_irqonly(bcm, flags);
 135.857 -		netif_stop_queue(bcm->net_dev);
 135.858 +		bcm43xx_mac_suspend(bcm);
 135.859  		if (bcm43xx_using_pio(bcm))
 135.860  			bcm43xx_pio_freeze_txqueues(bcm);
 135.861  		savedirqs = bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
 135.862 -		bcm43xx_unlock_irqonly(bcm, flags);
 135.863 -		bcm43xx_lock_noirq(bcm);
 135.864 +		spin_unlock_irqrestore(&bcm->irq_lock, flags);
 135.865  		bcm43xx_synchronize_irq(bcm);
 135.866 -	} else {
 135.867 -		/* Periodic work should take short time, so we want low
 135.868 -		 * locking overhead.
 135.869 -		 */
 135.870 -		bcm43xx_lock_irqsafe(bcm, flags);
 135.871  	}
 135.872  
 135.873  	do_periodic_work(bcm);
 135.874  
 135.875  	if (badness > BADNESS_LIMIT) {
 135.876 -		bcm43xx_lock_irqonly(bcm, flags);
 135.877 -		if (likely(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED)) {
 135.878 -			tasklet_enable(&bcm->isr_tasklet);
 135.879 -			bcm43xx_interrupt_enable(bcm, savedirqs);
 135.880 -			if (bcm43xx_using_pio(bcm))
 135.881 -				bcm43xx_pio_thaw_txqueues(bcm);
 135.882 -		}
 135.883 -		netif_wake_queue(bcm->net_dev);
 135.884 -		mmiowb();
 135.885 -		bcm43xx_unlock_irqonly(bcm, flags);
 135.886 -		bcm43xx_unlock_noirq(bcm);
 135.887 -	} else {
 135.888 -		mmiowb();
 135.889 -		bcm43xx_unlock_irqsafe(bcm, flags);
 135.890 +		spin_lock_irqsave(&bcm->irq_lock, flags);
 135.891 +		tasklet_enable(&bcm->isr_tasklet);
 135.892 +		bcm43xx_interrupt_enable(bcm, savedirqs);
 135.893 +		if (bcm43xx_using_pio(bcm))
 135.894 +			bcm43xx_pio_thaw_txqueues(bcm);
 135.895 +		bcm43xx_mac_enable(bcm);
 135.896  	}
 135.897 +	mmiowb();
 135.898 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 135.899 +	netif_wake_queue(bcm->net_dev);
 135.900 +	mutex_unlock(&bcm->mutex);
 135.901  }
 135.902  
 135.903 -static void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm)
 135.904 +void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm)
 135.905  {
 135.906  	cancel_rearming_delayed_work(&bcm->periodic_work);
 135.907  }
 135.908  
 135.909 -static void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm)
 135.910 +void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm)
 135.911  {
 135.912  	struct work_struct *work = &(bcm->periodic_work);
 135.913  
 135.914 @@ -3243,9 +3244,9 @@ static int bcm43xx_rng_read(struct hwrng
 135.915  	struct bcm43xx_private *bcm = (struct bcm43xx_private *)rng->priv;
 135.916  	unsigned long flags;
 135.917  
 135.918 -	bcm43xx_lock_irqonly(bcm, flags);
 135.919 +	spin_lock_irqsave(&(bcm)->irq_lock, flags);
 135.920  	*data = bcm43xx_read16(bcm, BCM43xx_MMIO_RNG);
 135.921 -	bcm43xx_unlock_irqonly(bcm, flags);
 135.922 +	spin_unlock_irqrestore(&(bcm)->irq_lock, flags);
 135.923  
 135.924  	return (sizeof(u16));
 135.925  }
 135.926 @@ -3271,139 +3272,330 @@ static int bcm43xx_rng_init(struct bcm43
 135.927  	return err;
 135.928  }
 135.929  
 135.930 +static int bcm43xx_shutdown_all_wireless_cores(struct bcm43xx_private *bcm)
 135.931 +{
 135.932 +	int ret = 0;
 135.933 +	int i, err;
 135.934 +	struct bcm43xx_coreinfo *core;
 135.935 +
 135.936 +	bcm43xx_set_status(bcm, BCM43xx_STAT_SHUTTINGDOWN);
 135.937 +	for (i = 0; i < bcm->nr_80211_available; i++) {
 135.938 +		core = &(bcm->core_80211[i]);
 135.939 +		assert(core->available);
 135.940 +		if (!core->initialized)
 135.941 +			continue;
 135.942 +		err = bcm43xx_switch_core(bcm, core);
 135.943 +		if (err) {
 135.944 +			dprintk(KERN_ERR PFX "shutdown_all_wireless_cores "
 135.945 +					     "switch_core failed (%d)\n", err);
 135.946 +			ret = err;
 135.947 +			continue;
 135.948 +		}
 135.949 +		bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
 135.950 +		bcm43xx_read32(bcm, BCM43xx_MMIO_GEN_IRQ_REASON); /* dummy read */
 135.951 +		bcm43xx_wireless_core_cleanup(bcm);
 135.952 +		if (core == bcm->active_80211_core)
 135.953 +			bcm->active_80211_core = NULL;
 135.954 +	}
 135.955 +	free_irq(bcm->irq, bcm);
 135.956 +	bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT);
 135.957 +
 135.958 +	return ret;
 135.959 +}
 135.960 +
 135.961  /* This is the opposite of bcm43xx_init_board() */
 135.962  static void bcm43xx_free_board(struct bcm43xx_private *bcm)
 135.963  {
 135.964 -	int i, err;
 135.965 -
 135.966 -	bcm43xx_lock_noirq(bcm);
 135.967 +	bcm43xx_rng_exit(bcm);
 135.968  	bcm43xx_sysfs_unregister(bcm);
 135.969  	bcm43xx_periodic_tasks_delete(bcm);
 135.970  
 135.971 -	bcm43xx_set_status(bcm, BCM43xx_STAT_SHUTTINGDOWN);
 135.972 -
 135.973 -	bcm43xx_rng_exit(bcm);
 135.974 +	mutex_lock(&(bcm)->mutex);
 135.975 +	bcm43xx_shutdown_all_wireless_cores(bcm);
 135.976 +	bcm43xx_pctl_set_crystal(bcm, 0);
 135.977 +	mutex_unlock(&(bcm)->mutex);
 135.978 +}
 135.979 +
 135.980 +static void prepare_phydata_for_init(struct bcm43xx_phyinfo *phy)
 135.981 +{
 135.982 +	phy->antenna_diversity = 0xFFFF;
 135.983 +	memset(phy->minlowsig, 0xFF, sizeof(phy->minlowsig));
 135.984 +	memset(phy->minlowsigpos, 0, sizeof(phy->minlowsigpos));
 135.985 +
 135.986 +	/* Flags */
 135.987 +	phy->calibrated = 0;
 135.988 +	phy->is_locked = 0;
 135.989 +
 135.990 +	if (phy->_lo_pairs) {
 135.991 +		memset(phy->_lo_pairs, 0,
 135.992 +		       sizeof(struct bcm43xx_lopair) * BCM43xx_LO_COUNT);
 135.993 +	}
 135.994 +	memset(phy->loopback_gain, 0, sizeof(phy->loopback_gain));
 135.995 +}
 135.996 +
 135.997 +static void prepare_radiodata_for_init(struct bcm43xx_private *bcm,
 135.998 +				       struct bcm43xx_radioinfo *radio)
 135.999 +{
135.1000 +	int i;
135.1001 +
135.1002 +	/* Set default attenuation values. */
135.1003 +	radio->baseband_atten = bcm43xx_default_baseband_attenuation(bcm);
135.1004 +	radio->radio_atten = bcm43xx_default_radio_attenuation(bcm);
135.1005 +	radio->txctl1 = bcm43xx_default_txctl1(bcm);
135.1006 +	radio->txctl2 = 0xFFFF;
135.1007 +	radio->txpwr_offset = 0;
135.1008 +
135.1009 +	/* NRSSI */
135.1010 +	radio->nrssislope = 0;
135.1011 +	for (i = 0; i < ARRAY_SIZE(radio->nrssi); i++)
135.1012 +		radio->nrssi[i] = -1000;
135.1013 +	for (i = 0; i < ARRAY_SIZE(radio->nrssi_lt); i++)
135.1014 +		radio->nrssi_lt[i] = i;
135.1015 +
135.1016 +	radio->lofcal = 0xFFFF;
135.1017 +	radio->initval = 0xFFFF;
135.1018 +
135.1019 +	radio->aci_enable = 0;
135.1020 +	radio->aci_wlan_automatic = 0;
135.1021 +	radio->aci_hw_rssi = 0;
135.1022 +}
135.1023 +
135.1024 +static void prepare_priv_for_init(struct bcm43xx_private *bcm)
135.1025 +{
135.1026 +	int i;
135.1027 +	struct bcm43xx_coreinfo *core;
135.1028 +	struct bcm43xx_coreinfo_80211 *wlext;
135.1029 +
135.1030 +	assert(!bcm->active_80211_core);
135.1031 +
135.1032 +	bcm43xx_set_status(bcm, BCM43xx_STAT_INITIALIZING);
135.1033 +
135.1034 +	/* Flags */
135.1035 +	bcm->was_initialized = 0;
135.1036 +	bcm->reg124_set_0x4 = 0;
135.1037 +
135.1038 +	/* Stats */
135.1039 +	memset(&bcm->stats, 0, sizeof(bcm->stats));
135.1040 +
135.1041 +	/* Wireless core data */
135.1042  	for (i = 0; i < BCM43xx_MAX_80211_CORES; i++) {
135.1043 -		if (!bcm->core_80211[i].available)
135.1044 -			continue;
135.1045 -		if (!bcm->core_80211[i].initialized)
135.1046 +		core = &(bcm->core_80211[i]);
135.1047 +		wlext = core->priv;
135.1048 +
135.1049 +		if (!core->available)
135.1050  			continue;
135.1051 -
135.1052 -		err = bcm43xx_switch_core(bcm, &bcm->core_80211[i]);
135.1053 -		assert(err == 0);
135.1054 -		bcm43xx_wireless_core_cleanup(bcm);
135.1055 +		assert(wlext == &(bcm->core_80211_ext[i]));
135.1056 +
135.1057 +		prepare_phydata_for_init(&wlext->phy);
135.1058 +		prepare_radiodata_for_init(bcm, &wlext->radio);
135.1059  	}
135.1060  
135.1061 -	bcm43xx_pctl_set_crystal(bcm, 0);
135.1062 -
135.1063 +	/* IRQ related flags */
135.1064 +	bcm->irq_reason = 0;
135.1065 +	memset(bcm->dma_reason, 0, sizeof(bcm->dma_reason));
135.1066 +	bcm->irq_savedstate = BCM43xx_IRQ_INITIAL;
135.1067 +
135.1068 +	bcm->mac_suspended = 1;
135.1069 +
135.1070 +	/* Noise calculation context */
135.1071 +	memset(&bcm->noisecalc, 0, sizeof(bcm->noisecalc));
135.1072 +
135.1073 +	/* Periodic work context */
135.1074 +	bcm->periodic_state = 0;
135.1075 +}
135.1076 +
135.1077 +static int wireless_core_up(struct bcm43xx_private *bcm,
135.1078 +			    int active_wlcore)
135.1079 +{
135.1080 +	int err;
135.1081 +
135.1082 +	if (!bcm43xx_core_enabled(bcm))
135.1083 +		bcm43xx_wireless_core_reset(bcm, 1);
135.1084 +	if (!active_wlcore)
135.1085 +		bcm43xx_wireless_core_mark_inactive(bcm);
135.1086 +	err = bcm43xx_wireless_core_init(bcm, active_wlcore);
135.1087 +	if (err)
135.1088 +		goto out;
135.1089 +	if (!active_wlcore)
135.1090 +		bcm43xx_radio_turn_off(bcm);
135.1091 +out:
135.1092 +	return err;
135.1093 +}
135.1094 +
135.1095 +/* Select and enable the "to be used" wireless core.
135.1096 + * Locking: bcm->mutex must be aquired before calling this.
135.1097 + *          bcm->irq_lock must not be aquired.
135.1098 + */
135.1099 +int bcm43xx_select_wireless_core(struct bcm43xx_private *bcm,
135.1100 +				 int phytype)
135.1101 +{
135.1102 +	int i, err;
135.1103 +	struct bcm43xx_coreinfo *active_core = NULL;
135.1104 +	struct bcm43xx_coreinfo_80211 *active_wlext = NULL;
135.1105 +	struct bcm43xx_coreinfo *core;
135.1106 +	struct bcm43xx_coreinfo_80211 *wlext;
135.1107 +	int adjust_active_sbtmstatelow = 0;
135.1108 +
135.1109 +	might_sleep();
135.1110 +
135.1111 +	if (phytype < 0) {
135.1112 +		/* If no phytype is requested, select the first core. */
135.1113 +		assert(bcm->core_80211[0].available);
135.1114 +		wlext = bcm->core_80211[0].priv;
135.1115 +		phytype = wlext->phy.type;
135.1116 +	}
135.1117 +	/* Find the requested core. */
135.1118 +	for (i = 0; i < bcm->nr_80211_available; i++) {
135.1119 +		core = &(bcm->core_80211[i]);
135.1120 +		wlext = core->priv;
135.1121 +		if (wlext->phy.type == phytype) {
135.1122 +			active_core = core;
135.1123 +			active_wlext = wlext;
135.1124 +			break;
135.1125 +		}
135.1126 +	}
135.1127 +	if (!active_core)
135.1128 +		return -ESRCH; /* No such PHYTYPE on this board. */
135.1129 +
135.1130 +	if (bcm->active_80211_core) {
135.1131 +		/* We already selected a wl core in the past.
135.1132 +		 * So first clean up everything.
135.1133 +		 */
135.1134 +		dprintk(KERN_INFO PFX "select_wireless_core: cleanup\n");
135.1135 +		ieee80211softmac_stop(bcm->net_dev);
135.1136 +		bcm43xx_set_status(bcm, BCM43xx_STAT_INITIALIZED);
135.1137 +		err = bcm43xx_disable_interrupts_sync(bcm);
135.1138 +		assert(!err);
135.1139 +		tasklet_enable(&bcm->isr_tasklet);
135.1140 +		err = bcm43xx_shutdown_all_wireless_cores(bcm);
135.1141 +		if (err)
135.1142 +			goto error;
135.1143 +		/* Ok, everything down, continue to re-initialize. */
135.1144 +		bcm43xx_set_status(bcm, BCM43xx_STAT_INITIALIZING);
135.1145 +	}
135.1146 +
135.1147 +	/* Reset all data structures. */
135.1148 +	prepare_priv_for_init(bcm);
135.1149 +
135.1150 +	err = bcm43xx_pctl_set_clock(bcm, BCM43xx_PCTL_CLK_FAST);
135.1151 +	if (err)
135.1152 +		goto error;
135.1153 +
135.1154 +	/* Mark all unused cores "inactive". */
135.1155 +	for (i = 0; i < bcm->nr_80211_available; i++) {
135.1156 +		core = &(bcm->core_80211[i]);
135.1157 +		wlext = core->priv;
135.1158 +
135.1159 +		if (core == active_core)
135.1160 +			continue;
135.1161 +		err = bcm43xx_switch_core(bcm, core);
135.1162 +		if (err) {
135.1163 +			dprintk(KERN_ERR PFX "Could not switch to inactive "
135.1164 +					     "802.11 core (%d)\n", err);
135.1165 +			goto error;
135.1166 +		}
135.1167 +		err = wireless_core_up(bcm, 0);
135.1168 +		if (err) {
135.1169 +			dprintk(KERN_ERR PFX "core_up for inactive 802.11 core "
135.1170 +					     "failed (%d)\n", err);
135.1171 +			goto error;
135.1172 +		}
135.1173 +		adjust_active_sbtmstatelow = 1;
135.1174 +	}
135.1175 +
135.1176 +	/* Now initialize the active 802.11 core. */
135.1177 +	err = bcm43xx_switch_core(bcm, active_core);
135.1178 +	if (err) {
135.1179 +		dprintk(KERN_ERR PFX "Could not switch to active "
135.1180 +				     "802.11 core (%d)\n", err);
135.1181 +		goto error;
135.1182 +	}
135.1183 +	if (adjust_active_sbtmstatelow &&
135.1184 +	    active_wlext->phy.type == BCM43xx_PHYTYPE_G) {
135.1185 +		u32 sbtmstatelow;
135.1186 +
135.1187 +		sbtmstatelow = bcm43xx_read32(bcm, BCM43xx_CIR_SBTMSTATELOW);
135.1188 +		sbtmstatelow |= 0x20000000;
135.1189 +		bcm43xx_write32(bcm, BCM43xx_CIR_SBTMSTATELOW, sbtmstatelow);
135.1190 +	}
135.1191 +	err = wireless_core_up(bcm, 1);
135.1192 +	if (err) {
135.1193 +		dprintk(KERN_ERR PFX "core_up for active 802.11 core "
135.1194 +				     "failed (%d)\n", err);
135.1195 +		goto error;
135.1196 +	}
135.1197 +	err = bcm43xx_pctl_set_clock(bcm, BCM43xx_PCTL_CLK_DYNAMIC);
135.1198 +	if (err)
135.1199 +		goto error;
135.1200 +	bcm->active_80211_core = active_core;
135.1201 +
135.1202 +	bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC);
135.1203 +	bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr));
135.1204 +	bcm43xx_security_init(bcm);
135.1205 +	drain_txstatus_queue(bcm);
135.1206 +	ieee80211softmac_start(bcm->net_dev);
135.1207 +
135.1208 +	/* Let's go! Be careful after enabling the IRQs.
135.1209 +	 * Don't switch cores, for example.
135.1210 +	 */
135.1211 +	bcm43xx_mac_enable(bcm);
135.1212 +	bcm43xx_set_status(bcm, BCM43xx_STAT_INITIALIZED);
135.1213 +	err = bcm43xx_initialize_irq(bcm);
135.1214 +	if (err)
135.1215 +		goto error;
135.1216 +	bcm43xx_interrupt_enable(bcm, bcm->irq_savedstate);
135.1217 +
135.1218 +	dprintk(KERN_INFO PFX "Selected 802.11 core (phytype %d)\n",
135.1219 +		active_wlext->phy.type);
135.1220 +
135.1221 +	return 0;
135.1222 +
135.1223 +error:
135.1224  	bcm43xx_set_status(bcm, BCM43xx_STAT_UNINIT);
135.1225 -	bcm43xx_unlock_noirq(bcm);
135.1226 +	bcm43xx_pctl_set_clock(bcm, BCM43xx_PCTL_CLK_SLOW);
135.1227 +	return err;
135.1228  }
135.1229  
135.1230  static int bcm43xx_init_board(struct bcm43xx_private *bcm)
135.1231  {
135.1232 -	int i, err;
135.1233 -	int connect_phy;
135.1234 -
135.1235 -	might_sleep();
135.1236 -
135.1237 -	bcm43xx_lock_noirq(bcm);
135.1238 -	bcm43xx_set_status(bcm, BCM43xx_STAT_INITIALIZING);
135.1239 -
135.1240 +	int err;
135.1241 +
135.1242 +	mutex_lock(&(bcm)->mutex);
135.1243 +
135.1244 +	tasklet_enable(&bcm->isr_tasklet);
135.1245  	err = bcm43xx_pctl_set_crystal(bcm, 1);
135.1246  	if (err)
135.1247 -		goto out;
135.1248 +		goto err_tasklet;
135.1249  	err = bcm43xx_pctl_init(bcm);
135.1250  	if (err)
135.1251  		goto err_crystal_off;
135.1252 -	err = bcm43xx_pctl_set_clock(bcm, BCM43xx_PCTL_CLK_FAST);
135.1253 +	err = bcm43xx_select_wireless_core(bcm, -1);
135.1254  	if (err)
135.1255  		goto err_crystal_off;
135.1256 -
135.1257 -	tasklet_enable(&bcm->isr_tasklet);
135.1258 -	for (i = 0; i < bcm->nr_80211_available; i++) {
135.1259 -		err = bcm43xx_switch_core(bcm, &bcm->core_80211[i]);
135.1260 -		assert(err != -ENODEV);
135.1261 -		if (err)
135.1262 -			goto err_80211_unwind;
135.1263 -
135.1264 -		/* Enable the selected wireless core.
135.1265 -		 * Connect PHY only on the first core.
135.1266 -		 */
135.1267 -		if (!bcm43xx_core_enabled(bcm)) {
135.1268 -			if (bcm->nr_80211_available == 1) {
135.1269 -				connect_phy = bcm43xx_current_phy(bcm)->connected;
135.1270 -			} else {
135.1271 -				if (i == 0)
135.1272 -					connect_phy = 1;
135.1273 -				else
135.1274 -					connect_phy = 0;
135.1275 -			}
135.1276 -			bcm43xx_wireless_core_reset(bcm, connect_phy);
135.1277 -		}
135.1278 -
135.1279 -		if (i != 0)
135.1280 -			bcm43xx_wireless_core_mark_inactive(bcm, &bcm->core_80211[0]);
135.1281 -
135.1282 -		err = bcm43xx_wireless_core_init(bcm);
135.1283 -		if (err)
135.1284 -			goto err_80211_unwind;
135.1285 -
135.1286 -		if (i != 0) {
135.1287 -			bcm43xx_mac_suspend(bcm);
135.1288 -			bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
135.1289 -			bcm43xx_radio_turn_off(bcm);
135.1290 -		}
135.1291 -	}
135.1292 -	bcm->active_80211_core = &bcm->core_80211[0];
135.1293 -	if (bcm->nr_80211_available >= 2) {
135.1294 -		bcm43xx_switch_core(bcm, &bcm->core_80211[0]);
135.1295 -		bcm43xx_mac_enable(bcm);
135.1296 -	}
135.1297 +	err = bcm43xx_sysfs_register(bcm);
135.1298 +	if (err)
135.1299 +		goto err_wlshutdown;
135.1300  	err = bcm43xx_rng_init(bcm);
135.1301  	if (err)
135.1302 -		goto err_80211_unwind;
135.1303 -	bcm43xx_macfilter_clear(bcm, BCM43xx_MACFILTER_ASSOC);
135.1304 -	bcm43xx_macfilter_set(bcm, BCM43xx_MACFILTER_SELF, (u8 *)(bcm->net_dev->dev_addr));
135.1305 -	dprintk(KERN_INFO PFX "80211 cores initialized\n");
135.1306 -	bcm43xx_security_init(bcm);
135.1307 -	bcm43xx_softmac_init(bcm);
135.1308 -
135.1309 -	bcm43xx_pctl_set_clock(bcm, BCM43xx_PCTL_CLK_DYNAMIC);
135.1310 -
135.1311 -	if (bcm43xx_current_radio(bcm)->initial_channel != 0xFF) {
135.1312 -		bcm43xx_mac_suspend(bcm);
135.1313 -		bcm43xx_radio_selectchannel(bcm, bcm43xx_current_radio(bcm)->initial_channel, 0);
135.1314 -		bcm43xx_mac_enable(bcm);
135.1315 -	}
135.1316 -
135.1317 -	/* Initialization of the board is done. Flag it as such. */
135.1318 -	bcm43xx_set_status(bcm, BCM43xx_STAT_INITIALIZED);
135.1319 -
135.1320 +		goto err_sysfs_unreg;
135.1321  	bcm43xx_periodic_tasks_setup(bcm);
135.1322 -	bcm43xx_sysfs_register(bcm);
135.1323 -	//FIXME: check for bcm43xx_sysfs_register failure. This function is a bit messy regarding unwinding, though...
135.1324  
135.1325  	/*FIXME: This should be handled by softmac instead. */
135.1326  	schedule_work(&bcm->softmac->associnfo.work);
135.1327  
135.1328 -	assert(err == 0);
135.1329  out:
135.1330 -	bcm43xx_unlock_noirq(bcm);
135.1331 +	mutex_unlock(&(bcm)->mutex);
135.1332  
135.1333  	return err;
135.1334  
135.1335 -err_80211_unwind:
135.1336 -	tasklet_disable(&bcm->isr_tasklet);
135.1337 -	/* unwind all 80211 initialization */
135.1338 -	for (i = 0; i < bcm->nr_80211_available; i++) {
135.1339 -		if (!bcm->core_80211[i].initialized)
135.1340 -			continue;
135.1341 -		bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
135.1342 -		bcm43xx_wireless_core_cleanup(bcm);
135.1343 -	}
135.1344 +err_sysfs_unreg:
135.1345 +	bcm43xx_sysfs_unregister(bcm);
135.1346 +err_wlshutdown:
135.1347 +	bcm43xx_shutdown_all_wireless_cores(bcm);
135.1348  err_crystal_off:
135.1349  	bcm43xx_pctl_set_crystal(bcm, 0);
135.1350 +err_tasklet:
135.1351 +	tasklet_disable(&bcm->isr_tasklet);
135.1352  	goto out;
135.1353  }
135.1354  
135.1355 @@ -3647,7 +3839,8 @@ static void bcm43xx_ieee80211_set_chan(s
135.1356  	struct bcm43xx_radioinfo *radio;
135.1357  	unsigned long flags;
135.1358  
135.1359 -	bcm43xx_lock_irqsafe(bcm, flags);
135.1360 +	mutex_lock(&bcm->mutex);
135.1361 +	spin_lock_irqsave(&bcm->irq_lock, flags);
135.1362  	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) {
135.1363  		bcm43xx_mac_suspend(bcm);
135.1364  		bcm43xx_radio_selectchannel(bcm, channel, 0);
135.1365 @@ -3656,7 +3849,8 @@ static void bcm43xx_ieee80211_set_chan(s
135.1366  		radio = bcm43xx_current_radio(bcm);
135.1367  		radio->initial_channel = channel;
135.1368  	}
135.1369 -	bcm43xx_unlock_irqsafe(bcm, flags);
135.1370 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
135.1371 +	mutex_unlock(&bcm->mutex);
135.1372  }
135.1373  
135.1374  /* set_security() callback in struct ieee80211_device */
135.1375 @@ -3670,7 +3864,8 @@ static void bcm43xx_ieee80211_set_securi
135.1376  	
135.1377  	dprintk(KERN_INFO PFX "set security called");
135.1378  
135.1379 -	bcm43xx_lock_irqsafe(bcm, flags);
135.1380 +	mutex_lock(&bcm->mutex);
135.1381 +	spin_lock_irqsave(&bcm->irq_lock, flags);
135.1382  
135.1383  	for (keyidx = 0; keyidx<WEP_KEYS; keyidx++)
135.1384  		if (sec->flags & (1<<keyidx)) {
135.1385 @@ -3739,7 +3934,8 @@ static void bcm43xx_ieee80211_set_securi
135.1386  		} else
135.1387  				bcm43xx_clear_keys(bcm);
135.1388  	}
135.1389 -	bcm43xx_unlock_irqsafe(bcm, flags);
135.1390 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
135.1391 +	mutex_unlock(&bcm->mutex);
135.1392  }
135.1393  
135.1394  /* hard_start_xmit() callback in struct ieee80211_device */
135.1395 @@ -3751,12 +3947,14 @@ static int bcm43xx_ieee80211_hard_start_
135.1396  	int err = -ENODEV;
135.1397  	unsigned long flags;
135.1398  
135.1399 -	bcm43xx_lock_irqonly(bcm, flags);
135.1400 +	spin_lock_irqsave(&bcm->irq_lock, flags);
135.1401  	if (likely(bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED))
135.1402  		err = bcm43xx_tx(bcm, txb);
135.1403 -	bcm43xx_unlock_irqonly(bcm, flags);
135.1404 -
135.1405 -	return err;
135.1406 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
135.1407 +
135.1408 +	if (unlikely(err))
135.1409 +		return NETDEV_TX_BUSY;
135.1410 +	return NETDEV_TX_OK;
135.1411  }
135.1412  
135.1413  static struct net_device_stats * bcm43xx_net_get_stats(struct net_device *net_dev)
135.1414 @@ -3769,9 +3967,9 @@ static void bcm43xx_net_tx_timeout(struc
135.1415  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
135.1416  	unsigned long flags;
135.1417  
135.1418 -	bcm43xx_lock_irqonly(bcm, flags);
135.1419 +	spin_lock_irqsave(&bcm->irq_lock, flags);
135.1420  	bcm43xx_controller_restart(bcm, "TX timeout");
135.1421 -	bcm43xx_unlock_irqonly(bcm, flags);
135.1422 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
135.1423  }
135.1424  
135.1425  #ifdef CONFIG_NET_POLL_CONTROLLER
135.1426 @@ -3781,7 +3979,8 @@ static void bcm43xx_net_poll_controller(
135.1427  	unsigned long flags;
135.1428  
135.1429  	local_irq_save(flags);
135.1430 -	bcm43xx_interrupt_handler(bcm->irq, bcm, NULL);
135.1431 +	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED)
135.1432 +		bcm43xx_interrupt_handler(bcm->irq, bcm, NULL);
135.1433  	local_irq_restore(flags);
135.1434  }
135.1435  #endif /* CONFIG_NET_POLL_CONTROLLER */
135.1436 @@ -3799,9 +3998,10 @@ static int bcm43xx_net_stop(struct net_d
135.1437  	int err;
135.1438  
135.1439  	ieee80211softmac_stop(net_dev);
135.1440 -	err = bcm43xx_disable_interrupts_sync(bcm, NULL);
135.1441 +	err = bcm43xx_disable_interrupts_sync(bcm);
135.1442  	assert(!err);
135.1443  	bcm43xx_free_board(bcm);
135.1444 +	flush_scheduled_work();
135.1445  
135.1446  	return 0;
135.1447  }
135.1448 @@ -3818,10 +4018,12 @@ static int bcm43xx_init_private(struct b
135.1449  	bcm->softmac->set_channel = bcm43xx_ieee80211_set_chan;
135.1450  
135.1451  	bcm->irq_savedstate = BCM43xx_IRQ_INITIAL;
135.1452 +	bcm->mac_suspended = 1;
135.1453  	bcm->pci_dev = pci_dev;
135.1454  	bcm->net_dev = net_dev;
135.1455  	bcm->bad_frames_preempt = modparam_bad_frames_preempt;
135.1456  	spin_lock_init(&bcm->irq_lock);
135.1457 +	spin_lock_init(&bcm->leds_lock);
135.1458  	mutex_init(&bcm->mutex);
135.1459  	tasklet_init(&bcm->isr_tasklet,
135.1460  		     (void (*)(unsigned long))bcm43xx_interrupt_tasklet,
135.1461 @@ -3940,7 +4142,6 @@ static void __devexit bcm43xx_remove_one
135.1462  	bcm43xx_debugfs_remove_device(bcm);
135.1463  	unregister_netdev(net_dev);
135.1464  	bcm43xx_detach_board(bcm);
135.1465 -	assert(bcm->ucode == NULL);
135.1466  	free_ieee80211softmac(net_dev);
135.1467  }
135.1468  
135.1469 @@ -3950,47 +4151,31 @@ static void __devexit bcm43xx_remove_one
135.1470  static void bcm43xx_chip_reset(void *_bcm)
135.1471  {
135.1472  	struct bcm43xx_private *bcm = _bcm;
135.1473 -	struct net_device *net_dev = bcm->net_dev;
135.1474 -	struct pci_dev *pci_dev = bcm->pci_dev;
135.1475 -	int err;
135.1476 -	int was_initialized = (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);
135.1477 -
135.1478 -	netif_stop_queue(bcm->net_dev);
135.1479 -	tasklet_disable(&bcm->isr_tasklet);
135.1480 -
135.1481 -	bcm->firmware_norelease = 1;
135.1482 -	if (was_initialized)
135.1483 -		bcm43xx_free_board(bcm);
135.1484 -	bcm->firmware_norelease = 0;
135.1485 -	bcm43xx_detach_board(bcm);
135.1486 -	err = bcm43xx_init_private(bcm, net_dev, pci_dev);
135.1487 -	if (err)
135.1488 -		goto failure;
135.1489 -	err = bcm43xx_attach_board(bcm);
135.1490 -	if (err)
135.1491 -		goto failure;
135.1492 -	if (was_initialized) {
135.1493 -		err = bcm43xx_init_board(bcm);
135.1494 -		if (err)
135.1495 -			goto failure;
135.1496 +	struct bcm43xx_phyinfo *phy;
135.1497 +	int err = -ENODEV;
135.1498 +
135.1499 +	mutex_lock(&(bcm)->mutex);
135.1500 +	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) {
135.1501 +		bcm43xx_periodic_tasks_delete(bcm);
135.1502 +		phy = bcm43xx_current_phy(bcm);
135.1503 +		err = bcm43xx_select_wireless_core(bcm, phy->type);
135.1504 +		if (!err)
135.1505 +			bcm43xx_periodic_tasks_setup(bcm);
135.1506  	}
135.1507 -	netif_wake_queue(bcm->net_dev);
135.1508 -	printk(KERN_INFO PFX "Controller restarted\n");
135.1509 -
135.1510 -	return;
135.1511 -failure:
135.1512 -	printk(KERN_ERR PFX "Controller restart failed\n");
135.1513 +	mutex_unlock(&(bcm)->mutex);
135.1514 +
135.1515 +	printk(KERN_ERR PFX "Controller restart%s\n",
135.1516 +	       (err == 0) ? "ed" : " failed");
135.1517  }
135.1518  
135.1519  /* Hard-reset the chip.
135.1520   * This can be called from interrupt or process context.
135.1521 - * Make sure to _not_ re-enable device interrupts after this has been called.
135.1522 -*/
135.1523 + * bcm->irq_lock must be locked.
135.1524 + */
135.1525  void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason)
135.1526  {
135.1527 -	bcm43xx_set_status(bcm, BCM43xx_STAT_RESTARTING);
135.1528 -	bcm43xx_interrupt_disable(bcm, BCM43xx_IRQ_ALL);
135.1529 -	bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); /* dummy read */
135.1530 +	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED)
135.1531 +		return;
135.1532  	printk(KERN_ERR PFX "Controller RESET (%s) ...\n", reason);
135.1533  	INIT_WORK(&bcm->restart_work, bcm43xx_chip_reset, bcm);
135.1534  	schedule_work(&bcm->restart_work);
135.1535 @@ -4002,21 +4187,16 @@ static int bcm43xx_suspend(struct pci_de
135.1536  {
135.1537  	struct net_device *net_dev = pci_get_drvdata(pdev);
135.1538  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
135.1539 -	unsigned long flags;
135.1540 -	int try_to_shutdown = 0, err;
135.1541 +	int err;
135.1542  
135.1543  	dprintk(KERN_INFO PFX "Suspending...\n");
135.1544  
135.1545 -	bcm43xx_lock_irqsafe(bcm, flags);
135.1546 -	bcm->was_initialized = (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED);
135.1547 -	if (bcm->was_initialized)
135.1548 -		try_to_shutdown = 1;
135.1549 -	bcm43xx_unlock_irqsafe(bcm, flags);
135.1550 -
135.1551  	netif_device_detach(net_dev);
135.1552 -	if (try_to_shutdown) {
135.1553 +	bcm->was_initialized = 0;
135.1554 +	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) {
135.1555 +		bcm->was_initialized = 1;
135.1556  		ieee80211softmac_stop(net_dev);
135.1557 -		err = bcm43xx_disable_interrupts_sync(bcm, &bcm->irq_savedstate);
135.1558 +		err = bcm43xx_disable_interrupts_sync(bcm);
135.1559  		if (unlikely(err)) {
135.1560  			dprintk(KERN_ERR PFX "Suspend failed.\n");
135.1561  			return -EAGAIN;
135.1562 @@ -4049,17 +4229,14 @@ static int bcm43xx_resume(struct pci_dev
135.1563  	pci_restore_state(pdev);
135.1564  
135.1565  	bcm43xx_chipset_attach(bcm);
135.1566 -	if (bcm->was_initialized) {
135.1567 -		bcm->irq_savedstate = BCM43xx_IRQ_INITIAL;
135.1568 +	if (bcm->was_initialized)
135.1569  		err = bcm43xx_init_board(bcm);
135.1570 -	}
135.1571  	if (err) {
135.1572  		printk(KERN_ERR PFX "Resume failed!\n");
135.1573  		return err;
135.1574  	}
135.1575 -
135.1576  	netif_device_attach(net_dev);
135.1577 -	
135.1578 +
135.1579  	dprintk(KERN_INFO PFX "Device resumed.\n");
135.1580  
135.1581  	return 0;
   136.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.h	Tue Oct 02 09:52:15 2007 +0100
   136.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.h	Wed Oct 03 10:00:44 2007 +0100
   136.3 @@ -133,11 +133,17 @@ void bcm43xx_dummy_transmission(struct b
   136.4  
   136.5  int bcm43xx_switch_core(struct bcm43xx_private *bcm, struct bcm43xx_coreinfo *new_core);
   136.6  
   136.7 +int bcm43xx_select_wireless_core(struct bcm43xx_private *bcm,
   136.8 +				 int phytype);
   136.9 +
  136.10  void bcm43xx_wireless_core_reset(struct bcm43xx_private *bcm, int connect_phy);
  136.11  
  136.12  void bcm43xx_mac_suspend(struct bcm43xx_private *bcm);
  136.13  void bcm43xx_mac_enable(struct bcm43xx_private *bcm);
  136.14  
  136.15 +void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm);
  136.16 +void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm);
  136.17 +
  136.18  void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason);
  136.19  
  136.20  int bcm43xx_sprom_read(struct bcm43xx_private *bcm, u16 *sprom);
   137.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c	Tue Oct 02 09:52:15 2007 +0100
   137.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c	Wed Oct 03 10:00:44 2007 +0100
   137.3 @@ -81,6 +81,16 @@ static const s8 bcm43xx_tssi2dbm_g_table
   137.4  static void bcm43xx_phy_initg(struct bcm43xx_private *bcm);
   137.5  
   137.6  
   137.7 +static inline
   137.8 +void bcm43xx_voluntary_preempt(void)
   137.9 +{
  137.10 +	assert(!in_atomic() && !in_irq() &&
  137.11 +	       !in_interrupt() && !irqs_disabled());
  137.12 +#ifndef CONFIG_PREEMPT
  137.13 +	cond_resched();
  137.14 +#endif /* CONFIG_PREEMPT */
  137.15 +}
  137.16 +
  137.17  void bcm43xx_raw_phy_lock(struct bcm43xx_private *bcm)
  137.18  {
  137.19  	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
  137.20 @@ -133,22 +143,14 @@ void bcm43xx_phy_write(struct bcm43xx_pr
  137.21  void bcm43xx_phy_calibrate(struct bcm43xx_private *bcm)
  137.22  {
  137.23  	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
  137.24 -	unsigned long flags;
  137.25  
  137.26  	bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); /* Dummy read. */
  137.27  	if (phy->calibrated)
  137.28  		return;
  137.29  	if (phy->type == BCM43xx_PHYTYPE_G && phy->rev == 1) {
  137.30 -		/* We do not want to be preempted while calibrating
  137.31 -		 * the hardware.
  137.32 -		 */
  137.33 -		local_irq_save(flags);
  137.34 -
  137.35  		bcm43xx_wireless_core_reset(bcm, 0);
  137.36  		bcm43xx_phy_initg(bcm);
  137.37  		bcm43xx_wireless_core_reset(bcm, 1);
  137.38 -
  137.39 -		local_irq_restore(flags);
  137.40  	}
  137.41  	phy->calibrated = 1;
  137.42  }
  137.43 @@ -359,7 +361,7 @@ static void bcm43xx_phy_setupg(struct bc
  137.44  	if (phy->rev <= 2)
  137.45  		for (i = 0; i < BCM43xx_ILT_NOISESCALEG_SIZE; i++)
  137.46  			bcm43xx_ilt_write(bcm, 0x1400 + i, bcm43xx_ilt_noisescaleg1[i]);
  137.47 -	else if ((phy->rev == 7) && (bcm43xx_phy_read(bcm, 0x0449) & 0x0200))
  137.48 +	else if ((phy->rev >= 7) && (bcm43xx_phy_read(bcm, 0x0449) & 0x0200))
  137.49  		for (i = 0; i < BCM43xx_ILT_NOISESCALEG_SIZE; i++)
  137.50  			bcm43xx_ilt_write(bcm, 0x1400 + i, bcm43xx_ilt_noisescaleg3[i]);
  137.51  	else
  137.52 @@ -369,7 +371,7 @@ static void bcm43xx_phy_setupg(struct bc
  137.53  	if (phy->rev == 2)
  137.54  		for (i = 0; i < BCM43xx_ILT_SIGMASQR_SIZE; i++)
  137.55  			bcm43xx_ilt_write(bcm, 0x5000 + i, bcm43xx_ilt_sigmasqr1[i]);
  137.56 -	else if ((phy->rev > 2) && (phy->rev <= 7))
  137.57 +	else if ((phy->rev > 2) && (phy->rev <= 8))
  137.58  		for (i = 0; i < BCM43xx_ILT_SIGMASQR_SIZE; i++)
  137.59  			bcm43xx_ilt_write(bcm, 0x5000 + i, bcm43xx_ilt_sigmasqr2[i]);
  137.60  	
  137.61 @@ -1195,7 +1197,7 @@ static void bcm43xx_phy_initg(struct bcm
  137.62  
  137.63  	if (phy->rev == 1)
  137.64  		bcm43xx_phy_initb5(bcm);
  137.65 -	else if (phy->rev >= 2 && phy->rev <= 7)
  137.66 +	else
  137.67  		bcm43xx_phy_initb6(bcm);
  137.68  	if (phy->rev >= 2 || phy->connected)
  137.69  		bcm43xx_phy_inita(bcm);
  137.70 @@ -1239,23 +1241,22 @@ static void bcm43xx_phy_initg(struct bcm
  137.71  		bcm43xx_phy_lo_g_measure(bcm);
  137.72  	} else {
  137.73  		if (radio->version == 0x2050 && radio->revision == 8) {
  137.74 -			//FIXME
  137.75 +			bcm43xx_radio_write16(bcm, 0x0052,
  137.76 +					      (radio->txctl1 << 4) | radio->txctl2);
  137.77  		} else {
  137.78  			bcm43xx_radio_write16(bcm, 0x0052,
  137.79  					      (bcm43xx_radio_read16(bcm, 0x0052)
  137.80  					       & 0xFFF0) | radio->txctl1);
  137.81  		}
  137.82  		if (phy->rev >= 6) {
  137.83 -			/*
  137.84  			bcm43xx_phy_write(bcm, 0x0036,
  137.85  					  (bcm43xx_phy_read(bcm, 0x0036)
  137.86 -					   & 0xF000) | (FIXME << 12));
  137.87 -			*/
  137.88 +					   & 0xF000) | (radio->txctl2 << 12));
  137.89  		}
  137.90  		if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL)
  137.91  			bcm43xx_phy_write(bcm, 0x002E, 0x8075);
  137.92  		else
  137.93 -			bcm43xx_phy_write(bcm, 0x003E, 0x807F);
  137.94 +			bcm43xx_phy_write(bcm, 0x002E, 0x807F);
  137.95  		if (phy->rev < 2)
  137.96  			bcm43xx_phy_write(bcm, 0x002F, 0x0101);
  137.97  		else
  137.98 @@ -1299,7 +1300,9 @@ static u16 bcm43xx_phy_lo_b_r15_loop(str
  137.99  {
 137.100  	int i;
 137.101  	u16 ret = 0;
 137.102 +	unsigned long flags;
 137.103  
 137.104 +	local_irq_save(flags);
 137.105  	for (i = 0; i < 10; i++){
 137.106  		bcm43xx_phy_write(bcm, 0x0015, 0xAFA0);
 137.107  		udelay(1);
 137.108 @@ -1309,6 +1312,8 @@ static u16 bcm43xx_phy_lo_b_r15_loop(str
 137.109  		udelay(40);
 137.110  		ret += bcm43xx_phy_read(bcm, 0x002C);
 137.111  	}
 137.112 +	local_irq_restore(flags);
 137.113 +	bcm43xx_voluntary_preempt();
 137.114  
 137.115  	return ret;
 137.116  }
 137.117 @@ -1435,6 +1440,7 @@ u16 bcm43xx_phy_lo_g_deviation_subval(st
 137.118  	}
 137.119  	ret = bcm43xx_phy_read(bcm, 0x002D);
 137.120  	local_irq_restore(flags);
 137.121 +	bcm43xx_voluntary_preempt();
 137.122  
 137.123  	return ret;
 137.124  }
 137.125 @@ -1760,6 +1766,7 @@ void bcm43xx_phy_lo_g_measure(struct bcm
 137.126  			bcm43xx_radio_write16(bcm, 0x43, i);
 137.127  			bcm43xx_radio_write16(bcm, 0x52, radio->txctl2);
 137.128  			udelay(10);
 137.129 +			bcm43xx_voluntary_preempt();
 137.130  
 137.131  			bcm43xx_phy_set_baseband_attenuation(bcm, j * 2);
 137.132  
 137.133 @@ -1803,6 +1810,7 @@ void bcm43xx_phy_lo_g_measure(struct bcm
 137.134  					      radio->txctl2
 137.135  					      | (3/*txctl1*/ << 4));//FIXME: shouldn't txctl1 be zero here and 3 in the loop above?
 137.136  			udelay(10);
 137.137 +			bcm43xx_voluntary_preempt();
 137.138  
 137.139  			bcm43xx_phy_set_baseband_attenuation(bcm, j * 2);
 137.140  
 137.141 @@ -1824,6 +1832,7 @@ void bcm43xx_phy_lo_g_measure(struct bcm
 137.142  		bcm43xx_phy_write(bcm, 0x0812, (r27 << 8) | 0xA2);
 137.143  		udelay(2);
 137.144  		bcm43xx_phy_write(bcm, 0x0812, (r27 << 8) | 0xA3);
 137.145 +		bcm43xx_voluntary_preempt();
 137.146  	} else
 137.147  		bcm43xx_phy_write(bcm, 0x0015, r27 | 0xEFA0);
 137.148  	bcm43xx_phy_lo_adjust(bcm, is_initializing);
 137.149 @@ -2188,12 +2197,6 @@ int bcm43xx_phy_init(struct bcm43xx_priv
 137.150  {
 137.151  	struct bcm43xx_phyinfo *phy = bcm43xx_current_phy(bcm);
 137.152  	int err = -ENODEV;
 137.153 -	unsigned long flags;
 137.154 -
 137.155 -	/* We do not want to be preempted while calibrating
 137.156 -	 * the hardware.
 137.157 -	 */
 137.158 -	local_irq_save(flags);
 137.159  
 137.160  	switch (phy->type) {
 137.161  	case BCM43xx_PHYTYPE_A:
 137.162 @@ -2227,7 +2230,6 @@ int bcm43xx_phy_init(struct bcm43xx_priv
 137.163  		err = 0;
 137.164  		break;
 137.165  	}
 137.166 -	local_irq_restore(flags);
 137.167  	if (err)
 137.168  		printk(KERN_WARNING PFX "Unknown PHYTYPE found!\n");
 137.169  
   138.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_pio.c	Tue Oct 02 09:52:15 2007 +0100
   138.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_pio.c	Wed Oct 03 10:00:44 2007 +0100
   138.3 @@ -262,7 +262,7 @@ static void tx_tasklet(unsigned long d)
   138.4  	int err;
   138.5  	u16 txctl;
   138.6  
   138.7 -	bcm43xx_lock_irqonly(bcm, flags);
   138.8 +	spin_lock_irqsave(&bcm->irq_lock, flags);
   138.9  
  138.10  	if (queue->tx_frozen)
  138.11  		goto out_unlock;
  138.12 @@ -300,7 +300,7 @@ static void tx_tasklet(unsigned long d)
  138.13  		continue;
  138.14  	}
  138.15  out_unlock:
  138.16 -	bcm43xx_unlock_irqonly(bcm, flags);
  138.17 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  138.18  }
  138.19  
  138.20  static void setup_txqueues(struct bcm43xx_pioqueue *queue)
   139.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c	Tue Oct 02 09:52:15 2007 +0100
   139.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c	Wed Oct 03 10:00:44 2007 +0100
   139.3 @@ -120,12 +120,14 @@ static ssize_t bcm43xx_attr_sprom_show(s
   139.4  			GFP_KERNEL);
   139.5  	if (!sprom)
   139.6  		return -ENOMEM;
   139.7 -	bcm43xx_lock_irqsafe(bcm, flags);
   139.8 +	mutex_lock(&bcm->mutex);
   139.9 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  139.10  	err = bcm43xx_sprom_read(bcm, sprom);
  139.11  	if (!err)
  139.12  		err = sprom2hex(sprom, buf, PAGE_SIZE);
  139.13  	mmiowb();
  139.14 -	bcm43xx_unlock_irqsafe(bcm, flags);
  139.15 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  139.16 +	mutex_unlock(&bcm->mutex);
  139.17  	kfree(sprom);
  139.18  
  139.19  	return err;
  139.20 @@ -150,10 +152,14 @@ static ssize_t bcm43xx_attr_sprom_store(
  139.21  	err = hex2sprom(sprom, buf, count);
  139.22  	if (err)
  139.23  		goto out_kfree;
  139.24 -	bcm43xx_lock_irqsafe(bcm, flags);
  139.25 +	mutex_lock(&bcm->mutex);
  139.26 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  139.27 +	spin_lock(&bcm->leds_lock);
  139.28  	err = bcm43xx_sprom_write(bcm, sprom);
  139.29  	mmiowb();
  139.30 -	bcm43xx_unlock_irqsafe(bcm, flags);
  139.31 +	spin_unlock(&bcm->leds_lock);
  139.32 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  139.33 +	mutex_unlock(&bcm->mutex);
  139.34  out_kfree:
  139.35  	kfree(sprom);
  139.36  
  139.37 @@ -170,13 +176,12 @@ static ssize_t bcm43xx_attr_interfmode_s
  139.38  					    char *buf)
  139.39  {
  139.40  	struct bcm43xx_private *bcm = dev_to_bcm(dev);
  139.41 -	int err;
  139.42  	ssize_t count = 0;
  139.43  
  139.44  	if (!capable(CAP_NET_ADMIN))
  139.45  		return -EPERM;
  139.46  
  139.47 -	bcm43xx_lock_noirq(bcm);
  139.48 +	mutex_lock(&bcm->mutex);
  139.49  
  139.50  	switch (bcm43xx_current_radio(bcm)->interfmode) {
  139.51  	case BCM43xx_RADIO_INTERFMODE_NONE:
  139.52 @@ -191,11 +196,10 @@ static ssize_t bcm43xx_attr_interfmode_s
  139.53  	default:
  139.54  		assert(0);
  139.55  	}
  139.56 -	err = 0;
  139.57  
  139.58 -	bcm43xx_unlock_noirq(bcm);
  139.59 +	mutex_unlock(&bcm->mutex);
  139.60  
  139.61 -	return err ? err : count;
  139.62 +	return count;
  139.63  
  139.64  }
  139.65  
  139.66 @@ -229,7 +233,8 @@ static ssize_t bcm43xx_attr_interfmode_s
  139.67  		return -EINVAL;
  139.68  	}
  139.69  
  139.70 -	bcm43xx_lock_irqsafe(bcm, flags);
  139.71 +	mutex_lock(&bcm->mutex);
  139.72 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  139.73  
  139.74  	err = bcm43xx_radio_set_interference_mitigation(bcm, mode);
  139.75  	if (err) {
  139.76 @@ -237,7 +242,8 @@ static ssize_t bcm43xx_attr_interfmode_s
  139.77  				    "supported by device\n");
  139.78  	}
  139.79  	mmiowb();
  139.80 -	bcm43xx_unlock_irqsafe(bcm, flags);
  139.81 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  139.82 +	mutex_unlock(&bcm->mutex);
  139.83  
  139.84  	return err ? err : count;
  139.85  }
  139.86 @@ -251,23 +257,21 @@ static ssize_t bcm43xx_attr_preamble_sho
  139.87  					  char *buf)
  139.88  {
  139.89  	struct bcm43xx_private *bcm = dev_to_bcm(dev);
  139.90 -	int err;
  139.91  	ssize_t count;
  139.92  
  139.93  	if (!capable(CAP_NET_ADMIN))
  139.94  		return -EPERM;
  139.95  
  139.96 -	bcm43xx_lock_noirq(bcm);
  139.97 +	mutex_lock(&bcm->mutex);
  139.98  
  139.99  	if (bcm->short_preamble)
 139.100  		count = snprintf(buf, PAGE_SIZE, "1 (Short Preamble enabled)\n");
 139.101  	else
 139.102  		count = snprintf(buf, PAGE_SIZE, "0 (Short Preamble disabled)\n");
 139.103  
 139.104 -	err = 0;
 139.105 -	bcm43xx_unlock_noirq(bcm);
 139.106 +	mutex_unlock(&bcm->mutex);
 139.107  
 139.108 -	return err ? err : count;
 139.109 +	return count;
 139.110  }
 139.111  
 139.112  static ssize_t bcm43xx_attr_preamble_store(struct device *dev,
 139.113 @@ -276,7 +280,6 @@ static ssize_t bcm43xx_attr_preamble_sto
 139.114  {
 139.115  	struct bcm43xx_private *bcm = dev_to_bcm(dev);
 139.116  	unsigned long flags;
 139.117 -	int err;
 139.118  	int value;
 139.119  
 139.120  	if (!capable(CAP_NET_ADMIN))
 139.121 @@ -285,14 +288,15 @@ static ssize_t bcm43xx_attr_preamble_sto
 139.122  	value = get_boolean(buf, count);
 139.123  	if (value < 0)
 139.124  		return value;
 139.125 -	bcm43xx_lock_irqsafe(bcm, flags);
 139.126 +	mutex_lock(&bcm->mutex);
 139.127 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 139.128  
 139.129  	bcm->short_preamble = !!value;
 139.130  
 139.131 -	err = 0;
 139.132 -	bcm43xx_unlock_irqsafe(bcm, flags);
 139.133 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 139.134 +	mutex_unlock(&bcm->mutex);
 139.135  
 139.136 -	return err ? err : count;
 139.137 +	return count;
 139.138  }
 139.139  
 139.140  static DEVICE_ATTR(shortpreamble, 0644,
   140.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c	Tue Oct 02 09:52:15 2007 +0100
   140.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c	Wed Oct 03 10:00:44 2007 +0100
   140.3 @@ -56,12 +56,11 @@ static int bcm43xx_wx_get_name(struct ne
   140.4  {
   140.5  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
   140.6  	int i;
   140.7 -	unsigned long flags;
   140.8  	struct bcm43xx_phyinfo *phy;
   140.9  	char suffix[7] = { 0 };
  140.10  	int have_a = 0, have_b = 0, have_g = 0;
  140.11  
  140.12 -	bcm43xx_lock_irqsafe(bcm, flags);
  140.13 +	mutex_lock(&bcm->mutex);
  140.14  	for (i = 0; i < bcm->nr_80211_available; i++) {
  140.15  		phy = &(bcm->core_80211_ext[i].phy);
  140.16  		switch (phy->type) {
  140.17 @@ -77,7 +76,7 @@ static int bcm43xx_wx_get_name(struct ne
  140.18  			assert(0);
  140.19  		}
  140.20  	}
  140.21 -	bcm43xx_unlock_irqsafe(bcm, flags);
  140.22 +	mutex_unlock(&bcm->mutex);
  140.23  
  140.24  	i = 0;
  140.25  	if (have_a) {
  140.26 @@ -111,7 +110,9 @@ static int bcm43xx_wx_set_channelfreq(st
  140.27  	int freq;
  140.28  	int err = -EINVAL;
  140.29  
  140.30 -	bcm43xx_lock_irqsafe(bcm, flags);
  140.31 +	mutex_lock(&bcm->mutex);
  140.32 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  140.33 +
  140.34  	if ((data->freq.m >= 0) && (data->freq.m <= 1000)) {
  140.35  		channel = data->freq.m;
  140.36  		freq = bcm43xx_channel_to_freq(bcm, channel);
  140.37 @@ -131,7 +132,8 @@ static int bcm43xx_wx_set_channelfreq(st
  140.38  		err = 0;
  140.39  	}
  140.40  out_unlock:
  140.41 -	bcm43xx_unlock_irqsafe(bcm, flags);
  140.42 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  140.43 +	mutex_unlock(&bcm->mutex);
  140.44  
  140.45  	return err;
  140.46  }
  140.47 @@ -143,11 +145,10 @@ static int bcm43xx_wx_get_channelfreq(st
  140.48  {
  140.49  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
  140.50  	struct bcm43xx_radioinfo *radio;
  140.51 -	unsigned long flags;
  140.52  	int err = -ENODEV;
  140.53  	u16 channel;
  140.54  
  140.55 -	bcm43xx_lock_irqsafe(bcm, flags);
  140.56 +	mutex_lock(&bcm->mutex);
  140.57  	radio = bcm43xx_current_radio(bcm);
  140.58  	channel = radio->channel;
  140.59  	if (channel == 0xFF) {
  140.60 @@ -162,7 +163,7 @@ static int bcm43xx_wx_get_channelfreq(st
  140.61  
  140.62  	err = 0;
  140.63  out_unlock:
  140.64 -	bcm43xx_unlock_irqsafe(bcm, flags);
  140.65 +	mutex_unlock(&bcm->mutex);
  140.66  
  140.67  	return err;
  140.68  }
  140.69 @@ -180,13 +181,15 @@ static int bcm43xx_wx_set_mode(struct ne
  140.70  	if (mode == IW_MODE_AUTO)
  140.71  		mode = BCM43xx_INITIAL_IWMODE;
  140.72  
  140.73 -	bcm43xx_lock_irqsafe(bcm, flags);
  140.74 +	mutex_lock(&bcm->mutex);
  140.75 +	spin_lock_irqsave(&bcm->irq_lock, flags);
  140.76  	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) {
  140.77  		if (bcm->ieee->iw_mode != mode)
  140.78  			bcm43xx_set_iwmode(bcm, mode);
  140.79  	} else
  140.80  		bcm->ieee->iw_mode = mode;
  140.81 -	bcm43xx_unlock_irqsafe(bcm, flags);
  140.82 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
  140.83 +	mutex_unlock(&bcm->mutex);
  140.84  
  140.85  	return 0;
  140.86  }
  140.87 @@ -197,11 +200,10 @@ static int bcm43xx_wx_get_mode(struct ne
  140.88  			       char *extra)
  140.89  {
  140.90  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
  140.91 -	unsigned long flags;
  140.92  
  140.93 -	bcm43xx_lock_irqsafe(bcm, flags);
  140.94 +	mutex_lock(&bcm->mutex);
  140.95  	data->mode = bcm->ieee->iw_mode;
  140.96 -	bcm43xx_unlock_irqsafe(bcm, flags);
  140.97 +	mutex_unlock(&bcm->mutex);
  140.98  
  140.99  	return 0;
 140.100  }
 140.101 @@ -214,7 +216,6 @@ static int bcm43xx_wx_get_rangeparams(st
 140.102  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
 140.103  	struct iw_range *range = (struct iw_range *)extra;
 140.104  	const struct ieee80211_geo *geo;
 140.105 -	unsigned long flags;
 140.106  	int i, j;
 140.107  	struct bcm43xx_phyinfo *phy;
 140.108  
 140.109 @@ -254,7 +255,7 @@ static int bcm43xx_wx_get_rangeparams(st
 140.110  			  IW_ENC_CAPA_CIPHER_TKIP |
 140.111  			  IW_ENC_CAPA_CIPHER_CCMP;
 140.112  
 140.113 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.114 +	mutex_lock(&bcm->mutex);
 140.115  	phy = bcm43xx_current_phy(bcm);
 140.116  
 140.117  	range->num_bitrates = 0;
 140.118 @@ -301,7 +302,7 @@ static int bcm43xx_wx_get_rangeparams(st
 140.119  	}
 140.120  	range->num_frequency = j;
 140.121  
 140.122 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.123 +	mutex_unlock(&bcm->mutex);
 140.124  
 140.125  	return 0;
 140.126  }
 140.127 @@ -314,11 +315,11 @@ static int bcm43xx_wx_set_nick(struct ne
 140.128  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
 140.129  	size_t len;
 140.130  
 140.131 -	bcm43xx_lock_noirq(bcm);
 140.132 +	mutex_lock(&bcm->mutex);
 140.133  	len =  min((size_t)data->data.length, (size_t)IW_ESSID_MAX_SIZE);
 140.134  	memcpy(bcm->nick, extra, len);
 140.135  	bcm->nick[len] = '\0';
 140.136 -	bcm43xx_unlock_noirq(bcm);
 140.137 +	mutex_unlock(&bcm->mutex);
 140.138  
 140.139  	return 0;
 140.140  }
 140.141 @@ -331,12 +332,12 @@ static int bcm43xx_wx_get_nick(struct ne
 140.142  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
 140.143  	size_t len;
 140.144  
 140.145 -	bcm43xx_lock_noirq(bcm);
 140.146 +	mutex_lock(&bcm->mutex);
 140.147  	len = strlen(bcm->nick) + 1;
 140.148  	memcpy(extra, bcm->nick, len);
 140.149  	data->data.length = (__u16)len;
 140.150  	data->data.flags = 1;
 140.151 -	bcm43xx_unlock_noirq(bcm);
 140.152 +	mutex_unlock(&bcm->mutex);
 140.153  
 140.154  	return 0;
 140.155  }
 140.156 @@ -350,7 +351,8 @@ static int bcm43xx_wx_set_rts(struct net
 140.157  	unsigned long flags;
 140.158  	int err = -EINVAL;
 140.159  
 140.160 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.161 +	mutex_lock(&bcm->mutex);
 140.162 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 140.163  	if (data->rts.disabled) {
 140.164  		bcm->rts_threshold = BCM43xx_MAX_RTS_THRESHOLD;
 140.165  		err = 0;
 140.166 @@ -361,7 +363,8 @@ static int bcm43xx_wx_set_rts(struct net
 140.167  			err = 0;
 140.168  		}
 140.169  	}
 140.170 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.171 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 140.172 +	mutex_unlock(&bcm->mutex);
 140.173  
 140.174  	return err;
 140.175  }
 140.176 @@ -372,13 +375,12 @@ static int bcm43xx_wx_get_rts(struct net
 140.177  			      char *extra)
 140.178  {
 140.179  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
 140.180 -	unsigned long flags;
 140.181  
 140.182 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.183 +	mutex_lock(&bcm->mutex);
 140.184  	data->rts.value = bcm->rts_threshold;
 140.185  	data->rts.fixed = 0;
 140.186  	data->rts.disabled = (bcm->rts_threshold == BCM43xx_MAX_RTS_THRESHOLD);
 140.187 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.188 +	mutex_unlock(&bcm->mutex);
 140.189  
 140.190  	return 0;
 140.191  }
 140.192 @@ -392,7 +394,8 @@ static int bcm43xx_wx_set_frag(struct ne
 140.193  	unsigned long flags;
 140.194  	int err = -EINVAL;
 140.195  
 140.196 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.197 +	mutex_lock(&bcm->mutex);
 140.198 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 140.199  	if (data->frag.disabled) {
 140.200  		bcm->ieee->fts = MAX_FRAG_THRESHOLD;
 140.201  		err = 0;
 140.202 @@ -403,7 +406,8 @@ static int bcm43xx_wx_set_frag(struct ne
 140.203  			err = 0;
 140.204  		}
 140.205  	}
 140.206 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.207 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 140.208 +	mutex_unlock(&bcm->mutex);
 140.209  
 140.210  	return err;
 140.211  }
 140.212 @@ -414,13 +418,12 @@ static int bcm43xx_wx_get_frag(struct ne
 140.213  			       char *extra)
 140.214  {
 140.215  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
 140.216 -	unsigned long flags;
 140.217  
 140.218 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.219 +	mutex_lock(&bcm->mutex);
 140.220  	data->frag.value = bcm->ieee->fts;
 140.221  	data->frag.fixed = 0;
 140.222  	data->frag.disabled = (bcm->ieee->fts == MAX_FRAG_THRESHOLD);
 140.223 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.224 +	mutex_unlock(&bcm->mutex);
 140.225  
 140.226  	return 0;
 140.227  }
 140.228 @@ -442,7 +445,8 @@ static int bcm43xx_wx_set_xmitpower(stru
 140.229  		return -EOPNOTSUPP;
 140.230  	}
 140.231  
 140.232 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.233 +	mutex_lock(&bcm->mutex);
 140.234 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 140.235  	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED)
 140.236  		goto out_unlock;
 140.237  	radio = bcm43xx_current_radio(bcm);
 140.238 @@ -466,7 +470,8 @@ static int bcm43xx_wx_set_xmitpower(stru
 140.239  	err = 0;
 140.240  
 140.241  out_unlock:
 140.242 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.243 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 140.244 +	mutex_unlock(&bcm->mutex);
 140.245  
 140.246  	return err;
 140.247  }
 140.248 @@ -478,10 +483,9 @@ static int bcm43xx_wx_get_xmitpower(stru
 140.249  {
 140.250  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
 140.251  	struct bcm43xx_radioinfo *radio;
 140.252 -	unsigned long flags;
 140.253  	int err = -ENODEV;
 140.254  
 140.255 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.256 +	mutex_lock(&bcm->mutex);
 140.257  	if (bcm43xx_status(bcm) != BCM43xx_STAT_INITIALIZED)
 140.258  		goto out_unlock;
 140.259  	radio = bcm43xx_current_radio(bcm);
 140.260 @@ -493,7 +497,7 @@ static int bcm43xx_wx_get_xmitpower(stru
 140.261  
 140.262  	err = 0;
 140.263  out_unlock:
 140.264 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.265 +	mutex_unlock(&bcm->mutex);
 140.266  
 140.267  	return err;
 140.268  }
 140.269 @@ -580,7 +584,8 @@ static int bcm43xx_wx_set_interfmode(str
 140.270  		return -EINVAL;
 140.271  	}
 140.272  
 140.273 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.274 +	mutex_lock(&bcm->mutex);
 140.275 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 140.276  	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED) {
 140.277  		err = bcm43xx_radio_set_interference_mitigation(bcm, mode);
 140.278  		if (err) {
 140.279 @@ -595,7 +600,8 @@ static int bcm43xx_wx_set_interfmode(str
 140.280  		} else
 140.281  			bcm43xx_current_radio(bcm)->interfmode = mode;
 140.282  	}
 140.283 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.284 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 140.285 +	mutex_unlock(&bcm->mutex);
 140.286  
 140.287  	return err;
 140.288  }
 140.289 @@ -606,12 +612,11 @@ static int bcm43xx_wx_get_interfmode(str
 140.290  				     char *extra)
 140.291  {
 140.292  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
 140.293 -	unsigned long flags;
 140.294  	int mode;
 140.295  
 140.296 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.297 +	mutex_lock(&bcm->mutex);
 140.298  	mode = bcm43xx_current_radio(bcm)->interfmode;
 140.299 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.300 +	mutex_unlock(&bcm->mutex);
 140.301  
 140.302  	switch (mode) {
 140.303  	case BCM43xx_RADIO_INTERFMODE_NONE:
 140.304 @@ -641,9 +646,11 @@ static int bcm43xx_wx_set_shortpreamble(
 140.305  	int on;
 140.306  
 140.307  	on = *((int *)extra);
 140.308 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.309 +	mutex_lock(&bcm->mutex);
 140.310 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 140.311  	bcm->short_preamble = !!on;
 140.312 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.313 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 140.314 +	mutex_unlock(&bcm->mutex);
 140.315  
 140.316  	return 0;
 140.317  }
 140.318 @@ -654,12 +661,11 @@ static int bcm43xx_wx_get_shortpreamble(
 140.319  					char *extra)
 140.320  {
 140.321  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
 140.322 -	unsigned long flags;
 140.323  	int on;
 140.324  
 140.325 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.326 +	mutex_lock(&bcm->mutex);
 140.327  	on = bcm->short_preamble;
 140.328 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.329 +	mutex_unlock(&bcm->mutex);
 140.330  
 140.331  	if (on)
 140.332  		strncpy(extra, "1 (Short Preamble enabled)", MAX_WX_STRING);
 140.333 @@ -681,11 +687,13 @@ static int bcm43xx_wx_set_swencryption(s
 140.334  	
 140.335  	on = *((int *)extra);
 140.336  
 140.337 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.338 +	mutex_lock(&bcm->mutex);
 140.339 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 140.340  	bcm->ieee->host_encrypt = !!on;
 140.341  	bcm->ieee->host_decrypt = !!on;
 140.342  	bcm->ieee->host_build_iv = !on;
 140.343 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.344 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 140.345 +	mutex_unlock(&bcm->mutex);
 140.346  
 140.347  	return 0;
 140.348  }
 140.349 @@ -696,12 +704,11 @@ static int bcm43xx_wx_get_swencryption(s
 140.350  				       char *extra)
 140.351  {
 140.352  	struct bcm43xx_private *bcm = bcm43xx_priv(net_dev);
 140.353 -	unsigned long flags;
 140.354  	int on;
 140.355  
 140.356 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.357 +	mutex_lock(&bcm->mutex);
 140.358  	on = bcm->ieee->host_encrypt;
 140.359 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.360 +	mutex_unlock(&bcm->mutex);
 140.361  
 140.362  	if (on)
 140.363  		strncpy(extra, "1 (SW encryption enabled) ", MAX_WX_STRING);
 140.364 @@ -764,11 +771,13 @@ static int bcm43xx_wx_sprom_read(struct 
 140.365  	if (!sprom)
 140.366  		goto out;
 140.367  
 140.368 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.369 +	mutex_lock(&bcm->mutex);
 140.370 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 140.371  	err = -ENODEV;
 140.372  	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED)
 140.373  		err = bcm43xx_sprom_read(bcm, sprom);
 140.374 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.375 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 140.376 +	mutex_unlock(&bcm->mutex);
 140.377  	if (!err)
 140.378  		data->data.length = sprom2hex(sprom, extra);
 140.379  	kfree(sprom);
 140.380 @@ -809,11 +818,15 @@ static int bcm43xx_wx_sprom_write(struct
 140.381  	if (err)
 140.382  		goto out_kfree;
 140.383  
 140.384 -	bcm43xx_lock_irqsafe(bcm, flags);
 140.385 +	mutex_lock(&bcm->mutex);
 140.386 +	spin_lock_irqsave(&bcm->irq_lock, flags);
 140.387 +	spin_lock(&bcm->leds_lock);
 140.388  	err = -ENODEV;
 140.389  	if (bcm43xx_status(bcm) == BCM43xx_STAT_INITIALIZED)
 140.390  		err = bcm43xx_sprom_write(bcm, sprom);
 140.391 -	bcm43xx_unlock_irqsafe(bcm, flags);
 140.392 +	spin_unlock(&bcm->leds_lock);
 140.393 +	spin_unlock_irqrestore(&bcm->irq_lock, flags);
 140.394 +	mutex_unlock(&bcm->mutex);
 140.395  out_kfree:
 140.396  	kfree(sprom);
 140.397  out:
   141.1 --- a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.h	Tue Oct 02 09:52:15 2007 +0100
   141.2 +++ b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.h	Wed Oct 03 10:00:44 2007 +0100
   141.3 @@ -137,14 +137,8 @@ struct bcm43xx_xmitstatus {
   141.4  	u16 unknown; //FIXME
   141.5  };
   141.6  
   141.7 -#define BCM43xx_TXSTAT_FLAG_ACK		0x01
   141.8 -//TODO #define BCM43xx_TXSTAT_FLAG_???	0x02
   141.9 -//TODO #define BCM43xx_TXSTAT_FLAG_???	0x04
  141.10 -//TODO #define BCM43xx_TXSTAT_FLAG_???	0x08
  141.11 -//TODO #define BCM43xx_TXSTAT_FLAG_???	0x10
  141.12 -#define BCM43xx_TXSTAT_FLAG_IGNORE	0x20
  141.13 -//TODO #define BCM43xx_TXSTAT_FLAG_???	0x40
  141.14 -//TODO #define BCM43xx_TXSTAT_FLAG_???	0x80
  141.15 +#define BCM43xx_TXSTAT_FLAG_AMPDU	0x10
  141.16 +#define BCM43xx_TXSTAT_FLAG_INTER	0x20
  141.17  
  141.18  u8 bcm43xx_plcp_get_ratecode_cck(const u8 bitrate);
  141.19  u8 bcm43xx_plcp_get_ratecode_ofdm(const u8 bitrate);
   142.1 --- a/drivers/net/wireless/zd1211rw/zd_chip.c	Tue Oct 02 09:52:15 2007 +0100
   142.2 +++ b/drivers/net/wireless/zd1211rw/zd_chip.c	Wed Oct 03 10:00:44 2007 +0100
   142.3 @@ -717,7 +717,7 @@ static int zd1211b_hw_reset_phy(struct z
   142.4  		{ CR21,  0x0e }, { CR22,  0x23 }, { CR23,  0x90 },
   142.5  		{ CR24,  0x14 }, { CR25,  0x40 }, { CR26,  0x10 },
   142.6  		{ CR27,  0x10 }, { CR28,  0x7f }, { CR29,  0x80 },
   142.7 -		{ CR30,  0x49 }, /* jointly decoder, no ASIC */
   142.8 +		{ CR30,  0x4b }, /* ASIC/FWT, no jointly decoder */
   142.9  		{ CR31,  0x60 }, { CR32,  0x43 }, { CR33,  0x08 },
  142.10  		{ CR34,  0x06 }, { CR35,  0x0a }, { CR36,  0x00 },
  142.11  		{ CR37,  0x00 }, { CR38,  0x38 }, { CR39,  0x0c },
   143.1 --- a/drivers/pci/pci-sysfs.c	Tue Oct 02 09:52:15 2007 +0100
   143.2 +++ b/drivers/pci/pci-sysfs.c	Wed Oct 03 10:00:44 2007 +0100
   143.3 @@ -571,6 +571,9 @@ int pci_create_sysfs_dev_files (struct p
   143.4   */
   143.5  void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
   143.6  {
   143.7 +	if (!sysfs_initialized)
   143.8 +		return;
   143.9 +
  143.10  	if (pdev->cfg_size < 4096)
  143.11  		sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
  143.12  	else
   144.1 --- a/drivers/pci/quirks.c	Tue Oct 02 09:52:15 2007 +0100
   144.2 +++ b/drivers/pci/quirks.c	Wed Oct 03 10:00:44 2007 +0100
   144.3 @@ -685,33 +685,6 @@ static void __devinit quirk_vt82c598_id(
   144.4  }
   144.5  DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA,	PCI_DEVICE_ID_VIA_82C597_0,	quirk_vt82c598_id );
   144.6  
   144.7 -#ifdef CONFIG_ACPI_SLEEP
   144.8 -
   144.9 -/*
  144.10 - * Some VIA systems boot with the abnormal status flag set. This can cause
  144.11 - * the BIOS to re-POST the system on resume rather than passing control
  144.12 - * back to the OS.  Clear the flag on boot
  144.13 - */
  144.14 -static void __devinit quirk_via_abnormal_poweroff(struct pci_dev *dev)
  144.15 -{
  144.16 -	u32 reg;
  144.17 -
  144.18 -	acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
  144.19 -				&reg);
  144.20 -
  144.21 -	if (reg & 0x800) {
  144.22 -		printk("Clearing abnormal poweroff flag\n");
  144.23 -		acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
  144.24 -					ACPI_REGISTER_PM1_STATUS,
  144.25 -					(u16)0x800);
  144.26 -	}
  144.27 -}
  144.28 -
  144.29 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235, quirk_via_abnormal_poweroff);
  144.30 -DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, quirk_via_abnormal_poweroff);
  144.31 -
  144.32 -#endif
  144.33 -
  144.34  /*
  144.35   * CardBus controllers have a legacy base address that enables them
  144.36   * to respond as i82365 pcmcia controllers.  We don't want them to
   145.1 --- a/drivers/pcmcia/ds.c	Tue Oct 02 09:52:15 2007 +0100
   145.2 +++ b/drivers/pcmcia/ds.c	Wed Oct 03 10:00:44 2007 +0100
   145.3 @@ -1264,6 +1264,11 @@ static void pcmcia_bus_remove_socket(str
   145.4  	socket->pcmcia_state.dead = 1;
   145.5  	pccard_register_pcmcia(socket, NULL);
   145.6  
   145.7 +	/* unregister any unbound devices */
   145.8 +	mutex_lock(&socket->skt_mutex);
   145.9 +	pcmcia_card_remove(socket, NULL);
  145.10 +	mutex_unlock(&socket->skt_mutex);
  145.11 +
  145.12  	pcmcia_put_socket(socket);
  145.13  
  145.14  	return;
   146.1 --- a/drivers/rtc/rtc-max6902.c	Tue Oct 02 09:52:15 2007 +0100
   146.2 +++ b/drivers/rtc/rtc-max6902.c	Wed Oct 03 10:00:44 2007 +0100
   146.3 @@ -137,7 +137,7 @@ static int max6902_get_datetime(struct d
   146.4  	dt->tm_min	= BCD2BIN(chip->buf[2]);
   146.5  	dt->tm_hour	= BCD2BIN(chip->buf[3]);
   146.6  	dt->tm_mday	= BCD2BIN(chip->buf[4]);
   146.7 -	dt->tm_mon	= BCD2BIN(chip->buf[5] - 1);
   146.8 +	dt->tm_mon	= BCD2BIN(chip->buf[5]) - 1;
   146.9  	dt->tm_wday	= BCD2BIN(chip->buf[6]);
  146.10  	dt->tm_year = BCD2BIN(chip->buf[7]);
  146.11  
   147.1 --- a/drivers/rtc/rtc-pcf8563.c	Tue Oct 02 09:52:15 2007 +0100
   147.2 +++ b/drivers/rtc/rtc-pcf8563.c	Wed Oct 03 10:00:44 2007 +0100
   147.3 @@ -95,7 +95,7 @@ static int pcf8563_get_datetime(struct i
   147.4  	tm->tm_wday = buf[PCF8563_REG_DW] & 0x07;
   147.5  	tm->tm_mon = BCD2BIN(buf[PCF8563_REG_MO] & 0x1F) - 1; /* rtc mn 1-12 */
   147.6  	tm->tm_year = BCD2BIN(buf[PCF8563_REG_YR])
   147.7 -		+ (buf[PCF8563_REG_MO] & PCF8563_MO_C ? 100 : 0);
   147.8 +		+ (buf[PCF8563_REG_MO] & PCF8563_MO_C ? 0 : 100);
   147.9  
  147.10  	dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
  147.11  		"mday=%d, mon=%d, year=%d, wday=%d\n",
  147.12 @@ -135,7 +135,7 @@ static int pcf8563_set_datetime(struct i
  147.13  
  147.14  	/* year and century */
  147.15  	buf[PCF8563_REG_YR] = BIN2BCD(tm->tm_year % 100);
  147.16 -	if (tm->tm_year / 100)
  147.17 +	if (tm->tm_year < 100)
  147.18  		buf[PCF8563_REG_MO] |= PCF8563_MO_C;
  147.19  
  147.20  	buf[PCF8563_REG_DW] = tm->tm_wday & 0x07;
   148.1 --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c	Tue Oct 02 09:52:15 2007 +0100
   148.2 +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c	Wed Oct 03 10:00:44 2007 +0100
   148.3 @@ -2539,15 +2539,28 @@ static void ahc_linux_set_iu(struct scsi
   148.4  static void ahc_linux_get_signalling(struct Scsi_Host *shost)
   148.5  {
   148.6  	struct ahc_softc *ahc = *(struct ahc_softc **)shost->hostdata;
   148.7 -	u8 mode = ahc_inb(ahc, SBLKCTL);
   148.8 +	unsigned long flags;
   148.9 +	u8 mode;
  148.10 +
  148.11 +	if (!(ahc->features & AHC_ULTRA2)) {
  148.12 +		/* non-LVD chipset, may not have SBLKCTL reg */
  148.13 +		spi_signalling(shost) = 
  148.14 +			ahc->features & AHC_HVD ?
  148.15 +			SPI_SIGNAL_HVD :
  148.16 +			SPI_SIGNAL_SE;
  148.17 +		return;
  148.18 +	}
  148.19 +
  148.20 +	ahc_lock(ahc, &flags);
  148.21 +	ahc_pause(ahc);
  148.22 +	mode = ahc_inb(ahc, SBLKCTL);
  148.23 +	ahc_unpause(ahc);
  148.24 +	ahc_unlock(ahc, &flags);
  148.25  
  148.26  	if (mode & ENAB40)
  148.27  		spi_signalling(shost) = SPI_SIGNAL_LVD;
  148.28  	else if (mode & ENAB20)
  148.29 -		spi_signalling(shost) = 
  148.30 -			ahc->features & AHC_HVD ?
  148.31 -			SPI_SIGNAL_HVD :
  148.32 -			SPI_SIGNAL_SE;
  148.33 +		spi_signalling(shost) = SPI_SIGNAL_SE;
  148.34  	else
  148.35  		spi_signalling(shost) = SPI_SIGNAL_UNKNOWN;
  148.36  }
   149.1 --- a/drivers/scsi/sata_mv.c	Tue Oct 02 09:52:15 2007 +0100
   149.2 +++ b/drivers/scsi/sata_mv.c	Wed Oct 03 10:00:44 2007 +0100
   149.3 @@ -463,6 +463,7 @@ static const struct ata_port_operations 
   149.4  
   149.5  	.qc_prep		= mv_qc_prep_iie,
   149.6  	.qc_issue		= mv_qc_issue,
   149.7 +	.data_xfer		= ata_mmio_data_xfer,
   149.8  
   149.9  	.eng_timeout		= mv_eng_timeout,
  149.10  
   150.1 --- a/drivers/scsi/scsi_lib.c	Tue Oct 02 09:52:15 2007 +0100
   150.2 +++ b/drivers/scsi/scsi_lib.c	Wed Oct 03 10:00:44 2007 +0100
   150.3 @@ -191,6 +191,7 @@ int scsi_execute(struct scsi_device *sde
   150.4  		goto out;
   150.5  
   150.6  	req->cmd_len = COMMAND_SIZE(cmd[0]);
   150.7 +	memset(req->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
   150.8  	memcpy(req->cmd, cmd, req->cmd_len);
   150.9  	req->sense = sense;
  150.10  	req->sense_len = 0;
  150.11 @@ -408,6 +409,7 @@ int scsi_execute_async(struct scsi_devic
  150.12  		goto free_req;
  150.13  
  150.14  	req->cmd_len = cmd_len;
  150.15 +	memset(req->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
  150.16  	memcpy(req->cmd, cmd, req->cmd_len);
  150.17  	req->sense = sioc->sense;
  150.18  	req->sense_len = 0;
   151.1 --- a/drivers/serial/serial_core.c	Tue Oct 02 09:52:15 2007 +0100
   151.2 +++ b/drivers/serial/serial_core.c	Wed Oct 03 10:00:44 2007 +0100
   151.3 @@ -1932,6 +1932,9 @@ int uart_suspend_port(struct uart_driver
   151.4  	if (state->info && state->info->flags & UIF_INITIALIZED) {
   151.5  		const struct uart_ops *ops = port->ops;
   151.6  
   151.7 +		state->info->flags = (state->info->flags & ~UIF_INITIALIZED)
   151.8 +				     | UIF_SUSPENDED;
   151.9 +
  151.10  		spin_lock_irq(&port->lock);
  151.11  		ops->stop_tx(port);
  151.12  		ops->set_mctrl(port, 0);
  151.13 @@ -1991,7 +1994,7 @@ int uart_resume_port(struct uart_driver 
  151.14  		console_start(port->cons);
  151.15  	}
  151.16  
  151.17 -	if (state->info && state->info->flags & UIF_INITIALIZED) {
  151.18 +	if (state->info && state->info->flags & UIF_SUSPENDED) {
  151.19  		const struct uart_ops *ops = port->ops;
  151.20  		int ret;
  151.21  
  151.22 @@ -2003,15 +2006,17 @@ int uart_resume_port(struct uart_driver 
  151.23  			ops->set_mctrl(port, port->mctrl);
  151.24  			ops->start_tx(port);
  151.25  			spin_unlock_irq(&port->lock);
  151.26 +			state->info->flags |= UIF_INITIALIZED;
  151.27  		} else {
  151.28  			/*
  151.29  			 * Failed to resume - maybe hardware went away?
  151.30  			 * Clear the "initialized" flag so we won't try
  151.31  			 * to call the low level drivers shutdown method.
  151.32  			 */
  151.33 -			state->info->flags &= ~UIF_INITIALIZED;
  151.34  			uart_shutdown(state);
  151.35  		}
  151.36 +
  151.37 +		state->info->flags &= ~UIF_SUSPENDED;
  151.38  	}
  151.39  
  151.40  	mutex_unlock(&state->mutex);
   152.1 --- a/drivers/serial/serial_cs.c	Tue Oct 02 09:52:15 2007 +0100
   152.2 +++ b/drivers/serial/serial_cs.c	Wed Oct 03 10:00:44 2007 +0100
   152.3 @@ -185,14 +185,12 @@ static int serial_suspend(struct pcmcia_
   152.4  
   152.5  static int serial_resume(struct pcmcia_device *link)
   152.6  {
   152.7 -	if (pcmcia_dev_present(link)) {
   152.8 -		struct serial_info *info = link->priv;
   152.9 -		int i;
  152.10 +	struct serial_info *info = link->priv;
  152.11 +	int i;
  152.12  
  152.13 -		for (i = 0; i < info->ndev; i++)
  152.14 -			serial8250_resume_port(info->line[i]);
  152.15 -		wakeup_card(info);
  152.16 -	}
  152.17 +	for (i = 0; i < info->ndev; i++)
  152.18 +		serial8250_resume_port(info->line[i]);
  152.19 +	wakeup_card(info);
  152.20  
  152.21  	return 0;
  152.22  }
   153.1 --- a/drivers/usb/class/usblp.c	Tue Oct 02 09:52:15 2007 +0100
   153.2 +++ b/drivers/usb/class/usblp.c	Wed Oct 03 10:00:44 2007 +0100
   153.3 @@ -701,6 +701,7 @@ static ssize_t usblp_write(struct file *
   153.4  		usblp->wcomplete = 0;
   153.5  		err = usb_submit_urb(usblp->writeurb, GFP_KERNEL);
   153.6  		if (err) {
   153.7 +			usblp->wcomplete = 1;
   153.8  			if (err != -ENOMEM)
   153.9  				count = -EIO;
  153.10  			else
   154.1 --- a/drivers/usb/core/devio.c	Tue Oct 02 09:52:15 2007 +0100
   154.2 +++ b/drivers/usb/core/devio.c	Wed Oct 03 10:00:44 2007 +0100
   154.3 @@ -59,6 +59,9 @@
   154.4  #define USB_DEVICE_MAX			USB_MAXBUS * 128
   154.5  static struct class *usb_device_class;
   154.6  
   154.7 +/* Mutual exclusion for removal, open, and release */
   154.8 +DEFINE_MUTEX(usbfs_mutex);
   154.9 +
  154.10  struct async {
  154.11  	struct list_head asynclist;
  154.12  	struct dev_state *ps;
  154.13 @@ -541,15 +544,13 @@ static int usbdev_open(struct inode *ino
  154.14  	struct dev_state *ps;
  154.15  	int ret;
  154.16  
  154.17 -	/* 
  154.18 -	 * no locking necessary here, as chrdev_open has the kernel lock
  154.19 -	 * (still acquire the kernel lock for safety)
  154.20 -	 */
  154.21 +	/* Protect against simultaneous removal or release */
  154.22 +	mutex_lock(&usbfs_mutex);
  154.23 +
  154.24  	ret = -ENOMEM;
  154.25  	if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL)))
  154.26 -		goto out_nolock;
  154.27 +		goto out;
  154.28  
  154.29 -	lock_kernel();
  154.30  	ret = -ENOENT;
  154.31  	/* check if we are called from a real node or usbfs */
  154.32  	if (imajor(inode) == USB_DEVICE_MAJOR)
  154.33 @@ -579,9 +580,8 @@ static int usbdev_open(struct inode *ino
  154.34  	list_add_tail(&ps->list, &dev->filelist);
  154.35  	file->private_data = ps;
  154.36   out:
  154.37 -	unlock_kernel();
  154.38 - out_nolock:
  154.39 -        return ret;
  154.40 +	mutex_unlock(&usbfs_mutex);
  154.41 +	return ret;
  154.42  }
  154.43  
  154.44  static int usbdev_release(struct inode *inode, struct file *file)
  154.45 @@ -591,7 +591,12 @@ static int usbdev_release(struct inode *
  154.46  	unsigned int ifnum;
  154.47  
  154.48  	usb_lock_device(dev);
  154.49 +
  154.50 +	/* Protect against simultaneous open */
  154.51 +	mutex_lock(&usbfs_mutex);
  154.52  	list_del_init(&ps->list);
  154.53 +	mutex_unlock(&usbfs_mutex);
  154.54 +
  154.55  	for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed);
  154.56  			ifnum++) {
  154.57  		if (test_bit(ifnum, &ps->ifclaimed))
  154.58 @@ -600,9 +605,8 @@ static int usbdev_release(struct inode *
  154.59  	destroy_all_async(ps);
  154.60  	usb_unlock_device(dev);
  154.61  	usb_put_dev(dev);
  154.62 -	ps->dev = NULL;
  154.63  	kfree(ps);
  154.64 -        return 0;
  154.65 +	return 0;
  154.66  }
  154.67  
  154.68  static int proc_control(struct dev_state *ps, void __user *arg)
   155.1 --- a/drivers/usb/core/notify.c	Tue Oct 02 09:52:15 2007 +0100
   155.2 +++ b/drivers/usb/core/notify.c	Wed Oct 03 10:00:44 2007 +0100
   155.3 @@ -50,8 +50,11 @@ void usb_notify_add_device(struct usb_de
   155.4  
   155.5  void usb_notify_remove_device(struct usb_device *udev)
   155.6  {
   155.7 +	/* Protect against simultaneous usbfs open */
   155.8 +	mutex_lock(&usbfs_mutex);
   155.9  	blocking_notifier_call_chain(&usb_notifier_list,
  155.10  			USB_DEVICE_REMOVE, udev);
  155.11 +	mutex_unlock(&usbfs_mutex);
  155.12  }
  155.13  
  155.14  void usb_notify_add_bus(struct usb_bus *ubus)
   156.1 --- a/drivers/usb/core/usb.h	Tue Oct 02 09:52:15 2007 +0100
   156.2 +++ b/drivers/usb/core/usb.h	Wed Oct 03 10:00:44 2007 +0100
   156.3 @@ -59,6 +59,7 @@ static inline int is_active(struct usb_i
   156.4  extern const char *usbcore_name;
   156.5  
   156.6  /* usbfs stuff */
   156.7 +extern struct mutex usbfs_mutex;
   156.8  extern struct usb_driver usbfs_driver;
   156.9  extern struct file_operations usbfs_devices_fops;
  156.10  extern struct file_operations usbfs_device_file_operations;
   157.1 --- a/drivers/usb/gadget/ether.c	Tue Oct 02 09:52:15 2007 +0100
   157.2 +++ b/drivers/usb/gadget/ether.c	Wed Oct 03 10:00:44 2007 +0100
   157.3 @@ -262,7 +262,7 @@ MODULE_PARM_DESC(host_addr, "Host Ethern
   157.4  #define DEV_CONFIG_CDC
   157.5  #endif
   157.6  
   157.7 -#ifdef CONFIG_USB_GADGET_MUSBHDRC
   157.8 +#ifdef CONFIG_USB_GADGET_MUSB_HDRC
   157.9  #define DEV_CONFIG_CDC
  157.10  #endif
  157.11  
  157.12 @@ -2564,7 +2564,7 @@ static struct usb_gadget_driver eth_driv
  157.13  
  157.14  	.function	= (char *) driver_desc,
  157.15  	.bind		= eth_bind,
  157.16 -	.unbind		= __exit_p(eth_unbind),
  157.17 +	.unbind		= eth_unbind,
  157.18  
  157.19  	.setup		= eth_setup,
  157.20  	.disconnect	= eth_disconnect,
   158.1 --- a/drivers/usb/input/hid-core.c	Tue Oct 02 09:52:15 2007 +0100
   158.2 +++ b/drivers/usb/input/hid-core.c	Wed Oct 03 10:00:44 2007 +0100
   158.3 @@ -1734,10 +1734,10 @@ static const struct hid_blacklist {
   158.4  	{ USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_POWERBOOK_HAS_FN },
   158.5  	{ USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_POWERBOOK_HAS_FN },
   158.6  	{ USB_VENDOR_ID_APPLE, 0x0214, HID_QUIRK_POWERBOOK_HAS_FN },
   158.7 -	{ USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN },
   158.8 +	{ USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
   158.9  	{ USB_VENDOR_ID_APPLE, 0x0216, HID_QUIRK_POWERBOOK_HAS_FN },
  158.10  	{ USB_VENDOR_ID_APPLE, 0x0217, HID_QUIRK_POWERBOOK_HAS_FN },
  158.11 -	{ USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN },
  158.12 +	{ USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_HAS_FN | HID_QUIRK_POWERBOOK_ISO_KEYBOARD},
  158.13  	{ USB_VENDOR_ID_APPLE, 0x0219, HID_QUIRK_POWERBOOK_HAS_FN },
  158.14  	{ USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN },
  158.15  	{ USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN },
   159.1 --- a/drivers/usb/input/hid-input.c	Tue Oct 02 09:52:15 2007 +0100
   159.2 +++ b/drivers/usb/input/hid-input.c	Wed Oct 03 10:00:44 2007 +0100
   159.3 @@ -123,6 +123,12 @@ static struct hidinput_key_translation p
   159.4  	{ }
   159.5  };
   159.6  
   159.7 +static struct hidinput_key_translation powerbook_iso_keyboard[] = {
   159.8 +	{ KEY_GRAVE,    KEY_102ND },
   159.9 +	{ KEY_102ND,    KEY_GRAVE },
  159.10 +	{ }
  159.11 +};
  159.12 +
  159.13  static int usbhid_pb_fnmode = 1;
  159.14  module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644);
  159.15  MODULE_PARM_DESC(pb_fnmode,
  159.16 @@ -197,6 +203,14 @@ static int hidinput_pb_event(struct hid_
  159.17  		}
  159.18  	}
  159.19  
  159.20 +	if (hid->quirks & HID_QUIRK_POWERBOOK_ISO_KEYBOARD) {
  159.21 +		trans = find_translation(powerbook_iso_keyboard, usage->code);
  159.22 +		if (trans) {
  159.23 +			input_event(input, usage->type, trans->to, value);
  159.24 +			return 1;
  159.25 +		}
  159.26 +	}
  159.27 +
  159.28  	return 0;
  159.29  }
  159.30  
  159.31 @@ -212,6 +226,9 @@ static void hidinput_pb_setup(struct inp
  159.32  
  159.33  	for (trans = powerbook_numlock_keys; trans->from; trans++)
  159.34  		set_bit(trans->to, input->keybit);
  159.35 +
  159.36 +	for (trans = powerbook_iso_keyboard; trans->from; trans++)
  159.37 +		set_bit(trans->to, input->keybit);
  159.38  }
  159.39  #else
  159.40  static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev *input,
   160.1 --- a/drivers/usb/input/hid.h	Tue Oct 02 09:52:15 2007 +0100
   160.2 +++ b/drivers/usb/input/hid.h	Wed Oct 03 10:00:44 2007 +0100
   160.3 @@ -260,6 +260,7 @@ struct hid_item {
   160.4  #define HID_QUIRK_POWERBOOK_HAS_FN		0x00001000
   160.5  #define HID_QUIRK_POWERBOOK_FN_ON		0x00002000
   160.6  #define HID_QUIRK_INVERT_HWHEEL			0x00004000
   160.7 +#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD	0x00010000
   160.8  
   160.9  /*
  160.10   * This is the global environment of the parser. This information is
   161.1 --- a/drivers/usb/input/usbtouchscreen.c	Tue Oct 02 09:52:15 2007 +0100
   161.2 +++ b/drivers/usb/input/usbtouchscreen.c	Wed Oct 03 10:00:44 2007 +0100
   161.3 @@ -522,7 +522,7 @@ static int usbtouch_probe(struct usb_int
   161.4  		                     type->max_press, 0, 0);
   161.5  
   161.6  	usb_fill_int_urb(usbtouch->irq, usbtouch->udev,
   161.7 -			 usb_rcvintpipe(usbtouch->udev, 0x81),
   161.8 +			 usb_rcvintpipe(usbtouch->udev, endpoint->bEndpointAddress),
   161.9  			 usbtouch->data, type->rept_size,
  161.10  			 usbtouch_irq, usbtouch, endpoint->bInterval);
  161.11  
   162.1 --- a/drivers/video/fbmem.c	Tue Oct 02 09:52:15 2007 +0100
   162.2 +++ b/drivers/video/fbmem.c	Wed Oct 03 10:00:44 2007 +0100
   162.3 @@ -554,7 +554,8 @@ static int fbmem_read_proc(char *buf, ch
   162.4  	int clen;
   162.5  
   162.6  	clen = 0;
   162.7 -	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && len < 4000; fi++)
   162.8 +	for (fi = registered_fb; fi < &registered_fb[FB_MAX] && clen < 4000;
   162.9 +	     fi++)
  162.10  		if (*fi)
  162.11  			clen += sprintf(buf + clen, "%d %s\n",
  162.12  				        (*fi)->node,
   163.1 --- a/drivers/video/fbsysfs.c	Tue Oct 02 09:52:15 2007 +0100
   163.2 +++ b/drivers/video/fbsysfs.c	Wed Oct 03 10:00:44 2007 +0100
   163.3 @@ -397,6 +397,12 @@ static ssize_t store_bl_curve(struct cla
   163.4  	u8 tmp_curve[FB_BACKLIGHT_LEVELS];
   163.5  	unsigned int i;
   163.6  
   163.7 +	/* Some drivers don't use framebuffer_alloc(), but those also
   163.8 +	 * don't have backlights.
   163.9 +	 */
  163.10 +	if (!fb_info || !fb_info->bl_dev)
  163.11 +		return -ENODEV;
  163.12 +
  163.13  	if (count != (FB_BACKLIGHT_LEVELS / 8 * 24))
  163.14  		return -EINVAL;
  163.15  
  163.16 @@ -430,6 +436,12 @@ static ssize_t show_bl_curve(struct clas
  163.17  	ssize_t len = 0;
  163.18  	unsigned int i;
  163.19  
  163.20 +	/* Some drivers don't use framebuffer_alloc(), but those also
  163.21 +	 * don't have backlights.
  163.22 +	 */
  163.23 +	if (!fb_info || !fb_info->bl_dev)
  163.24 +		return -ENODEV;
  163.25 +
  163.26  	mutex_lock(&fb_info->bl_mutex);
  163.27  	for (i = 0; i < FB_BACKLIGHT_LEVELS; i += 8)
  163.28  		len += snprintf(&buf[len], PAGE_SIZE,
   164.1 --- a/drivers/video/nvidia/nv_hw.c	Tue Oct 02 09:52:15 2007 +0100
   164.2 +++ b/drivers/video/nvidia/nv_hw.c	Wed Oct 03 10:00:44 2007 +0100
   164.3 @@ -145,12 +145,18 @@ static void nvGetClocks(struct nvidia_pa
   164.4  
   164.5  	if (par->Architecture >= NV_ARCH_40) {
   164.6  		pll = NV_RD32(par->PMC, 0x4020);
   164.7 -		P = (pll >> 16) & 0x03;
   164.8 +		P = (pll >> 16) & 0x07;
   164.9  		pll = NV_RD32(par->PMC, 0x4024);
  164.10  		M = pll & 0xFF;
  164.11  		N = (pll >> 8) & 0xFF;
  164.12 -		MB = (pll >> 16) & 0xFF;
  164.13 -		NB = (pll >> 24) & 0xFF;
  164.14 +		if (((par->Chipset & 0xfff0) == 0x0290) ||
  164.15 +				((par->Chipset & 0xfff0) == 0x0390)) {
  164.16 +			MB = 1;
  164.17 +			NB = 1;
  164.18 +		} else {
  164.19 +			MB = (pll >> 16) & 0xFF;
  164.20 +			NB = (pll >> 24) & 0xFF;
  164.21 +		}
  164.22  		*MClk = ((N * NB * par->CrystalFreqKHz) / (M * MB)) >> P;
  164.23  
  164.24  		pll = NV_RD32(par->PMC, 0x4000);
   165.1 --- a/drivers/video/nvidia/nv_setup.c	Tue Oct 02 09:52:15 2007 +0100
   165.2 +++ b/drivers/video/nvidia/nv_setup.c	Wed Oct 03 10:00:44 2007 +0100
   165.3 @@ -359,6 +359,7 @@ int NVCommonSetup(struct fb_info *info)
   165.4  	case 0x0186:
   165.5  	case 0x0187:
   165.6  	case 0x018D:
   165.7 +	case 0x0228:
   165.8  	case 0x0286:
   165.9  	case 0x028C:
  165.10  	case 0x0316:
  165.11 @@ -382,6 +383,10 @@ int NVCommonSetup(struct fb_info *info)
  165.12  	case 0x034C:
  165.13  	case 0x0160:
  165.14  	case 0x0166:
  165.15 +	case 0x0169:
  165.16 +	case 0x016B:
  165.17 +	case 0x016C:
  165.18 +	case 0x016D:
  165.19  	case 0x00C8:
  165.20  	case 0x00CC:
  165.21  	case 0x0144:
  165.22 @@ -639,12 +644,23 @@ int NVCommonSetup(struct fb_info *info)
  165.23  		par->fpHeight = NV_RD32(par->PRAMDAC, 0x0800) + 1;
  165.24  		par->fpSyncs = NV_RD32(par->PRAMDAC, 0x0848) & 0x30000033;
  165.25  
  165.26 -		printk("Panel size is %i x %i\n", par->fpWidth, par->fpHeight);
  165.27 +		printk("nvidiafb: Panel size is %i x %i\n", par->fpWidth, par->fpHeight);
  165.28  	}
  165.29  
  165.30  	if (monA)
  165.31  		info->monspecs = *monA;
  165.32  
  165.33 +	if (!par->FlatPanel || !par->twoHeads)
  165.34 +		par->FPDither = 0;
  165.35 +
  165.36 +	par->LVDS = 0;
  165.37 +	if (par->FlatPanel && par->twoHeads) {
  165.38 +		NV_WR32(par->PRAMDAC0, 0x08B0, 0x00010004);
  165.39 +		if (par->PRAMDAC0[0x08b4] & 1)
  165.40 +			par->LVDS = 1;
  165.41 +		printk("nvidiafb: Panel is %s\n", par->LVDS ? "LVDS" : "TMDS");
  165.42 +	}
  165.43 +
  165.44  	kfree(edidA);
  165.45  	kfree(edidB);
  165.46  done:
   166.1 --- a/drivers/video/nvidia/nv_type.h	Tue Oct 02 09:52:15 2007 +0100
   166.2 +++ b/drivers/video/nvidia/nv_type.h	Wed Oct 03 10:00:44 2007 +0100
   166.3 @@ -129,6 +129,7 @@ struct nvidia_par {
   166.4  	int fpHeight;
   166.5  	int PanelTweak;
   166.6  	int paneltweak;
   166.7 +	int LVDS;
   166.8  	int pm_state;
   166.9  	u32 crtcSync_read;
  166.10  	u32 fpSyncs;
   167.1 --- a/drivers/video/nvidia/nvidia.c	Tue Oct 02 09:52:15 2007 +0100
   167.2 +++ b/drivers/video/nvidia/nvidia.c	Wed Oct 03 10:00:44 2007 +0100
   167.3 @@ -1145,20 +1145,20 @@ static u32 __devinit nvidia_get_arch(str
   167.4  	case 0x0340:		/* GeForceFX 5700 */
   167.5  		arch = NV_ARCH_30;
   167.6  		break;
   167.7 -	case 0x0040:
   167.8 -	case 0x00C0:
   167.9 -	case 0x0120:
  167.10 +	case 0x0040:		/* GeForce 6800 */
  167.11 +	case 0x00C0:		/* GeForce 6800 */
  167.12 +	case 0x0120:		/* GeForce 6800 */
  167.13  	case 0x0130:
  167.14 -	case 0x0140:
  167.15 -	case 0x0160:
  167.16 -	case 0x01D0:
  167.17 -	case 0x0090:
  167.18 -	case 0x0210:
  167.19 -	case 0x0220:
  167.20 +	case 0x0140:		/* GeForce 6600 */
  167.21 +	case 0x0160:		/* GeForce 6200 */
  167.22 +	case 0x01D0:		/* GeForce 7200, 7300, 7400 */
  167.23 +	case 0x0090:		/* GeForce 7800 */
  167.24 +	case 0x0210:		/* GeForce 6800 */
  167.25 +	case 0x0220:		/* GeForce 6200 */
  167.26  	case 0x0230:
  167.27 -	case 0x0240:
  167.28 -	case 0x0290:
  167.29 -	case 0x0390:
  167.30 +	case 0x0240:		/* GeForce 6100 */
  167.31 +	case 0x0290:		/* GeForce 7900 */
  167.32 +	case 0x0390:		/* GeForce 7600 */
  167.33  		arch = NV_ARCH_40;
  167.34  		break;
  167.35  	case 0x0020:		/* TNT, TNT2 */
   168.1 --- a/fs/buffer.c	Tue Oct 02 09:52:15 2007 +0100
   168.2 +++ b/fs/buffer.c	Wed Oct 03 10:00:44 2007 +0100
   168.3 @@ -838,7 +838,10 @@ EXPORT_SYMBOL(mark_buffer_dirty_inode);
   168.4   */
   168.5  int __set_page_dirty_buffers(struct page *page)
   168.6  {
   168.7 -	struct address_space * const mapping = page->mapping;
   168.8 +	struct address_space * const mapping = page_mapping(page);
   168.9 +
  168.10 +	if (unlikely(!mapping))
  168.11 +		return !TestSetPageDirty(page);
  168.12  
  168.13  	spin_lock(&mapping->private_lock);
  168.14  	if (page_has_buffers(page)) {
  168.15 @@ -1176,8 +1179,21 @@ grow_buffers(struct block_device *bdev, 
  168.16  	} while ((size << sizebits) < PAGE_SIZE);
  168.17  
  168.18  	index = block >> sizebits;
  168.19 +
  168.20 +	/*
  168.21 +	 * Check for a block which wants to lie outside our maximum possible
  168.22 +	 * pagecache index.  (this comparison is done using sector_t types).
  168.23 +	 */
  168.24 +	if (unlikely(index != block >> sizebits)) {
  168.25 +		char b[BDEVNAME_SIZE];
  168.26 +
  168.27 +		printk(KERN_ERR "%s: requested out-of-range block %llu for "
  168.28 +			"device %s\n",
  168.29 +			__FUNCTION__, (unsigned long long)block,
  168.30 +			bdevname(bdev, b));
  168.31 +		return -EIO;
  168.32 +	}
  168.33  	block = index << sizebits;
  168.34 -
  168.35  	/* Create a page with the proper size buffers.. */
  168.36  	page = grow_dev_page(bdev, block, index, size);
  168.37  	if (!page)
  168.38 @@ -1204,12 +1220,16 @@ static struct buffer_head *
  168.39  
  168.40  	for (;;) {
  168.41  		struct buffer_head * bh;
  168.42 +		int ret;
  168.43  
  168.44  		bh = __find_get_block(bdev, block, size);
  168.45  		if (bh)
  168.46  			return bh;
  168.47  
  168.48 -		if (!grow_buffers(bdev, block, size))
  168.49 +		ret = grow_buffers(bdev, block, size);
  168.50 +		if (ret < 0)
  168.51 +			return NULL;
  168.52 +		if (ret == 0)
  168.53  			free_more_memory();
  168.54  	}
  168.55  }
   169.1 --- a/fs/cifs/CHANGES	Tue Oct 02 09:52:15 2007 +0100
   169.2 +++ b/fs/cifs/CHANGES	Wed Oct 03 10:00:44 2007 +0100
   169.3 @@ -6,7 +6,11 @@ on requests on other threads.  Improve P
   169.4  (lock cancel now works, and unlock of merged range works even
   169.5  to Windows servers now).  Fix oops on mount to lanman servers
   169.6  (win9x, os/2 etc.) when null password.  Do not send listxattr
   169.7 -(SMB to query all EAs) if nouser_xattr specified.
   169.8 +(SMB to query all EAs) if nouser_xattr specified.  Return error
   169.9 +in rename 2nd attempt retry (ie report if rename by handle also
  169.10 +fails, after rename by path fails, we were not reporting whether
  169.11 +the retry worked or not).
  169.12 +
  169.13  
  169.14  Version 1.44
  169.15  ------------
   170.1 --- a/fs/cifs/file.c	Tue Oct 02 09:52:15 2007 +0100
   170.2 +++ b/fs/cifs/file.c	Wed Oct 03 10:00:44 2007 +0100
   170.3 @@ -752,6 +752,7 @@ int cifs_lock(struct file *file, int cmd
   170.4  			int stored_rc = 0;
   170.5  			struct cifsLockInfo *li, *tmp;
   170.6  
   170.7 +			rc = 0;
   170.8  			down(&fid->lock_sem);
   170.9  			list_for_each_entry_safe(li, tmp, &fid->llist, llist) {
  170.10  				if (pfLock->fl_start <= li->offset &&
  170.11 @@ -766,7 +767,7 @@ int cifs_lock(struct file *file, int cmd
  170.12  					kfree(li);
  170.13  				}
  170.14  			}
  170.15 -		up(&fid->lock_sem);
  170.16 +			up(&fid->lock_sem);
  170.17  		}
  170.18  	}
  170.19  
   171.1 --- a/fs/cifs/inode.c	Tue Oct 02 09:52:15 2007 +0100
   171.2 +++ b/fs/cifs/inode.c	Wed Oct 03 10:00:44 2007 +0100
   171.3 @@ -880,10 +880,14 @@ int cifs_rename(struct inode *source_ino
   171.4  			kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO), GFP_KERNEL);
   171.5  		if (info_buf_source != NULL) {
   171.6  			info_buf_target = info_buf_source + 1;
   171.7 -			rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName,
   171.8 -				info_buf_source, cifs_sb_source->local_nls, 
   171.9 -				cifs_sb_source->mnt_cifs_flags &
  171.10 -					CIFS_MOUNT_MAP_SPECIAL_CHR);
  171.11 +			if (pTcon->ses->capabilities & CAP_UNIX)
  171.12 +				rc = CIFSSMBUnixQPathInfo(xid, pTcon, fromName,
  171.13 +					info_buf_source, 
  171.14 +					cifs_sb_source->local_nls,
  171.15 +					cifs_sb_source->mnt_cifs_flags &
  171.16 +						CIFS_MOUNT_MAP_SPECIAL_CHR);
  171.17 +			/* else rc is still EEXIST so will fall through to
  171.18 +			   unlink the target and retry rename */
  171.19  			if (rc == 0) {
  171.20  				rc = CIFSSMBUnixQPathInfo(xid, pTcon, toName,
  171.21  						info_buf_target,
  171.22 @@ -932,7 +936,7 @@ int cifs_rename(struct inode *source_ino
  171.23  				 cifs_sb_source->mnt_cifs_flags & 
  171.24  					CIFS_MOUNT_MAP_SPECIAL_CHR);
  171.25  		if (rc==0) {
  171.26 -			CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName,
  171.27 +			rc = CIFSSMBRenameOpenFile(xid, pTcon, netfid, toName,
  171.28  					      cifs_sb_source->local_nls, 
  171.29  					      cifs_sb_source->mnt_cifs_flags &
  171.30  						CIFS_MOUNT_MAP_SPECIAL_CHR);
   172.1 --- a/fs/compat.c	Tue Oct 02 09:52:15 2007 +0100
   172.2 +++ b/fs/compat.c	Wed Oct 03 10:00:44 2007 +0100
   172.3 @@ -873,7 +873,7 @@ asmlinkage long compat_sys_mount(char __
   172.4  
   172.5  	retval = -EINVAL;
   172.6  
   172.7 -	if (type_page) {
   172.8 +	if (type_page && data_page) {
   172.9  		if (!strcmp((char *)type_page, SMBFS_NAME)) {
  172.10  			do_smb_super_data_conv((void *)data_page);
  172.11  		} else if (!strcmp((char *)type_page, NCPFS_NAME)) {
   173.1 --- a/fs/ext2/super.c	Tue Oct 02 09:52:15 2007 +0100
   173.2 +++ b/fs/ext2/super.c	Wed Oct 03 10:00:44 2007 +0100
   173.3 @@ -701,10 +701,14 @@ static int ext2_fill_super(struct super_
   173.4  		set_opt(sbi->s_mount_opt, GRPID);
   173.5  	if (def_mount_opts & EXT2_DEFM_UID16)
   173.6  		set_opt(sbi->s_mount_opt, NO_UID32);
   173.7 +#ifdef CONFIG_EXT2_FS_XATTR
   173.8  	if (def_mount_opts & EXT2_DEFM_XATTR_USER)
   173.9  		set_opt(sbi->s_mount_opt, XATTR_USER);
  173.10 +#endif
  173.11 +#ifdef CONFIG_EXT2_FS_POSIX_ACL
  173.12  	if (def_mount_opts & EXT2_DEFM_ACL)
  173.13  		set_opt(sbi->s_mount_opt, POSIX_ACL);
  173.14 +#endif
  173.15  	
  173.16  	if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC)
  173.17  		set_opt(sbi->s_mount_opt, ERRORS_PANIC);
   174.1 --- a/fs/ext3/super.c	Tue Oct 02 09:52:15 2007 +0100
   174.2 +++ b/fs/ext3/super.c	Wed Oct 03 10:00:44 2007 +0100
   174.3 @@ -1451,10 +1451,14 @@ static int ext3_fill_super (struct super
   174.4  		set_opt(sbi->s_mount_opt, GRPID);
   174.5  	if (def_mount_opts & EXT3_DEFM_UID16)
   174.6  		set_opt(sbi->s_mount_opt, NO_UID32);
   174.7 +#ifdef CONFIG_EXT3_FS_XATTR
   174.8  	if (def_mount_opts & EXT3_DEFM_XATTR_USER)
   174.9  		set_opt(sbi->s_mount_opt, XATTR_USER);
  174.10 +#endif
  174.11 +#ifdef CONFIG_EXT3_FS_POSIX_ACL
  174.12  	if (def_mount_opts & EXT3_DEFM_ACL)
  174.13  		set_opt(sbi->s_mount_opt, POSIX_ACL);
  174.14 +#endif
  174.15  	if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_DATA)
  174.16  		sbi->s_mount_opt |= EXT3_MOUNT_JOURNAL_DATA;
  174.17  	else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_ORDERED)
   175.1 --- a/fs/fuse/dir.c	Tue Oct 02 09:52:15 2007 +0100
   175.2 +++ b/fs/fuse/dir.c	Wed Oct 03 10:00:44 2007 +0100
   175.3 @@ -138,6 +138,7 @@ static int fuse_dentry_revalidate(struct
   175.4  		struct fuse_entry_out outarg;
   175.5  		struct fuse_conn *fc;
   175.6  		struct fuse_req *req;
   175.7 +		struct fuse_req *forget_req;
   175.8  
   175.9  		/* Doesn't hurt to "reset" the validity timeout */
  175.10  		fuse_invalidate_entry_cache(entry);
  175.11 @@ -151,21 +152,29 @@ static int fuse_dentry_revalidate(struct
  175.12  		if (IS_ERR(req))
  175.13  			return 0;
  175.14  
  175.15 +		forget_req = fuse_get_req(fc);
  175.16 +		if (IS_ERR(forget_req)) {
  175.17 +			fuse_put_request(fc, req);
  175.18 +			return 0;
  175.19 +		}
  175.20 +
  175.21  		fuse_lookup_init(req, entry->d_parent->d_inode, entry, &outarg);
  175.22  		request_send(fc, req);
  175.23  		err = req->out.h.error;
  175.24 +		fuse_put_request(fc, req);
  175.25  		/* Zero nodeid is same as -ENOENT */
  175.26  		if (!err && !outarg.nodeid)
  175.27  			err = -ENOENT;
  175.28  		if (!err) {
  175.29  			struct fuse_inode *fi = get_fuse_inode(inode);
  175.30  			if (outarg.nodeid != get_node_id(inode)) {
  175.31 -				fuse_send_forget(fc, req, outarg.nodeid, 1);
  175.32 +				fuse_send_forget(fc, forget_req,
  175.33 +						 outarg.nodeid, 1);
  175.34  				return 0;
  175.35  			}
  175.36  			fi->nlookup ++;
  175.37  		}
  175.38 -		fuse_put_request(fc, req);
  175.39 +		fuse_put_request(fc, forget_req);
  175.40  		if (err || (outarg.attr.mode ^ inode->i_mode) & S_IFMT)
  175.41  			return 0;
  175.42  
  175.43 @@ -214,6 +223,7 @@ static struct dentry *fuse_lookup(struct
  175.44  	struct inode *inode = NULL;
  175.45  	struct fuse_conn *fc = get_fuse_conn(dir);
  175.46  	struct fuse_req *req;
  175.47 +	struct fuse_req *forget_req;
  175.48  
  175.49  	if (entry->d_name.len > FUSE_NAME_MAX)
  175.50  		return ERR_PTR(-ENAMETOOLONG);
  175.51 @@ -222,9 +232,16 @@ static struct dentry *fuse_lookup(struct
  175.52  	if (IS_ERR(req))
  175.53  		return ERR_PTR(PTR_ERR(req));
  175.54  
  175.55 +	forget_req = fuse_get_req(fc);
  175.56 +	if (IS_ERR(forget_req)) {
  175.57 +		fuse_put_request(fc, req);
  175.58 +		return ERR_PTR(PTR_ERR(forget_req));
  175.59 +	}
  175.60 +
  175.61  	fuse_lookup_init(req, dir, entry, &outarg);
  175.62  	request_send(fc, req);
  175.63  	err = req->out.h.error;
  175.64 +	fuse_put_request(fc, req);
  175.65  	/* Zero nodeid is same as -ENOENT, but with valid timeout */
  175.66  	if (!err && outarg.nodeid &&
  175.67  	    (invalid_nodeid(outarg.nodeid) || !valid_mode(outarg.attr.mode)))
  175.68 @@ -233,11 +250,11 @@ static struct dentry *fuse_lookup(struct
  175.69  		inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
  175.70  				  &outarg.attr);
  175.71  		if (!inode) {
  175.72 -			fuse_send_forget(fc, req, outarg.nodeid, 1);
  175.73 +			fuse_send_forget(fc, forget_req, outarg.nodeid, 1);
  175.74  			return ERR_PTR(-ENOMEM);
  175.75  		}
  175.76  	}
  175.77 -	fuse_put_request(fc, req);
  175.78 +	fuse_put_request(fc, forget_req);
  175.79  	if (err && err != -ENOENT)
  175.80  		return ERR_PTR(err);
  175.81  
  175.82 @@ -375,6 +392,13 @@ static int create_new_entry(struct fuse_
  175.83  	struct fuse_entry_out outarg;
  175.84  	struct inode *inode;
  175.85  	int err;
  175.86 +	struct fuse_req *forget_req;
  175.87 +
  175.88 +	forget_req = fuse_get_req(fc);
  175.89 +	if (IS_ERR(forget_req)) {
  175.90 +		fuse_put_request(fc, req);
  175.91 +		return PTR_ERR(forget_req);
  175.92 +	}
  175.93  
  175.94  	req->in.h.nodeid = get_node_id(dir);
  175.95  	req->out.numargs = 1;
  175.96 @@ -382,24 +406,24 @@ static int create_new_entry(struct fuse_
  175.97  	req->out.args[0].value = &outarg;
  175.98  	request_send(fc, req);
  175.99  	err = req->out.h.error;
 175.100 -	if (err) {
 175.101 -		fuse_put_request(fc, req);
 175.102 -		return err;
 175.103 -	}
 175.104 +	fuse_put_request(fc, req);
 175.105 +	if (err)
 175.106 +		goto out_put_forget_req;
 175.107 +
 175.108  	err = -EIO;
 175.109  	if (invalid_nodeid(outarg.nodeid))
 175.110 -		goto out_put_request;
 175.111 +		goto out_put_forget_req;
 175.112  
 175.113  	if ((outarg.attr.mode ^ mode) & S_IFMT)
 175.114 -		goto out_put_request;
 175.115 +		goto out_put_forget_req;
 175.116  
 175.117  	inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation,
 175.118  			  &outarg.attr);
 175.119  	if (!inode) {
 175.120 -		fuse_send_forget(fc, req, outarg.nodeid, 1);
 175.121 +		fuse_send_forget(fc, forget_req, outarg.nodeid, 1);
 175.122  		return -ENOMEM;
 175.123  	}
 175.124 -	fuse_put_request(fc, req);
 175.125 +	fuse_put_request(fc, forget_req);
 175.126  
 175.127  	if (dir_alias(inode)) {
 175.128  		iput(inode);
 175.129 @@ -411,8 +435,8 @@ static int create_new_entry(struct fuse_
 175.130  	fuse_invalidate_attr(dir);
 175.131  	return 0;
 175.132  
 175.133 - out_put_request:
 175.134 -	fuse_put_request(fc, req);
 175.135 + out_put_forget_req:
 175.136 +	fuse_put_request(fc, forget_req);
 175.137  	return err;
 175.138  }
 175.139  
 175.140 @@ -935,14 +959,30 @@ static void iattr_to_fattr(struct iattr 
 175.141  	}
 175.142  }
 175.143  
 175.144 +static void fuse_vmtruncate(struct inode *inode, loff_t offset)
 175.145 +{
 175.146 +	struct fuse_conn *fc = get_fuse_conn(inode);
 175.147 +	int need_trunc;
 175.148 +
 175.149 +	spin_lock(&fc->lock);
 175.150 +	need_trunc = inode->i_size > offset;
 175.151 +	i_size_write(inode, offset);
 175.152 +	spin_unlock(&fc->lock);
 175.153 +
 175.154 +	if (need_trunc) {
 175.155 +		struct address_space *mapping = inode->i_mapping;
 175.156 +		unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
 175.157 +		truncate_inode_pages(mapping, offset);
 175.158 +	}
 175.159 +}
 175.160 +
 175.161  /*
 175.162   * Set attributes, and at the same time refresh them.
 175.163   *
 175.164   * Truncation is slightly complicated, because the 'truncate' request
 175.165   * may fail, in which case we don't want to touch the mapping.
 175.166 - * vmtruncate() doesn't allow for this case.  So do the rlimit
 175.167 - * checking by hand and call vmtruncate() only after the file has
 175.168 - * actually been truncated.
 175.169 + * vmtruncate() doesn't allow for this case, so do the rlimit checking
 175.170 + * and the actual truncation by hand.
 175.171   */
 175.172  static int fuse_setattr(struct dentry *entry, struct iattr *attr)
 175.173  {
 175.174 @@ -993,12 +1033,8 @@ static int fuse_setattr(struct dentry *e
 175.175  			make_bad_inode(inode);
 175.176  			err = -EIO;
 175.177  		} else {
 175.178 -			if (is_truncate) {
 175.179 -				loff_t origsize = i_size_read(inode);
 175.180 -				i_size_write(inode, outarg.attr.size);
 175.181 -				if (origsize > outarg.attr.size)
 175.182 -					vmtruncate(inode, outarg.attr.size);
 175.183 -			}
 175.184 +			if (is_truncate)
 175.185 +				fuse_vmtruncate(inode, outarg.attr.size);
 175.186  			fuse_change_attributes(inode, &outarg.attr);
 175.187  			fi->i_time = time_to_jiffies(outarg.attr_valid,
 175.188  						     outarg.attr_valid_nsec);
   176.1 --- a/fs/fuse/file.c	Tue Oct 02 09:52:15 2007 +0100
   176.2 +++ b/fs/fuse/file.c	Wed Oct 03 10:00:44 2007 +0100
   176.3 @@ -481,8 +481,10 @@ static int fuse_commit_write(struct file
   176.4  		err = -EIO;
   176.5  	if (!err) {
   176.6  		pos += count;
   176.7 -		if (pos > i_size_read(inode))
   176.8 +		spin_lock(&fc->lock);
   176.9 +		if (pos > inode->i_size)
  176.10  			i_size_write(inode, pos);
  176.11 +		spin_unlock(&fc->lock);
  176.12  
  176.13  		if (offset == 0 && to == PAGE_CACHE_SIZE) {
  176.14  			clear_page_dirty(page);
  176.15 @@ -586,8 +588,12 @@ static ssize_t fuse_direct_io(struct fil
  176.16  	}
  176.17  	fuse_put_request(fc, req);
  176.18  	if (res > 0) {
  176.19 -		if (write && pos > i_size_read(inode))
  176.20 -			i_size_write(inode, pos);
  176.21 +		if (write) {
  176.22 +			spin_lock(&fc->lock);
  176.23 +			if (pos > inode->i_size)
  176.24 +				i_size_write(inode, pos);
  176.25 +			spin_unlock(&fc->lock);
  176.26 +		}
  176.27  		*ppos = pos;
  176.28  	}
  176.29  	fuse_invalidate_attr(inode);
   177.1 --- a/fs/fuse/inode.c	Tue Oct 02 09:52:15 2007 +0100
   177.2 +++ b/fs/fuse/inode.c	Wed Oct 03 10:00:44 2007 +0100
   177.3 @@ -109,6 +109,7 @@ static int fuse_remount_fs(struct super_
   177.4  
   177.5  void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr)
   177.6  {
   177.7 +	struct fuse_conn *fc = get_fuse_conn(inode);
   177.8  	if (S_ISREG(inode->i_mode) && i_size_read(inode) != attr->size)
   177.9  		invalidate_inode_pages(inode->i_mapping);
  177.10  
  177.11 @@ -117,7 +118,9 @@ void fuse_change_attributes(struct inode
  177.12  	inode->i_nlink   = attr->nlink;
  177.13  	inode->i_uid     = attr->uid;
  177.14  	inode->i_gid     = attr->gid;
  177.15 +	spin_lock(&fc->lock);
  177.16  	i_size_write(inode, attr->size);
  177.17 +	spin_unlock(&fc->lock);
  177.18  	inode->i_blksize = PAGE_CACHE_SIZE;
  177.19  	inode->i_blocks  = attr->blocks;
  177.20  	inode->i_atime.tv_sec   = attr->atime;
  177.21 @@ -131,7 +134,7 @@ void fuse_change_attributes(struct inode
  177.22  static void fuse_init_inode(struct inode *inode, struct fuse_attr *attr)
  177.23  {
  177.24  	inode->i_mode = attr->mode & S_IFMT;
  177.25 -	i_size_write(inode, attr->size);
  177.26 +	inode->i_size = attr->size;
  177.27  	if (S_ISREG(inode->i_mode)) {
  177.28  		fuse_init_common(inode);
  177.29  		fuse_init_file_inode(inode);
   178.1 --- a/fs/hfs/super.c	Tue Oct 02 09:52:15 2007 +0100
   178.2 +++ b/fs/hfs/super.c	Wed Oct 03 10:00:44 2007 +0100
   178.3 @@ -391,11 +391,13 @@ static int hfs_fill_super(struct super_b
   178.4  		hfs_find_exit(&fd);
   178.5  		goto bail_no_root;
   178.6  	}
   178.7 +	res = -EINVAL;
   178.8  	root_inode = hfs_iget(sb, &fd.search_key->cat, &rec);
   178.9  	hfs_find_exit(&fd);
  178.10  	if (!root_inode)
  178.11  		goto bail_no_root;
  178.12  
  178.13 +	res = -ENOMEM;
  178.14  	sb->s_root = d_alloc_root(root_inode);
  178.15  	if (!sb->s_root)
  178.16  		goto bail_iput;
   179.1 --- a/fs/jbd/commit.c	Tue Oct 02 09:52:15 2007 +0100
   179.2 +++ b/fs/jbd/commit.c	Wed Oct 03 10:00:44 2007 +0100
   179.3 @@ -160,6 +160,117 @@ static int journal_write_commit_record(j
   179.4  	return (ret == -EIO);
   179.5  }
   179.6  
   179.7 +void journal_do_submit_data(struct buffer_head **wbuf, int bufs)
   179.8 +{
   179.9 +	int i;
  179.10 +
  179.11 +	for (i = 0; i < bufs; i++) {
  179.12 +		wbuf[i]->b_end_io = end_buffer_write_sync;
  179.13 +		/* We use-up our safety reference in submit_bh() */
  179.14 +		submit_bh(WRITE, wbuf[i]);
  179.15 +	}
  179.16 +}
  179.17 +
  179.18 +/*
  179.19 + *  Submit all the data buffers to disk
  179.20 + */
  179.21 +static void journal_submit_data_buffers(journal_t *journal,
  179.22 +				transaction_t *commit_transaction)
  179.23 +{
  179.24 +	struct journal_head *jh;
  179.25 +	struct buffer_head *bh;
  179.26 +	int locked;
  179.27 +	int bufs = 0;
  179.28 +	struct buffer_head **wbuf = journal->j_wbuf;
  179.29 +
  179.30 +	/*
  179.31 +	 * Whenever we unlock the journal and sleep, things can get added
  179.32 +	 * onto ->t_sync_datalist, so we have to keep looping back to
  179.33 +	 * write_out_data until we *know* that the list is empty.
  179.34 +	 *
  179.35 +	 * Cleanup any flushed data buffers from the data list.  Even in
  179.36 +	 * abort mode, we want to flush this out as soon as possible.
  179.37 +	 */
  179.38 +write_out_data:
  179.39 +	cond_resched();
  179.40 +	spin_lock(&journal->j_list_lock);
  179.41 +
  179.42 +	while (commit_transaction->t_sync_datalist) {
  179.43 +		jh = commit_transaction->t_sync_datalist;
  179.44 +		bh = jh2bh(jh);
  179.45 +		locked = 0;
  179.46 +
  179.47 +		/* Get reference just to make sure buffer does not disappear
  179.48 +		 * when we are forced to drop various locks */
  179.49 +		get_bh(bh);
  179.50 +		/* If the buffer is dirty, we need to submit IO and hence
  179.51 +		 * we need the buffer lock. We try to lock the buffer without
  179.52 +		 * blocking. If we fail, we need to drop j_list_lock and do
  179.53 +		 * blocking lock_buffer().
  179.54 +		 */
  179.55 +		if (buffer_dirty(bh)) {
  179.56 +			if (test_set_buffer_locked(bh)) {
  179.57 +				BUFFER_TRACE(bh, "needs blocking lock");
  179.58 +				spin_unlock(&journal->j_list_lock);
  179.59 +				/* Write out all data to prevent deadlocks */
  179.60 +				journal_do_submit_data(wbuf, bufs);
  179.61 +				bufs = 0;
  179.62 +				lock_buffer(bh);
  179.63 +				spin_lock(&journal->j_list_lock);
  179.64 +			}
  179.65 +			locked = 1;
  179.66 +		}
  179.67 +		/* We have to get bh_state lock. Again out of order, sigh. */
  179.68 +		if (!inverted_lock(journal, bh)) {
  179.69 +			jbd_lock_bh_state(bh);
  179.70 +			spin_lock(&journal->j_list_lock);
  179.71 +		}
  179.72 +		/* Someone already cleaned up the buffer? */
  179.73 +		if (!buffer_jbd(bh)
  179.74 +			|| jh->b_transaction != commit_transaction
  179.75 +			|| jh->b_jlist != BJ_SyncData) {
  179.76 +			jbd_unlock_bh_state(bh);
  179.77 +			if (locked)
  179.78 +				unlock_buffer(bh);
  179.79 +			BUFFER_TRACE(bh, "already cleaned up");
  179.80 +			put_bh(bh);
  179.81 +			continue;
  179.82 +		}
  179.83 +		if (locked && test_clear_buffer_dirty(bh)) {
  179.84 +			BUFFER_TRACE(bh, "needs writeout, adding to array");
  179.85 +			wbuf[bufs++] = bh;
  179.86 +			__journal_file_buffer(jh, commit_transaction,
  179.87 +						BJ_Locked);
  179.88 +			jbd_unlock_bh_state(bh);
  179.89 +			if (bufs == journal->j_wbufsize) {
  179.90 +				spin_unlock(&journal->j_list_lock);
  179.91 +				journal_do_submit_data(wbuf, bufs);
  179.92 +				bufs = 0;
  179.93 +				goto write_out_data;
  179.94 +			}
  179.95 +		}
  179.96 +		else {
  179.97 +			BUFFER_TRACE(bh, "writeout complete: unfile");
  179.98 +			__journal_unfile_buffer(jh);
  179.99 +			jbd_unlock_bh_state(bh);
 179.100 +			if (locked)
 179.101 +				unlock_buffer(bh);
 179.102 +			journal_remove_journal_head(bh);
 179.103 +			/* Once for our safety reference, once for
 179.104 +			 * journal_remove_journal_head() */
 179.105 +			put_bh(bh);
 179.106 +			put_bh(bh);
 179.107 +		}
 179.108 +
 179.109 +		if (lock_need_resched(&journal->j_list_lock)) {
 179.110 +			spin_unlock(&journal->j_list_lock);
 179.111 +			goto write_out_data;
 179.112 +		}
 179.113 +	}
 179.114 +	spin_unlock(&journal->j_list_lock);
 179.115 +	journal_do_submit_data(wbuf, bufs);
 179.116 +}
 179.117 +
 179.118  /*
 179.119   * journal_commit_transaction
 179.120   *
 179.121 @@ -313,80 +424,13 @@ void journal_commit_transaction(journal_
 179.122  	 * Now start flushing things to disk, in the order they appear
 179.123  	 * on the transaction lists.  Data blocks go first.
 179.124  	 */
 179.125 -
 179.126  	err = 0;
 179.127 -	/*
 179.128 -	 * Whenever we unlock the journal and sleep, things can get added
 179.129 -	 * onto ->t_sync_datalist, so we have to keep looping back to
 179.130 -	 * write_out_data until we *know* that the list is empty.
 179.131 -	 */
 179.132 -	bufs = 0;
 179.133 -	/*
 179.134 -	 * Cleanup any flushed data buffers from the data list.  Even in
 179.135 -	 * abort mode, we want to flush this out as soon as possible.
 179.136 -	 */
 179.137 -write_out_data:
 179.138 -	cond_resched();
 179.139 -	spin_lock(&journal->j_list_lock);
 179.140 -
 179.141 -	while (commit_transaction->t_sync_datalist) {
 179.142 -		struct buffer_head *bh;
 179.143 -
 179.144 -		jh = commit_transaction->t_sync_datalist;
 179.145 -		commit_transaction->t_sync_datalist = jh->b_tnext;
 179.146 -		bh = jh2bh(jh);
 179.147 -		if (buffer_locked(bh)) {
 179.148 -			BUFFER_TRACE(bh, "locked");
 179.149 -			if (!inverted_lock(journal, bh))
 179.150 -				goto write_out_data;
 179.151 -			__journal_temp_unlink_buffer(jh);
 179.152 -			__journal_file_buffer(jh, commit_transaction,
 179.153 -						BJ_Locked);
 179.154 -			jbd_unlock_bh_state(bh);
 179.155 -			if (lock_need_resched(&journal->j_list_lock)) {
 179.156 -				spin_unlock(&journal->j_list_lock);
 179.157 -				goto write_out_data;
 179.158 -			}
 179.159 -		} else {
 179.160 -			if (buffer_dirty(bh)) {
 179.161 -				BUFFER_TRACE(bh, "start journal writeout");
 179.162 -				get_bh(bh);
 179.163 -				wbuf[bufs++] = bh;
 179.164 -				if (bufs == journal->j_wbufsize) {
 179.165 -					jbd_debug(2, "submit %d writes\n",
 179.166 -							bufs);
 179.167 -					spin_unlock(&journal->j_list_lock);
 179.168 -					ll_rw_block(SWRITE, bufs, wbuf);
 179.169 -					journal_brelse_array(wbuf, bufs);
 179.170 -					bufs = 0;
 179.171 -					goto write_out_data;
 179.172 -				}
 179.173 -			} else {
 179.174 -				BUFFER_TRACE(bh, "writeout complete: unfile");
 179.175 -				if (!inverted_lock(journal, bh))
 179.176 -					goto write_out_data;
 179.177 -				__journal_unfile_buffer(jh);
 179.178 -				jbd_unlock_bh_state(bh);
 179.179 -				journal_remove_journal_head(bh);
 179.180 -				put_bh(bh);
 179.181 -				if (lock_need_resched(&journal->j_list_lock)) {
 179.182 -					spin_unlock(&journal->j_list_lock);
 179.183 -					goto write_out_data;
 179.184 -				}
 179.185 -			}
 179.186 -		}
 179.187 -	}
 179.188 -
 179.189 -	if (bufs) {
 179.190 -		spin_unlock(&journal->j_list_lock);
 179.191 -		ll_rw_block(SWRITE, bufs, wbuf);
 179.192 -		journal_brelse_array(wbuf, bufs);
 179.193 -		spin_lock(&journal->j_list_lock);
 179.194 -	}
 179.195 +	journal_submit_data_buffers(journal, commit_transaction);
 179.196  
 179.197  	/*
 179.198  	 * Wait for all previously submitted IO to complete.
 179.199  	 */
 179.200 +	spin_lock(&journal->j_list_lock);
 179.201  	while (commit_transaction->t_locked_list) {
 179.202  		struct buffer_head *bh;
 179.203  
   180.1 --- a/fs/jfs/jfs_imap.c	Tue Oct 02 09:52:15 2007 +0100
   180.2 +++ b/fs/jfs/jfs_imap.c	Wed Oct 03 10:00:44 2007 +0100
   180.3 @@ -318,7 +318,7 @@ int diRead(struct inode *ip)
   180.4  	struct inomap *imap;
   180.5  	int block_offset;
   180.6  	int inodes_left;
   180.7 -	uint pageno;
   180.8 +	unsigned long pageno;
   180.9  	int rel_inode;
  180.10  
  180.11  	jfs_info("diRead: ino = %ld", ip->i_ino);
  180.12 @@ -606,7 +606,7 @@ int diWrite(tid_t tid, struct inode *ip)
  180.13  	int block_offset;
  180.14  	int inodes_left;
  180.15  	struct metapage *mp;
  180.16 -	uint pageno;
  180.17 +	unsigned long pageno;
  180.18  	int rel_inode;
  180.19  	int dioffset;
  180.20  	struct inode *ipimap;
   181.1 --- a/fs/nfs/dir.c	Tue Oct 02 09:52:15 2007 +0100
   181.2 +++ b/fs/nfs/dir.c	Wed Oct 03 10:00:44 2007 +0100
   181.3 @@ -902,9 +902,15 @@ static struct dentry *nfs_lookup(struct 
   181.4  
   181.5  	lock_kernel();
   181.6  
   181.7 -	/* If we're doing an exclusive create, optimize away the lookup */
   181.8 -	if (nfs_is_exclusive_create(dir, nd))
   181.9 -		goto no_entry;
  181.10 +	/*
  181.11 +	 * If we're doing an exclusive create, optimize away the lookup
  181.12 +	 * but don't hash the dentry.
  181.13 +	 */
  181.14 +	if (nfs_is_exclusive_create(dir, nd)) {
  181.15 +		d_instantiate(dentry, NULL);
  181.16 +		res = NULL;
  181.17 +		goto out_unlock;
  181.18 +	}
  181.19  
  181.20  	error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, &fhandle, &fattr);
  181.21  	if (error == -ENOENT)
  181.22 @@ -1156,6 +1162,8 @@ int nfs_instantiate(struct dentry *dentr
  181.23  	if (IS_ERR(inode))
  181.24  		goto out_err;
  181.25  	d_instantiate(dentry, inode);
  181.26 +	if (d_unhashed(dentry))
  181.27 +		d_rehash(dentry);
  181.28  	return 0;
  181.29  out_err:
  181.30  	d_drop(dentry);
   182.1 --- a/fs/nfsd/nfs2acl.c	Tue Oct 02 09:52:15 2007 +0100
   182.2 +++ b/fs/nfsd/nfs2acl.c	Wed Oct 03 10:00:44 2007 +0100
   182.3 @@ -287,13 +287,20 @@ static int nfsaclsvc_release_getacl(stru
   182.4  	return 1;
   182.5  }
   182.6  
   182.7 -static int nfsaclsvc_release_fhandle(struct svc_rqst *rqstp, u32 *p,
   182.8 -		struct nfsd_fhandle *resp)
   182.9 +static int nfsaclsvc_release_attrstat(struct svc_rqst *rqstp, u32 *p,
  182.10 +		struct nfsd_attrstat *resp)
  182.11  {
  182.12  	fh_put(&resp->fh);
  182.13  	return 1;
  182.14  }
  182.15  
  182.16 +static int nfsaclsvc_release_access(struct svc_rqst *rqstp, u32 *p,
  182.17 +               struct nfsd3_accessres *resp)
  182.18 +{
  182.19 +       fh_put(&resp->fh);
  182.20 +       return 1;
  182.21 +}
  182.22 +
  182.23  #define nfsaclsvc_decode_voidargs	NULL
  182.24  #define nfsaclsvc_encode_voidres	NULL
  182.25  #define nfsaclsvc_release_void		NULL
  182.26 @@ -322,9 +329,9 @@ struct nfsd3_voidargs { int dummy; };
  182.27  static struct svc_procedure		nfsd_acl_procedures2[] = {
  182.28    PROC(null,	void,		void,		void,	  RC_NOCACHE, ST),
  182.29    PROC(getacl,	getacl,		getacl,		getacl,	  RC_NOCACHE, ST+1+2*(1+ACL)),
  182.30 -  PROC(setacl,	setacl,		attrstat,	fhandle,  RC_NOCACHE, ST+AT),
  182.31 -  PROC(getattr, fhandle,	attrstat,	fhandle,  RC_NOCACHE, ST+AT),
  182.32 -  PROC(access,	access,		access,		fhandle,  RC_NOCACHE, ST+AT+1),
  182.33 +  PROC(setacl,	setacl,		attrstat,	attrstat, RC_NOCACHE, ST+AT),
  182.34 +  PROC(getattr, fhandle,	attrstat,	attrstat, RC_NOCACHE, ST+AT),
  182.35 +  PROC(access,	access,		access,		access,   RC_NOCACHE, ST+AT+1),
  182.36  };
  182.37  
  182.38  struct svc_version	nfsd_acl_version2 = {
   183.1 --- a/fs/splice.c	Tue Oct 02 09:52:15 2007 +0100
   183.2 +++ b/fs/splice.c	Wed Oct 03 10:00:44 2007 +0100
   183.3 @@ -607,7 +607,7 @@ find_page:
   183.4  			ret = -ENOMEM;
   183.5  			page = page_cache_alloc_cold(mapping);
   183.6  			if (unlikely(!page))
   183.7 -				goto out_nomem;
   183.8 +				goto out_ret;
   183.9  
  183.10  			/*
  183.11  			 * This will also lock the page
  183.12 @@ -666,7 +666,7 @@ find_page:
  183.13  		if (sd->pos + this_len > isize)
  183.14  			vmtruncate(mapping->host, isize);
  183.15  
  183.16 -		goto out;
  183.17 +		goto out_ret;
  183.18  	}
  183.19  
  183.20  	if (buf->page != page) {
  183.21 @@ -698,7 +698,7 @@ find_page:
  183.22  out:
  183.23  	page_cache_release(page);
  183.24  	unlock_page(page);
  183.25 -out_nomem:
  183.26 +out_ret:
  183.27  	return ret;
  183.28  }
  183.29  
   184.1 --- a/fs/sysfs/file.c	Tue Oct 02 09:52:15 2007 +0100
   184.2 +++ b/fs/sysfs/file.c	Wed Oct 03 10:00:44 2007 +0100
   184.3 @@ -483,11 +483,6 @@ int sysfs_update_file(struct kobject * k
   184.4  		    (victim->d_parent->d_inode == dir->d_inode)) {
   184.5  			victim->d_inode->i_mtime = CURRENT_TIME;
   184.6  			fsnotify_modify(victim);
   184.7 -
   184.8 -			/**
   184.9 -			 * Drop reference from initial sysfs_get_dentry().
  184.10 -			 */
  184.11 -			dput(victim);
  184.12  			res = 0;
  184.13  		} else
  184.14  			d_drop(victim);
   185.1 --- a/include/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   185.2 +++ b/include/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   185.3 @@ -1,2 +1,9 @@
   185.4 -header-y += asm-generic/ linux/ scsi/ sound/ mtd/ rdma/ video/
   185.5 -header-y += asm-$(ARCH)/ 
   185.6 +header-y += asm-generic/
   185.7 +header-y += linux/
   185.8 +header-y += scsi/
   185.9 +header-y += sound/
  185.10 +header-y += mtd/
  185.11 +header-y += rdma/
  185.12 +header-y += video/
  185.13 +
  185.14 +header-y += asm-$(ARCH)/
   186.1 --- a/include/asm-alpha/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   186.2 +++ b/include/asm-alpha/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   186.3 @@ -1,5 +1,11 @@
   186.4  include include/asm-generic/Kbuild.asm
   186.5  
   186.6 -unifdef-y += console.h fpu.h sysinfo.h compiler.h
   186.7 +header-y += gentrap.h
   186.8 +header-y += regdef.h
   186.9 +header-y += pal.h
  186.10 +header-y += reg.h
  186.11  
  186.12 -header-y += gentrap.h regdef.h pal.h reg.h
  186.13 +unifdef-y += console.h
  186.14 +unifdef-y += fpu.h
  186.15 +unifdef-y += sysinfo.h
  186.16 +unifdef-y += compiler.h
   187.1 --- a/include/asm-arm/elf.h	Tue Oct 02 09:52:15 2007 +0100
   187.2 +++ b/include/asm-arm/elf.h	Wed Oct 03 10:00:44 2007 +0100
   187.3 @@ -8,9 +8,6 @@
   187.4  
   187.5  #include <asm/ptrace.h>
   187.6  #include <asm/user.h>
   187.7 -#ifdef __KERNEL
   187.8 -#include <asm/procinfo.h>
   187.9 -#endif
  187.10  
  187.11  typedef unsigned long elf_greg_t;
  187.12  typedef unsigned long elf_freg_t[3];
  187.13 @@ -32,11 +29,6 @@ typedef elf_greg_t elf_gregset_t[ELF_NGR
  187.14  typedef struct user_fp elf_fpregset_t;
  187.15  
  187.16  /*
  187.17 - * This is used to ensure we don't load something for the wrong architecture.
  187.18 - */
  187.19 -#define elf_check_arch(x) ( ((x)->e_machine == EM_ARM) && (ELF_PROC_OK((x))) )
  187.20 -
  187.21 -/*
  187.22   * These are used to set parameters in the core dumps.
  187.23   */
  187.24  #define ELF_CLASS	ELFCLASS32
  187.25 @@ -47,6 +39,14 @@ typedef struct user_fp elf_fpregset_t;
  187.26  #endif
  187.27  #define ELF_ARCH	EM_ARM
  187.28  
  187.29 +#ifdef __KERNEL__
  187.30 +#include <asm/procinfo.h>
  187.31 +
  187.32 +/*
  187.33 + * This is used to ensure we don't load something for the wrong architecture.
  187.34 + */
  187.35 +#define elf_check_arch(x) ( ((x)->e_machine == EM_ARM) && (ELF_PROC_OK((x))) )
  187.36 +
  187.37  #define USE_ELF_CORE_DUMP
  187.38  #define ELF_EXEC_PAGESIZE	4096
  187.39  
  187.40 @@ -83,8 +83,6 @@ typedef struct user_fp elf_fpregset_t;
  187.41  extern char elf_platform[];
  187.42  #define ELF_PLATFORM	(elf_platform)
  187.43  
  187.44 -#ifdef __KERNEL__
  187.45 -
  187.46  /*
  187.47   * 32-bit code is always OK.  Some cpus can do 26-bit, some can't.
  187.48   */
   188.1 --- a/include/asm-arm/page.h	Tue Oct 02 09:52:15 2007 +0100
   188.2 +++ b/include/asm-arm/page.h	Wed Oct 03 10:00:44 2007 +0100
   188.3 @@ -11,13 +11,13 @@
   188.4  #define _ASMARM_PAGE_H
   188.5  
   188.6  
   188.7 +#ifdef __KERNEL__
   188.8 +
   188.9  /* PAGE_SHIFT determines the page size */
  188.10  #define PAGE_SHIFT		12
  188.11  #define PAGE_SIZE		(1UL << PAGE_SHIFT)
  188.12  #define PAGE_MASK		(~(PAGE_SIZE-1))
  188.13  
  188.14 -#ifdef __KERNEL__
  188.15 -
  188.16  /* to align the pointer to the (next) page boundary */
  188.17  #define PAGE_ALIGN(addr)	(((addr)+PAGE_SIZE-1)&PAGE_MASK)
  188.18  
   189.1 --- a/include/asm-arm/unistd.h	Tue Oct 02 09:52:15 2007 +0100
   189.2 +++ b/include/asm-arm/unistd.h	Wed Oct 03 10:00:44 2007 +0100
   189.3 @@ -347,6 +347,19 @@
   189.4  #define __NR_mbind			(__NR_SYSCALL_BASE+319)
   189.5  #define __NR_get_mempolicy		(__NR_SYSCALL_BASE+320)
   189.6  #define __NR_set_mempolicy		(__NR_SYSCALL_BASE+321)
   189.7 +#define __NR_openat			(__NR_SYSCALL_BASE+322)
   189.8 +#define __NR_mkdirat			(__NR_SYSCALL_BASE+323)
   189.9 +#define __NR_mknodat			(__NR_SYSCALL_BASE+324)
  189.10 +#define __NR_fchownat			(__NR_SYSCALL_BASE+325)
  189.11 +#define __NR_futimesat			(__NR_SYSCALL_BASE+326)
  189.12 +#define __NR_fstatat64			(__NR_SYSCALL_BASE+327)
  189.13 +#define __NR_unlinkat			(__NR_SYSCALL_BASE+328)
  189.14 +#define __NR_renameat			(__NR_SYSCALL_BASE+329)
  189.15 +#define __NR_linkat			(__NR_SYSCALL_BASE+330)
  189.16 +#define __NR_symlinkat			(__NR_SYSCALL_BASE+331)
  189.17 +#define __NR_readlinkat			(__NR_SYSCALL_BASE+332)
  189.18 +#define __NR_fchmodat			(__NR_SYSCALL_BASE+333)
  189.19 +#define __NR_faccessat			(__NR_SYSCALL_BASE+334)
  189.20  
  189.21  /*
  189.22   * The following SWIs are ARM private.
   190.1 --- a/include/asm-arm26/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   190.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   190.3 @@ -1,1 +0,0 @@
   190.4 -include include/asm-generic/Kbuild.asm
   191.1 --- a/include/asm-cris/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   191.2 +++ b/include/asm-cris/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   191.3 @@ -1,1 +1,5 @@
   191.4  include include/asm-generic/Kbuild.asm
   191.5 +
   191.6 +header-y += arch-v10/ arch-v32/
   191.7 +
   191.8 +unifdef-y += rs485.h
   192.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   192.2 +++ b/include/asm-cris/arch-v10/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   192.3 @@ -0,0 +1,2 @@
   192.4 +header-y += ptrace.h
   192.5 +header-y += user.h
   193.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   193.2 +++ b/include/asm-cris/arch-v32/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   193.3 @@ -0,0 +1,2 @@
   193.4 +header-y += ptrace.h
   193.5 +header-y += user.h
   194.1 --- a/include/asm-cris/byteorder.h	Tue Oct 02 09:52:15 2007 +0100
   194.2 +++ b/include/asm-cris/byteorder.h	Wed Oct 03 10:00:44 2007 +0100
   194.3 @@ -3,14 +3,15 @@
   194.4  
   194.5  #ifdef __GNUC__
   194.6  
   194.7 +#ifdef __KERNEL__
   194.8  #include <asm/arch/byteorder.h>
   194.9  
  194.10  /* defines are necessary because the other files detect the presence
  194.11   * of a defined __arch_swab32, not an inline
  194.12   */
  194.13 -
  194.14  #define __arch__swab32(x) ___arch__swab32(x)
  194.15  #define __arch__swab16(x) ___arch__swab16(x)
  194.16 +#endif /* __KERNEL__ */
  194.17  
  194.18  #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
  194.19  #  define __BYTEORDER_HAS_U64__
   195.1 --- a/include/asm-cris/elf.h	Tue Oct 02 09:52:15 2007 +0100
   195.2 +++ b/include/asm-cris/elf.h	Wed Oct 03 10:00:44 2007 +0100
   195.3 @@ -5,7 +5,6 @@
   195.4   * ELF register definitions..
   195.5   */
   195.6  
   195.7 -#include <asm/arch/elf.h>
   195.8  #include <asm/user.h>
   195.9  
  195.10  #define R_CRIS_NONE             0
  195.11 @@ -46,6 +45,9 @@ typedef unsigned long elf_fpregset_t;
  195.12  #define ELF_DATA	ELFDATA2LSB
  195.13  #define ELF_ARCH	EM_CRIS
  195.14  
  195.15 +#ifdef __KERNEL__
  195.16 +#include <asm/arch/elf.h>
  195.17 +
  195.18  /* The master for these definitions is {binutils}/include/elf/cris.h:  */
  195.19  /* User symbols in this file have a leading underscore.  */
  195.20  #define EF_CRIS_UNDERSCORE		0x00000001
  195.21 @@ -87,8 +89,8 @@ typedef unsigned long elf_fpregset_t;
  195.22  
  195.23  #define ELF_PLATFORM  (NULL)
  195.24  
  195.25 -#ifdef __KERNEL__
  195.26  #define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
  195.27 -#endif
  195.28 +
  195.29 +#endif /* __KERNEL__ */
  195.30  
  195.31  #endif
   196.1 --- a/include/asm-cris/page.h	Tue Oct 02 09:52:15 2007 +0100
   196.2 +++ b/include/asm-cris/page.h	Wed Oct 03 10:00:44 2007 +0100
   196.3 @@ -1,6 +1,8 @@
   196.4  #ifndef _CRIS_PAGE_H
   196.5  #define _CRIS_PAGE_H
   196.6  
   196.7 +#ifdef __KERNEL__
   196.8 +
   196.9  #include <asm/arch/page.h>
  196.10  
  196.11  /* PAGE_SHIFT determines the page size */
  196.12 @@ -12,8 +14,6 @@
  196.13  #endif
  196.14  #define PAGE_MASK	(~(PAGE_SIZE-1))
  196.15  
  196.16 -#ifdef __KERNEL__
  196.17 -
  196.18  #define clear_page(page)        memset((void *)(page), 0, PAGE_SIZE)
  196.19  #define copy_page(to,from)      memcpy((void *)(to), (void *)(from), PAGE_SIZE)
  196.20  
  196.21 @@ -73,10 +73,10 @@ typedef struct { unsigned long pgprot; }
  196.22  #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
  196.23  				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  196.24  
  196.25 -#endif /* __KERNEL__ */
  196.26 -
  196.27  #include <asm-generic/memory_model.h>
  196.28  #include <asm-generic/page.h>
  196.29  
  196.30 +#endif /* __KERNEL__ */
  196.31 +
  196.32  #endif /* _CRIS_PAGE_H */
  196.33  
   197.1 --- a/include/asm-cris/posix_types.h	Tue Oct 02 09:52:15 2007 +0100
   197.2 +++ b/include/asm-cris/posix_types.h	Wed Oct 03 10:00:44 2007 +0100
   197.3 @@ -6,8 +6,6 @@
   197.4  #ifndef __ARCH_CRIS_POSIX_TYPES_H
   197.5  #define __ARCH_CRIS_POSIX_TYPES_H
   197.6  
   197.7 -#include <asm/bitops.h>
   197.8 -
   197.9  /*
  197.10   * This file is generally used by user-level software, so you need to
  197.11   * be a little careful about namespace pollution etc.  Also, we cannot
  197.12 @@ -53,9 +51,8 @@ typedef struct {
  197.13  #endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
  197.14  } __kernel_fsid_t;
  197.15  
  197.16 -/* should this ifdef be here ?  */
  197.17 -
  197.18 -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
  197.19 +#ifdef __KERNEL__
  197.20 +#include <asm/bitops.h>
  197.21  
  197.22  #undef	__FD_SET
  197.23  #define __FD_SET(fd,fdsetp) set_bit(fd, (void *)(fdsetp))
  197.24 @@ -69,6 +66,6 @@ typedef struct {
  197.25  #undef	__FD_ZERO
  197.26  #define __FD_ZERO(fdsetp) memset((void *)(fdsetp), 0, __FDSET_LONGS << 2)
  197.27  
  197.28 -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
  197.29 +#endif /* __KERNEL__ */
  197.30  
  197.31  #endif /* __ARCH_CRIS_POSIX_TYPES_H */
   198.1 --- a/include/asm-cris/unistd.h	Tue Oct 02 09:52:15 2007 +0100
   198.2 +++ b/include/asm-cris/unistd.h	Wed Oct 03 10:00:44 2007 +0100
   198.3 @@ -1,8 +1,6 @@
   198.4  #ifndef _ASM_CRIS_UNISTD_H_
   198.5  #define _ASM_CRIS_UNISTD_H_
   198.6  
   198.7 -#include <asm/arch/unistd.h>
   198.8 -
   198.9  /*
  198.10   * This file contains the system call numbers, and stub macros for libc.
  198.11   */
  198.12 @@ -299,6 +297,7 @@
  198.13  
  198.14  #define NR_syscalls 289
  198.15  
  198.16 +#include <asm/arch/unistd.h>
  198.17  
  198.18  #define __ARCH_WANT_IPC_PARSE_VERSION
  198.19  #define __ARCH_WANT_OLD_READDIR
  198.20 @@ -322,7 +321,6 @@
  198.21  #define __ARCH_WANT_SYS_SIGPENDING
  198.22  #define __ARCH_WANT_SYS_SIGPROCMASK
  198.23  #define __ARCH_WANT_SYS_RT_SIGACTION
  198.24 -#endif
  198.25  
  198.26  #ifdef __KERNEL_SYSCALLS__
  198.27  
   199.1 --- a/include/asm-generic/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   199.2 +++ b/include/asm-generic/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   199.3 @@ -1,3 +1,12 @@
   199.4 -header-y += atomic.h errno-base.h errno.h fcntl.h ioctl.h ipc.h mman.h \
   199.5 -	signal.h statfs.h
   199.6 -unifdef-y := resource.h siginfo.h
   199.7 +header-y += atomic.h
   199.8 +header-y += errno-base.h
   199.9 +header-y += errno.h
  199.10 +header-y += fcntl.h
  199.11 +header-y += ioctl.h
  199.12 +header-y += ipc.h
  199.13 +header-y += mman.h
  199.14 +header-y += signal.h
  199.15 +header-y += statfs.h
  199.16 +
  199.17 +unifdef-y += resource.h
  199.18 +unifdef-y += siginfo.h
   200.1 --- a/include/asm-generic/Kbuild.asm	Tue Oct 02 09:52:15 2007 +0100
   200.2 +++ b/include/asm-generic/Kbuild.asm	Wed Oct 03 10:00:44 2007 +0100
   200.3 @@ -1,8 +1,34 @@
   200.4 -unifdef-y += a.out.h auxvec.h byteorder.h errno.h fcntl.h ioctl.h	\
   200.5 -	ioctls.h ipcbuf.h mman.h msgbuf.h param.h poll.h		\
   200.6 -	posix_types.h ptrace.h resource.h sembuf.h shmbuf.h shmparam.h	\
   200.7 -	sigcontext.h siginfo.h signal.h socket.h sockios.h stat.h	\
   200.8 -	statfs.h termbits.h termios.h types.h unistd.h user.h
   200.9 +unifdef-y += a.out.h
  200.10 +unifdef-y += auxvec.h
  200.11 +unifdef-y += byteorder.h
  200.12 +unifdef-y += errno.h
  200.13 +unifdef-y += fcntl.h
  200.14 +unifdef-y += ioctl.h
  200.15 +unifdef-y += ioctls.h
  200.16 +unifdef-y += ipcbuf.h
  200.17 +unifdef-y += mman.h
  200.18 +unifdef-y += msgbuf.h
  200.19 +unifdef-y += param.h
  200.20 +unifdef-y += poll.h
  200.21 +unifdef-y += posix_types.h
  200.22 +unifdef-y += ptrace.h
  200.23 +unifdef-y += resource.h
  200.24 +unifdef-y += sembuf.h
  200.25 +unifdef-y += shmbuf.h
  200.26 +unifdef-y += sigcontext.h
  200.27 +unifdef-y += siginfo.h
  200.28 +unifdef-y += signal.h
  200.29 +unifdef-y += socket.h
  200.30 +unifdef-y += sockios.h
  200.31 +unifdef-y += stat.h
  200.32 +unifdef-y += statfs.h
  200.33 +unifdef-y += termbits.h
  200.34 +unifdef-y += termios.h
  200.35 +unifdef-y += types.h
  200.36 +unifdef-y += unistd.h
  200.37 +unifdef-y += user.h
  200.38  
  200.39  # These probably shouldn't be exported
  200.40 -unifdef-y += elf.h page.h
  200.41 +unifdef-y += shmparam.h
  200.42 +unifdef-y += elf.h
  200.43 +unifdef-y += page.h
   201.1 --- a/include/asm-generic/audit_change_attr.h	Tue Oct 02 09:52:15 2007 +0100
   201.2 +++ b/include/asm-generic/audit_change_attr.h	Wed Oct 03 10:00:44 2007 +0100
   201.3 @@ -1,16 +1,20 @@
   201.4  __NR_chmod,
   201.5  __NR_fchmod,
   201.6 +#ifdef __NR_chown
   201.7  __NR_chown,
   201.8  __NR_fchown,
   201.9  __NR_lchown,
  201.10 +#endif
  201.11  __NR_setxattr,
  201.12  __NR_lsetxattr,
  201.13  __NR_fsetxattr,
  201.14  __NR_removexattr,
  201.15  __NR_lremovexattr,
  201.16  __NR_fremovexattr,
  201.17 +#ifdef __NR_fchownat
  201.18  __NR_fchownat,
  201.19  __NR_fchmodat,
  201.20 +#endif
  201.21  #ifdef __NR_chown32
  201.22  __NR_chown32,
  201.23  __NR_fchown32,
   202.1 --- a/include/asm-generic/audit_dir_write.h	Tue Oct 02 09:52:15 2007 +0100
   202.2 +++ b/include/asm-generic/audit_dir_write.h	Wed Oct 03 10:00:44 2007 +0100
   202.3 @@ -1,14 +1,18 @@
   202.4  __NR_rename,
   202.5  __NR_mkdir,
   202.6  __NR_rmdir,
   202.7 +#ifdef __NR_creat
   202.8  __NR_creat,
   202.9 +#endif
  202.10  __NR_link,
  202.11  __NR_unlink,
  202.12  __NR_symlink,
  202.13  __NR_mknod,
  202.14 +#ifdef __NR_mkdirat
  202.15  __NR_mkdirat,
  202.16  __NR_mknodat,
  202.17  __NR_unlinkat,
  202.18  __NR_renameat,
  202.19  __NR_linkat,
  202.20  __NR_symlinkat,
  202.21 +#endif
   203.1 --- a/include/asm-h8300/page.h	Tue Oct 02 09:52:15 2007 +0100
   203.2 +++ b/include/asm-h8300/page.h	Wed Oct 03 10:00:44 2007 +0100
   203.3 @@ -1,6 +1,7 @@
   203.4  #ifndef _H8300_PAGE_H
   203.5  #define _H8300_PAGE_H
   203.6  
   203.7 +#ifdef __KERNEL__
   203.8  
   203.9  /* PAGE_SHIFT determines the page size */
  203.10  
  203.11 @@ -8,8 +9,6 @@
  203.12  #define PAGE_SIZE	(1UL << PAGE_SHIFT)
  203.13  #define PAGE_MASK	(~(PAGE_SIZE-1))
  203.14  
  203.15 -#ifdef __KERNEL__
  203.16 -
  203.17  #include <asm/setup.h>
  203.18  
  203.19  #ifndef __ASSEMBLY__
  203.20 @@ -76,9 +75,9 @@ extern unsigned long memory_end;
  203.21  
  203.22  #endif /* __ASSEMBLY__ */
  203.23  
  203.24 -#endif /* __KERNEL__ */
  203.25 -
  203.26  #include <asm-generic/memory_model.h>
  203.27  #include <asm-generic/page.h>
  203.28  
  203.29 +#endif /* __KERNEL__ */
  203.30 +
  203.31  #endif /* _H8300_PAGE_H */
   204.1 --- a/include/asm-i386/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   204.2 +++ b/include/asm-i386/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   204.3 @@ -1,5 +1,10 @@
   204.4  include include/asm-generic/Kbuild.asm
   204.5  
   204.6 -header-y += boot.h debugreg.h ldt.h ucontext.h
   204.7 +header-y += boot.h
   204.8 +header-y += debugreg.h
   204.9 +header-y += ldt.h
  204.10 +header-y += ucontext.h
  204.11  
  204.12 -unifdef-y += mtrr.h setup.h vm86.h
  204.13 +unifdef-y += mtrr.h
  204.14 +unifdef-y += setup.h
  204.15 +unifdef-y += vm86.h
   205.1 --- a/include/asm-ia64/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   205.2 +++ b/include/asm-ia64/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   205.3 @@ -1,7 +1,17 @@
   205.4  include include/asm-generic/Kbuild.asm
   205.5  
   205.6 -header-y += break.h fpu.h fpswa.h gcc_intrin.h ia64regs.h		\
   205.7 -	 intel_intrin.h intrinsics.h perfmon_default_smpl.h	\
   205.8 -	 ptrace_offsets.h rse.h setup.h ucontext.h
   205.9 +header-y += break.h
  205.10 +header-y += fpu.h
  205.11 +header-y += fpswa.h
  205.12 +header-y += gcc_intrin.h
  205.13 +header-y += ia64regs.h
  205.14 +header-y += intel_intrin.h
  205.15 +header-y += intrinsics.h
  205.16 +header-y += perfmon_default_smpl.h
  205.17 +header-y += ptrace_offsets.h
  205.18 +header-y += rse.h
  205.19 +header-y += setup.h
  205.20 +header-y += ucontext.h
  205.21  
  205.22 -unifdef-y += perfmon.h ustack.h
  205.23 +unifdef-y += perfmon.h
  205.24 +unifdef-y += ustack.h
   206.1 --- a/include/asm-ia64/numa.h	Tue Oct 02 09:52:15 2007 +0100
   206.2 +++ b/include/asm-ia64/numa.h	Wed Oct 03 10:00:44 2007 +0100
   206.3 @@ -64,7 +64,13 @@ extern int paddr_to_nid(unsigned long pa
   206.4  
   206.5  #define local_nodeid (cpu_to_node_map[smp_processor_id()])
   206.6  
   206.7 +extern void map_cpu_to_node(int cpu, int nid);
   206.8 +extern void unmap_cpu_from_node(int cpu, int nid);
   206.9 +
  206.10 +
  206.11  #else /* !CONFIG_NUMA */
  206.12 +#define map_cpu_to_node(cpu, nid)	do{}while(0)
  206.13 +#define unmap_cpu_from_node(cpu, nid)	do{}while(0)
  206.14  
  206.15  #define paddr_to_nid(addr)	0
  206.16  
   207.1 --- a/include/asm-m32r/page.h	Tue Oct 02 09:52:15 2007 +0100
   207.2 +++ b/include/asm-m32r/page.h	Wed Oct 03 10:00:44 2007 +0100
   207.3 @@ -87,10 +87,9 @@ typedef struct { unsigned long pgprot; }
   207.4  
   207.5  #define devmem_is_allowed(x) 1
   207.6  
   207.7 -#endif /* __KERNEL__ */
   207.8 -
   207.9  #include <asm-generic/memory_model.h>
  207.10  #include <asm-generic/page.h>
  207.11  
  207.12 +#endif /* __KERNEL__ */
  207.13  #endif /* _ASM_M32R_PAGE_H */
  207.14  
   208.1 --- a/include/asm-m32r/ptrace.h	Tue Oct 02 09:52:15 2007 +0100
   208.2 +++ b/include/asm-m32r/ptrace.h	Wed Oct 03 10:00:44 2007 +0100
   208.3 @@ -12,8 +12,6 @@
   208.4   *   Copyright (C) 2001-2002, 2004  Hirokazu Takata <takata at linux-m32r.org>
   208.5   */
   208.6  
   208.7 -#include <asm/m32r.h>		/* M32R_PSW_BSM, M32R_PSW_BPM */
   208.8 -
   208.9  /* 0 - 13 are integer registers (general purpose registers).  */
  208.10  #define PT_R4		0
  208.11  #define PT_R5		1
  208.12 @@ -35,21 +33,10 @@
  208.13  #define PT_R15		PT_SP
  208.14  
  208.15  /* processor status and miscellaneous context registers.  */
  208.16 -#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
  208.17  #define PT_ACC0H	15
  208.18  #define PT_ACC0L	16
  208.19 -#define PT_ACC1H	17
  208.20 -#define PT_ACC1L	18
  208.21 -#define PT_ACCH		PT_ACC0H
  208.22 -#define PT_ACCL		PT_ACC0L
  208.23 -#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
  208.24 -#define PT_ACCH		15
  208.25 -#define PT_ACCL		16
  208.26 -#define PT_DUMMY_ACC1H	17
  208.27 -#define PT_DUMMY_ACC1L	18
  208.28 -#else
  208.29 -#error unknown isa conifiguration
  208.30 -#endif
  208.31 +#define PT_ACC1H	17	/* ISA_DSP_LEVEL2 only */
  208.32 +#define PT_ACC1L	18	/* ISA_DSP_LEVEL2 only */
  208.33  #define PT_PSW		19
  208.34  #define PT_BPC		20
  208.35  #define PT_BBPSW	21
  208.36 @@ -105,19 +92,10 @@ struct pt_regs {
  208.37  	long syscall_nr;
  208.38  
  208.39  	/* Saved main processor status and miscellaneous context registers. */
  208.40 -#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
  208.41  	unsigned long acc0h;
  208.42  	unsigned long acc0l;
  208.43 -	unsigned long acc1h;
  208.44 -	unsigned long acc1l;
  208.45 -#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
  208.46 -	unsigned long acch;
  208.47 -	unsigned long accl;
  208.48 -	unsigned long dummy_acc1h;
  208.49 -	unsigned long dummy_acc1l;
  208.50 -#else
  208.51 -#error unknown isa configuration
  208.52 -#endif
  208.53 +	unsigned long acc1h;	/* ISA_DSP_LEVEL2 only */
  208.54 +	unsigned long acc1l;	/* ISA_DSP_LEVEL2 only */
  208.55  	unsigned long psw;
  208.56  	unsigned long bpc;		/* saved PC for TRAP syscalls */
  208.57  	unsigned long bbpsw;
  208.58 @@ -140,6 +118,8 @@ struct pt_regs {
  208.59  
  208.60  #ifdef __KERNEL__
  208.61  
  208.62 +#include <asm/m32r.h>		/* M32R_PSW_BSM, M32R_PSW_BPM */
  208.63 +
  208.64  #define __ARCH_SYS_PTRACE	1
  208.65  
  208.66  #if defined(CONFIG_ISA_M32R2) || defined(CONFIG_CHIP_VDEC2)
   209.1 --- a/include/asm-m32r/sigcontext.h	Tue Oct 02 09:52:15 2007 +0100
   209.2 +++ b/include/asm-m32r/sigcontext.h	Wed Oct 03 10:00:44 2007 +0100
   209.3 @@ -23,19 +23,10 @@ struct sigcontext {
   209.4  	unsigned long sc_r12;
   209.5  
   209.6  	/* Saved main processor status and miscellaneous context registers. */
   209.7 -#if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
   209.8  	unsigned long sc_acc0h;
   209.9  	unsigned long sc_acc0l;
  209.10 -	unsigned long sc_acc1h;
  209.11 -	unsigned long sc_acc1l;
  209.12 -#elif defined(CONFIG_ISA_M32R2) || defined(CONFIG_ISA_M32R)
  209.13 -	unsigned long sc_acch;
  209.14 -	unsigned long sc_accl;
  209.15 -	unsigned long sc_dummy_acc1h;
  209.16 -	unsigned long sc_dummy_acc1l;
  209.17 -#else
  209.18 -#error unknown isa configuration
  209.19 -#endif
  209.20 +	unsigned long sc_acc1h;	/* ISA_DSP_LEVEL2 only */
  209.21 +	unsigned long sc_acc1l;	/* ISA_DSP_LEVEL2 only */
  209.22  	unsigned long sc_psw;
  209.23  	unsigned long sc_bpc;		/* saved PC for TRAP syscalls */
  209.24  	unsigned long sc_bbpsw;
   210.1 --- a/include/asm-m32r/signal.h	Tue Oct 02 09:52:15 2007 +0100
   210.2 +++ b/include/asm-m32r/signal.h	Wed Oct 03 10:00:44 2007 +0100
   210.3 @@ -6,7 +6,6 @@
   210.4  /* orig : i386 2.4.18 */
   210.5  
   210.6  #include <linux/types.h>
   210.7 -#include <linux/linkage.h>
   210.8  #include <linux/time.h>
   210.9  #include <linux/compiler.h>
  210.10  
   211.1 --- a/include/asm-m32r/unistd.h	Tue Oct 02 09:52:15 2007 +0100
   211.2 +++ b/include/asm-m32r/unistd.h	Wed Oct 03 10:00:44 2007 +0100
   211.3 @@ -3,8 +3,6 @@
   211.4  
   211.5  /* $Id$ */
   211.6  
   211.7 -#include <asm/syscall.h>	/* SYSCALL_* */
   211.8 -
   211.9  /*
  211.10   * This file contains the system call numbers.
  211.11   */
  211.12 @@ -303,6 +301,8 @@
  211.13   * <asm-m32r/errno.h>
  211.14   */
  211.15  
  211.16 +#include <asm/syscall.h>	/* SYSCALL_* */
  211.17 +
  211.18  #define __syscall_return(type, res) \
  211.19  do { \
  211.20  	if ((unsigned long)(res) >= (unsigned long)(-(124 + 1))) { \
   212.1 --- a/include/asm-m32r/user.h	Tue Oct 02 09:52:15 2007 +0100
   212.2 +++ b/include/asm-m32r/user.h	Wed Oct 03 10:00:44 2007 +0100
   212.3 @@ -8,7 +8,6 @@
   212.4   */
   212.5  
   212.6  #include <linux/types.h>
   212.7 -#include <asm/processor.h>
   212.8  #include <asm/ptrace.h>
   212.9  #include <asm/page.h>
  212.10  
   213.1 --- a/include/asm-m68knommu/page.h	Tue Oct 02 09:52:15 2007 +0100
   213.2 +++ b/include/asm-m68knommu/page.h	Wed Oct 03 10:00:44 2007 +0100
   213.3 @@ -1,6 +1,7 @@
   213.4  #ifndef _M68KNOMMU_PAGE_H
   213.5  #define _M68KNOMMU_PAGE_H
   213.6  
   213.7 +#ifdef __KERNEL__
   213.8  
   213.9  /* PAGE_SHIFT determines the page size */
  213.10  
  213.11 @@ -8,8 +9,6 @@
  213.12  #define PAGE_SIZE	(1UL << PAGE_SHIFT)
  213.13  #define PAGE_MASK	(~(PAGE_SIZE-1))
  213.14  
  213.15 -#ifdef __KERNEL__
  213.16 -
  213.17  #include <asm/setup.h>
  213.18  
  213.19  #ifndef __ASSEMBLY__
  213.20 @@ -76,8 +75,8 @@ extern unsigned long memory_end;
  213.21  
  213.22  #endif /* __ASSEMBLY__ */
  213.23  
  213.24 +#include <asm-generic/page.h>
  213.25 +
  213.26  #endif /* __KERNEL__ */
  213.27  
  213.28 -#include <asm-generic/page.h>
  213.29 -
  213.30  #endif /* _M68KNOMMU_PAGE_H */
   214.1 --- a/include/asm-powerpc/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   214.2 +++ b/include/asm-powerpc/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   214.3 @@ -1,10 +1,41 @@
   214.4  include include/asm-generic/Kbuild.asm
   214.5  
   214.6 -unifdef-y += a.out.h asm-compat.h bootx.h byteorder.h cputable.h elf.h	\
   214.7 -	nvram.h param.h posix_types.h ptrace.h seccomp.h signal.h	\
   214.8 -	termios.h types.h unistd.h
   214.9 +header-y += auxvec.h
  214.10 +header-y += ioctls.h
  214.11 +header-y += mman.h
  214.12 +header-y += sembuf.h
  214.13 +header-y += siginfo.h
  214.14 +header-y += stat.h
  214.15 +header-y += errno.h
  214.16 +header-y += ipcbuf.h
  214.17 +header-y += msgbuf.h
  214.18 +header-y += shmbuf.h
  214.19 +header-y += socket.h
  214.20 +header-y += termbits.h
  214.21 +header-y += fcntl.h
  214.22 +header-y += ipc.h
  214.23 +header-y += poll.h
  214.24 +header-y += shmparam.h
  214.25 +header-y += sockios.h
  214.26 +header-y += ucontext.h
  214.27 +header-y += ioctl.h
  214.28 +header-y += linkage.h
  214.29 +header-y += resource.h
  214.30 +header-y += sigcontext.h
  214.31 +header-y += statfs.h
  214.32  
  214.33 -header-y += auxvec.h ioctls.h mman.h sembuf.h siginfo.h stat.h errno.h	\
  214.34 -	ipcbuf.h msgbuf.h shmbuf.h socket.h termbits.h fcntl.h ipc.h	\
  214.35 -	poll.h shmparam.h sockios.h ucontext.h ioctl.h linkage.h	\
  214.36 -	resource.h sigcontext.h statfs.h
  214.37 +unifdef-y += a.out.h
  214.38 +unifdef-y += asm-compat.h
  214.39 +unifdef-y += bootx.h
  214.40 +unifdef-y += byteorder.h
  214.41 +unifdef-y += cputable.h
  214.42 +unifdef-y += elf.h
  214.43 +unifdef-y += nvram.h
  214.44 +unifdef-y += param.h
  214.45 +unifdef-y += posix_types.h
  214.46 +unifdef-y += ptrace.h
  214.47 +unifdef-y += seccomp.h
  214.48 +unifdef-y += signal.h
  214.49 +unifdef-y += termios.h
  214.50 +unifdef-y += types.h
  214.51 +unifdef-y += unistd.h
   215.1 --- a/include/asm-powerpc/current.h	Tue Oct 02 09:52:15 2007 +0100
   215.2 +++ b/include/asm-powerpc/current.h	Wed Oct 03 10:00:44 2007 +0100
   215.3 @@ -14,7 +14,17 @@ struct task_struct;
   215.4  #ifdef __powerpc64__
   215.5  #include <asm/paca.h>
   215.6  
   215.7 -#define current		(get_paca()->__current)
   215.8 +static inline struct task_struct *get_current(void)
   215.9 +{
  215.10 +	struct task_struct *task;
  215.11 +
  215.12 +	__asm__ __volatile__("ld %0,%1(13)"
  215.13 +	: "=r" (task)
  215.14 +	: "i" (offsetof(struct paca_struct, __current)));
  215.15 +
  215.16 +	return task;
  215.17 +}
  215.18 +#define current	get_current()
  215.19  
  215.20  #else
  215.21  
   216.1 --- a/include/asm-powerpc/ptrace.h	Tue Oct 02 09:52:15 2007 +0100
   216.2 +++ b/include/asm-powerpc/ptrace.h	Wed Oct 03 10:00:44 2007 +0100
   216.3 @@ -215,12 +215,10 @@ do {									      \
   216.4  #define PTRACE_GETVRREGS	18
   216.5  #define PTRACE_SETVRREGS	19
   216.6  
   216.7 -#ifndef __powerpc64__
   216.8  /* Get/set all the upper 32-bits of the SPE registers, accumulator, and
   216.9   * spefscr, in one go */
  216.10  #define PTRACE_GETEVRREGS	20
  216.11  #define PTRACE_SETEVRREGS	21
  216.12 -#endif /* __powerpc64__ */
  216.13  
  216.14  /*
  216.15   * Get or set a debug register. The first 16 are DABR registers and the
  216.16 @@ -235,7 +233,6 @@ do {									      \
  216.17  #define PPC_PTRACE_GETFPREGS	0x97	/* Get FPRs 0 - 31 */
  216.18  #define PPC_PTRACE_SETFPREGS	0x96	/* Set FPRs 0 - 31 */
  216.19  
  216.20 -#ifdef __powerpc64__
  216.21  /* Calls to trace a 64bit program from a 32bit program */
  216.22  #define PPC_PTRACE_PEEKTEXT_3264 0x95
  216.23  #define PPC_PTRACE_PEEKDATA_3264 0x94
  216.24 @@ -243,6 +240,5 @@ do {									      \
  216.25  #define PPC_PTRACE_POKEDATA_3264 0x92
  216.26  #define PPC_PTRACE_PEEKUSR_3264  0x91
  216.27  #define PPC_PTRACE_POKEUSR_3264  0x90
  216.28 -#endif /* __powerpc64__ */
  216.29  
  216.30  #endif /* _ASM_POWERPC_PTRACE_H */
   217.1 --- a/include/asm-s390/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   217.2 +++ b/include/asm-s390/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   217.3 @@ -1,4 +1,11 @@
   217.4  include include/asm-generic/Kbuild.asm
   217.5  
   217.6 -unifdef-y += cmb.h debug.h
   217.7 -header-y += dasd.h qeth.h tape390.h ucontext.h vtoc.h z90crypt.h
   217.8 +header-y += dasd.h
   217.9 +header-y += qeth.h
  217.10 +header-y += tape390.h
  217.11 +header-y += ucontext.h
  217.12 +header-y += vtoc.h
  217.13 +header-y += z90crypt.h
  217.14 +
  217.15 +unifdef-y += cmb.h
  217.16 +unifdef-y += debug.h
   218.1 --- a/include/asm-s390/div64.h	Tue Oct 02 09:52:15 2007 +0100
   218.2 +++ b/include/asm-s390/div64.h	Wed Oct 03 10:00:44 2007 +0100
   218.3 @@ -1,49 +1,1 @@
   218.4 -#ifndef __S390_DIV64
   218.5 -#define __S390_DIV64
   218.6 -
   218.7 -#ifndef __s390x__
   218.8 -
   218.9 -/* for do_div "base" needs to be smaller than 2^31-1 */
  218.10 -#define do_div(n, base) ({                                      \
  218.11 -	unsigned long long __n = (n);				\
  218.12 -	unsigned long __r;					\
  218.13 -								\
  218.14 -	asm ("   slr  0,0\n"					\
  218.15 -	     "   l    1,%1\n"					\
  218.16 -	     "   srdl 0,1\n"					\
  218.17 -	     "   dr   0,%2\n"					\
  218.18 -	     "   alr  1,1\n"					\
  218.19 -	     "   alr  0,0\n"					\
  218.20 -	     "   lhi  2,1\n"					\
  218.21 -	     "   n    2,%1\n"					\
  218.22 -	     "   alr  0,2\n"					\
  218.23 -	     "   clr  0,%2\n"					\
  218.24 -	     "   jl   0f\n"					\
  218.25 -	     "   slr  0,%2\n"					\
  218.26 -             "   ahi  1,1\n"					\
  218.27 -	     "0: st   1,%1\n"					\
  218.28 -	     "   l    1,4+%1\n"					\
  218.29 -	     "   srdl 0,1\n"					\
  218.30 -             "   dr   0,%2\n"					\
  218.31 -	     "   alr  1,1\n"					\
  218.32 -	     "   alr  0,0\n"					\
  218.33 -	     "   lhi  2,1\n"					\
  218.34 -	     "   n    2,4+%1\n"					\
  218.35 -	     "   alr  0,2\n"					\
  218.36 -	     "   clr  0,%2\n"					\
  218.37 -             "   jl   1f\n"					\
  218.38 -	     "   slr  0,%2\n"					\
  218.39 -	     "   ahi  1,1\n"					\
  218.40 -	     "1: st   1,4+%1\n"					\
  218.41 -             "   lr   %0,0"					\
  218.42 -	     : "=d" (__r), "=m" (__n)				\
  218.43 -	     : "d" (base), "m" (__n) : "0", "1", "2", "cc" );	\
  218.44 -	(n) = (__n);						\
  218.45 -        __r;                                                    \
  218.46 -})
  218.47 -
  218.48 -#else /* __s390x__ */
  218.49  #include <asm-generic/div64.h>
  218.50 -#endif /* __s390x__ */
  218.51 -
  218.52 -#endif
   219.1 --- a/include/asm-sh/page.h	Tue Oct 02 09:52:15 2007 +0100
   219.2 +++ b/include/asm-sh/page.h	Wed Oct 03 10:00:44 2007 +0100
   219.3 @@ -112,9 +112,8 @@ typedef struct { unsigned long pgprot; }
   219.4  #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
   219.5  				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
   219.6  
   219.7 -#endif /* __KERNEL__ */
   219.8 -
   219.9  #include <asm-generic/memory_model.h>
  219.10  #include <asm-generic/page.h>
  219.11  
  219.12 +#endif /* __KERNEL__ */
  219.13  #endif /* __ASM_SH_PAGE_H */
   220.1 --- a/include/asm-sh/ptrace.h	Tue Oct 02 09:52:15 2007 +0100
   220.2 +++ b/include/asm-sh/ptrace.h	Wed Oct 03 10:00:44 2007 +0100
   220.3 @@ -1,8 +1,6 @@
   220.4  #ifndef __ASM_SH_PTRACE_H
   220.5  #define __ASM_SH_PTRACE_H
   220.6  
   220.7 -#include <asm/ubc.h>
   220.8 -
   220.9  /*
  220.10   * Copyright (C) 1999, 2000  Niibe Yutaka
  220.11   *
   221.1 --- a/include/asm-sh64/page.h	Tue Oct 02 09:52:15 2007 +0100
   221.2 +++ b/include/asm-sh64/page.h	Wed Oct 03 10:00:44 2007 +0100
   221.3 @@ -112,9 +112,8 @@ typedef struct { unsigned long pgprot; }
   221.4  #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
   221.5  				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
   221.6  
   221.7 -#endif /* __KERNEL__ */
   221.8 -
   221.9  #include <asm-generic/memory_model.h>
  221.10  #include <asm-generic/page.h>
  221.11  
  221.12 +#endif /* __KERNEL__ */
  221.13  #endif /* __ASM_SH64_PAGE_H */
   222.1 --- a/include/asm-sh64/shmparam.h	Tue Oct 02 09:52:15 2007 +0100
   222.2 +++ b/include/asm-sh64/shmparam.h	Wed Oct 03 10:00:44 2007 +0100
   222.3 @@ -2,19 +2,11 @@
   222.4  #define __ASM_SH64_SHMPARAM_H
   222.5  
   222.6  /*
   222.7 - * This file is subject to the terms and conditions of the GNU General Public
   222.8 - * License.  See the file "COPYING" in the main directory of this archive
   222.9 - * for more details.
  222.10 - *
  222.11 - * include/asm-sh64/shmparam.h
  222.12 - *
  222.13 - * Copyright (C) 2000, 2001  Paolo Alberelli
  222.14 - *
  222.15 + * Set this to a sensible safe default, we'll work out the specifics for the
  222.16 + * align mask from the cache descriptor at run-time.
  222.17   */
  222.18 +#define	SHMLBA	0x4000
  222.19  
  222.20 -#include <asm/cache.h>
  222.21 -
  222.22 -/* attach addr a multiple of this */
  222.23 -#define	SHMLBA	(cpu_data->dcache.sets * L1_CACHE_BYTES)
  222.24 +#define __ARCH_FORCE_SHMLBA
  222.25  
  222.26  #endif /* __ASM_SH64_SHMPARAM_H */
   223.1 --- a/include/asm-sh64/signal.h	Tue Oct 02 09:52:15 2007 +0100
   223.2 +++ b/include/asm-sh64/signal.h	Wed Oct 03 10:00:44 2007 +0100
   223.3 @@ -13,7 +13,6 @@
   223.4   */
   223.5  
   223.6  #include <linux/types.h>
   223.7 -#include <asm/processor.h>
   223.8  
   223.9  /* Avoid too many header ordering problems.  */
  223.10  struct siginfo;
   224.1 --- a/include/asm-sh64/user.h	Tue Oct 02 09:52:15 2007 +0100
   224.2 +++ b/include/asm-sh64/user.h	Wed Oct 03 10:00:44 2007 +0100
   224.3 @@ -13,7 +13,6 @@
   224.4   */
   224.5  
   224.6  #include <linux/types.h>
   224.7 -#include <asm/processor.h>
   224.8  #include <asm/ptrace.h>
   224.9  #include <asm/page.h>
  224.10  
   225.1 --- a/include/asm-sparc/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   225.2 +++ b/include/asm-sparc/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   225.3 @@ -1,6 +1,15 @@
   225.4  include include/asm-generic/Kbuild.asm
   225.5  
   225.6 -unifdef-y += fbio.h perfctr.h psr.h
   225.7 -header-y += apc.h asi.h auxio.h bpp.h head.h ipc.h jsflash.h	\
   225.8 -	openpromio.h pbm.h pconf.h pgtsun4.h reg.h traps.h	\
   225.9 -	turbosparc.h vfc_ioctls.h winmacro.h
  225.10 +header-y += apc.h
  225.11 +header-y += asi.h
  225.12 +header-y += bpp.h
  225.13 +header-y += jsflash.h
  225.14 +header-y += openpromio.h
  225.15 +header-y += pconf.h
  225.16 +header-y += reg.h
  225.17 +header-y += traps.h
  225.18 +header-y += vfc_ioctls.h
  225.19 +
  225.20 +unifdef-y += fbio.h
  225.21 +unifdef-y += perfctr.h
  225.22 +unifdef-y += psr.h
   226.1 --- a/include/asm-sparc/page.h	Tue Oct 02 09:52:15 2007 +0100
   226.2 +++ b/include/asm-sparc/page.h	Wed Oct 03 10:00:44 2007 +0100
   226.3 @@ -8,6 +8,8 @@
   226.4  #ifndef _SPARC_PAGE_H
   226.5  #define _SPARC_PAGE_H
   226.6  
   226.7 +#ifdef __KERNEL__
   226.8 +
   226.9  #ifdef CONFIG_SUN4
  226.10  #define PAGE_SHIFT   13
  226.11  #else
  226.12 @@ -21,8 +23,6 @@
  226.13  #endif
  226.14  #define PAGE_MASK    (~(PAGE_SIZE-1))
  226.15  
  226.16 -#ifdef __KERNEL__
  226.17 -
  226.18  #include <asm/btfixup.h>
  226.19  
  226.20  #ifndef __ASSEMBLY__
  226.21 @@ -160,9 +160,9 @@ extern unsigned long pfn_base;
  226.22  #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
  226.23  				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  226.24  
  226.25 -#endif /* __KERNEL__ */
  226.26 -
  226.27  #include <asm-generic/memory_model.h>
  226.28  #include <asm-generic/page.h>
  226.29  
  226.30 +#endif /* __KERNEL__ */
  226.31 +
  226.32  #endif /* _SPARC_PAGE_H */
   227.1 --- a/include/asm-sparc/unistd.h	Tue Oct 02 09:52:15 2007 +0100
   227.2 +++ b/include/asm-sparc/unistd.h	Wed Oct 03 10:00:44 2007 +0100
   227.3 @@ -319,6 +319,8 @@
   227.4  #define __NR_set_robust_list	300
   227.5  #define __NR_get_robust_list	301
   227.6  
   227.7 +#define NR_SYSCALLS		302
   227.8 +
   227.9  #ifdef __KERNEL__
  227.10  /* WARNING: You MAY NOT add syscall numbers larger than 301, since
  227.11   *          all of the syscall tables in the Sparc kernel are
   228.1 --- a/include/asm-sparc64/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   228.2 +++ b/include/asm-sparc64/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   228.3 @@ -4,7 +4,23 @@ ALTARCH := sparc
   228.4  ARCHDEF := defined __sparc__ && defined __arch64__
   228.5  ALTARCHDEF := defined __sparc__ && !defined __arch64__
   228.6  
   228.7 -unifdef-y += fbio.h perfctr.h
   228.8 -header-y += apb.h asi.h bbc.h bpp.h display7seg.h envctrl.h floppy.h	\
   228.9 -	ipc.h kdebug.h mostek.h openprom.h openpromio.h parport.h	\
  228.10 -	pconf.h psrcompat.h pstate.h reg.h uctx.h utrap.h watchdog.h
  228.11 +header-y += apb.h
  228.12 +header-y += asi.h
  228.13 +header-y += bbc.h
  228.14 +header-y += bpp.h
  228.15 +header-y += const.h
  228.16 +header-y += display7seg.h
  228.17 +header-y += envctrl.h
  228.18 +header-y += ipc.h
  228.19 +header-y += openprom.h
  228.20 +header-y += openpromio.h
  228.21 +header-y += pconf.h
  228.22 +header-y += psrcompat.h
  228.23 +header-y += pstate.h
  228.24 +header-y += reg.h
  228.25 +header-y += uctx.h
  228.26 +header-y += utrap.h
  228.27 +header-y += watchdog.h
  228.28 +
  228.29 +unifdef-y += fbio.h
  228.30 +unifdef-y += perfctr.h
   229.1 --- a/include/asm-sparc64/futex.h	Tue Oct 02 09:52:15 2007 +0100
   229.2 +++ b/include/asm-sparc64/futex.h	Wed Oct 03 10:00:44 2007 +0100
   229.3 @@ -87,24 +87,22 @@ static inline int
   229.4  futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
   229.5  {
   229.6  	__asm__ __volatile__(
   229.7 -	"\n1:	lduwa	[%2] %%asi, %0\n"
   229.8 -	"2:	casa	[%2] %%asi, %0, %1\n"
   229.9 -	"3:\n"
  229.10 +	"\n1:	casa	[%3] %%asi, %2, %0\n"
  229.11 +	"2:\n"
  229.12  	"	.section .fixup,#alloc,#execinstr\n"
  229.13  	"	.align	4\n"
  229.14 -	"4:	ba	3b\n"
  229.15 -	"	 mov	%3, %0\n"
  229.16 +	"3:	ba	2b\n"
  229.17 +	"	 mov	%4, %0\n"
  229.18  	"	.previous\n"
  229.19  	"	.section __ex_table,\"a\"\n"
  229.20  	"	.align	4\n"
  229.21 -	"	.word	1b, 4b\n"
  229.22 -	"	.word	2b, 4b\n"
  229.23 +	"	.word	1b, 3b\n"
  229.24  	"	.previous\n"
  229.25 -	: "=&r" (oldval)
  229.26 -	: "r" (newval), "r" (uaddr), "i" (-EFAULT)
  229.27 +	: "=r" (newval)
  229.28 +	: "0" (newval), "r" (oldval), "r" (uaddr), "i" (-EFAULT)
  229.29  	: "memory");
  229.30  
  229.31 -	return oldval;
  229.32 +	return newval;
  229.33  }
  229.34  
  229.35  #endif /* !(_SPARC64_FUTEX_H) */
   230.1 --- a/include/asm-sparc64/page.h	Tue Oct 02 09:52:15 2007 +0100
   230.2 +++ b/include/asm-sparc64/page.h	Wed Oct 03 10:00:44 2007 +0100
   230.3 @@ -3,6 +3,8 @@
   230.4  #ifndef _SPARC64_PAGE_H
   230.5  #define _SPARC64_PAGE_H
   230.6  
   230.7 +#ifdef __KERNEL__
   230.8 +
   230.9  #include <asm/const.h>
  230.10  
  230.11  #if defined(CONFIG_SPARC64_PAGE_SIZE_8KB)
  230.12 @@ -27,8 +29,6 @@
  230.13  #define DCACHE_ALIASING_POSSIBLE
  230.14  #endif
  230.15  
  230.16 -#ifdef __KERNEL__
  230.17 -
  230.18  #if defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
  230.19  #define HPAGE_SHIFT		22
  230.20  #elif defined(CONFIG_HUGETLB_PAGE_SIZE_512K)
  230.21 @@ -141,8 +141,7 @@ typedef unsigned long pgprot_t;
  230.22  #define VM_DATA_DEFAULT_FLAGS	(VM_READ | VM_WRITE | VM_EXEC | \
  230.23  				 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
  230.24  
  230.25 -#endif /* !(__KERNEL__) */
  230.26 -
  230.27  #include <asm-generic/page.h>
  230.28  
  230.29 -#endif /* !(_SPARC64_PAGE_H) */
  230.30 +#endif /* __KERNEL__ */
  230.31 +#endif /* _SPARC64_PAGE_H */
   231.1 --- a/include/asm-sparc64/shmparam.h	Tue Oct 02 09:52:15 2007 +0100
   231.2 +++ b/include/asm-sparc64/shmparam.h	Wed Oct 03 10:00:44 2007 +0100
   231.3 @@ -1,6 +1,7 @@
   231.4  /* $Id: shmparam.h,v 1.5 2001/09/24 21:17:57 kanoj Exp $ */
   231.5  #ifndef _ASMSPARC64_SHMPARAM_H
   231.6  #define _ASMSPARC64_SHMPARAM_H
   231.7 +#ifdef __KERNEL__
   231.8  
   231.9  #include <asm/spitfire.h>
  231.10  
  231.11 @@ -8,4 +9,5 @@
  231.12  /* attach addr a multiple of this */
  231.13  #define	SHMLBA	((PAGE_SIZE > L1DCACHE_SIZE) ? PAGE_SIZE : L1DCACHE_SIZE)
  231.14  
  231.15 +#endif /* __KERNEL__ */
  231.16  #endif /* _ASMSPARC64_SHMPARAM_H */
   232.1 --- a/include/asm-sparc64/unistd.h	Tue Oct 02 09:52:15 2007 +0100
   232.2 +++ b/include/asm-sparc64/unistd.h	Wed Oct 03 10:00:44 2007 +0100
   232.3 @@ -321,6 +321,8 @@
   232.4  #define __NR_set_robust_list	300
   232.5  #define __NR_get_robust_list	301
   232.6  
   232.7 +#define NR_SYSCALLS		302
   232.8 +
   232.9  #ifdef __KERNEL__
  232.10  /* WARNING: You MAY NOT add syscall numbers larger than 301, since
  232.11   *          all of the syscall tables in the Sparc kernel are
   233.1 --- a/include/asm-um/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   233.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   233.3 @@ -1,1 +0,0 @@
   233.4 -include include/asm-generic/Kbuild.asm
   234.1 --- a/include/asm-v850/page.h	Tue Oct 02 09:52:15 2007 +0100
   234.2 +++ b/include/asm-v850/page.h	Wed Oct 03 10:00:44 2007 +0100
   234.3 @@ -14,6 +14,8 @@
   234.4  #ifndef __V850_PAGE_H__
   234.5  #define __V850_PAGE_H__
   234.6  
   234.7 +#ifdef __KERNEL__
   234.8 +
   234.9  #include <asm/machdep.h>
  234.10  
  234.11  
  234.12 @@ -32,7 +34,6 @@
  234.13  #endif
  234.14  
  234.15  
  234.16 -#ifdef __KERNEL__
  234.17  #ifndef __ASSEMBLY__
  234.18  
  234.19  #define STRICT_MM_TYPECHECKS
  234.20 @@ -122,9 +123,9 @@ typedef unsigned long pgprot_t;
  234.21  #define __va(x)		     ((void *)__phys_to_virt ((unsigned long)(x)))
  234.22  
  234.23  
  234.24 -#endif /* KERNEL */
  234.25 -
  234.26  #include <asm-generic/memory_model.h>
  234.27  #include <asm-generic/page.h>
  234.28  
  234.29 +#endif /* KERNEL */
  234.30 +
  234.31  #endif /* __V850_PAGE_H__ */
   235.1 --- a/include/asm-v850/param.h	Tue Oct 02 09:52:15 2007 +0100
   235.2 +++ b/include/asm-v850/param.h	Wed Oct 03 10:00:44 2007 +0100
   235.3 @@ -14,8 +14,6 @@
   235.4  #ifndef __V850_PARAM_H__
   235.5  #define __V850_PARAM_H__
   235.6  
   235.7 -#include <asm/machdep.h>	/* For HZ */
   235.8 -
   235.9  #define EXEC_PAGESIZE	4096
  235.10  
  235.11  #ifndef NOGROUP
  235.12 @@ -25,6 +23,8 @@
  235.13  #define MAXHOSTNAMELEN	64	/* max length of hostname */
  235.14  
  235.15  #ifdef __KERNEL__
  235.16 +#include <asm/machdep.h>	/* For HZ */
  235.17 +
  235.18  # define USER_HZ	100
  235.19  # define CLOCKS_PER_SEC	USER_HZ
  235.20  #endif
   236.1 --- a/include/asm-x86_64/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   236.2 +++ b/include/asm-x86_64/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   236.3 @@ -4,8 +4,18 @@ ALTARCH := i386
   236.4  ARCHDEF := defined __x86_64__
   236.5  ALTARCHDEF := defined __i386__
   236.6  
   236.7 -header-y += boot.h bootsetup.h cpufeature.h debugreg.h ldt.h \
   236.8 -	 msr.h prctl.h setup.h sigcontext32.h ucontext.h \
   236.9 -	 vsyscall32.h
  236.10 +header-y += boot.h
  236.11 +header-y += bootsetup.h
  236.12 +header-y += cpufeature.h
  236.13 +header-y += debugreg.h
  236.14 +header-y += ldt.h
  236.15 +header-y += msr.h
  236.16 +header-y += prctl.h
  236.17 +header-y += setup.h
  236.18 +header-y += sigcontext32.h
  236.19 +header-y += ucontext.h
  236.20 +header-y += vsyscall32.h
  236.21  
  236.22 -unifdef-y += mce.h mtrr.h vsyscall.h
  236.23 +unifdef-y += mce.h
  236.24 +unifdef-y += mtrr.h
  236.25 +unifdef-y += vsyscall.h
   237.1 --- a/include/asm-x86_64/system.h	Tue Oct 02 09:52:15 2007 +0100
   237.2 +++ b/include/asm-x86_64/system.h	Wed Oct 03 10:00:44 2007 +0100
   237.3 @@ -14,12 +14,13 @@
   237.4  #define __RESTORE(reg,offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t"
   237.5  
   237.6  /* frame pointer must be last for get_wchan */
   237.7 -#define SAVE_CONTEXT    "pushq %%rbp ; movq %%rsi,%%rbp\n\t"
   237.8 -#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp\n\t"
   237.9 +#define SAVE_CONTEXT    "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t"
  237.10 +#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t"
  237.11  
  237.12  #define __EXTRA_CLOBBER  \
  237.13  	,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15"
  237.14  
  237.15 +/* Save restore flags to clear handle leaking NT */
  237.16  #define switch_to(prev,next,last) \
  237.17  	asm volatile(SAVE_CONTEXT						    \
  237.18  		     "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */	  \
   238.1 --- a/include/linux/Kbuild	Tue Oct 02 09:52:15 2007 +0100
   238.2 +++ b/include/linux/Kbuild	Wed Oct 03 10:00:44 2007 +0100
   238.3 @@ -1,63 +1,343 @@
   238.4 -header-y := byteorder/ dvb/ hdlc/ isdn/ nfsd/ raid/ sunrpc/ tc_act/	\
   238.5 -	netfilter/ netfilter_arp/ netfilter_bridge/ netfilter_ipv4/	\
   238.6 -	netfilter_ipv6/
   238.7 +header-y += byteorder/
   238.8 +header-y += dvb/
   238.9 +header-y += hdlc/
  238.10 +header-y += isdn/
  238.11 +header-y += nfsd/
  238.12 +header-y += raid/
  238.13 +header-y += sunrpc/
  238.14 +header-y += tc_act/
  238.15 +header-y += netfilter/
  238.16 +header-y += netfilter_arp/
  238.17 +header-y += netfilter_bridge/
  238.18 +header-y += netfilter_ipv4/
  238.19 +header-y += netfilter_ipv6/
  238.20  
  238.21 -header-y += affs_fs.h affs_hardblocks.h aio_abi.h a.out.h arcfb.h	\
  238.22 -	atmapi.h atmbr2684.h atmclip.h atm_eni.h atm_he.h		\
  238.23 -	atm_idt77105.h atmioc.h atmlec.h atmmpc.h atm_nicstar.h		\
  238.24 -	atmppp.h atmsap.h atmsvc.h atm_zatm.h auto_fs4.h auxvec.h	\
  238.25 -	awe_voice.h ax25.h b1lli.h baycom.h bfs_fs.h blkpg.h		\
  238.26 -	bpqether.h cdk.h chio.h coda_psdev.h coff.h comstats.h		\
  238.27 -	consolemap.h cycx_cfm.h dm-ioctl.h dn.h dqblk_v1.h		\
  238.28 -	dqblk_v2.h dqblk_xfs.h efs_fs_sb.h elf-fdpic.h elf.h elf-em.h	\
  238.29 -	fadvise.h fd.h fdreg.h ftape-header-segment.h ftape-vendors.h	\
  238.30 -	fuse.h futex.h genetlink.h gen_stats.h gigaset_dev.h hdsmart.h	\
  238.31 -	hpfs_fs.h hysdn_if.h i2c-dev.h i8k.h icmp.h			\
  238.32 -	if_arcnet.h if_arp.h if_bonding.h if_cablemodem.h if_fc.h	\
  238.33 -	if_fddi.h if.h if_hippi.h if_infiniband.h if_packet.h		\
  238.34 -	if_plip.h if_ppp.h if_slip.h if_strip.h if_tunnel.h in6.h	\
  238.35 -	in_route.h ioctl.h ip.h ipmi_msgdefs.h ip_mp_alg.h ipsec.h	\
  238.36 -	ipx.h irda.h isdn_divertif.h iso_fs.h ite_gpio.h ixjuser.h	\
  238.37 -	jffs2.h keyctl.h limits.h major.h matroxfb.h meye.h minix_fs.h	\
  238.38 -	mmtimer.h mqueue.h mtio.h ncp_no.h netfilter_arp.h netrom.h	\
  238.39 -	nfs2.h nfs4_mount.h nfs_mount.h openprom_fs.h param.h		\
  238.40 -	pci_ids.h pci_regs.h personality.h pfkeyv2.h pg.h pkt_cls.h	\
  238.41 -	pkt_sched.h posix_types.h ppdev.h prctl.h ps2esdi.h qic117.h	\
  238.42 -	qnxtypes.h quotaio_v1.h quotaio_v2.h radeonfb.h raw.h		\
  238.43 -	resource.h rose.h sctp.h smbno.h snmp.h sockios.h som.h		\
  238.44 -	sound.h stddef.h synclink.h telephony.h termios.h ticable.h	\
  238.45 -	times.h tiocl.h tipc.h toshiba.h ultrasound.h un.h utime.h	\
  238.46 -	utsname.h video_decoder.h video_encoder.h videotext.h vt.h	\
  238.47 -	wavefront.h wireless.h xattr.h x25.h zorro_ids.h
  238.48 +header-y += affs_fs.h
  238.49 +header-y += affs_hardblocks.h
  238.50 +header-y += aio_abi.h
  238.51 +header-y += a.out.h
  238.52 +header-y += arcfb.h
  238.53 +header-y += atmapi.h
  238.54 +header-y += atmbr2684.h
  238.55 +header-y += atmclip.h
  238.56 +header-y += atm_eni.h
  238.57 +header-y += atm_he.h
  238.58 +header-y += atm_idt77105.h
  238.59 +header-y += atmioc.h
  238.60 +header-y += atmlec.h
  238.61 +header-y += atmmpc.h
  238.62 +header-y += atm_nicstar.h
  238.63 +header-y += atmppp.h
  238.64 +header-y += atmsap.h
  238.65 +header-y += atmsvc.h
  238.66 +header-y += atm_zatm.h
  238.67 +header-y += auto_fs4.h
  238.68 +header-y += auxvec.h
  238.69 +header-y += awe_voice.h
  238.70 +header-y += ax25.h
  238.71 +header-y += b1lli.h
  238.72 +header-y += baycom.h
  238.73 +header-y += bfs_fs.h
  238.74 +header-y += blkpg.h
  238.75 +header-y += bpqether.h
  238.76 +header-y += cdk.h
  238.77 +header-y += chio.h
  238.78 +header-y += coda_psdev.h
  238.79 +header-y += coff.h
  238.80 +header-y += comstats.h
  238.81 +header-y += consolemap.h
  238.82 +header-y += cycx_cfm.h
  238.83 +header-y += dm-ioctl.h
  238.84 +header-y += dn.h
  238.85 +header-y += dqblk_v1.h
  238.86 +header-y += dqblk_v2.h
  238.87 +header-y += dqblk_xfs.h
  238.88 +header-y += efs_fs_sb.h
  238.89 +header-y += elf-fdpic.h
  238.90 +header-y += elf.h
  238.91 +header-y += elf-em.h
  238.92 +header-y += fadvise.h
  238.93 +header-y += fd.h
  238.94 +header-y += fdreg.h
  238.95 +header-y += ftape-header-segment.h
  238.96 +header-y += ftape-vendors.h
  238.97 +header-y += fuse.h
  238.98 +header-y += futex.h
  238.99 +header-y += genetlink.h
 238.100 +header-y += gen_stats.h
 238.101 +header-y += gigaset_dev.h
 238.102 +header-y += hdsmart.h
 238.103 +header-y += hpfs_fs.h
 238.104 +header-y += hysdn_if.h
 238.105 +header-y += i2c-dev.h
 238.106 +header-y += i8k.h
 238.107 +header-y += icmp.h
 238.108 +header-y += if_arcnet.h
 238.109 +header-y += if_arp.h
 238.110 +header-y += if_bonding.h
 238.111 +header-y += if_cablemodem.h
 238.112 +header-y += if_fc.h
 238.113 +header-y += if_fddi.h
 238.114 +header-y += if.h
 238.115 +header-y += if_hippi.h
 238.116 +header-y += if_infiniband.h
 238.117 +header-y += if_packet.h
 238.118 +header-y += if_plip.h
 238.119 +header-y += if_ppp.h
 238.120 +header-y += if_slip.h
 238.121 +header-y += if_strip.h
 238.122 +header-y += if_tunnel.h
 238.123 +header-y += in6.h
 238.124 +header-y += in_route.h
 238.125 +header-y += ioctl.h
 238.126 +header-y += ip.h
 238.127 +header-y += ipmi_msgdefs.h
 238.128 +header-y += ip_mp_alg.h
 238.129 +header-y += ipsec.h
 238.130 +header-y += ipx.h
 238.131 +header-y += irda.h
 238.132 +header-y += isdn_divertif.h
 238.133 +header-y += iso_fs.h
 238.134 +header-y += ite_gpio.h
 238.135 +header-y += ixjuser.h
 238.136 +header-y += jffs2.h
 238.137 +header-y += keyctl.h
 238.138 +header-y += limits.h
 238.139 +header-y += major.h
 238.140 +header-y += matroxfb.h
 238.141 +header-y += meye.h
 238.142 +header-y += minix_fs.h
 238.143 +header-y += mmtimer.h
 238.144 +header-y += mqueue.h
 238.145 +header-y += mtio.h
 238.146 +header-y += ncp_no.h
 238.147 +header-y += netfilter_arp.h
 238.148 +header-y += netrom.h
 238.149 +header-y += nfs2.h
 238.150 +header-y += nfs4_mount.h
 238.151 +header-y += nfs_mount.h
 238.152 +header-y += openprom_fs.h
 238.153 +header-y += param.h
 238.154 +header-y += pci_ids.h
 238.155 +header-y += pci_regs.h
 238.156 +header-y += personality.h
 238.157 +header-y += pfkeyv2.h