aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/00-INDEX2
-rw-r--r--Documentation/cpuidle/core.txt23
-rw-r--r--Documentation/cpuidle/driver.txt31
-rw-r--r--Documentation/cpuidle/governor.txt29
-rw-r--r--Documentation/cpuidle/sysfs.txt79
-rw-r--r--MAINTAINERS9
-rw-r--r--Makefile4
-rw-r--r--arch/alpha/kernel/osf_sys.c4
-rw-r--r--arch/blackfin/kernel/traps.c12
-rw-r--r--arch/cris/arch-v10/lib/memset.c397
-rw-r--r--arch/cris/arch-v32/lib/memset.c398
-rw-r--r--arch/m68knommu/platform/5206/Makefile4
-rw-r--r--arch/m68knommu/platform/5206e/Makefile4
-rw-r--r--arch/m68knommu/platform/520x/Makefile4
-rw-r--r--arch/m68knommu/platform/523x/Makefile4
-rw-r--r--arch/m68knommu/platform/5249/Makefile4
-rw-r--r--arch/m68knommu/platform/5272/Makefile4
-rw-r--r--arch/m68knommu/platform/527x/Makefile4
-rw-r--r--arch/m68knommu/platform/528x/Makefile4
-rw-r--r--arch/m68knommu/platform/5307/Makefile4
-rw-r--r--arch/m68knommu/platform/532x/Makefile4
-rw-r--r--arch/m68knommu/platform/5407/Makefile4
-rw-r--r--arch/m68knommu/platform/coldfire/Makefile4
-rw-r--r--arch/m68knommu/platform/coldfire/entry.S9
-rw-r--r--arch/m68knommu/platform/coldfire/timers.c17
-rw-r--r--arch/mips/kernel/sysirix.c12
-rw-r--r--arch/parisc/hpux/sys_hpux.c4
-rw-r--r--arch/powerpc/Kconfig4
-rw-r--r--arch/powerpc/boot/Makefile2
-rw-r--r--arch/powerpc/boot/ps3-hvcall.S2
-rw-r--r--arch/powerpc/kernel/Makefile2
-rw-r--r--arch/powerpc/kernel/process.c2
-rw-r--r--arch/powerpc/kernel/vdso.c12
-rw-r--r--arch/powerpc/oprofile/cell/spu_task_sync.c15
-rw-r--r--arch/powerpc/platforms/512x/Kconfig1
-rw-r--r--arch/powerpc/platforms/52xx/Kconfig2
-rw-r--r--arch/powerpc/platforms/Kconfig2
-rw-r--r--arch/powerpc/platforms/Kconfig.cputype4
-rw-r--r--arch/powerpc/platforms/cell/ras.c11
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c18
-rw-r--r--arch/powerpc/platforms/cell/spufs/syscalls.c2
-rw-r--r--arch/powerpc/platforms/embedded6xx/Kconfig4
-rw-r--r--arch/powerpc/platforms/iseries/vio.c2
-rw-r--r--arch/sh/Kconfig19
-rw-r--r--arch/sh/Kconfig.cpu4
-rw-r--r--arch/sh/Kconfig.debug3
-rw-r--r--arch/sh/Makefile1
-rw-r--r--arch/sh/boards/renesas/migor/Makefile1
-rw-r--r--arch/sh/boards/renesas/migor/setup.c61
-rw-r--r--arch/sh/boards/renesas/r7780rp/setup.c47
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/setup.c45
-rw-r--r--arch/sh/boards/renesas/sdk7780/Kconfig7
-rw-r--r--arch/sh/cchips/hd6446x/hd64465/setup.c47
-rw-r--r--arch/sh/configs/migor_defconfig824
-rw-r--r--arch/sh/configs/rts7751r2d1_defconfig340
-rw-r--r--arch/sh/configs/rts7751r2dplus_defconfig340
-rw-r--r--arch/sh/configs/se7705_defconfig1
-rw-r--r--arch/sh/drivers/dma/dma-api.c2
-rw-r--r--arch/sh/drivers/pci/fixups-lboxre2.c4
-rw-r--r--arch/sh/drivers/pci/fixups-rts7751r2d.c4
-rw-r--r--arch/sh/drivers/pci/ops-dreamcast.c44
-rw-r--r--arch/sh/drivers/pci/ops-rts7751r2d.c3
-rw-r--r--arch/sh/drivers/pci/pci-sh4.h4
-rw-r--r--arch/sh/drivers/pci/pci-sh7751.c16
-rw-r--r--arch/sh/drivers/pci/pci-sh7780.c2
-rw-r--r--arch/sh/kernel/Makefile_321
-rw-r--r--arch/sh/kernel/Makefile_641
-rw-r--r--arch/sh/kernel/cpu/irq/Makefile1
-rw-r--r--arch/sh/kernel/cpu/irq/intc-sh5.c27
-rw-r--r--arch/sh/kernel/cpu/irq/maskreg.c93
-rw-r--r--arch/sh/kernel/cpu/sh4/probe.c8
-rw-r--r--arch/sh/kernel/cpu/sh4a/Makefile2
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7722.c10
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7366.c177
-rw-r--r--arch/sh/kernel/cpu/sh5/probe.c61
-rw-r--r--arch/sh/kernel/io.c8
-rw-r--r--arch/sh/kernel/io_generic.c24
-rw-r--r--arch/sh/kernel/io_trapped.c276
-rw-r--r--arch/sh/kernel/irq.c3
-rw-r--r--arch/sh/kernel/process_64.c9
-rw-r--r--arch/sh/kernel/ptrace_32.c4
-rw-r--r--arch/sh/kernel/setup.c2
-rw-r--r--arch/sh/kernel/syscalls_32.S4
-rw-r--r--arch/sh/kernel/syscalls_64.S4
-rw-r--r--arch/sh/kernel/time_32.c19
-rw-r--r--arch/sh/kernel/time_64.c31
-rw-r--r--arch/sh/kernel/timers/timer-mtu2.c1
-rw-r--r--arch/sh/kernel/traps_32.c164
-rw-r--r--arch/sh/kernel/traps_64.c4
-rw-r--r--arch/sh/kernel/vmlinux_64.lds.S2
-rw-r--r--arch/sh/mm/cache-sh5.c1019
-rw-r--r--arch/sh/mm/consistent.c32
-rw-r--r--arch/sh/mm/fault_32.c11
-rw-r--r--arch/sh/mm/init.c2
-rw-r--r--arch/sh/tools/mach-types2
-rw-r--r--arch/sparc64/solaris/fs.c12
-rw-r--r--arch/um/drivers/mconsole_kern.c6
-rw-r--r--arch/x86/Kconfig4
-rw-r--r--arch/x86/kernel/acpi/cstate.c2
-rw-r--r--arch/x86/kernel/efi.c4
-rw-r--r--arch/x86/kernel/pci-gart_64.c9
-rw-r--r--arch/x86/kernel/test_rodata.c2
-rw-r--r--arch/x86/kernel/traps_64.c4
-rw-r--r--arch/x86/mm/fault.c2
-rw-r--r--arch/x86/mm/init_32.c1
-rw-r--r--arch/x86/mm/init_64.c1
-rw-r--r--arch/x86/mm/pageattr.c17
-rw-r--r--drivers/acpi/blacklist.c64
-rw-r--r--drivers/acpi/event.c2
-rw-r--r--drivers/acpi/hardware/hwsleep.c1
-rw-r--r--drivers/acpi/osl.c6
-rw-r--r--drivers/acpi/processor_idle.c19
-rw-r--r--drivers/block/swim3.c4
-rw-r--r--drivers/bluetooth/hci_ldisc.c1
-rw-r--r--drivers/char/hvc_rtas.c2
-rw-r--r--drivers/cpuidle/cpuidle.c3
-rw-r--r--drivers/cpuidle/sysfs.c14
-rw-r--r--drivers/hid/hid-input-quirks.c17
-rw-r--r--drivers/hid/hid-input.c8
-rw-r--r--drivers/hid/usbhid/hid-quirks.c38
-rw-r--r--drivers/infiniband/core/cm.c26
-rw-r--r--drivers/infiniband/core/cma.c10
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c17
-rw-r--r--drivers/infiniband/hw/mlx4/mr.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c1
-rw-r--r--drivers/macintosh/mediabay.c2
-rw-r--r--drivers/md/bitmap.c8
-rw-r--r--drivers/md/dm-table.c4
-rw-r--r--drivers/md/md.c3
-rw-r--r--drivers/misc/thinkpad_acpi.c4
-rw-r--r--drivers/mtd/mtdsuper.c14
-rw-r--r--drivers/net/8139too.c2
-rw-r--r--drivers/net/Kconfig18
-rw-r--r--drivers/net/Makefile3
-rw-r--r--drivers/net/cxgb3/l2t.c2
-rw-r--r--drivers/net/cxgb3/sge.c35
-rw-r--r--drivers/net/dm9000.c654
-rw-r--r--drivers/net/e1000/e1000_main.c18
-rw-r--r--drivers/net/forcedeth.c132
-rw-r--r--drivers/net/mlx4/mr.c21
-rw-r--r--drivers/net/netconsole.c4
-rw-r--r--drivers/net/ni52.c1142
-rw-r--r--drivers/net/ni52.h158
-rw-r--r--drivers/net/pcnet32.c48
-rw-r--r--drivers/net/phy/fixed.c4
-rw-r--r--drivers/net/ps3_gelic_net.c1215
-rw-r--r--drivers/net/ps3_gelic_net.h415
-rw-r--r--drivers/net/ps3_gelic_wireless.c2753
-rw-r--r--drivers/net/ps3_gelic_wireless.h329
-rw-r--r--drivers/net/r6040.c233
-rw-r--r--drivers/net/sis190.c3
-rw-r--r--drivers/oprofile/buffer_sync.c21
-rw-r--r--drivers/pnp/pnpacpi/core.c2
-rw-r--r--drivers/pnp/pnpbios/core.c2
-rw-r--r--drivers/ps3/ps3-lpm.c22
-rw-r--r--drivers/ps3/ps3-sys-manager.c44
-rw-r--r--drivers/s390/net/claw.h19
-rw-r--r--drivers/s390/net/lcs.c2
-rw-r--r--drivers/s390/net/lcs.h16
-rw-r--r--drivers/s390/net/netiucv.c29
-rw-r--r--drivers/serial/sh-sci.c2
-rw-r--r--drivers/serial/sh-sci.h9
-rw-r--r--drivers/sh/maple/maple.c981
-rw-r--r--drivers/usb/gadget/file_storage.c8
-rw-r--r--fs/afs/mntpt.c23
-rw-r--r--fs/autofs4/root.c5
-rw-r--r--fs/binfmt_flat.c8
-rw-r--r--fs/block_dev.c6
-rw-r--r--fs/cifs/cifs_dfs_ref.c25
-rw-r--r--fs/coda/pioctl.c6
-rw-r--r--fs/compat.c11
-rw-r--r--fs/compat_ioctl.c2
-rw-r--r--fs/configfs/symlink.c8
-rw-r--r--fs/dcache.c103
-rw-r--r--fs/dcookies.c34
-rw-r--r--fs/dquot.c9
-rw-r--r--fs/ecryptfs/dentry.c12
-rw-r--r--fs/ecryptfs/inode.c24
-rw-r--r--fs/ecryptfs/main.c6
-rw-r--r--fs/exec.c8
-rw-r--r--fs/ext3/super.c8
-rw-r--r--fs/ext4/super.c8
-rw-r--r--fs/gfs2/ops_fstype.c7
-rw-r--r--fs/inotify_user.c12
-rw-r--r--fs/namei.c311
-rw-r--r--fs/namespace.c268
-rw-r--r--fs/nfs/callback.c18
-rw-r--r--fs/nfs/dir.c8
-rw-r--r--fs/nfs/namespace.c29
-rw-r--r--fs/nfs/nfs4proc.c8
-rw-r--r--fs/nfs/nfs4state.c4
-rw-r--r--fs/nfs/super.c4
-rw-r--r--fs/nfsctl.c4
-rw-r--r--fs/nfsd/export.c122
-rw-r--r--fs/nfsd/nfs3proc.c2
-rw-r--r--fs/nfsd/nfs3xdr.c4
-rw-r--r--fs/nfsd/nfs4recover.c34
-rw-r--r--fs/nfsd/nfs4state.c4
-rw-r--r--fs/nfsd/nfs4xdr.c12
-rw-r--r--fs/nfsd/nfsfh.c26
-rw-r--r--fs/nfsd/nfsproc.c6
-rw-r--r--fs/nfsd/nfsxdr.c2
-rw-r--r--fs/nfsd/vfs.c13
-rw-r--r--fs/open.c61
-rw-r--r--fs/proc/base.c61
-rw-r--r--fs/proc/internal.h2
-rw-r--r--fs/proc/nommu.c2
-rw-r--r--fs/proc/proc_sysctl.c2
-rw-r--r--fs/proc/task_mmu.c8
-rw-r--r--fs/proc/task_nommu.c6
-rw-r--r--fs/reiserfs/super.c14
-rw-r--r--fs/seq_file.c6
-rw-r--r--fs/stat.c19
-rw-r--r--fs/utimes.c4
-rw-r--r--fs/xattr.c32
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c8
-rw-r--r--include/acpi/processor.h9
-rw-r--r--include/asm-m68knommu/cacheflush.h14
-rw-r--r--include/asm-m68knommu/system.h2
-rw-r--r--include/asm-powerpc/systbl.h4
-rw-r--r--include/asm-powerpc/unistd.h6
-rw-r--r--include/asm-ppc/page.h2
-rw-r--r--include/asm-sh/bugs.h2
-rw-r--r--include/asm-sh/cpu-sh4/freq.h4
-rw-r--r--include/asm-sh/cpu-sh5/cacheflush.h6
-rw-r--r--include/asm-sh/cpu-sh5/mmu_context.h6
-rw-r--r--include/asm-sh/hp6xx.h28
-rw-r--r--include/asm-sh/io.h22
-rw-r--r--include/asm-sh/io_trapped.h58
-rw-r--r--include/asm-sh/ioctls.h4
-rw-r--r--include/asm-sh/irq.h4
-rw-r--r--include/asm-sh/mmu_context_64.h3
-rw-r--r--include/asm-sh/page.h7
-rw-r--r--include/asm-sh/pgtable_64.h13
-rw-r--r--include/asm-sh/processor.h2
-rw-r--r--include/asm-sh/r7780rp.h3
-rw-r--r--include/asm-sh/rts7751r2d.h3
-rw-r--r--include/asm-sh/system.h5
-rw-r--r--include/asm-sh/system_32.h3
-rw-r--r--include/asm-sh/termbits.h5
-rw-r--r--include/asm-sh/termios.h6
-rw-r--r--include/asm-sh/tlb.h1
-rw-r--r--include/asm-sh/uaccess.h29
-rw-r--r--include/asm-sh/uaccess_32.h24
-rw-r--r--include/asm-sh/uaccess_64.h19
-rw-r--r--include/asm-sh/unistd_32.h6
-rw-r--r--include/asm-sh/unistd_64.h6
-rw-r--r--include/asm-x86/cacheflush.h7
-rw-r--r--include/asm-x86/kdebug.h1
-rw-r--r--include/linux/acpi.h1
-rw-r--r--include/linux/audit.h5
-rw-r--r--include/linux/configfs.h1
-rw-r--r--include/linux/cpuidle.h2
-rw-r--r--include/linux/dcache.h5
-rw-r--r--include/linux/dcookies.h15
-rw-r--r--include/linux/dm9000.h2
-rw-r--r--include/linux/fs.h6
-rw-r--r--include/linux/fs_struct.h10
-rw-r--r--include/linux/hid.h2
-rw-r--r--include/linux/ktime.h2
-rw-r--r--include/linux/maple.h100
-rw-r--r--include/linux/module.h3
-rw-r--r--include/linux/namei.h11
-rw-r--r--include/linux/netdevice.h8
-rw-r--r--include/linux/nfsd/export.h8
-rw-r--r--include/linux/path.h15
-rw-r--r--include/linux/proc_fs.h2
-rw-r--r--include/linux/seq_file.h5
-rw-r--r--include/linux/slub_def.h15
-rw-r--r--include/net/ax25.h2
-rw-r--r--include/net/ndisc.h1
-rw-r--r--include/net/xfrm.h5
-rw-r--r--init/do_mounts.c6
-rw-r--r--kernel/audit.c12
-rw-r--r--kernel/audit_tree.c28
-rw-r--r--kernel/auditfilter.c15
-rw-r--r--kernel/auditsc.c28
-rw-r--r--kernel/exit.c12
-rw-r--r--kernel/fork.c18
-rw-r--r--kernel/futex.c2
-rw-r--r--kernel/futex_compat.c2
-rw-r--r--kernel/hrtimer.c48
-rw-r--r--kernel/kmod.c5
-rw-r--r--kernel/posix-timers.c8
-rw-r--r--mm/memory.c9
-rw-r--r--mm/mempolicy.c2
-rw-r--r--mm/slab.c3
-rw-r--r--mm/slub.c94
-rw-r--r--mm/swapfile.c2
-rw-r--r--net/ax25/af_ax25.c12
-rw-r--r--net/ax25/ax25_dev.c2
-rw-r--r--net/ax25/ax25_ds_timer.c12
-rw-r--r--net/ax25/ax25_route.c28
-rw-r--r--net/ax25/ax25_timer.c60
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/neighbour.c12
-rw-r--r--net/core/rtnetlink.c36
-rw-r--r--net/core/skbuff.c3
-rw-r--r--net/ipv4/ah4.c2
-rw-r--r--net/ipv4/arp.c3
-rw-r--r--net/ipv4/esp4.c5
-rw-r--r--net/ipv4/fib_trie.c99
-rw-r--r--net/ipv4/inet_hashtables.c3
-rw-r--r--net/ipv4/ip_sockglue.c5
-rw-r--r--net/ipv6/ah6.c2
-rw-r--r--net/ipv6/esp6.c5
-rw-r--r--net/ipv6/ip6_output.c6
-rw-r--r--net/ipv6/xfrm6_output.c2
-rw-r--r--net/key/af_key.c1
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c2
-rw-r--r--net/netfilter/xt_SECMARK.c2
-rw-r--r--net/netlabel/netlabel_domainhash.c6
-rw-r--r--net/netlabel/netlabel_unlabeled.c30
-rw-r--r--net/netlabel/netlabel_user.c3
-rw-r--r--net/netlink/genetlink.c6
-rw-r--r--net/socket.c3
-rw-r--r--net/sunrpc/rpc_pipe.c7
-rw-r--r--net/unix/af_unix.c26
-rw-r--r--net/xfrm/Kconfig2
-rw-r--r--net/xfrm/xfrm_input.c4
-rw-r--r--net/xfrm/xfrm_output.c2
-rw-r--r--net/xfrm/xfrm_user.c1
-rwxr-xr-xscripts/kernel-doc1
-rw-r--r--security/selinux/avc.c15
-rw-r--r--security/selinux/hooks.c32
-rw-r--r--security/selinux/include/avc.h6
-rw-r--r--security/smack/smack_lsm.c2
-rw-r--r--sound/core/seq/seq_clientmgr.c4
-rw-r--r--sound/core/seq/seq_device.c3
-rw-r--r--sound/core/sound.c4
-rw-r--r--sound/core/timer.c2
-rw-r--r--sound/ppc/daca.c5
-rw-r--r--sound/ppc/tumbler.c5
336 files changed, 11003 insertions, 5403 deletions
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX
index 8d556707bb68..30b327a116ea 100644
--- a/Documentation/00-INDEX
+++ b/Documentation/00-INDEX
@@ -109,6 +109,8 @@ cpu-hotplug.txt
109 - document describing CPU hotplug support in the Linux kernel. 109 - document describing CPU hotplug support in the Linux kernel.
110cpu-load.txt 110cpu-load.txt
111 - document describing how CPU load statistics are collected. 111 - document describing how CPU load statistics are collected.
112cpuidle/
113 - info on CPU_IDLE, CPU idle state management subsystem.
112cpusets.txt 114cpusets.txt
113 - documents the cpusets feature; assign CPUs and Mem to a set of tasks. 115 - documents the cpusets feature; assign CPUs and Mem to a set of tasks.
114cputopology.txt 116cputopology.txt
diff --git a/Documentation/cpuidle/core.txt b/Documentation/cpuidle/core.txt
new file mode 100644
index 000000000000..63ecc5dc9d8a
--- /dev/null
+++ b/Documentation/cpuidle/core.txt
@@ -0,0 +1,23 @@
1
2 Supporting multiple CPU idle levels in kernel
3
4 cpuidle
5
6General Information:
7
8Various CPUs today support multiple idle levels that are differentiated
9by varying exit latencies and power consumption during idle.
10cpuidle is a generic in-kernel infrastructure that separates
11idle policy (governor) from idle mechanism (driver) and provides a
12standardized infrastructure to support independent development of
13governors and drivers.
14
15cpuidle resides under drivers/cpuidle.
16
17Boot options:
18"cpuidle_sysfs_switch"
19enables current_governor interface in /sys/devices/system/cpu/cpuidle/,
20which can be used to switch governors at run time. This boot option
21is meant for developer testing only. In normal usage, kernel picks the
22best governor based on governor ratings.
23SEE ALSO: sysfs.txt in this directory.
diff --git a/Documentation/cpuidle/driver.txt b/Documentation/cpuidle/driver.txt
new file mode 100644
index 000000000000..7a9e09ece931
--- /dev/null
+++ b/Documentation/cpuidle/driver.txt
@@ -0,0 +1,31 @@
1
2
3 Supporting multiple CPU idle levels in kernel
4
5 cpuidle drivers
6
7
8
9
10cpuidle driver hooks into the cpuidle infrastructure and handles the
11architecture/platform dependent part of CPU idle states. Driver
12provides the platform idle state detection capability and also
13has mechanisms in place to support actual entry-exit into CPU idle states.
14
15cpuidle driver initializes the cpuidle_device structure for each CPU device
16and registers with cpuidle using cpuidle_register_device.
17
18It can also support the dynamic changes (like battery <-> AC), by using
19cpuidle_pause_and_lock, cpuidle_disable_device and cpuidle_enable_device,
20cpuidle_resume_and_unlock.
21
22Interfaces:
23extern int cpuidle_register_driver(struct cpuidle_driver *drv);
24extern void cpuidle_unregister_driver(struct cpuidle_driver *drv);
25extern int cpuidle_register_device(struct cpuidle_device *dev);
26extern void cpuidle_unregister_device(struct cpuidle_device *dev);
27
28extern void cpuidle_pause_and_lock(void);
29extern void cpuidle_resume_and_unlock(void);
30extern int cpuidle_enable_device(struct cpuidle_device *dev);
31extern void cpuidle_disable_device(struct cpuidle_device *dev);
diff --git a/Documentation/cpuidle/governor.txt b/Documentation/cpuidle/governor.txt
new file mode 100644
index 000000000000..12c6bd50c9f6
--- /dev/null
+++ b/Documentation/cpuidle/governor.txt
@@ -0,0 +1,29 @@
1
2
3
4 Supporting multiple CPU idle levels in kernel
5
6 cpuidle governors
7
8
9
10
11cpuidle governor is policy routine that decides what idle state to enter at
12any given time. cpuidle core uses different callbacks to the governor.
13
14* enable() to enable governor for a particular device
15* disable() to disable governor for a particular device
16* select() to select an idle state to enter
17* reflect() called after returning from the idle state, which can be used
18 by the governor for some record keeping.
19
20More than one governor can be registered at the same time and
21users can switch between drivers using /sysfs interface (when enabled).
22More than one governor part is supported for developers to easily experiment
23with different governors. By default, most optimal governor based on your
24kernel configuration and platform will be selected by cpuidle.
25
26Interfaces:
27extern int cpuidle_register_governor(struct cpuidle_governor *gov);
28extern void cpuidle_unregister_governor(struct cpuidle_governor *gov);
29struct cpuidle_governor
diff --git a/Documentation/cpuidle/sysfs.txt b/Documentation/cpuidle/sysfs.txt
new file mode 100644
index 000000000000..50d7b1642759
--- /dev/null
+++ b/Documentation/cpuidle/sysfs.txt
@@ -0,0 +1,79 @@
1
2
3 Supporting multiple CPU idle levels in kernel
4
5 cpuidle sysfs
6
7System global cpuidle related information and tunables are under
8/sys/devices/system/cpu/cpuidle
9
10The current interfaces in this directory has self-explanatory names:
11* current_driver
12* current_governor_ro
13
14With cpuidle_sysfs_switch boot option (meant for developer testing)
15following objects are visible instead.
16* current_driver
17* available_governors
18* current_governor
19In this case users can switch the governor at run time by writing
20to current_governor.
21
22
23Per logical CPU specific cpuidle information are under
24/sys/devices/system/cpu/cpuX/cpuidle
25for each online cpu X
26
27--------------------------------------------------------------------------------
28# ls -lR /sys/devices/system/cpu/cpu0/cpuidle/
29/sys/devices/system/cpu/cpu0/cpuidle/:
30total 0
31drwxr-xr-x 2 root root 0 Feb 8 10:42 state0
32drwxr-xr-x 2 root root 0 Feb 8 10:42 state1
33drwxr-xr-x 2 root root 0 Feb 8 10:42 state2
34drwxr-xr-x 2 root root 0 Feb 8 10:42 state3
35
36/sys/devices/system/cpu/cpu0/cpuidle/state0:
37total 0
38-r--r--r-- 1 root root 4096 Feb 8 10:42 desc
39-r--r--r-- 1 root root 4096 Feb 8 10:42 latency
40-r--r--r-- 1 root root 4096 Feb 8 10:42 name
41-r--r--r-- 1 root root 4096 Feb 8 10:42 power
42-r--r--r-- 1 root root 4096 Feb 8 10:42 time
43-r--r--r-- 1 root root 4096 Feb 8 10:42 usage
44
45/sys/devices/system/cpu/cpu0/cpuidle/state1:
46total 0
47-r--r--r-- 1 root root 4096 Feb 8 10:42 desc
48-r--r--r-- 1 root root 4096 Feb 8 10:42 latency
49-r--r--r-- 1 root root 4096 Feb 8 10:42 name
50-r--r--r-- 1 root root 4096 Feb 8 10:42 power
51-r--r--r-- 1 root root 4096 Feb 8 10:42 time
52-r--r--r-- 1 root root 4096 Feb 8 10:42 usage
53
54/sys/devices/system/cpu/cpu0/cpuidle/state2:
55total 0
56-r--r--r-- 1 root root 4096 Feb 8 10:42 desc
57-r--r--r-- 1 root root 4096 Feb 8 10:42 latency
58-r--r--r-- 1 root root 4096 Feb 8 10:42 name
59-r--r--r-- 1 root root 4096 Feb 8 10:42 power
60-r--r--r-- 1 root root 4096 Feb 8 10:42 time
61-r--r--r-- 1 root root 4096 Feb 8 10:42 usage
62
63/sys/devices/system/cpu/cpu0/cpuidle/state3:
64total 0
65-r--r--r-- 1 root root 4096 Feb 8 10:42 desc
66-r--r--r-- 1 root root 4096 Feb 8 10:42 latency
67-r--r--r-- 1 root root 4096 Feb 8 10:42 name
68-r--r--r-- 1 root root 4096 Feb 8 10:42 power
69-r--r--r-- 1 root root 4096 Feb 8 10:42 time
70-r--r--r-- 1 root root 4096 Feb 8 10:42 usage
71--------------------------------------------------------------------------------
72
73
74* desc : Small description about the idle state (string)
75* latency : Latency to exit out of this idle state (in microseconds)
76* name : Name of the idle state (string)
77* power : Power consumed while in this idle state (in milliwatts)
78* time : Total time spent in this idle state (in microseconds)
79* usage : Number of times this state was entered (count)
diff --git a/MAINTAINERS b/MAINTAINERS
index 6680ec44779e..1d2edb491b34 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1255,8 +1255,8 @@ W: http://linux-net.osdl.org/index.php/DCCP
1255S: Maintained 1255S: Maintained
1256 1256
1257DECnet NETWORK LAYER 1257DECnet NETWORK LAYER
1258P: Patrick Caulfield 1258P: Christine Caulfield
1259M: patrick@tykepenguin.com 1259M: christine.caulfield@googlemail.com
1260W: http://linux-decnet.sourceforge.net 1260W: http://linux-decnet.sourceforge.net
1261L: linux-decnet-user@lists.sourceforge.net 1261L: linux-decnet-user@lists.sourceforge.net
1262S: Maintained 1262S: Maintained
@@ -1318,8 +1318,8 @@ L: linux-kernel@vger.kernel.org
1318S: Maintained 1318S: Maintained
1319 1319
1320DISTRIBUTED LOCK MANAGER 1320DISTRIBUTED LOCK MANAGER
1321P: Patrick Caulfield 1321P: Christine Caulfield
1322M: pcaulfie@redhat.com 1322M: ccaulfie@redhat.com
1323P: David Teigland 1323P: David Teigland
1324M: teigland@redhat.com 1324M: teigland@redhat.com
1325L: cluster-devel@redhat.com 1325L: cluster-devel@redhat.com
@@ -1616,6 +1616,7 @@ S: Maintained
1616FILESYSTEMS (VFS and infrastructure) 1616FILESYSTEMS (VFS and infrastructure)
1617P: Alexander Viro 1617P: Alexander Viro
1618M: viro@zeniv.linux.org.uk 1618M: viro@zeniv.linux.org.uk
1619L: linux-fsdevel@vger.kernel.org
1619S: Maintained 1620S: Maintained
1620 1621
1621FIREWIRE SUBSYSTEM (drivers/firewire, <linux/firewire*.h>) 1622FIREWIRE SUBSYSTEM (drivers/firewire, <linux/firewire*.h>)
diff --git a/Makefile b/Makefile
index c162370c7367..67cc45786177 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 25 3SUBLEVEL = 25
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc2
5NAME = Arr Matey! A Hairy Bilge Rat! 5NAME = Funky Weasel is Jiggy wit it
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
8# To see a list of typical targets execute "make help" 8# To see a list of typical targets execute "make help"
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 973c5c3705e3..8c71daf94a59 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -259,8 +259,8 @@ osf_statfs(char __user *path, struct osf_statfs __user *buffer, unsigned long bu
259 259
260 retval = user_path_walk(path, &nd); 260 retval = user_path_walk(path, &nd);
261 if (!retval) { 261 if (!retval) {
262 retval = do_osf_statfs(nd.dentry, buffer, bufsiz); 262 retval = do_osf_statfs(nd.path.dentry, buffer, bufsiz);
263 path_release(&nd); 263 path_put(&nd.path);
264 } 264 }
265 return retval; 265 return retval;
266} 266}
diff --git a/arch/blackfin/kernel/traps.c b/arch/blackfin/kernel/traps.c
index 58717cb19707..56a67ab698c7 100644
--- a/arch/blackfin/kernel/traps.c
+++ b/arch/blackfin/kernel/traps.c
@@ -126,15 +126,13 @@ static void decode_address(char *buf, unsigned long address)
126 struct vm_area_struct *vma = vml->vma; 126 struct vm_area_struct *vma = vml->vma;
127 127
128 if (address >= vma->vm_start && address < vma->vm_end) { 128 if (address >= vma->vm_start && address < vma->vm_end) {
129 char _tmpbuf[256];
129 char *name = p->comm; 130 char *name = p->comm;
130 struct file *file = vma->vm_file; 131 struct file *file = vma->vm_file;
131 if (file) { 132
132 char _tmpbuf[256]; 133 if (file)
133 name = d_path(file->f_dentry, 134 name = d_path(&file->f_path, _tmpbuf,
134 file->f_vfsmnt, 135 sizeof(_tmpbuf));
135 _tmpbuf,
136 sizeof(_tmpbuf));
137 }
138 136
139 /* FLAT does not have its text aligned to the start of 137 /* FLAT does not have its text aligned to the start of
140 * the map while FDPIC ELF does ... 138 * the map while FDPIC ELF does ...
diff --git a/arch/cris/arch-v10/lib/memset.c b/arch/cris/arch-v10/lib/memset.c
index 42c1101043a3..c94ea9b3ec29 100644
--- a/arch/cris/arch-v10/lib/memset.c
+++ b/arch/cris/arch-v10/lib/memset.c
@@ -1,252 +1,259 @@
1/*#************************************************************************#*/ 1/* A memset for CRIS.
2/*#-------------------------------------------------------------------------*/ 2 Copyright (C) 1999-2005 Axis Communications.
3/*# */ 3 All rights reserved.
4/*# FUNCTION NAME: memset() */ 4
5/*# */ 5 Redistribution and use in source and binary forms, with or without
6/*# PARAMETERS: void* dst; Destination address. */ 6 modification, are permitted provided that the following conditions
7/*# int c; Value of byte to write. */ 7 are met:
8/*# int len; Number of bytes to write. */ 8
9/*# */ 9 1. Redistributions of source code must retain the above copyright
10/*# RETURNS: dst. */ 10 notice, this list of conditions and the following disclaimer.
11/*# */ 11
12/*# DESCRIPTION: Sets the memory dst of length len bytes to c, as standard. */ 12 2. Neither the name of Axis Communications nor the names of its
13/*# Framework taken from memcpy. This routine is */ 13 contributors may be used to endorse or promote products derived
14/*# very sensitive to compiler changes in register allocation. */ 14 from this software without specific prior written permission.
15/*# Should really be rewritten to avoid this problem. */ 15
16/*# */ 16 THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS
17/*#-------------------------------------------------------------------------*/ 17 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18/*# */ 18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19/*# HISTORY */ 19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS
20/*# */ 20 COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21/*# DATE NAME CHANGES */ 21 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22/*# ---- ---- ------- */ 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23/*# 990713 HP Tired of watching this function (or */ 23 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24/*# really, the nonoptimized generic */ 24 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25/*# implementation) take up 90% of simulator */ 25 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26/*# output. Measurements needed. */ 26 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27/*# */ 27 POSSIBILITY OF SUCH DAMAGE. */
28/*#-------------------------------------------------------------------------*/ 28
29 29/* FIXME: This file should really only be used for reference, as the
30#include <linux/types.h> 30 result is somewhat depending on gcc generating what we expect rather
31 31 than what we describe. An assembly file should be used instead. */
32/* No, there's no macro saying 12*4, since it is "hard" to get it into 32
33 the asm in a good way. Thus better to expose the problem everywhere. 33/* Note the multiple occurrence of the expression "12*4", including the
34 */ 34 asm. It is hard to get it into the asm in a good way. Thus better to
35 35 expose the problem everywhere: no macro. */
36/* Assuming 1 cycle per dword written or read (ok, not really true), and 36
37 one per instruction, then 43+3*(n/48-1) <= 24+24*(n/48-1) 37/* Assuming one cycle per dword written or read (ok, not really true; the
38 so n >= 45.7; n >= 0.9; we win on the first full 48-byte block to set. */ 38 world is not ideal), and one cycle per instruction, then 43+3*(n/48-1)
39 39 <= 24+24*(n/48-1) so n >= 45.7; n >= 0.9; we win on the first full
40#define ZERO_BLOCK_SIZE (1*12*4) 40 48-byte block to set. */
41 41
42void *memset(void *pdst, 42#define MEMSET_BY_BLOCK_THRESHOLD (1 * 48)
43 int c, 43
44 size_t plen) 44/* No name ambiguities in this file. */
45__asm__ (".syntax no_register_prefix");
46
47void *memset(void *pdst, int c, unsigned int plen)
45{ 48{
46 /* Ok. Now we want the parameters put in special registers. 49 /* Now we want the parameters in special registers. Make sure the
47 Make sure the compiler is able to make something useful of this. */ 50 compiler does something usable with this. */
48 51
49 register char *return_dst __asm__ ("r10") = pdst; 52 register char *return_dst __asm__ ("r10") = pdst;
50 register int n __asm__ ("r12") = plen; 53 register int n __asm__ ("r12") = plen;
51 register int lc __asm__ ("r11") = c; 54 register int lc __asm__ ("r11") = c;
52 55
53 /* Most apps use memset sanely. Only those memsetting about 3..4 56 /* Most apps use memset sanely. Memsetting about 3..4 bytes or less get
54 bytes or less get penalized compared to the generic implementation 57 penalized here compared to the generic implementation. */
55 - and that's not really sane use. */
56 58
57 /* Ugh. This is fragile at best. Check with newer GCC releases, if 59 /* This is fragile performancewise at best. Check with newer GCC
58 they compile cascaded "x |= x << 8" sanely! */ 60 releases, if they compile cascaded "x |= x << 8" to sane code. */
59 __asm__("movu.b %0,$r13\n\t" 61 __asm__("movu.b %0,r13 \n\
60 "lslq 8,$r13\n\t" 62 lslq 8,r13 \n\
61 "move.b %0,$r13\n\t" 63 move.b %0,r13 \n\
62 "move.d $r13,%0\n\t" 64 move.d r13,%0 \n\
63 "lslq 16,$r13\n\t" 65 lslq 16,r13 \n\
64 "or.d $r13,%0" 66 or.d r13,%0"
65 : "=r" (lc) : "0" (lc) : "r13"); 67 : "=r" (lc) /* Inputs. */
68 : "0" (lc) /* Outputs. */
69 : "r13"); /* Trash. */
66 70
67 { 71 {
68 register char *dst __asm__ ("r13") = pdst; 72 register char *dst __asm__ ("r13") = pdst;
69 73
70 /* This is NONPORTABLE, but since this whole routine is */ 74 if (((unsigned long) pdst & 3) != 0
71 /* grossly nonportable that doesn't matter. */ 75 /* Oops! n = 0 must be a valid call, regardless of alignment. */
76 && n >= 3)
77 {
78 if ((unsigned long) dst & 1)
79 {
80 *dst = (char) lc;
81 n--;
82 dst++;
83 }
72 84
73 if (((unsigned long) pdst & 3) != 0 85 if ((unsigned long) dst & 2)
74 /* Oops! n=0 must be a legal call, regardless of alignment. */ 86 {
75 && n >= 3) 87 *(short *) dst = lc;
76 { 88 n -= 2;
77 if ((unsigned long)dst & 1) 89 dst += 2;
78 { 90 }
79 *dst = (char) lc; 91 }
80 n--;
81 dst++;
82 }
83
84 if ((unsigned long)dst & 2)
85 {
86 *(short *)dst = lc;
87 n -= 2;
88 dst += 2;
89 }
90 }
91 92
92 /* Now the fun part. For the threshold value of this, check the equation 93 /* Decide which setting method to use. */
93 above. */ 94 if (n >= MEMSET_BY_BLOCK_THRESHOLD)
94 /* Decide which copying method to use. */ 95 {
95 if (n >= ZERO_BLOCK_SIZE) 96 /* It is not optimal to tell the compiler about clobbering any
96 { 97 registers; that will move the saving/restoring of those registers
97 /* For large copies we use 'movem' */ 98 to the function prologue/epilogue, and make non-block sizes
98 99 suboptimal. */
99 /* It is not optimal to tell the compiler about clobbering any 100 __asm__ volatile
100 registers; that will move the saving/restoring of those registers 101 ("\
101 to the function prologue/epilogue, and make non-movem sizes 102 ;; GCC does promise correct register allocations, but let's \n\
102 suboptimal. 103 ;; make sure it keeps its promises. \n\
103 104 .ifnc %0-%1-%4,$r13-$r12-$r11 \n\
104 This method is not foolproof; it assumes that the "asm reg" 105 .error \"GCC reg alloc bug: %0-%1-%4 != $r13-$r12-$r11\" \n\
105 declarations at the beginning of the function really are used 106 .endif \n\
106 here (beware: they may be moved to temporary registers). 107 \n\
107 This way, we do not have to save/move the registers around into 108 ;; Save the registers we'll clobber in the movem process \n\
108 temporaries; we can safely use them straight away. 109 ;; on the stack. Don't mention them to gcc, it will only be \n\
109 110 ;; upset. \n\
110 If you want to check that the allocation was right; then 111 subq 11*4,sp \n\
111 check the equalities in the first comment. It should say 112 movem r10,[sp] \n\
112 "r13=r13, r12=r12, r11=r11" */
113 __asm__ volatile ("\n\
114 ;; Check that the following is true (same register names on \n\
115 ;; both sides of equal sign, as in r8=r8): \n\
116 ;; %0=r13, %1=r12, %4=r11 \n\
117 ;; \n\
118 ;; Save the registers we'll clobber in the movem process \n\
119 ;; on the stack. Don't mention them to gcc, it will only be \n\
120 ;; upset. \n\
121 subq 11*4,$sp \n\
122 movem $r10,[$sp] \n\
123 \n\ 113 \n\
124 move.d $r11,$r0 \n\ 114 move.d r11,r0 \n\
125 move.d $r11,$r1 \n\ 115 move.d r11,r1 \n\
126 move.d $r11,$r2 \n\ 116 move.d r11,r2 \n\
127 move.d $r11,$r3 \n\ 117 move.d r11,r3 \n\
128 move.d $r11,$r4 \n\ 118 move.d r11,r4 \n\
129 move.d $r11,$r5 \n\ 119 move.d r11,r5 \n\
130 move.d $r11,$r6 \n\ 120 move.d r11,r6 \n\
131 move.d $r11,$r7 \n\ 121 move.d r11,r7 \n\
132 move.d $r11,$r8 \n\ 122 move.d r11,r8 \n\
133 move.d $r11,$r9 \n\ 123 move.d r11,r9 \n\
134 move.d $r11,$r10 \n\ 124 move.d r11,r10 \n\
135 \n\ 125 \n\
136 ;; Now we've got this: \n\ 126 ;; Now we've got this: \n\
137 ;; r13 - dst \n\ 127 ;; r13 - dst \n\
138 ;; r12 - n \n\ 128 ;; r12 - n \n\
139 \n\ 129 \n\
140 ;; Update n for the first loop \n\ 130 ;; Update n for the first loop \n\
141 subq 12*4,$r12 \n\ 131 subq 12*4,r12 \n\
1420: \n\ 1320: \n\
143 subq 12*4,$r12 \n\ 133"
144 bge 0b \n\ 134#ifdef __arch_common_v10_v32
145 movem $r11,[$r13+] \n\ 135 /* Cater to branch offset difference between v32 and v10. We
136 assume the branch below has an 8-bit offset. */
137" setf\n"
138#endif
139" subq 12*4,r12 \n\
140 bge 0b \n\
141 movem r11,[r13+] \n\
146 \n\ 142 \n\
147 addq 12*4,$r12 ;; compensate for last loop underflowing n \n\ 143 ;; Compensate for last loop underflowing n. \n\
144 addq 12*4,r12 \n\
148 \n\ 145 \n\
149 ;; Restore registers from stack \n\ 146 ;; Restore registers from stack. \n\
150 movem [$sp+],$r10" 147 movem [sp+],r10"
151 148
152 /* Outputs */ : "=r" (dst), "=r" (n) 149 /* Outputs. */
153 /* Inputs */ : "0" (dst), "1" (n), "r" (lc)); 150 : "=r" (dst), "=r" (n)
154 151
155 } 152 /* Inputs. */
153 : "0" (dst), "1" (n), "r" (lc));
154 }
155
156 /* An ad-hoc unroll, used for 4*12-1..16 bytes. */
157 while (n >= 16)
158 {
159 *(long *) dst = lc; dst += 4;
160 *(long *) dst = lc; dst += 4;
161 *(long *) dst = lc; dst += 4;
162 *(long *) dst = lc; dst += 4;
163 n -= 16;
164 }
156 165
157 /* Either we directly starts copying, using dword copying
158 in a loop, or we copy as much as possible with 'movem'
159 and then the last block (<44 bytes) is copied here.
160 This will work since 'movem' will have updated src,dst,n. */
161
162 while ( n >= 16 )
163 {
164 *((long*)dst)++ = lc;
165 *((long*)dst)++ = lc;
166 *((long*)dst)++ = lc;
167 *((long*)dst)++ = lc;
168 n -= 16;
169 }
170
171 /* A switch() is definitely the fastest although it takes a LOT of code.
172 * Particularly if you inline code this.
173 */
174 switch (n) 166 switch (n)
175 { 167 {
176 case 0: 168 case 0:
177 break; 169 break;
170
178 case 1: 171 case 1:
179 *(char*)dst = (char) lc; 172 *dst = (char) lc;
180 break; 173 break;
174
181 case 2: 175 case 2:
182 *(short*)dst = (short) lc; 176 *(short *) dst = (short) lc;
183 break; 177 break;
178
184 case 3: 179 case 3:
185 *((short*)dst)++ = (short) lc; 180 *(short *) dst = (short) lc; dst += 2;
186 *(char*)dst = (char) lc; 181 *dst = (char) lc;
187 break; 182 break;
183
188 case 4: 184 case 4:
189 *((long*)dst)++ = lc; 185 *(long *) dst = lc;
190 break; 186 break;
187
191 case 5: 188 case 5:
192 *((long*)dst)++ = lc; 189 *(long *) dst = lc; dst += 4;
193 *(char*)dst = (char) lc; 190 *dst = (char) lc;
194 break; 191 break;
192
195 case 6: 193 case 6:
196 *((long*)dst)++ = lc; 194 *(long *) dst = lc; dst += 4;
197 *(short*)dst = (short) lc; 195 *(short *) dst = (short) lc;
198 break; 196 break;
197
199 case 7: 198 case 7:
200 *((long*)dst)++ = lc; 199 *(long *) dst = lc; dst += 4;
201 *((short*)dst)++ = (short) lc; 200 *(short *) dst = (short) lc; dst += 2;
202 *(char*)dst = (char) lc; 201 *dst = (char) lc;
203 break; 202 break;
203
204 case 8: 204 case 8:
205 *((long*)dst)++ = lc; 205 *(long *) dst = lc; dst += 4;
206 *((long*)dst)++ = lc; 206 *(long *) dst = lc;
207 break; 207 break;
208
208 case 9: 209 case 9:
209 *((long*)dst)++ = lc; 210 *(long *) dst = lc; dst += 4;
210 *((long*)dst)++ = lc; 211 *(long *) dst = lc; dst += 4;
211 *(char*)dst = (char) lc; 212 *dst = (char) lc;
212 break; 213 break;
214
213 case 10: 215 case 10:
214 *((long*)dst)++ = lc; 216 *(long *) dst = lc; dst += 4;
215 *((long*)dst)++ = lc; 217 *(long *) dst = lc; dst += 4;
216 *(short*)dst = (short) lc; 218 *(short *) dst = (short) lc;
217 break; 219 break;
220
218 case 11: 221 case 11:
219 *((long*)dst)++ = lc; 222 *(long *) dst = lc; dst += 4;
220 *((long*)dst)++ = lc; 223 *(long *) dst = lc; dst += 4;
221 *((short*)dst)++ = (short) lc; 224 *(short *) dst = (short) lc; dst += 2;
222 *(char*)dst = (char) lc; 225 *dst = (char) lc;
223 break; 226 break;
227
224 case 12: 228 case 12:
225 *((long*)dst)++ = lc; 229 *(long *) dst = lc; dst += 4;
226 *((long*)dst)++ = lc; 230 *(long *) dst = lc; dst += 4;
227 *((long*)dst)++ = lc; 231 *(long *) dst = lc;
228 break; 232 break;
233
229 case 13: 234 case 13:
230 *((long*)dst)++ = lc; 235 *(long *) dst = lc; dst += 4;
231 *((long*)dst)++ = lc; 236 *(long *) dst = lc; dst += 4;
232 *((long*)dst)++ = lc; 237 *(long *) dst = lc; dst += 4;
233 *(char*)dst = (char) lc; 238 *dst = (char) lc;
234 break; 239 break;
240
235 case 14: 241 case 14:
236 *((long*)dst)++ = lc; 242 *(long *) dst = lc; dst += 4;
237 *((long*)dst)++ = lc; 243 *(long *) dst = lc; dst += 4;
238 *((long*)dst)++ = lc; 244 *(long *) dst = lc; dst += 4;
239 *(short*)dst = (short) lc; 245 *(short *) dst = (short) lc;
240 break; 246 break;
247
241 case 15: 248 case 15:
242 *((long*)dst)++ = lc; 249 *(long *) dst = lc; dst += 4;
243 *((long*)dst)++ = lc; 250 *(long *) dst = lc; dst += 4;
244 *((long*)dst)++ = lc; 251 *(long *) dst = lc; dst += 4;
245 *((short*)dst)++ = (short) lc; 252 *(short *) dst = (short) lc; dst += 2;
246 *(char*)dst = (char) lc; 253 *dst = (char) lc;
247 break; 254 break;
248 } 255 }
249 } 256 }
250 257
251 return return_dst; /* destination pointer. */ 258 return return_dst;
252} /* memset() */ 259}
diff --git a/arch/cris/arch-v32/lib/memset.c b/arch/cris/arch-v32/lib/memset.c
index ffca1214674e..c94ea9b3ec29 100644
--- a/arch/cris/arch-v32/lib/memset.c
+++ b/arch/cris/arch-v32/lib/memset.c
@@ -1,253 +1,259 @@
1/*#************************************************************************#*/ 1/* A memset for CRIS.
2/*#-------------------------------------------------------------------------*/ 2 Copyright (C) 1999-2005 Axis Communications.
3/*# */ 3 All rights reserved.
4/*# FUNCTION NAME: memset() */ 4
5/*# */ 5 Redistribution and use in source and binary forms, with or without
6/*# PARAMETERS: void* dst; Destination address. */ 6 modification, are permitted provided that the following conditions
7/*# int c; Value of byte to write. */ 7 are met:
8/*# int len; Number of bytes to write. */ 8
9/*# */ 9 1. Redistributions of source code must retain the above copyright
10/*# RETURNS: dst. */ 10 notice, this list of conditions and the following disclaimer.
11/*# */ 11
12/*# DESCRIPTION: Sets the memory dst of length len bytes to c, as standard. */ 12 2. Neither the name of Axis Communications nor the names of its
13/*# Framework taken from memcpy. This routine is */ 13 contributors may be used to endorse or promote products derived
14/*# very sensitive to compiler changes in register allocation. */ 14 from this software without specific prior written permission.
15/*# Should really be rewritten to avoid this problem. */ 15
16/*# */ 16 THIS SOFTWARE IS PROVIDED BY AXIS COMMUNICATIONS AND ITS CONTRIBUTORS
17/*#-------------------------------------------------------------------------*/ 17 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18/*# */ 18 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19/*# HISTORY */ 19 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AXIS
20/*# */ 20 COMMUNICATIONS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21/*# DATE NAME CHANGES */ 21 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22/*# ---- ---- ------- */ 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23/*# 990713 HP Tired of watching this function (or */ 23 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24/*# really, the nonoptimized generic */ 24 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25/*# implementation) take up 90% of simulator */ 25 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26/*# output. Measurements needed. */ 26 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27/*# */ 27 POSSIBILITY OF SUCH DAMAGE. */
28/*#-------------------------------------------------------------------------*/ 28
29 29/* FIXME: This file should really only be used for reference, as the
30#include <linux/types.h> 30 result is somewhat depending on gcc generating what we expect rather
31 31 than what we describe. An assembly file should be used instead. */
32/* No, there's no macro saying 12*4, since it is "hard" to get it into 32
33 the asm in a good way. Thus better to expose the problem everywhere. 33/* Note the multiple occurrence of the expression "12*4", including the
34 */ 34 asm. It is hard to get it into the asm in a good way. Thus better to
35 35 expose the problem everywhere: no macro. */
36/* Assuming 1 cycle per dword written or read (ok, not really true), and 36
37 one per instruction, then 43+3*(n/48-1) <= 24+24*(n/48-1) 37/* Assuming one cycle per dword written or read (ok, not really true; the
38 so n >= 45.7; n >= 0.9; we win on the first full 48-byte block to set. */ 38 world is not ideal), and one cycle per instruction, then 43+3*(n/48-1)
39 39 <= 24+24*(n/48-1) so n >= 45.7; n >= 0.9; we win on the first full
40#define ZERO_BLOCK_SIZE (1*12*4) 40 48-byte block to set. */
41 41
42void *memset(void *pdst, 42#define MEMSET_BY_BLOCK_THRESHOLD (1 * 48)
43 int c, 43
44 size_t plen) 44/* No name ambiguities in this file. */
45__asm__ (".syntax no_register_prefix");
46
47void *memset(void *pdst, int c, unsigned int plen)
45{ 48{
46 /* Ok. Now we want the parameters put in special registers. 49 /* Now we want the parameters in special registers. Make sure the
47 Make sure the compiler is able to make something useful of this. */ 50 compiler does something usable with this. */
48 51
49 register char *return_dst __asm__ ("r10") = pdst; 52 register char *return_dst __asm__ ("r10") = pdst;
50 register int n __asm__ ("r12") = plen; 53 register int n __asm__ ("r12") = plen;
51 register int lc __asm__ ("r11") = c; 54 register int lc __asm__ ("r11") = c;
52 55
53 /* Most apps use memset sanely. Only those memsetting about 3..4 56 /* Most apps use memset sanely. Memsetting about 3..4 bytes or less get
54 bytes or less get penalized compared to the generic implementation 57 penalized here compared to the generic implementation. */
55 - and that's not really sane use. */
56 58
57 /* Ugh. This is fragile at best. Check with newer GCC releases, if 59 /* This is fragile performancewise at best. Check with newer GCC
58 they compile cascaded "x |= x << 8" sanely! */ 60 releases, if they compile cascaded "x |= x << 8" to sane code. */
59 __asm__("movu.b %0,$r13 \n\ 61 __asm__("movu.b %0,r13 \n\
60 lslq 8,$r13 \n\ 62 lslq 8,r13 \n\
61 move.b %0,$r13 \n\ 63 move.b %0,r13 \n\
62 move.d $r13,%0 \n\ 64 move.d r13,%0 \n\
63 lslq 16,$r13 \n\ 65 lslq 16,r13 \n\
64 or.d $r13,%0" 66 or.d r13,%0"
65 : "=r" (lc) : "0" (lc) : "r13"); 67 : "=r" (lc) /* Inputs. */
68 : "0" (lc) /* Outputs. */
69 : "r13"); /* Trash. */
66 70
67 { 71 {
68 register char *dst __asm__ ("r13") = pdst; 72 register char *dst __asm__ ("r13") = pdst;
69 73
70 /* This is NONPORTABLE, but since this whole routine is */ 74 if (((unsigned long) pdst & 3) != 0
71 /* grossly nonportable that doesn't matter. */ 75 /* Oops! n = 0 must be a valid call, regardless of alignment. */
76 && n >= 3)
77 {
78 if ((unsigned long) dst & 1)
79 {
80 *dst = (char) lc;
81 n--;
82 dst++;
83 }
72 84
73 if (((unsigned long) pdst & 3) != 0 85 if ((unsigned long) dst & 2)
74 /* Oops! n=0 must be a legal call, regardless of alignment. */ 86 {
75 && n >= 3) 87 *(short *) dst = lc;
76 { 88 n -= 2;
77 if ((unsigned long)dst & 1) 89 dst += 2;
78 { 90 }
79 *dst = (char) lc; 91 }
80 n--;
81 dst++;
82 }
83
84 if ((unsigned long)dst & 2)
85 {
86 *(short *)dst = lc;
87 n -= 2;
88 dst += 2;
89 }
90 }
91 92
92 /* Now the fun part. For the threshold value of this, check the equation 93 /* Decide which setting method to use. */
93 above. */ 94 if (n >= MEMSET_BY_BLOCK_THRESHOLD)
94 /* Decide which copying method to use. */ 95 {
95 if (n >= ZERO_BLOCK_SIZE) 96 /* It is not optimal to tell the compiler about clobbering any
96 { 97 registers; that will move the saving/restoring of those registers
97 /* For large copies we use 'movem' */ 98 to the function prologue/epilogue, and make non-block sizes
98 99 suboptimal. */
99 /* It is not optimal to tell the compiler about clobbering any 100 __asm__ volatile
100 registers; that will move the saving/restoring of those registers 101 ("\
101 to the function prologue/epilogue, and make non-movem sizes 102 ;; GCC does promise correct register allocations, but let's \n\
102 suboptimal. 103 ;; make sure it keeps its promises. \n\
103 104 .ifnc %0-%1-%4,$r13-$r12-$r11 \n\
104 This method is not foolproof; it assumes that the "asm reg" 105 .error \"GCC reg alloc bug: %0-%1-%4 != $r13-$r12-$r11\" \n\
105 declarations at the beginning of the function really are used 106 .endif \n\
106 here (beware: they may be moved to temporary registers).
107 This way, we do not have to save/move the registers around into
108 temporaries; we can safely use them straight away.
109
110 If you want to check that the allocation was right; then
111 check the equalities in the first comment. It should say
112 "r13=r13, r12=r12, r11=r11" */
113 __asm__ volatile (" \n\
114 ;; Check that the register asm declaration got right. \n\
115 ;; The GCC manual says it will work, but there *has* been bugs. \n\
116 .ifnc %0-%1-%4,$r13-$r12-$r11 \n\
117 .err \n\
118 .endif \n\
119 \n\ 107 \n\
120 ;; Save the registers we'll clobber in the movem process \n\ 108 ;; Save the registers we'll clobber in the movem process \n\
121 ;; on the stack. Don't mention them to gcc, it will only be \n\ 109 ;; on the stack. Don't mention them to gcc, it will only be \n\
122 ;; upset. \n\ 110 ;; upset. \n\
123 subq 11*4,$sp \n\ 111 subq 11*4,sp \n\
124 movem $r10,[$sp] \n\ 112 movem r10,[sp] \n\
125 \n\ 113 \n\
126 move.d $r11,$r0 \n\ 114 move.d r11,r0 \n\
127 move.d $r11,$r1 \n\ 115 move.d r11,r1 \n\
128 move.d $r11,$r2 \n\ 116 move.d r11,r2 \n\
129 move.d $r11,$r3 \n\ 117 move.d r11,r3 \n\
130 move.d $r11,$r4 \n\ 118 move.d r11,r4 \n\
131 move.d $r11,$r5 \n\ 119 move.d r11,r5 \n\
132 move.d $r11,$r6 \n\ 120 move.d r11,r6 \n\
133 move.d $r11,$r7 \n\ 121 move.d r11,r7 \n\
134 move.d $r11,$r8 \n\ 122 move.d r11,r8 \n\
135 move.d $r11,$r9 \n\ 123 move.d r11,r9 \n\
136 move.d $r11,$r10 \n\ 124 move.d r11,r10 \n\
137 \n\ 125 \n\
138 ;; Now we've got this: \n\ 126 ;; Now we've got this: \n\
139 ;; r13 - dst \n\ 127 ;; r13 - dst \n\
140 ;; r12 - n \n\ 128 ;; r12 - n \n\
141 \n\ 129 \n\
142 ;; Update n for the first loop \n\ 130 ;; Update n for the first loop \n\
143 subq 12*4,$r12 \n\ 131 subq 12*4,r12 \n\
1440: \n\ 1320: \n\
145 subq 12*4,$r12 \n\ 133"
146 bge 0b \n\ 134#ifdef __arch_common_v10_v32
147 movem $r11,[$r13+] \n\ 135 /* Cater to branch offset difference between v32 and v10. We
136 assume the branch below has an 8-bit offset. */
137" setf\n"
138#endif
139" subq 12*4,r12 \n\
140 bge 0b \n\
141 movem r11,[r13+] \n\
148 \n\ 142 \n\
149 addq 12*4,$r12 ;; compensate for last loop underflowing n \n\ 143 ;; Compensate for last loop underflowing n. \n\
144 addq 12*4,r12 \n\
150 \n\ 145 \n\
151 ;; Restore registers from stack \n\ 146 ;; Restore registers from stack. \n\
152 movem [$sp+],$r10" 147 movem [sp+],r10"
153 148
154 /* Outputs */ : "=r" (dst), "=r" (n) 149 /* Outputs. */
155 /* Inputs */ : "0" (dst), "1" (n), "r" (lc)); 150 : "=r" (dst), "=r" (n)
156 } 151
152 /* Inputs. */
153 : "0" (dst), "1" (n), "r" (lc));
154 }
155
156 /* An ad-hoc unroll, used for 4*12-1..16 bytes. */
157 while (n >= 16)
158 {
159 *(long *) dst = lc; dst += 4;
160 *(long *) dst = lc; dst += 4;
161 *(long *) dst = lc; dst += 4;
162 *(long *) dst = lc; dst += 4;
163 n -= 16;
164 }
157 165
158 /* Either we directly starts copying, using dword copying
159 in a loop, or we copy as much as possible with 'movem'
160 and then the last block (<44 bytes) is copied here.
161 This will work since 'movem' will have updated src,dst,n. */
162
163 while ( n >= 16 )
164 {
165 *((long*)dst)++ = lc;
166 *((long*)dst)++ = lc;
167 *((long*)dst)++ = lc;
168 *((long*)dst)++ = lc;
169 n -= 16;
170 }
171
172 /* A switch() is definitely the fastest although it takes a LOT of code.
173 * Particularly if you inline code this.
174 */
175 switch (n) 166 switch (n)
176 { 167 {
177 case 0: 168 case 0:
178 break; 169 break;
170
179 case 1: 171 case 1:
180 *(char*)dst = (char) lc; 172 *dst = (char) lc;
181 break; 173 break;
174
182 case 2: 175 case 2:
183 *(short*)dst = (short) lc; 176 *(short *) dst = (short) lc;
184 break; 177 break;
178
185 case 3: 179 case 3:
186 *((short*)dst)++ = (short) lc; 180 *(short *) dst = (short) lc; dst += 2;
187 *(char*)dst = (char) lc; 181 *dst = (char) lc;
188 break; 182 break;
183
189 case 4: 184 case 4:
190 *((long*)dst)++ = lc; 185 *(long *) dst = lc;
191 break; 186 break;
187
192 case 5: 188 case 5:
193 *((long*)dst)++ = lc; 189 *(long *) dst = lc; dst += 4;
194 *(char*)dst = (char) lc; 190 *dst = (char) lc;
195 break; 191 break;
192
196 case 6: 193 case 6:
197 *((long*)dst)++ = lc; 194 *(long *) dst = lc; dst += 4;
198 *(short*)dst = (short) lc; 195 *(short *) dst = (short) lc;
199 break; 196 break;
197
200 case 7: 198 case 7:
201 *((long*)dst)++ = lc; 199 *(long *) dst = lc; dst += 4;
202 *((short*)dst)++ = (short) lc; 200 *(short *) dst = (short) lc; dst += 2;
203 *(char*)dst = (char) lc; 201 *dst = (char) lc;
204 break; 202 break;
203
205 case 8: 204 case 8:
206 *((long*)dst)++ = lc; 205 *(long *) dst = lc; dst += 4;
207 *((long*)dst)++ = lc; 206 *(long *) dst = lc;
208 break; 207 break;
208
209 case 9: 209 case 9:
210 *((long*)dst)++ = lc; 210 *(long *) dst = lc; dst += 4;
211 *((long*)dst)++ = lc; 211 *(long *) dst = lc; dst += 4;
212 *(char*)dst = (char) lc; 212 *dst = (char) lc;
213 break; 213 break;
214
214 case 10: 215 case 10:
215 *((long*)dst)++ = lc; 216 *(long *) dst = lc; dst += 4;
216 *((long*)dst)++ = lc; 217 *(long *) dst = lc; dst += 4;
217 *(short*)dst = (short) lc; 218 *(short *) dst = (short) lc;
218 break; 219 break;
220
219 case 11: 221 case 11:
220 *((long*)dst)++ = lc; 222 *(long *) dst = lc; dst += 4;
221 *((long*)dst)++ = lc; 223 *(long *) dst = lc; dst += 4;
222 *((short*)dst)++ = (short) lc; 224 *(short *) dst = (short) lc; dst += 2;
223 *(char*)dst = (char) lc; 225 *dst = (char) lc;
224 break; 226 break;
227
225 case 12: 228 case 12:
226 *((long*)dst)++ = lc; 229 *(long *) dst = lc; dst += 4;
227 *((long*)dst)++ = lc; 230 *(long *) dst = lc; dst += 4;
228 *((long*)dst)++ = lc; 231 *(long *) dst = lc;
229 break; 232 break;
233
230 case 13: 234 case 13:
231 *((long*)dst)++ = lc; 235 *(long *) dst = lc; dst += 4;
232 *((long*)dst)++ = lc; 236 *(long *) dst = lc; dst += 4;
233 *((long*)dst)++ = lc; 237 *(long *) dst = lc; dst += 4;
234 *(char*)dst = (char) lc; 238 *dst = (char) lc;
235 break; 239 break;
240
236 case 14: 241 case 14:
237 *((long*)dst)++ = lc; 242 *(long *) dst = lc; dst += 4;
238 *((long*)dst)++ = lc; 243 *(long *) dst = lc; dst += 4;
239 *((long*)dst)++ = lc; 244 *(long *) dst = lc; dst += 4;
240 *(short*)dst = (short) lc; 245 *(short *) dst = (short) lc;
241 break; 246 break;
247
242 case 15: 248 case 15:
243 *((long*)dst)++ = lc; 249 *(long *) dst = lc; dst += 4;
244 *((long*)dst)++ = lc; 250 *(long *) dst = lc; dst += 4;
245 *((long*)dst)++ = lc; 251 *(long *) dst = lc; dst += 4;
246 *((short*)dst)++ = (short) lc; 252 *(short *) dst = (short) lc; dst += 2;
247 *(char*)dst = (char) lc; 253 *dst = (char) lc;
248 break; 254 break;
249 } 255 }
250 } 256 }
251 257
252 return return_dst; /* destination pointer. */ 258 return return_dst;
253} /* memset() */ 259}
diff --git a/arch/m68knommu/platform/5206/Makefile b/arch/m68knommu/platform/5206/Makefile
index c7bb0cef31a0..a439d9ab3f27 100644
--- a/arch/m68knommu/platform/5206/Makefile
+++ b/arch/m68knommu/platform/5206/Makefile
@@ -12,9 +12,7 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-y := config.o 17obj-y := config.o
20 18
diff --git a/arch/m68knommu/platform/5206e/Makefile b/arch/m68knommu/platform/5206e/Makefile
index c7bb0cef31a0..a439d9ab3f27 100644
--- a/arch/m68knommu/platform/5206e/Makefile
+++ b/arch/m68knommu/platform/5206e/Makefile
@@ -12,9 +12,7 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-y := config.o 17obj-y := config.o
20 18
diff --git a/arch/m68knommu/platform/520x/Makefile b/arch/m68knommu/platform/520x/Makefile
index 31b4eb51739d..a50e76acc8fd 100644
--- a/arch/m68knommu/platform/520x/Makefile
+++ b/arch/m68knommu/platform/520x/Makefile
@@ -12,8 +12,6 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-y := config.o 17obj-y := config.o
diff --git a/arch/m68knommu/platform/523x/Makefile b/arch/m68knommu/platform/523x/Makefile
index ac9fbece8a4f..5694d593f029 100644
--- a/arch/m68knommu/platform/523x/Makefile
+++ b/arch/m68knommu/platform/523x/Makefile
@@ -12,8 +12,6 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-y := config.o 17obj-y := config.o
diff --git a/arch/m68knommu/platform/5249/Makefile b/arch/m68knommu/platform/5249/Makefile
index c7bb0cef31a0..a439d9ab3f27 100644
--- a/arch/m68knommu/platform/5249/Makefile
+++ b/arch/m68knommu/platform/5249/Makefile
@@ -12,9 +12,7 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-y := config.o 17obj-y := config.o
20 18
diff --git a/arch/m68knommu/platform/5272/Makefile b/arch/m68knommu/platform/5272/Makefile
index 7475c38c3b4e..26135d92b34d 100644
--- a/arch/m68knommu/platform/5272/Makefile
+++ b/arch/m68knommu/platform/5272/Makefile
@@ -12,9 +12,7 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-y := config.o 17obj-y := config.o
20 18
diff --git a/arch/m68knommu/platform/527x/Makefile b/arch/m68knommu/platform/527x/Makefile
index 7475c38c3b4e..26135d92b34d 100644
--- a/arch/m68knommu/platform/527x/Makefile
+++ b/arch/m68knommu/platform/527x/Makefile
@@ -12,9 +12,7 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-y := config.o 17obj-y := config.o
20 18
diff --git a/arch/m68knommu/platform/528x/Makefile b/arch/m68knommu/platform/528x/Makefile
index 7475c38c3b4e..26135d92b34d 100644
--- a/arch/m68knommu/platform/528x/Makefile
+++ b/arch/m68knommu/platform/528x/Makefile
@@ -12,9 +12,7 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-y := config.o 17obj-y := config.o
20 18
diff --git a/arch/m68knommu/platform/5307/Makefile b/arch/m68knommu/platform/5307/Makefile
index 580fd6658d7c..cfd586860fd8 100644
--- a/arch/m68knommu/platform/5307/Makefile
+++ b/arch/m68knommu/platform/5307/Makefile
@@ -12,9 +12,7 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-y += config.o 17obj-y += config.o
20 18
diff --git a/arch/m68knommu/platform/532x/Makefile b/arch/m68knommu/platform/532x/Makefile
index 475b92866a9b..e431912f5628 100644
--- a/arch/m68knommu/platform/532x/Makefile
+++ b/arch/m68knommu/platform/532x/Makefile
@@ -12,9 +12,7 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19#obj-y := config.o usb-mcf532x.o spi-mcf532x.o 17#obj-y := config.o usb-mcf532x.o spi-mcf532x.o
20obj-y := config.o 18obj-y := config.o
diff --git a/arch/m68knommu/platform/5407/Makefile b/arch/m68knommu/platform/5407/Makefile
index 68633b27df51..e6035e7a2d3f 100644
--- a/arch/m68knommu/platform/5407/Makefile
+++ b/arch/m68knommu/platform/5407/Makefile
@@ -12,9 +12,7 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16EXTRA_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-y := config.o 17obj-y := config.o
20 18
diff --git a/arch/m68knommu/platform/coldfire/Makefile b/arch/m68knommu/platform/coldfire/Makefile
index e5fff297ae01..40cf20be1b90 100644
--- a/arch/m68knommu/platform/coldfire/Makefile
+++ b/arch/m68knommu/platform/coldfire/Makefile
@@ -12,9 +12,7 @@
12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT 12# EXTRA_AFLAGS += -DTRAP_DBG_INTERRUPT
13# 13#
14 14
15ifdef CONFIG_FULLDEBUG 15asflags-$(CONFIG_FULLDEBUG) := -DDEBUGGER_COMPATIBLE_CACHE=1
16AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
17endif
18 16
19obj-$(CONFIG_COLDFIRE) += dma.o entry.o vectors.o 17obj-$(CONFIG_COLDFIRE) += dma.o entry.o vectors.o
20obj-$(CONFIG_M5206) += timers.o 18obj-$(CONFIG_M5206) += timers.o
diff --git a/arch/m68knommu/platform/coldfire/entry.S b/arch/m68knommu/platform/coldfire/entry.S
index b333731b875a..111b66dc737b 100644
--- a/arch/m68knommu/platform/coldfire/entry.S
+++ b/arch/m68knommu/platform/coldfire/entry.S
@@ -197,14 +197,13 @@ ENTRY(fasthandler)
197 RESTORE_LOCAL 197 RESTORE_LOCAL
198 198
199ENTRY(ret_from_interrupt) 199ENTRY(ret_from_interrupt)
200 jeq 2f
2011:
202 RESTORE_ALL
2032:
204 moveb %sp@(PT_SR),%d0 200 moveb %sp@(PT_SR),%d0
205 andl #0x7,%d0 201 andl #0x7,%d0
206 jhi 1b 202 jeq 1f
207 203
204 RESTORE_ALL
205
2061:
208 /* check if we need to do software interrupts */ 207 /* check if we need to do software interrupts */
209 movel irq_stat+CPUSTAT_SOFTIRQ_PENDING,%d0 208 movel irq_stat+CPUSTAT_SOFTIRQ_PENDING,%d0
210 jeq ret_from_exception 209 jeq ret_from_exception
diff --git a/arch/m68knommu/platform/coldfire/timers.c b/arch/m68knommu/platform/coldfire/timers.c
index a60213e877ef..ba5a9f32ebd4 100644
--- a/arch/m68knommu/platform/coldfire/timers.c
+++ b/arch/m68knommu/platform/coldfire/timers.c
@@ -148,25 +148,32 @@ irqreturn_t coldfire_profile_tick(int irq, void *dummy)
148 /* Reset ColdFire timer2 */ 148 /* Reset ColdFire timer2 */
149 __raw_writeb(MCFTIMER_TER_CAP | MCFTIMER_TER_REF, PA(MCFTIMER_TER)); 149 __raw_writeb(MCFTIMER_TER_CAP | MCFTIMER_TER_REF, PA(MCFTIMER_TER));
150 if (current->pid) 150 if (current->pid)
151 profile_tick(CPU_PROFILING, regs); 151 profile_tick(CPU_PROFILING);
152 return IRQ_HANDLED; 152 return IRQ_HANDLED;
153} 153}
154 154
155/***************************************************************************/ 155/***************************************************************************/
156 156
157static struct irqaction coldfire_profile_irq = {
158 .name = "profile timer",
159 .flags = IRQF_DISABLED | IRQF_TIMER,
160 .handler = coldfire_profile_tick,
161};
162
157void coldfire_profile_init(void) 163void coldfire_profile_init(void)
158{ 164{
159 printk(KERN_INFO "PROFILE: lodging TIMER2 @ %dHz as profile timer\n", PROFILEHZ); 165 printk(KERN_INFO "PROFILE: lodging TIMER2 @ %dHz as profile timer\n",
166 PROFILEHZ);
167
168 setup_irq(mcf_profilevector, &coldfire_profile_irq);
160 169
161 /* Set up TIMER 2 as high speed profile clock */ 170 /* Set up TIMER 2 as high speed profile clock */
162 __raw_writew(MCFTIMER_TMR_DISABLE, PA(MCFTIMER_TMR)); 171 __raw_writew(MCFTIMER_TMR_DISABLE, PA(MCFTIMER_TMR));
163 172
164 __raw_writetrr(((MCF_CLK / 16) / PROFILEHZ), PA(MCFTIMER_TRR)); 173 __raw_writetrr(((MCF_BUSCLK / 16) / PROFILEHZ), PA(MCFTIMER_TRR));
165 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 | 174 __raw_writew(MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 |
166 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, PA(MCFTIMER_TMR)); 175 MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE, PA(MCFTIMER_TMR));
167 176
168 request_irq(mcf_profilevector, coldfire_profile_tick,
169 (IRQF_DISABLED | IRQ_FLG_FAST), "profile timer", NULL);
170 mcf_settimericr(2, 7); 177 mcf_settimericr(2, 7);
171} 178}
172 179
diff --git a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c
index d70c4e0e85fb..672fba84b2cc 100644
--- a/arch/mips/kernel/sysirix.c
+++ b/arch/mips/kernel/sysirix.c
@@ -694,7 +694,7 @@ asmlinkage int irix_statfs(const char __user *path,
694 if (error) 694 if (error)
695 goto out; 695 goto out;
696 696
697 error = vfs_statfs(nd.dentry, &kbuf); 697 error = vfs_statfs(nd.path.dentry, &kbuf);
698 if (error) 698 if (error)
699 goto dput_and_out; 699 goto dput_and_out;
700 700
@@ -711,7 +711,7 @@ asmlinkage int irix_statfs(const char __user *path,
711 } 711 }
712 712
713dput_and_out: 713dput_and_out:
714 path_release(&nd); 714 path_put(&nd.path);
715out: 715out:
716 return error; 716 return error;
717} 717}
@@ -1360,7 +1360,7 @@ asmlinkage int irix_statvfs(char __user *fname, struct irix_statvfs __user *buf)
1360 error = user_path_walk(fname, &nd); 1360 error = user_path_walk(fname, &nd);
1361 if (error) 1361 if (error)
1362 goto out; 1362 goto out;
1363 error = vfs_statfs(nd.dentry, &kbuf); 1363 error = vfs_statfs(nd.path.dentry, &kbuf);
1364 if (error) 1364 if (error)
1365 goto dput_and_out; 1365 goto dput_and_out;
1366 1366
@@ -1385,7 +1385,7 @@ asmlinkage int irix_statvfs(char __user *fname, struct irix_statvfs __user *buf)
1385 error |= __put_user(0, &buf->f_fstr[i]); 1385 error |= __put_user(0, &buf->f_fstr[i]);
1386 1386
1387dput_and_out: 1387dput_and_out:
1388 path_release(&nd); 1388 path_put(&nd.path);
1389out: 1389out:
1390 return error; 1390 return error;
1391} 1391}
@@ -1611,7 +1611,7 @@ asmlinkage int irix_statvfs64(char __user *fname, struct irix_statvfs64 __user *
1611 error = user_path_walk(fname, &nd); 1611 error = user_path_walk(fname, &nd);
1612 if (error) 1612 if (error)
1613 goto out; 1613 goto out;
1614 error = vfs_statfs(nd.dentry, &kbuf); 1614 error = vfs_statfs(nd.path.dentry, &kbuf);
1615 if (error) 1615 if (error)
1616 goto dput_and_out; 1616 goto dput_and_out;
1617 1617
@@ -1636,7 +1636,7 @@ asmlinkage int irix_statvfs64(char __user *fname, struct irix_statvfs64 __user *
1636 error |= __put_user(0, &buf->f_fstr[i]); 1636 error |= __put_user(0, &buf->f_fstr[i]);
1637 1637
1638dput_and_out: 1638dput_and_out:
1639 path_release(&nd); 1639 path_put(&nd.path);
1640out: 1640out:
1641 return error; 1641 return error;
1642} 1642}
diff --git a/arch/parisc/hpux/sys_hpux.c b/arch/parisc/hpux/sys_hpux.c
index 3e025df2dc86..0c5b9dabb475 100644
--- a/arch/parisc/hpux/sys_hpux.c
+++ b/arch/parisc/hpux/sys_hpux.c
@@ -219,10 +219,10 @@ asmlinkage long hpux_statfs(const char __user *path,
219 error = user_path_walk(path, &nd); 219 error = user_path_walk(path, &nd);
220 if (!error) { 220 if (!error) {
221 struct hpux_statfs tmp; 221 struct hpux_statfs tmp;
222 error = vfs_statfs_hpux(nd.dentry, &tmp); 222 error = vfs_statfs_hpux(nd.path.dentry, &tmp);
223 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 223 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
224 error = -EFAULT; 224 error = -EFAULT;
225 path_release(&nd); 225 path_put(&nd.path);
226 } 226 }
227 return error; 227 return error;
228} 228}
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 485513c9f1af..5b8d8382b762 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -442,10 +442,6 @@ config SECCOMP
442 442
443 If unsure, say Y. Only embedded should say N here. 443 If unsure, say Y. Only embedded should say N here.
444 444
445config WANT_DEVICE_TREE
446 bool
447 default n
448
449endmenu 445endmenu
450 446
451config ISA_DMA_API 447config ISA_DMA_API
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 49797a45416c..63d07ccbb9db 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -147,6 +147,8 @@ HOSTCFLAGS += -I$(src)/dtc-src/ -I$(src)/libfdt/
147targets += dtc-src/dtc-parser.tab.c 147targets += dtc-src/dtc-parser.tab.c
148targets += dtc-src/dtc-lexer.lex.c 148targets += dtc-src/dtc-lexer.lex.c
149 149
150clean-files += dtc-src/dtc-parser.tab.h
151
150ifdef DTC_GENPARSER 152ifdef DTC_GENPARSER
151BISON = bison 153BISON = bison
152FLEX = flex 154FLEX = flex
diff --git a/arch/powerpc/boot/ps3-hvcall.S b/arch/powerpc/boot/ps3-hvcall.S
index 585965f7e6a8..d6068f1829ca 100644
--- a/arch/powerpc/boot/ps3-hvcall.S
+++ b/arch/powerpc/boot/ps3-hvcall.S
@@ -145,7 +145,7 @@
145.macro STORE_REGS_5_2 145.macro STORE_REGS_5_2
146 lwz r11, 16(r1) 146 lwz r11, 16(r1)
147 std r4, 0(r11) 147 std r4, 0(r11)
148 lwz r11, 24(r1) 148 lwz r11, 20(r1)
149 std r5, 0(r11) 149 std r5, 0(r11)
150.endm 150.endm
151 151
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 0662ae46f724..c1baf9d5903f 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -104,3 +104,5 @@ quiet_cmd_systbl_chk = CALL $<
104PHONY += systbl_chk 104PHONY += systbl_chk
105systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i 105systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i
106 $(call cmd,systbl_chk) 106 $(call cmd,systbl_chk)
107
108clean-files := vmlinux.lds
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index b9d88374f14f..4846bf543a8c 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -462,7 +462,7 @@ void show_regs(struct pt_regs * regs)
462 current, task_pid_nr(current), current->comm, task_thread_info(current)); 462 current, task_pid_nr(current), current->comm, task_thread_info(current));
463 463
464#ifdef CONFIG_SMP 464#ifdef CONFIG_SMP
465 printk(" CPU: %d", smp_processor_id()); 465 printk(" CPU: %d", raw_smp_processor_id());
466#endif /* CONFIG_SMP */ 466#endif /* CONFIG_SMP */
467 467
468 for (i = 0; i < 32; i++) { 468 for (i = 0; i < 32; i++) {
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 3702df7dc567..d3437c4c4a6f 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -336,9 +336,9 @@ static unsigned long __init find_function32(struct lib32_elfinfo *lib,
336 return sym->st_value - VDSO32_LBASE; 336 return sym->st_value - VDSO32_LBASE;
337} 337}
338 338
339static int vdso_do_func_patch32(struct lib32_elfinfo *v32, 339static int __init vdso_do_func_patch32(struct lib32_elfinfo *v32,
340 struct lib64_elfinfo *v64, 340 struct lib64_elfinfo *v64,
341 const char *orig, const char *fix) 341 const char *orig, const char *fix)
342{ 342{
343 Elf32_Sym *sym32_gen, *sym32_fix; 343 Elf32_Sym *sym32_gen, *sym32_fix;
344 344
@@ -433,9 +433,9 @@ static unsigned long __init find_function64(struct lib64_elfinfo *lib,
433#endif 433#endif
434} 434}
435 435
436static int vdso_do_func_patch64(struct lib32_elfinfo *v32, 436static int __init vdso_do_func_patch64(struct lib32_elfinfo *v32,
437 struct lib64_elfinfo *v64, 437 struct lib64_elfinfo *v64,
438 const char *orig, const char *fix) 438 const char *orig, const char *fix)
439{ 439{
440 Elf64_Sym *sym64_gen, *sym64_fix; 440 Elf64_Sym *sym64_gen, *sym64_fix;
441 441
diff --git a/arch/powerpc/oprofile/cell/spu_task_sync.c b/arch/powerpc/oprofile/cell/spu_task_sync.c
index 4a890cb42b98..257b13cb18af 100644
--- a/arch/powerpc/oprofile/cell/spu_task_sync.c
+++ b/arch/powerpc/oprofile/cell/spu_task_sync.c
@@ -198,14 +198,13 @@ out:
198 * dcookie user still being registered (namely, the reader 198 * dcookie user still being registered (namely, the reader
199 * of the event buffer). 199 * of the event buffer).
200 */ 200 */
201static inline unsigned long fast_get_dcookie(struct dentry *dentry, 201static inline unsigned long fast_get_dcookie(struct path *path)
202 struct vfsmount *vfsmnt)
203{ 202{
204 unsigned long cookie; 203 unsigned long cookie;
205 204
206 if (dentry->d_cookie) 205 if (path->dentry->d_cookie)
207 return (unsigned long)dentry; 206 return (unsigned long)path->dentry;
208 get_dcookie(dentry, vfsmnt, &cookie); 207 get_dcookie(path, &cookie);
209 return cookie; 208 return cookie;
210} 209}
211 210
@@ -240,8 +239,7 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,
240 continue; 239 continue;
241 if (!(vma->vm_flags & VM_EXECUTABLE)) 240 if (!(vma->vm_flags & VM_EXECUTABLE))
242 continue; 241 continue;
243 app_cookie = fast_get_dcookie(vma->vm_file->f_dentry, 242 app_cookie = fast_get_dcookie(&vma->vm_file->f_path);
244 vma->vm_file->f_vfsmnt);
245 pr_debug("got dcookie for %s\n", 243 pr_debug("got dcookie for %s\n",
246 vma->vm_file->f_dentry->d_name.name); 244 vma->vm_file->f_dentry->d_name.name);
247 app = vma->vm_file; 245 app = vma->vm_file;
@@ -262,8 +260,7 @@ get_exec_dcookie_and_offset(struct spu *spu, unsigned int *offsetp,
262 break; 260 break;
263 } 261 }
264 262
265 *spu_bin_dcookie = fast_get_dcookie(vma->vm_file->f_dentry, 263 *spu_bin_dcookie = fast_get_dcookie(&vma->vm_file->f_path);
266 vma->vm_file->f_vfsmnt);
267 pr_debug("got dcookie for %s\n", vma->vm_file->f_dentry->d_name.name); 264 pr_debug("got dcookie for %s\n", vma->vm_file->f_dentry->d_name.name);
268 265
269 up_read(&mm->mmap_sem); 266 up_read(&mm->mmap_sem);
diff --git a/arch/powerpc/platforms/512x/Kconfig b/arch/powerpc/platforms/512x/Kconfig
index c6fa49e23dc0..4c0da0c079e9 100644
--- a/arch/powerpc/platforms/512x/Kconfig
+++ b/arch/powerpc/platforms/512x/Kconfig
@@ -13,7 +13,6 @@ config MPC5121_ADS
13 bool "Freescale MPC5121E ADS" 13 bool "Freescale MPC5121E ADS"
14 depends on PPC_MULTIPLATFORM && PPC32 14 depends on PPC_MULTIPLATFORM && PPC32
15 select DEFAULT_UIMAGE 15 select DEFAULT_UIMAGE
16 select WANT_DEVICE_TREE
17 select PPC_MPC5121 16 select PPC_MPC5121
18 help 17 help
19 This option enables support for the MPC5121E ADS board. 18 This option enables support for the MPC5121E ADS board.
diff --git a/arch/powerpc/platforms/52xx/Kconfig b/arch/powerpc/platforms/52xx/Kconfig
index 515f244c90bb..cf945d55c276 100644
--- a/arch/powerpc/platforms/52xx/Kconfig
+++ b/arch/powerpc/platforms/52xx/Kconfig
@@ -8,7 +8,6 @@ config PPC_MPC5200_SIMPLE
8 bool "Generic support for simple MPC5200 based boards" 8 bool "Generic support for simple MPC5200 based boards"
9 depends on PPC_MPC52xx 9 depends on PPC_MPC52xx
10 select DEFAULT_UIMAGE 10 select DEFAULT_UIMAGE
11 select WANT_DEVICE_TREE
12 help 11 help
13 This option enables support for a simple MPC52xx based boards which 12 This option enables support for a simple MPC52xx based boards which
14 do not need a custom platform specific setup. Such boards are 13 do not need a custom platform specific setup. Such boards are
@@ -35,7 +34,6 @@ config PPC_LITE5200
35 bool "Freescale Lite5200 Eval Board" 34 bool "Freescale Lite5200 Eval Board"
36 depends on PPC_MPC52xx 35 depends on PPC_MPC52xx
37 select DEFAULT_UIMAGE 36 select DEFAULT_UIMAGE
38 select WANT_DEVICE_TREE
39 37
40config PPC_MPC5200_BUGFIX 38config PPC_MPC5200_BUGFIX
41 bool "MPC5200 (L25R) bugfix support" 39 bool "MPC5200 (L25R) bugfix support"
diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
index fcedbec07f94..0afd22595546 100644
--- a/arch/powerpc/platforms/Kconfig
+++ b/arch/powerpc/platforms/Kconfig
@@ -15,7 +15,6 @@ config PPC_MULTIPLATFORM
15config PPC_82xx 15config PPC_82xx
16 bool "Freescale 82xx" 16 bool "Freescale 82xx"
17 depends on 6xx 17 depends on 6xx
18 select WANT_DEVICE_TREE
19 18
20config PPC_83xx 19config PPC_83xx
21 bool "Freescale 83xx" 20 bool "Freescale 83xx"
@@ -23,7 +22,6 @@ config PPC_83xx
23 select FSL_SOC 22 select FSL_SOC
24 select MPC83xx 23 select MPC83xx
25 select IPIC 24 select IPIC
26 select WANT_DEVICE_TREE
27 select FSL_EMB_PERFMON 25 select FSL_EMB_PERFMON
28 26
29config PPC_86xx 27config PPC_86xx
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 69941ba70975..73d81ce14b67 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -29,26 +29,22 @@ config PPC_85xx
29 bool "Freescale 85xx" 29 bool "Freescale 85xx"
30 select E500 30 select E500
31 select FSL_SOC 31 select FSL_SOC
32 select WANT_DEVICE_TREE
33 select MPC85xx 32 select MPC85xx
34 33
35config PPC_8xx 34config PPC_8xx
36 bool "Freescale 8xx" 35 bool "Freescale 8xx"
37 select FSL_SOC 36 select FSL_SOC
38 select 8xx 37 select 8xx
39 select WANT_DEVICE_TREE
40 select PPC_LIB_RHEAP 38 select PPC_LIB_RHEAP
41 39
42config 40x 40config 40x
43 bool "AMCC 40x" 41 bool "AMCC 40x"
44 select PPC_DCR_NATIVE 42 select PPC_DCR_NATIVE
45 select WANT_DEVICE_TREE
46 select PPC_UDBG_16550 43 select PPC_UDBG_16550
47 44
48config 44x 45config 44x
49 bool "AMCC 44x" 46 bool "AMCC 44x"
50 select PPC_DCR_NATIVE 47 select PPC_DCR_NATIVE
51 select WANT_DEVICE_TREE
52 select PPC_UDBG_16550 48 select PPC_UDBG_16550
53 49
54config E200 50config E200
diff --git a/arch/powerpc/platforms/cell/ras.c b/arch/powerpc/platforms/cell/ras.c
index b2494ebcdbe9..e43024c0392e 100644
--- a/arch/powerpc/platforms/cell/ras.c
+++ b/arch/powerpc/platforms/cell/ras.c
@@ -1,4 +1,13 @@
1#define DEBUG 1/*
2 * Copyright 2006-2008, IBM Corporation.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#undef DEBUG
2 11
3#include <linux/types.h> 12#include <linux/types.h>
4#include <linux/kernel.h> 13#include <linux/kernel.h>
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index e6e6559c55ed..6d1228c66c5e 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -1,3 +1,4 @@
1
1/* 2/*
2 * SPU file system 3 * SPU file system
3 * 4 *
@@ -592,7 +593,7 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
592 593
593 ret = -EINVAL; 594 ret = -EINVAL;
594 /* check if we are on spufs */ 595 /* check if we are on spufs */
595 if (nd->dentry->d_sb->s_type != &spufs_type) 596 if (nd->path.dentry->d_sb->s_type != &spufs_type)
596 goto out; 597 goto out;
597 598
598 /* don't accept undefined flags */ 599 /* don't accept undefined flags */
@@ -600,9 +601,9 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
600 goto out; 601 goto out;
601 602
602 /* only threads can be underneath a gang */ 603 /* only threads can be underneath a gang */
603 if (nd->dentry != nd->dentry->d_sb->s_root) { 604 if (nd->path.dentry != nd->path.dentry->d_sb->s_root) {
604 if ((flags & SPU_CREATE_GANG) || 605 if ((flags & SPU_CREATE_GANG) ||
605 !SPUFS_I(nd->dentry->d_inode)->i_gang) 606 !SPUFS_I(nd->path.dentry->d_inode)->i_gang)
606 goto out; 607 goto out;
607 } 608 }
608 609
@@ -618,16 +619,17 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
618 mode &= ~current->fs->umask; 619 mode &= ~current->fs->umask;
619 620
620 if (flags & SPU_CREATE_GANG) 621 if (flags & SPU_CREATE_GANG)
621 return spufs_create_gang(nd->dentry->d_inode, 622 return spufs_create_gang(nd->path.dentry->d_inode,
622 dentry, nd->mnt, mode); 623 dentry, nd->path.mnt, mode);
623 else 624 else
624 return spufs_create_context(nd->dentry->d_inode, 625 return spufs_create_context(nd->path.dentry->d_inode,
625 dentry, nd->mnt, flags, mode, filp); 626 dentry, nd->path.mnt, flags, mode,
627 filp);
626 628
627out_dput: 629out_dput:
628 dput(dentry); 630 dput(dentry);
629out_dir: 631out_dir:
630 mutex_unlock(&nd->dentry->d_inode->i_mutex); 632 mutex_unlock(&nd->path.dentry->d_inode->i_mutex);
631out: 633out:
632 return ret; 634 return ret;
633} 635}
diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c
index 430404413178..49c87769b1f8 100644
--- a/arch/powerpc/platforms/cell/spufs/syscalls.c
+++ b/arch/powerpc/platforms/cell/spufs/syscalls.c
@@ -73,7 +73,7 @@ static long do_spu_create(const char __user *pathname, unsigned int flags,
73 LOOKUP_OPEN|LOOKUP_CREATE, &nd); 73 LOOKUP_OPEN|LOOKUP_CREATE, &nd);
74 if (!ret) { 74 if (!ret) {
75 ret = spufs_create(&nd, flags, mode, neighbor); 75 ret = spufs_create(&nd, flags, mode, neighbor);
76 path_release(&nd); 76 path_put(&nd.path);
77 } 77 }
78 putname(tmp); 78 putname(tmp);
79 } 79 }
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/powerpc/platforms/embedded6xx/Kconfig
index 6c8083757938..429088967813 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -24,7 +24,6 @@ config STORCENTER
24 select MPIC 24 select MPIC
25 select FSL_SOC 25 select FSL_SOC
26 select PPC_UDBG_16550 if SERIAL_8250 26 select PPC_UDBG_16550 if SERIAL_8250
27 select WANT_DEVICE_TREE
28 select MPC10X_OPENPIC 27 select MPC10X_OPENPIC
29 select MPC10X_BRIDGE 28 select MPC10X_BRIDGE
30 help 29 help
@@ -37,7 +36,6 @@ config MPC7448HPC2
37 select TSI108_BRIDGE 36 select TSI108_BRIDGE
38 select DEFAULT_UIMAGE 37 select DEFAULT_UIMAGE
39 select PPC_UDBG_16550 38 select PPC_UDBG_16550
40 select WANT_DEVICE_TREE
41 select TSI108_BRIDGE 39 select TSI108_BRIDGE
42 help 40 help
43 Select MPC7448HPC2 if configuring for Freescale MPC7448HPC2 (Taiga) 41 Select MPC7448HPC2 if configuring for Freescale MPC7448HPC2 (Taiga)
@@ -48,7 +46,6 @@ config PPC_HOLLY
48 depends on EMBEDDED6xx 46 depends on EMBEDDED6xx
49 select TSI108_BRIDGE 47 select TSI108_BRIDGE
50 select PPC_UDBG_16550 48 select PPC_UDBG_16550
51 select WANT_DEVICE_TREE
52 select TSI108_BRIDGE 49 select TSI108_BRIDGE
53 help 50 help
54 Select PPC_HOLLY if configuring for an IBM 750GX/CL Eval 51 Select PPC_HOLLY if configuring for an IBM 750GX/CL Eval
@@ -59,7 +56,6 @@ config PPC_PRPMC2800
59 depends on EMBEDDED6xx 56 depends on EMBEDDED6xx
60 select MV64X60 57 select MV64X60
61 select NOT_COHERENT_CACHE 58 select NOT_COHERENT_CACHE
62 select WANT_DEVICE_TREE
63 help 59 help
64 This option enables support for the Motorola PrPMC2800 board 60 This option enables support for the Motorola PrPMC2800 board
65 61
diff --git a/arch/powerpc/platforms/iseries/vio.c b/arch/powerpc/platforms/iseries/vio.c
index be06cfd9fa3d..657b72f68493 100644
--- a/arch/powerpc/platforms/iseries/vio.c
+++ b/arch/powerpc/platforms/iseries/vio.c
@@ -75,7 +75,7 @@ static struct property *new_property(const char *name, int length,
75 return np; 75 return np;
76} 76}
77 77
78static void __init free_property(struct property *np) 78static void free_property(struct property *np)
79{ 79{
80 kfree(np); 80 kfree(np);
81} 81}
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index d87d4bf88803..b3400b5ad5c6 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -93,6 +93,9 @@ config ARCH_NO_VIRT_TO_BUS
93config ARCH_SUPPORTS_AOUT 93config ARCH_SUPPORTS_AOUT
94 def_bool y 94 def_bool y
95 95
96config IO_TRAPPED
97 bool
98
96source "init/Kconfig" 99source "init/Kconfig"
97 100
98menu "System type" 101menu "System type"
@@ -312,6 +315,13 @@ config CPU_SUBTYPE_SH7722
312 select ARCH_SPARSEMEM_ENABLE 315 select ARCH_SPARSEMEM_ENABLE
313 select SYS_SUPPORTS_NUMA 316 select SYS_SUPPORTS_NUMA
314 317
318config CPU_SUBTYPE_SH7366
319 bool "Support SH7366 processor"
320 select CPU_SH4AL_DSP
321 select CPU_SHX2
322 select ARCH_SPARSEMEM_ENABLE
323 select SYS_SUPPORTS_NUMA
324
315# SH-5 Processor Support 325# SH-5 Processor Support
316 326
317config CPU_SUBTYPE_SH5_101 327config CPU_SUBTYPE_SH5_101
@@ -456,6 +466,7 @@ config SH_RTS7751R2D
456 bool "RTS7751R2D" 466 bool "RTS7751R2D"
457 depends on CPU_SUBTYPE_SH7751R 467 depends on CPU_SUBTYPE_SH7751R
458 select SYS_SUPPORTS_PCI 468 select SYS_SUPPORTS_PCI
469 select IO_TRAPPED
459 help 470 help
460 Select RTS7751R2D if configuring for a Renesas Technology 471 Select RTS7751R2D if configuring for a Renesas Technology
461 Sales SH-Graphics board. 472 Sales SH-Graphics board.
@@ -472,6 +483,14 @@ config SH_HIGHLANDER
472 bool "Highlander" 483 bool "Highlander"
473 depends on CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7785 484 depends on CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7785
474 select SYS_SUPPORTS_PCI 485 select SYS_SUPPORTS_PCI
486 select IO_TRAPPED
487
488config SH_MIGOR
489 bool "Migo-R"
490 depends on CPU_SUBTYPE_SH7722
491 help
492 Select Migo-R if configuring for the SH7722 Migo-R platform
493 by Renesas System Solutions Asia Pte. Ltd.
475 494
476config SH_EDOSK7705 495config SH_EDOSK7705
477 bool "EDOSK7705" 496 bool "EDOSK7705"
diff --git a/arch/sh/Kconfig.cpu b/arch/sh/Kconfig.cpu
index d850184d0694..0e27fe3b182b 100644
--- a/arch/sh/Kconfig.cpu
+++ b/arch/sh/Kconfig.cpu
@@ -12,6 +12,7 @@ config CPU_LITTLE_ENDIAN
12 12
13config CPU_BIG_ENDIAN 13config CPU_BIG_ENDIAN
14 bool "Big Endian" 14 bool "Big Endian"
15 depends on !CPU_SH5
15 16
16endchoice 17endchoice
17 18
@@ -87,9 +88,6 @@ config SH64_ID2815_WORKAROUND
87config CPU_HAS_INTEVT 88config CPU_HAS_INTEVT
88 bool 89 bool
89 90
90config CPU_HAS_MASKREG_IRQ
91 bool
92
93config CPU_HAS_IPR_IRQ 91config CPU_HAS_IPR_IRQ
94 bool 92 bool
95 93
diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
index f7c716166ce8..5dcb74b947a9 100644
--- a/arch/sh/Kconfig.debug
+++ b/arch/sh/Kconfig.debug
@@ -29,7 +29,8 @@ config EARLY_SCIF_CONSOLE
29config EARLY_SCIF_CONSOLE_PORT 29config EARLY_SCIF_CONSOLE_PORT
30 hex 30 hex
31 depends on EARLY_SCIF_CONSOLE 31 depends on EARLY_SCIF_CONSOLE
32 default "0xffe00000" if CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7763 32 default "0xffe00000" if CPU_SUBTYPE_SH7780 || CPU_SUBTYPE_SH7763
33 default "0xffe00000" if CPU_SUBTYPE_SH7722 || CPU_SUBTYPE_SH7366
33 default "0xffea0000" if CPU_SUBTYPE_SH7785 34 default "0xffea0000" if CPU_SUBTYPE_SH7785
34 default "0xfffe8000" if CPU_SUBTYPE_SH7203 35 default "0xfffe8000" if CPU_SUBTYPE_SH7203
35 default "0xfffe9800" if CPU_SUBTYPE_SH7206 || CPU_SUBTYPE_SH7263 36 default "0xfffe9800" if CPU_SUBTYPE_SH7206 || CPU_SUBTYPE_SH7263
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 17fc36186bf4..81381e5773c8 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -116,6 +116,7 @@ machdir-$(CONFIG_SH_RTS7751R2D) += renesas/rts7751r2d
116machdir-$(CONFIG_SH_7751_SYSTEMH) += renesas/systemh 116machdir-$(CONFIG_SH_7751_SYSTEMH) += renesas/systemh
117machdir-$(CONFIG_SH_EDOSK7705) += renesas/edosk7705 117machdir-$(CONFIG_SH_EDOSK7705) += renesas/edosk7705
118machdir-$(CONFIG_SH_HIGHLANDER) += renesas/r7780rp 118machdir-$(CONFIG_SH_HIGHLANDER) += renesas/r7780rp
119machdir-$(CONFIG_SH_MIGOR) += renesas/migor
119machdir-$(CONFIG_SH_SDK7780) += renesas/sdk7780 120machdir-$(CONFIG_SH_SDK7780) += renesas/sdk7780
120machdir-$(CONFIG_SH_7710VOIPGW) += renesas/sh7710voipgw 121machdir-$(CONFIG_SH_7710VOIPGW) += renesas/sh7710voipgw
121machdir-$(CONFIG_SH_X3PROTO) += renesas/x3proto 122machdir-$(CONFIG_SH_X3PROTO) += renesas/x3proto
diff --git a/arch/sh/boards/renesas/migor/Makefile b/arch/sh/boards/renesas/migor/Makefile
new file mode 100644
index 000000000000..77037567633b
--- /dev/null
+++ b/arch/sh/boards/renesas/migor/Makefile
@@ -0,0 +1 @@
obj-y := setup.o
diff --git a/arch/sh/boards/renesas/migor/setup.c b/arch/sh/boards/renesas/migor/setup.c
new file mode 100644
index 000000000000..21ab8c8fb590
--- /dev/null
+++ b/arch/sh/boards/renesas/migor/setup.c
@@ -0,0 +1,61 @@
1/*
2 * Renesas System Solutions Asia Pte. Ltd - Migo-R
3 *
4 * Copyright (C) 2008 Magnus Damm
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/init.h>
11#include <linux/platform_device.h>
12#include <linux/interrupt.h>
13#include <asm/machvec.h>
14#include <asm/io.h>
15
16/* Address IRQ Size Bus Description
17 * 0x00000000 64MB 16 NOR Flash (SP29PL256N)
18 * 0x0c000000 64MB 64 SDRAM (2xK4M563233G)
19 * 0x10000000 IRQ0 16 Ethernet (SMC91C111)
20 * 0x14000000 IRQ4 16 USB 2.0 Host Controller (M66596)
21 * 0x18000000 8GB 8 NAND Flash (K9K8G08U0A)
22 */
23
24static struct resource smc91x_eth_resources[] = {
25 [0] = {
26 .name = "smc91x-regs" ,
27 .start = P2SEGADDR(0x10000300),
28 .end = P2SEGADDR(0x1000030f),
29 .flags = IORESOURCE_MEM,
30 },
31 [1] = {
32 .start = 32, /* IRQ0 */
33 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH,
34 },
35};
36
37static struct platform_device smc91x_eth_device = {
38 .name = "smc91x",
39 .num_resources = ARRAY_SIZE(smc91x_eth_resources),
40 .resource = smc91x_eth_resources,
41};
42
43static struct platform_device *migor_devices[] __initdata = {
44 &smc91x_eth_device,
45};
46
47static int __init migor_devices_setup(void)
48{
49 return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices));
50}
51__initcall(migor_devices_setup);
52
53static void __init migor_setup(char **cmdline_p)
54{
55 ctrl_outw(0x1000, 0xa4050110); /* Enable IRQ0 in PJCR */
56}
57
58static struct sh_machine_vector mv_migor __initmv = {
59 .mv_name = "Migo-R",
60 .mv_setup = migor_setup,
61};
diff --git a/arch/sh/boards/renesas/r7780rp/setup.c b/arch/sh/boards/renesas/r7780rp/setup.c
index f7a8d5c9d510..2f68bea7890c 100644
--- a/arch/sh/boards/renesas/r7780rp/setup.c
+++ b/arch/sh/boards/renesas/r7780rp/setup.c
@@ -23,6 +23,7 @@
23#include <asm/clock.h> 23#include <asm/clock.h>
24#include <asm/heartbeat.h> 24#include <asm/heartbeat.h>
25#include <asm/io.h> 25#include <asm/io.h>
26#include <asm/io_trapped.h>
26 27
27static struct resource r8a66597_usb_host_resources[] = { 28static struct resource r8a66597_usb_host_resources[] = {
28 [0] = { 29 [0] = {
@@ -181,13 +182,27 @@ static struct platform_device *r7780rp_devices[] __initdata = {
181 &m66592_usb_peripheral_device, 182 &m66592_usb_peripheral_device,
182 &heartbeat_device, 183 &heartbeat_device,
183#ifndef CONFIG_SH_R7780RP 184#ifndef CONFIG_SH_R7780RP
184 &cf_ide_device,
185 &ax88796_device, 185 &ax88796_device,
186#endif 186#endif
187}; 187};
188 188
189/*
190 * The CF is connected using a 16-bit bus where 8-bit operations are
191 * unsupported. The linux ata driver is however using 8-bit operations, so
192 * insert a trapped io filter to convert 8-bit operations into 16-bit.
193 */
194static struct trapped_io cf_trapped_io = {
195 .resource = cf_ide_resources,
196 .num_resources = 2,
197 .minimum_bus_width = 16,
198};
199
189static int __init r7780rp_devices_setup(void) 200static int __init r7780rp_devices_setup(void)
190{ 201{
202#ifndef CONFIG_SH_R7780RP
203 if (register_trapped_io(&cf_trapped_io) == 0)
204 platform_device_register(&cf_ide_device);
205#endif
191 return platform_add_devices(r7780rp_devices, 206 return platform_add_devices(r7780rp_devices,
192 ARRAY_SIZE(r7780rp_devices)); 207 ARRAY_SIZE(r7780rp_devices));
193} 208}
@@ -226,34 +241,6 @@ static void r7780rp_power_off(void)
226 ctrl_outw(0x0001, PA_POFF); 241 ctrl_outw(0x0001, PA_POFF);
227} 242}
228 243
229static inline unsigned char is_ide_ioaddr(unsigned long addr)
230{
231 return ((cf_ide_resources[0].start <= addr &&
232 addr <= cf_ide_resources[0].end) ||
233 (cf_ide_resources[1].start <= addr &&
234 addr <= cf_ide_resources[1].end));
235}
236
237void highlander_writeb(u8 b, void __iomem *addr)
238{
239 unsigned long tmp = (unsigned long __force)addr;
240
241 if (is_ide_ioaddr(tmp))
242 ctrl_outw((u16)b, tmp);
243 else
244 ctrl_outb(b, tmp);
245}
246
247u8 highlander_readb(void __iomem *addr)
248{
249 unsigned long tmp = (unsigned long __force)addr;
250
251 if (is_ide_ioaddr(tmp))
252 return ctrl_inw(tmp) & 0xff;
253 else
254 return ctrl_inb(tmp);
255}
256
257/* 244/*
258 * Initialize the board 245 * Initialize the board
259 */ 246 */
@@ -338,6 +325,4 @@ static struct sh_machine_vector mv_highlander __initmv = {
338 .mv_setup = highlander_setup, 325 .mv_setup = highlander_setup,
339 .mv_init_irq = highlander_init_irq, 326 .mv_init_irq = highlander_init_irq,
340 .mv_irq_demux = highlander_irq_demux, 327 .mv_irq_demux = highlander_irq_demux,
341 .mv_readb = highlander_readb,
342 .mv_writeb = highlander_writeb,
343}; 328};
diff --git a/arch/sh/boards/renesas/rts7751r2d/setup.c b/arch/sh/boards/renesas/rts7751r2d/setup.c
index a0ef81b7de37..f21ee49ef3a5 100644
--- a/arch/sh/boards/renesas/rts7751r2d/setup.c
+++ b/arch/sh/boards/renesas/rts7751r2d/setup.c
@@ -21,6 +21,7 @@
21#include <asm/machvec.h> 21#include <asm/machvec.h>
22#include <asm/rts7751r2d.h> 22#include <asm/rts7751r2d.h>
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/io_trapped.h>
24#include <asm/spi.h> 25#include <asm/spi.h>
25 26
26static struct resource cf_ide_resources[] = { 27static struct resource cf_ide_resources[] = {
@@ -214,13 +215,25 @@ static struct platform_device *rts7751r2d_devices[] __initdata = {
214 &uart_device, 215 &uart_device,
215 &sm501_device, 216 &sm501_device,
216#endif 217#endif
217 &cf_ide_device,
218 &heartbeat_device, 218 &heartbeat_device,
219 &spi_sh_sci_device, 219 &spi_sh_sci_device,
220}; 220};
221 221
222/*
223 * The CF is connected with a 16-bit bus where 8-bit operations are
224 * unsupported. The linux ata driver is however using 8-bit operations, so
225 * insert a trapped io filter to convert 8-bit operations into 16-bit.
226 */
227static struct trapped_io cf_trapped_io = {
228 .resource = cf_ide_resources,
229 .num_resources = 2,
230 .minimum_bus_width = 16,
231};
232
222static int __init rts7751r2d_devices_setup(void) 233static int __init rts7751r2d_devices_setup(void)
223{ 234{
235 if (register_trapped_io(&cf_trapped_io) == 0)
236 platform_device_register(&cf_ide_device);
224 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); 237 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
225 return platform_add_devices(rts7751r2d_devices, 238 return platform_add_devices(rts7751r2d_devices,
226 ARRAY_SIZE(rts7751r2d_devices)); 239 ARRAY_SIZE(rts7751r2d_devices));
@@ -232,34 +245,6 @@ static void rts7751r2d_power_off(void)
232 ctrl_outw(0x0001, PA_POWOFF); 245 ctrl_outw(0x0001, PA_POWOFF);
233} 246}
234 247
235static inline unsigned char is_ide_ioaddr(unsigned long addr)
236{
237 return ((cf_ide_resources[0].start <= addr &&
238 addr <= cf_ide_resources[0].end) ||
239 (cf_ide_resources[1].start <= addr &&
240 addr <= cf_ide_resources[1].end));
241}
242
243void rts7751r2d_writeb(u8 b, void __iomem *addr)
244{
245 unsigned long tmp = (unsigned long __force)addr;
246
247 if (is_ide_ioaddr(tmp))
248 ctrl_outw((u16)b, tmp);
249 else
250 ctrl_outb(b, tmp);
251}
252
253u8 rts7751r2d_readb(void __iomem *addr)
254{
255 unsigned long tmp = (unsigned long __force)addr;
256
257 if (is_ide_ioaddr(tmp))
258 return ctrl_inw(tmp) & 0xff;
259 else
260 return ctrl_inb(tmp);
261}
262
263/* 248/*
264 * Initialize the board 249 * Initialize the board
265 */ 250 */
@@ -310,6 +295,4 @@ static struct sh_machine_vector mv_rts7751r2d __initmv = {
310 .mv_setup = rts7751r2d_setup, 295 .mv_setup = rts7751r2d_setup,
311 .mv_init_irq = init_rts7751r2d_IRQ, 296 .mv_init_irq = init_rts7751r2d_IRQ,
312 .mv_irq_demux = rts7751r2d_irq_demux, 297 .mv_irq_demux = rts7751r2d_irq_demux,
313 .mv_writeb = rts7751r2d_writeb,
314 .mv_readb = rts7751r2d_readb,
315}; 298};
diff --git a/arch/sh/boards/renesas/sdk7780/Kconfig b/arch/sh/boards/renesas/sdk7780/Kconfig
index e4f5b6985be1..065f1df09bf1 100644
--- a/arch/sh/boards/renesas/sdk7780/Kconfig
+++ b/arch/sh/boards/renesas/sdk7780/Kconfig
@@ -4,13 +4,6 @@ choice
4 prompt "SDK7780 options" 4 prompt "SDK7780 options"
5 default SH_SDK7780_BASE 5 default SH_SDK7780_BASE
6 6
7config SH_SDK7780_STANDALONE
8 bool "SDK7780 board support"
9 depends on CPU_SUBTYPE_SH7780
10 help
11 Selecting this option will enable support for the
12 standalone version of the SDK7780. If in doubt, say Y.
13
14config SH_SDK7780_BASE 7config SH_SDK7780_BASE
15 bool "SDK7780 with base-board support" 8 bool "SDK7780 with base-board support"
16 depends on CPU_SUBTYPE_SH7780 9 depends on CPU_SUBTYPE_SH7780
diff --git a/arch/sh/cchips/hd6446x/hd64465/setup.c b/arch/sh/cchips/hd6446x/hd64465/setup.c
index 5cef0db4018b..9b8820c36701 100644
--- a/arch/sh/cchips/hd6446x/hd64465/setup.c
+++ b/arch/sh/cchips/hd6446x/hd64465/setup.c
@@ -17,10 +17,8 @@
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <linux/irq.h> 19#include <linux/irq.h>
20
21#include <asm/io.h> 20#include <asm/io.h>
22#include <asm/irq.h> 21#include <asm/irq.h>
23
24#include <asm/hd64465/hd64465.h> 22#include <asm/hd64465/hd64465.h>
25 23
26static void disable_hd64465_irq(unsigned int irq) 24static void disable_hd64465_irq(unsigned int irq)
@@ -28,51 +26,45 @@ static void disable_hd64465_irq(unsigned int irq)
28 unsigned short nimr; 26 unsigned short nimr;
29 unsigned short mask = 1 << (irq - HD64465_IRQ_BASE); 27 unsigned short mask = 1 << (irq - HD64465_IRQ_BASE);
30 28
31 pr_debug("disable_hd64465_irq(%d): mask=%x\n", irq, mask); 29 pr_debug("disable_hd64465_irq(%d): mask=%x\n", irq, mask);
32 nimr = inw(HD64465_REG_NIMR); 30 nimr = inw(HD64465_REG_NIMR);
33 nimr |= mask; 31 nimr |= mask;
34 outw(nimr, HD64465_REG_NIMR); 32 outw(nimr, HD64465_REG_NIMR);
35} 33}
36 34
37
38static void enable_hd64465_irq(unsigned int irq) 35static void enable_hd64465_irq(unsigned int irq)
39{ 36{
40 unsigned short nimr; 37 unsigned short nimr;
41 unsigned short mask = 1 << (irq - HD64465_IRQ_BASE); 38 unsigned short mask = 1 << (irq - HD64465_IRQ_BASE);
42 39
43 pr_debug("enable_hd64465_irq(%d): mask=%x\n", irq, mask); 40 pr_debug("enable_hd64465_irq(%d): mask=%x\n", irq, mask);
44 nimr = inw(HD64465_REG_NIMR); 41 nimr = inw(HD64465_REG_NIMR);
45 nimr &= ~mask; 42 nimr &= ~mask;
46 outw(nimr, HD64465_REG_NIMR); 43 outw(nimr, HD64465_REG_NIMR);
47} 44}
48 45
49
50static void mask_and_ack_hd64465(unsigned int irq) 46static void mask_and_ack_hd64465(unsigned int irq)
51{ 47{
52 disable_hd64465_irq(irq); 48 disable_hd64465_irq(irq);
53} 49}
54 50
55
56static void end_hd64465_irq(unsigned int irq) 51static void end_hd64465_irq(unsigned int irq)
57{ 52{
58 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 53 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
59 enable_hd64465_irq(irq); 54 enable_hd64465_irq(irq);
60} 55}
61 56
62
63static unsigned int startup_hd64465_irq(unsigned int irq) 57static unsigned int startup_hd64465_irq(unsigned int irq)
64{ 58{
65 enable_hd64465_irq(irq); 59 enable_hd64465_irq(irq);
66 return 0; 60 return 0;
67} 61}
68 62
69
70static void shutdown_hd64465_irq(unsigned int irq) 63static void shutdown_hd64465_irq(unsigned int irq)
71{ 64{
72 disable_hd64465_irq(irq); 65 disable_hd64465_irq(irq);
73} 66}
74 67
75
76static struct hw_interrupt_type hd64465_irq_type = { 68static struct hw_interrupt_type hd64465_irq_type = {
77 .typename = "HD64465-IRQ", 69 .typename = "HD64465-IRQ",
78 .startup = startup_hd64465_irq, 70 .startup = startup_hd64465_irq,
@@ -83,7 +75,6 @@ static struct hw_interrupt_type hd64465_irq_type = {
83 .end = end_hd64465_irq, 75 .end = end_hd64465_irq,
84}; 76};
85 77
86
87static irqreturn_t hd64465_interrupt(int irq, void *dev_id) 78static irqreturn_t hd64465_interrupt(int irq, void *dev_id)
88{ 79{
89 printk(KERN_INFO 80 printk(KERN_INFO
@@ -93,9 +84,6 @@ static irqreturn_t hd64465_interrupt(int irq, void *dev_id)
93 return IRQ_NONE; 84 return IRQ_NONE;
94} 85}
95 86
96
97/*====================================================*/
98
99/* 87/*
100 * Support for a secondary IRQ demux step. This is necessary 88 * Support for a secondary IRQ demux step. This is necessary
101 * because the HD64465 presents a very thin interface to the 89 * because the HD64465 presents a very thin interface to the
@@ -103,8 +91,7 @@ static irqreturn_t hd64465_interrupt(int irq, void *dev_id)
103 * normally done in hardware by other PCMCIA host bridges is 91 * normally done in hardware by other PCMCIA host bridges is
104 * instead done in software. 92 * instead done in software.
105 */ 93 */
106static struct 94static struct {
107{
108 int (*func)(int, void *); 95 int (*func)(int, void *);
109 void *dev; 96 void *dev;
110} hd64465_demux[HD64465_IRQ_NUM]; 97} hd64465_demux[HD64465_IRQ_NUM];
@@ -112,19 +99,17 @@ static struct
112void hd64465_register_irq_demux(int irq, 99void hd64465_register_irq_demux(int irq,
113 int (*demux)(int irq, void *dev), void *dev) 100 int (*demux)(int irq, void *dev), void *dev)
114{ 101{
115 hd64465_demux[irq - HD64465_IRQ_BASE].func = demux; 102 hd64465_demux[irq - HD64465_IRQ_BASE].func = demux;
116 hd64465_demux[irq - HD64465_IRQ_BASE].dev = dev; 103 hd64465_demux[irq - HD64465_IRQ_BASE].dev = dev;
117} 104}
118EXPORT_SYMBOL(hd64465_register_irq_demux); 105EXPORT_SYMBOL(hd64465_register_irq_demux);
119 106
120void hd64465_unregister_irq_demux(int irq) 107void hd64465_unregister_irq_demux(int irq)
121{ 108{
122 hd64465_demux[irq - HD64465_IRQ_BASE].func = 0; 109 hd64465_demux[irq - HD64465_IRQ_BASE].func = 0;
123} 110}
124EXPORT_SYMBOL(hd64465_unregister_irq_demux); 111EXPORT_SYMBOL(hd64465_unregister_irq_demux);
125 112
126
127
128int hd64465_irq_demux(int irq) 113int hd64465_irq_demux(int irq)
129{ 114{
130 if (irq == CONFIG_HD64465_IRQ) { 115 if (irq == CONFIG_HD64465_IRQ) {
@@ -132,16 +117,16 @@ int hd64465_irq_demux(int irq)
132 unsigned short nirr = inw(HD64465_REG_NIRR); 117 unsigned short nirr = inw(HD64465_REG_NIRR);
133 unsigned short nimr = inw(HD64465_REG_NIMR); 118 unsigned short nimr = inw(HD64465_REG_NIMR);
134 119
135 pr_debug("hd64465_irq_demux, nirr=%04x, nimr=%04x\n", nirr, nimr); 120 pr_debug("hd64465_irq_demux, nirr=%04x, nimr=%04x\n", nirr, nimr);
136 nirr &= ~nimr; 121 nirr &= ~nimr;
137 for (bit = 1, i = 0 ; i < HD64465_IRQ_NUM ; bit <<= 1, i++) 122 for (bit = 1, i = 0 ; i < HD64465_IRQ_NUM ; bit <<= 1, i++)
138 if (nirr & bit) 123 if (nirr & bit)
139 break; 124 break;
140 125
141 if (i < HD64465_IRQ_NUM) { 126 if (i < HD64465_IRQ_NUM) {
142 irq = HD64465_IRQ_BASE + i; 127 irq = HD64465_IRQ_BASE + i;
143 if (hd64465_demux[i].func != 0) 128 if (hd64465_demux[i].func != 0)
144 irq = hd64465_demux[i].func(irq, hd64465_demux[i].dev); 129 irq = hd64465_demux[i].func(irq, hd64465_demux[i].dev);
145 } 130 }
146 } 131 }
147 return irq; 132 return irq;
@@ -154,7 +139,6 @@ static struct irqaction irq0 = {
154 .name = "HD64465", 139 .name = "HD64465",
155}; 140};
156 141
157
158static int __init setup_hd64465(void) 142static int __init setup_hd64465(void)
159{ 143{
160 int i; 144 int i;
@@ -176,8 +160,8 @@ static int __init setup_hd64465(void)
176 160
177 rev = inw(HD64465_REG_SRR); 161 rev = inw(HD64465_REG_SRR);
178 printk(KERN_INFO "HD64465 hardware revision %d.%d\n", (rev >> 8) & 0xff, rev & 0xff); 162 printk(KERN_INFO "HD64465 hardware revision %d.%d\n", (rev >> 8) & 0xff, rev & 0xff);
179 163
180 outw(0xffff, HD64465_REG_NIMR); /* mask all interrupts */ 164 outw(0xffff, HD64465_REG_NIMR); /* mask all interrupts */
181 165
182 for (i = 0; i < HD64465_IRQ_NUM ; i++) { 166 for (i = 0; i < HD64465_IRQ_NUM ; i++) {
183 irq_desc[HD64465_IRQ_BASE + i].chip = &hd64465_irq_type; 167 irq_desc[HD64465_IRQ_BASE + i].chip = &hd64465_irq_type;
@@ -185,16 +169,13 @@ static int __init setup_hd64465(void)
185 169
186 setup_irq(CONFIG_HD64465_IRQ, &irq0); 170 setup_irq(CONFIG_HD64465_IRQ, &irq0);
187 171
188#ifdef CONFIG_SERIAL
189 /* wake up the UART from STANDBY at this point */ 172 /* wake up the UART from STANDBY at this point */
190 smscr = inw(HD64465_REG_SMSCR); 173 smscr = inw(HD64465_REG_SMSCR);
191 outw(smscr & (~HD64465_SMSCR_UARTST), HD64465_REG_SMSCR); 174 outw(smscr & (~HD64465_SMSCR_UARTST), HD64465_REG_SMSCR);
192 175
193 /* remap IO ports for first ISA serial port to HD64465 UART */ 176 /* remap IO ports for first ISA serial port to HD64465 UART */
194 hd64465_port_map(0x3f8, 8, CONFIG_HD64465_IOBASE + 0x8000, 1); 177 hd64465_port_map(0x3f8, 8, CONFIG_HD64465_IOBASE + 0x8000, 1);
195#endif
196 178
197 return 0; 179 return 0;
198} 180}
199
200module_init(setup_hd64465); 181module_init(setup_hd64465);
diff --git a/arch/sh/configs/migor_defconfig b/arch/sh/configs/migor_defconfig
new file mode 100644
index 000000000000..ee5900817f8f
--- /dev/null
+++ b/arch/sh/configs/migor_defconfig
@@ -0,0 +1,824 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.24
4# Wed Feb 6 21:52:20 2008
5#
6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y
8CONFIG_RWSEM_GENERIC_SPINLOCK=y
9CONFIG_GENERIC_BUG=y
10CONFIG_GENERIC_FIND_NEXT_BIT=y
11CONFIG_GENERIC_HWEIGHT=y
12CONFIG_GENERIC_HARDIRQS=y
13CONFIG_GENERIC_IRQ_PROBE=y
14CONFIG_GENERIC_CALIBRATE_DELAY=y
15CONFIG_GENERIC_TIME=y
16CONFIG_GENERIC_CLOCKEVENTS=y
17CONFIG_SYS_SUPPORTS_NUMA=y
18CONFIG_STACKTRACE_SUPPORT=y
19CONFIG_LOCKDEP_SUPPORT=y
20# CONFIG_ARCH_HAS_ILOG2_U32 is not set
21# CONFIG_ARCH_HAS_ILOG2_U64 is not set
22CONFIG_ARCH_NO_VIRT_TO_BUS=y
23CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
24
25#
26# General setup
27#
28CONFIG_EXPERIMENTAL=y
29CONFIG_BROKEN_ON_SMP=y
30CONFIG_INIT_ENV_ARG_LIMIT=32
31CONFIG_LOCALVERSION=""
32CONFIG_LOCALVERSION_AUTO=y
33CONFIG_SWAP=y
34CONFIG_SYSVIPC=y
35CONFIG_SYSVIPC_SYSCTL=y
36# CONFIG_POSIX_MQUEUE is not set
37# CONFIG_BSD_PROCESS_ACCT is not set
38# CONFIG_TASKSTATS is not set
39# CONFIG_USER_NS is not set
40# CONFIG_PID_NS is not set
41# CONFIG_AUDIT is not set
42CONFIG_IKCONFIG=y
43CONFIG_IKCONFIG_PROC=y
44CONFIG_LOG_BUF_SHIFT=14
45# CONFIG_CGROUPS is not set
46CONFIG_FAIR_GROUP_SCHED=y
47CONFIG_FAIR_USER_SCHED=y
48# CONFIG_FAIR_CGROUP_SCHED is not set
49CONFIG_SYSFS_DEPRECATED=y
50# CONFIG_RELAY is not set
51CONFIG_BLK_DEV_INITRD=y
52CONFIG_INITRAMFS_SOURCE=""
53# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
54CONFIG_SYSCTL=y
55CONFIG_EMBEDDED=y
56CONFIG_UID16=y
57# CONFIG_SYSCTL_SYSCALL is not set
58CONFIG_KALLSYMS=y
59# CONFIG_KALLSYMS_EXTRA_PASS is not set
60CONFIG_HOTPLUG=y
61CONFIG_PRINTK=y
62CONFIG_BUG=y
63CONFIG_ELF_CORE=y
64CONFIG_BASE_FULL=y
65CONFIG_FUTEX=y
66CONFIG_ANON_INODES=y
67CONFIG_EPOLL=y
68CONFIG_SIGNALFD=y
69CONFIG_EVENTFD=y
70CONFIG_SHMEM=y
71CONFIG_VM_EVENT_COUNTERS=y
72CONFIG_SLAB=y
73# CONFIG_SLUB is not set
74# CONFIG_SLOB is not set
75CONFIG_PROFILING=y
76# CONFIG_MARKERS is not set
77CONFIG_OPROFILE=y
78CONFIG_HAVE_OPROFILE=y
79# CONFIG_HAVE_KPROBES is not set
80CONFIG_SLABINFO=y
81CONFIG_RT_MUTEXES=y
82# CONFIG_TINY_SHMEM is not set
83CONFIG_BASE_SMALL=0
84CONFIG_MODULES=y
85# CONFIG_MODULE_UNLOAD is not set
86# CONFIG_MODVERSIONS is not set
87# CONFIG_MODULE_SRCVERSION_ALL is not set
88# CONFIG_KMOD is not set
89CONFIG_BLOCK=y
90# CONFIG_LBD is not set
91# CONFIG_BLK_DEV_IO_TRACE is not set
92# CONFIG_LSF is not set
93# CONFIG_BLK_DEV_BSG is not set
94
95#
96# IO Schedulers
97#
98CONFIG_IOSCHED_NOOP=y
99CONFIG_IOSCHED_AS=y
100CONFIG_IOSCHED_DEADLINE=y
101CONFIG_IOSCHED_CFQ=y
102CONFIG_DEFAULT_AS=y
103# CONFIG_DEFAULT_DEADLINE is not set
104# CONFIG_DEFAULT_CFQ is not set
105# CONFIG_DEFAULT_NOOP is not set
106CONFIG_DEFAULT_IOSCHED="anticipatory"
107CONFIG_CLASSIC_RCU=y
108# CONFIG_PREEMPT_RCU is not set
109
110#
111# System type
112#
113CONFIG_CPU_SH4=y
114CONFIG_CPU_SH4A=y
115CONFIG_CPU_SH4AL_DSP=y
116CONFIG_CPU_SHX2=y
117# CONFIG_CPU_SUBTYPE_SH7619 is not set
118# CONFIG_CPU_SUBTYPE_SH7203 is not set
119# CONFIG_CPU_SUBTYPE_SH7206 is not set
120# CONFIG_CPU_SUBTYPE_SH7263 is not set
121# CONFIG_CPU_SUBTYPE_SH7705 is not set
122# CONFIG_CPU_SUBTYPE_SH7706 is not set
123# CONFIG_CPU_SUBTYPE_SH7707 is not set
124# CONFIG_CPU_SUBTYPE_SH7708 is not set
125# CONFIG_CPU_SUBTYPE_SH7709 is not set
126# CONFIG_CPU_SUBTYPE_SH7710 is not set
127# CONFIG_CPU_SUBTYPE_SH7712 is not set
128# CONFIG_CPU_SUBTYPE_SH7720 is not set
129# CONFIG_CPU_SUBTYPE_SH7721 is not set
130# CONFIG_CPU_SUBTYPE_SH7750 is not set
131# CONFIG_CPU_SUBTYPE_SH7091 is not set
132# CONFIG_CPU_SUBTYPE_SH7750R is not set
133# CONFIG_CPU_SUBTYPE_SH7750S is not set
134# CONFIG_CPU_SUBTYPE_SH7751 is not set
135# CONFIG_CPU_SUBTYPE_SH7751R is not set
136# CONFIG_CPU_SUBTYPE_SH7760 is not set
137# CONFIG_CPU_SUBTYPE_SH4_202 is not set
138# CONFIG_CPU_SUBTYPE_SH7763 is not set
139# CONFIG_CPU_SUBTYPE_SH7770 is not set
140# CONFIG_CPU_SUBTYPE_SH7780 is not set
141# CONFIG_CPU_SUBTYPE_SH7785 is not set
142# CONFIG_CPU_SUBTYPE_SHX3 is not set
143# CONFIG_CPU_SUBTYPE_SH7343 is not set
144CONFIG_CPU_SUBTYPE_SH7722=y
145# CONFIG_CPU_SUBTYPE_SH5_101 is not set
146# CONFIG_CPU_SUBTYPE_SH5_103 is not set
147
148#
149# Memory management options
150#
151CONFIG_QUICKLIST=y
152CONFIG_MMU=y
153CONFIG_PAGE_OFFSET=0x80000000
154CONFIG_MEMORY_START=0x0c000000
155CONFIG_MEMORY_SIZE=0x04000000
156CONFIG_29BIT=y
157# CONFIG_X2TLB is not set
158CONFIG_VSYSCALL=y
159CONFIG_NUMA=y
160CONFIG_NODES_SHIFT=1
161CONFIG_ARCH_SPARSEMEM_ENABLE=y
162CONFIG_ARCH_SPARSEMEM_DEFAULT=y
163CONFIG_MAX_ACTIVE_REGIONS=2
164CONFIG_ARCH_POPULATES_NODE_MAP=y
165CONFIG_ARCH_SELECT_MEMORY_MODEL=y
166CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
167CONFIG_PAGE_SIZE_4KB=y
168# CONFIG_PAGE_SIZE_8KB is not set
169# CONFIG_PAGE_SIZE_64KB is not set
170CONFIG_SELECT_MEMORY_MODEL=y
171# CONFIG_FLATMEM_MANUAL is not set
172# CONFIG_DISCONTIGMEM_MANUAL is not set
173CONFIG_SPARSEMEM_MANUAL=y
174CONFIG_SPARSEMEM=y
175CONFIG_NEED_MULTIPLE_NODES=y
176CONFIG_HAVE_MEMORY_PRESENT=y
177CONFIG_SPARSEMEM_STATIC=y
178# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
179# CONFIG_MEMORY_HOTPLUG is not set
180CONFIG_SPLIT_PTLOCK_CPUS=4
181# CONFIG_MIGRATION is not set
182# CONFIG_RESOURCES_64BIT is not set
183CONFIG_ZONE_DMA_FLAG=0
184CONFIG_NR_QUICK=2
185
186#
187# Cache configuration
188#
189# CONFIG_SH_DIRECT_MAPPED is not set
190CONFIG_CACHE_WRITEBACK=y
191# CONFIG_CACHE_WRITETHROUGH is not set
192# CONFIG_CACHE_OFF is not set
193
194#
195# Processor features
196#
197CONFIG_CPU_LITTLE_ENDIAN=y
198# CONFIG_CPU_BIG_ENDIAN is not set
199# CONFIG_SH_FPU_EMU is not set
200CONFIG_SH_DSP=y
201# CONFIG_SH_STORE_QUEUES is not set
202CONFIG_CPU_HAS_INTEVT=y
203CONFIG_CPU_HAS_SR_RB=y
204CONFIG_CPU_HAS_PTEA=y
205CONFIG_CPU_HAS_DSP=y
206
207#
208# Board support
209#
210# CONFIG_SH_7722_SOLUTION_ENGINE is not set
211CONFIG_SH_MIGOR=y
212
213#
214# Timer and clock configuration
215#
216CONFIG_SH_TMU=y
217CONFIG_SH_TIMER_IRQ=16
218CONFIG_SH_PCLK_FREQ=33333333
219# CONFIG_TICK_ONESHOT is not set
220# CONFIG_NO_HZ is not set
221# CONFIG_HIGH_RES_TIMERS is not set
222CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
223
224#
225# CPU Frequency scaling
226#
227# CONFIG_CPU_FREQ is not set
228
229#
230# DMA support
231#
232# CONFIG_SH_DMA is not set
233
234#
235# Companion Chips
236#
237
238#
239# Additional SuperH Device Drivers
240#
241# CONFIG_HEARTBEAT is not set
242# CONFIG_PUSH_SWITCH is not set
243
244#
245# Kernel features
246#
247# CONFIG_HZ_100 is not set
248CONFIG_HZ_250=y
249# CONFIG_HZ_300 is not set
250# CONFIG_HZ_1000 is not set
251CONFIG_HZ=250
252# CONFIG_SCHED_HRTICK is not set
253# CONFIG_KEXEC is not set
254# CONFIG_CRASH_DUMP is not set
255CONFIG_PREEMPT_NONE=y
256# CONFIG_PREEMPT_VOLUNTARY is not set
257# CONFIG_PREEMPT is not set
258CONFIG_RCU_TRACE=y
259CONFIG_GUSA=y
260
261#
262# Boot options
263#
264CONFIG_ZERO_PAGE_OFFSET=0x00001000
265CONFIG_BOOT_LINK_OFFSET=0x00800000
266CONFIG_CMDLINE_BOOL=y
267CONFIG_CMDLINE="console=ttySC0,115200 earlyprintk=serial ip=on"
268
269#
270# Bus options
271#
272# CONFIG_ARCH_SUPPORTS_MSI is not set
273# CONFIG_PCCARD is not set
274
275#
276# Executable file formats
277#
278CONFIG_BINFMT_ELF=y
279# CONFIG_BINFMT_MISC is not set
280
281#
282# Networking
283#
284CONFIG_NET=y
285
286#
287# Networking options
288#
289CONFIG_PACKET=y
290# CONFIG_PACKET_MMAP is not set
291CONFIG_UNIX=y
292CONFIG_XFRM=y
293# CONFIG_XFRM_USER is not set
294# CONFIG_XFRM_SUB_POLICY is not set
295# CONFIG_XFRM_MIGRATE is not set
296# CONFIG_XFRM_STATISTICS is not set
297# CONFIG_NET_KEY is not set
298CONFIG_INET=y
299# CONFIG_IP_MULTICAST is not set
300# CONFIG_IP_ADVANCED_ROUTER is not set
301CONFIG_IP_FIB_HASH=y
302CONFIG_IP_PNP=y
303CONFIG_IP_PNP_DHCP=y
304# CONFIG_IP_PNP_BOOTP is not set
305# CONFIG_IP_PNP_RARP is not set
306# CONFIG_NET_IPIP is not set
307# CONFIG_NET_IPGRE is not set
308# CONFIG_ARPD is not set
309# CONFIG_SYN_COOKIES is not set
310# CONFIG_INET_AH is not set
311# CONFIG_INET_ESP is not set
312# CONFIG_INET_IPCOMP is not set
313# CONFIG_INET_XFRM_TUNNEL is not set
314# CONFIG_INET_TUNNEL is not set
315CONFIG_INET_XFRM_MODE_TRANSPORT=y
316CONFIG_INET_XFRM_MODE_TUNNEL=y
317CONFIG_INET_XFRM_MODE_BEET=y
318# CONFIG_INET_LRO is not set
319CONFIG_INET_DIAG=y
320CONFIG_INET_TCP_DIAG=y
321# CONFIG_TCP_CONG_ADVANCED is not set
322CONFIG_TCP_CONG_CUBIC=y
323CONFIG_DEFAULT_TCP_CONG="cubic"
324# CONFIG_TCP_MD5SIG is not set
325# CONFIG_IPV6 is not set
326# CONFIG_INET6_XFRM_TUNNEL is not set
327# CONFIG_INET6_TUNNEL is not set
328# CONFIG_NETWORK_SECMARK is not set
329# CONFIG_NETFILTER is not set
330# CONFIG_IP_DCCP is not set
331# CONFIG_IP_SCTP is not set
332# CONFIG_TIPC is not set
333# CONFIG_ATM is not set
334# CONFIG_BRIDGE is not set
335# CONFIG_VLAN_8021Q is not set
336# CONFIG_DECNET is not set
337# CONFIG_LLC2 is not set
338# CONFIG_IPX is not set
339# CONFIG_ATALK is not set
340# CONFIG_X25 is not set
341# CONFIG_LAPB is not set
342# CONFIG_ECONET is not set
343# CONFIG_WAN_ROUTER is not set
344# CONFIG_NET_SCHED is not set
345
346#
347# Network testing
348#
349# CONFIG_NET_PKTGEN is not set
350# CONFIG_HAMRADIO is not set
351# CONFIG_CAN is not set
352# CONFIG_IRDA is not set
353# CONFIG_BT is not set
354# CONFIG_AF_RXRPC is not set
355
356#
357# Wireless
358#
359# CONFIG_CFG80211 is not set
360CONFIG_WIRELESS_EXT=y
361# CONFIG_MAC80211 is not set
362# CONFIG_IEEE80211 is not set
363# CONFIG_RFKILL is not set
364# CONFIG_NET_9P is not set
365
366#
367# Device Drivers
368#
369
370#
371# Generic Driver Options
372#
373CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
374CONFIG_STANDALONE=y
375CONFIG_PREVENT_FIRMWARE_BUILD=y
376CONFIG_FW_LOADER=m
377# CONFIG_SYS_HYPERVISOR is not set
378# CONFIG_CONNECTOR is not set
379# CONFIG_MTD is not set
380# CONFIG_PARPORT is not set
381CONFIG_BLK_DEV=y
382# CONFIG_BLK_DEV_COW_COMMON is not set
383# CONFIG_BLK_DEV_LOOP is not set
384# CONFIG_BLK_DEV_NBD is not set
385CONFIG_BLK_DEV_RAM=y
386CONFIG_BLK_DEV_RAM_COUNT=16
387CONFIG_BLK_DEV_RAM_SIZE=4096
388CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
389# CONFIG_CDROM_PKTCDVD is not set
390# CONFIG_ATA_OVER_ETH is not set
391CONFIG_MISC_DEVICES=y
392# CONFIG_EEPROM_93CX6 is not set
393# CONFIG_IDE is not set
394
395#
396# SCSI device support
397#
398# CONFIG_RAID_ATTRS is not set
399CONFIG_SCSI=y
400CONFIG_SCSI_DMA=y
401# CONFIG_SCSI_TGT is not set
402# CONFIG_SCSI_NETLINK is not set
403CONFIG_SCSI_PROC_FS=y
404
405#
406# SCSI support type (disk, tape, CD-ROM)
407#
408CONFIG_BLK_DEV_SD=y
409# CONFIG_CHR_DEV_ST is not set
410# CONFIG_CHR_DEV_OSST is not set
411# CONFIG_BLK_DEV_SR is not set
412# CONFIG_CHR_DEV_SG is not set
413# CONFIG_CHR_DEV_SCH is not set
414
415#
416# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
417#
418# CONFIG_SCSI_MULTI_LUN is not set
419# CONFIG_SCSI_CONSTANTS is not set
420# CONFIG_SCSI_LOGGING is not set
421# CONFIG_SCSI_SCAN_ASYNC is not set
422CONFIG_SCSI_WAIT_SCAN=m
423
424#
425# SCSI Transports
426#
427# CONFIG_SCSI_SPI_ATTRS is not set
428# CONFIG_SCSI_FC_ATTRS is not set
429# CONFIG_SCSI_ISCSI_ATTRS is not set
430# CONFIG_SCSI_SAS_LIBSAS is not set
431# CONFIG_SCSI_SRP_ATTRS is not set
432CONFIG_SCSI_LOWLEVEL=y
433# CONFIG_ISCSI_TCP is not set
434# CONFIG_SCSI_DEBUG is not set
435# CONFIG_ATA is not set
436# CONFIG_MD is not set
437CONFIG_NETDEVICES=y
438# CONFIG_NETDEVICES_MULTIQUEUE is not set
439# CONFIG_DUMMY is not set
440# CONFIG_BONDING is not set
441# CONFIG_MACVLAN is not set
442# CONFIG_EQUALIZER is not set
443# CONFIG_TUN is not set
444# CONFIG_VETH is not set
445# CONFIG_PHYLIB is not set
446CONFIG_NET_ETHERNET=y
447CONFIG_MII=y
448# CONFIG_AX88796 is not set
449# CONFIG_STNIC is not set
450CONFIG_SMC91X=y
451# CONFIG_IBM_NEW_EMAC_ZMII is not set
452# CONFIG_IBM_NEW_EMAC_RGMII is not set
453# CONFIG_IBM_NEW_EMAC_TAH is not set
454# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
455# CONFIG_B44 is not set
456# CONFIG_NETDEV_1000 is not set
457# CONFIG_NETDEV_10000 is not set
458
459#
460# Wireless LAN
461#
462# CONFIG_WLAN_PRE80211 is not set
463# CONFIG_WLAN_80211 is not set
464# CONFIG_WAN is not set
465# CONFIG_PPP is not set
466# CONFIG_SLIP is not set
467# CONFIG_NETCONSOLE is not set
468# CONFIG_NETPOLL is not set
469# CONFIG_NET_POLL_CONTROLLER is not set
470# CONFIG_ISDN is not set
471# CONFIG_PHONE is not set
472
473#
474# Input device support
475#
476CONFIG_INPUT=y
477# CONFIG_INPUT_FF_MEMLESS is not set
478# CONFIG_INPUT_POLLDEV is not set
479
480#
481# Userland interfaces
482#
483# CONFIG_INPUT_MOUSEDEV is not set
484# CONFIG_INPUT_JOYDEV is not set
485# CONFIG_INPUT_EVDEV is not set
486# CONFIG_INPUT_EVBUG is not set
487
488#
489# Input Device Drivers
490#
491# CONFIG_INPUT_KEYBOARD is not set
492# CONFIG_INPUT_MOUSE is not set
493# CONFIG_INPUT_JOYSTICK is not set
494# CONFIG_INPUT_TABLET is not set
495# CONFIG_INPUT_TOUCHSCREEN is not set
496# CONFIG_INPUT_MISC is not set
497
498#
499# Hardware I/O ports
500#
501# CONFIG_SERIO is not set
502# CONFIG_GAMEPORT is not set
503
504#
505# Character devices
506#
507CONFIG_VT=y
508CONFIG_VT_CONSOLE=y
509CONFIG_HW_CONSOLE=y
510CONFIG_VT_HW_CONSOLE_BINDING=y
511# CONFIG_SERIAL_NONSTANDARD is not set
512
513#
514# Serial drivers
515#
516# CONFIG_SERIAL_8250 is not set
517
518#
519# Non-8250 serial port support
520#
521CONFIG_SERIAL_SH_SCI=y
522CONFIG_SERIAL_SH_SCI_NR_UARTS=3
523CONFIG_SERIAL_SH_SCI_CONSOLE=y
524CONFIG_SERIAL_CORE=y
525CONFIG_SERIAL_CORE_CONSOLE=y
526CONFIG_UNIX98_PTYS=y
527CONFIG_LEGACY_PTYS=y
528CONFIG_LEGACY_PTY_COUNT=256
529# CONFIG_IPMI_HANDLER is not set
530CONFIG_HW_RANDOM=y
531# CONFIG_R3964 is not set
532# CONFIG_RAW_DRIVER is not set
533# CONFIG_TCG_TPM is not set
534# CONFIG_I2C is not set
535
536#
537# SPI support
538#
539# CONFIG_SPI is not set
540# CONFIG_SPI_MASTER is not set
541# CONFIG_W1 is not set
542# CONFIG_POWER_SUPPLY is not set
543# CONFIG_HWMON is not set
544# CONFIG_WATCHDOG is not set
545
546#
547# Sonics Silicon Backplane
548#
549CONFIG_SSB_POSSIBLE=y
550# CONFIG_SSB is not set
551
552#
553# Multifunction device drivers
554#
555# CONFIG_MFD_SM501 is not set
556
557#
558# Multimedia devices
559#
560# CONFIG_VIDEO_DEV is not set
561# CONFIG_DVB_CORE is not set
562# CONFIG_DAB is not set
563
564#
565# Graphics support
566#
567# CONFIG_VGASTATE is not set
568# CONFIG_VIDEO_OUTPUT_CONTROL is not set
569# CONFIG_FB is not set
570# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
571
572#
573# Display device support
574#
575# CONFIG_DISPLAY_SUPPORT is not set
576
577#
578# Console display driver support
579#
580CONFIG_DUMMY_CONSOLE=y
581
582#
583# Sound
584#
585# CONFIG_SOUND is not set
586CONFIG_HID_SUPPORT=y
587CONFIG_HID=y
588# CONFIG_HID_DEBUG is not set
589# CONFIG_HIDRAW is not set
590CONFIG_USB_SUPPORT=y
591CONFIG_USB_ARCH_HAS_HCD=y
592# CONFIG_USB_ARCH_HAS_OHCI is not set
593# CONFIG_USB_ARCH_HAS_EHCI is not set
594# CONFIG_USB is not set
595
596#
597# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
598#
599CONFIG_USB_GADGET=y
600# CONFIG_USB_GADGET_DEBUG_FILES is not set
601# CONFIG_USB_GADGET_DEBUG_FS is not set
602CONFIG_USB_GADGET_SELECTED=y
603# CONFIG_USB_GADGET_AMD5536UDC is not set
604# CONFIG_USB_GADGET_ATMEL_USBA is not set
605# CONFIG_USB_GADGET_FSL_USB2 is not set
606# CONFIG_USB_GADGET_NET2280 is not set
607# CONFIG_USB_GADGET_PXA2XX is not set
608CONFIG_USB_GADGET_M66592=y
609CONFIG_USB_M66592=y
610CONFIG_SUPERH_BUILT_IN_M66592=y
611# CONFIG_USB_GADGET_GOKU is not set
612# CONFIG_USB_GADGET_LH7A40X is not set
613# CONFIG_USB_GADGET_OMAP is not set
614# CONFIG_USB_GADGET_S3C2410 is not set
615# CONFIG_USB_GADGET_AT91 is not set
616# CONFIG_USB_GADGET_DUMMY_HCD is not set
617CONFIG_USB_GADGET_DUALSPEED=y
618# CONFIG_USB_ZERO is not set
619# CONFIG_USB_ETH is not set
620# CONFIG_USB_GADGETFS is not set
621# CONFIG_USB_FILE_STORAGE is not set
622CONFIG_USB_G_SERIAL=y
623# CONFIG_USB_MIDI_GADGET is not set
624# CONFIG_USB_G_PRINTER is not set
625# CONFIG_MMC is not set
626# CONFIG_NEW_LEDS is not set
627CONFIG_RTC_LIB=y
628CONFIG_RTC_CLASS=y
629CONFIG_RTC_HCTOSYS=y
630CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
631# CONFIG_RTC_DEBUG is not set
632
633#
634# RTC interfaces
635#
636CONFIG_RTC_INTF_SYSFS=y
637CONFIG_RTC_INTF_PROC=y
638CONFIG_RTC_INTF_DEV=y
639# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
640# CONFIG_RTC_DRV_TEST is not set
641
642#
643# SPI RTC drivers
644#
645
646#
647# Platform RTC drivers
648#
649# CONFIG_RTC_DRV_DS1553 is not set
650# CONFIG_RTC_DRV_STK17TA8 is not set
651# CONFIG_RTC_DRV_DS1742 is not set
652# CONFIG_RTC_DRV_M48T86 is not set
653# CONFIG_RTC_DRV_M48T59 is not set
654# CONFIG_RTC_DRV_V3020 is not set
655
656#
657# on-CPU RTC drivers
658#
659CONFIG_RTC_DRV_SH=y
660
661#
662# Userspace I/O
663#
664# CONFIG_UIO is not set
665
666#
667# File systems
668#
669# CONFIG_EXT2_FS is not set
670# CONFIG_EXT3_FS is not set
671# CONFIG_EXT4DEV_FS is not set
672# CONFIG_REISERFS_FS is not set
673# CONFIG_JFS_FS is not set
674# CONFIG_FS_POSIX_ACL is not set
675# CONFIG_XFS_FS is not set
676# CONFIG_GFS2_FS is not set
677# CONFIG_OCFS2_FS is not set
678# CONFIG_MINIX_FS is not set
679# CONFIG_ROMFS_FS is not set
680# CONFIG_INOTIFY is not set
681# CONFIG_QUOTA is not set
682# CONFIG_DNOTIFY is not set
683# CONFIG_AUTOFS_FS is not set
684# CONFIG_AUTOFS4_FS is not set
685# CONFIG_FUSE_FS is not set
686
687#
688# CD-ROM/DVD Filesystems
689#
690# CONFIG_ISO9660_FS is not set
691# CONFIG_UDF_FS is not set
692
693#
694# DOS/FAT/NT Filesystems
695#
696# CONFIG_MSDOS_FS is not set
697# CONFIG_VFAT_FS is not set
698# CONFIG_NTFS_FS is not set
699
700#
701# Pseudo filesystems
702#
703CONFIG_PROC_FS=y
704CONFIG_PROC_KCORE=y
705CONFIG_PROC_SYSCTL=y
706CONFIG_SYSFS=y
707CONFIG_TMPFS=y
708# CONFIG_TMPFS_POSIX_ACL is not set
709# CONFIG_HUGETLBFS is not set
710# CONFIG_HUGETLB_PAGE is not set
711# CONFIG_CONFIGFS_FS is not set
712
713#
714# Miscellaneous filesystems
715#
716# CONFIG_ADFS_FS is not set
717# CONFIG_AFFS_FS is not set
718# CONFIG_HFS_FS is not set
719# CONFIG_HFSPLUS_FS is not set
720# CONFIG_BEFS_FS is not set
721# CONFIG_BFS_FS is not set
722# CONFIG_EFS_FS is not set
723# CONFIG_CRAMFS is not set
724# CONFIG_VXFS_FS is not set
725# CONFIG_HPFS_FS is not set
726# CONFIG_QNX4FS_FS is not set
727# CONFIG_SYSV_FS is not set
728# CONFIG_UFS_FS is not set
729# CONFIG_NETWORK_FILESYSTEMS is not set
730
731#
732# Partition Types
733#
734# CONFIG_PARTITION_ADVANCED is not set
735CONFIG_MSDOS_PARTITION=y
736# CONFIG_NLS is not set
737# CONFIG_DLM is not set
738
739#
740# Kernel hacking
741#
742CONFIG_TRACE_IRQFLAGS_SUPPORT=y
743# CONFIG_PRINTK_TIME is not set
744CONFIG_ENABLE_WARN_DEPRECATED=y
745CONFIG_ENABLE_MUST_CHECK=y
746# CONFIG_MAGIC_SYSRQ is not set
747# CONFIG_UNUSED_SYMBOLS is not set
748CONFIG_DEBUG_FS=y
749# CONFIG_HEADERS_CHECK is not set
750# CONFIG_DEBUG_KERNEL is not set
751# CONFIG_DEBUG_BUGVERBOSE is not set
752# CONFIG_SAMPLES is not set
753# CONFIG_SH_STANDARD_BIOS is not set
754CONFIG_EARLY_SCIF_CONSOLE=y
755CONFIG_EARLY_SCIF_CONSOLE_PORT=0xffe00000
756CONFIG_EARLY_PRINTK=y
757# CONFIG_SH_KGDB is not set
758
759#
760# Security options
761#
762# CONFIG_KEYS is not set
763# CONFIG_SECURITY is not set
764# CONFIG_SECURITY_FILE_CAPABILITIES is not set
765CONFIG_CRYPTO=y
766# CONFIG_CRYPTO_SEQIV is not set
767# CONFIG_CRYPTO_MANAGER is not set
768# CONFIG_CRYPTO_HMAC is not set
769# CONFIG_CRYPTO_XCBC is not set
770# CONFIG_CRYPTO_NULL is not set
771# CONFIG_CRYPTO_MD4 is not set
772# CONFIG_CRYPTO_MD5 is not set
773# CONFIG_CRYPTO_SHA1 is not set
774# CONFIG_CRYPTO_SHA256 is not set
775# CONFIG_CRYPTO_SHA512 is not set
776# CONFIG_CRYPTO_WP512 is not set
777# CONFIG_CRYPTO_TGR192 is not set
778# CONFIG_CRYPTO_GF128MUL is not set
779# CONFIG_CRYPTO_ECB is not set
780# CONFIG_CRYPTO_CBC is not set
781# CONFIG_CRYPTO_PCBC is not set
782# CONFIG_CRYPTO_LRW is not set
783# CONFIG_CRYPTO_XTS is not set
784# CONFIG_CRYPTO_CTR is not set
785# CONFIG_CRYPTO_GCM is not set
786# CONFIG_CRYPTO_CCM is not set
787# CONFIG_CRYPTO_CRYPTD is not set
788# CONFIG_CRYPTO_DES is not set
789# CONFIG_CRYPTO_FCRYPT is not set
790# CONFIG_CRYPTO_BLOWFISH is not set
791# CONFIG_CRYPTO_TWOFISH is not set
792# CONFIG_CRYPTO_SERPENT is not set
793# CONFIG_CRYPTO_AES is not set
794# CONFIG_CRYPTO_CAST5 is not set
795# CONFIG_CRYPTO_CAST6 is not set
796# CONFIG_CRYPTO_TEA is not set
797# CONFIG_CRYPTO_ARC4 is not set
798# CONFIG_CRYPTO_KHAZAD is not set
799# CONFIG_CRYPTO_ANUBIS is not set
800# CONFIG_CRYPTO_SEED is not set
801# CONFIG_CRYPTO_SALSA20 is not set
802# CONFIG_CRYPTO_DEFLATE is not set
803# CONFIG_CRYPTO_MICHAEL_MIC is not set
804# CONFIG_CRYPTO_CRC32C is not set
805# CONFIG_CRYPTO_CAMELLIA is not set
806# CONFIG_CRYPTO_TEST is not set
807# CONFIG_CRYPTO_AUTHENC is not set
808# CONFIG_CRYPTO_LZO is not set
809CONFIG_CRYPTO_HW=y
810
811#
812# Library routines
813#
814CONFIG_BITREVERSE=y
815# CONFIG_CRC_CCITT is not set
816# CONFIG_CRC16 is not set
817# CONFIG_CRC_ITU_T is not set
818CONFIG_CRC32=y
819# CONFIG_CRC7 is not set
820# CONFIG_LIBCRC32C is not set
821CONFIG_PLIST=y
822CONFIG_HAS_IOMEM=y
823CONFIG_HAS_IOPORT=y
824CONFIG_HAS_DMA=y
diff --git a/arch/sh/configs/rts7751r2d1_defconfig b/arch/sh/configs/rts7751r2d1_defconfig
index 2dc754e5b733..3a915fd436d9 100644
--- a/arch/sh/configs/rts7751r2d1_defconfig
+++ b/arch/sh/configs/rts7751r2d1_defconfig
@@ -1,9 +1,10 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.23-rc2 3# Linux kernel version: 2.6.24
4# Tue Aug 14 18:04:44 2007 4# Thu Feb 7 16:25:55 2008
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 8CONFIG_RWSEM_GENERIC_SPINLOCK=y
8CONFIG_GENERIC_BUG=y 9CONFIG_GENERIC_BUG=y
9CONFIG_GENERIC_FIND_NEXT_BIT=y 10CONFIG_GENERIC_FIND_NEXT_BIT=y
@@ -36,9 +37,14 @@ CONFIG_SYSVIPC_SYSCTL=y
36# CONFIG_BSD_PROCESS_ACCT is not set 37# CONFIG_BSD_PROCESS_ACCT is not set
37# CONFIG_TASKSTATS is not set 38# CONFIG_TASKSTATS is not set
38# CONFIG_USER_NS is not set 39# CONFIG_USER_NS is not set
40# CONFIG_PID_NS is not set
39# CONFIG_AUDIT is not set 41# CONFIG_AUDIT is not set
40# CONFIG_IKCONFIG is not set 42# CONFIG_IKCONFIG is not set
41CONFIG_LOG_BUF_SHIFT=14 43CONFIG_LOG_BUF_SHIFT=14
44# CONFIG_CGROUPS is not set
45CONFIG_FAIR_GROUP_SCHED=y
46CONFIG_FAIR_USER_SCHED=y
47# CONFIG_FAIR_CGROUP_SCHED is not set
42CONFIG_SYSFS_DEPRECATED=y 48CONFIG_SYSFS_DEPRECATED=y
43# CONFIG_RELAY is not set 49# CONFIG_RELAY is not set
44# CONFIG_BLK_DEV_INITRD is not set 50# CONFIG_BLK_DEV_INITRD is not set
@@ -53,6 +59,7 @@ CONFIG_HOTPLUG=y
53CONFIG_PRINTK=y 59CONFIG_PRINTK=y
54CONFIG_BUG=y 60CONFIG_BUG=y
55CONFIG_ELF_CORE=y 61CONFIG_ELF_CORE=y
62CONFIG_COMPAT_BRK=y
56CONFIG_BASE_FULL=y 63CONFIG_BASE_FULL=y
57CONFIG_FUTEX=y 64CONFIG_FUTEX=y
58CONFIG_ANON_INODES=y 65CONFIG_ANON_INODES=y
@@ -65,6 +72,13 @@ CONFIG_VM_EVENT_COUNTERS=y
65CONFIG_SLAB=y 72CONFIG_SLAB=y
66# CONFIG_SLUB is not set 73# CONFIG_SLUB is not set
67# CONFIG_SLOB is not set 74# CONFIG_SLOB is not set
75CONFIG_PROFILING=y
76# CONFIG_MARKERS is not set
77CONFIG_OPROFILE=y
78CONFIG_HAVE_OPROFILE=y
79# CONFIG_HAVE_KPROBES is not set
80CONFIG_PROC_PAGE_MONITOR=y
81CONFIG_SLABINFO=y
68CONFIG_RT_MUTEXES=y 82CONFIG_RT_MUTEXES=y
69# CONFIG_TINY_SHMEM is not set 83# CONFIG_TINY_SHMEM is not set
70CONFIG_BASE_SMALL=0 84CONFIG_BASE_SMALL=0
@@ -91,13 +105,17 @@ CONFIG_DEFAULT_AS=y
91# CONFIG_DEFAULT_CFQ is not set 105# CONFIG_DEFAULT_CFQ is not set
92# CONFIG_DEFAULT_NOOP is not set 106# CONFIG_DEFAULT_NOOP is not set
93CONFIG_DEFAULT_IOSCHED="anticipatory" 107CONFIG_DEFAULT_IOSCHED="anticipatory"
108CONFIG_CLASSIC_RCU=y
109# CONFIG_PREEMPT_RCU is not set
94 110
95# 111#
96# System type 112# System type
97# 113#
98CONFIG_CPU_SH4=y 114CONFIG_CPU_SH4=y
99# CONFIG_CPU_SUBTYPE_SH7619 is not set 115# CONFIG_CPU_SUBTYPE_SH7619 is not set
116# CONFIG_CPU_SUBTYPE_SH7203 is not set
100# CONFIG_CPU_SUBTYPE_SH7206 is not set 117# CONFIG_CPU_SUBTYPE_SH7206 is not set
118# CONFIG_CPU_SUBTYPE_SH7263 is not set
101# CONFIG_CPU_SUBTYPE_SH7705 is not set 119# CONFIG_CPU_SUBTYPE_SH7705 is not set
102# CONFIG_CPU_SUBTYPE_SH7706 is not set 120# CONFIG_CPU_SUBTYPE_SH7706 is not set
103# CONFIG_CPU_SUBTYPE_SH7707 is not set 121# CONFIG_CPU_SUBTYPE_SH7707 is not set
@@ -105,6 +123,8 @@ CONFIG_CPU_SH4=y
105# CONFIG_CPU_SUBTYPE_SH7709 is not set 123# CONFIG_CPU_SUBTYPE_SH7709 is not set
106# CONFIG_CPU_SUBTYPE_SH7710 is not set 124# CONFIG_CPU_SUBTYPE_SH7710 is not set
107# CONFIG_CPU_SUBTYPE_SH7712 is not set 125# CONFIG_CPU_SUBTYPE_SH7712 is not set
126# CONFIG_CPU_SUBTYPE_SH7720 is not set
127# CONFIG_CPU_SUBTYPE_SH7721 is not set
108# CONFIG_CPU_SUBTYPE_SH7750 is not set 128# CONFIG_CPU_SUBTYPE_SH7750 is not set
109# CONFIG_CPU_SUBTYPE_SH7091 is not set 129# CONFIG_CPU_SUBTYPE_SH7091 is not set
110# CONFIG_CPU_SUBTYPE_SH7750R is not set 130# CONFIG_CPU_SUBTYPE_SH7750R is not set
@@ -113,14 +133,15 @@ CONFIG_CPU_SH4=y
113CONFIG_CPU_SUBTYPE_SH7751R=y 133CONFIG_CPU_SUBTYPE_SH7751R=y
114# CONFIG_CPU_SUBTYPE_SH7760 is not set 134# CONFIG_CPU_SUBTYPE_SH7760 is not set
115# CONFIG_CPU_SUBTYPE_SH4_202 is not set 135# CONFIG_CPU_SUBTYPE_SH4_202 is not set
116# CONFIG_CPU_SUBTYPE_ST40STB1 is not set 136# CONFIG_CPU_SUBTYPE_SH7763 is not set
117# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
118# CONFIG_CPU_SUBTYPE_SH7770 is not set 137# CONFIG_CPU_SUBTYPE_SH7770 is not set
119# CONFIG_CPU_SUBTYPE_SH7780 is not set 138# CONFIG_CPU_SUBTYPE_SH7780 is not set
120# CONFIG_CPU_SUBTYPE_SH7785 is not set 139# CONFIG_CPU_SUBTYPE_SH7785 is not set
121# CONFIG_CPU_SUBTYPE_SHX3 is not set 140# CONFIG_CPU_SUBTYPE_SHX3 is not set
122# CONFIG_CPU_SUBTYPE_SH7343 is not set 141# CONFIG_CPU_SUBTYPE_SH7343 is not set
123# CONFIG_CPU_SUBTYPE_SH7722 is not set 142# CONFIG_CPU_SUBTYPE_SH7722 is not set
143# CONFIG_CPU_SUBTYPE_SH5_101 is not set
144# CONFIG_CPU_SUBTYPE_SH5_103 is not set
124 145
125# 146#
126# Memory management options 147# Memory management options
@@ -130,6 +151,7 @@ CONFIG_MMU=y
130CONFIG_PAGE_OFFSET=0x80000000 151CONFIG_PAGE_OFFSET=0x80000000
131CONFIG_MEMORY_START=0x0c000000 152CONFIG_MEMORY_START=0x0c000000
132CONFIG_MEMORY_SIZE=0x04000000 153CONFIG_MEMORY_SIZE=0x04000000
154CONFIG_29BIT=y
133CONFIG_VSYSCALL=y 155CONFIG_VSYSCALL=y
134CONFIG_ARCH_FLATMEM_ENABLE=y 156CONFIG_ARCH_FLATMEM_ENABLE=y
135CONFIG_ARCH_SPARSEMEM_ENABLE=y 157CONFIG_ARCH_SPARSEMEM_ENABLE=y
@@ -147,6 +169,7 @@ CONFIG_FLATMEM_MANUAL=y
147CONFIG_FLATMEM=y 169CONFIG_FLATMEM=y
148CONFIG_FLAT_NODE_MEM_MAP=y 170CONFIG_FLAT_NODE_MEM_MAP=y
149CONFIG_SPARSEMEM_STATIC=y 171CONFIG_SPARSEMEM_STATIC=y
172# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
150CONFIG_SPLIT_PTLOCK_CPUS=4 173CONFIG_SPLIT_PTLOCK_CPUS=4
151# CONFIG_RESOURCES_64BIT is not set 174# CONFIG_RESOURCES_64BIT is not set
152CONFIG_ZONE_DMA_FLAG=0 175CONFIG_ZONE_DMA_FLAG=0
@@ -168,23 +191,22 @@ CONFIG_CPU_LITTLE_ENDIAN=y
168CONFIG_SH_FPU=y 191CONFIG_SH_FPU=y
169# CONFIG_SH_STORE_QUEUES is not set 192# CONFIG_SH_STORE_QUEUES is not set
170CONFIG_CPU_HAS_INTEVT=y 193CONFIG_CPU_HAS_INTEVT=y
171CONFIG_CPU_HAS_INTC_IRQ=y
172CONFIG_CPU_HAS_SR_RB=y 194CONFIG_CPU_HAS_SR_RB=y
173CONFIG_CPU_HAS_PTEA=y 195CONFIG_CPU_HAS_PTEA=y
196CONFIG_CPU_HAS_FPU=y
174 197
175# 198#
176# Board support 199# Board support
177# 200#
178# CONFIG_SH_7751_SYSTEMH is not set 201# CONFIG_SH_7751_SYSTEMH is not set
179# CONFIG_SH_SECUREEDGE5410 is not set 202# CONFIG_SH_SECUREEDGE5410 is not set
180# CONFIG_SH_HS7751RVOIP is not set
181CONFIG_SH_RTS7751R2D=y 203CONFIG_SH_RTS7751R2D=y
182# CONFIG_SH_LANDISK is not set 204# CONFIG_SH_LANDISK is not set
183# CONFIG_SH_TITAN is not set 205# CONFIG_SH_TITAN is not set
184# CONFIG_SH_LBOX_RE2 is not set 206# CONFIG_SH_LBOX_RE2 is not set
185 207
186# 208#
187# RTS7751R2D options 209# RTS7751R2D Board Revision
188# 210#
189# CONFIG_RTS7751R2D_PLUS is not set 211# CONFIG_RTS7751R2D_PLUS is not set
190CONFIG_RTS7751R2D_1=y 212CONFIG_RTS7751R2D_1=y
@@ -198,6 +220,7 @@ CONFIG_SH_PCLK_FREQ=60000000
198# CONFIG_TICK_ONESHOT is not set 220# CONFIG_TICK_ONESHOT is not set
199# CONFIG_NO_HZ is not set 221# CONFIG_NO_HZ is not set
200# CONFIG_HIGH_RES_TIMERS is not set 222# CONFIG_HIGH_RES_TIMERS is not set
223CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
201 224
202# 225#
203# CPU Frequency scaling 226# CPU Frequency scaling
@@ -227,11 +250,15 @@ CONFIG_HZ_250=y
227# CONFIG_HZ_300 is not set 250# CONFIG_HZ_300 is not set
228# CONFIG_HZ_1000 is not set 251# CONFIG_HZ_1000 is not set
229CONFIG_HZ=250 252CONFIG_HZ=250
253# CONFIG_SCHED_HRTICK is not set
230# CONFIG_KEXEC is not set 254# CONFIG_KEXEC is not set
231# CONFIG_CRASH_DUMP is not set 255# CONFIG_CRASH_DUMP is not set
232CONFIG_PREEMPT_NONE=y 256CONFIG_PREEMPT_NONE=y
233# CONFIG_PREEMPT_VOLUNTARY is not set 257# CONFIG_PREEMPT_VOLUNTARY is not set
234# CONFIG_PREEMPT is not set 258# CONFIG_PREEMPT is not set
259CONFIG_RCU_TRACE=y
260CONFIG_GUSA=y
261# CONFIG_GUSA_RB is not set
235 262
236# 263#
237# Boot options 264# Boot options
@@ -250,10 +277,7 @@ CONFIG_SH_PCIDMA_NONCOHERENT=y
250CONFIG_PCI_AUTO=y 277CONFIG_PCI_AUTO=y
251CONFIG_PCI_AUTO_UPDATE_RESOURCES=y 278CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
252# CONFIG_ARCH_SUPPORTS_MSI is not set 279# CONFIG_ARCH_SUPPORTS_MSI is not set
253 280CONFIG_PCI_LEGACY=y
254#
255# PCCARD (PCMCIA/CardBus) support
256#
257# CONFIG_PCCARD is not set 281# CONFIG_PCCARD is not set
258CONFIG_HOTPLUG_PCI=y 282CONFIG_HOTPLUG_PCI=y
259# CONFIG_HOTPLUG_PCI_FAKE is not set 283# CONFIG_HOTPLUG_PCI_FAKE is not set
@@ -281,6 +305,7 @@ CONFIG_XFRM=y
281# CONFIG_XFRM_USER is not set 305# CONFIG_XFRM_USER is not set
282# CONFIG_XFRM_SUB_POLICY is not set 306# CONFIG_XFRM_SUB_POLICY is not set
283# CONFIG_XFRM_MIGRATE is not set 307# CONFIG_XFRM_MIGRATE is not set
308# CONFIG_XFRM_STATISTICS is not set
284# CONFIG_NET_KEY is not set 309# CONFIG_NET_KEY is not set
285CONFIG_INET=y 310CONFIG_INET=y
286# CONFIG_IP_MULTICAST is not set 311# CONFIG_IP_MULTICAST is not set
@@ -299,6 +324,7 @@ CONFIG_IP_FIB_HASH=y
299CONFIG_INET_XFRM_MODE_TRANSPORT=y 324CONFIG_INET_XFRM_MODE_TRANSPORT=y
300CONFIG_INET_XFRM_MODE_TUNNEL=y 325CONFIG_INET_XFRM_MODE_TUNNEL=y
301CONFIG_INET_XFRM_MODE_BEET=y 326CONFIG_INET_XFRM_MODE_BEET=y
327# CONFIG_INET_LRO is not set
302CONFIG_INET_DIAG=y 328CONFIG_INET_DIAG=y
303CONFIG_INET_TCP_DIAG=y 329CONFIG_INET_TCP_DIAG=y
304# CONFIG_TCP_CONG_ADVANCED is not set 330# CONFIG_TCP_CONG_ADVANCED is not set
@@ -324,10 +350,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
324# CONFIG_LAPB is not set 350# CONFIG_LAPB is not set
325# CONFIG_ECONET is not set 351# CONFIG_ECONET is not set
326# CONFIG_WAN_ROUTER is not set 352# CONFIG_WAN_ROUTER is not set
327
328#
329# QoS and/or fair queueing
330#
331# CONFIG_NET_SCHED is not set 353# CONFIG_NET_SCHED is not set
332 354
333# 355#
@@ -335,6 +357,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
335# 357#
336# CONFIG_NET_PKTGEN is not set 358# CONFIG_NET_PKTGEN is not set
337# CONFIG_HAMRADIO is not set 359# CONFIG_HAMRADIO is not set
360# CONFIG_CAN is not set
338# CONFIG_IRDA is not set 361# CONFIG_IRDA is not set
339# CONFIG_BT is not set 362# CONFIG_BT is not set
340# CONFIG_AF_RXRPC is not set 363# CONFIG_AF_RXRPC is not set
@@ -356,6 +379,7 @@ CONFIG_WIRELESS_EXT=y
356# 379#
357# Generic Driver Options 380# Generic Driver Options
358# 381#
382CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
359CONFIG_STANDALONE=y 383CONFIG_STANDALONE=y
360CONFIG_PREVENT_FIRMWARE_BUILD=y 384CONFIG_PREVENT_FIRMWARE_BUILD=y
361CONFIG_FW_LOADER=m 385CONFIG_FW_LOADER=m
@@ -371,6 +395,7 @@ CONFIG_BLK_DEV=y
371# CONFIG_BLK_DEV_LOOP is not set 395# CONFIG_BLK_DEV_LOOP is not set
372# CONFIG_BLK_DEV_NBD is not set 396# CONFIG_BLK_DEV_NBD is not set
373# CONFIG_BLK_DEV_SX8 is not set 397# CONFIG_BLK_DEV_SX8 is not set
398# CONFIG_BLK_DEV_UB is not set
374CONFIG_BLK_DEV_RAM=y 399CONFIG_BLK_DEV_RAM=y
375CONFIG_BLK_DEV_RAM_COUNT=16 400CONFIG_BLK_DEV_RAM_COUNT=16
376CONFIG_BLK_DEV_RAM_SIZE=4096 401CONFIG_BLK_DEV_RAM_SIZE=4096
@@ -420,6 +445,7 @@ CONFIG_SCSI_WAIT_SCAN=m
420# CONFIG_SCSI_FC_ATTRS is not set 445# CONFIG_SCSI_FC_ATTRS is not set
421# CONFIG_SCSI_ISCSI_ATTRS is not set 446# CONFIG_SCSI_ISCSI_ATTRS is not set
422# CONFIG_SCSI_SAS_LIBSAS is not set 447# CONFIG_SCSI_SAS_LIBSAS is not set
448# CONFIG_SCSI_SRP_ATTRS is not set
423CONFIG_SCSI_LOWLEVEL=y 449CONFIG_SCSI_LOWLEVEL=y
424# CONFIG_ISCSI_TCP is not set 450# CONFIG_ISCSI_TCP is not set
425# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 451# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
@@ -493,7 +519,9 @@ CONFIG_ATA=y
493# CONFIG_PATA_MPIIX is not set 519# CONFIG_PATA_MPIIX is not set
494# CONFIG_PATA_OLDPIIX is not set 520# CONFIG_PATA_OLDPIIX is not set
495# CONFIG_PATA_NETCELL is not set 521# CONFIG_PATA_NETCELL is not set
522# CONFIG_PATA_NINJA32 is not set
496# CONFIG_PATA_NS87410 is not set 523# CONFIG_PATA_NS87410 is not set
524# CONFIG_PATA_NS87415 is not set
497# CONFIG_PATA_OPTI is not set 525# CONFIG_PATA_OPTI is not set
498# CONFIG_PATA_OPTIDMA is not set 526# CONFIG_PATA_OPTIDMA is not set
499# CONFIG_PATA_PDC_OLD is not set 527# CONFIG_PATA_PDC_OLD is not set
@@ -508,14 +536,7 @@ CONFIG_ATA=y
508# CONFIG_PATA_WINBOND is not set 536# CONFIG_PATA_WINBOND is not set
509CONFIG_PATA_PLATFORM=y 537CONFIG_PATA_PLATFORM=y
510# CONFIG_MD is not set 538# CONFIG_MD is not set
511
512#
513# Fusion MPT device support
514#
515# CONFIG_FUSION is not set 539# CONFIG_FUSION is not set
516# CONFIG_FUSION_SPI is not set
517# CONFIG_FUSION_FC is not set
518# CONFIG_FUSION_SAS is not set
519 540
520# 541#
521# IEEE 1394 (FireWire) support 542# IEEE 1394 (FireWire) support
@@ -530,25 +551,31 @@ CONFIG_NETDEVICES=y
530# CONFIG_MACVLAN is not set 551# CONFIG_MACVLAN is not set
531# CONFIG_EQUALIZER is not set 552# CONFIG_EQUALIZER is not set
532# CONFIG_TUN is not set 553# CONFIG_TUN is not set
554# CONFIG_VETH is not set
533# CONFIG_ARCNET is not set 555# CONFIG_ARCNET is not set
534# CONFIG_PHYLIB is not set 556# CONFIG_PHYLIB is not set
535CONFIG_NET_ETHERNET=y 557CONFIG_NET_ETHERNET=y
536CONFIG_MII=y 558CONFIG_MII=y
559# CONFIG_AX88796 is not set
537# CONFIG_STNIC is not set 560# CONFIG_STNIC is not set
538# CONFIG_HAPPYMEAL is not set 561# CONFIG_HAPPYMEAL is not set
539# CONFIG_SUNGEM is not set 562# CONFIG_SUNGEM is not set
540# CONFIG_CASSINI is not set 563# CONFIG_CASSINI is not set
541# CONFIG_NET_VENDOR_3COM is not set 564# CONFIG_NET_VENDOR_3COM is not set
542# CONFIG_SMC91X is not set 565# CONFIG_SMC91X is not set
566# CONFIG_ENC28J60 is not set
543# CONFIG_NET_TULIP is not set 567# CONFIG_NET_TULIP is not set
544# CONFIG_HP100 is not set 568# CONFIG_HP100 is not set
569# CONFIG_IBM_NEW_EMAC_ZMII is not set
570# CONFIG_IBM_NEW_EMAC_RGMII is not set
571# CONFIG_IBM_NEW_EMAC_TAH is not set
572# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
545CONFIG_NET_PCI=y 573CONFIG_NET_PCI=y
546# CONFIG_PCNET32 is not set 574# CONFIG_PCNET32 is not set
547# CONFIG_AMD8111_ETH is not set 575# CONFIG_AMD8111_ETH is not set
548# CONFIG_ADAPTEC_STARFIRE is not set 576# CONFIG_ADAPTEC_STARFIRE is not set
549# CONFIG_B44 is not set 577# CONFIG_B44 is not set
550# CONFIG_FORCEDETH is not set 578# CONFIG_FORCEDETH is not set
551# CONFIG_DGRS is not set
552# CONFIG_EEPRO100 is not set 579# CONFIG_EEPRO100 is not set
553# CONFIG_E100 is not set 580# CONFIG_E100 is not set
554# CONFIG_FEALNX is not set 581# CONFIG_FEALNX is not set
@@ -560,6 +587,7 @@ CONFIG_8139TOO=y
560# CONFIG_8139TOO_TUNE_TWISTER is not set 587# CONFIG_8139TOO_TUNE_TWISTER is not set
561# CONFIG_8139TOO_8129 is not set 588# CONFIG_8139TOO_8129 is not set
562# CONFIG_8139_OLD_RX_RESET is not set 589# CONFIG_8139_OLD_RX_RESET is not set
590# CONFIG_R6040 is not set
563# CONFIG_SIS900 is not set 591# CONFIG_SIS900 is not set
564# CONFIG_EPIC100 is not set 592# CONFIG_EPIC100 is not set
565# CONFIG_SUNDANCE is not set 593# CONFIG_SUNDANCE is not set
@@ -570,6 +598,10 @@ CONFIG_NETDEV_1000=y
570# CONFIG_ACENIC is not set 598# CONFIG_ACENIC is not set
571# CONFIG_DL2K is not set 599# CONFIG_DL2K is not set
572# CONFIG_E1000 is not set 600# CONFIG_E1000 is not set
601# CONFIG_E1000E is not set
602# CONFIG_E1000E_ENABLED is not set
603# CONFIG_IP1000 is not set
604# CONFIG_IGB is not set
573# CONFIG_NS83820 is not set 605# CONFIG_NS83820 is not set
574# CONFIG_HAMACHI is not set 606# CONFIG_HAMACHI is not set
575# CONFIG_YELLOWFIN is not set 607# CONFIG_YELLOWFIN is not set
@@ -577,6 +609,7 @@ CONFIG_NETDEV_1000=y
577# CONFIG_SIS190 is not set 609# CONFIG_SIS190 is not set
578# CONFIG_SKGE is not set 610# CONFIG_SKGE is not set
579# CONFIG_SKY2 is not set 611# CONFIG_SKY2 is not set
612# CONFIG_SK98LIN is not set
580# CONFIG_VIA_VELOCITY is not set 613# CONFIG_VIA_VELOCITY is not set
581# CONFIG_TIGON3 is not set 614# CONFIG_TIGON3 is not set
582# CONFIG_BNX2 is not set 615# CONFIG_BNX2 is not set
@@ -585,11 +618,15 @@ CONFIG_NETDEV_1000=y
585CONFIG_NETDEV_10000=y 618CONFIG_NETDEV_10000=y
586# CONFIG_CHELSIO_T1 is not set 619# CONFIG_CHELSIO_T1 is not set
587# CONFIG_CHELSIO_T3 is not set 620# CONFIG_CHELSIO_T3 is not set
621# CONFIG_IXGBE is not set
588# CONFIG_IXGB is not set 622# CONFIG_IXGB is not set
589# CONFIG_S2IO is not set 623# CONFIG_S2IO is not set
590# CONFIG_MYRI10GE is not set 624# CONFIG_MYRI10GE is not set
591# CONFIG_NETXEN_NIC is not set 625# CONFIG_NETXEN_NIC is not set
626# CONFIG_NIU is not set
592# CONFIG_MLX4_CORE is not set 627# CONFIG_MLX4_CORE is not set
628# CONFIG_TEHUTI is not set
629# CONFIG_BNX2X is not set
593# CONFIG_TR is not set 630# CONFIG_TR is not set
594 631
595# 632#
@@ -597,13 +634,21 @@ CONFIG_NETDEV_10000=y
597# 634#
598# CONFIG_WLAN_PRE80211 is not set 635# CONFIG_WLAN_PRE80211 is not set
599# CONFIG_WLAN_80211 is not set 636# CONFIG_WLAN_80211 is not set
637
638#
639# USB Network Adapters
640#
641# CONFIG_USB_CATC is not set
642# CONFIG_USB_KAWETH is not set
643# CONFIG_USB_PEGASUS is not set
644# CONFIG_USB_RTL8150 is not set
645# CONFIG_USB_USBNET is not set
600# CONFIG_WAN is not set 646# CONFIG_WAN is not set
601# CONFIG_FDDI is not set 647# CONFIG_FDDI is not set
602# CONFIG_HIPPI is not set 648# CONFIG_HIPPI is not set
603# CONFIG_PPP is not set 649# CONFIG_PPP is not set
604# CONFIG_SLIP is not set 650# CONFIG_SLIP is not set
605# CONFIG_NET_FC is not set 651# CONFIG_NET_FC is not set
606# CONFIG_SHAPER is not set
607# CONFIG_NETCONSOLE is not set 652# CONFIG_NETCONSOLE is not set
608# CONFIG_NETPOLL is not set 653# CONFIG_NETPOLL is not set
609# CONFIG_NET_POLL_CONTROLLER is not set 654# CONFIG_NET_POLL_CONTROLLER is not set
@@ -622,7 +667,6 @@ CONFIG_INPUT=y
622# 667#
623# CONFIG_INPUT_MOUSEDEV is not set 668# CONFIG_INPUT_MOUSEDEV is not set
624# CONFIG_INPUT_JOYDEV is not set 669# CONFIG_INPUT_JOYDEV is not set
625# CONFIG_INPUT_TSDEV is not set
626# CONFIG_INPUT_EVDEV is not set 670# CONFIG_INPUT_EVDEV is not set
627# CONFIG_INPUT_EVBUG is not set 671# CONFIG_INPUT_EVBUG is not set
628 672
@@ -650,6 +694,7 @@ CONFIG_VT_CONSOLE=y
650CONFIG_HW_CONSOLE=y 694CONFIG_HW_CONSOLE=y
651CONFIG_VT_HW_CONSOLE_BINDING=y 695CONFIG_VT_HW_CONSOLE_BINDING=y
652# CONFIG_SERIAL_NONSTANDARD is not set 696# CONFIG_SERIAL_NONSTANDARD is not set
697# CONFIG_NOZOMI is not set
653 698
654# 699#
655# Serial drivers 700# Serial drivers
@@ -674,11 +719,9 @@ CONFIG_UNIX98_PTYS=y
674CONFIG_LEGACY_PTYS=y 719CONFIG_LEGACY_PTYS=y
675CONFIG_LEGACY_PTY_COUNT=256 720CONFIG_LEGACY_PTY_COUNT=256
676# CONFIG_IPMI_HANDLER is not set 721# CONFIG_IPMI_HANDLER is not set
677# CONFIG_WATCHDOG is not set
678CONFIG_HW_RANDOM=y 722CONFIG_HW_RANDOM=y
679# CONFIG_R3964 is not set 723# CONFIG_R3964 is not set
680# CONFIG_APPLICOM is not set 724# CONFIG_APPLICOM is not set
681# CONFIG_DRM is not set
682# CONFIG_RAW_DRIVER is not set 725# CONFIG_RAW_DRIVER is not set
683# CONFIG_TCG_TPM is not set 726# CONFIG_TCG_TPM is not set
684CONFIG_DEVPORT=y 727CONFIG_DEVPORT=y
@@ -687,16 +730,30 @@ CONFIG_DEVPORT=y
687# 730#
688# SPI support 731# SPI support
689# 732#
690# CONFIG_SPI is not set 733CONFIG_SPI=y
691# CONFIG_SPI_MASTER is not set 734CONFIG_SPI_MASTER=y
735
736#
737# SPI Master Controller Drivers
738#
739CONFIG_SPI_BITBANG=y
740CONFIG_SPI_SH_SCI=y
741
742#
743# SPI Protocol Masters
744#
745# CONFIG_SPI_AT25 is not set
746# CONFIG_SPI_SPIDEV is not set
747# CONFIG_SPI_TLE62X0 is not set
692# CONFIG_W1 is not set 748# CONFIG_W1 is not set
693# CONFIG_POWER_SUPPLY is not set 749# CONFIG_POWER_SUPPLY is not set
694CONFIG_HWMON=y 750CONFIG_HWMON=y
695# CONFIG_HWMON_VID is not set 751# CONFIG_HWMON_VID is not set
696# CONFIG_SENSORS_ABITUGURU is not set 752# CONFIG_SENSORS_I5K_AMB is not set
697# CONFIG_SENSORS_ABITUGURU3 is not set
698# CONFIG_SENSORS_F71805F is not set 753# CONFIG_SENSORS_F71805F is not set
754# CONFIG_SENSORS_F71882FG is not set
699# CONFIG_SENSORS_IT87 is not set 755# CONFIG_SENSORS_IT87 is not set
756# CONFIG_SENSORS_LM70 is not set
700# CONFIG_SENSORS_PC87360 is not set 757# CONFIG_SENSORS_PC87360 is not set
701# CONFIG_SENSORS_PC87427 is not set 758# CONFIG_SENSORS_PC87427 is not set
702# CONFIG_SENSORS_SIS5595 is not set 759# CONFIG_SENSORS_SIS5595 is not set
@@ -708,6 +765,13 @@ CONFIG_HWMON=y
708# CONFIG_SENSORS_W83627HF is not set 765# CONFIG_SENSORS_W83627HF is not set
709# CONFIG_SENSORS_W83627EHF is not set 766# CONFIG_SENSORS_W83627EHF is not set
710# CONFIG_HWMON_DEBUG_CHIP is not set 767# CONFIG_HWMON_DEBUG_CHIP is not set
768# CONFIG_WATCHDOG is not set
769
770#
771# Sonics Silicon Backplane
772#
773CONFIG_SSB_POSSIBLE=y
774# CONFIG_SSB is not set
711 775
712# 776#
713# Multifunction device drivers 777# Multifunction device drivers
@@ -720,16 +784,12 @@ CONFIG_MFD_SM501=y
720# CONFIG_VIDEO_DEV is not set 784# CONFIG_VIDEO_DEV is not set
721# CONFIG_DVB_CORE is not set 785# CONFIG_DVB_CORE is not set
722CONFIG_DAB=y 786CONFIG_DAB=y
787# CONFIG_USB_DABUSB is not set
723 788
724# 789#
725# Graphics support 790# Graphics support
726# 791#
727# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 792# CONFIG_DRM is not set
728
729#
730# Display device support
731#
732# CONFIG_DISPLAY_SUPPORT is not set
733# CONFIG_VGASTATE is not set 793# CONFIG_VGASTATE is not set
734CONFIG_VIDEO_OUTPUT_CONTROL=m 794CONFIG_VIDEO_OUTPUT_CONTROL=m
735CONFIG_FB=y 795CONFIG_FB=y
@@ -738,6 +798,7 @@ CONFIG_FB=y
738CONFIG_FB_CFB_FILLRECT=y 798CONFIG_FB_CFB_FILLRECT=y
739CONFIG_FB_CFB_COPYAREA=y 799CONFIG_FB_CFB_COPYAREA=y
740CONFIG_FB_CFB_IMAGEBLIT=y 800CONFIG_FB_CFB_IMAGEBLIT=y
801# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
741# CONFIG_FB_SYS_FILLRECT is not set 802# CONFIG_FB_SYS_FILLRECT is not set
742# CONFIG_FB_SYS_COPYAREA is not set 803# CONFIG_FB_SYS_COPYAREA is not set
743# CONFIG_FB_SYS_IMAGEBLIT is not set 804# CONFIG_FB_SYS_IMAGEBLIT is not set
@@ -777,6 +838,12 @@ CONFIG_FB_DEFERRED_IO=y
777# CONFIG_FB_PM3 is not set 838# CONFIG_FB_PM3 is not set
778CONFIG_FB_SM501=y 839CONFIG_FB_SM501=y
779# CONFIG_FB_VIRTUAL is not set 840# CONFIG_FB_VIRTUAL is not set
841# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
842
843#
844# Display device support
845#
846# CONFIG_DISPLAY_SUPPORT is not set
780 847
781# 848#
782# Console display driver support 849# Console display driver support
@@ -844,6 +911,7 @@ CONFIG_SND_AC97_CODEC=m
844# CONFIG_SND_BT87X is not set 911# CONFIG_SND_BT87X is not set
845# CONFIG_SND_CA0106 is not set 912# CONFIG_SND_CA0106 is not set
846# CONFIG_SND_CMIPCI is not set 913# CONFIG_SND_CMIPCI is not set
914# CONFIG_SND_OXYGEN is not set
847# CONFIG_SND_CS4281 is not set 915# CONFIG_SND_CS4281 is not set
848# CONFIG_SND_CS46XX is not set 916# CONFIG_SND_CS46XX is not set
849# CONFIG_SND_DARLA20 is not set 917# CONFIG_SND_DARLA20 is not set
@@ -868,6 +936,7 @@ CONFIG_SND_AC97_CODEC=m
868# CONFIG_SND_HDA_INTEL is not set 936# CONFIG_SND_HDA_INTEL is not set
869# CONFIG_SND_HDSP is not set 937# CONFIG_SND_HDSP is not set
870# CONFIG_SND_HDSPM is not set 938# CONFIG_SND_HDSPM is not set
939# CONFIG_SND_HIFIER is not set
871# CONFIG_SND_ICE1712 is not set 940# CONFIG_SND_ICE1712 is not set
872# CONFIG_SND_ICE1724 is not set 941# CONFIG_SND_ICE1724 is not set
873# CONFIG_SND_INTEL8X0 is not set 942# CONFIG_SND_INTEL8X0 is not set
@@ -885,16 +954,27 @@ CONFIG_SND_AC97_CODEC=m
885# CONFIG_SND_TRIDENT is not set 954# CONFIG_SND_TRIDENT is not set
886# CONFIG_SND_VIA82XX is not set 955# CONFIG_SND_VIA82XX is not set
887# CONFIG_SND_VIA82XX_MODEM is not set 956# CONFIG_SND_VIA82XX_MODEM is not set
957# CONFIG_SND_VIRTUOSO is not set
888# CONFIG_SND_VX222 is not set 958# CONFIG_SND_VX222 is not set
889CONFIG_SND_YMFPCI=m 959CONFIG_SND_YMFPCI=m
890CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL=y 960CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL=y
891# CONFIG_SND_AC97_POWER_SAVE is not set 961# CONFIG_SND_AC97_POWER_SAVE is not set
892 962
893# 963#
964# SPI devices
965#
966
967#
894# SUPERH devices 968# SUPERH devices
895# 969#
896 970
897# 971#
972# USB devices
973#
974# CONFIG_SND_USB_AUDIO is not set
975# CONFIG_SND_USB_CAIAQ is not set
976
977#
898# System on Chip audio support 978# System on Chip audio support
899# 979#
900# CONFIG_SND_SOC is not set 980# CONFIG_SND_SOC is not set
@@ -904,6 +984,10 @@ CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL=y
904# 984#
905 985
906# 986#
987# ALSA SoC audio for Freescale SOCs
988#
989
990#
907# Open Sound System 991# Open Sound System
908# 992#
909CONFIG_SOUND_PRIME=m 993CONFIG_SOUND_PRIME=m
@@ -914,19 +998,104 @@ CONFIG_AC97_BUS=m
914CONFIG_HID_SUPPORT=y 998CONFIG_HID_SUPPORT=y
915CONFIG_HID=y 999CONFIG_HID=y
916# CONFIG_HID_DEBUG is not set 1000# CONFIG_HID_DEBUG is not set
1001# CONFIG_HIDRAW is not set
1002
1003#
1004# USB Input Devices
1005#
1006CONFIG_USB_HID=y
1007# CONFIG_USB_HIDINPUT_POWERBOOK is not set
1008# CONFIG_HID_FF is not set
1009# CONFIG_USB_HIDDEV is not set
917CONFIG_USB_SUPPORT=y 1010CONFIG_USB_SUPPORT=y
918CONFIG_USB_ARCH_HAS_HCD=y 1011CONFIG_USB_ARCH_HAS_HCD=y
919CONFIG_USB_ARCH_HAS_OHCI=y 1012CONFIG_USB_ARCH_HAS_OHCI=y
920CONFIG_USB_ARCH_HAS_EHCI=y 1013CONFIG_USB_ARCH_HAS_EHCI=y
921# CONFIG_USB is not set 1014CONFIG_USB=y
1015# CONFIG_USB_DEBUG is not set
1016CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
1017
1018#
1019# Miscellaneous USB options
1020#
1021# CONFIG_USB_DEVICEFS is not set
1022CONFIG_USB_DEVICE_CLASS=y
1023# CONFIG_USB_DYNAMIC_MINORS is not set
1024# CONFIG_USB_OTG is not set
1025
1026#
1027# USB Host Controller Drivers
1028#
1029# CONFIG_USB_EHCI_HCD is not set
1030# CONFIG_USB_ISP116X_HCD is not set
1031CONFIG_USB_OHCI_HCD=y
1032# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
1033# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
1034CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1035# CONFIG_USB_UHCI_HCD is not set
1036# CONFIG_USB_SL811_HCD is not set
1037# CONFIG_USB_R8A66597_HCD is not set
1038
1039#
1040# USB Device Class drivers
1041#
1042# CONFIG_USB_ACM is not set
1043# CONFIG_USB_PRINTER is not set
922 1044
923# 1045#
924# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 1046# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
925# 1047#
926 1048
927# 1049#
928# USB Gadget Support 1050# may also be needed; see USB_STORAGE Help for more information
1051#
1052CONFIG_USB_STORAGE=y
1053# CONFIG_USB_STORAGE_DEBUG is not set
1054# CONFIG_USB_STORAGE_DATAFAB is not set
1055# CONFIG_USB_STORAGE_FREECOM is not set
1056# CONFIG_USB_STORAGE_ISD200 is not set
1057# CONFIG_USB_STORAGE_DPCM is not set
1058# CONFIG_USB_STORAGE_USBAT is not set
1059# CONFIG_USB_STORAGE_SDDR09 is not set
1060# CONFIG_USB_STORAGE_SDDR55 is not set
1061# CONFIG_USB_STORAGE_JUMPSHOT is not set
1062# CONFIG_USB_STORAGE_ALAUDA is not set
1063# CONFIG_USB_STORAGE_KARMA is not set
1064CONFIG_USB_LIBUSUAL=y
1065
1066#
1067# USB Imaging devices
1068#
1069# CONFIG_USB_MDC800 is not set
1070# CONFIG_USB_MICROTEK is not set
1071# CONFIG_USB_MON is not set
1072
1073#
1074# USB port drivers
1075#
1076# CONFIG_USB_SERIAL is not set
1077
1078#
1079# USB Miscellaneous drivers
929# 1080#
1081# CONFIG_USB_EMI62 is not set
1082# CONFIG_USB_EMI26 is not set
1083# CONFIG_USB_ADUTUX is not set
1084# CONFIG_USB_AUERSWALD is not set
1085# CONFIG_USB_RIO500 is not set
1086# CONFIG_USB_LEGOTOWER is not set
1087# CONFIG_USB_LCD is not set
1088# CONFIG_USB_BERRY_CHARGE is not set
1089# CONFIG_USB_LED is not set
1090# CONFIG_USB_CYPRESS_CY7C63 is not set
1091# CONFIG_USB_CYTHERM is not set
1092# CONFIG_USB_PHIDGET is not set
1093# CONFIG_USB_IDMOUSE is not set
1094# CONFIG_USB_FTDI_ELAN is not set
1095# CONFIG_USB_APPLEDISPLAY is not set
1096# CONFIG_USB_LD is not set
1097# CONFIG_USB_TRANCEVIBRATOR is not set
1098# CONFIG_USB_IOWARRIOR is not set
930# CONFIG_USB_GADGET is not set 1099# CONFIG_USB_GADGET is not set
931# CONFIG_MMC is not set 1100# CONFIG_MMC is not set
932# CONFIG_NEW_LEDS is not set 1101# CONFIG_NEW_LEDS is not set
@@ -949,13 +1118,17 @@ CONFIG_RTC_INTF_DEV=y
949# 1118#
950# SPI RTC drivers 1119# SPI RTC drivers
951# 1120#
1121# CONFIG_RTC_DRV_MAX6902 is not set
1122CONFIG_RTC_DRV_R9701=y
1123# CONFIG_RTC_DRV_RS5C348 is not set
952 1124
953# 1125#
954# Platform RTC drivers 1126# Platform RTC drivers
955# 1127#
1128# CONFIG_RTC_DRV_DS1511 is not set
956# CONFIG_RTC_DRV_DS1553 is not set 1129# CONFIG_RTC_DRV_DS1553 is not set
957# CONFIG_RTC_DRV_STK17TA8 is not set
958# CONFIG_RTC_DRV_DS1742 is not set 1130# CONFIG_RTC_DRV_DS1742 is not set
1131# CONFIG_RTC_DRV_STK17TA8 is not set
959# CONFIG_RTC_DRV_M48T86 is not set 1132# CONFIG_RTC_DRV_M48T86 is not set
960# CONFIG_RTC_DRV_M48T59 is not set 1133# CONFIG_RTC_DRV_M48T59 is not set
961# CONFIG_RTC_DRV_V3020 is not set 1134# CONFIG_RTC_DRV_V3020 is not set
@@ -963,20 +1136,7 @@ CONFIG_RTC_INTF_DEV=y
963# 1136#
964# on-CPU RTC drivers 1137# on-CPU RTC drivers
965# 1138#
966CONFIG_RTC_DRV_SH=y 1139# CONFIG_RTC_DRV_SH is not set
967
968#
969# DMA Engine support
970#
971# CONFIG_DMA_ENGINE is not set
972
973#
974# DMA Clients
975#
976
977#
978# DMA Devices
979#
980 1140
981# 1141#
982# Userspace I/O 1142# Userspace I/O
@@ -1034,7 +1194,6 @@ CONFIG_TMPFS=y
1034# CONFIG_TMPFS_POSIX_ACL is not set 1194# CONFIG_TMPFS_POSIX_ACL is not set
1035# CONFIG_HUGETLBFS is not set 1195# CONFIG_HUGETLBFS is not set
1036# CONFIG_HUGETLB_PAGE is not set 1196# CONFIG_HUGETLB_PAGE is not set
1037CONFIG_RAMFS=y
1038# CONFIG_CONFIGFS_FS is not set 1197# CONFIG_CONFIGFS_FS is not set
1039 1198
1040# 1199#
@@ -1053,10 +1212,7 @@ CONFIG_RAMFS=y
1053# CONFIG_QNX4FS_FS is not set 1212# CONFIG_QNX4FS_FS is not set
1054# CONFIG_SYSV_FS is not set 1213# CONFIG_SYSV_FS is not set
1055# CONFIG_UFS_FS is not set 1214# CONFIG_UFS_FS is not set
1056 1215CONFIG_NETWORK_FILESYSTEMS=y
1057#
1058# Network File Systems
1059#
1060# CONFIG_NFS_FS is not set 1216# CONFIG_NFS_FS is not set
1061# CONFIG_NFSD is not set 1217# CONFIG_NFSD is not set
1062# CONFIG_SMB_FS is not set 1218# CONFIG_SMB_FS is not set
@@ -1070,10 +1226,6 @@ CONFIG_RAMFS=y
1070# 1226#
1071# CONFIG_PARTITION_ADVANCED is not set 1227# CONFIG_PARTITION_ADVANCED is not set
1072CONFIG_MSDOS_PARTITION=y 1228CONFIG_MSDOS_PARTITION=y
1073
1074#
1075# Native Language Support
1076#
1077CONFIG_NLS=y 1229CONFIG_NLS=y
1078CONFIG_NLS_DEFAULT="iso8859-1" 1230CONFIG_NLS_DEFAULT="iso8859-1"
1079# CONFIG_NLS_CODEPAGE_437 is not set 1231# CONFIG_NLS_CODEPAGE_437 is not set
@@ -1114,30 +1266,22 @@ CONFIG_NLS_CODEPAGE_932=y
1114# CONFIG_NLS_KOI8_R is not set 1266# CONFIG_NLS_KOI8_R is not set
1115# CONFIG_NLS_KOI8_U is not set 1267# CONFIG_NLS_KOI8_U is not set
1116# CONFIG_NLS_UTF8 is not set 1268# CONFIG_NLS_UTF8 is not set
1117
1118#
1119# Distributed Lock Manager
1120#
1121# CONFIG_DLM is not set 1269# CONFIG_DLM is not set
1122 1270
1123# 1271#
1124# Profiling support
1125#
1126CONFIG_PROFILING=y
1127CONFIG_OPROFILE=y
1128
1129#
1130# Kernel hacking 1272# Kernel hacking
1131# 1273#
1132CONFIG_TRACE_IRQFLAGS_SUPPORT=y 1274CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1133# CONFIG_PRINTK_TIME is not set 1275# CONFIG_PRINTK_TIME is not set
1276CONFIG_ENABLE_WARN_DEPRECATED=y
1134CONFIG_ENABLE_MUST_CHECK=y 1277CONFIG_ENABLE_MUST_CHECK=y
1135# CONFIG_MAGIC_SYSRQ is not set 1278# CONFIG_MAGIC_SYSRQ is not set
1136# CONFIG_UNUSED_SYMBOLS is not set 1279# CONFIG_UNUSED_SYMBOLS is not set
1137# CONFIG_DEBUG_FS is not set 1280CONFIG_DEBUG_FS=y
1138# CONFIG_HEADERS_CHECK is not set 1281# CONFIG_HEADERS_CHECK is not set
1139# CONFIG_DEBUG_KERNEL is not set 1282# CONFIG_DEBUG_KERNEL is not set
1140# CONFIG_DEBUG_BUGVERBOSE is not set 1283# CONFIG_DEBUG_BUGVERBOSE is not set
1284# CONFIG_SAMPLES is not set
1141# CONFIG_SH_STANDARD_BIOS is not set 1285# CONFIG_SH_STANDARD_BIOS is not set
1142CONFIG_EARLY_SCIF_CONSOLE=y 1286CONFIG_EARLY_SCIF_CONSOLE=y
1143CONFIG_EARLY_SCIF_CONSOLE_PORT=0xffe80000 1287CONFIG_EARLY_SCIF_CONSOLE_PORT=0xffe80000
@@ -1149,7 +1293,53 @@ CONFIG_EARLY_PRINTK=y
1149# 1293#
1150# CONFIG_KEYS is not set 1294# CONFIG_KEYS is not set
1151# CONFIG_SECURITY is not set 1295# CONFIG_SECURITY is not set
1152# CONFIG_CRYPTO is not set 1296# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1297CONFIG_CRYPTO=y
1298# CONFIG_CRYPTO_SEQIV is not set
1299# CONFIG_CRYPTO_MANAGER is not set
1300# CONFIG_CRYPTO_HMAC is not set
1301# CONFIG_CRYPTO_XCBC is not set
1302# CONFIG_CRYPTO_NULL is not set
1303# CONFIG_CRYPTO_MD4 is not set
1304# CONFIG_CRYPTO_MD5 is not set
1305# CONFIG_CRYPTO_SHA1 is not set
1306# CONFIG_CRYPTO_SHA256 is not set
1307# CONFIG_CRYPTO_SHA512 is not set
1308# CONFIG_CRYPTO_WP512 is not set
1309# CONFIG_CRYPTO_TGR192 is not set
1310# CONFIG_CRYPTO_GF128MUL is not set
1311# CONFIG_CRYPTO_ECB is not set
1312# CONFIG_CRYPTO_CBC is not set
1313# CONFIG_CRYPTO_PCBC is not set
1314# CONFIG_CRYPTO_LRW is not set
1315# CONFIG_CRYPTO_XTS is not set
1316# CONFIG_CRYPTO_CTR is not set
1317# CONFIG_CRYPTO_GCM is not set
1318# CONFIG_CRYPTO_CCM is not set
1319# CONFIG_CRYPTO_CRYPTD is not set
1320# CONFIG_CRYPTO_DES is not set
1321# CONFIG_CRYPTO_FCRYPT is not set
1322# CONFIG_CRYPTO_BLOWFISH is not set
1323# CONFIG_CRYPTO_TWOFISH is not set
1324# CONFIG_CRYPTO_SERPENT is not set
1325# CONFIG_CRYPTO_AES is not set
1326# CONFIG_CRYPTO_CAST5 is not set
1327# CONFIG_CRYPTO_CAST6 is not set
1328# CONFIG_CRYPTO_TEA is not set
1329# CONFIG_CRYPTO_ARC4 is not set
1330# CONFIG_CRYPTO_KHAZAD is not set
1331# CONFIG_CRYPTO_ANUBIS is not set
1332# CONFIG_CRYPTO_SEED is not set
1333# CONFIG_CRYPTO_SALSA20 is not set
1334# CONFIG_CRYPTO_DEFLATE is not set
1335# CONFIG_CRYPTO_MICHAEL_MIC is not set
1336# CONFIG_CRYPTO_CRC32C is not set
1337# CONFIG_CRYPTO_CAMELLIA is not set
1338# CONFIG_CRYPTO_TEST is not set
1339# CONFIG_CRYPTO_AUTHENC is not set
1340# CONFIG_CRYPTO_LZO is not set
1341CONFIG_CRYPTO_HW=y
1342# CONFIG_CRYPTO_DEV_HIFN_795X is not set
1153 1343
1154# 1344#
1155# Library routines 1345# Library routines
diff --git a/arch/sh/configs/rts7751r2dplus_defconfig b/arch/sh/configs/rts7751r2dplus_defconfig
index 4ff5a752dcd9..0a6d3b9e648b 100644
--- a/arch/sh/configs/rts7751r2dplus_defconfig
+++ b/arch/sh/configs/rts7751r2dplus_defconfig
@@ -1,9 +1,10 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.23-rc2 3# Linux kernel version: 2.6.24
4# Tue Aug 14 16:33:08 2007 4# Thu Feb 7 16:17:47 2008
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_SUPERH32=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 8CONFIG_RWSEM_GENERIC_SPINLOCK=y
8CONFIG_GENERIC_BUG=y 9CONFIG_GENERIC_BUG=y
9CONFIG_GENERIC_FIND_NEXT_BIT=y 10CONFIG_GENERIC_FIND_NEXT_BIT=y
@@ -36,9 +37,14 @@ CONFIG_SYSVIPC_SYSCTL=y
36# CONFIG_BSD_PROCESS_ACCT is not set 37# CONFIG_BSD_PROCESS_ACCT is not set
37# CONFIG_TASKSTATS is not set 38# CONFIG_TASKSTATS is not set
38# CONFIG_USER_NS is not set 39# CONFIG_USER_NS is not set
40# CONFIG_PID_NS is not set
39# CONFIG_AUDIT is not set 41# CONFIG_AUDIT is not set
40# CONFIG_IKCONFIG is not set 42# CONFIG_IKCONFIG is not set
41CONFIG_LOG_BUF_SHIFT=14 43CONFIG_LOG_BUF_SHIFT=14
44# CONFIG_CGROUPS is not set
45CONFIG_FAIR_GROUP_SCHED=y
46CONFIG_FAIR_USER_SCHED=y
47# CONFIG_FAIR_CGROUP_SCHED is not set
42CONFIG_SYSFS_DEPRECATED=y 48CONFIG_SYSFS_DEPRECATED=y
43# CONFIG_RELAY is not set 49# CONFIG_RELAY is not set
44# CONFIG_BLK_DEV_INITRD is not set 50# CONFIG_BLK_DEV_INITRD is not set
@@ -53,6 +59,7 @@ CONFIG_HOTPLUG=y
53CONFIG_PRINTK=y 59CONFIG_PRINTK=y
54CONFIG_BUG=y 60CONFIG_BUG=y
55CONFIG_ELF_CORE=y 61CONFIG_ELF_CORE=y
62CONFIG_COMPAT_BRK=y
56CONFIG_BASE_FULL=y 63CONFIG_BASE_FULL=y
57CONFIG_FUTEX=y 64CONFIG_FUTEX=y
58CONFIG_ANON_INODES=y 65CONFIG_ANON_INODES=y
@@ -65,6 +72,13 @@ CONFIG_VM_EVENT_COUNTERS=y
65CONFIG_SLAB=y 72CONFIG_SLAB=y
66# CONFIG_SLUB is not set 73# CONFIG_SLUB is not set
67# CONFIG_SLOB is not set 74# CONFIG_SLOB is not set
75CONFIG_PROFILING=y
76# CONFIG_MARKERS is not set
77CONFIG_OPROFILE=y
78CONFIG_HAVE_OPROFILE=y
79# CONFIG_HAVE_KPROBES is not set
80CONFIG_PROC_PAGE_MONITOR=y
81CONFIG_SLABINFO=y
68CONFIG_RT_MUTEXES=y 82CONFIG_RT_MUTEXES=y
69# CONFIG_TINY_SHMEM is not set 83# CONFIG_TINY_SHMEM is not set
70CONFIG_BASE_SMALL=0 84CONFIG_BASE_SMALL=0
@@ -91,13 +105,17 @@ CONFIG_DEFAULT_AS=y
91# CONFIG_DEFAULT_CFQ is not set 105# CONFIG_DEFAULT_CFQ is not set
92# CONFIG_DEFAULT_NOOP is not set 106# CONFIG_DEFAULT_NOOP is not set
93CONFIG_DEFAULT_IOSCHED="anticipatory" 107CONFIG_DEFAULT_IOSCHED="anticipatory"
108CONFIG_CLASSIC_RCU=y
109# CONFIG_PREEMPT_RCU is not set
94 110
95# 111#
96# System type 112# System type
97# 113#
98CONFIG_CPU_SH4=y 114CONFIG_CPU_SH4=y
99# CONFIG_CPU_SUBTYPE_SH7619 is not set 115# CONFIG_CPU_SUBTYPE_SH7619 is not set
116# CONFIG_CPU_SUBTYPE_SH7203 is not set
100# CONFIG_CPU_SUBTYPE_SH7206 is not set 117# CONFIG_CPU_SUBTYPE_SH7206 is not set
118# CONFIG_CPU_SUBTYPE_SH7263 is not set
101# CONFIG_CPU_SUBTYPE_SH7705 is not set 119# CONFIG_CPU_SUBTYPE_SH7705 is not set
102# CONFIG_CPU_SUBTYPE_SH7706 is not set 120# CONFIG_CPU_SUBTYPE_SH7706 is not set
103# CONFIG_CPU_SUBTYPE_SH7707 is not set 121# CONFIG_CPU_SUBTYPE_SH7707 is not set
@@ -105,6 +123,8 @@ CONFIG_CPU_SH4=y
105# CONFIG_CPU_SUBTYPE_SH7709 is not set 123# CONFIG_CPU_SUBTYPE_SH7709 is not set
106# CONFIG_CPU_SUBTYPE_SH7710 is not set 124# CONFIG_CPU_SUBTYPE_SH7710 is not set
107# CONFIG_CPU_SUBTYPE_SH7712 is not set 125# CONFIG_CPU_SUBTYPE_SH7712 is not set
126# CONFIG_CPU_SUBTYPE_SH7720 is not set
127# CONFIG_CPU_SUBTYPE_SH7721 is not set
108# CONFIG_CPU_SUBTYPE_SH7750 is not set 128# CONFIG_CPU_SUBTYPE_SH7750 is not set
109# CONFIG_CPU_SUBTYPE_SH7091 is not set 129# CONFIG_CPU_SUBTYPE_SH7091 is not set
110# CONFIG_CPU_SUBTYPE_SH7750R is not set 130# CONFIG_CPU_SUBTYPE_SH7750R is not set
@@ -113,14 +133,15 @@ CONFIG_CPU_SH4=y
113CONFIG_CPU_SUBTYPE_SH7751R=y 133CONFIG_CPU_SUBTYPE_SH7751R=y
114# CONFIG_CPU_SUBTYPE_SH7760 is not set 134# CONFIG_CPU_SUBTYPE_SH7760 is not set
115# CONFIG_CPU_SUBTYPE_SH4_202 is not set 135# CONFIG_CPU_SUBTYPE_SH4_202 is not set
116# CONFIG_CPU_SUBTYPE_ST40STB1 is not set 136# CONFIG_CPU_SUBTYPE_SH7763 is not set
117# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
118# CONFIG_CPU_SUBTYPE_SH7770 is not set 137# CONFIG_CPU_SUBTYPE_SH7770 is not set
119# CONFIG_CPU_SUBTYPE_SH7780 is not set 138# CONFIG_CPU_SUBTYPE_SH7780 is not set
120# CONFIG_CPU_SUBTYPE_SH7785 is not set 139# CONFIG_CPU_SUBTYPE_SH7785 is not set
121# CONFIG_CPU_SUBTYPE_SHX3 is not set 140# CONFIG_CPU_SUBTYPE_SHX3 is not set
122# CONFIG_CPU_SUBTYPE_SH7343 is not set 141# CONFIG_CPU_SUBTYPE_SH7343 is not set
123# CONFIG_CPU_SUBTYPE_SH7722 is not set 142# CONFIG_CPU_SUBTYPE_SH7722 is not set
143# CONFIG_CPU_SUBTYPE_SH5_101 is not set
144# CONFIG_CPU_SUBTYPE_SH5_103 is not set
124 145
125# 146#
126# Memory management options 147# Memory management options
@@ -130,6 +151,7 @@ CONFIG_MMU=y
130CONFIG_PAGE_OFFSET=0x80000000 151CONFIG_PAGE_OFFSET=0x80000000
131CONFIG_MEMORY_START=0x0c000000 152CONFIG_MEMORY_START=0x0c000000
132CONFIG_MEMORY_SIZE=0x04000000 153CONFIG_MEMORY_SIZE=0x04000000
154CONFIG_29BIT=y
133CONFIG_VSYSCALL=y 155CONFIG_VSYSCALL=y
134CONFIG_ARCH_FLATMEM_ENABLE=y 156CONFIG_ARCH_FLATMEM_ENABLE=y
135CONFIG_ARCH_SPARSEMEM_ENABLE=y 157CONFIG_ARCH_SPARSEMEM_ENABLE=y
@@ -147,6 +169,7 @@ CONFIG_FLATMEM_MANUAL=y
147CONFIG_FLATMEM=y 169CONFIG_FLATMEM=y
148CONFIG_FLAT_NODE_MEM_MAP=y 170CONFIG_FLAT_NODE_MEM_MAP=y
149CONFIG_SPARSEMEM_STATIC=y 171CONFIG_SPARSEMEM_STATIC=y
172# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
150CONFIG_SPLIT_PTLOCK_CPUS=4 173CONFIG_SPLIT_PTLOCK_CPUS=4
151# CONFIG_RESOURCES_64BIT is not set 174# CONFIG_RESOURCES_64BIT is not set
152CONFIG_ZONE_DMA_FLAG=0 175CONFIG_ZONE_DMA_FLAG=0
@@ -168,23 +191,22 @@ CONFIG_CPU_LITTLE_ENDIAN=y
168CONFIG_SH_FPU=y 191CONFIG_SH_FPU=y
169# CONFIG_SH_STORE_QUEUES is not set 192# CONFIG_SH_STORE_QUEUES is not set
170CONFIG_CPU_HAS_INTEVT=y 193CONFIG_CPU_HAS_INTEVT=y
171CONFIG_CPU_HAS_INTC_IRQ=y
172CONFIG_CPU_HAS_SR_RB=y 194CONFIG_CPU_HAS_SR_RB=y
173CONFIG_CPU_HAS_PTEA=y 195CONFIG_CPU_HAS_PTEA=y
196CONFIG_CPU_HAS_FPU=y
174 197
175# 198#
176# Board support 199# Board support
177# 200#
178# CONFIG_SH_7751_SYSTEMH is not set 201# CONFIG_SH_7751_SYSTEMH is not set
179# CONFIG_SH_SECUREEDGE5410 is not set 202# CONFIG_SH_SECUREEDGE5410 is not set
180# CONFIG_SH_HS7751RVOIP is not set
181CONFIG_SH_RTS7751R2D=y 203CONFIG_SH_RTS7751R2D=y
182# CONFIG_SH_LANDISK is not set 204# CONFIG_SH_LANDISK is not set
183# CONFIG_SH_TITAN is not set 205# CONFIG_SH_TITAN is not set
184# CONFIG_SH_LBOX_RE2 is not set 206# CONFIG_SH_LBOX_RE2 is not set
185 207
186# 208#
187# RTS7751R2D options 209# RTS7751R2D Board Revision
188# 210#
189CONFIG_RTS7751R2D_PLUS=y 211CONFIG_RTS7751R2D_PLUS=y
190# CONFIG_RTS7751R2D_1 is not set 212# CONFIG_RTS7751R2D_1 is not set
@@ -198,6 +220,7 @@ CONFIG_SH_PCLK_FREQ=60000000
198# CONFIG_TICK_ONESHOT is not set 220# CONFIG_TICK_ONESHOT is not set
199# CONFIG_NO_HZ is not set 221# CONFIG_NO_HZ is not set
200# CONFIG_HIGH_RES_TIMERS is not set 222# CONFIG_HIGH_RES_TIMERS is not set
223CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
201 224
202# 225#
203# CPU Frequency scaling 226# CPU Frequency scaling
@@ -227,11 +250,15 @@ CONFIG_HZ_250=y
227# CONFIG_HZ_300 is not set 250# CONFIG_HZ_300 is not set
228# CONFIG_HZ_1000 is not set 251# CONFIG_HZ_1000 is not set
229CONFIG_HZ=250 252CONFIG_HZ=250
253# CONFIG_SCHED_HRTICK is not set
230# CONFIG_KEXEC is not set 254# CONFIG_KEXEC is not set
231# CONFIG_CRASH_DUMP is not set 255# CONFIG_CRASH_DUMP is not set
232CONFIG_PREEMPT_NONE=y 256CONFIG_PREEMPT_NONE=y
233# CONFIG_PREEMPT_VOLUNTARY is not set 257# CONFIG_PREEMPT_VOLUNTARY is not set
234# CONFIG_PREEMPT is not set 258# CONFIG_PREEMPT is not set
259CONFIG_RCU_TRACE=y
260CONFIG_GUSA=y
261# CONFIG_GUSA_RB is not set
235 262
236# 263#
237# Boot options 264# Boot options
@@ -250,10 +277,7 @@ CONFIG_SH_PCIDMA_NONCOHERENT=y
250CONFIG_PCI_AUTO=y 277CONFIG_PCI_AUTO=y
251CONFIG_PCI_AUTO_UPDATE_RESOURCES=y 278CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
252# CONFIG_ARCH_SUPPORTS_MSI is not set 279# CONFIG_ARCH_SUPPORTS_MSI is not set
253 280CONFIG_PCI_LEGACY=y
254#
255# PCCARD (PCMCIA/CardBus) support
256#
257# CONFIG_PCCARD is not set 281# CONFIG_PCCARD is not set
258CONFIG_HOTPLUG_PCI=y 282CONFIG_HOTPLUG_PCI=y
259# CONFIG_HOTPLUG_PCI_FAKE is not set 283# CONFIG_HOTPLUG_PCI_FAKE is not set
@@ -281,6 +305,7 @@ CONFIG_XFRM=y
281# CONFIG_XFRM_USER is not set 305# CONFIG_XFRM_USER is not set
282# CONFIG_XFRM_SUB_POLICY is not set 306# CONFIG_XFRM_SUB_POLICY is not set
283# CONFIG_XFRM_MIGRATE is not set 307# CONFIG_XFRM_MIGRATE is not set
308# CONFIG_XFRM_STATISTICS is not set
284# CONFIG_NET_KEY is not set 309# CONFIG_NET_KEY is not set
285CONFIG_INET=y 310CONFIG_INET=y
286# CONFIG_IP_MULTICAST is not set 311# CONFIG_IP_MULTICAST is not set
@@ -299,6 +324,7 @@ CONFIG_IP_FIB_HASH=y
299CONFIG_INET_XFRM_MODE_TRANSPORT=y 324CONFIG_INET_XFRM_MODE_TRANSPORT=y
300CONFIG_INET_XFRM_MODE_TUNNEL=y 325CONFIG_INET_XFRM_MODE_TUNNEL=y
301CONFIG_INET_XFRM_MODE_BEET=y 326CONFIG_INET_XFRM_MODE_BEET=y
327# CONFIG_INET_LRO is not set
302CONFIG_INET_DIAG=y 328CONFIG_INET_DIAG=y
303CONFIG_INET_TCP_DIAG=y 329CONFIG_INET_TCP_DIAG=y
304# CONFIG_TCP_CONG_ADVANCED is not set 330# CONFIG_TCP_CONG_ADVANCED is not set
@@ -324,10 +350,6 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
324# CONFIG_LAPB is not set 350# CONFIG_LAPB is not set
325# CONFIG_ECONET is not set 351# CONFIG_ECONET is not set
326# CONFIG_WAN_ROUTER is not set 352# CONFIG_WAN_ROUTER is not set
327
328#
329# QoS and/or fair queueing
330#
331# CONFIG_NET_SCHED is not set 353# CONFIG_NET_SCHED is not set
332 354
333# 355#
@@ -335,6 +357,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
335# 357#
336# CONFIG_NET_PKTGEN is not set 358# CONFIG_NET_PKTGEN is not set
337# CONFIG_HAMRADIO is not set 359# CONFIG_HAMRADIO is not set
360# CONFIG_CAN is not set
338# CONFIG_IRDA is not set 361# CONFIG_IRDA is not set
339# CONFIG_BT is not set 362# CONFIG_BT is not set
340# CONFIG_AF_RXRPC is not set 363# CONFIG_AF_RXRPC is not set
@@ -356,6 +379,7 @@ CONFIG_WIRELESS_EXT=y
356# 379#
357# Generic Driver Options 380# Generic Driver Options
358# 381#
382CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
359CONFIG_STANDALONE=y 383CONFIG_STANDALONE=y
360CONFIG_PREVENT_FIRMWARE_BUILD=y 384CONFIG_PREVENT_FIRMWARE_BUILD=y
361CONFIG_FW_LOADER=m 385CONFIG_FW_LOADER=m
@@ -371,6 +395,7 @@ CONFIG_BLK_DEV=y
371# CONFIG_BLK_DEV_LOOP is not set 395# CONFIG_BLK_DEV_LOOP is not set
372# CONFIG_BLK_DEV_NBD is not set 396# CONFIG_BLK_DEV_NBD is not set
373# CONFIG_BLK_DEV_SX8 is not set 397# CONFIG_BLK_DEV_SX8 is not set
398# CONFIG_BLK_DEV_UB is not set
374CONFIG_BLK_DEV_RAM=y 399CONFIG_BLK_DEV_RAM=y
375CONFIG_BLK_DEV_RAM_COUNT=16 400CONFIG_BLK_DEV_RAM_COUNT=16
376CONFIG_BLK_DEV_RAM_SIZE=4096 401CONFIG_BLK_DEV_RAM_SIZE=4096
@@ -420,6 +445,7 @@ CONFIG_SCSI_WAIT_SCAN=m
420# CONFIG_SCSI_FC_ATTRS is not set 445# CONFIG_SCSI_FC_ATTRS is not set
421# CONFIG_SCSI_ISCSI_ATTRS is not set 446# CONFIG_SCSI_ISCSI_ATTRS is not set
422# CONFIG_SCSI_SAS_LIBSAS is not set 447# CONFIG_SCSI_SAS_LIBSAS is not set
448# CONFIG_SCSI_SRP_ATTRS is not set
423CONFIG_SCSI_LOWLEVEL=y 449CONFIG_SCSI_LOWLEVEL=y
424# CONFIG_ISCSI_TCP is not set 450# CONFIG_ISCSI_TCP is not set
425# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 451# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
@@ -493,7 +519,9 @@ CONFIG_ATA=y
493# CONFIG_PATA_MPIIX is not set 519# CONFIG_PATA_MPIIX is not set
494# CONFIG_PATA_OLDPIIX is not set 520# CONFIG_PATA_OLDPIIX is not set
495# CONFIG_PATA_NETCELL is not set 521# CONFIG_PATA_NETCELL is not set
522# CONFIG_PATA_NINJA32 is not set
496# CONFIG_PATA_NS87410 is not set 523# CONFIG_PATA_NS87410 is not set
524# CONFIG_PATA_NS87415 is not set
497# CONFIG_PATA_OPTI is not set 525# CONFIG_PATA_OPTI is not set
498# CONFIG_PATA_OPTIDMA is not set 526# CONFIG_PATA_OPTIDMA is not set
499# CONFIG_PATA_PDC_OLD is not set 527# CONFIG_PATA_PDC_OLD is not set
@@ -508,14 +536,7 @@ CONFIG_ATA=y
508# CONFIG_PATA_WINBOND is not set 536# CONFIG_PATA_WINBOND is not set
509CONFIG_PATA_PLATFORM=y 537CONFIG_PATA_PLATFORM=y
510# CONFIG_MD is not set 538# CONFIG_MD is not set
511
512#
513# Fusion MPT device support
514#
515# CONFIG_FUSION is not set 539# CONFIG_FUSION is not set
516# CONFIG_FUSION_SPI is not set
517# CONFIG_FUSION_FC is not set
518# CONFIG_FUSION_SAS is not set
519 540
520# 541#
521# IEEE 1394 (FireWire) support 542# IEEE 1394 (FireWire) support
@@ -530,25 +551,31 @@ CONFIG_NETDEVICES=y
530# CONFIG_MACVLAN is not set 551# CONFIG_MACVLAN is not set
531# CONFIG_EQUALIZER is not set 552# CONFIG_EQUALIZER is not set
532# CONFIG_TUN is not set 553# CONFIG_TUN is not set
554# CONFIG_VETH is not set
533# CONFIG_ARCNET is not set 555# CONFIG_ARCNET is not set
534# CONFIG_PHYLIB is not set 556# CONFIG_PHYLIB is not set
535CONFIG_NET_ETHERNET=y 557CONFIG_NET_ETHERNET=y
536CONFIG_MII=y 558CONFIG_MII=y
559# CONFIG_AX88796 is not set
537# CONFIG_STNIC is not set 560# CONFIG_STNIC is not set
538# CONFIG_HAPPYMEAL is not set 561# CONFIG_HAPPYMEAL is not set
539# CONFIG_SUNGEM is not set 562# CONFIG_SUNGEM is not set
540# CONFIG_CASSINI is not set 563# CONFIG_CASSINI is not set
541# CONFIG_NET_VENDOR_3COM is not set 564# CONFIG_NET_VENDOR_3COM is not set
542# CONFIG_SMC91X is not set 565# CONFIG_SMC91X is not set
566# CONFIG_ENC28J60 is not set
543# CONFIG_NET_TULIP is not set 567# CONFIG_NET_TULIP is not set
544# CONFIG_HP100 is not set 568# CONFIG_HP100 is not set
569# CONFIG_IBM_NEW_EMAC_ZMII is not set
570# CONFIG_IBM_NEW_EMAC_RGMII is not set
571# CONFIG_IBM_NEW_EMAC_TAH is not set
572# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
545CONFIG_NET_PCI=y 573CONFIG_NET_PCI=y
546# CONFIG_PCNET32 is not set 574# CONFIG_PCNET32 is not set
547# CONFIG_AMD8111_ETH is not set 575# CONFIG_AMD8111_ETH is not set
548# CONFIG_ADAPTEC_STARFIRE is not set 576# CONFIG_ADAPTEC_STARFIRE is not set
549# CONFIG_B44 is not set 577# CONFIG_B44 is not set
550# CONFIG_FORCEDETH is not set 578# CONFIG_FORCEDETH is not set
551# CONFIG_DGRS is not set
552# CONFIG_EEPRO100 is not set 579# CONFIG_EEPRO100 is not set
553# CONFIG_E100 is not set 580# CONFIG_E100 is not set
554# CONFIG_FEALNX is not set 581# CONFIG_FEALNX is not set
@@ -560,6 +587,7 @@ CONFIG_8139TOO=y
560# CONFIG_8139TOO_TUNE_TWISTER is not set 587# CONFIG_8139TOO_TUNE_TWISTER is not set
561# CONFIG_8139TOO_8129 is not set 588# CONFIG_8139TOO_8129 is not set
562# CONFIG_8139_OLD_RX_RESET is not set 589# CONFIG_8139_OLD_RX_RESET is not set
590# CONFIG_R6040 is not set
563# CONFIG_SIS900 is not set 591# CONFIG_SIS900 is not set
564# CONFIG_EPIC100 is not set 592# CONFIG_EPIC100 is not set
565# CONFIG_SUNDANCE is not set 593# CONFIG_SUNDANCE is not set
@@ -570,6 +598,10 @@ CONFIG_NETDEV_1000=y
570# CONFIG_ACENIC is not set 598# CONFIG_ACENIC is not set
571# CONFIG_DL2K is not set 599# CONFIG_DL2K is not set
572# CONFIG_E1000 is not set 600# CONFIG_E1000 is not set
601# CONFIG_E1000E is not set
602# CONFIG_E1000E_ENABLED is not set
603# CONFIG_IP1000 is not set
604# CONFIG_IGB is not set
573# CONFIG_NS83820 is not set 605# CONFIG_NS83820 is not set
574# CONFIG_HAMACHI is not set 606# CONFIG_HAMACHI is not set
575# CONFIG_YELLOWFIN is not set 607# CONFIG_YELLOWFIN is not set
@@ -577,6 +609,7 @@ CONFIG_NETDEV_1000=y
577# CONFIG_SIS190 is not set 609# CONFIG_SIS190 is not set
578# CONFIG_SKGE is not set 610# CONFIG_SKGE is not set
579# CONFIG_SKY2 is not set 611# CONFIG_SKY2 is not set
612# CONFIG_SK98LIN is not set
580# CONFIG_VIA_VELOCITY is not set 613# CONFIG_VIA_VELOCITY is not set
581# CONFIG_TIGON3 is not set 614# CONFIG_TIGON3 is not set
582# CONFIG_BNX2 is not set 615# CONFIG_BNX2 is not set
@@ -585,11 +618,15 @@ CONFIG_NETDEV_1000=y
585CONFIG_NETDEV_10000=y 618CONFIG_NETDEV_10000=y
586# CONFIG_CHELSIO_T1 is not set 619# CONFIG_CHELSIO_T1 is not set
587# CONFIG_CHELSIO_T3 is not set 620# CONFIG_CHELSIO_T3 is not set
621# CONFIG_IXGBE is not set
588# CONFIG_IXGB is not set 622# CONFIG_IXGB is not set
589# CONFIG_S2IO is not set 623# CONFIG_S2IO is not set
590# CONFIG_MYRI10GE is not set 624# CONFIG_MYRI10GE is not set
591# CONFIG_NETXEN_NIC is not set 625# CONFIG_NETXEN_NIC is not set
626# CONFIG_NIU is not set
592# CONFIG_MLX4_CORE is not set 627# CONFIG_MLX4_CORE is not set
628# CONFIG_TEHUTI is not set
629# CONFIG_BNX2X is not set
593# CONFIG_TR is not set 630# CONFIG_TR is not set
594 631
595# 632#
@@ -597,13 +634,21 @@ CONFIG_NETDEV_10000=y
597# 634#
598# CONFIG_WLAN_PRE80211 is not set 635# CONFIG_WLAN_PRE80211 is not set
599# CONFIG_WLAN_80211 is not set 636# CONFIG_WLAN_80211 is not set
637
638#
639# USB Network Adapters
640#
641# CONFIG_USB_CATC is not set
642# CONFIG_USB_KAWETH is not set
643# CONFIG_USB_PEGASUS is not set
644# CONFIG_USB_RTL8150 is not set
645# CONFIG_USB_USBNET is not set
600# CONFIG_WAN is not set 646# CONFIG_WAN is not set
601# CONFIG_FDDI is not set 647# CONFIG_FDDI is not set
602# CONFIG_HIPPI is not set 648# CONFIG_HIPPI is not set
603# CONFIG_PPP is not set 649# CONFIG_PPP is not set
604# CONFIG_SLIP is not set 650# CONFIG_SLIP is not set
605# CONFIG_NET_FC is not set 651# CONFIG_NET_FC is not set
606# CONFIG_SHAPER is not set
607# CONFIG_NETCONSOLE is not set 652# CONFIG_NETCONSOLE is not set
608# CONFIG_NETPOLL is not set 653# CONFIG_NETPOLL is not set
609# CONFIG_NET_POLL_CONTROLLER is not set 654# CONFIG_NET_POLL_CONTROLLER is not set
@@ -622,7 +667,6 @@ CONFIG_INPUT=y
622# 667#
623# CONFIG_INPUT_MOUSEDEV is not set 668# CONFIG_INPUT_MOUSEDEV is not set
624# CONFIG_INPUT_JOYDEV is not set 669# CONFIG_INPUT_JOYDEV is not set
625# CONFIG_INPUT_TSDEV is not set
626# CONFIG_INPUT_EVDEV is not set 670# CONFIG_INPUT_EVDEV is not set
627# CONFIG_INPUT_EVBUG is not set 671# CONFIG_INPUT_EVBUG is not set
628 672
@@ -650,6 +694,7 @@ CONFIG_VT_CONSOLE=y
650CONFIG_HW_CONSOLE=y 694CONFIG_HW_CONSOLE=y
651CONFIG_VT_HW_CONSOLE_BINDING=y 695CONFIG_VT_HW_CONSOLE_BINDING=y
652# CONFIG_SERIAL_NONSTANDARD is not set 696# CONFIG_SERIAL_NONSTANDARD is not set
697# CONFIG_NOZOMI is not set
653 698
654# 699#
655# Serial drivers 700# Serial drivers
@@ -674,11 +719,9 @@ CONFIG_UNIX98_PTYS=y
674CONFIG_LEGACY_PTYS=y 719CONFIG_LEGACY_PTYS=y
675CONFIG_LEGACY_PTY_COUNT=256 720CONFIG_LEGACY_PTY_COUNT=256
676# CONFIG_IPMI_HANDLER is not set 721# CONFIG_IPMI_HANDLER is not set
677# CONFIG_WATCHDOG is not set
678CONFIG_HW_RANDOM=y 722CONFIG_HW_RANDOM=y
679# CONFIG_R3964 is not set 723# CONFIG_R3964 is not set
680# CONFIG_APPLICOM is not set 724# CONFIG_APPLICOM is not set
681# CONFIG_DRM is not set
682# CONFIG_RAW_DRIVER is not set 725# CONFIG_RAW_DRIVER is not set
683# CONFIG_TCG_TPM is not set 726# CONFIG_TCG_TPM is not set
684CONFIG_DEVPORT=y 727CONFIG_DEVPORT=y
@@ -687,16 +730,30 @@ CONFIG_DEVPORT=y
687# 730#
688# SPI support 731# SPI support
689# 732#
690# CONFIG_SPI is not set 733CONFIG_SPI=y
691# CONFIG_SPI_MASTER is not set 734CONFIG_SPI_MASTER=y
735
736#
737# SPI Master Controller Drivers
738#
739CONFIG_SPI_BITBANG=y
740CONFIG_SPI_SH_SCI=y
741
742#
743# SPI Protocol Masters
744#
745# CONFIG_SPI_AT25 is not set
746# CONFIG_SPI_SPIDEV is not set
747# CONFIG_SPI_TLE62X0 is not set
692# CONFIG_W1 is not set 748# CONFIG_W1 is not set
693# CONFIG_POWER_SUPPLY is not set 749# CONFIG_POWER_SUPPLY is not set
694CONFIG_HWMON=y 750CONFIG_HWMON=y
695# CONFIG_HWMON_VID is not set 751# CONFIG_HWMON_VID is not set
696# CONFIG_SENSORS_ABITUGURU is not set 752# CONFIG_SENSORS_I5K_AMB is not set
697# CONFIG_SENSORS_ABITUGURU3 is not set
698# CONFIG_SENSORS_F71805F is not set 753# CONFIG_SENSORS_F71805F is not set
754# CONFIG_SENSORS_F71882FG is not set
699# CONFIG_SENSORS_IT87 is not set 755# CONFIG_SENSORS_IT87 is not set
756# CONFIG_SENSORS_LM70 is not set
700# CONFIG_SENSORS_PC87360 is not set 757# CONFIG_SENSORS_PC87360 is not set
701# CONFIG_SENSORS_PC87427 is not set 758# CONFIG_SENSORS_PC87427 is not set
702# CONFIG_SENSORS_SIS5595 is not set 759# CONFIG_SENSORS_SIS5595 is not set
@@ -708,6 +765,13 @@ CONFIG_HWMON=y
708# CONFIG_SENSORS_W83627HF is not set 765# CONFIG_SENSORS_W83627HF is not set
709# CONFIG_SENSORS_W83627EHF is not set 766# CONFIG_SENSORS_W83627EHF is not set
710# CONFIG_HWMON_DEBUG_CHIP is not set 767# CONFIG_HWMON_DEBUG_CHIP is not set
768# CONFIG_WATCHDOG is not set
769
770#
771# Sonics Silicon Backplane
772#
773CONFIG_SSB_POSSIBLE=y
774# CONFIG_SSB is not set
711 775
712# 776#
713# Multifunction device drivers 777# Multifunction device drivers
@@ -720,16 +784,12 @@ CONFIG_MFD_SM501=y
720# CONFIG_VIDEO_DEV is not set 784# CONFIG_VIDEO_DEV is not set
721# CONFIG_DVB_CORE is not set 785# CONFIG_DVB_CORE is not set
722CONFIG_DAB=y 786CONFIG_DAB=y
787# CONFIG_USB_DABUSB is not set
723 788
724# 789#
725# Graphics support 790# Graphics support
726# 791#
727# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 792# CONFIG_DRM is not set
728
729#
730# Display device support
731#
732# CONFIG_DISPLAY_SUPPORT is not set
733# CONFIG_VGASTATE is not set 793# CONFIG_VGASTATE is not set
734CONFIG_VIDEO_OUTPUT_CONTROL=m 794CONFIG_VIDEO_OUTPUT_CONTROL=m
735CONFIG_FB=y 795CONFIG_FB=y
@@ -738,6 +798,7 @@ CONFIG_FB=y
738CONFIG_FB_CFB_FILLRECT=y 798CONFIG_FB_CFB_FILLRECT=y
739CONFIG_FB_CFB_COPYAREA=y 799CONFIG_FB_CFB_COPYAREA=y
740CONFIG_FB_CFB_IMAGEBLIT=y 800CONFIG_FB_CFB_IMAGEBLIT=y
801# CONFIG_FB_CFB_REV_PIXELS_IN_BYTE is not set
741# CONFIG_FB_SYS_FILLRECT is not set 802# CONFIG_FB_SYS_FILLRECT is not set
742# CONFIG_FB_SYS_COPYAREA is not set 803# CONFIG_FB_SYS_COPYAREA is not set
743# CONFIG_FB_SYS_IMAGEBLIT is not set 804# CONFIG_FB_SYS_IMAGEBLIT is not set
@@ -777,6 +838,12 @@ CONFIG_FB_DEFERRED_IO=y
777# CONFIG_FB_PM3 is not set 838# CONFIG_FB_PM3 is not set
778CONFIG_FB_SM501=y 839CONFIG_FB_SM501=y
779# CONFIG_FB_VIRTUAL is not set 840# CONFIG_FB_VIRTUAL is not set
841# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
842
843#
844# Display device support
845#
846# CONFIG_DISPLAY_SUPPORT is not set
780 847
781# 848#
782# Console display driver support 849# Console display driver support
@@ -844,6 +911,7 @@ CONFIG_SND_AC97_CODEC=m
844# CONFIG_SND_BT87X is not set 911# CONFIG_SND_BT87X is not set
845# CONFIG_SND_CA0106 is not set 912# CONFIG_SND_CA0106 is not set
846# CONFIG_SND_CMIPCI is not set 913# CONFIG_SND_CMIPCI is not set
914# CONFIG_SND_OXYGEN is not set
847# CONFIG_SND_CS4281 is not set 915# CONFIG_SND_CS4281 is not set
848# CONFIG_SND_CS46XX is not set 916# CONFIG_SND_CS46XX is not set
849# CONFIG_SND_DARLA20 is not set 917# CONFIG_SND_DARLA20 is not set
@@ -868,6 +936,7 @@ CONFIG_SND_AC97_CODEC=m
868# CONFIG_SND_HDA_INTEL is not set 936# CONFIG_SND_HDA_INTEL is not set
869# CONFIG_SND_HDSP is not set 937# CONFIG_SND_HDSP is not set
870# CONFIG_SND_HDSPM is not set 938# CONFIG_SND_HDSPM is not set
939# CONFIG_SND_HIFIER is not set
871# CONFIG_SND_ICE1712 is not set 940# CONFIG_SND_ICE1712 is not set
872# CONFIG_SND_ICE1724 is not set 941# CONFIG_SND_ICE1724 is not set
873# CONFIG_SND_INTEL8X0 is not set 942# CONFIG_SND_INTEL8X0 is not set
@@ -885,16 +954,27 @@ CONFIG_SND_AC97_CODEC=m
885# CONFIG_SND_TRIDENT is not set 954# CONFIG_SND_TRIDENT is not set
886# CONFIG_SND_VIA82XX is not set 955# CONFIG_SND_VIA82XX is not set
887# CONFIG_SND_VIA82XX_MODEM is not set 956# CONFIG_SND_VIA82XX_MODEM is not set
957# CONFIG_SND_VIRTUOSO is not set
888# CONFIG_SND_VX222 is not set 958# CONFIG_SND_VX222 is not set
889CONFIG_SND_YMFPCI=m 959CONFIG_SND_YMFPCI=m
890CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL=y 960CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL=y
891# CONFIG_SND_AC97_POWER_SAVE is not set 961# CONFIG_SND_AC97_POWER_SAVE is not set
892 962
893# 963#
964# SPI devices
965#
966
967#
894# SUPERH devices 968# SUPERH devices
895# 969#
896 970
897# 971#
972# USB devices
973#
974# CONFIG_SND_USB_AUDIO is not set
975# CONFIG_SND_USB_CAIAQ is not set
976
977#
898# System on Chip audio support 978# System on Chip audio support
899# 979#
900# CONFIG_SND_SOC is not set 980# CONFIG_SND_SOC is not set
@@ -904,6 +984,10 @@ CONFIG_SND_YMFPCI_FIRMWARE_IN_KERNEL=y
904# 984#
905 985
906# 986#
987# ALSA SoC audio for Freescale SOCs
988#
989
990#
907# Open Sound System 991# Open Sound System
908# 992#
909CONFIG_SOUND_PRIME=m 993CONFIG_SOUND_PRIME=m
@@ -914,19 +998,104 @@ CONFIG_AC97_BUS=m
914CONFIG_HID_SUPPORT=y 998CONFIG_HID_SUPPORT=y
915CONFIG_HID=y 999CONFIG_HID=y
916# CONFIG_HID_DEBUG is not set 1000# CONFIG_HID_DEBUG is not set
1001# CONFIG_HIDRAW is not set
1002
1003#
1004# USB Input Devices
1005#
1006CONFIG_USB_HID=y
1007# CONFIG_USB_HIDINPUT_POWERBOOK is not set
1008# CONFIG_HID_FF is not set
1009# CONFIG_USB_HIDDEV is not set
917CONFIG_USB_SUPPORT=y 1010CONFIG_USB_SUPPORT=y
918CONFIG_USB_ARCH_HAS_HCD=y 1011CONFIG_USB_ARCH_HAS_HCD=y
919CONFIG_USB_ARCH_HAS_OHCI=y 1012CONFIG_USB_ARCH_HAS_OHCI=y
920CONFIG_USB_ARCH_HAS_EHCI=y 1013CONFIG_USB_ARCH_HAS_EHCI=y
921# CONFIG_USB is not set 1014CONFIG_USB=y
1015# CONFIG_USB_DEBUG is not set
1016CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
1017
1018#
1019# Miscellaneous USB options
1020#
1021# CONFIG_USB_DEVICEFS is not set
1022CONFIG_USB_DEVICE_CLASS=y
1023# CONFIG_USB_DYNAMIC_MINORS is not set
1024# CONFIG_USB_OTG is not set
1025
1026#
1027# USB Host Controller Drivers
1028#
1029# CONFIG_USB_EHCI_HCD is not set
1030# CONFIG_USB_ISP116X_HCD is not set
1031CONFIG_USB_OHCI_HCD=y
1032# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
1033# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
1034CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1035# CONFIG_USB_UHCI_HCD is not set
1036# CONFIG_USB_SL811_HCD is not set
1037# CONFIG_USB_R8A66597_HCD is not set
1038
1039#
1040# USB Device Class drivers
1041#
1042# CONFIG_USB_ACM is not set
1043# CONFIG_USB_PRINTER is not set
922 1044
923# 1045#
924# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 1046# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
925# 1047#
926 1048
927# 1049#
928# USB Gadget Support 1050# may also be needed; see USB_STORAGE Help for more information
1051#
1052CONFIG_USB_STORAGE=y
1053# CONFIG_USB_STORAGE_DEBUG is not set
1054# CONFIG_USB_STORAGE_DATAFAB is not set
1055# CONFIG_USB_STORAGE_FREECOM is not set
1056# CONFIG_USB_STORAGE_ISD200 is not set
1057# CONFIG_USB_STORAGE_DPCM is not set
1058# CONFIG_USB_STORAGE_USBAT is not set
1059# CONFIG_USB_STORAGE_SDDR09 is not set
1060# CONFIG_USB_STORAGE_SDDR55 is not set
1061# CONFIG_USB_STORAGE_JUMPSHOT is not set
1062# CONFIG_USB_STORAGE_ALAUDA is not set
1063# CONFIG_USB_STORAGE_KARMA is not set
1064CONFIG_USB_LIBUSUAL=y
1065
1066#
1067# USB Imaging devices
1068#
1069# CONFIG_USB_MDC800 is not set
1070# CONFIG_USB_MICROTEK is not set
1071# CONFIG_USB_MON is not set
1072
1073#
1074# USB port drivers
1075#
1076# CONFIG_USB_SERIAL is not set
1077
1078#
1079# USB Miscellaneous drivers
929# 1080#
1081# CONFIG_USB_EMI62 is not set
1082# CONFIG_USB_EMI26 is not set
1083# CONFIG_USB_ADUTUX is not set
1084# CONFIG_USB_AUERSWALD is not set
1085# CONFIG_USB_RIO500 is not set
1086# CONFIG_USB_LEGOTOWER is not set
1087# CONFIG_USB_LCD is not set
1088# CONFIG_USB_BERRY_CHARGE is not set
1089# CONFIG_USB_LED is not set
1090# CONFIG_USB_CYPRESS_CY7C63 is not set
1091# CONFIG_USB_CYTHERM is not set
1092# CONFIG_USB_PHIDGET is not set
1093# CONFIG_USB_IDMOUSE is not set
1094# CONFIG_USB_FTDI_ELAN is not set
1095# CONFIG_USB_APPLEDISPLAY is not set
1096# CONFIG_USB_LD is not set
1097# CONFIG_USB_TRANCEVIBRATOR is not set
1098# CONFIG_USB_IOWARRIOR is not set
930# CONFIG_USB_GADGET is not set 1099# CONFIG_USB_GADGET is not set
931# CONFIG_MMC is not set 1100# CONFIG_MMC is not set
932# CONFIG_NEW_LEDS is not set 1101# CONFIG_NEW_LEDS is not set
@@ -949,13 +1118,17 @@ CONFIG_RTC_INTF_DEV=y
949# 1118#
950# SPI RTC drivers 1119# SPI RTC drivers
951# 1120#
1121# CONFIG_RTC_DRV_MAX6902 is not set
1122CONFIG_RTC_DRV_R9701=y
1123# CONFIG_RTC_DRV_RS5C348 is not set
952 1124
953# 1125#
954# Platform RTC drivers 1126# Platform RTC drivers
955# 1127#
1128# CONFIG_RTC_DRV_DS1511 is not set
956# CONFIG_RTC_DRV_DS1553 is not set 1129# CONFIG_RTC_DRV_DS1553 is not set
957# CONFIG_RTC_DRV_STK17TA8 is not set
958# CONFIG_RTC_DRV_DS1742 is not set 1130# CONFIG_RTC_DRV_DS1742 is not set
1131# CONFIG_RTC_DRV_STK17TA8 is not set
959# CONFIG_RTC_DRV_M48T86 is not set 1132# CONFIG_RTC_DRV_M48T86 is not set
960# CONFIG_RTC_DRV_M48T59 is not set 1133# CONFIG_RTC_DRV_M48T59 is not set
961# CONFIG_RTC_DRV_V3020 is not set 1134# CONFIG_RTC_DRV_V3020 is not set
@@ -963,20 +1136,7 @@ CONFIG_RTC_INTF_DEV=y
963# 1136#
964# on-CPU RTC drivers 1137# on-CPU RTC drivers
965# 1138#
966CONFIG_RTC_DRV_SH=y 1139# CONFIG_RTC_DRV_SH is not set
967
968#
969# DMA Engine support
970#
971# CONFIG_DMA_ENGINE is not set
972
973#
974# DMA Clients
975#
976
977#
978# DMA Devices
979#
980 1140
981# 1141#
982# Userspace I/O 1142# Userspace I/O
@@ -1034,7 +1194,6 @@ CONFIG_TMPFS=y
1034# CONFIG_TMPFS_POSIX_ACL is not set 1194# CONFIG_TMPFS_POSIX_ACL is not set
1035# CONFIG_HUGETLBFS is not set 1195# CONFIG_HUGETLBFS is not set
1036# CONFIG_HUGETLB_PAGE is not set 1196# CONFIG_HUGETLB_PAGE is not set
1037CONFIG_RAMFS=y
1038# CONFIG_CONFIGFS_FS is not set 1197# CONFIG_CONFIGFS_FS is not set
1039 1198
1040# 1199#
@@ -1053,10 +1212,7 @@ CONFIG_RAMFS=y
1053# CONFIG_QNX4FS_FS is not set 1212# CONFIG_QNX4FS_FS is not set
1054# CONFIG_SYSV_FS is not set 1213# CONFIG_SYSV_FS is not set
1055# CONFIG_UFS_FS is not set 1214# CONFIG_UFS_FS is not set
1056 1215CONFIG_NETWORK_FILESYSTEMS=y
1057#
1058# Network File Systems
1059#
1060# CONFIG_NFS_FS is not set 1216# CONFIG_NFS_FS is not set
1061# CONFIG_NFSD is not set 1217# CONFIG_NFSD is not set
1062# CONFIG_SMB_FS is not set 1218# CONFIG_SMB_FS is not set
@@ -1070,10 +1226,6 @@ CONFIG_RAMFS=y
1070# 1226#
1071# CONFIG_PARTITION_ADVANCED is not set 1227# CONFIG_PARTITION_ADVANCED is not set
1072CONFIG_MSDOS_PARTITION=y 1228CONFIG_MSDOS_PARTITION=y
1073
1074#
1075# Native Language Support
1076#
1077CONFIG_NLS=y 1229CONFIG_NLS=y
1078CONFIG_NLS_DEFAULT="iso8859-1" 1230CONFIG_NLS_DEFAULT="iso8859-1"
1079# CONFIG_NLS_CODEPAGE_437 is not set 1231# CONFIG_NLS_CODEPAGE_437 is not set
@@ -1114,30 +1266,22 @@ CONFIG_NLS_CODEPAGE_932=y
1114# CONFIG_NLS_KOI8_R is not set 1266# CONFIG_NLS_KOI8_R is not set
1115# CONFIG_NLS_KOI8_U is not set 1267# CONFIG_NLS_KOI8_U is not set
1116# CONFIG_NLS_UTF8 is not set 1268# CONFIG_NLS_UTF8 is not set
1117
1118#
1119# Distributed Lock Manager
1120#
1121# CONFIG_DLM is not set 1269# CONFIG_DLM is not set
1122 1270
1123# 1271#
1124# Profiling support
1125#
1126CONFIG_PROFILING=y
1127CONFIG_OPROFILE=y
1128
1129#
1130# Kernel hacking 1272# Kernel hacking
1131# 1273#
1132CONFIG_TRACE_IRQFLAGS_SUPPORT=y 1274CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1133# CONFIG_PRINTK_TIME is not set 1275# CONFIG_PRINTK_TIME is not set
1276CONFIG_ENABLE_WARN_DEPRECATED=y
1134CONFIG_ENABLE_MUST_CHECK=y 1277CONFIG_ENABLE_MUST_CHECK=y
1135# CONFIG_MAGIC_SYSRQ is not set 1278# CONFIG_MAGIC_SYSRQ is not set
1136# CONFIG_UNUSED_SYMBOLS is not set 1279# CONFIG_UNUSED_SYMBOLS is not set
1137# CONFIG_DEBUG_FS is not set 1280CONFIG_DEBUG_FS=y
1138# CONFIG_HEADERS_CHECK is not set 1281# CONFIG_HEADERS_CHECK is not set
1139# CONFIG_DEBUG_KERNEL is not set 1282# CONFIG_DEBUG_KERNEL is not set
1140# CONFIG_DEBUG_BUGVERBOSE is not set 1283# CONFIG_DEBUG_BUGVERBOSE is not set
1284# CONFIG_SAMPLES is not set
1141# CONFIG_SH_STANDARD_BIOS is not set 1285# CONFIG_SH_STANDARD_BIOS is not set
1142CONFIG_EARLY_SCIF_CONSOLE=y 1286CONFIG_EARLY_SCIF_CONSOLE=y
1143CONFIG_EARLY_SCIF_CONSOLE_PORT=0xffe80000 1287CONFIG_EARLY_SCIF_CONSOLE_PORT=0xffe80000
@@ -1149,7 +1293,53 @@ CONFIG_EARLY_PRINTK=y
1149# 1293#
1150# CONFIG_KEYS is not set 1294# CONFIG_KEYS is not set
1151# CONFIG_SECURITY is not set 1295# CONFIG_SECURITY is not set
1152# CONFIG_CRYPTO is not set 1296# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1297CONFIG_CRYPTO=y
1298# CONFIG_CRYPTO_SEQIV is not set
1299# CONFIG_CRYPTO_MANAGER is not set
1300# CONFIG_CRYPTO_HMAC is not set
1301# CONFIG_CRYPTO_XCBC is not set
1302# CONFIG_CRYPTO_NULL is not set
1303# CONFIG_CRYPTO_MD4 is not set
1304# CONFIG_CRYPTO_MD5 is not set
1305# CONFIG_CRYPTO_SHA1 is not set
1306# CONFIG_CRYPTO_SHA256 is not set
1307# CONFIG_CRYPTO_SHA512 is not set
1308# CONFIG_CRYPTO_WP512 is not set
1309# CONFIG_CRYPTO_TGR192 is not set
1310# CONFIG_CRYPTO_GF128MUL is not set
1311# CONFIG_CRYPTO_ECB is not set
1312# CONFIG_CRYPTO_CBC is not set
1313# CONFIG_CRYPTO_PCBC is not set
1314# CONFIG_CRYPTO_LRW is not set
1315# CONFIG_CRYPTO_XTS is not set
1316# CONFIG_CRYPTO_CTR is not set
1317# CONFIG_CRYPTO_GCM is not set
1318# CONFIG_CRYPTO_CCM is not set
1319# CONFIG_CRYPTO_CRYPTD is not set
1320# CONFIG_CRYPTO_DES is not set
1321# CONFIG_CRYPTO_FCRYPT is not set
1322# CONFIG_CRYPTO_BLOWFISH is not set
1323# CONFIG_CRYPTO_TWOFISH is not set
1324# CONFIG_CRYPTO_SERPENT is not set
1325# CONFIG_CRYPTO_AES is not set
1326# CONFIG_CRYPTO_CAST5 is not set
1327# CONFIG_CRYPTO_CAST6 is not set
1328# CONFIG_CRYPTO_TEA is not set
1329# CONFIG_CRYPTO_ARC4 is not set
1330# CONFIG_CRYPTO_KHAZAD is not set
1331# CONFIG_CRYPTO_ANUBIS is not set
1332# CONFIG_CRYPTO_SEED is not set
1333# CONFIG_CRYPTO_SALSA20 is not set
1334# CONFIG_CRYPTO_DEFLATE is not set
1335# CONFIG_CRYPTO_MICHAEL_MIC is not set
1336# CONFIG_CRYPTO_CRC32C is not set
1337# CONFIG_CRYPTO_CAMELLIA is not set
1338# CONFIG_CRYPTO_TEST is not set
1339# CONFIG_CRYPTO_AUTHENC is not set
1340# CONFIG_CRYPTO_LZO is not set
1341CONFIG_CRYPTO_HW=y
1342# CONFIG_CRYPTO_DEV_HIFN_795X is not set
1153 1343
1154# 1344#
1155# Library routines 1345# Library routines
diff --git a/arch/sh/configs/se7705_defconfig b/arch/sh/configs/se7705_defconfig
index 87ae5c1f8629..84717d854867 100644
--- a/arch/sh/configs/se7705_defconfig
+++ b/arch/sh/configs/se7705_defconfig
@@ -231,7 +231,6 @@ CONFIG_CPU_LITTLE_ENDIAN=y
231# CONFIG_SH_DSP is not set 231# CONFIG_SH_DSP is not set
232# CONFIG_SH_ADC is not set 232# CONFIG_SH_ADC is not set
233CONFIG_CPU_HAS_INTEVT=y 233CONFIG_CPU_HAS_INTEVT=y
234CONFIG_CPU_HAS_PINT_IRQ=y
235CONFIG_CPU_HAS_IPR_IRQ=y 234CONFIG_CPU_HAS_IPR_IRQ=y
236CONFIG_CPU_HAS_SR_RB=y 235CONFIG_CPU_HAS_SR_RB=y
237 236
diff --git a/arch/sh/drivers/dma/dma-api.c b/arch/sh/drivers/dma/dma-api.c
index 76ed816d9a24..727126e907e3 100644
--- a/arch/sh/drivers/dma/dma-api.c
+++ b/arch/sh/drivers/dma/dma-api.c
@@ -350,7 +350,7 @@ int register_dmac(struct dma_info *info)
350 350
351 BUG_ON((info->flags & DMAC_CHANNELS_CONFIGURED) && !info->channels); 351 BUG_ON((info->flags & DMAC_CHANNELS_CONFIGURED) && !info->channels);
352 352
353 info->pdev = platform_device_register_simple((char *)info->name, -1, 353 info->pdev = platform_device_register_simple(info->name, -1,
354 NULL, 0); 354 NULL, 0);
355 if (IS_ERR(info->pdev)) 355 if (IS_ERR(info->pdev))
356 return PTR_ERR(info->pdev); 356 return PTR_ERR(info->pdev);
diff --git a/arch/sh/drivers/pci/fixups-lboxre2.c b/arch/sh/drivers/pci/fixups-lboxre2.c
index 40b19bdfb891..1c1d41255ec0 100644
--- a/arch/sh/drivers/pci/fixups-lboxre2.c
+++ b/arch/sh/drivers/pci/fixups-lboxre2.c
@@ -18,7 +18,7 @@ int pci_fixup_pcic(void)
18{ 18{
19 unsigned long bcr1, mcr; 19 unsigned long bcr1, mcr;
20 20
21 bcr1 = inl(SH7751_BCR1); 21 bcr1 = ctrl_inl(SH7751_BCR1);
22 bcr1 |= 0x40080000; /* Enable Bit 19 BREQEN, set PCIC to slave */ 22 bcr1 |= 0x40080000; /* Enable Bit 19 BREQEN, set PCIC to slave */
23 pci_write_reg(bcr1, SH4_PCIBCR1); 23 pci_write_reg(bcr1, SH4_PCIBCR1);
24 24
@@ -28,7 +28,7 @@ int pci_fixup_pcic(void)
28 pci_write_reg(0xfb900047, SH7751_PCICONF1); 28 pci_write_reg(0xfb900047, SH7751_PCICONF1);
29 pci_write_reg(0xab000001, SH7751_PCICONF4); 29 pci_write_reg(0xab000001, SH7751_PCICONF4);
30 30
31 mcr = inl(SH7751_MCR); 31 mcr = ctrl_inl(SH7751_MCR);
32 mcr = (mcr & PCIMCR_MRSET_OFF) & PCIMCR_RFSH_OFF; 32 mcr = (mcr & PCIMCR_MRSET_OFF) & PCIMCR_RFSH_OFF;
33 pci_write_reg(mcr, SH4_PCIMCR); 33 pci_write_reg(mcr, SH4_PCIMCR);
34 34
diff --git a/arch/sh/drivers/pci/fixups-rts7751r2d.c b/arch/sh/drivers/pci/fixups-rts7751r2d.c
index e72ceb560d5b..904bce8768d3 100644
--- a/arch/sh/drivers/pci/fixups-rts7751r2d.c
+++ b/arch/sh/drivers/pci/fixups-rts7751r2d.c
@@ -19,7 +19,7 @@ int pci_fixup_pcic(void)
19{ 19{
20 unsigned long bcr1, mcr; 20 unsigned long bcr1, mcr;
21 21
22 bcr1 = inl(SH7751_BCR1); 22 bcr1 = ctrl_inl(SH7751_BCR1);
23 bcr1 |= 0x40080000; /* Enable Bit 19 BREQEN, set PCIC to slave */ 23 bcr1 |= 0x40080000; /* Enable Bit 19 BREQEN, set PCIC to slave */
24 pci_write_reg(bcr1, SH4_PCIBCR1); 24 pci_write_reg(bcr1, SH4_PCIBCR1);
25 25
@@ -30,7 +30,7 @@ int pci_fixup_pcic(void)
30 pci_write_reg(0xfb900047, SH7751_PCICONF1); 30 pci_write_reg(0xfb900047, SH7751_PCICONF1);
31 pci_write_reg(0xab000001, SH7751_PCICONF4); 31 pci_write_reg(0xab000001, SH7751_PCICONF4);
32 32
33 mcr = inl(SH7751_MCR); 33 mcr = ctrl_inl(SH7751_MCR);
34 mcr = (mcr & PCIMCR_MRSET_OFF) & PCIMCR_RFSH_OFF; 34 mcr = (mcr & PCIMCR_MRSET_OFF) & PCIMCR_RFSH_OFF;
35 pci_write_reg(mcr, SH4_PCIMCR); 35 pci_write_reg(mcr, SH4_PCIMCR);
36 36
diff --git a/arch/sh/drivers/pci/ops-dreamcast.c b/arch/sh/drivers/pci/ops-dreamcast.c
index e1284fc69361..0dac87b19624 100644
--- a/arch/sh/drivers/pci/ops-dreamcast.c
+++ b/arch/sh/drivers/pci/ops-dreamcast.c
@@ -83,9 +83,9 @@ static int gapspci_read(struct pci_bus *bus, unsigned int devfn, int where, int
83 return PCIBIOS_DEVICE_NOT_FOUND; 83 return PCIBIOS_DEVICE_NOT_FOUND;
84 84
85 switch (size) { 85 switch (size) {
86 case 1: *val = inb(GAPSPCI_BBA_CONFIG+where); break; 86 case 1: *val = ctrl_inb(GAPSPCI_BBA_CONFIG+where); break;
87 case 2: *val = inw(GAPSPCI_BBA_CONFIG+where); break; 87 case 2: *val = ctrl_inw(GAPSPCI_BBA_CONFIG+where); break;
88 case 4: *val = inl(GAPSPCI_BBA_CONFIG+where); break; 88 case 4: *val = ctrl_inl(GAPSPCI_BBA_CONFIG+where); break;
89 } 89 }
90 90
91 return PCIBIOS_SUCCESSFUL; 91 return PCIBIOS_SUCCESSFUL;
@@ -97,9 +97,9 @@ static int gapspci_write(struct pci_bus *bus, unsigned int devfn, int where, int
97 return PCIBIOS_DEVICE_NOT_FOUND; 97 return PCIBIOS_DEVICE_NOT_FOUND;
98 98
99 switch (size) { 99 switch (size) {
100 case 1: outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break; 100 case 1: ctrl_outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break;
101 case 2: outw((u16)val, GAPSPCI_BBA_CONFIG+where); break; 101 case 2: ctrl_outw((u16)val, GAPSPCI_BBA_CONFIG+where); break;
102 case 4: outl((u32)val, GAPSPCI_BBA_CONFIG+where); break; 102 case 4: ctrl_outl((u32)val, GAPSPCI_BBA_CONFIG+where); break;
103 } 103 }
104 104
105 return PCIBIOS_SUCCESSFUL; 105 return PCIBIOS_SUCCESSFUL;
@@ -127,36 +127,36 @@ int __init gapspci_init(void)
127 */ 127 */
128 128
129 for (i=0; i<16; i++) 129 for (i=0; i<16; i++)
130 idbuf[i] = inb(GAPSPCI_REGS+i); 130 idbuf[i] = ctrl_inb(GAPSPCI_REGS+i);
131 131
132 if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16)) 132 if (strncmp(idbuf, "GAPSPCI_BRIDGE_2", 16))
133 return -ENODEV; 133 return -ENODEV;
134 134
135 outl(0x5a14a501, GAPSPCI_REGS+0x18); 135 ctrl_outl(0x5a14a501, GAPSPCI_REGS+0x18);
136 136
137 for (i=0; i<1000000; i++) 137 for (i=0; i<1000000; i++)
138 ; 138 ;
139 139
140 if (inl(GAPSPCI_REGS+0x18) != 1) 140 if (ctrl_inl(GAPSPCI_REGS+0x18) != 1)
141 return -EINVAL; 141 return -EINVAL;
142 142
143 outl(0x01000000, GAPSPCI_REGS+0x20); 143 ctrl_outl(0x01000000, GAPSPCI_REGS+0x20);
144 outl(0x01000000, GAPSPCI_REGS+0x24); 144 ctrl_outl(0x01000000, GAPSPCI_REGS+0x24);
145 145
146 outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28); 146 ctrl_outl(GAPSPCI_DMA_BASE, GAPSPCI_REGS+0x28);
147 outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c); 147 ctrl_outl(GAPSPCI_DMA_BASE+GAPSPCI_DMA_SIZE, GAPSPCI_REGS+0x2c);
148 148
149 outl(1, GAPSPCI_REGS+0x14); 149 ctrl_outl(1, GAPSPCI_REGS+0x14);
150 outl(1, GAPSPCI_REGS+0x34); 150 ctrl_outl(1, GAPSPCI_REGS+0x34);
151 151
152 /* Setting Broadband Adapter */ 152 /* Setting Broadband Adapter */
153 outw(0xf900, GAPSPCI_BBA_CONFIG+0x06); 153 ctrl_outw(0xf900, GAPSPCI_BBA_CONFIG+0x06);
154 outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30); 154 ctrl_outl(0x00000000, GAPSPCI_BBA_CONFIG+0x30);
155 outb(0x00, GAPSPCI_BBA_CONFIG+0x3c); 155 ctrl_outb(0x00, GAPSPCI_BBA_CONFIG+0x3c);
156 outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d); 156 ctrl_outb(0xf0, GAPSPCI_BBA_CONFIG+0x0d);
157 outw(0x0006, GAPSPCI_BBA_CONFIG+0x04); 157 ctrl_outw(0x0006, GAPSPCI_BBA_CONFIG+0x04);
158 outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10); 158 ctrl_outl(0x00002001, GAPSPCI_BBA_CONFIG+0x10);
159 outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14); 159 ctrl_outl(0x01000000, GAPSPCI_BBA_CONFIG+0x14);
160 160
161 return 0; 161 return 0;
162} 162}
diff --git a/arch/sh/drivers/pci/ops-rts7751r2d.c b/arch/sh/drivers/pci/ops-rts7751r2d.c
index ec8430c8d2d1..b3fa3e2ef184 100644
--- a/arch/sh/drivers/pci/ops-rts7751r2d.c
+++ b/arch/sh/drivers/pci/ops-rts7751r2d.c
@@ -33,7 +33,7 @@ int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
33static struct resource sh7751_io_resource = { 33static struct resource sh7751_io_resource = {
34 .name = "SH7751_IO", 34 .name = "SH7751_IO",
35 .start = 0x4000, 35 .start = 0x4000,
36 .end = 0x4000 + SH7751_PCI_IO_SIZE - 1, 36 .end = SH7751_PCI_IO_SIZE - 1,
37 .flags = IORESOURCE_IO 37 .flags = IORESOURCE_IO
38}; 38};
39 39
@@ -68,6 +68,7 @@ static struct sh4_pci_address_map sh7751_pci_map = {
68 68
69int __init pcibios_init_platform(void) 69int __init pcibios_init_platform(void)
70{ 70{
71 __set_io_port_base(SH7751_PCI_IO_BASE);
71 return sh7751_pcic_init(&sh7751_pci_map); 72 return sh7751_pcic_init(&sh7751_pci_map);
72} 73}
73 74
diff --git a/arch/sh/drivers/pci/pci-sh4.h b/arch/sh/drivers/pci/pci-sh4.h
index 4925c79ea959..07e29506080f 100644
--- a/arch/sh/drivers/pci/pci-sh4.h
+++ b/arch/sh/drivers/pci/pci-sh4.h
@@ -172,11 +172,11 @@ struct sh4_pci_address_map {
172 172
173static inline void pci_write_reg(unsigned long val, unsigned long reg) 173static inline void pci_write_reg(unsigned long val, unsigned long reg)
174{ 174{
175 outl(val, PCI_REG(reg)); 175 ctrl_outl(val, PCI_REG(reg));
176} 176}
177 177
178static inline unsigned long pci_read_reg(unsigned long reg) 178static inline unsigned long pci_read_reg(unsigned long reg)
179{ 179{
180 return inl(PCI_REG(reg)); 180 return ctrl_inl(PCI_REG(reg));
181} 181}
182#endif /* __PCI_SH4_H */ 182#endif /* __PCI_SH4_H */
diff --git a/arch/sh/drivers/pci/pci-sh7751.c b/arch/sh/drivers/pci/pci-sh7751.c
index 1aca7fe5783b..3065eb184f01 100644
--- a/arch/sh/drivers/pci/pci-sh7751.c
+++ b/arch/sh/drivers/pci/pci-sh7751.c
@@ -58,7 +58,7 @@ static int __init __area_sdram_check(unsigned int area)
58{ 58{
59 u32 word; 59 u32 word;
60 60
61 word = inl(SH7751_BCR1); 61 word = ctrl_inl(SH7751_BCR1);
62 /* check BCR for SDRAM in area */ 62 /* check BCR for SDRAM in area */
63 if (((word >> area) & 1) == 0) { 63 if (((word >> area) & 1) == 0) {
64 printk("PCI: Area %d is not configured for SDRAM. BCR1=0x%x\n", 64 printk("PCI: Area %d is not configured for SDRAM. BCR1=0x%x\n",
@@ -67,7 +67,7 @@ static int __init __area_sdram_check(unsigned int area)
67 } 67 }
68 pci_write_reg(word, SH4_PCIBCR1); 68 pci_write_reg(word, SH4_PCIBCR1);
69 69
70 word = (u16)inw(SH7751_BCR2); 70 word = (u16)ctrl_inw(SH7751_BCR2);
71 /* check BCR2 for 32bit SDRAM interface*/ 71 /* check BCR2 for 32bit SDRAM interface*/
72 if (((word >> (area << 1)) & 0x3) != 0x3) { 72 if (((word >> (area << 1)) & 0x3) != 0x3) {
73 printk("PCI: Area %d is not 32 bit SDRAM. BCR2=0x%x\n", 73 printk("PCI: Area %d is not 32 bit SDRAM. BCR2=0x%x\n",
@@ -85,9 +85,9 @@ int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
85 u32 word; 85 u32 word;
86 86
87 /* Set the BCR's to enable PCI access */ 87 /* Set the BCR's to enable PCI access */
88 reg = inl(SH7751_BCR1); 88 reg = ctrl_inl(SH7751_BCR1);
89 reg |= 0x80000; 89 reg |= 0x80000;
90 outl(reg, SH7751_BCR1); 90 ctrl_outl(reg, SH7751_BCR1);
91 91
92 /* Turn the clocks back on (not done in reset)*/ 92 /* Turn the clocks back on (not done in reset)*/
93 pci_write_reg(0, SH4_PCICLKR); 93 pci_write_reg(0, SH4_PCICLKR);
@@ -179,13 +179,13 @@ int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
179 return 0; 179 return 0;
180 180
181 /* configure the wait control registers */ 181 /* configure the wait control registers */
182 word = inl(SH7751_WCR1); 182 word = ctrl_inl(SH7751_WCR1);
183 pci_write_reg(word, SH4_PCIWCR1); 183 pci_write_reg(word, SH4_PCIWCR1);
184 word = inl(SH7751_WCR2); 184 word = ctrl_inl(SH7751_WCR2);
185 pci_write_reg(word, SH4_PCIWCR2); 185 pci_write_reg(word, SH4_PCIWCR2);
186 word = inl(SH7751_WCR3); 186 word = ctrl_inl(SH7751_WCR3);
187 pci_write_reg(word, SH4_PCIWCR3); 187 pci_write_reg(word, SH4_PCIWCR3);
188 word = inl(SH7751_MCR); 188 word = ctrl_inl(SH7751_MCR);
189 pci_write_reg(word, SH4_PCIMCR); 189 pci_write_reg(word, SH4_PCIMCR);
190 190
191 /* NOTE: I'm ignoring the PCI error IRQs for now.. 191 /* NOTE: I'm ignoring the PCI error IRQs for now..
diff --git a/arch/sh/drivers/pci/pci-sh7780.c b/arch/sh/drivers/pci/pci-sh7780.c
index 7d797f4de5e7..b2a2bfa3c1bd 100644
--- a/arch/sh/drivers/pci/pci-sh7780.c
+++ b/arch/sh/drivers/pci/pci-sh7780.c
@@ -52,7 +52,7 @@ static int __init sh7780_pci_init(void)
52 52
53 pr_debug("PCI: Starting intialization.\n"); 53 pr_debug("PCI: Starting intialization.\n");
54 54
55 outl(0x00000001, SH7780_PCI_VCR2); /* Enable PCIC */ 55 ctrl_outl(0x00000001, SH7780_PCI_VCR2); /* Enable PCIC */
56 56
57 /* check for SH7780/SH7780R hardware */ 57 /* check for SH7780/SH7780R hardware */
58 id = pci_read_reg(SH7780_PCIVID); 58 id = pci_read_reg(SH7780_PCIVID);
diff --git a/arch/sh/kernel/Makefile_32 b/arch/sh/kernel/Makefile_32
index c89289831053..62bf373266f7 100644
--- a/arch/sh/kernel/Makefile_32
+++ b/arch/sh/kernel/Makefile_32
@@ -22,5 +22,6 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
22obj-$(CONFIG_PM) += pm.o 22obj-$(CONFIG_PM) += pm.o
23obj-$(CONFIG_STACKTRACE) += stacktrace.o 23obj-$(CONFIG_STACKTRACE) += stacktrace.o
24obj-$(CONFIG_BINFMT_ELF) += dump_task.o 24obj-$(CONFIG_BINFMT_ELF) += dump_task.o
25obj-$(CONFIG_IO_TRAPPED) += io_trapped.o
25 26
26EXTRA_CFLAGS += -Werror 27EXTRA_CFLAGS += -Werror
diff --git a/arch/sh/kernel/Makefile_64 b/arch/sh/kernel/Makefile_64
index 1ef21cc087f3..e01283d49cbf 100644
--- a/arch/sh/kernel/Makefile_64
+++ b/arch/sh/kernel/Makefile_64
@@ -18,5 +18,6 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
18obj-$(CONFIG_PM) += pm.o 18obj-$(CONFIG_PM) += pm.o
19obj-$(CONFIG_STACKTRACE) += stacktrace.o 19obj-$(CONFIG_STACKTRACE) += stacktrace.o
20obj-$(CONFIG_BINFMT_ELF) += dump_task.o 20obj-$(CONFIG_BINFMT_ELF) += dump_task.o
21obj-$(CONFIG_IO_TRAPPED) += io_trapped.o
21 22
22EXTRA_CFLAGS += -Werror 23EXTRA_CFLAGS += -Werror
diff --git a/arch/sh/kernel/cpu/irq/Makefile b/arch/sh/kernel/cpu/irq/Makefile
index cc1836e47a5d..462a8f6dfee2 100644
--- a/arch/sh/kernel/cpu/irq/Makefile
+++ b/arch/sh/kernel/cpu/irq/Makefile
@@ -6,4 +6,3 @@ obj-y += intc.o
6obj-$(CONFIG_SUPERH32) += imask.o 6obj-$(CONFIG_SUPERH32) += imask.o
7obj-$(CONFIG_CPU_SH5) += intc-sh5.o 7obj-$(CONFIG_CPU_SH5) += intc-sh5.o
8obj-$(CONFIG_CPU_HAS_IPR_IRQ) += ipr.o 8obj-$(CONFIG_CPU_HAS_IPR_IRQ) += ipr.o
9obj-$(CONFIG_CPU_HAS_MASKREG_IRQ) += maskreg.o
diff --git a/arch/sh/kernel/cpu/irq/intc-sh5.c b/arch/sh/kernel/cpu/irq/intc-sh5.c
index 43ee7a9a4f0b..d6e0e2bdaad5 100644
--- a/arch/sh/kernel/cpu/irq/intc-sh5.c
+++ b/arch/sh/kernel/cpu/irq/intc-sh5.c
@@ -75,21 +75,6 @@ int intc_evt_to_irq[(0xE20/0x20)+1] = {
75 -1, -1 /* 0xE00 - 0xE20 */ 75 -1, -1 /* 0xE00 - 0xE20 */
76}; 76};
77 77
78/*
79 * Opposite mapper.
80 */
81static int IRQ_to_vectorN[NR_INTC_IRQS] = {
82 0x12, 0x15, 0x18, 0x1B, 0x40, 0x41, 0x42, 0x43, /* 0- 7 */
83 -1, -1, -1, -1, 0x50, 0x51, 0x52, 0x53, /* 8-15 */
84 0x54, 0x55, 0x32, 0x33, 0x34, 0x35, 0x36, -1, /* 16-23 */
85 -1, -1, -1, -1, -1, -1, -1, -1, /* 24-31 */
86 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x38, /* 32-39 */
87 0x39, 0x3A, 0x3B, -1, -1, -1, -1, -1, /* 40-47 */
88 -1, -1, -1, -1, -1, -1, -1, -1, /* 48-55 */
89 -1, -1, -1, -1, -1, -1, -1, 0x2B, /* 56-63 */
90
91};
92
93static unsigned long intc_virt; 78static unsigned long intc_virt;
94 79
95static unsigned int startup_intc_irq(unsigned int irq); 80static unsigned int startup_intc_irq(unsigned int irq);
@@ -176,6 +161,18 @@ void make_intc_irq(unsigned int irq)
176} 161}
177 162
178#if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL) 163#if defined(CONFIG_PROC_FS) && defined(CONFIG_SYSCTL)
164static int IRQ_to_vectorN[NR_INTC_IRQS] = {
165 0x12, 0x15, 0x18, 0x1B, 0x40, 0x41, 0x42, 0x43, /* 0- 7 */
166 -1, -1, -1, -1, 0x50, 0x51, 0x52, 0x53, /* 8-15 */
167 0x54, 0x55, 0x32, 0x33, 0x34, 0x35, 0x36, -1, /* 16-23 */
168 -1, -1, -1, -1, -1, -1, -1, -1, /* 24-31 */
169 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x38, /* 32-39 */
170 0x39, 0x3A, 0x3B, -1, -1, -1, -1, -1, /* 40-47 */
171 -1, -1, -1, -1, -1, -1, -1, -1, /* 48-55 */
172 -1, -1, -1, -1, -1, -1, -1, 0x2B, /* 56-63 */
173
174};
175
179int intc_irq_describe(char* p, int irq) 176int intc_irq_describe(char* p, int irq)
180{ 177{
181 if (irq < NR_INTC_IRQS) 178 if (irq < NR_INTC_IRQS)
diff --git a/arch/sh/kernel/cpu/irq/maskreg.c b/arch/sh/kernel/cpu/irq/maskreg.c
deleted file mode 100644
index 978992e367a5..000000000000
--- a/arch/sh/kernel/cpu/irq/maskreg.c
+++ /dev/null
@@ -1,93 +0,0 @@
1/*
2 * Interrupt handling for Simple external interrupt mask register
3 *
4 * Copyright (C) 2001 A&D Co., Ltd. <http://www.aandd.co.jp>
5 *
6 * This is for the machine which have single 16 bit register
7 * for masking external IRQ individually.
8 * Each bit of the register is for masking each interrupt.
9 *
10 * This file may be copied or modified under the terms of the GNU
11 * General Public License. See linux/COPYING for more information.
12 */
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/irq.h>
16#include <asm/system.h>
17#include <asm/io.h>
18
19/* address of external interrupt mask register */
20unsigned long irq_mask_register;
21
22/* forward declaration */
23static unsigned int startup_maskreg_irq(unsigned int irq);
24static void shutdown_maskreg_irq(unsigned int irq);
25static void enable_maskreg_irq(unsigned int irq);
26static void disable_maskreg_irq(unsigned int irq);
27static void mask_and_ack_maskreg(unsigned int);
28static void end_maskreg_irq(unsigned int irq);
29
30/* hw_interrupt_type */
31static struct hw_interrupt_type maskreg_irq_type = {
32 .typename = "Mask Register",
33 .startup = startup_maskreg_irq,
34 .shutdown = shutdown_maskreg_irq,
35 .enable = enable_maskreg_irq,
36 .disable = disable_maskreg_irq,
37 .ack = mask_and_ack_maskreg,
38 .end = end_maskreg_irq
39};
40
41/* actual implementation */
42static unsigned int startup_maskreg_irq(unsigned int irq)
43{
44 enable_maskreg_irq(irq);
45 return 0; /* never anything pending */
46}
47
48static void shutdown_maskreg_irq(unsigned int irq)
49{
50 disable_maskreg_irq(irq);
51}
52
53static void disable_maskreg_irq(unsigned int irq)
54{
55 unsigned short val, mask = 0x01 << irq;
56
57 BUG_ON(!irq_mask_register);
58
59 /* Set "irq"th bit */
60 val = ctrl_inw(irq_mask_register);
61 val |= mask;
62 ctrl_outw(val, irq_mask_register);
63}
64
65static void enable_maskreg_irq(unsigned int irq)
66{
67 unsigned short val, mask = ~(0x01 << irq);
68
69 BUG_ON(!irq_mask_register);
70
71 /* Clear "irq"th bit */
72 val = ctrl_inw(irq_mask_register);
73 val &= mask;
74 ctrl_outw(val, irq_mask_register);
75}
76
77static void mask_and_ack_maskreg(unsigned int irq)
78{
79 disable_maskreg_irq(irq);
80}
81
82static void end_maskreg_irq(unsigned int irq)
83{
84 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
85 enable_maskreg_irq(irq);
86}
87
88void make_maskreg_irq(unsigned int irq)
89{
90 disable_irq_nosync(irq);
91 irq_desc[irq].handler = &maskreg_irq_type;
92 disable_maskreg_irq(irq);
93}
diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
index f2b9238cda04..9e89984c4f1d 100644
--- a/arch/sh/kernel/cpu/sh4/probe.c
+++ b/arch/sh/kernel/cpu/sh4/probe.c
@@ -126,12 +126,18 @@ int __init detect_cpu_and_cache_system(void)
126 CPU_HAS_LLSC; 126 CPU_HAS_LLSC;
127 break; 127 break;
128 case 0x3008: 128 case 0x3008:
129 if (prr == 0xa0) { 129 if (prr == 0xa0 || prr == 0xa1) {
130 boot_cpu_data.type = CPU_SH7722; 130 boot_cpu_data.type = CPU_SH7722;
131 boot_cpu_data.icache.ways = 4; 131 boot_cpu_data.icache.ways = 4;
132 boot_cpu_data.dcache.ways = 4; 132 boot_cpu_data.dcache.ways = 4;
133 boot_cpu_data.flags |= CPU_HAS_LLSC; 133 boot_cpu_data.flags |= CPU_HAS_LLSC;
134 } 134 }
135 else if (prr == 0x70) {
136 boot_cpu_data.type = CPU_SH7366;
137 boot_cpu_data.icache.ways = 4;
138 boot_cpu_data.dcache.ways = 4;
139 boot_cpu_data.flags |= CPU_HAS_LLSC;
140 }
135 break; 141 break;
136 case 0x4000: /* 1st cut */ 142 case 0x4000: /* 1st cut */
137 case 0x4001: /* 2nd cut */ 143 case 0x4001: /* 2nd cut */
diff --git a/arch/sh/kernel/cpu/sh4a/Makefile b/arch/sh/kernel/cpu/sh4a/Makefile
index 08ac6387bf17..5d890ac8e793 100644
--- a/arch/sh/kernel/cpu/sh4a/Makefile
+++ b/arch/sh/kernel/cpu/sh4a/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_CPU_SUBTYPE_SH7780) += setup-sh7780.o
9obj-$(CONFIG_CPU_SUBTYPE_SH7785) += setup-sh7785.o 9obj-$(CONFIG_CPU_SUBTYPE_SH7785) += setup-sh7785.o
10obj-$(CONFIG_CPU_SUBTYPE_SH7343) += setup-sh7343.o 10obj-$(CONFIG_CPU_SUBTYPE_SH7343) += setup-sh7343.o
11obj-$(CONFIG_CPU_SUBTYPE_SH7722) += setup-sh7722.o 11obj-$(CONFIG_CPU_SUBTYPE_SH7722) += setup-sh7722.o
12obj-$(CONFIG_CPU_SUBTYPE_SH7366) += setup-sh7366.o
12obj-$(CONFIG_CPU_SUBTYPE_SHX3) += setup-shx3.o 13obj-$(CONFIG_CPU_SUBTYPE_SHX3) += setup-shx3.o
13 14
14# SMP setup 15# SMP setup
@@ -21,6 +22,7 @@ clock-$(CONFIG_CPU_SUBTYPE_SH7780) := clock-sh7780.o
21clock-$(CONFIG_CPU_SUBTYPE_SH7785) := clock-sh7785.o 22clock-$(CONFIG_CPU_SUBTYPE_SH7785) := clock-sh7785.o
22clock-$(CONFIG_CPU_SUBTYPE_SH7343) := clock-sh7343.o 23clock-$(CONFIG_CPU_SUBTYPE_SH7343) := clock-sh7343.o
23clock-$(CONFIG_CPU_SUBTYPE_SH7722) := clock-sh7722.o 24clock-$(CONFIG_CPU_SUBTYPE_SH7722) := clock-sh7722.o
25clock-$(CONFIG_CPU_SUBTYPE_SH7366) := clock-sh7722.o
24clock-$(CONFIG_CPU_SUBTYPE_SHX3) := clock-shx3.o 26clock-$(CONFIG_CPU_SUBTYPE_SHX3) := clock-shx3.o
25 27
26obj-y += $(clock-y) 28obj-y += $(clock-y)
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index a0fd8bb21f7c..299138ebe160 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/sh/kernel/cpu/sh4a/clock-sh7722.c 2 * arch/sh/kernel/cpu/sh4a/clock-sh7722.c
3 * 3 *
4 * SH7722 support for the clock framework 4 * SH7722 & SH7366 support for the clock framework
5 * 5 *
6 * Copyright (c) 2006-2007 Nomad Global Solutions Inc 6 * Copyright (c) 2006-2007 Nomad Global Solutions Inc
7 * Based on code for sh7343 by Paul Mundt 7 * Based on code for sh7343 by Paul Mundt
@@ -417,15 +417,19 @@ static int sh7722_siu_which(struct clk *clk)
417 return 0; 417 return 0;
418 if (!strcmp(clk->name, "siu_b_clk")) 418 if (!strcmp(clk->name, "siu_b_clk"))
419 return 1; 419 return 1;
420#if defined(CONFIG_CPU_SUBTYPE_SH7722)
420 if (!strcmp(clk->name, "irda_clk")) 421 if (!strcmp(clk->name, "irda_clk"))
421 return 2; 422 return 2;
423#endif
422 return -EINVAL; 424 return -EINVAL;
423} 425}
424 426
425static unsigned long sh7722_siu_regs[] = { 427static unsigned long sh7722_siu_regs[] = {
426 [0] = SCLKACR, 428 [0] = SCLKACR,
427 [1] = SCLKBCR, 429 [1] = SCLKBCR,
430#if defined(CONFIG_CPU_SUBTYPE_SH7722)
428 [2] = IrDACLKCR, 431 [2] = IrDACLKCR,
432#endif
429}; 433};
430 434
431static int sh7722_siu_start_stop(struct clk *clk, int enable) 435static int sh7722_siu_start_stop(struct clk *clk, int enable)
@@ -571,10 +575,12 @@ static struct clk sh7722_siu_b_clock = {
571 .ops = &sh7722_siu_clk_ops, 575 .ops = &sh7722_siu_clk_ops,
572}; 576};
573 577
578#if defined(CONFIG_CPU_SUBTYPE_SH7722)
574static struct clk sh7722_irda_clock = { 579static struct clk sh7722_irda_clock = {
575 .name = "irda_clk", 580 .name = "irda_clk",
576 .ops = &sh7722_siu_clk_ops, 581 .ops = &sh7722_siu_clk_ops,
577}; 582};
583#endif
578 584
579static struct clk sh7722_video_clock = { 585static struct clk sh7722_video_clock = {
580 .name = "video_clk", 586 .name = "video_clk",
@@ -588,7 +594,9 @@ static struct clk *sh7722_clocks[] = {
588 &sh7722_sdram_clock, 594 &sh7722_sdram_clock,
589 &sh7722_siu_a_clock, 595 &sh7722_siu_a_clock,
590 &sh7722_siu_b_clock, 596 &sh7722_siu_b_clock,
597#if defined(CONFIG_CPU_SUBTYPE_SH7722)
591 &sh7722_irda_clock, 598 &sh7722_irda_clock,
599#endif
592 &sh7722_video_clock, 600 &sh7722_video_clock,
593}; 601};
594 602
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
new file mode 100644
index 000000000000..967e8b69a2f8
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
@@ -0,0 +1,177 @@
1/*
2 * SH7366 Setup
3 *
4 * Copyright (C) 2008 Renesas Solutions
5 *
6 * Based on linux/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/platform_device.h>
13#include <linux/init.h>
14#include <linux/serial.h>
15#include <asm/sci.h>
16
17static struct plat_sci_port sci_platform_data[] = {
18 {
19 .mapbase = 0xffe00000,
20 .flags = UPF_BOOT_AUTOCONF,
21 .type = PORT_SCIF,
22 .irqs = { 80, 80, 80, 80 },
23 }, {
24 .flags = 0,
25 }
26};
27
28static struct platform_device sci_device = {
29 .name = "sh-sci",
30 .id = -1,
31 .dev = {
32 .platform_data = sci_platform_data,
33 },
34};
35
36static struct platform_device *sh7366_devices[] __initdata = {
37 &sci_device,
38};
39
40static int __init sh7366_devices_setup(void)
41{
42 return platform_add_devices(sh7366_devices,
43 ARRAY_SIZE(sh7366_devices));
44}
45__initcall(sh7366_devices_setup);
46
47enum {
48 UNUSED=0,
49
50 /* interrupt sources */
51 IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7,
52 ICB,
53 DMAC0, DMAC1, DMAC2, DMAC3,
54 VIO_CEUI, VIO_BEUI, VIO_VEUI, VOU,
55 MFI, VPU, USB,
56 MMC_MMC1I, MMC_MMC2I, MMC_MMC3I,
57 DMAC4, DMAC5, DMAC_DADERR,
58 SCIF, SCIFA1, SCIFA2,
59 DENC, MSIOF,
60 FLCTL_FLSTEI, FLCTL_FLENDI, FLCTL_FLTREQ0I, FLCTL_FLTREQ1I,
61 I2C_ALI, I2C_TACKI, I2C_WAITI, I2C_DTEI,
62 SDHI0, SDHI1, SDHI2, SDHI3,
63 CMT, TSIF, SIU,
64 TMU0, TMU1, TMU2,
65 VEU2, LCDC,
66
67 /* interrupt groups */
68
69 DMAC0123, VIOVOU, MMC, DMAC45, FLCTL, I2C, SDHI,
70};
71
72static struct intc_vect vectors[] __initdata = {
73 INTC_VECT(IRQ0, 0x600), INTC_VECT(IRQ1, 0x620),
74 INTC_VECT(IRQ2, 0x640), INTC_VECT(IRQ3, 0x660),
75 INTC_VECT(IRQ4, 0x680), INTC_VECT(IRQ5, 0x6a0),
76 INTC_VECT(IRQ6, 0x6c0), INTC_VECT(IRQ7, 0x6e0),
77 INTC_VECT(ICB, 0x700),
78 INTC_VECT(DMAC0, 0x800), INTC_VECT(DMAC1, 0x820),
79 INTC_VECT(DMAC2, 0x840), INTC_VECT(DMAC3, 0x860),
80 INTC_VECT(VIO_CEUI, 0x880), INTC_VECT(VIO_BEUI, 0x8a0),
81 INTC_VECT(VIO_VEUI, 0x8c0), INTC_VECT(VOU, 0x8e0),
82 INTC_VECT(MFI, 0x900), INTC_VECT(VPU, 0x980), INTC_VECT(USB, 0xa20),
83 INTC_VECT(MMC_MMC1I, 0xb00), INTC_VECT(MMC_MMC2I, 0xb20),
84 INTC_VECT(MMC_MMC3I, 0xb40),
85 INTC_VECT(DMAC4, 0xb80), INTC_VECT(DMAC5, 0xba0),
86 INTC_VECT(DMAC_DADERR, 0xbc0),
87 INTC_VECT(SCIF, 0xc00), INTC_VECT(SCIFA1, 0xc20),
88 INTC_VECT(SCIFA2, 0xc40),
89 INTC_VECT(DENC, 0xc60), INTC_VECT(MSIOF, 0xc80),
90 INTC_VECT(FLCTL_FLSTEI, 0xd80), INTC_VECT(FLCTL_FLENDI, 0xda0),
91 INTC_VECT(FLCTL_FLTREQ0I, 0xdc0), INTC_VECT(FLCTL_FLTREQ1I, 0xde0),
92 INTC_VECT(I2C_ALI, 0xe00), INTC_VECT(I2C_TACKI, 0xe20),
93 INTC_VECT(I2C_WAITI, 0xe40), INTC_VECT(I2C_DTEI, 0xe60),
94 INTC_VECT(SDHI0, 0xe80), INTC_VECT(SDHI1, 0xea0),
95 INTC_VECT(SDHI2, 0xec0), INTC_VECT(SDHI3, 0xee0),
96 INTC_VECT(CMT, 0xf00), INTC_VECT(TSIF, 0xf20),
97 INTC_VECT(SIU, 0xf80),
98 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
99 INTC_VECT(TMU2, 0x440),
100 INTC_VECT(VEU2, 0x580), INTC_VECT(LCDC, 0x580),
101};
102
103static struct intc_group groups[] __initdata = {
104 INTC_GROUP(DMAC0123, DMAC0, DMAC1, DMAC2, DMAC3),
105 INTC_GROUP(VIOVOU, VIO_CEUI, VIO_BEUI, VIO_VEUI, VOU),
106 INTC_GROUP(MMC, MMC_MMC1I, MMC_MMC2I, MMC_MMC3I),
107 INTC_GROUP(DMAC45, DMAC4, DMAC5, DMAC_DADERR),
108 INTC_GROUP(FLCTL, FLCTL_FLSTEI, FLCTL_FLENDI,
109 FLCTL_FLTREQ0I, FLCTL_FLTREQ1I),
110 INTC_GROUP(I2C, I2C_ALI, I2C_TACKI, I2C_WAITI, I2C_DTEI),
111 INTC_GROUP(SDHI, SDHI0, SDHI1, SDHI2, SDHI3),
112};
113
114static struct intc_mask_reg mask_registers[] __initdata = {
115 { 0xa4080080, 0xa40800c0, 8, /* IMR0 / IMCR0 */
116 { } },
117 { 0xa4080084, 0xa40800c4, 8, /* IMR1 / IMCR1 */
118 { VOU, VIO_VEUI, VIO_BEUI, VIO_CEUI, DMAC3, DMAC2, DMAC1, DMAC0 } },
119 { 0xa4080088, 0xa40800c8, 8, /* IMR2 / IMCR2 */
120 { 0, 0, 0, VPU, 0, 0, 0, MFI } },
121 { 0xa408008c, 0xa40800cc, 8, /* IMR3 / IMCR3 */
122 { 0, 0, 0, ICB } },
123 { 0xa4080090, 0xa40800d0, 8, /* IMR4 / IMCR4 */
124 { 0, TMU2, TMU1, TMU0, VEU2, 0, 0, LCDC } },
125 { 0xa4080094, 0xa40800d4, 8, /* IMR5 / IMCR5 */
126 { 0, DMAC_DADERR, DMAC5, DMAC4, DENC, SCIFA2, SCIFA1, SCIF } },
127 { 0xa4080098, 0xa40800d8, 8, /* IMR6 / IMCR6 */
128 { 0, 0, 0, 0, 0, 0, 0, MSIOF } },
129 { 0xa408009c, 0xa40800dc, 8, /* IMR7 / IMCR7 */
130 { I2C_DTEI, I2C_WAITI, I2C_TACKI, I2C_ALI,
131 FLCTL_FLTREQ1I, FLCTL_FLTREQ0I, FLCTL_FLENDI, FLCTL_FLSTEI } },
132 { 0xa40800a0, 0xa40800e0, 8, /* IMR8 / IMCR8 */
133 { SDHI3, SDHI2, SDHI1, SDHI0, 0, 0, 0, SIU } },
134 { 0xa40800a4, 0xa40800e4, 8, /* IMR9 / IMCR9 */
135 { 0, 0, 0, CMT, 0, USB, } },
136 { 0xa40800a8, 0xa40800e8, 8, /* IMR10 / IMCR10 */
137 { 0, MMC_MMC3I, MMC_MMC2I, MMC_MMC1I } },
138 { 0xa40800ac, 0xa40800ec, 8, /* IMR11 / IMCR11 */
139 { 0, 0, 0, 0, 0, 0, 0, TSIF } },
140 { 0xa4140044, 0xa4140064, 8, /* INTMSK00 / INTMSKCLR00 */
141 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
142};
143
144static struct intc_prio_reg prio_registers[] __initdata = {
145 { 0xa4080000, 0, 16, 4, /* IPRA */ { TMU0, TMU1, TMU2 } },
146 { 0xa4080004, 0, 16, 4, /* IPRB */ { VEU2, LCDC, ICB } },
147 { 0xa4080008, 0, 16, 4, /* IPRC */ { } },
148 { 0xa408000c, 0, 16, 4, /* IPRD */ { } },
149 { 0xa4080010, 0, 16, 4, /* IPRE */ { DMAC0123, VIOVOU, MFI, VPU } },
150 { 0xa4080014, 0, 16, 4, /* IPRF */ { 0, DMAC45, USB, CMT } },
151 { 0xa4080018, 0, 16, 4, /* IPRG */ { SCIF, SCIFA1, SCIFA2, DENC } },
152 { 0xa408001c, 0, 16, 4, /* IPRH */ { MSIOF, 0, FLCTL, I2C } },
153 { 0xa4080020, 0, 16, 4, /* IPRI */ { 0, 0, TSIF, } },
154 { 0xa4080024, 0, 16, 4, /* IPRJ */ { 0, 0, SIU } },
155 { 0xa4080028, 0, 16, 4, /* IPRK */ { 0, MMC, 0, SDHI } },
156 { 0xa408002c, 0, 16, 4, /* IPRL */ { } },
157 { 0xa4140010, 0, 32, 4, /* INTPRI00 */
158 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
159};
160
161static struct intc_sense_reg sense_registers[] __initdata = {
162 { 0xa414001c, 16, 2, /* ICR1 */
163 { IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5, IRQ6, IRQ7 } },
164};
165
166static DECLARE_INTC_DESC(intc_desc, "sh7366", vectors, groups,
167 mask_registers, prio_registers, sense_registers);
168
169void __init plat_irq_setup(void)
170{
171 register_intc_controller(&intc_desc);
172}
173
174void __init plat_mem_setup(void)
175{
176 /* TODO: Register Node 1 */
177}
diff --git a/arch/sh/kernel/cpu/sh5/probe.c b/arch/sh/kernel/cpu/sh5/probe.c
index 15d167fd0ae7..31f8cb0f6374 100644
--- a/arch/sh/kernel/cpu/sh5/probe.c
+++ b/arch/sh/kernel/cpu/sh5/probe.c
@@ -20,19 +20,18 @@ int __init detect_cpu_and_cache_system(void)
20{ 20{
21 unsigned long long cir; 21 unsigned long long cir;
22 22
23 /* Do peeks in real mode to avoid having to set up a mapping for the 23 /*
24 WPC registers. On SH5-101 cut2, such a mapping would be exposed to 24 * Do peeks in real mode to avoid having to set up a mapping for
25 an address translation erratum which would make it hard to set up 25 * the WPC registers. On SH5-101 cut2, such a mapping would be
26 correctly. */ 26 * exposed to an address translation erratum which would make it
27 * hard to set up correctly.
28 */
27 cir = peek_real_address_q(0x0d000008); 29 cir = peek_real_address_q(0x0d000008);
28 if ((cir & 0xffff) == 0x5103) { 30 if ((cir & 0xffff) == 0x5103)
29 boot_cpu_data.type = CPU_SH5_103; 31 boot_cpu_data.type = CPU_SH5_103;
30 } else if (((cir >> 32) & 0xffff) == 0x51e2) { 32 else if (((cir >> 32) & 0xffff) == 0x51e2)
31 /* CPU.VCR aliased at CIR address on SH5-101 */ 33 /* CPU.VCR aliased at CIR address on SH5-101 */
32 boot_cpu_data.type = CPU_SH5_101; 34 boot_cpu_data.type = CPU_SH5_101;
33 } else {
34 boot_cpu_data.type = CPU_SH_NONE;
35 }
36 35
37 /* 36 /*
38 * First, setup some sane values for the I-cache. 37 * First, setup some sane values for the I-cache.
@@ -40,37 +39,33 @@ int __init detect_cpu_and_cache_system(void)
40 boot_cpu_data.icache.ways = 4; 39 boot_cpu_data.icache.ways = 4;
41 boot_cpu_data.icache.sets = 256; 40 boot_cpu_data.icache.sets = 256;
42 boot_cpu_data.icache.linesz = L1_CACHE_BYTES; 41 boot_cpu_data.icache.linesz = L1_CACHE_BYTES;
42 boot_cpu_data.icache.way_incr = (1 << 13);
43 boot_cpu_data.icache.entry_shift = 5;
44 boot_cpu_data.icache.way_size = boot_cpu_data.icache.sets *
45 boot_cpu_data.icache.linesz;
46 boot_cpu_data.icache.entry_mask = 0x1fe0;
47 boot_cpu_data.icache.flags = 0;
43 48
44#if 0
45 /* 49 /*
46 * FIXME: This can probably be cleaned up a bit as well.. for example, 50 * Next, setup some sane values for the D-cache.
47 * do we really need the way shift _and_ the way_step_shift ?? Judging 51 *
48 * by the existing code, I would guess no.. is there any valid reason 52 * On the SH5, these are pretty consistent with the I-cache settings,
49 * why we need to be tracking this around? 53 * so we just copy over the existing definitions.. these can be fixed
54 * up later, especially if we add runtime CPU probing.
55 *
56 * Though in the meantime it saves us from having to duplicate all of
57 * the above definitions..
50 */ 58 */
51 boot_cpu_data.icache.way_shift = 13; 59 boot_cpu_data.dcache = boot_cpu_data.icache;
52 boot_cpu_data.icache.entry_shift = 5;
53 boot_cpu_data.icache.set_shift = 4;
54 boot_cpu_data.icache.way_step_shift = 16;
55 boot_cpu_data.icache.asid_shift = 2;
56 60
57 /* 61 /*
58 * way offset = cache size / associativity, so just don't factor in 62 * Setup any cache-related flags here
59 * associativity in the first place..
60 */ 63 */
61 boot_cpu_data.icache.way_ofs = boot_cpu_data.icache.sets * 64#if defined(CONFIG_CACHE_WRITETHROUGH)
62 boot_cpu_data.icache.linesz; 65 set_bit(SH_CACHE_MODE_WT, &(boot_cpu_data.dcache.flags));
63 66#elif defined(CONFIG_CACHE_WRITEBACK)
64 boot_cpu_data.icache.asid_mask = 0x3fc; 67 set_bit(SH_CACHE_MODE_WB, &(boot_cpu_data.dcache.flags));
65 boot_cpu_data.icache.idx_mask = 0x1fe0;
66 boot_cpu_data.icache.epn_mask = 0xffffe000;
67#endif 68#endif
68 69
69 boot_cpu_data.icache.flags = 0;
70
71 /* A trivial starting point.. */
72 memcpy(&boot_cpu_data.dcache,
73 &boot_cpu_data.icache, sizeof(struct cache_info));
74
75 return 0; 70 return 0;
76} 71}
diff --git a/arch/sh/kernel/io.c b/arch/sh/kernel/io.c
index 71c9fde2fd90..2b8991229900 100644
--- a/arch/sh/kernel/io.c
+++ b/arch/sh/kernel/io.c
@@ -63,7 +63,13 @@ EXPORT_SYMBOL(memset_io);
63 63
64void __iomem *ioport_map(unsigned long port, unsigned int nr) 64void __iomem *ioport_map(unsigned long port, unsigned int nr)
65{ 65{
66 return sh_mv.mv_ioport_map(port, nr); 66 void __iomem *ret;
67
68 ret = __ioport_map_trapped(port, nr);
69 if (ret)
70 return ret;
71
72 return __ioport_map(port, nr);
67} 73}
68EXPORT_SYMBOL(ioport_map); 74EXPORT_SYMBOL(ioport_map);
69 75
diff --git a/arch/sh/kernel/io_generic.c b/arch/sh/kernel/io_generic.c
index 771ea4230441..db769449f5a7 100644
--- a/arch/sh/kernel/io_generic.c
+++ b/arch/sh/kernel/io_generic.c
@@ -33,17 +33,17 @@ static inline void delay(void)
33 33
34u8 generic_inb(unsigned long port) 34u8 generic_inb(unsigned long port)
35{ 35{
36 return ctrl_inb((unsigned long __force)ioport_map(port, 1)); 36 return ctrl_inb((unsigned long __force)__ioport_map(port, 1));
37} 37}
38 38
39u16 generic_inw(unsigned long port) 39u16 generic_inw(unsigned long port)
40{ 40{
41 return ctrl_inw((unsigned long __force)ioport_map(port, 2)); 41 return ctrl_inw((unsigned long __force)__ioport_map(port, 2));
42} 42}
43 43
44u32 generic_inl(unsigned long port) 44u32 generic_inl(unsigned long port)
45{ 45{
46 return ctrl_inl((unsigned long __force)ioport_map(port, 4)); 46 return ctrl_inl((unsigned long __force)__ioport_map(port, 4));
47} 47}
48 48
49u8 generic_inb_p(unsigned long port) 49u8 generic_inb_p(unsigned long port)
@@ -81,7 +81,7 @@ void generic_insb(unsigned long port, void *dst, unsigned long count)
81 volatile u8 *port_addr; 81 volatile u8 *port_addr;
82 u8 *buf = dst; 82 u8 *buf = dst;
83 83
84 port_addr = (volatile u8 *)ioport_map(port, 1); 84 port_addr = (volatile u8 *)__ioport_map(port, 1);
85 while (count--) 85 while (count--)
86 *buf++ = *port_addr; 86 *buf++ = *port_addr;
87} 87}
@@ -91,7 +91,7 @@ void generic_insw(unsigned long port, void *dst, unsigned long count)
91 volatile u16 *port_addr; 91 volatile u16 *port_addr;
92 u16 *buf = dst; 92 u16 *buf = dst;
93 93
94 port_addr = (volatile u16 *)ioport_map(port, 2); 94 port_addr = (volatile u16 *)__ioport_map(port, 2);
95 while (count--) 95 while (count--)
96 *buf++ = *port_addr; 96 *buf++ = *port_addr;
97 97
@@ -103,7 +103,7 @@ void generic_insl(unsigned long port, void *dst, unsigned long count)
103 volatile u32 *port_addr; 103 volatile u32 *port_addr;
104 u32 *buf = dst; 104 u32 *buf = dst;
105 105
106 port_addr = (volatile u32 *)ioport_map(port, 4); 106 port_addr = (volatile u32 *)__ioport_map(port, 4);
107 while (count--) 107 while (count--)
108 *buf++ = *port_addr; 108 *buf++ = *port_addr;
109 109
@@ -112,17 +112,17 @@ void generic_insl(unsigned long port, void *dst, unsigned long count)
112 112
113void generic_outb(u8 b, unsigned long port) 113void generic_outb(u8 b, unsigned long port)
114{ 114{
115 ctrl_outb(b, (unsigned long __force)ioport_map(port, 1)); 115 ctrl_outb(b, (unsigned long __force)__ioport_map(port, 1));
116} 116}
117 117
118void generic_outw(u16 b, unsigned long port) 118void generic_outw(u16 b, unsigned long port)
119{ 119{
120 ctrl_outw(b, (unsigned long __force)ioport_map(port, 2)); 120 ctrl_outw(b, (unsigned long __force)__ioport_map(port, 2));
121} 121}
122 122
123void generic_outl(u32 b, unsigned long port) 123void generic_outl(u32 b, unsigned long port)
124{ 124{
125 ctrl_outl(b, (unsigned long __force)ioport_map(port, 4)); 125 ctrl_outl(b, (unsigned long __force)__ioport_map(port, 4));
126} 126}
127 127
128void generic_outb_p(u8 b, unsigned long port) 128void generic_outb_p(u8 b, unsigned long port)
@@ -153,7 +153,7 @@ void generic_outsb(unsigned long port, const void *src, unsigned long count)
153 volatile u8 *port_addr; 153 volatile u8 *port_addr;
154 const u8 *buf = src; 154 const u8 *buf = src;
155 155
156 port_addr = (volatile u8 __force *)ioport_map(port, 1); 156 port_addr = (volatile u8 __force *)__ioport_map(port, 1);
157 157
158 while (count--) 158 while (count--)
159 *port_addr = *buf++; 159 *port_addr = *buf++;
@@ -164,7 +164,7 @@ void generic_outsw(unsigned long port, const void *src, unsigned long count)
164 volatile u16 *port_addr; 164 volatile u16 *port_addr;
165 const u16 *buf = src; 165 const u16 *buf = src;
166 166
167 port_addr = (volatile u16 __force *)ioport_map(port, 2); 167 port_addr = (volatile u16 __force *)__ioport_map(port, 2);
168 168
169 while (count--) 169 while (count--)
170 *port_addr = *buf++; 170 *port_addr = *buf++;
@@ -177,7 +177,7 @@ void generic_outsl(unsigned long port, const void *src, unsigned long count)
177 volatile u32 *port_addr; 177 volatile u32 *port_addr;
178 const u32 *buf = src; 178 const u32 *buf = src;
179 179
180 port_addr = (volatile u32 __force *)ioport_map(port, 4); 180 port_addr = (volatile u32 __force *)__ioport_map(port, 4);
181 while (count--) 181 while (count--)
182 *port_addr = *buf++; 182 *port_addr = *buf++;
183 183
diff --git a/arch/sh/kernel/io_trapped.c b/arch/sh/kernel/io_trapped.c
new file mode 100644
index 000000000000..86a665d92201
--- /dev/null
+++ b/arch/sh/kernel/io_trapped.c
@@ -0,0 +1,276 @@
1/*
2 * Trapped io support
3 *
4 * Copyright (C) 2008 Magnus Damm
5 *
6 * Intercept io operations by trapping.
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#include <linux/kernel.h>
13#include <linux/mm.h>
14#include <linux/bitops.h>
15#include <linux/vmalloc.h>
16#include <linux/module.h>
17#include <asm/system.h>
18#include <asm/mmu_context.h>
19#include <asm/uaccess.h>
20#include <asm/io.h>
21#include <asm/io_trapped.h>
22
23#define TRAPPED_PAGES_MAX 16
24
25#ifdef CONFIG_HAS_IOPORT
26LIST_HEAD(trapped_io);
27EXPORT_SYMBOL_GPL(trapped_io);
28#endif
29#ifdef CONFIG_HAS_IOMEM
30LIST_HEAD(trapped_mem);
31EXPORT_SYMBOL_GPL(trapped_mem);
32#endif
33static DEFINE_SPINLOCK(trapped_lock);
34
35int __init register_trapped_io(struct trapped_io *tiop)
36{
37 struct resource *res;
38 unsigned long len = 0, flags = 0;
39 struct page *pages[TRAPPED_PAGES_MAX];
40 int k, n;
41
42 /* structure must be page aligned */
43 if ((unsigned long)tiop & (PAGE_SIZE - 1))
44 goto bad;
45
46 for (k = 0; k < tiop->num_resources; k++) {
47 res = tiop->resource + k;
48 len += roundup((res->end - res->start) + 1, PAGE_SIZE);
49 flags |= res->flags;
50 }
51
52 /* support IORESOURCE_IO _or_ MEM, not both */
53 if (hweight_long(flags) != 1)
54 goto bad;
55
56 n = len >> PAGE_SHIFT;
57
58 if (n >= TRAPPED_PAGES_MAX)
59 goto bad;
60
61 for (k = 0; k < n; k++)
62 pages[k] = virt_to_page(tiop);
63
64 tiop->virt_base = vmap(pages, n, VM_MAP, PAGE_NONE);
65 if (!tiop->virt_base)
66 goto bad;
67
68 len = 0;
69 for (k = 0; k < tiop->num_resources; k++) {
70 res = tiop->resource + k;
71 pr_info("trapped io 0x%08lx overrides %s 0x%08lx\n",
72 (unsigned long)(tiop->virt_base + len),
73 res->flags & IORESOURCE_IO ? "io" : "mmio",
74 (unsigned long)res->start);
75 len += roundup((res->end - res->start) + 1, PAGE_SIZE);
76 }
77
78 tiop->magic = IO_TRAPPED_MAGIC;
79 INIT_LIST_HEAD(&tiop->list);
80 spin_lock_irq(&trapped_lock);
81 if (flags & IORESOURCE_IO)
82 list_add(&tiop->list, &trapped_io);
83 if (flags & IORESOURCE_MEM)
84 list_add(&tiop->list, &trapped_mem);
85 spin_unlock_irq(&trapped_lock);
86
87 return 0;
88 bad:
89 pr_warning("unable to install trapped io filter\n");
90 return -1;
91}
92EXPORT_SYMBOL_GPL(register_trapped_io);
93
94void __iomem *match_trapped_io_handler(struct list_head *list,
95 unsigned long offset,
96 unsigned long size)
97{
98 unsigned long voffs;
99 struct trapped_io *tiop;
100 struct resource *res;
101 int k, len;
102
103 spin_lock_irq(&trapped_lock);
104 list_for_each_entry(tiop, list, list) {
105 voffs = 0;
106 for (k = 0; k < tiop->num_resources; k++) {
107 res = tiop->resource + k;
108 if (res->start == offset) {
109 spin_unlock_irq(&trapped_lock);
110 return tiop->virt_base + voffs;
111 }
112
113 len = (res->end - res->start) + 1;
114 voffs += roundup(len, PAGE_SIZE);
115 }
116 }
117 spin_unlock_irq(&trapped_lock);
118 return NULL;
119}
120EXPORT_SYMBOL_GPL(match_trapped_io_handler);
121
122static struct trapped_io *lookup_tiop(unsigned long address)
123{
124 pgd_t *pgd_k;
125 pud_t *pud_k;
126 pmd_t *pmd_k;
127 pte_t *pte_k;
128 pte_t entry;
129
130 pgd_k = swapper_pg_dir + pgd_index(address);
131 if (!pgd_present(*pgd_k))
132 return NULL;
133
134 pud_k = pud_offset(pgd_k, address);
135 if (!pud_present(*pud_k))
136 return NULL;
137
138 pmd_k = pmd_offset(pud_k, address);
139 if (!pmd_present(*pmd_k))
140 return NULL;
141
142 pte_k = pte_offset_kernel(pmd_k, address);
143 entry = *pte_k;
144
145 return pfn_to_kaddr(pte_pfn(entry));
146}
147
148static unsigned long lookup_address(struct trapped_io *tiop,
149 unsigned long address)
150{
151 struct resource *res;
152 unsigned long vaddr = (unsigned long)tiop->virt_base;
153 unsigned long len;
154 int k;
155
156 for (k = 0; k < tiop->num_resources; k++) {
157 res = tiop->resource + k;
158 len = roundup((res->end - res->start) + 1, PAGE_SIZE);
159 if (address < (vaddr + len))
160 return res->start + (address - vaddr);
161 vaddr += len;
162 }
163 return 0;
164}
165
166static unsigned long long copy_word(unsigned long src_addr, int src_len,
167 unsigned long dst_addr, int dst_len)
168{
169 unsigned long long tmp = 0;
170
171 switch (src_len) {
172 case 1:
173 tmp = ctrl_inb(src_addr);
174 break;
175 case 2:
176 tmp = ctrl_inw(src_addr);
177 break;
178 case 4:
179 tmp = ctrl_inl(src_addr);
180 break;
181 case 8:
182 tmp = ctrl_inq(src_addr);
183 break;
184 }
185
186 switch (dst_len) {
187 case 1:
188 ctrl_outb(tmp, dst_addr);
189 break;
190 case 2:
191 ctrl_outw(tmp, dst_addr);
192 break;
193 case 4:
194 ctrl_outl(tmp, dst_addr);
195 break;
196 case 8:
197 ctrl_outq(tmp, dst_addr);
198 break;
199 }
200
201 return tmp;
202}
203
204static unsigned long from_device(void *dst, const void *src, unsigned long cnt)
205{
206 struct trapped_io *tiop;
207 unsigned long src_addr = (unsigned long)src;
208 unsigned long long tmp;
209
210 pr_debug("trapped io read 0x%08lx (%ld)\n", src_addr, cnt);
211 tiop = lookup_tiop(src_addr);
212 WARN_ON(!tiop || (tiop->magic != IO_TRAPPED_MAGIC));
213
214 src_addr = lookup_address(tiop, src_addr);
215 if (!src_addr)
216 return cnt;
217
218 tmp = copy_word(src_addr,
219 max_t(unsigned long, cnt,
220 (tiop->minimum_bus_width / 8)),
221 (unsigned long)dst, cnt);
222
223 pr_debug("trapped io read 0x%08lx -> 0x%08llx\n", src_addr, tmp);
224 return 0;
225}
226
227static unsigned long to_device(void *dst, const void *src, unsigned long cnt)
228{
229 struct trapped_io *tiop;
230 unsigned long dst_addr = (unsigned long)dst;
231 unsigned long long tmp;
232
233 pr_debug("trapped io write 0x%08lx (%ld)\n", dst_addr, cnt);
234 tiop = lookup_tiop(dst_addr);
235 WARN_ON(!tiop || (tiop->magic != IO_TRAPPED_MAGIC));
236
237 dst_addr = lookup_address(tiop, dst_addr);
238 if (!dst_addr)
239 return cnt;
240
241 tmp = copy_word((unsigned long)src, cnt,
242 dst_addr, max_t(unsigned long, cnt,
243 (tiop->minimum_bus_width / 8)));
244
245 pr_debug("trapped io write 0x%08lx -> 0x%08llx\n", dst_addr, tmp);
246 return 0;
247}
248
249static struct mem_access trapped_io_access = {
250 from_device,
251 to_device,
252};
253
254int handle_trapped_io(struct pt_regs *regs, unsigned long address)
255{
256 mm_segment_t oldfs;
257 opcode_t instruction;
258 int tmp;
259
260 if (!lookup_tiop(address))
261 return 0;
262
263 WARN_ON(user_mode(regs));
264
265 oldfs = get_fs();
266 set_fs(KERNEL_DS);
267 if (copy_from_user(&instruction, (void *)(regs->pc),
268 sizeof(instruction))) {
269 set_fs(oldfs);
270 return 0;
271 }
272
273 tmp = handle_unaligned_access(instruction, regs, &trapped_io_access);
274 set_fs(oldfs);
275 return tmp == 0;
276}
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 0586bc62ad96..9bf19b00696a 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -248,9 +248,6 @@ asmlinkage void do_softirq(void)
248 248
249void __init init_IRQ(void) 249void __init init_IRQ(void)
250{ 250{
251#ifdef CONFIG_CPU_HAS_PINT_IRQ
252 init_IRQ_pint();
253#endif
254 plat_irq_setup(); 251 plat_irq_setup();
255 252
256 /* Perform the machine specific initialisation */ 253 /* Perform the machine specific initialisation */
diff --git a/arch/sh/kernel/process_64.c b/arch/sh/kernel/process_64.c
index cff3b7dc9c56..046999b1d1af 100644
--- a/arch/sh/kernel/process_64.c
+++ b/arch/sh/kernel/process_64.c
@@ -623,6 +623,7 @@ extern void interruptible_sleep_on(wait_queue_head_t *q);
623 623
624#define mid_sched ((unsigned long) interruptible_sleep_on) 624#define mid_sched ((unsigned long) interruptible_sleep_on)
625 625
626#ifdef CONFIG_FRAME_POINTER
626static int in_sh64_switch_to(unsigned long pc) 627static int in_sh64_switch_to(unsigned long pc)
627{ 628{
628 extern char __sh64_switch_to_end; 629 extern char __sh64_switch_to_end;
@@ -631,12 +632,10 @@ static int in_sh64_switch_to(unsigned long pc)
631 return (pc >= (unsigned long) sh64_switch_to) && 632 return (pc >= (unsigned long) sh64_switch_to) &&
632 (pc < (unsigned long) &__sh64_switch_to_end); 633 (pc < (unsigned long) &__sh64_switch_to_end);
633} 634}
635#endif
634 636
635unsigned long get_wchan(struct task_struct *p) 637unsigned long get_wchan(struct task_struct *p)
636{ 638{
637 unsigned long schedule_fp;
638 unsigned long sh64_switch_to_fp;
639 unsigned long schedule_caller_pc;
640 unsigned long pc; 639 unsigned long pc;
641 640
642 if (!p || p == current || p->state == TASK_RUNNING) 641 if (!p || p == current || p->state == TASK_RUNNING)
@@ -649,6 +648,10 @@ unsigned long get_wchan(struct task_struct *p)
649 648
650#ifdef CONFIG_FRAME_POINTER 649#ifdef CONFIG_FRAME_POINTER
651 if (in_sh64_switch_to(pc)) { 650 if (in_sh64_switch_to(pc)) {
651 unsigned long schedule_fp;
652 unsigned long sh64_switch_to_fp;
653 unsigned long schedule_caller_pc;
654
652 sh64_switch_to_fp = (long) p->thread.sp; 655 sh64_switch_to_fp = (long) p->thread.sp;
653 /* r14 is saved at offset 4 in the sh64_switch_to frame */ 656 /* r14 is saved at offset 4 in the sh64_switch_to frame */
654 schedule_fp = *(unsigned long *) (long)(sh64_switch_to_fp + 4); 657 schedule_fp = *(unsigned long *) (long)(sh64_switch_to_fp + 4);
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c
index ce0664a58b49..fddb547f3c2b 100644
--- a/arch/sh/kernel/ptrace_32.c
+++ b/arch/sh/kernel/ptrace_32.c
@@ -220,7 +220,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
220 dp = ((unsigned long) child) + THREAD_SIZE - 220 dp = ((unsigned long) child) + THREAD_SIZE -
221 sizeof(struct pt_dspregs); 221 sizeof(struct pt_dspregs);
222 if (*((int *) (dp - 4)) == SR_FD) { 222 if (*((int *) (dp - 4)) == SR_FD) {
223 copy_to_user(addr, (void *) dp, 223 copy_to_user((void *)addr, (void *) dp,
224 sizeof(struct pt_dspregs)); 224 sizeof(struct pt_dspregs));
225 ret = 0; 225 ret = 0;
226 } 226 }
@@ -234,7 +234,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
234 dp = ((unsigned long) child) + THREAD_SIZE - 234 dp = ((unsigned long) child) + THREAD_SIZE -
235 sizeof(struct pt_dspregs); 235 sizeof(struct pt_dspregs);
236 if (*((int *) (dp - 4)) == SR_FD) { 236 if (*((int *) (dp - 4)) == SR_FD) {
237 copy_from_user((void *) dp, addr, 237 copy_from_user((void *) dp, (void *)addr,
238 sizeof(struct pt_dspregs)); 238 sizeof(struct pt_dspregs));
239 ret = 0; 239 ret = 0;
240 } 240 }
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 18a5baf2cbad..ff4f54a47c07 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -333,7 +333,7 @@ static const char *cpu_name[] = {
333 [CPU_SH7343] = "SH7343", [CPU_SH7785] = "SH7785", 333 [CPU_SH7343] = "SH7343", [CPU_SH7785] = "SH7785",
334 [CPU_SH7722] = "SH7722", [CPU_SHX3] = "SH-X3", 334 [CPU_SH7722] = "SH7722", [CPU_SHX3] = "SH-X3",
335 [CPU_SH5_101] = "SH5-101", [CPU_SH5_103] = "SH5-103", 335 [CPU_SH5_101] = "SH5-101", [CPU_SH5_103] = "SH5-103",
336 [CPU_SH_NONE] = "Unknown" 336 [CPU_SH7366] = "SH7366", [CPU_SH_NONE] = "Unknown"
337}; 337};
338 338
339const char *get_cpu_subtype(struct sh_cpuinfo *c) 339const char *get_cpu_subtype(struct sh_cpuinfo *c)
diff --git a/arch/sh/kernel/syscalls_32.S b/arch/sh/kernel/syscalls_32.S
index 719e127a7c05..a46cc3a41148 100644
--- a/arch/sh/kernel/syscalls_32.S
+++ b/arch/sh/kernel/syscalls_32.S
@@ -338,6 +338,8 @@ ENTRY(sys_call_table)
338 .long sys_epoll_pwait 338 .long sys_epoll_pwait
339 .long sys_utimensat /* 320 */ 339 .long sys_utimensat /* 320 */
340 .long sys_signalfd 340 .long sys_signalfd
341 .long sys_ni_syscall 341 .long sys_timerfd_create
342 .long sys_eventfd 342 .long sys_eventfd
343 .long sys_fallocate 343 .long sys_fallocate
344 .long sys_timerfd_settime /* 325 */
345 .long sys_timerfd_gettime
diff --git a/arch/sh/kernel/syscalls_64.S b/arch/sh/kernel/syscalls_64.S
index 12c7340356ae..d5d7843aad94 100644
--- a/arch/sh/kernel/syscalls_64.S
+++ b/arch/sh/kernel/syscalls_64.S
@@ -376,6 +376,8 @@ sys_call_table:
376 .long sys_epoll_pwait 376 .long sys_epoll_pwait
377 .long sys_utimensat 377 .long sys_utimensat
378 .long sys_signalfd 378 .long sys_signalfd
379 .long sys_ni_syscall /* 350 */ 379 .long sys_timerfd_create /* 350 */
380 .long sys_eventfd 380 .long sys_eventfd
381 .long sys_fallocate 381 .long sys_fallocate
382 .long sys_timerfd_settime
383 .long sys_timerfd_gettime
diff --git a/arch/sh/kernel/time_32.c b/arch/sh/kernel/time_32.c
index 2bc04bfee738..7281342c044d 100644
--- a/arch/sh/kernel/time_32.c
+++ b/arch/sh/kernel/time_32.c
@@ -120,10 +120,6 @@ static long last_rtc_update;
120 */ 120 */
121void handle_timer_tick(void) 121void handle_timer_tick(void)
122{ 122{
123 do_timer(1);
124#ifndef CONFIG_SMP
125 update_process_times(user_mode(get_irq_regs()));
126#endif
127 if (current->pid) 123 if (current->pid)
128 profile_tick(CPU_PROFILING); 124 profile_tick(CPU_PROFILING);
129 125
@@ -133,6 +129,16 @@ void handle_timer_tick(void)
133#endif 129#endif
134 130
135 /* 131 /*
132 * Here we are in the timer irq handler. We just have irqs locally
133 * disabled but we don't know if the timer_bh is running on the other
134 * CPU. We need to avoid to SMP race with it. NOTE: we don' t need
135 * the irq version of write_lock because as just said we have irq
136 * locally disabled. -arca
137 */
138 write_seqlock(&xtime_lock);
139 do_timer(1);
140
141 /*
136 * If we have an externally synchronized Linux clock, then update 142 * If we have an externally synchronized Linux clock, then update
137 * RTC clock accordingly every ~11 minutes. Set_rtc_mmss() has to be 143 * RTC clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
138 * called as close as possible to 500 ms before the new second starts. 144 * called as close as possible to 500 ms before the new second starts.
@@ -147,6 +153,11 @@ void handle_timer_tick(void)
147 /* do it again in 60s */ 153 /* do it again in 60s */
148 last_rtc_update = xtime.tv_sec - 600; 154 last_rtc_update = xtime.tv_sec - 600;
149 } 155 }
156 write_sequnlock(&xtime_lock);
157
158#ifndef CONFIG_SMP
159 update_process_times(user_mode(get_irq_regs()));
160#endif
150} 161}
151#endif /* !CONFIG_GENERIC_CLOCKEVENTS */ 162#endif /* !CONFIG_GENERIC_CLOCKEVENTS */
152 163
diff --git a/arch/sh/kernel/time_64.c b/arch/sh/kernel/time_64.c
index f819ba38a6ce..898977ee2030 100644
--- a/arch/sh/kernel/time_64.c
+++ b/arch/sh/kernel/time_64.c
@@ -229,15 +229,22 @@ static long last_rtc_update;
229static inline void do_timer_interrupt(void) 229static inline void do_timer_interrupt(void)
230{ 230{
231 unsigned long long current_ctc; 231 unsigned long long current_ctc;
232
233 if (current->pid)
234 profile_tick(CPU_PROFILING);
235
236 /*
237 * Here we are in the timer irq handler. We just have irqs locally
238 * disabled but we don't know if the timer_bh is running on the other
239 * CPU. We need to avoid to SMP race with it. NOTE: we don' t need
240 * the irq version of write_lock because as just said we have irq
241 * locally disabled. -arca
242 */
243 write_lock(&xtime_lock);
232 asm ("getcon cr62, %0" : "=r" (current_ctc)); 244 asm ("getcon cr62, %0" : "=r" (current_ctc));
233 ctc_last_interrupt = (unsigned long) current_ctc; 245 ctc_last_interrupt = (unsigned long) current_ctc;
234 246
235 do_timer(1); 247 do_timer(1);
236#ifndef CONFIG_SMP
237 update_process_times(user_mode(get_irq_regs()));
238#endif
239 if (current->pid)
240 profile_tick(CPU_PROFILING);
241 248
242#ifdef CONFIG_HEARTBEAT 249#ifdef CONFIG_HEARTBEAT
243 if (sh_mv.mv_heartbeat != NULL) 250 if (sh_mv.mv_heartbeat != NULL)
@@ -259,6 +266,11 @@ static inline void do_timer_interrupt(void)
259 /* do it again in 60 s */ 266 /* do it again in 60 s */
260 last_rtc_update = xtime.tv_sec - 600; 267 last_rtc_update = xtime.tv_sec - 600;
261 } 268 }
269 write_unlock(&xtime_lock);
270
271#ifndef CONFIG_SMP
272 update_process_times(user_mode(get_irq_regs()));
273#endif
262} 274}
263 275
264/* 276/*
@@ -275,16 +287,7 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)
275 timer_status &= ~0x100; 287 timer_status &= ~0x100;
276 ctrl_outw(timer_status, TMU0_TCR); 288 ctrl_outw(timer_status, TMU0_TCR);
277 289
278 /*
279 * Here we are in the timer irq handler. We just have irqs locally
280 * disabled but we don't know if the timer_bh is running on the other
281 * CPU. We need to avoid to SMP race with it. NOTE: we don' t need
282 * the irq version of write_lock because as just said we have irq
283 * locally disabled. -arca
284 */
285 write_lock(&xtime_lock);
286 do_timer_interrupt(); 290 do_timer_interrupt();
287 write_unlock(&xtime_lock);
288 291
289 return IRQ_HANDLED; 292 return IRQ_HANDLED;
290} 293}
diff --git a/arch/sh/kernel/timers/timer-mtu2.c b/arch/sh/kernel/timers/timer-mtu2.c
index 463cd08f9517..ade9d6eb29f9 100644
--- a/arch/sh/kernel/timers/timer-mtu2.c
+++ b/arch/sh/kernel/timers/timer-mtu2.c
@@ -154,7 +154,6 @@ static int mtu2_timer_stop(void)
154 154
155static int mtu2_timer_init(void) 155static int mtu2_timer_init(void)
156{ 156{
157 u8 tmp;
158 unsigned long interval; 157 unsigned long interval;
159 158
160 setup_irq(CONFIG_SH_TIMER_IRQ, &mtu2_irq); 159 setup_irq(CONFIG_SH_TIMER_IRQ, &mtu2_irq);
diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c
index 2e58f7a6b746..baa4fa368dce 100644
--- a/arch/sh/kernel/traps_32.c
+++ b/arch/sh/kernel/traps_32.c
@@ -147,6 +147,36 @@ static int die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
147 return -EFAULT; 147 return -EFAULT;
148} 148}
149 149
150static inline void sign_extend(unsigned int count, unsigned char *dst)
151{
152#ifdef __LITTLE_ENDIAN__
153 if ((count == 1) && dst[0] & 0x80) {
154 dst[1] = 0xff;
155 dst[2] = 0xff;
156 dst[3] = 0xff;
157 }
158 if ((count == 2) && dst[1] & 0x80) {
159 dst[2] = 0xff;
160 dst[3] = 0xff;
161 }
162#else
163 if ((count == 1) && dst[3] & 0x80) {
164 dst[2] = 0xff;
165 dst[1] = 0xff;
166 dst[0] = 0xff;
167 }
168 if ((count == 2) && dst[2] & 0x80) {
169 dst[1] = 0xff;
170 dst[0] = 0xff;
171 }
172#endif
173}
174
175static struct mem_access user_mem_access = {
176 copy_from_user,
177 copy_to_user,
178};
179
150/* 180/*
151 * handle an instruction that does an unaligned memory access by emulating the 181 * handle an instruction that does an unaligned memory access by emulating the
152 * desired behaviour 182 * desired behaviour
@@ -154,7 +184,8 @@ static int die_if_no_fixup(const char * str, struct pt_regs * regs, long err)
154 * (if that instruction is in a branch delay slot) 184 * (if that instruction is in a branch delay slot)
155 * - return 0 if emulation okay, -EFAULT on existential error 185 * - return 0 if emulation okay, -EFAULT on existential error
156 */ 186 */
157static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs) 187static int handle_unaligned_ins(opcode_t instruction, struct pt_regs *regs,
188 struct mem_access *ma)
158{ 189{
159 int ret, index, count; 190 int ret, index, count;
160 unsigned long *rm, *rn; 191 unsigned long *rm, *rn;
@@ -178,25 +209,13 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
178 dst = (unsigned char*) rn; 209 dst = (unsigned char*) rn;
179 *(unsigned long*)dst = 0; 210 *(unsigned long*)dst = 0;
180 211
181#ifdef __LITTLE_ENDIAN__ 212#if !defined(__LITTLE_ENDIAN__)
182 if (copy_from_user(dst, src, count))
183 goto fetch_fault;
184
185 if ((count == 2) && dst[1] & 0x80) {
186 dst[2] = 0xff;
187 dst[3] = 0xff;
188 }
189#else
190 dst += 4-count; 213 dst += 4-count;
191 214#endif
192 if (__copy_user(dst, src, count)) 215 if (ma->from(dst, src, count))
193 goto fetch_fault; 216 goto fetch_fault;
194 217
195 if ((count == 2) && dst[2] & 0x80) { 218 sign_extend(count, dst);
196 dst[0] = 0xff;
197 dst[1] = 0xff;
198 }
199#endif
200 } else { 219 } else {
201 /* to memory */ 220 /* to memory */
202 src = (unsigned char*) rm; 221 src = (unsigned char*) rm;
@@ -206,7 +225,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
206 dst = (unsigned char*) *rn; 225 dst = (unsigned char*) *rn;
207 dst += regs->regs[0]; 226 dst += regs->regs[0];
208 227
209 if (copy_to_user(dst, src, count)) 228 if (ma->to(dst, src, count))
210 goto fetch_fault; 229 goto fetch_fault;
211 } 230 }
212 ret = 0; 231 ret = 0;
@@ -217,7 +236,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
217 dst = (unsigned char*) *rn; 236 dst = (unsigned char*) *rn;
218 dst += (instruction&0x000F)<<2; 237 dst += (instruction&0x000F)<<2;
219 238
220 if (copy_to_user(dst,src,4)) 239 if (ma->to(dst, src, 4))
221 goto fetch_fault; 240 goto fetch_fault;
222 ret = 0; 241 ret = 0;
223 break; 242 break;
@@ -230,7 +249,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
230#if !defined(__LITTLE_ENDIAN__) 249#if !defined(__LITTLE_ENDIAN__)
231 src += 4-count; 250 src += 4-count;
232#endif 251#endif
233 if (copy_to_user(dst, src, count)) 252 if (ma->to(dst, src, count))
234 goto fetch_fault; 253 goto fetch_fault;
235 ret = 0; 254 ret = 0;
236 break; 255 break;
@@ -241,7 +260,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
241 dst = (unsigned char*) rn; 260 dst = (unsigned char*) rn;
242 *(unsigned long*)dst = 0; 261 *(unsigned long*)dst = 0;
243 262
244 if (copy_from_user(dst,src,4)) 263 if (ma->from(dst, src, 4))
245 goto fetch_fault; 264 goto fetch_fault;
246 ret = 0; 265 ret = 0;
247 break; 266 break;
@@ -253,25 +272,12 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
253 dst = (unsigned char*) rn; 272 dst = (unsigned char*) rn;
254 *(unsigned long*)dst = 0; 273 *(unsigned long*)dst = 0;
255 274
256#ifdef __LITTLE_ENDIAN__ 275#if !defined(__LITTLE_ENDIAN__)
257 if (copy_from_user(dst, src, count))
258 goto fetch_fault;
259
260 if ((count == 2) && dst[1] & 0x80) {
261 dst[2] = 0xff;
262 dst[3] = 0xff;
263 }
264#else
265 dst += 4-count; 276 dst += 4-count;
266
267 if (copy_from_user(dst, src, count))
268 goto fetch_fault;
269
270 if ((count == 2) && dst[2] & 0x80) {
271 dst[0] = 0xff;
272 dst[1] = 0xff;
273 }
274#endif 277#endif
278 if (ma->from(dst, src, count))
279 goto fetch_fault;
280 sign_extend(count, dst);
275 ret = 0; 281 ret = 0;
276 break; 282 break;
277 283
@@ -285,7 +291,7 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
285 dst = (unsigned char*) *rm; /* called Rn in the spec */ 291 dst = (unsigned char*) *rm; /* called Rn in the spec */
286 dst += (instruction&0x000F)<<1; 292 dst += (instruction&0x000F)<<1;
287 293
288 if (copy_to_user(dst, src, 2)) 294 if (ma->to(dst, src, 2))
289 goto fetch_fault; 295 goto fetch_fault;
290 ret = 0; 296 ret = 0;
291 break; 297 break;
@@ -299,21 +305,9 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
299#if !defined(__LITTLE_ENDIAN__) 305#if !defined(__LITTLE_ENDIAN__)
300 dst += 2; 306 dst += 2;
301#endif 307#endif
302 308 if (ma->from(dst, src, 2))
303 if (copy_from_user(dst, src, 2))
304 goto fetch_fault; 309 goto fetch_fault;
305 310 sign_extend(2, dst);
306#ifdef __LITTLE_ENDIAN__
307 if (dst[1] & 0x80) {
308 dst[2] = 0xff;
309 dst[3] = 0xff;
310 }
311#else
312 if (dst[2] & 0x80) {
313 dst[0] = 0xff;
314 dst[1] = 0xff;
315 }
316#endif
317 ret = 0; 311 ret = 0;
318 break; 312 break;
319 } 313 }
@@ -332,11 +326,14 @@ static int handle_unaligned_ins(u16 instruction, struct pt_regs *regs)
332 * emulate the instruction in the delay slot 326 * emulate the instruction in the delay slot
333 * - fetches the instruction from PC+2 327 * - fetches the instruction from PC+2
334 */ 328 */
335static inline int handle_unaligned_delayslot(struct pt_regs *regs) 329static inline int handle_delayslot(struct pt_regs *regs,
330 opcode_t old_instruction,
331 struct mem_access *ma)
336{ 332{
337 u16 instruction; 333 opcode_t instruction;
334 void *addr = (void *)(regs->pc + instruction_size(old_instruction));
338 335
339 if (copy_from_user(&instruction, (u16 *)(regs->pc+2), 2)) { 336 if (copy_from_user(&instruction, addr, sizeof(instruction))) {
340 /* the instruction-fetch faulted */ 337 /* the instruction-fetch faulted */
341 if (user_mode(regs)) 338 if (user_mode(regs))
342 return -EFAULT; 339 return -EFAULT;
@@ -346,7 +343,7 @@ static inline int handle_unaligned_delayslot(struct pt_regs *regs)
346 regs, 0); 343 regs, 0);
347 } 344 }
348 345
349 return handle_unaligned_ins(instruction,regs); 346 return handle_unaligned_ins(instruction, regs, ma);
350} 347}
351 348
352/* 349/*
@@ -369,10 +366,11 @@ static inline int handle_unaligned_delayslot(struct pt_regs *regs)
369 * XXX: SH-2A needs this too, but it needs an overhaul thanks to mixed 32-bit 366 * XXX: SH-2A needs this too, but it needs an overhaul thanks to mixed 32-bit
370 * opcodes.. 367 * opcodes..
371 */ 368 */
372#ifndef CONFIG_CPU_SH2A 369
373static int handle_unaligned_notify_count = 10; 370static int handle_unaligned_notify_count = 10;
374 371
375static int handle_unaligned_access(u16 instruction, struct pt_regs *regs) 372int handle_unaligned_access(opcode_t instruction, struct pt_regs *regs,
373 struct mem_access *ma)
376{ 374{
377 u_int rm; 375 u_int rm;
378 int ret, index; 376 int ret, index;
@@ -387,7 +385,7 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
387 printk(KERN_NOTICE "Fixing up unaligned userspace access " 385 printk(KERN_NOTICE "Fixing up unaligned userspace access "
388 "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n", 386 "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n",
389 current->comm, task_pid_nr(current), 387 current->comm, task_pid_nr(current),
390 (u16 *)regs->pc, instruction); 388 (void *)regs->pc, instruction);
391 } 389 }
392 390
393 ret = -EFAULT; 391 ret = -EFAULT;
@@ -395,19 +393,19 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
395 case 0x0000: 393 case 0x0000:
396 if (instruction==0x000B) { 394 if (instruction==0x000B) {
397 /* rts */ 395 /* rts */
398 ret = handle_unaligned_delayslot(regs); 396 ret = handle_delayslot(regs, instruction, ma);
399 if (ret==0) 397 if (ret==0)
400 regs->pc = regs->pr; 398 regs->pc = regs->pr;
401 } 399 }
402 else if ((instruction&0x00FF)==0x0023) { 400 else if ((instruction&0x00FF)==0x0023) {
403 /* braf @Rm */ 401 /* braf @Rm */
404 ret = handle_unaligned_delayslot(regs); 402 ret = handle_delayslot(regs, instruction, ma);
405 if (ret==0) 403 if (ret==0)
406 regs->pc += rm + 4; 404 regs->pc += rm + 4;
407 } 405 }
408 else if ((instruction&0x00FF)==0x0003) { 406 else if ((instruction&0x00FF)==0x0003) {
409 /* bsrf @Rm */ 407 /* bsrf @Rm */
410 ret = handle_unaligned_delayslot(regs); 408 ret = handle_delayslot(regs, instruction, ma);
411 if (ret==0) { 409 if (ret==0) {
412 regs->pr = regs->pc + 4; 410 regs->pr = regs->pc + 4;
413 regs->pc += rm + 4; 411 regs->pc += rm + 4;
@@ -428,13 +426,13 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
428 case 0x4000: 426 case 0x4000:
429 if ((instruction&0x00FF)==0x002B) { 427 if ((instruction&0x00FF)==0x002B) {
430 /* jmp @Rm */ 428 /* jmp @Rm */
431 ret = handle_unaligned_delayslot(regs); 429 ret = handle_delayslot(regs, instruction, ma);
432 if (ret==0) 430 if (ret==0)
433 regs->pc = rm; 431 regs->pc = rm;
434 } 432 }
435 else if ((instruction&0x00FF)==0x000B) { 433 else if ((instruction&0x00FF)==0x000B) {
436 /* jsr @Rm */ 434 /* jsr @Rm */
437 ret = handle_unaligned_delayslot(regs); 435 ret = handle_delayslot(regs, instruction, ma);
438 if (ret==0) { 436 if (ret==0) {
439 regs->pr = regs->pc + 4; 437 regs->pr = regs->pc + 4;
440 regs->pc = rm; 438 regs->pc = rm;
@@ -461,7 +459,7 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
461 case 0x0B00: /* bf lab - no delayslot*/ 459 case 0x0B00: /* bf lab - no delayslot*/
462 break; 460 break;
463 case 0x0F00: /* bf/s lab */ 461 case 0x0F00: /* bf/s lab */
464 ret = handle_unaligned_delayslot(regs); 462 ret = handle_delayslot(regs, instruction, ma);
465 if (ret==0) { 463 if (ret==0) {
466#if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB) 464#if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)
467 if ((regs->sr & 0x00000001) != 0) 465 if ((regs->sr & 0x00000001) != 0)
@@ -474,7 +472,7 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
474 case 0x0900: /* bt lab - no delayslot */ 472 case 0x0900: /* bt lab - no delayslot */
475 break; 473 break;
476 case 0x0D00: /* bt/s lab */ 474 case 0x0D00: /* bt/s lab */
477 ret = handle_unaligned_delayslot(regs); 475 ret = handle_delayslot(regs, instruction, ma);
478 if (ret==0) { 476 if (ret==0) {
479#if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB) 477#if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)
480 if ((regs->sr & 0x00000001) == 0) 478 if ((regs->sr & 0x00000001) == 0)
@@ -488,13 +486,13 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
488 break; 486 break;
489 487
490 case 0xA000: /* bra label */ 488 case 0xA000: /* bra label */
491 ret = handle_unaligned_delayslot(regs); 489 ret = handle_delayslot(regs, instruction, ma);
492 if (ret==0) 490 if (ret==0)
493 regs->pc += SH_PC_12BIT_OFFSET(instruction); 491 regs->pc += SH_PC_12BIT_OFFSET(instruction);
494 break; 492 break;
495 493
496 case 0xB000: /* bsr label */ 494 case 0xB000: /* bsr label */
497 ret = handle_unaligned_delayslot(regs); 495 ret = handle_delayslot(regs, instruction, ma);
498 if (ret==0) { 496 if (ret==0) {
499 regs->pr = regs->pc + 4; 497 regs->pr = regs->pc + 4;
500 regs->pc += SH_PC_12BIT_OFFSET(instruction); 498 regs->pc += SH_PC_12BIT_OFFSET(instruction);
@@ -505,12 +503,11 @@ static int handle_unaligned_access(u16 instruction, struct pt_regs *regs)
505 503
506 /* handle non-delay-slot instruction */ 504 /* handle non-delay-slot instruction */
507 simple: 505 simple:
508 ret = handle_unaligned_ins(instruction,regs); 506 ret = handle_unaligned_ins(instruction, regs, ma);
509 if (ret==0) 507 if (ret==0)
510 regs->pc += instruction_size(instruction); 508 regs->pc += instruction_size(instruction);
511 return ret; 509 return ret;
512} 510}
513#endif /* CONFIG_CPU_SH2A */
514 511
515#ifdef CONFIG_CPU_HAS_SR_RB 512#ifdef CONFIG_CPU_HAS_SR_RB
516#define lookup_exception_vector(x) \ 513#define lookup_exception_vector(x) \
@@ -538,10 +535,8 @@ asmlinkage void do_address_error(struct pt_regs *regs,
538 unsigned long error_code = 0; 535 unsigned long error_code = 0;
539 mm_segment_t oldfs; 536 mm_segment_t oldfs;
540 siginfo_t info; 537 siginfo_t info;
541#ifndef CONFIG_CPU_SH2A 538 opcode_t instruction;
542 u16 instruction;
543 int tmp; 539 int tmp;
544#endif
545 540
546 /* Intentional ifdef */ 541 /* Intentional ifdef */
547#ifdef CONFIG_CPU_HAS_SR_RB 542#ifdef CONFIG_CPU_HAS_SR_RB
@@ -561,9 +556,9 @@ asmlinkage void do_address_error(struct pt_regs *regs,
561 goto uspace_segv; 556 goto uspace_segv;
562 } 557 }
563 558
564#ifndef CONFIG_CPU_SH2A
565 set_fs(USER_DS); 559 set_fs(USER_DS);
566 if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) { 560 if (copy_from_user(&instruction, (void *)(regs->pc),
561 sizeof(instruction))) {
567 /* Argh. Fault on the instruction itself. 562 /* Argh. Fault on the instruction itself.
568 This should never happen non-SMP 563 This should never happen non-SMP
569 */ 564 */
@@ -571,13 +566,12 @@ asmlinkage void do_address_error(struct pt_regs *regs,
571 goto uspace_segv; 566 goto uspace_segv;
572 } 567 }
573 568
574 tmp = handle_unaligned_access(instruction, regs); 569 tmp = handle_unaligned_access(instruction, regs,
570 &user_mem_access);
575 set_fs(oldfs); 571 set_fs(oldfs);
576 572
577 if (tmp==0) 573 if (tmp==0)
578 return; /* sorted */ 574 return; /* sorted */
579#endif
580
581uspace_segv: 575uspace_segv:
582 printk(KERN_NOTICE "Sending SIGBUS to \"%s\" due to unaligned " 576 printk(KERN_NOTICE "Sending SIGBUS to \"%s\" due to unaligned "
583 "access (PC %lx PR %lx)\n", current->comm, regs->pc, 577 "access (PC %lx PR %lx)\n", current->comm, regs->pc,
@@ -592,9 +586,9 @@ uspace_segv:
592 if (regs->pc & 1) 586 if (regs->pc & 1)
593 die("unaligned program counter", regs, error_code); 587 die("unaligned program counter", regs, error_code);
594 588
595#ifndef CONFIG_CPU_SH2A
596 set_fs(KERNEL_DS); 589 set_fs(KERNEL_DS);
597 if (copy_from_user(&instruction, (u16 *)(regs->pc), 2)) { 590 if (copy_from_user(&instruction, (void *)(regs->pc),
591 sizeof(instruction))) {
598 /* Argh. Fault on the instruction itself. 592 /* Argh. Fault on the instruction itself.
599 This should never happen non-SMP 593 This should never happen non-SMP
600 */ 594 */
@@ -602,14 +596,8 @@ uspace_segv:
602 die("insn faulting in do_address_error", regs, 0); 596 die("insn faulting in do_address_error", regs, 0);
603 } 597 }
604 598
605 handle_unaligned_access(instruction, regs); 599 handle_unaligned_access(instruction, regs, &user_mem_access);
606 set_fs(oldfs); 600 set_fs(oldfs);
607#else
608 printk(KERN_NOTICE "Killing process \"%s\" due to unaligned "
609 "access\n", current->comm);
610
611 force_sig(SIGSEGV, current);
612#endif
613 } 601 }
614} 602}
615 603
diff --git a/arch/sh/kernel/traps_64.c b/arch/sh/kernel/traps_64.c
index c0b3c6f6edb5..a55ac81d795b 100644
--- a/arch/sh/kernel/traps_64.c
+++ b/arch/sh/kernel/traps_64.c
@@ -630,7 +630,7 @@ static int misaligned_fpu_load(struct pt_regs *regs,
630 current->thread.fpu.hard.fp_regs[destreg] = buflo; 630 current->thread.fpu.hard.fp_regs[destreg] = buflo;
631 current->thread.fpu.hard.fp_regs[destreg+1] = bufhi; 631 current->thread.fpu.hard.fp_regs[destreg+1] = bufhi;
632 } else { 632 } else {
633#if defined(CONFIG_LITTLE_ENDIAN) 633#if defined(CONFIG_CPU_LITTLE_ENDIAN)
634 current->thread.fpu.hard.fp_regs[destreg] = bufhi; 634 current->thread.fpu.hard.fp_regs[destreg] = bufhi;
635 current->thread.fpu.hard.fp_regs[destreg+1] = buflo; 635 current->thread.fpu.hard.fp_regs[destreg+1] = buflo;
636#else 636#else
@@ -700,7 +700,7 @@ static int misaligned_fpu_store(struct pt_regs *regs,
700 buflo = current->thread.fpu.hard.fp_regs[srcreg]; 700 buflo = current->thread.fpu.hard.fp_regs[srcreg];
701 bufhi = current->thread.fpu.hard.fp_regs[srcreg+1]; 701 bufhi = current->thread.fpu.hard.fp_regs[srcreg+1];
702 } else { 702 } else {
703#if defined(CONFIG_LITTLE_ENDIAN) 703#if defined(CONFIG_CPU_LITTLE_ENDIAN)
704 bufhi = current->thread.fpu.hard.fp_regs[srcreg]; 704 bufhi = current->thread.fpu.hard.fp_regs[srcreg];
705 buflo = current->thread.fpu.hard.fp_regs[srcreg+1]; 705 buflo = current->thread.fpu.hard.fp_regs[srcreg+1];
706#else 706#else
diff --git a/arch/sh/kernel/vmlinux_64.lds.S b/arch/sh/kernel/vmlinux_64.lds.S
index 3f1bd6392bb3..d1e177009a41 100644
--- a/arch/sh/kernel/vmlinux_64.lds.S
+++ b/arch/sh/kernel/vmlinux_64.lds.S
@@ -51,7 +51,7 @@ SECTIONS
51 KPROBES_TEXT 51 KPROBES_TEXT
52 *(.fixup) 52 *(.fixup)
53 *(.gnu.warning) 53 *(.gnu.warning)
54#ifdef CONFIG_LITTLE_ENDIAN 54#ifdef CONFIG_CPU_LITTLE_ENDIAN
55 } = 0x6ff0fff0 55 } = 0x6ff0fff0
56#else 56#else
57 } = 0xf0fff06f 57 } = 0xf0fff06f
diff --git a/arch/sh/mm/cache-sh5.c b/arch/sh/mm/cache-sh5.c
index 4617e3aeee73..3877321fcede 100644
--- a/arch/sh/mm/cache-sh5.c
+++ b/arch/sh/mm/cache-sh5.c
@@ -1,10 +1,10 @@
1/* 1/*
2 * arch/sh/mm/cache-sh5.c 2 * arch/sh/mm/cache-sh5.c
3 * 3 *
4 * Original version Copyright (C) 2000, 2001 Paolo Alberelli 4 * Copyright (C) 2000, 2001 Paolo Alberelli
5 * Second version Copyright (C) benedict.gaster@superh.com 2002 5 * Copyright (C) 2002 Benedict Gaster
6 * Third version Copyright Richard.Curnow@superh.com 2003 6 * Copyright (C) 2003 Richard Curnow
7 * Hacks to third version Copyright (C) 2003 Paul Mundt 7 * Copyright (C) 2003 - 2008 Paul Mundt
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive 10 * License. See the file "COPYING" in the main directory of this archive
@@ -13,101 +13,20 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/mman.h> 14#include <linux/mman.h>
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/threads.h> 16#include <asm/tlb.h>
17#include <asm/page.h>
18#include <asm/pgtable.h>
19#include <asm/processor.h> 17#include <asm/processor.h>
20#include <asm/cache.h> 18#include <asm/cache.h>
21#include <asm/tlb.h> 19#include <asm/pgalloc.h>
22#include <asm/io.h>
23#include <asm/uaccess.h> 20#include <asm/uaccess.h>
24#include <asm/mmu_context.h> 21#include <asm/mmu_context.h>
25#include <asm/pgalloc.h> /* for flush_itlb_range */
26
27#include <linux/proc_fs.h>
28
29/* This function is in entry.S */
30extern unsigned long switch_and_save_asid(unsigned long new_asid);
31 22
32/* Wired TLB entry for the D-cache */ 23/* Wired TLB entry for the D-cache */
33static unsigned long long dtlb_cache_slot; 24static unsigned long long dtlb_cache_slot;
34 25
35/** 26void __init p3_cache_init(void)
36 * sh64_cache_init()
37 *
38 * This is pretty much just a straightforward clone of the SH
39 * detect_cpu_and_cache_system().
40 *
41 * This function is responsible for setting up all of the cache
42 * info dynamically as well as taking care of CPU probing and
43 * setting up the relevant subtype data.
44 *
45 * FIXME: For the time being, we only really support the SH5-101
46 * out of the box, and don't support dynamic probing for things
47 * like the SH5-103 or even cut2 of the SH5-101. Implement this
48 * later!
49 */
50int __init sh64_cache_init(void)
51{ 27{
52 /* 28 /* Reserve a slot for dcache colouring in the DTLB */
53 * First, setup some sane values for the I-cache. 29 dtlb_cache_slot = sh64_get_wired_dtlb_entry();
54 */
55 cpu_data->icache.ways = 4;
56 cpu_data->icache.sets = 256;
57 cpu_data->icache.linesz = L1_CACHE_BYTES;
58
59 /*
60 * FIXME: This can probably be cleaned up a bit as well.. for example,
61 * do we really need the way shift _and_ the way_step_shift ?? Judging
62 * by the existing code, I would guess no.. is there any valid reason
63 * why we need to be tracking this around?
64 */
65 cpu_data->icache.way_shift = 13;
66 cpu_data->icache.entry_shift = 5;
67 cpu_data->icache.set_shift = 4;
68 cpu_data->icache.way_step_shift = 16;
69 cpu_data->icache.asid_shift = 2;
70
71 /*
72 * way offset = cache size / associativity, so just don't factor in
73 * associativity in the first place..
74 */
75 cpu_data->icache.way_ofs = cpu_data->icache.sets *
76 cpu_data->icache.linesz;
77
78 cpu_data->icache.asid_mask = 0x3fc;
79 cpu_data->icache.idx_mask = 0x1fe0;
80 cpu_data->icache.epn_mask = 0xffffe000;
81 cpu_data->icache.flags = 0;
82
83 /*
84 * Next, setup some sane values for the D-cache.
85 *
86 * On the SH5, these are pretty consistent with the I-cache settings,
87 * so we just copy over the existing definitions.. these can be fixed
88 * up later, especially if we add runtime CPU probing.
89 *
90 * Though in the meantime it saves us from having to duplicate all of
91 * the above definitions..
92 */
93 cpu_data->dcache = cpu_data->icache;
94
95 /*
96 * Setup any cache-related flags here
97 */
98#if defined(CONFIG_DCACHE_WRITE_THROUGH)
99 set_bit(SH_CACHE_MODE_WT, &(cpu_data->dcache.flags));
100#elif defined(CONFIG_DCACHE_WRITE_BACK)
101 set_bit(SH_CACHE_MODE_WB, &(cpu_data->dcache.flags));
102#endif
103
104 /*
105 * We also need to reserve a slot for the D-cache in the DTLB, so we
106 * do this now ..
107 */
108 dtlb_cache_slot = sh64_get_wired_dtlb_entry();
109
110 return 0;
111} 30}
112 31
113#ifdef CONFIG_DCACHE_DISABLED 32#ifdef CONFIG_DCACHE_DISABLED
@@ -116,73 +35,48 @@ int __init sh64_cache_init(void)
116#define sh64_dcache_purge_user_range(mm, start, end) do { } while (0) 35#define sh64_dcache_purge_user_range(mm, start, end) do { } while (0)
117#define sh64_dcache_purge_phy_page(paddr) do { } while (0) 36#define sh64_dcache_purge_phy_page(paddr) do { } while (0)
118#define sh64_dcache_purge_virt_page(mm, eaddr) do { } while (0) 37#define sh64_dcache_purge_virt_page(mm, eaddr) do { } while (0)
119#define sh64_dcache_purge_kernel_range(start, end) do { } while (0)
120#define sh64_dcache_wback_current_user_range(start, end) do { } while (0)
121#endif 38#endif
122 39
123/*##########################################################################*/ 40/*
124 41 * The following group of functions deal with mapping and unmapping a
125/* From here onwards, a rewrite of the implementation, 42 * temporary page into a DTLB slot that has been set aside for exclusive
126 by Richard.Curnow@superh.com. 43 * use.
127 44 */
128 The major changes in this compared to the old version are; 45static inline void
129 1. use more selective purging through OCBP instead of using ALLOCO to purge 46sh64_setup_dtlb_cache_slot(unsigned long eaddr, unsigned long asid,
130 by natural replacement. This avoids purging out unrelated cache lines 47 unsigned long paddr)
131 that happen to be in the same set.
132 2. exploit the APIs copy_user_page and clear_user_page better
133 3. be more selective about I-cache purging, in particular use invalidate_all
134 more sparingly.
135
136 */
137
138/*##########################################################################
139 SUPPORT FUNCTIONS
140 ##########################################################################*/
141
142/****************************************************************************/
143/* The following group of functions deal with mapping and unmapping a temporary
144 page into the DTLB slot that have been set aside for our exclusive use. */
145/* In order to accomplish this, we use the generic interface for adding and
146 removing a wired slot entry as defined in arch/sh/mm/tlb-sh5.c */
147/****************************************************************************/
148
149static unsigned long slot_own_flags;
150
151static inline void sh64_setup_dtlb_cache_slot(unsigned long eaddr, unsigned long asid, unsigned long paddr)
152{ 48{
153 local_irq_save(slot_own_flags); 49 local_irq_disable();
154 sh64_setup_tlb_slot(dtlb_cache_slot, eaddr, asid, paddr); 50 sh64_setup_tlb_slot(dtlb_cache_slot, eaddr, asid, paddr);
155} 51}
156 52
157static inline void sh64_teardown_dtlb_cache_slot(void) 53static inline void sh64_teardown_dtlb_cache_slot(void)
158{ 54{
159 sh64_teardown_tlb_slot(dtlb_cache_slot); 55 sh64_teardown_tlb_slot(dtlb_cache_slot);
160 local_irq_restore(slot_own_flags); 56 local_irq_enable();
161} 57}
162 58
163/****************************************************************************/
164
165#ifndef CONFIG_ICACHE_DISABLED 59#ifndef CONFIG_ICACHE_DISABLED
166 60static inline void sh64_icache_inv_all(void)
167static void __inline__ sh64_icache_inv_all(void)
168{ 61{
169 unsigned long long addr, flag, data; 62 unsigned long long addr, flag, data;
170 unsigned int flags; 63 unsigned int flags;
171 64
172 addr=ICCR0; 65 addr = ICCR0;
173 flag=ICCR0_ICI; 66 flag = ICCR0_ICI;
174 data=0; 67 data = 0;
175 68
176 /* Make this a critical section for safety (probably not strictly necessary.) */ 69 /* Make this a critical section for safety (probably not strictly necessary.) */
177 local_irq_save(flags); 70 local_irq_save(flags);
178 71
179 /* Without %1 it gets unexplicably wrong */ 72 /* Without %1 it gets unexplicably wrong */
180 asm volatile("getcfg %3, 0, %0\n\t" 73 __asm__ __volatile__ (
181 "or %0, %2, %0\n\t" 74 "getcfg %3, 0, %0\n\t"
182 "putcfg %3, 0, %0\n\t" 75 "or %0, %2, %0\n\t"
183 "synci" 76 "putcfg %3, 0, %0\n\t"
184 : "=&r" (data) 77 "synci"
185 : "0" (data), "r" (flag), "r" (addr)); 78 : "=&r" (data)
79 : "0" (data), "r" (flag), "r" (addr));
186 80
187 local_irq_restore(flags); 81 local_irq_restore(flags);
188} 82}
@@ -193,20 +87,12 @@ static void sh64_icache_inv_kernel_range(unsigned long start, unsigned long end)
193 * the addresses lie in the kernel superpage. */ 87 * the addresses lie in the kernel superpage. */
194 88
195 unsigned long long ullend, addr, aligned_start; 89 unsigned long long ullend, addr, aligned_start;
196#if (NEFF == 32)
197 aligned_start = (unsigned long long)(signed long long)(signed long) start; 90 aligned_start = (unsigned long long)(signed long long)(signed long) start;
198#else 91 addr = L1_CACHE_ALIGN(aligned_start);
199#error "NEFF != 32"
200#endif
201 aligned_start &= L1_CACHE_ALIGN_MASK;
202 addr = aligned_start;
203#if (NEFF == 32)
204 ullend = (unsigned long long) (signed long long) (signed long) end; 92 ullend = (unsigned long long) (signed long long) (signed long) end;
205#else 93
206#error "NEFF != 32"
207#endif
208 while (addr <= ullend) { 94 while (addr <= ullend) {
209 asm __volatile__ ("icbi %0, 0" : : "r" (addr)); 95 __asm__ __volatile__ ("icbi %0, 0" : : "r" (addr));
210 addr += L1_CACHE_BYTES; 96 addr += L1_CACHE_BYTES;
211 } 97 }
212} 98}
@@ -215,7 +101,7 @@ static void sh64_icache_inv_user_page(struct vm_area_struct *vma, unsigned long
215{ 101{
216 /* If we get called, we know that vma->vm_flags contains VM_EXEC. 102 /* If we get called, we know that vma->vm_flags contains VM_EXEC.
217 Also, eaddr is page-aligned. */ 103 Also, eaddr is page-aligned. */
218 104 unsigned int cpu = smp_processor_id();
219 unsigned long long addr, end_addr; 105 unsigned long long addr, end_addr;
220 unsigned long flags = 0; 106 unsigned long flags = 0;
221 unsigned long running_asid, vma_asid; 107 unsigned long running_asid, vma_asid;
@@ -237,17 +123,17 @@ static void sh64_icache_inv_user_page(struct vm_area_struct *vma, unsigned long
237 */ 123 */
238 124
239 running_asid = get_asid(); 125 running_asid = get_asid();
240 vma_asid = (vma->vm_mm->context & MMU_CONTEXT_ASID_MASK); 126 vma_asid = cpu_asid(cpu, vma->vm_mm);
241 if (running_asid != vma_asid) { 127 if (running_asid != vma_asid) {
242 local_irq_save(flags); 128 local_irq_save(flags);
243 switch_and_save_asid(vma_asid); 129 switch_and_save_asid(vma_asid);
244 } 130 }
245 while (addr < end_addr) { 131 while (addr < end_addr) {
246 /* Worth unrolling a little */ 132 /* Worth unrolling a little */
247 asm __volatile__("icbi %0, 0" : : "r" (addr)); 133 __asm__ __volatile__("icbi %0, 0" : : "r" (addr));
248 asm __volatile__("icbi %0, 32" : : "r" (addr)); 134 __asm__ __volatile__("icbi %0, 32" : : "r" (addr));
249 asm __volatile__("icbi %0, 64" : : "r" (addr)); 135 __asm__ __volatile__("icbi %0, 64" : : "r" (addr));
250 asm __volatile__("icbi %0, 96" : : "r" (addr)); 136 __asm__ __volatile__("icbi %0, 96" : : "r" (addr));
251 addr += 128; 137 addr += 128;
252 } 138 }
253 if (running_asid != vma_asid) { 139 if (running_asid != vma_asid) {
@@ -256,8 +142,6 @@ static void sh64_icache_inv_user_page(struct vm_area_struct *vma, unsigned long
256 } 142 }
257} 143}
258 144
259/****************************************************************************/
260
261static void sh64_icache_inv_user_page_range(struct mm_struct *mm, 145static void sh64_icache_inv_user_page_range(struct mm_struct *mm,
262 unsigned long start, unsigned long end) 146 unsigned long start, unsigned long end)
263{ 147{
@@ -275,10 +159,10 @@ static void sh64_icache_inv_user_page_range(struct mm_struct *mm,
275 possible with the D-cache. Just assume 64 for now as a working 159 possible with the D-cache. Just assume 64 for now as a working
276 figure. 160 figure.
277 */ 161 */
278
279 int n_pages; 162 int n_pages;
280 163
281 if (!mm) return; 164 if (!mm)
165 return;
282 166
283 n_pages = ((end - start) >> PAGE_SHIFT); 167 n_pages = ((end - start) >> PAGE_SHIFT);
284 if (n_pages >= 64) { 168 if (n_pages >= 64) {
@@ -290,7 +174,7 @@ static void sh64_icache_inv_user_page_range(struct mm_struct *mm,
290 unsigned long mm_asid, current_asid; 174 unsigned long mm_asid, current_asid;
291 unsigned long long flags = 0ULL; 175 unsigned long long flags = 0ULL;
292 176
293 mm_asid = mm->context & MMU_CONTEXT_ASID_MASK; 177 mm_asid = cpu_asid(smp_processor_id(), mm);
294 current_asid = get_asid(); 178 current_asid = get_asid();
295 179
296 if (mm_asid != current_asid) { 180 if (mm_asid != current_asid) {
@@ -322,6 +206,7 @@ static void sh64_icache_inv_user_page_range(struct mm_struct *mm,
322 } 206 }
323 aligned_start = vma->vm_end; /* Skip to start of next region */ 207 aligned_start = vma->vm_end; /* Skip to start of next region */
324 } 208 }
209
325 if (mm_asid != current_asid) { 210 if (mm_asid != current_asid) {
326 switch_and_save_asid(current_asid); 211 switch_and_save_asid(current_asid);
327 local_irq_restore(flags); 212 local_irq_restore(flags);
@@ -329,47 +214,46 @@ static void sh64_icache_inv_user_page_range(struct mm_struct *mm,
329 } 214 }
330} 215}
331 216
217/*
218 * Invalidate a small range of user context I-cache, not necessarily page
219 * (or even cache-line) aligned.
220 *
221 * Since this is used inside ptrace, the ASID in the mm context typically
222 * won't match current_asid. We'll have to switch ASID to do this. For
223 * safety, and given that the range will be small, do all this under cli.
224 *
225 * Note, there is a hazard that the ASID in mm->context is no longer
226 * actually associated with mm, i.e. if the mm->context has started a new
227 * cycle since mm was last active. However, this is just a performance
228 * issue: all that happens is that we invalidate lines belonging to
229 * another mm, so the owning process has to refill them when that mm goes
230 * live again. mm itself can't have any cache entries because there will
231 * have been a flush_cache_all when the new mm->context cycle started.
232 */
332static void sh64_icache_inv_user_small_range(struct mm_struct *mm, 233static void sh64_icache_inv_user_small_range(struct mm_struct *mm,
333 unsigned long start, int len) 234 unsigned long start, int len)
334{ 235{
335
336 /* Invalidate a small range of user context I-cache, not necessarily
337 page (or even cache-line) aligned. */
338
339 unsigned long long eaddr = start; 236 unsigned long long eaddr = start;
340 unsigned long long eaddr_end = start + len; 237 unsigned long long eaddr_end = start + len;
341 unsigned long current_asid, mm_asid; 238 unsigned long current_asid, mm_asid;
342 unsigned long long flags; 239 unsigned long long flags;
343 unsigned long long epage_start; 240 unsigned long long epage_start;
344 241
345 /* Since this is used inside ptrace, the ASID in the mm context 242 /*
346 typically won't match current_asid. We'll have to switch ASID to do 243 * Align to start of cache line. Otherwise, suppose len==8 and
347 this. For safety, and given that the range will be small, do all 244 * start was at 32N+28 : the last 4 bytes wouldn't get invalidated.
348 this under cli. 245 */
349 246 eaddr = L1_CACHE_ALIGN(start);
350 Note, there is a hazard that the ASID in mm->context is no longer
351 actually associated with mm, i.e. if the mm->context has started a
352 new cycle since mm was last active. However, this is just a
353 performance issue: all that happens is that we invalidate lines
354 belonging to another mm, so the owning process has to refill them
355 when that mm goes live again. mm itself can't have any cache
356 entries because there will have been a flush_cache_all when the new
357 mm->context cycle started. */
358
359 /* Align to start of cache line. Otherwise, suppose len==8 and start
360 was at 32N+28 : the last 4 bytes wouldn't get invalidated. */
361 eaddr = start & L1_CACHE_ALIGN_MASK;
362 eaddr_end = start + len; 247 eaddr_end = start + len;
363 248
249 mm_asid = cpu_asid(smp_processor_id(), mm);
364 local_irq_save(flags); 250 local_irq_save(flags);
365 mm_asid = mm->context & MMU_CONTEXT_ASID_MASK;
366 current_asid = switch_and_save_asid(mm_asid); 251 current_asid = switch_and_save_asid(mm_asid);
367 252
368 epage_start = eaddr & PAGE_MASK; 253 epage_start = eaddr & PAGE_MASK;
369 254
370 while (eaddr < eaddr_end) 255 while (eaddr < eaddr_end) {
371 { 256 __asm__ __volatile__("icbi %0, 0" : : "r" (eaddr));
372 asm __volatile__("icbi %0, 0" : : "r" (eaddr));
373 eaddr += L1_CACHE_BYTES; 257 eaddr += L1_CACHE_BYTES;
374 } 258 }
375 switch_and_save_asid(current_asid); 259 switch_and_save_asid(current_asid);
@@ -394,30 +278,24 @@ static void sh64_icache_inv_current_user_range(unsigned long start, unsigned lon
394 been recycled since we were last active in which case we might just 278 been recycled since we were last active in which case we might just
395 invalidate another processes I-cache entries : no worries, just a 279 invalidate another processes I-cache entries : no worries, just a
396 performance drop for him. */ 280 performance drop for him. */
397 aligned_start = start & L1_CACHE_ALIGN_MASK; 281 aligned_start = L1_CACHE_ALIGN(start);
398 addr = aligned_start; 282 addr = aligned_start;
399 while (addr < ull_end) { 283 while (addr < ull_end) {
400 asm __volatile__ ("icbi %0, 0" : : "r" (addr)); 284 __asm__ __volatile__ ("icbi %0, 0" : : "r" (addr));
401 asm __volatile__ ("nop"); 285 __asm__ __volatile__ ("nop");
402 asm __volatile__ ("nop"); 286 __asm__ __volatile__ ("nop");
403 addr += L1_CACHE_BYTES; 287 addr += L1_CACHE_BYTES;
404 } 288 }
405} 289}
406
407#endif /* !CONFIG_ICACHE_DISABLED */ 290#endif /* !CONFIG_ICACHE_DISABLED */
408 291
409/****************************************************************************/
410
411#ifndef CONFIG_DCACHE_DISABLED 292#ifndef CONFIG_DCACHE_DISABLED
412
413/* Buffer used as the target of alloco instructions to purge data from cache 293/* Buffer used as the target of alloco instructions to purge data from cache
414 sets by natural eviction. -- RPC */ 294 sets by natural eviction. -- RPC */
415#define DUMMY_ALLOCO_AREA_SIZE L1_CACHE_SIZE_BYTES + (1024 * 4) 295#define DUMMY_ALLOCO_AREA_SIZE ((L1_CACHE_BYTES << 10) + (1024 * 4))
416static unsigned char dummy_alloco_area[DUMMY_ALLOCO_AREA_SIZE] __cacheline_aligned = { 0, }; 296static unsigned char dummy_alloco_area[DUMMY_ALLOCO_AREA_SIZE] __cacheline_aligned = { 0, };
417 297
418/****************************************************************************/ 298static void inline sh64_dcache_purge_sets(int sets_to_purge_base, int n_sets)
419
420static void __inline__ sh64_dcache_purge_sets(int sets_to_purge_base, int n_sets)
421{ 299{
422 /* Purge all ways in a particular block of sets, specified by the base 300 /* Purge all ways in a particular block of sets, specified by the base
423 set number and number of sets. Can handle wrap-around, if that's 301 set number and number of sets. Can handle wrap-around, if that's
@@ -428,102 +306,86 @@ static void __inline__ sh64_dcache_purge_sets(int sets_to_purge_base, int n_sets
428 int j; 306 int j;
429 int set_offset; 307 int set_offset;
430 308
431 dummy_buffer_base_set = ((int)&dummy_alloco_area & cpu_data->dcache.idx_mask) >> cpu_data->dcache.entry_shift; 309 dummy_buffer_base_set = ((int)&dummy_alloco_area &
310 cpu_data->dcache.entry_mask) >>
311 cpu_data->dcache.entry_shift;
432 set_offset = sets_to_purge_base - dummy_buffer_base_set; 312 set_offset = sets_to_purge_base - dummy_buffer_base_set;
433 313
434 for (j=0; j<n_sets; j++, set_offset++) { 314 for (j = 0; j < n_sets; j++, set_offset++) {
435 set_offset &= (cpu_data->dcache.sets - 1); 315 set_offset &= (cpu_data->dcache.sets - 1);
436 eaddr0 = (unsigned long long)dummy_alloco_area + (set_offset << cpu_data->dcache.entry_shift); 316 eaddr0 = (unsigned long long)dummy_alloco_area +
437 317 (set_offset << cpu_data->dcache.entry_shift);
438 /* Do one alloco which hits the required set per cache way. For 318
439 write-back mode, this will purge the #ways resident lines. There's 319 /*
440 little point unrolling this loop because the allocos stall more if 320 * Do one alloco which hits the required set per cache
441 they're too close together. */ 321 * way. For write-back mode, this will purge the #ways
442 eaddr1 = eaddr0 + cpu_data->dcache.way_ofs * cpu_data->dcache.ways; 322 * resident lines. There's little point unrolling this
443 for (eaddr=eaddr0; eaddr<eaddr1; eaddr+=cpu_data->dcache.way_ofs) { 323 * loop because the allocos stall more if they're too
444 asm __volatile__ ("alloco %0, 0" : : "r" (eaddr)); 324 * close together.
445 asm __volatile__ ("synco"); /* TAKum03020 */ 325 */
326 eaddr1 = eaddr0 + cpu_data->dcache.way_size *
327 cpu_data->dcache.ways;
328
329 for (eaddr = eaddr0; eaddr < eaddr1;
330 eaddr += cpu_data->dcache.way_size) {
331 __asm__ __volatile__ ("alloco %0, 0" : : "r" (eaddr));
332 __asm__ __volatile__ ("synco"); /* TAKum03020 */
446 } 333 }
447 334
448 eaddr1 = eaddr0 + cpu_data->dcache.way_ofs * cpu_data->dcache.ways; 335 eaddr1 = eaddr0 + cpu_data->dcache.way_size *
449 for (eaddr=eaddr0; eaddr<eaddr1; eaddr+=cpu_data->dcache.way_ofs) { 336 cpu_data->dcache.ways;
450 /* Load from each address. Required because alloco is a NOP if 337
451 the cache is write-through. Write-through is a config option. */ 338 for (eaddr = eaddr0; eaddr < eaddr1;
339 eaddr += cpu_data->dcache.way_size) {
340 /*
341 * Load from each address. Required because
342 * alloco is a NOP if the cache is write-through.
343 */
452 if (test_bit(SH_CACHE_MODE_WT, &(cpu_data->dcache.flags))) 344 if (test_bit(SH_CACHE_MODE_WT, &(cpu_data->dcache.flags)))
453 *(volatile unsigned char *)(int)eaddr; 345 ctrl_inb(eaddr);
454 } 346 }
455 } 347 }
456 348
457 /* Don't use OCBI to invalidate the lines. That costs cycles directly. 349 /*
458 If the dummy block is just left resident, it will naturally get 350 * Don't use OCBI to invalidate the lines. That costs cycles
459 evicted as required. */ 351 * directly. If the dummy block is just left resident, it will
460 352 * naturally get evicted as required.
461 return; 353 */
462} 354}
463 355
464/****************************************************************************/ 356/*
465 357 * Purge the entire contents of the dcache. The most efficient way to
358 * achieve this is to use alloco instructions on a region of unused
359 * memory equal in size to the cache, thereby causing the current
360 * contents to be discarded by natural eviction. The alternative, namely
361 * reading every tag, setting up a mapping for the corresponding page and
362 * doing an OCBP for the line, would be much more expensive.
363 */
466static void sh64_dcache_purge_all(void) 364static void sh64_dcache_purge_all(void)
467{ 365{
468 /* Purge the entire contents of the dcache. The most efficient way to
469 achieve this is to use alloco instructions on a region of unused
470 memory equal in size to the cache, thereby causing the current
471 contents to be discarded by natural eviction. The alternative,
472 namely reading every tag, setting up a mapping for the corresponding
473 page and doing an OCBP for the line, would be much more expensive.
474 */
475 366
476 sh64_dcache_purge_sets(0, cpu_data->dcache.sets); 367 sh64_dcache_purge_sets(0, cpu_data->dcache.sets);
477
478 return;
479
480} 368}
481 369
482/****************************************************************************/
483
484static void sh64_dcache_purge_kernel_range(unsigned long start, unsigned long end)
485{
486 /* Purge the range of addresses [start,end] from the D-cache. The
487 addresses lie in the superpage mapping. There's no harm if we
488 overpurge at either end - just a small performance loss. */
489 unsigned long long ullend, addr, aligned_start;
490#if (NEFF == 32)
491 aligned_start = (unsigned long long)(signed long long)(signed long) start;
492#else
493#error "NEFF != 32"
494#endif
495 aligned_start &= L1_CACHE_ALIGN_MASK;
496 addr = aligned_start;
497#if (NEFF == 32)
498 ullend = (unsigned long long) (signed long long) (signed long) end;
499#else
500#error "NEFF != 32"
501#endif
502 while (addr <= ullend) {
503 asm __volatile__ ("ocbp %0, 0" : : "r" (addr));
504 addr += L1_CACHE_BYTES;
505 }
506 return;
507}
508 370
509/* Assumes this address (+ (2**n_synbits) pages up from it) aren't used for 371/* Assumes this address (+ (2**n_synbits) pages up from it) aren't used for
510 anything else in the kernel */ 372 anything else in the kernel */
511#define MAGIC_PAGE0_START 0xffffffffec000000ULL 373#define MAGIC_PAGE0_START 0xffffffffec000000ULL
512 374
513static void sh64_dcache_purge_coloured_phy_page(unsigned long paddr, unsigned long eaddr) 375/* Purge the physical page 'paddr' from the cache. It's known that any
376 * cache lines requiring attention have the same page colour as the the
377 * address 'eaddr'.
378 *
379 * This relies on the fact that the D-cache matches on physical tags when
380 * no virtual tag matches. So we create an alias for the original page
381 * and purge through that. (Alternatively, we could have done this by
382 * switching ASID to match the original mapping and purged through that,
383 * but that involves ASID switching cost + probably a TLBMISS + refill
384 * anyway.)
385 */
386static void sh64_dcache_purge_coloured_phy_page(unsigned long paddr,
387 unsigned long eaddr)
514{ 388{
515 /* Purge the physical page 'paddr' from the cache. It's known that any
516 cache lines requiring attention have the same page colour as the the
517 address 'eaddr'.
518
519 This relies on the fact that the D-cache matches on physical tags
520 when no virtual tag matches. So we create an alias for the original
521 page and purge through that. (Alternatively, we could have done
522 this by switching ASID to match the original mapping and purged
523 through that, but that involves ASID switching cost + probably a
524 TLBMISS + refill anyway.)
525 */
526
527 unsigned long long magic_page_start; 389 unsigned long long magic_page_start;
528 unsigned long long magic_eaddr, magic_eaddr_end; 390 unsigned long long magic_eaddr, magic_eaddr_end;
529 391
@@ -531,47 +393,45 @@ static void sh64_dcache_purge_coloured_phy_page(unsigned long paddr, unsigned lo
531 393
532 /* As long as the kernel is not pre-emptible, this doesn't need to be 394 /* As long as the kernel is not pre-emptible, this doesn't need to be
533 under cli/sti. */ 395 under cli/sti. */
534
535 sh64_setup_dtlb_cache_slot(magic_page_start, get_asid(), paddr); 396 sh64_setup_dtlb_cache_slot(magic_page_start, get_asid(), paddr);
536 397
537 magic_eaddr = magic_page_start; 398 magic_eaddr = magic_page_start;
538 magic_eaddr_end = magic_eaddr + PAGE_SIZE; 399 magic_eaddr_end = magic_eaddr + PAGE_SIZE;
400
539 while (magic_eaddr < magic_eaddr_end) { 401 while (magic_eaddr < magic_eaddr_end) {
540 /* Little point in unrolling this loop - the OCBPs are blocking 402 /* Little point in unrolling this loop - the OCBPs are blocking
541 and won't go any quicker (i.e. the loop overhead is parallel 403 and won't go any quicker (i.e. the loop overhead is parallel
542 to part of the OCBP execution.) */ 404 to part of the OCBP execution.) */
543 asm __volatile__ ("ocbp %0, 0" : : "r" (magic_eaddr)); 405 __asm__ __volatile__ ("ocbp %0, 0" : : "r" (magic_eaddr));
544 magic_eaddr += L1_CACHE_BYTES; 406 magic_eaddr += L1_CACHE_BYTES;
545 } 407 }
546 408
547 sh64_teardown_dtlb_cache_slot(); 409 sh64_teardown_dtlb_cache_slot();
548} 410}
549 411
550/****************************************************************************/ 412/*
551 413 * Purge a page given its physical start address, by creating a temporary
414 * 1 page mapping and purging across that. Even if we know the virtual
415 * address (& vma or mm) of the page, the method here is more elegant
416 * because it avoids issues of coping with page faults on the purge
417 * instructions (i.e. no special-case code required in the critical path
418 * in the TLB miss handling).
419 */
552static void sh64_dcache_purge_phy_page(unsigned long paddr) 420static void sh64_dcache_purge_phy_page(unsigned long paddr)
553{ 421{
554 /* Pure a page given its physical start address, by creating a
555 temporary 1 page mapping and purging across that. Even if we know
556 the virtual address (& vma or mm) of the page, the method here is
557 more elegant because it avoids issues of coping with page faults on
558 the purge instructions (i.e. no special-case code required in the
559 critical path in the TLB miss handling). */
560
561 unsigned long long eaddr_start, eaddr, eaddr_end; 422 unsigned long long eaddr_start, eaddr, eaddr_end;
562 int i; 423 int i;
563 424
564 /* As long as the kernel is not pre-emptible, this doesn't need to be 425 /* As long as the kernel is not pre-emptible, this doesn't need to be
565 under cli/sti. */ 426 under cli/sti. */
566
567 eaddr_start = MAGIC_PAGE0_START; 427 eaddr_start = MAGIC_PAGE0_START;
568 for (i=0; i < (1 << CACHE_OC_N_SYNBITS); i++) { 428 for (i = 0; i < (1 << CACHE_OC_N_SYNBITS); i++) {
569 sh64_setup_dtlb_cache_slot(eaddr_start, get_asid(), paddr); 429 sh64_setup_dtlb_cache_slot(eaddr_start, get_asid(), paddr);
570 430
571 eaddr = eaddr_start; 431 eaddr = eaddr_start;
572 eaddr_end = eaddr + PAGE_SIZE; 432 eaddr_end = eaddr + PAGE_SIZE;
573 while (eaddr < eaddr_end) { 433 while (eaddr < eaddr_end) {
574 asm __volatile__ ("ocbp %0, 0" : : "r" (eaddr)); 434 __asm__ __volatile__ ("ocbp %0, 0" : : "r" (eaddr));
575 eaddr += L1_CACHE_BYTES; 435 eaddr += L1_CACHE_BYTES;
576 } 436 }
577 437
@@ -584,6 +444,7 @@ static void sh64_dcache_purge_user_pages(struct mm_struct *mm,
584 unsigned long addr, unsigned long end) 444 unsigned long addr, unsigned long end)
585{ 445{
586 pgd_t *pgd; 446 pgd_t *pgd;
447 pud_t *pud;
587 pmd_t *pmd; 448 pmd_t *pmd;
588 pte_t *pte; 449 pte_t *pte;
589 pte_t entry; 450 pte_t entry;
@@ -597,7 +458,11 @@ static void sh64_dcache_purge_user_pages(struct mm_struct *mm,
597 if (pgd_bad(*pgd)) 458 if (pgd_bad(*pgd))
598 return; 459 return;
599 460
600 pmd = pmd_offset(pgd, addr); 461 pud = pud_offset(pgd, addr);
462 if (pud_none(*pud) || pud_bad(*pud))
463 return;
464
465 pmd = pmd_offset(pud, addr);
601 if (pmd_none(*pmd) || pmd_bad(*pmd)) 466 if (pmd_none(*pmd) || pmd_bad(*pmd))
602 return; 467 return;
603 468
@@ -611,419 +476,357 @@ static void sh64_dcache_purge_user_pages(struct mm_struct *mm,
611 } while (pte++, addr += PAGE_SIZE, addr != end); 476 } while (pte++, addr += PAGE_SIZE, addr != end);
612 pte_unmap_unlock(pte - 1, ptl); 477 pte_unmap_unlock(pte - 1, ptl);
613} 478}
614/****************************************************************************/
615 479
480/*
481 * There are at least 5 choices for the implementation of this, with
482 * pros (+), cons(-), comments(*):
483 *
484 * 1. ocbp each line in the range through the original user's ASID
485 * + no lines spuriously evicted
486 * - tlbmiss handling (must either handle faults on demand => extra
487 * special-case code in tlbmiss critical path), or map the page in
488 * advance (=> flush_tlb_range in advance to avoid multiple hits)
489 * - ASID switching
490 * - expensive for large ranges
491 *
492 * 2. temporarily map each page in the range to a special effective
493 * address and ocbp through the temporary mapping; relies on the
494 * fact that SH-5 OCB* always do TLB lookup and match on ptags (they
495 * never look at the etags)
496 * + no spurious evictions
497 * - expensive for large ranges
498 * * surely cheaper than (1)
499 *
500 * 3. walk all the lines in the cache, check the tags, if a match
501 * occurs create a page mapping to ocbp the line through
502 * + no spurious evictions
503 * - tag inspection overhead
504 * - (especially for small ranges)
505 * - potential cost of setting up/tearing down page mapping for
506 * every line that matches the range
507 * * cost partly independent of range size
508 *
509 * 4. walk all the lines in the cache, check the tags, if a match
510 * occurs use 4 * alloco to purge the line (+3 other probably
511 * innocent victims) by natural eviction
512 * + no tlb mapping overheads
513 * - spurious evictions
514 * - tag inspection overhead
515 *
516 * 5. implement like flush_cache_all
517 * + no tag inspection overhead
518 * - spurious evictions
519 * - bad for small ranges
520 *
521 * (1) can be ruled out as more expensive than (2). (2) appears best
522 * for small ranges. The choice between (3), (4) and (5) for large
523 * ranges and the range size for the large/small boundary need
524 * benchmarking to determine.
525 *
526 * For now use approach (2) for small ranges and (5) for large ones.
527 */
616static void sh64_dcache_purge_user_range(struct mm_struct *mm, 528static void sh64_dcache_purge_user_range(struct mm_struct *mm,
617 unsigned long start, unsigned long end) 529 unsigned long start, unsigned long end)
618{ 530{
619 /* There are at least 5 choices for the implementation of this, with 531 int n_pages = ((end - start) >> PAGE_SHIFT);
620 pros (+), cons(-), comments(*):
621
622 1. ocbp each line in the range through the original user's ASID
623 + no lines spuriously evicted
624 - tlbmiss handling (must either handle faults on demand => extra
625 special-case code in tlbmiss critical path), or map the page in
626 advance (=> flush_tlb_range in advance to avoid multiple hits)
627 - ASID switching
628 - expensive for large ranges
629
630 2. temporarily map each page in the range to a special effective
631 address and ocbp through the temporary mapping; relies on the
632 fact that SH-5 OCB* always do TLB lookup and match on ptags (they
633 never look at the etags)
634 + no spurious evictions
635 - expensive for large ranges
636 * surely cheaper than (1)
637
638 3. walk all the lines in the cache, check the tags, if a match
639 occurs create a page mapping to ocbp the line through
640 + no spurious evictions
641 - tag inspection overhead
642 - (especially for small ranges)
643 - potential cost of setting up/tearing down page mapping for
644 every line that matches the range
645 * cost partly independent of range size
646
647 4. walk all the lines in the cache, check the tags, if a match
648 occurs use 4 * alloco to purge the line (+3 other probably
649 innocent victims) by natural eviction
650 + no tlb mapping overheads
651 - spurious evictions
652 - tag inspection overhead
653
654 5. implement like flush_cache_all
655 + no tag inspection overhead
656 - spurious evictions
657 - bad for small ranges
658
659 (1) can be ruled out as more expensive than (2). (2) appears best
660 for small ranges. The choice between (3), (4) and (5) for large
661 ranges and the range size for the large/small boundary need
662 benchmarking to determine.
663
664 For now use approach (2) for small ranges and (5) for large ones.
665
666 */
667
668 int n_pages;
669 532
670 n_pages = ((end - start) >> PAGE_SHIFT);
671 if (n_pages >= 64 || ((start ^ (end - 1)) & PMD_MASK)) { 533 if (n_pages >= 64 || ((start ^ (end - 1)) & PMD_MASK)) {
672#if 1
673 sh64_dcache_purge_all(); 534 sh64_dcache_purge_all();
674#else
675 unsigned long long set, way;
676 unsigned long mm_asid = mm->context & MMU_CONTEXT_ASID_MASK;
677 for (set = 0; set < cpu_data->dcache.sets; set++) {
678 unsigned long long set_base_config_addr = CACHE_OC_ADDRESS_ARRAY + (set << cpu_data->dcache.set_shift);
679 for (way = 0; way < cpu_data->dcache.ways; way++) {
680 unsigned long long config_addr = set_base_config_addr + (way << cpu_data->dcache.way_step_shift);
681 unsigned long long tag0;
682 unsigned long line_valid;
683
684 asm __volatile__("getcfg %1, 0, %0" : "=r" (tag0) : "r" (config_addr));
685 line_valid = tag0 & SH_CACHE_VALID;
686 if (line_valid) {
687 unsigned long cache_asid;
688 unsigned long epn;
689
690 cache_asid = (tag0 & cpu_data->dcache.asid_mask) >> cpu_data->dcache.asid_shift;
691 /* The next line needs some
692 explanation. The virtual tags
693 encode bits [31:13] of the virtual
694 address, bit [12] of the 'tag' being
695 implied by the cache set index. */
696 epn = (tag0 & cpu_data->dcache.epn_mask) | ((set & 0x80) << cpu_data->dcache.entry_shift);
697
698 if ((cache_asid == mm_asid) && (start <= epn) && (epn < end)) {
699 /* TODO : could optimise this
700 call by batching multiple
701 adjacent sets together. */
702 sh64_dcache_purge_sets(set, 1);
703 break; /* Don't waste time inspecting other ways for this set */
704 }
705 }
706 }
707 }
708#endif
709 } else { 535 } else {
710 /* Small range, covered by a single page table page */ 536 /* Small range, covered by a single page table page */
711 start &= PAGE_MASK; /* should already be so */ 537 start &= PAGE_MASK; /* should already be so */
712 end = PAGE_ALIGN(end); /* should already be so */ 538 end = PAGE_ALIGN(end); /* should already be so */
713 sh64_dcache_purge_user_pages(mm, start, end); 539 sh64_dcache_purge_user_pages(mm, start, end);
714 } 540 }
715 return;
716} 541}
717 542
718static void sh64_dcache_wback_current_user_range(unsigned long start, unsigned long end) 543/*
544 * Purge the range of addresses from the D-cache.
545 *
546 * The addresses lie in the superpage mapping. There's no harm if we
547 * overpurge at either end - just a small performance loss.
548 */
549void __flush_purge_region(void *start, int size)
719{ 550{
720 unsigned long long aligned_start; 551 unsigned long long ullend, addr, aligned_start;
721 unsigned long long ull_end;
722 unsigned long long addr;
723
724 ull_end = end;
725 552
726 /* Just wback over the range using the natural addresses. TLB miss 553 aligned_start = (unsigned long long)(signed long long)(signed long) start;
727 handling will be OK (TBC) : the range has just been written to by 554 addr = L1_CACHE_ALIGN(aligned_start);
728 the signal frame setup code, so the PTEs must exist. 555 ullend = (unsigned long long) (signed long long) (signed long) start + size;
729 556
730 Note, if we have CONFIG_PREEMPT and get preempted inside this loop, 557 while (addr <= ullend) {
731 it doesn't matter, even if the pid->ASID mapping changes whilst 558 __asm__ __volatile__ ("ocbp %0, 0" : : "r" (addr));
732 we're away. In that case the cache will have been flushed when the
733 mapping was renewed. So the writebacks below will be nugatory (and
734 we'll doubtless have to fault the TLB entry/ies in again with the
735 new ASID), but it's a rare case.
736 */
737 aligned_start = start & L1_CACHE_ALIGN_MASK;
738 addr = aligned_start;
739 while (addr < ull_end) {
740 asm __volatile__ ("ocbwb %0, 0" : : "r" (addr));
741 addr += L1_CACHE_BYTES; 559 addr += L1_CACHE_BYTES;
742 } 560 }
743} 561}
744 562
745/****************************************************************************/ 563void __flush_wback_region(void *start, int size)
746
747/* These *MUST* lie in an area of virtual address space that's otherwise unused. */
748#define UNIQUE_EADDR_START 0xe0000000UL
749#define UNIQUE_EADDR_END 0xe8000000UL
750
751static unsigned long sh64_make_unique_eaddr(unsigned long user_eaddr, unsigned long paddr)
752{ 564{
753 /* Given a physical address paddr, and a user virtual address 565 unsigned long long ullend, addr, aligned_start;
754 user_eaddr which will eventually be mapped to it, create a one-off
755 kernel-private eaddr mapped to the same paddr. This is used for
756 creating special destination pages for copy_user_page and
757 clear_user_page */
758 566
759 static unsigned long current_pointer = UNIQUE_EADDR_START; 567 aligned_start = (unsigned long long)(signed long long)(signed long) start;
760 unsigned long coloured_pointer; 568 addr = L1_CACHE_ALIGN(aligned_start);
569 ullend = (unsigned long long) (signed long long) (signed long) start + size;
761 570
762 if (current_pointer == UNIQUE_EADDR_END) { 571 while (addr < ullend) {
763 sh64_dcache_purge_all(); 572 __asm__ __volatile__ ("ocbwb %0, 0" : : "r" (addr));
764 current_pointer = UNIQUE_EADDR_START; 573 addr += L1_CACHE_BYTES;
765 } 574 }
766
767 coloured_pointer = (current_pointer & ~CACHE_OC_SYN_MASK) | (user_eaddr & CACHE_OC_SYN_MASK);
768 sh64_setup_dtlb_cache_slot(coloured_pointer, get_asid(), paddr);
769
770 current_pointer += (PAGE_SIZE << CACHE_OC_N_SYNBITS);
771
772 return coloured_pointer;
773}
774
775/****************************************************************************/
776
777static void sh64_copy_user_page_coloured(void *to, void *from, unsigned long address)
778{
779 void *coloured_to;
780
781 /* Discard any existing cache entries of the wrong colour. These are
782 present quite often, if the kernel has recently used the page
783 internally, then given it up, then it's been allocated to the user.
784 */
785 sh64_dcache_purge_coloured_phy_page(__pa(to), (unsigned long) to);
786
787 coloured_to = (void *) sh64_make_unique_eaddr(address, __pa(to));
788 sh64_page_copy(from, coloured_to);
789
790 sh64_teardown_dtlb_cache_slot();
791} 575}
792 576
793static void sh64_clear_user_page_coloured(void *to, unsigned long address) 577void __flush_invalidate_region(void *start, int size)
794{ 578{
795 void *coloured_to; 579 unsigned long long ullend, addr, aligned_start;
796
797 /* Discard any existing kernel-originated lines of the wrong colour (as
798 above) */
799 sh64_dcache_purge_coloured_phy_page(__pa(to), (unsigned long) to);
800 580
801 coloured_to = (void *) sh64_make_unique_eaddr(address, __pa(to)); 581 aligned_start = (unsigned long long)(signed long long)(signed long) start;
802 sh64_page_clear(coloured_to); 582 addr = L1_CACHE_ALIGN(aligned_start);
583 ullend = (unsigned long long) (signed long long) (signed long) start + size;
803 584
804 sh64_teardown_dtlb_cache_slot(); 585 while (addr < ullend) {
586 __asm__ __volatile__ ("ocbi %0, 0" : : "r" (addr));
587 addr += L1_CACHE_BYTES;
588 }
805} 589}
806
807#endif /* !CONFIG_DCACHE_DISABLED */ 590#endif /* !CONFIG_DCACHE_DISABLED */
808 591
809/****************************************************************************/ 592/*
810 593 * Invalidate the entire contents of both caches, after writing back to
811/*########################################################################## 594 * memory any dirty data from the D-cache.
812 EXTERNALLY CALLABLE API. 595 */
813 ##########################################################################*/
814
815/* These functions are described in Documentation/cachetlb.txt.
816 Each one of these functions varies in behaviour depending on whether the
817 I-cache and/or D-cache are configured out.
818
819 Note that the Linux term 'flush' corresponds to what is termed 'purge' in
820 the sh/sh64 jargon for the D-cache, i.e. write back dirty data then
821 invalidate the cache lines, and 'invalidate' for the I-cache.
822 */
823
824#undef FLUSH_TRACE
825
826void flush_cache_all(void) 596void flush_cache_all(void)
827{ 597{
828 /* Invalidate the entire contents of both caches, after writing back to
829 memory any dirty data from the D-cache. */
830 sh64_dcache_purge_all(); 598 sh64_dcache_purge_all();
831 sh64_icache_inv_all(); 599 sh64_icache_inv_all();
832} 600}
833 601
834/****************************************************************************/ 602/*
835 603 * Invalidate an entire user-address space from both caches, after
604 * writing back dirty data (e.g. for shared mmap etc).
605 *
606 * This could be coded selectively by inspecting all the tags then
607 * doing 4*alloco on any set containing a match (as for
608 * flush_cache_range), but fork/exit/execve (where this is called from)
609 * are expensive anyway.
610 *
611 * Have to do a purge here, despite the comments re I-cache below.
612 * There could be odd-coloured dirty data associated with the mm still
613 * in the cache - if this gets written out through natural eviction
614 * after the kernel has reused the page there will be chaos.
615 *
616 * The mm being torn down won't ever be active again, so any Icache
617 * lines tagged with its ASID won't be visible for the rest of the
618 * lifetime of this ASID cycle. Before the ASID gets reused, there
619 * will be a flush_cache_all. Hence we don't need to touch the
620 * I-cache. This is similar to the lack of action needed in
621 * flush_tlb_mm - see fault.c.
622 */
836void flush_cache_mm(struct mm_struct *mm) 623void flush_cache_mm(struct mm_struct *mm)
837{ 624{
838 /* Invalidate an entire user-address space from both caches, after
839 writing back dirty data (e.g. for shared mmap etc). */
840
841 /* This could be coded selectively by inspecting all the tags then
842 doing 4*alloco on any set containing a match (as for
843 flush_cache_range), but fork/exit/execve (where this is called from)
844 are expensive anyway. */
845
846 /* Have to do a purge here, despite the comments re I-cache below.
847 There could be odd-coloured dirty data associated with the mm still
848 in the cache - if this gets written out through natural eviction
849 after the kernel has reused the page there will be chaos.
850 */
851
852 sh64_dcache_purge_all(); 625 sh64_dcache_purge_all();
853
854 /* The mm being torn down won't ever be active again, so any Icache
855 lines tagged with its ASID won't be visible for the rest of the
856 lifetime of this ASID cycle. Before the ASID gets reused, there
857 will be a flush_cache_all. Hence we don't need to touch the
858 I-cache. This is similar to the lack of action needed in
859 flush_tlb_mm - see fault.c. */
860} 626}
861 627
862/****************************************************************************/ 628/*
863 629 * Invalidate (from both caches) the range [start,end) of virtual
630 * addresses from the user address space specified by mm, after writing
631 * back any dirty data.
632 *
633 * Note, 'end' is 1 byte beyond the end of the range to flush.
634 */
864void flush_cache_range(struct vm_area_struct *vma, unsigned long start, 635void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
865 unsigned long end) 636 unsigned long end)
866{ 637{
867 struct mm_struct *mm = vma->vm_mm; 638 struct mm_struct *mm = vma->vm_mm;
868 639
869 /* Invalidate (from both caches) the range [start,end) of virtual
870 addresses from the user address space specified by mm, after writing
871 back any dirty data.
872
873 Note, 'end' is 1 byte beyond the end of the range to flush. */
874
875 sh64_dcache_purge_user_range(mm, start, end); 640 sh64_dcache_purge_user_range(mm, start, end);
876 sh64_icache_inv_user_page_range(mm, start, end); 641 sh64_icache_inv_user_page_range(mm, start, end);
877} 642}
878 643
879/****************************************************************************/ 644/*
880 645 * Invalidate any entries in either cache for the vma within the user
881void flush_cache_page(struct vm_area_struct *vma, unsigned long eaddr, unsigned long pfn) 646 * address space vma->vm_mm for the page starting at virtual address
647 * 'eaddr'. This seems to be used primarily in breaking COW. Note,
648 * the I-cache must be searched too in case the page in question is
649 * both writable and being executed from (e.g. stack trampolines.)
650 *
651 * Note, this is called with pte lock held.
652 */
653void flush_cache_page(struct vm_area_struct *vma, unsigned long eaddr,
654 unsigned long pfn)
882{ 655{
883 /* Invalidate any entries in either cache for the vma within the user
884 address space vma->vm_mm for the page starting at virtual address
885 'eaddr'. This seems to be used primarily in breaking COW. Note,
886 the I-cache must be searched too in case the page in question is
887 both writable and being executed from (e.g. stack trampolines.)
888
889 Note, this is called with pte lock held.
890 */
891
892 sh64_dcache_purge_phy_page(pfn << PAGE_SHIFT); 656 sh64_dcache_purge_phy_page(pfn << PAGE_SHIFT);
893 657
894 if (vma->vm_flags & VM_EXEC) { 658 if (vma->vm_flags & VM_EXEC)
895 sh64_icache_inv_user_page(vma, eaddr); 659 sh64_icache_inv_user_page(vma, eaddr);
896 }
897} 660}
898 661
899/****************************************************************************/ 662void flush_dcache_page(struct page *page)
663{
664 sh64_dcache_purge_phy_page(page_to_phys(page));
665 wmb();
666}
900 667
901#ifndef CONFIG_DCACHE_DISABLED 668/*
669 * Flush the range [start,end] of kernel virtual adddress space from
670 * the I-cache. The corresponding range must be purged from the
671 * D-cache also because the SH-5 doesn't have cache snooping between
672 * the caches. The addresses will be visible through the superpage
673 * mapping, therefore it's guaranteed that there no cache entries for
674 * the range in cache sets of the wrong colour.
675 */
676void flush_icache_range(unsigned long start, unsigned long end)
677{
678 __flush_purge_region((void *)start, end);
679 wmb();
680 sh64_icache_inv_kernel_range(start, end);
681}
902 682
903void copy_user_page(void *to, void *from, unsigned long address, struct page *page) 683/*
684 * Flush the range of user (defined by vma->vm_mm) address space starting
685 * at 'addr' for 'len' bytes from the cache. The range does not straddle
686 * a page boundary, the unique physical page containing the range is
687 * 'page'. This seems to be used mainly for invalidating an address
688 * range following a poke into the program text through the ptrace() call
689 * from another process (e.g. for BRK instruction insertion).
690 */
691void flush_icache_user_range(struct vm_area_struct *vma,
692 struct page *page, unsigned long addr, int len)
904{ 693{
905 /* 'from' and 'to' are kernel virtual addresses (within the superpage
906 mapping of the physical RAM). 'address' is the user virtual address
907 where the copy 'to' will be mapped after. This allows a custom
908 mapping to be used to ensure that the new copy is placed in the
909 right cache sets for the user to see it without having to bounce it
910 out via memory. Note however : the call to flush_page_to_ram in
911 (generic)/mm/memory.c:(break_cow) undoes all this good work in that one
912 very important case!
913
914 TBD : can we guarantee that on every call, any cache entries for
915 'from' are in the same colour sets as 'address' also? i.e. is this
916 always used just to deal with COW? (I suspect not). */
917
918 /* There are two possibilities here for when the page 'from' was last accessed:
919 * by the kernel : this is OK, no purge required.
920 * by the/a user (e.g. for break_COW) : need to purge.
921
922 If the potential user mapping at 'address' is the same colour as
923 'from' there is no need to purge any cache lines from the 'from'
924 page mapped into cache sets of colour 'address'. (The copy will be
925 accessing the page through 'from').
926 */
927 694
928 if (((address ^ (unsigned long) from) & CACHE_OC_SYN_MASK) != 0) { 695 sh64_dcache_purge_coloured_phy_page(page_to_phys(page), addr);
929 sh64_dcache_purge_coloured_phy_page(__pa(from), address); 696 mb();
930 }
931 697
932 if (((address ^ (unsigned long) to) & CACHE_OC_SYN_MASK) == 0) { 698 if (vma->vm_flags & VM_EXEC)
933 /* No synonym problem on destination */ 699 sh64_icache_inv_user_small_range(vma->vm_mm, addr, len);
934 sh64_page_copy(from, to); 700}
935 } else { 701
936 sh64_copy_user_page_coloured(to, from, address); 702/*
937 } 703 * For the address range [start,end), write back the data from the
704 * D-cache and invalidate the corresponding region of the I-cache for the
705 * current process. Used to flush signal trampolines on the stack to
706 * make them executable.
707 */
708void flush_cache_sigtramp(unsigned long vaddr)
709{
710 unsigned long end = vaddr + L1_CACHE_BYTES;
938 711
939 /* Note, don't need to flush 'from' page from the cache again - it's 712 __flush_wback_region((void *)vaddr, L1_CACHE_BYTES);
940 done anyway by the generic code */ 713 wmb();
714 sh64_icache_inv_current_user_range(vaddr, end);
941} 715}
942 716
943void clear_user_page(void *to, unsigned long address, struct page *page) 717/*
718 * These *MUST* lie in an area of virtual address space that's otherwise
719 * unused.
720 */
721#define UNIQUE_EADDR_START 0xe0000000UL
722#define UNIQUE_EADDR_END 0xe8000000UL
723
724/*
725 * Given a physical address paddr, and a user virtual address user_eaddr
726 * which will eventually be mapped to it, create a one-off kernel-private
727 * eaddr mapped to the same paddr. This is used for creating special
728 * destination pages for copy_user_page and clear_user_page.
729 */
730static unsigned long sh64_make_unique_eaddr(unsigned long user_eaddr,
731 unsigned long paddr)
944{ 732{
945 /* 'to' is a kernel virtual address (within the superpage 733 static unsigned long current_pointer = UNIQUE_EADDR_START;
946 mapping of the physical RAM). 'address' is the user virtual address 734 unsigned long coloured_pointer;
947 where the 'to' page will be mapped after. This allows a custom
948 mapping to be used to ensure that the new copy is placed in the
949 right cache sets for the user to see it without having to bounce it
950 out via memory.
951 */
952 735
953 if (((address ^ (unsigned long) to) & CACHE_OC_SYN_MASK) == 0) { 736 if (current_pointer == UNIQUE_EADDR_END) {
954 /* No synonym problem on destination */ 737 sh64_dcache_purge_all();
955 sh64_page_clear(to); 738 current_pointer = UNIQUE_EADDR_START;
956 } else {
957 sh64_clear_user_page_coloured(to, address);
958 } 739 }
959}
960 740
961#endif /* !CONFIG_DCACHE_DISABLED */ 741 coloured_pointer = (current_pointer & ~CACHE_OC_SYN_MASK) |
742 (user_eaddr & CACHE_OC_SYN_MASK);
743 sh64_setup_dtlb_cache_slot(coloured_pointer, get_asid(), paddr);
962 744
963/****************************************************************************/ 745 current_pointer += (PAGE_SIZE << CACHE_OC_N_SYNBITS);
964 746
965void flush_dcache_page(struct page *page) 747 return coloured_pointer;
966{
967 sh64_dcache_purge_phy_page(page_to_phys(page));
968 wmb();
969} 748}
970 749
971/****************************************************************************/ 750static void sh64_copy_user_page_coloured(void *to, void *from,
972 751 unsigned long address)
973void flush_icache_range(unsigned long start, unsigned long end)
974{ 752{
975 /* Flush the range [start,end] of kernel virtual adddress space from 753 void *coloured_to;
976 the I-cache. The corresponding range must be purged from the
977 D-cache also because the SH-5 doesn't have cache snooping between
978 the caches. The addresses will be visible through the superpage
979 mapping, therefore it's guaranteed that there no cache entries for
980 the range in cache sets of the wrong colour.
981 754
982 Primarily used for cohering the I-cache after a module has 755 /*
983 been loaded. */ 756 * Discard any existing cache entries of the wrong colour. These are
757 * present quite often, if the kernel has recently used the page
758 * internally, then given it up, then it's been allocated to the user.
759 */
760 sh64_dcache_purge_coloured_phy_page(__pa(to), (unsigned long)to);
984 761
985 /* We also make sure to purge the same range from the D-cache since 762 coloured_to = (void *)sh64_make_unique_eaddr(address, __pa(to));
986 flush_page_to_ram() won't be doing this for us! */ 763 copy_page(from, coloured_to);
987 764
988 sh64_dcache_purge_kernel_range(start, end); 765 sh64_teardown_dtlb_cache_slot();
989 wmb();
990 sh64_icache_inv_kernel_range(start, end);
991} 766}
992 767
993/****************************************************************************/ 768static void sh64_clear_user_page_coloured(void *to, unsigned long address)
994
995void flush_icache_user_range(struct vm_area_struct *vma,
996 struct page *page, unsigned long addr, int len)
997{ 769{
998 /* Flush the range of user (defined by vma->vm_mm) address space 770 void *coloured_to;
999 starting at 'addr' for 'len' bytes from the cache. The range does
1000 not straddle a page boundary, the unique physical page containing
1001 the range is 'page'. This seems to be used mainly for invalidating
1002 an address range following a poke into the program text through the
1003 ptrace() call from another process (e.g. for BRK instruction
1004 insertion). */
1005 771
1006 sh64_dcache_purge_coloured_phy_page(page_to_phys(page), addr); 772 /*
1007 mb(); 773 * Discard any existing kernel-originated lines of the wrong
774 * colour (as above)
775 */
776 sh64_dcache_purge_coloured_phy_page(__pa(to), (unsigned long)to);
1008 777
1009 if (vma->vm_flags & VM_EXEC) { 778 coloured_to = (void *)sh64_make_unique_eaddr(address, __pa(to));
1010 sh64_icache_inv_user_small_range(vma->vm_mm, addr, len); 779 clear_page(coloured_to);
1011 }
1012}
1013 780
1014/*########################################################################## 781 sh64_teardown_dtlb_cache_slot();
1015 ARCH/SH64 PRIVATE CALLABLE API. 782}
1016 ##########################################################################*/
1017 783
1018void flush_cache_sigtramp(unsigned long start, unsigned long end) 784/*
785 * 'from' and 'to' are kernel virtual addresses (within the superpage
786 * mapping of the physical RAM). 'address' is the user virtual address
787 * where the copy 'to' will be mapped after. This allows a custom
788 * mapping to be used to ensure that the new copy is placed in the
789 * right cache sets for the user to see it without having to bounce it
790 * out via memory. Note however : the call to flush_page_to_ram in
791 * (generic)/mm/memory.c:(break_cow) undoes all this good work in that one
792 * very important case!
793 *
794 * TBD : can we guarantee that on every call, any cache entries for
795 * 'from' are in the same colour sets as 'address' also? i.e. is this
796 * always used just to deal with COW? (I suspect not).
797 *
798 * There are two possibilities here for when the page 'from' was last accessed:
799 * - by the kernel : this is OK, no purge required.
800 * - by the/a user (e.g. for break_COW) : need to purge.
801 *
802 * If the potential user mapping at 'address' is the same colour as
803 * 'from' there is no need to purge any cache lines from the 'from'
804 * page mapped into cache sets of colour 'address'. (The copy will be
805 * accessing the page through 'from').
806 */
807void copy_user_page(void *to, void *from, unsigned long address,
808 struct page *page)
1019{ 809{
1020 /* For the address range [start,end), write back the data from the 810 if (((address ^ (unsigned long) from) & CACHE_OC_SYN_MASK) != 0)
1021 D-cache and invalidate the corresponding region of the I-cache for 811 sh64_dcache_purge_coloured_phy_page(__pa(from), address);
1022 the current process. Used to flush signal trampolines on the stack
1023 to make them executable. */
1024 812
1025 sh64_dcache_wback_current_user_range(start, end); 813 if (((address ^ (unsigned long) to) & CACHE_OC_SYN_MASK) == 0)
1026 wmb(); 814 copy_page(to, from);
1027 sh64_icache_inv_current_user_range(start, end); 815 else
816 sh64_copy_user_page_coloured(to, from, address);
1028} 817}
1029 818
819/*
820 * 'to' is a kernel virtual address (within the superpage mapping of the
821 * physical RAM). 'address' is the user virtual address where the 'to'
822 * page will be mapped after. This allows a custom mapping to be used to
823 * ensure that the new copy is placed in the right cache sets for the
824 * user to see it without having to bounce it out via memory.
825 */
826void clear_user_page(void *to, unsigned long address, struct page *page)
827{
828 if (((address ^ (unsigned long) to) & CACHE_OC_SYN_MASK) == 0)
829 clear_page(to);
830 else
831 sh64_clear_user_page_coloured(to, address);
832}
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index 7b2131c9eeda..d3c33fc5b1c2 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -26,7 +26,7 @@ struct dma_coherent_mem {
26void *dma_alloc_coherent(struct device *dev, size_t size, 26void *dma_alloc_coherent(struct device *dev, size_t size,
27 dma_addr_t *dma_handle, gfp_t gfp) 27 dma_addr_t *dma_handle, gfp_t gfp)
28{ 28{
29 void *ret; 29 void *ret, *ret_nocache;
30 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL; 30 struct dma_coherent_mem *mem = dev ? dev->dma_mem : NULL;
31 int order = get_order(size); 31 int order = get_order(size);
32 32
@@ -44,17 +44,24 @@ void *dma_alloc_coherent(struct device *dev, size_t size,
44 } 44 }
45 45
46 ret = (void *)__get_free_pages(gfp, order); 46 ret = (void *)__get_free_pages(gfp, order);
47 47 if (!ret)
48 if (ret != NULL) { 48 return NULL;
49 memset(ret, 0, size); 49
50 /* 50 memset(ret, 0, size);
51 * Pages from the page allocator may have data present in 51 /*
52 * cache. So flush the cache before using uncached memory. 52 * Pages from the page allocator may have data present in
53 */ 53 * cache. So flush the cache before using uncached memory.
54 dma_cache_sync(NULL, ret, size, DMA_BIDIRECTIONAL); 54 */
55 *dma_handle = virt_to_phys(ret); 55 dma_cache_sync(dev, ret, size, DMA_BIDIRECTIONAL);
56
57 ret_nocache = ioremap_nocache(virt_to_phys(ret), size);
58 if (!ret_nocache) {
59 free_pages((unsigned long)ret, order);
60 return NULL;
56 } 61 }
57 return ret; 62
63 *dma_handle = virt_to_phys(ret);
64 return ret_nocache;
58} 65}
59EXPORT_SYMBOL(dma_alloc_coherent); 66EXPORT_SYMBOL(dma_alloc_coherent);
60 67
@@ -71,7 +78,8 @@ void dma_free_coherent(struct device *dev, size_t size,
71 } else { 78 } else {
72 WARN_ON(irqs_disabled()); /* for portability */ 79 WARN_ON(irqs_disabled()); /* for portability */
73 BUG_ON(mem && mem->flags & DMA_MEMORY_EXCLUSIVE); 80 BUG_ON(mem && mem->flags & DMA_MEMORY_EXCLUSIVE);
74 free_pages((unsigned long)vaddr, order); 81 free_pages((unsigned long)phys_to_virt(dma_handle), order);
82 iounmap(vaddr);
75 } 83 }
76} 84}
77EXPORT_SYMBOL(dma_free_coherent); 85EXPORT_SYMBOL(dma_free_coherent);
diff --git a/arch/sh/mm/fault_32.c b/arch/sh/mm/fault_32.c
index 33b43d20e9f6..d1fa27594c6e 100644
--- a/arch/sh/mm/fault_32.c
+++ b/arch/sh/mm/fault_32.c
@@ -15,6 +15,7 @@
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/hardirq.h> 16#include <linux/hardirq.h>
17#include <linux/kprobes.h> 17#include <linux/kprobes.h>
18#include <asm/io_trapped.h>
18#include <asm/system.h> 19#include <asm/system.h>
19#include <asm/mmu_context.h> 20#include <asm/mmu_context.h>
20#include <asm/tlbflush.h> 21#include <asm/tlbflush.h>
@@ -163,6 +164,8 @@ no_context:
163 if (fixup_exception(regs)) 164 if (fixup_exception(regs))
164 return; 165 return;
165 166
167 if (handle_trapped_io(regs, address))
168 return;
166/* 169/*
167 * Oops. The kernel tried to access some bad page. We'll have to 170 * Oops. The kernel tried to access some bad page. We'll have to
168 * terminate things with extreme prejudice. 171 * terminate things with extreme prejudice.
@@ -296,6 +299,14 @@ asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
296 entry = pte_mkdirty(entry); 299 entry = pte_mkdirty(entry);
297 entry = pte_mkyoung(entry); 300 entry = pte_mkyoung(entry);
298 301
302#if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SMP)
303 /*
304 * ITLB is not affected by "ldtlb" instruction.
305 * So, we need to flush the entry by ourselves.
306 */
307 local_flush_tlb_one(get_asid(), address & PAGE_MASK);
308#endif
309
299 set_pte(pte, entry); 310 set_pte(pte, entry);
300 update_mmu_cache(NULL, address, entry); 311 update_mmu_cache(NULL, address, entry);
301 312
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 2918c6b14659..e2ed6dd252b9 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -203,6 +203,7 @@ void __init paging_init(void)
203 203
204 free_area_init_nodes(max_zone_pfns); 204 free_area_init_nodes(max_zone_pfns);
205 205
206#ifdef CONFIG_SUPERH32
206 /* Set up the uncached fixmap */ 207 /* Set up the uncached fixmap */
207 set_fixmap_nocache(FIX_UNCACHED, __pa(&__uncached_start)); 208 set_fixmap_nocache(FIX_UNCACHED, __pa(&__uncached_start));
208 209
@@ -214,6 +215,7 @@ void __init paging_init(void)
214 */ 215 */
215 cached_to_uncached = P2SEG - P1SEG; 216 cached_to_uncached = P2SEG - P1SEG;
216#endif 217#endif
218#endif
217} 219}
218 220
219static struct kcore_list kcore_mem, kcore_vmalloc; 221static struct kcore_list kcore_mem, kcore_vmalloc;
diff --git a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
index 25810670a0fa..67997af25c0c 100644
--- a/arch/sh/tools/mach-types
+++ b/arch/sh/tools/mach-types
@@ -45,3 +45,5 @@ MAGICPANELR2 SH_MAGIC_PANEL_R2
45R2D_PLUS RTS7751R2D_PLUS 45R2D_PLUS RTS7751R2D_PLUS
46R2D_1 RTS7751R2D_1 46R2D_1 RTS7751R2D_1
47CAYMAN SH_CAYMAN 47CAYMAN SH_CAYMAN
48SDK7780 SH_SDK7780
49MIGOR SH_MIGOR
diff --git a/arch/sparc64/solaris/fs.c b/arch/sparc64/solaris/fs.c
index 9311bfe4f2f7..7d035f0d3ae1 100644
--- a/arch/sparc64/solaris/fs.c
+++ b/arch/sparc64/solaris/fs.c
@@ -434,9 +434,9 @@ asmlinkage int solaris_statvfs(u32 path, u32 buf)
434 434
435 error = user_path_walk(A(path),&nd); 435 error = user_path_walk(A(path),&nd);
436 if (!error) { 436 if (!error) {
437 struct inode * inode = nd.dentry->d_inode; 437 struct inode *inode = nd.path.dentry->d_inode;
438 error = report_statvfs(nd.mnt, inode, buf); 438 error = report_statvfs(nd.path.mnt, inode, buf);
439 path_release(&nd); 439 path_put(&nd.path);
440 } 440 }
441 return error; 441 return error;
442} 442}
@@ -464,9 +464,9 @@ asmlinkage int solaris_statvfs64(u32 path, u32 buf)
464 lock_kernel(); 464 lock_kernel();
465 error = user_path_walk(A(path), &nd); 465 error = user_path_walk(A(path), &nd);
466 if (!error) { 466 if (!error) {
467 struct inode * inode = nd.dentry->d_inode; 467 struct inode *inode = nd.path.dentry->d_inode;
468 error = report_statvfs64(nd.mnt, inode, buf); 468 error = report_statvfs64(nd.path.mnt, inode, buf);
469 path_release(&nd); 469 path_put(&nd.path);
470 } 470 }
471 unlock_kernel(); 471 unlock_kernel();
472 return error; 472 return error;
diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
index ebb265c07e4d..19d579d74d27 100644
--- a/arch/um/drivers/mconsole_kern.c
+++ b/arch/um/drivers/mconsole_kern.c
@@ -145,8 +145,8 @@ void mconsole_proc(struct mc_request *req)
145 } 145 }
146 up_write(&super->s_umount); 146 up_write(&super->s_umount);
147 147
148 nd.dentry = super->s_root; 148 nd.path.dentry = super->s_root;
149 nd.mnt = NULL; 149 nd.path.mnt = NULL;
150 nd.flags = O_RDONLY + 1; 150 nd.flags = O_RDONLY + 1;
151 nd.last_type = LAST_ROOT; 151 nd.last_type = LAST_ROOT;
152 152
@@ -159,7 +159,7 @@ void mconsole_proc(struct mc_request *req)
159 goto out_kill; 159 goto out_kill;
160 } 160 }
161 161
162 file = dentry_open(nd.dentry, nd.mnt, O_RDONLY); 162 file = dentry_open(nd.path.dentry, nd.path.mnt, O_RDONLY);
163 if (IS_ERR(file)) { 163 if (IS_ERR(file)) {
164 mconsole_reply(req, "Failed to open file", 1, 0); 164 mconsole_reply(req, "Failed to open file", 1, 0);
165 goto out_kill; 165 goto out_kill;
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index aaed1a3b92d6..3be2305709b7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -21,6 +21,8 @@ config X86
21 select HAVE_IDE 21 select HAVE_IDE
22 select HAVE_OPROFILE 22 select HAVE_OPROFILE
23 select HAVE_KPROBES 23 select HAVE_KPROBES
24 select HAVE_KVM
25
24 26
25config GENERIC_LOCKBREAK 27config GENERIC_LOCKBREAK
26 def_bool n 28 def_bool n
@@ -119,8 +121,6 @@ config ARCH_HAS_CPU_RELAX
119config HAVE_SETUP_PER_CPU_AREA 121config HAVE_SETUP_PER_CPU_AREA
120 def_bool X86_64 122 def_bool X86_64
121 123
122select HAVE_KVM
123
124config ARCH_HIBERNATION_POSSIBLE 124config ARCH_HIBERNATION_POSSIBLE
125 def_bool y 125 def_bool y
126 depends on !SMP || !X86_VOYAGER 126 depends on !SMP || !X86_VOYAGER
diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
index 10b67170b133..8ca3557a6d59 100644
--- a/arch/x86/kernel/acpi/cstate.c
+++ b/arch/x86/kernel/acpi/cstate.c
@@ -126,6 +126,8 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
126 printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d " 126 printk(KERN_DEBUG "Monitor-Mwait will be used to enter C-%d "
127 "state\n", cx->type); 127 "state\n", cx->type);
128 } 128 }
129 snprintf(cx->desc, ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
130 cx->address);
129 131
130out: 132out:
131 set_cpus_allowed(current, saved_mask); 133 set_cpus_allowed(current, saved_mask);
diff --git a/arch/x86/kernel/efi.c b/arch/x86/kernel/efi.c
index cbdf9bacc575..0c0eeb163d90 100644
--- a/arch/x86/kernel/efi.c
+++ b/arch/x86/kernel/efi.c
@@ -391,7 +391,7 @@ static void __init runtime_code_page_mkexec(void)
391 if (md->type != EFI_RUNTIME_SERVICES_CODE) 391 if (md->type != EFI_RUNTIME_SERVICES_CODE)
392 continue; 392 continue;
393 393
394 set_memory_x(md->virt_addr, md->num_pages << EFI_PAGE_SHIFT); 394 set_memory_x(md->virt_addr, md->num_pages);
395 } 395 }
396} 396}
397 397
@@ -434,7 +434,7 @@ void __init efi_enter_virtual_mode(void)
434 } 434 }
435 435
436 if (!(md->attribute & EFI_MEMORY_WB)) 436 if (!(md->attribute & EFI_MEMORY_WB))
437 set_memory_uc(md->virt_addr, size); 437 set_memory_uc(md->virt_addr, md->num_pages);
438 438
439 systab = (u64) (unsigned long) efi_phys.systab; 439 systab = (u64) (unsigned long) efi_phys.systab;
440 if (md->phys_addr <= systab && systab < end) { 440 if (md->phys_addr <= systab && systab < end) {
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index 65f6acb025c8..faf3229f8fb3 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -749,6 +749,15 @@ void __init gart_iommu_init(void)
749 */ 749 */
750 set_memory_np((unsigned long)__va(iommu_bus_base), 750 set_memory_np((unsigned long)__va(iommu_bus_base),
751 iommu_size >> PAGE_SHIFT); 751 iommu_size >> PAGE_SHIFT);
752 /*
753 * Tricky. The GART table remaps the physical memory range,
754 * so the CPU wont notice potential aliases and if the memory
755 * is remapped to UC later on, we might surprise the PCI devices
756 * with a stray writeout of a cacheline. So play it sure and
757 * do an explicit, full-scale wbinvd() _after_ having marked all
758 * the pages as Not-Present:
759 */
760 wbinvd();
752 761
753 /* 762 /*
754 * Try to workaround a bug (thanks to BenH) 763 * Try to workaround a bug (thanks to BenH)
diff --git a/arch/x86/kernel/test_rodata.c b/arch/x86/kernel/test_rodata.c
index 4c163772000e..c29e235792af 100644
--- a/arch/x86/kernel/test_rodata.c
+++ b/arch/x86/kernel/test_rodata.c
@@ -10,8 +10,8 @@
10 * of the License. 10 * of the License.
11 */ 11 */
12#include <linux/module.h> 12#include <linux/module.h>
13#include <asm/cacheflush.h>
13#include <asm/sections.h> 14#include <asm/sections.h>
14extern int rodata_test_data;
15 15
16int rodata_test(void) 16int rodata_test(void)
17{ 17{
diff --git a/arch/x86/kernel/traps_64.c b/arch/x86/kernel/traps_64.c
index efc66df728b6..045466681911 100644
--- a/arch/x86/kernel/traps_64.c
+++ b/arch/x86/kernel/traps_64.c
@@ -84,7 +84,7 @@ static inline void conditional_sti(struct pt_regs *regs)
84 84
85static inline void preempt_conditional_sti(struct pt_regs *regs) 85static inline void preempt_conditional_sti(struct pt_regs *regs)
86{ 86{
87 preempt_disable(); 87 inc_preempt_count();
88 if (regs->flags & X86_EFLAGS_IF) 88 if (regs->flags & X86_EFLAGS_IF)
89 local_irq_enable(); 89 local_irq_enable();
90} 90}
@@ -95,7 +95,7 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
95 local_irq_disable(); 95 local_irq_disable();
96 /* Make sure to not schedule here because we could be running 96 /* Make sure to not schedule here because we could be running
97 on an exception stack. */ 97 on an exception stack. */
98 preempt_enable_no_resched(); 98 dec_preempt_count();
99} 99}
100 100
101int kstack_depth_to_print = 12; 101int kstack_depth_to_print = 12;
diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 621afb6343dc..fdc667422df9 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -186,7 +186,7 @@ static int bad_address(void *p)
186} 186}
187#endif 187#endif
188 188
189void dump_pagetable(unsigned long address) 189static void dump_pagetable(unsigned long address)
190{ 190{
191#ifdef CONFIG_X86_32 191#ifdef CONFIG_X86_32
192 __typeof__(pte_val(__pte(0))) page; 192 __typeof__(pte_val(__pte(0))) page;
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 8106bba41ecb..ee1091a46964 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -47,6 +47,7 @@
47#include <asm/sections.h> 47#include <asm/sections.h>
48#include <asm/paravirt.h> 48#include <asm/paravirt.h>
49#include <asm/setup.h> 49#include <asm/setup.h>
50#include <asm/cacheflush.h>
50 51
51unsigned int __VMALLOC_RESERVE = 128 << 20; 52unsigned int __VMALLOC_RESERVE = 128 << 20;
52 53
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index b59fc238151f..a4a9cccdd4f2 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -45,6 +45,7 @@
45#include <asm/sections.h> 45#include <asm/sections.h>
46#include <asm/kdebug.h> 46#include <asm/kdebug.h>
47#include <asm/numa.h> 47#include <asm/numa.h>
48#include <asm/cacheflush.h>
48 49
49const struct dma_mapping_ops *dma_ops; 50const struct dma_mapping_ops *dma_ops;
50EXPORT_SYMBOL(dma_ops); 51EXPORT_SYMBOL(dma_ops);
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index bd61ed13f9cf..4119379f80ff 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -688,6 +688,15 @@ static int change_page_attr_set_clr(unsigned long addr, int numpages,
688 if (!pgprot_val(mask_set) && !pgprot_val(mask_clr)) 688 if (!pgprot_val(mask_set) && !pgprot_val(mask_clr))
689 return 0; 689 return 0;
690 690
691 /* Ensure we are PAGE_SIZE aligned */
692 if (addr & ~PAGE_MASK) {
693 addr &= PAGE_MASK;
694 /*
695 * People should not be passing in unaligned addresses:
696 */
697 WARN_ON_ONCE(1);
698 }
699
691 cpa.vaddr = addr; 700 cpa.vaddr = addr;
692 cpa.numpages = numpages; 701 cpa.numpages = numpages;
693 cpa.mask_set = mask_set; 702 cpa.mask_set = mask_set;
@@ -861,8 +870,12 @@ void kernel_map_pages(struct page *page, int numpages, int enable)
861 return; 870 return;
862 871
863 /* 872 /*
864 * The return value is ignored - the calls cannot fail, 873 * The return value is ignored as the calls cannot fail.
865 * large pages are disabled at boot time: 874 * Large pages are kept enabled at boot time, and are
875 * split up quickly with DEBUG_PAGEALLOC. If a splitup
876 * fails here (due to temporary memory shortage) no damage
877 * is done because we just keep the largepage intact up
878 * to the next attempt when it will likely be split up:
866 */ 879 */
867 if (enable) 880 if (enable)
868 __set_pages_p(page, numpages); 881 __set_pages_p(page, numpages);
diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
index 9ce983ed60f0..ea92bac42c53 100644
--- a/drivers/acpi/blacklist.c
+++ b/drivers/acpi/blacklist.c
@@ -186,6 +186,12 @@ static int __init dmi_unknown_osi_linux(const struct dmi_system_id *d)
186 acpi_dmi_osi_linux(-1, d); /* unknown */ 186 acpi_dmi_osi_linux(-1, d); /* unknown */
187 return 0; 187 return 0;
188} 188}
189static int __init dmi_disable_osi_vista(const struct dmi_system_id *d)
190{
191 printk(KERN_NOTICE PREFIX "DMI detected: %s\n", d->ident);
192 acpi_osi_setup("!Windows 2006");
193 return 0;
194}
189 195
190/* 196/*
191 * Most BIOS that invoke OSI(Linux) do nothing with it. 197 * Most BIOS that invoke OSI(Linux) do nothing with it.
@@ -228,10 +234,10 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
228 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"), 234 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 5520"),
229 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 6460"), 235 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 6460"),
230 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 7510"), 236 * DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 7510"),
231 * DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5220"),
232 * 237 *
233 * _OSI(Linux) is a NOP: 238 * _OSI(Linux) is a NOP:
234 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"), 239 * DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5315"),
240 * DMI_MATCH(DMI_PRODUCT_NAME, "Extensa 5220"),
235 */ 241 */
236 { 242 {
237 .callback = dmi_disable_osi_linux, 243 .callback = dmi_disable_osi_linux,
@@ -327,12 +333,20 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
327 }, 333 },
328 { /* OSI(Linux) effect unknown */ 334 { /* OSI(Linux) effect unknown */
329 .callback = dmi_unknown_osi_linux, 335 .callback = dmi_unknown_osi_linux,
330 .ident = "Dell OP GX620", 336 .ident = "Dell OptiPlex GX620",
331 .matches = { 337 .matches = {
332 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), 338 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
333 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX620"), 339 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex GX620"),
334 }, 340 },
335 }, 341 },
342 { /* OSI(Linux) causes some USB initialization to not run */
343 .callback = dmi_unknown_osi_linux,
344 .ident = "Dell OptiPlex 755",
345 .matches = {
346 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
347 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 755"),
348 },
349 },
336 { /* OSI(Linux) effect unknown */ 350 { /* OSI(Linux) effect unknown */
337 .callback = dmi_unknown_osi_linux, 351 .callback = dmi_unknown_osi_linux,
338 .ident = "Dell PE 1900", 352 .ident = "Dell PE 1900",
@@ -342,6 +356,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
342 }, 356 },
343 }, 357 },
344 { /* OSI(Linux) is a NOP */ 358 { /* OSI(Linux) is a NOP */
359 .callback = dmi_unknown_osi_linux,
360 .ident = "Dell PE 1950",
361 .matches = {
362 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
363 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 1950"),
364 },
365 },
366 { /* OSI(Linux) is a NOP */
345 .callback = dmi_disable_osi_linux, 367 .callback = dmi_disable_osi_linux,
346 .ident = "Dell PE R200", 368 .ident = "Dell PE R200",
347 .matches = { 369 .matches = {
@@ -357,6 +379,22 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
357 DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 390"), 379 DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 390"),
358 }, 380 },
359 }, 381 },
382 { /* OSI(Linux) touches USB */
383 .callback = dmi_unknown_osi_linux,
384 .ident = "Dell PR 390",
385 .matches = {
386 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
387 DMI_MATCH(DMI_PRODUCT_NAME, "Precision WorkStation 690"),
388 },
389 },
390 { /* OSI(Linux) unknown - ASL looks benign, but may effect dock/SMM */
391 .callback = dmi_unknown_osi_linux,
392 .ident = "Dell PR M4300",
393 .matches = {
394 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
395 DMI_MATCH(DMI_PRODUCT_NAME, "Precision M4300"),
396 },
397 },
360 { /* OSI(Linux) is a NOP */ 398 { /* OSI(Linux) is a NOP */
361 .callback = dmi_disable_osi_linux, 399 .callback = dmi_disable_osi_linux,
362 .ident = "Dell Vostro 1000", 400 .ident = "Dell Vostro 1000",
@@ -390,10 +428,10 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
390 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1536"), 428 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1536"),
391 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1556"), 429 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pi 1556"),
392 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 1546"), 430 * DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Xi 1546"),
431 * DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
393 * _OSI(Linux) unknown effect: 432 * _OSI(Linux) unknown effect:
394 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo M1425"), 433 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo M1425"),
395 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo Si 1520"), 434 * DMI_MATCH(DMI_PRODUCT_NAME, "Amilo Si 1520"),
396 * DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
397 */ 435 */
398 { 436 {
399 .callback = dmi_disable_osi_linux, 437 .callback = dmi_disable_osi_linux,
@@ -402,6 +440,14 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
402 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), 440 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
403 }, 441 },
404 }, 442 },
443 {
444 .callback = dmi_disable_osi_vista,
445 .ident = "Fujitsu Siemens",
446 .matches = {
447 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
448 DMI_MATCH(DMI_PRODUCT_NAME, "ESPRIMO Mobile V5505"),
449 },
450 },
405 /* 451 /*
406 * Disable OSI(Linux) warnings on all "Hewlett-Packard" 452 * Disable OSI(Linux) warnings on all "Hewlett-Packard"
407 * 453 *
@@ -443,10 +489,11 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
443 * _OSI(Linux) helps sound 489 * _OSI(Linux) helps sound
444 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad R61"), 490 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad R61"),
445 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T61"), 491 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T61"),
492 * _OSI(Linux) has Linux specific hooks
493 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"),
446 * _OSI(Linux) is a NOP: 494 * _OSI(Linux) is a NOP:
447 * DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"), 495 * DMI_MATCH(DMI_PRODUCT_VERSION, "3000 N100"),
448 * _OSI(Linux) effect unknown 496 * DMI_MATCH(DMI_PRODUCT_VERSION, "LENOVO3000 V100"),
449 * DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X61"),
450 */ 497 */
451 { 498 {
452 .callback = dmi_enable_osi_linux, 499 .callback = dmi_enable_osi_linux,
@@ -465,7 +512,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
465 }, 512 },
466 }, 513 },
467 { 514 {
468 .callback = dmi_unknown_osi_linux, 515 .callback = dmi_enable_osi_linux,
469 .ident = "Lenovo ThinkPad X61", 516 .ident = "Lenovo ThinkPad X61",
470 .matches = { 517 .matches = {
471 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 518 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
@@ -473,7 +520,7 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
473 }, 520 },
474 }, 521 },
475 { 522 {
476 .callback = dmi_unknown_osi_linux, 523 .callback = dmi_disable_osi_linux,
477 .ident = "Lenovo 3000 V100", 524 .ident = "Lenovo 3000 V100",
478 .matches = { 525 .matches = {
479 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 526 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
@@ -543,8 +590,9 @@ static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
543 * Disable OSI(Linux) warnings on all "Sony Corporation" 590 * Disable OSI(Linux) warnings on all "Sony Corporation"
544 * 591 *
545 * _OSI(Linux) is a NOP: 592 * _OSI(Linux) is a NOP:
546 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ650N"), 593 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NR11S_S"),
547 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ38GP_C"), 594 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ38GP_C"),
595 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SZ650N"),
548 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-TZ21MN_N"), 596 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-TZ21MN_N"),
549 * _OSI(Linux) unknown effect: 597 * _OSI(Linux) unknown effect:
550 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ11M"), 598 * DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ11M"),
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 5479dc0eeeec..abec1ca94cf4 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -110,7 +110,7 @@ static const struct file_operations acpi_system_event_ops = {
110#endif /* CONFIG_ACPI_PROC_EVENT */ 110#endif /* CONFIG_ACPI_PROC_EVENT */
111 111
112/* ACPI notifier chain */ 112/* ACPI notifier chain */
113BLOCKING_NOTIFIER_HEAD(acpi_chain_head); 113static BLOCKING_NOTIFIER_HEAD(acpi_chain_head);
114 114
115int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data) 115int acpi_notifier_call_chain(struct acpi_device *dev, u32 type, u32 data)
116{ 116{
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index 058d0be5cbe2..4290e0193097 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -616,6 +616,7 @@ acpi_status acpi_leave_sleep_state(u8 sleep_state)
616 return_ACPI_STATUS(status); 616 return_ACPI_STATUS(status);
617 } 617 }
618 618
619 arg.integer.value = sleep_state;
619 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL); 620 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
620 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 621 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
621 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK")); 622 ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK"));
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 15e602377655..8edba7b678eb 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -325,7 +325,7 @@ acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
325} 325}
326 326
327#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD 327#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
328struct acpi_table_header *acpi_find_dsdt_initrd(void) 328static struct acpi_table_header *acpi_find_dsdt_initrd(void)
329{ 329{
330 struct file *firmware_file; 330 struct file *firmware_file;
331 mm_segment_t oldfs; 331 mm_segment_t oldfs;
@@ -419,7 +419,7 @@ acpi_os_table_override(struct acpi_table_header * existing_table,
419} 419}
420 420
421#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD 421#ifdef CONFIG_ACPI_CUSTOM_DSDT_INITRD
422int __init acpi_no_initrd_override_setup(char *s) 422static int __init acpi_no_initrd_override_setup(char *s)
423{ 423{
424 acpi_no_initrd_override = 1; 424 acpi_no_initrd_override = 1;
425 return 1; 425 return 1;
@@ -1109,7 +1109,7 @@ void __init acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d)
1109 * string starting with '!' disables that string 1109 * string starting with '!' disables that string
1110 * otherwise string is added to list, augmenting built-in strings 1110 * otherwise string is added to list, augmenting built-in strings
1111 */ 1111 */
1112static int __init acpi_osi_setup(char *str) 1112int __init acpi_osi_setup(char *str)
1113{ 1113{
1114 if (str == NULL || *str == '\0') { 1114 if (str == NULL || *str == '\0') {
1115 printk(KERN_INFO PREFIX "_OSI method disabled\n"); 1115 printk(KERN_INFO PREFIX "_OSI method disabled\n");
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 32003fdc91e8..980e1c33e6c5 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -945,11 +945,16 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
945 * Otherwise, ignore this info and continue. 945 * Otherwise, ignore this info and continue.
946 */ 946 */
947 cx.entry_method = ACPI_CSTATE_HALT; 947 cx.entry_method = ACPI_CSTATE_HALT;
948 snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT");
948 } else { 949 } else {
949 continue; 950 continue;
950 } 951 }
952 } else {
953 snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI IOPORT 0x%x",
954 cx.address);
951 } 955 }
952 956
957
953 obj = &(element->package.elements[2]); 958 obj = &(element->package.elements[2]);
954 if (obj->type != ACPI_TYPE_INTEGER) 959 if (obj->type != ACPI_TYPE_INTEGER)
955 continue; 960 continue;
@@ -1420,6 +1425,14 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
1420 return 0; 1425 return 0;
1421 1426
1422 local_irq_disable(); 1427 local_irq_disable();
1428
1429 /* Do not access any ACPI IO ports in suspend path */
1430 if (acpi_idle_suspend) {
1431 acpi_safe_halt();
1432 local_irq_enable();
1433 return 0;
1434 }
1435
1423 if (pr->flags.bm_check) 1436 if (pr->flags.bm_check)
1424 acpi_idle_update_bm_rld(pr, cx); 1437 acpi_idle_update_bm_rld(pr, cx);
1425 1438
@@ -1643,6 +1656,11 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
1643 return -EINVAL; 1656 return -EINVAL;
1644 } 1657 }
1645 1658
1659 for (i = 0; i < CPUIDLE_STATE_MAX; i++) {
1660 dev->states[i].name[0] = '\0';
1661 dev->states[i].desc[0] = '\0';
1662 }
1663
1646 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) { 1664 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
1647 cx = &pr->power.states[i]; 1665 cx = &pr->power.states[i];
1648 state = &dev->states[count]; 1666 state = &dev->states[count];
@@ -1659,6 +1677,7 @@ static int acpi_processor_setup_cpuidle(struct acpi_processor *pr)
1659 cpuidle_set_statedata(state, cx); 1677 cpuidle_set_statedata(state, cx);
1660 1678
1661 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i); 1679 snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i);
1680 strncpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
1662 state->exit_latency = cx->latency; 1681 state->exit_latency = cx->latency;
1663 state->target_residency = cx->latency * latency_factor; 1682 state->target_residency = cx->latency * latency_factor;
1664 state->power_usage = cx->power; 1683 state->power_usage = cx->power;
diff --git a/drivers/block/swim3.c b/drivers/block/swim3.c
index b4e462f154ea..730ccea78e45 100644
--- a/drivers/block/swim3.c
+++ b/drivers/block/swim3.c
@@ -251,10 +251,6 @@ static int floppy_release(struct inode *inode, struct file *filp);
251static int floppy_check_change(struct gendisk *disk); 251static int floppy_check_change(struct gendisk *disk);
252static int floppy_revalidate(struct gendisk *disk); 252static int floppy_revalidate(struct gendisk *disk);
253 253
254#ifndef CONFIG_PMAC_MEDIABAY
255#define check_media_bay(which, what) 1
256#endif
257
258static void swim3_select(struct floppy_state *fs, int sel) 254static void swim3_select(struct floppy_state *fs, int sel)
259{ 255{
260 struct swim3 __iomem *sw = fs->swim3; 256 struct swim3 __iomem *sw = fs->swim3;
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index e68821d074b0..7e31d5f1bc8a 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -208,6 +208,7 @@ static int hci_uart_close(struct hci_dev *hdev)
208 return 0; 208 return 0;
209 209
210 hci_uart_flush(hdev); 210 hci_uart_flush(hdev);
211 hdev->flush = NULL;
211 return 0; 212 return 0;
212} 213}
213 214
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c
index bb09413d5a21..88590d040046 100644
--- a/drivers/char/hvc_rtas.c
+++ b/drivers/char/hvc_rtas.c
@@ -76,7 +76,7 @@ static struct hv_ops hvc_rtas_get_put_ops = {
76 .put_chars = hvc_rtas_write_console, 76 .put_chars = hvc_rtas_write_console,
77}; 77};
78 78
79static int hvc_rtas_init(void) 79static int __init hvc_rtas_init(void)
80{ 80{
81 struct hvc_struct *hp; 81 struct hvc_struct *hp;
82 82
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 60f71e6345e3..d73663a52324 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -219,7 +219,8 @@ static void poll_idle_init(struct cpuidle_device *dev)
219 219
220 cpuidle_set_statedata(state, NULL); 220 cpuidle_set_statedata(state, NULL);
221 221
222 snprintf(state->name, CPUIDLE_NAME_LEN, "C0 (poll idle)"); 222 snprintf(state->name, CPUIDLE_NAME_LEN, "C0");
223 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
223 state->exit_latency = 0; 224 state->exit_latency = 0;
224 state->target_residency = 0; 225 state->target_residency = 0;
225 state->power_usage = -1; 226 state->power_usage = -1;
diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
index 088ea74edd34..69102ca05685 100644
--- a/drivers/cpuidle/sysfs.c
+++ b/drivers/cpuidle/sysfs.c
@@ -218,16 +218,23 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
218 return sprintf(buf, "%u\n", state->_name);\ 218 return sprintf(buf, "%u\n", state->_name);\
219} 219}
220 220
221static ssize_t show_state_name(struct cpuidle_state *state, char *buf) 221#define define_show_state_str_function(_name) \
222{ 222static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \
223 return sprintf(buf, "%s\n", state->name); 223{ \
224 if (state->_name[0] == '\0')\
225 return sprintf(buf, "<null>\n");\
226 return sprintf(buf, "%s\n", state->_name);\
224} 227}
225 228
226define_show_state_function(exit_latency) 229define_show_state_function(exit_latency)
227define_show_state_function(power_usage) 230define_show_state_function(power_usage)
228define_show_state_function(usage) 231define_show_state_function(usage)
229define_show_state_function(time) 232define_show_state_function(time)
233define_show_state_str_function(name)
234define_show_state_str_function(desc)
235
230define_one_state_ro(name, show_state_name); 236define_one_state_ro(name, show_state_name);
237define_one_state_ro(desc, show_state_desc);
231define_one_state_ro(latency, show_state_exit_latency); 238define_one_state_ro(latency, show_state_exit_latency);
232define_one_state_ro(power, show_state_power_usage); 239define_one_state_ro(power, show_state_power_usage);
233define_one_state_ro(usage, show_state_usage); 240define_one_state_ro(usage, show_state_usage);
@@ -235,6 +242,7 @@ define_one_state_ro(time, show_state_time);
235 242
236static struct attribute *cpuidle_state_default_attrs[] = { 243static struct attribute *cpuidle_state_default_attrs[] = {
237 &attr_name.attr, 244 &attr_name.attr,
245 &attr_desc.attr,
238 &attr_latency.attr, 246 &attr_latency.attr,
239 &attr_power.attr, 247 &attr_power.attr,
240 &attr_usage.attr, 248 &attr_usage.attr,
diff --git a/drivers/hid/hid-input-quirks.c b/drivers/hid/hid-input-quirks.c
index a870ba58faa3..dceadd0c1419 100644
--- a/drivers/hid/hid-input-quirks.c
+++ b/drivers/hid/hid-input-quirks.c
@@ -352,7 +352,7 @@ int hidinput_mapping_quirks(struct hid_usage *usage,
352 return 0; 352 return 0;
353} 353}
354 354
355void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value) 355int hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, struct hid_usage *usage, __s32 value)
356{ 356{
357 struct input_dev *input; 357 struct input_dev *input;
358 358
@@ -362,34 +362,34 @@ void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, stru
362 || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) { 362 || ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007))) {
363 if (value) hid->quirks |= HID_QUIRK_2WHEEL_MOUSE_HACK_ON; 363 if (value) hid->quirks |= HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
364 else hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON; 364 else hid->quirks &= ~HID_QUIRK_2WHEEL_MOUSE_HACK_ON;
365 return; 365 return 1;
366 } 366 }
367 367
368 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) && 368 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
369 (usage->type == EV_REL) && 369 (usage->type == EV_REL) &&
370 (usage->code == REL_WHEEL)) { 370 (usage->code == REL_WHEEL)) {
371 hid->delayed_value = value; 371 hid->delayed_value = value;
372 return; 372 return 1;
373 } 373 }
374 374
375 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) && 375 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
376 (usage->hid == 0x000100b8)) { 376 (usage->hid == 0x000100b8)) {
377 input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value); 377 input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value);
378 return; 378 return 1;
379 } 379 }
380 380
381 if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) { 381 if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) {
382 input_event(input, usage->type, usage->code, -value); 382 input_event(input, usage->type, usage->code, -value);
383 return; 383 return 1;
384 } 384 }
385 385
386 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) { 386 if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_ON) && (usage->code == REL_WHEEL)) {
387 input_event(input, usage->type, REL_HWHEEL, value); 387 input_event(input, usage->type, REL_HWHEEL, value);
388 return; 388 return 1;
389 } 389 }
390 390
391 if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value)) 391 if ((hid->quirks & HID_QUIRK_APPLE_HAS_FN) && hidinput_apple_event(hid, input, usage, value))
392 return; 392 return 1;
393 393
394 /* Handling MS keyboards special buttons */ 394 /* Handling MS keyboards special buttons */
395 if (hid->quirks & HID_QUIRK_MICROSOFT_KEYS && 395 if (hid->quirks & HID_QUIRK_MICROSOFT_KEYS &&
@@ -416,8 +416,9 @@ void hidinput_event_quirks(struct hid_device *hid, struct hid_field *field, stru
416 if (hid->quirks & HID_QUIRK_HWHEEL_WHEEL_INVERT && 416 if (hid->quirks & HID_QUIRK_HWHEEL_WHEEL_INVERT &&
417 usage->type == EV_REL && usage->code == REL_HWHEEL) { 417 usage->type == EV_REL && usage->code == REL_HWHEEL) {
418 input_event(input, usage->type, REL_WHEEL, -value); 418 input_event(input, usage->type, REL_WHEEL, -value);
419 return; 419 return 1;
420 } 420 }
421 return 0;
421} 422}
422 423
423 424
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index 5325d98b4328..5a38fb27d69f 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -97,6 +97,7 @@ struct hidinput_key_translation {
97#define APPLE_FLAG_FKEY 0x01 97#define APPLE_FLAG_FKEY 0x01
98 98
99static struct hidinput_key_translation apple_fn_keys[] = { 99static struct hidinput_key_translation apple_fn_keys[] = {
100 { KEY_BACKSPACE, KEY_DELETE },
100 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, 101 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
101 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, 102 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
102 { KEY_F3, KEY_CYCLEWINDOWS, APPLE_FLAG_FKEY }, /* Exposé */ 103 { KEY_F3, KEY_CYCLEWINDOWS, APPLE_FLAG_FKEY }, /* Exposé */
@@ -109,6 +110,10 @@ static struct hidinput_key_translation apple_fn_keys[] = {
109 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, 110 { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
110 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, 111 { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
111 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, 112 { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
113 { KEY_UP, KEY_PAGEUP },
114 { KEY_DOWN, KEY_PAGEDOWN },
115 { KEY_LEFT, KEY_HOME },
116 { KEY_RIGHT, KEY_END },
112 { } 117 { }
113}; 118};
114 119
@@ -854,7 +859,8 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
854 return; 859 return;
855 860
856 /* handle input events for quirky devices */ 861 /* handle input events for quirky devices */
857 hidinput_event_quirks(hid, field, usage, value); 862 if (hidinput_event_quirks(hid, field, usage, value))
863 return;
858 864
859 if (usage->hat_min < usage->hat_max || usage->hat_dir) { 865 if (usage->hat_min < usage->hat_max || usage->hat_dir) {
860 int hat_dir = usage->hat_dir; 866 int hat_dir = usage->hat_dir;
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
index b77b61e0cd7b..e6d05f6b1c1c 100644
--- a/drivers/hid/usbhid/hid-quirks.c
+++ b/drivers/hid/usbhid/hid-quirks.c
@@ -66,6 +66,12 @@
66#define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220 66#define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220
67#define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221 67#define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221
68#define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222 68#define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222
69#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI 0x0229
70#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO 0x022a
71#define USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS 0x022b
72#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI 0x022c
73#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO 0x022d
74#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS 0x022e
69#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a 75#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a
70#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b 76#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b
71#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242 77#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242
@@ -193,6 +199,17 @@
193#define USB_DEVICE_ID_GTCO_502 0x0502 199#define USB_DEVICE_ID_GTCO_502 0x0502
194#define USB_DEVICE_ID_GTCO_503 0x0503 200#define USB_DEVICE_ID_GTCO_503 0x0503
195#define USB_DEVICE_ID_GTCO_504 0x0504 201#define USB_DEVICE_ID_GTCO_504 0x0504
202#define USB_DEVICE_ID_GTCO_600 0x0600
203#define USB_DEVICE_ID_GTCO_601 0x0601
204#define USB_DEVICE_ID_GTCO_602 0x0602
205#define USB_DEVICE_ID_GTCO_603 0x0603
206#define USB_DEVICE_ID_GTCO_604 0x0604
207#define USB_DEVICE_ID_GTCO_605 0x0605
208#define USB_DEVICE_ID_GTCO_606 0x0606
209#define USB_DEVICE_ID_GTCO_607 0x0607
210#define USB_DEVICE_ID_GTCO_608 0x0608
211#define USB_DEVICE_ID_GTCO_609 0x0609
212#define USB_DEVICE_ID_GTCO_609 0x0609
196#define USB_DEVICE_ID_GTCO_1000 0x1000 213#define USB_DEVICE_ID_GTCO_1000 0x1000
197#define USB_DEVICE_ID_GTCO_1001 0x1001 214#define USB_DEVICE_ID_GTCO_1001 0x1001
198#define USB_DEVICE_ID_GTCO_1002 0x1002 215#define USB_DEVICE_ID_GTCO_1002 0x1002
@@ -200,7 +217,7 @@
200#define USB_DEVICE_ID_GTCO_1004 0x1004 217#define USB_DEVICE_ID_GTCO_1004 0x1004
201#define USB_DEVICE_ID_GTCO_1005 0x1005 218#define USB_DEVICE_ID_GTCO_1005 0x1005
202#define USB_DEVICE_ID_GTCO_1006 0x1006 219#define USB_DEVICE_ID_GTCO_1006 0x1006
203 220#define USB_DEVICE_ID_GTCO_1007 0x1007
204#define USB_VENDOR_ID_HAPP 0x078b 221#define USB_VENDOR_ID_HAPP 0x078b
205#define USB_DEVICE_ID_UGCI_DRIVING 0x0010 222#define USB_DEVICE_ID_UGCI_DRIVING 0x0010
206#define USB_DEVICE_ID_UGCI_FLYING 0x0020 223#define USB_DEVICE_ID_UGCI_FLYING 0x0020
@@ -368,6 +385,7 @@
368#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 385#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002
369#define USB_DEVICE_ID_VERNIER_SKIP 0x0003 386#define USB_DEVICE_ID_VERNIER_SKIP 0x0003
370#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 387#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
388#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
371 389
372#define USB_VENDOR_ID_WACOM 0x056a 390#define USB_VENDOR_ID_WACOM 0x056a
373 391
@@ -496,6 +514,16 @@ static const struct hid_blacklist {
496 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502, HID_QUIRK_IGNORE }, 514 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502, HID_QUIRK_IGNORE },
497 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503, HID_QUIRK_IGNORE }, 515 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503, HID_QUIRK_IGNORE },
498 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504, HID_QUIRK_IGNORE }, 516 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504, HID_QUIRK_IGNORE },
517 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_600, HID_QUIRK_IGNORE },
518 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_601, HID_QUIRK_IGNORE },
519 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_602, HID_QUIRK_IGNORE },
520 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_603, HID_QUIRK_IGNORE },
521 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_604, HID_QUIRK_IGNORE },
522 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_605, HID_QUIRK_IGNORE },
523 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_606, HID_QUIRK_IGNORE },
524 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_607, HID_QUIRK_IGNORE },
525 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_608, HID_QUIRK_IGNORE },
526 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_609, HID_QUIRK_IGNORE },
499 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000, HID_QUIRK_IGNORE }, 527 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000, HID_QUIRK_IGNORE },
500 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001, HID_QUIRK_IGNORE }, 528 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001, HID_QUIRK_IGNORE },
501 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002, HID_QUIRK_IGNORE }, 529 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002, HID_QUIRK_IGNORE },
@@ -503,6 +531,7 @@ static const struct hid_blacklist {
503 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004, HID_QUIRK_IGNORE }, 531 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004, HID_QUIRK_IGNORE },
504 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005, HID_QUIRK_IGNORE }, 532 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005, HID_QUIRK_IGNORE },
505 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006, HID_QUIRK_IGNORE }, 533 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006, HID_QUIRK_IGNORE },
534 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007, HID_QUIRK_IGNORE },
506 { USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA, HID_QUIRK_IGNORE }, 535 { USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA, HID_QUIRK_IGNORE },
507 { USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE }, 536 { USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO, HID_QUIRK_IGNORE },
508 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY, HID_QUIRK_IGNORE }, 537 { USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY, HID_QUIRK_IGNORE },
@@ -541,6 +570,7 @@ static const struct hid_blacklist {
541 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE }, 570 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP, HID_QUIRK_IGNORE },
542 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE }, 571 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP, HID_QUIRK_IGNORE },
543 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE }, 572 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE },
573 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC, HID_QUIRK_IGNORE },
544 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 574 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
545 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 575 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
546 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT, HID_QUIRK_IGNORE }, 576 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT, HID_QUIRK_IGNORE },
@@ -593,6 +623,12 @@ static const struct hid_blacklist {
593 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI, HID_QUIRK_APPLE_HAS_FN }, 623 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI, HID_QUIRK_APPLE_HAS_FN },
594 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD }, 624 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD },
595 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS, HID_QUIRK_APPLE_HAS_FN }, 625 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS, HID_QUIRK_APPLE_HAS_FN },
626 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
627 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE | HID_QUIRK_APPLE_ISO_KEYBOARD },
628 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
629 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI, HID_QUIRK_APPLE_HAS_FN },
630 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_APPLE_ISO_KEYBOARD },
631 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS, HID_QUIRK_APPLE_HAS_FN },
596 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 632 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
597 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE }, 633 { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY, HID_QUIRK_APPLE_HAS_FN | HID_QUIRK_IGNORE_MOUSE },
598 634
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 638b727d42e0..b10ade92efed 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3587,8 +3587,6 @@ static void cm_release_port_obj(struct kobject *obj)
3587{ 3587{
3588 struct cm_port *cm_port; 3588 struct cm_port *cm_port;
3589 3589
3590 printk(KERN_ERR "free cm port\n");
3591
3592 cm_port = container_of(obj, struct cm_port, port_obj); 3590 cm_port = container_of(obj, struct cm_port, port_obj);
3593 kfree(cm_port); 3591 kfree(cm_port);
3594} 3592}
@@ -3601,8 +3599,6 @@ static void cm_release_dev_obj(struct kobject *obj)
3601{ 3599{
3602 struct cm_device *cm_dev; 3600 struct cm_device *cm_dev;
3603 3601
3604 printk(KERN_ERR "free cm dev\n");
3605
3606 cm_dev = container_of(obj, struct cm_device, dev_obj); 3602 cm_dev = container_of(obj, struct cm_device, dev_obj);
3607 kfree(cm_dev); 3603 kfree(cm_dev);
3608} 3604}
@@ -3616,18 +3612,12 @@ struct class cm_class = {
3616}; 3612};
3617EXPORT_SYMBOL(cm_class); 3613EXPORT_SYMBOL(cm_class);
3618 3614
3619static void cm_remove_fs_obj(struct kobject *obj)
3620{
3621 kobject_put(obj->parent);
3622 kobject_put(obj);
3623}
3624
3625static int cm_create_port_fs(struct cm_port *port) 3615static int cm_create_port_fs(struct cm_port *port)
3626{ 3616{
3627 int i, ret; 3617 int i, ret;
3628 3618
3629 ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type, 3619 ret = kobject_init_and_add(&port->port_obj, &cm_port_obj_type,
3630 kobject_get(&port->cm_dev->dev_obj), 3620 &port->cm_dev->dev_obj,
3631 "%d", port->port_num); 3621 "%d", port->port_num);
3632 if (ret) { 3622 if (ret) {
3633 kfree(port); 3623 kfree(port);
@@ -3637,7 +3627,7 @@ static int cm_create_port_fs(struct cm_port *port)
3637 for (i = 0; i < CM_COUNTER_GROUPS; i++) { 3627 for (i = 0; i < CM_COUNTER_GROUPS; i++) {
3638 ret = kobject_init_and_add(&port->counter_group[i].obj, 3628 ret = kobject_init_and_add(&port->counter_group[i].obj,
3639 &cm_counter_obj_type, 3629 &cm_counter_obj_type,
3640 kobject_get(&port->port_obj), 3630 &port->port_obj,
3641 "%s", counter_group_names[i]); 3631 "%s", counter_group_names[i]);
3642 if (ret) 3632 if (ret)
3643 goto error; 3633 goto error;
@@ -3647,8 +3637,8 @@ static int cm_create_port_fs(struct cm_port *port)
3647 3637
3648error: 3638error:
3649 while (i--) 3639 while (i--)
3650 cm_remove_fs_obj(&port->counter_group[i].obj); 3640 kobject_put(&port->counter_group[i].obj);
3651 cm_remove_fs_obj(&port->port_obj); 3641 kobject_put(&port->port_obj);
3652 return ret; 3642 return ret;
3653 3643
3654} 3644}
@@ -3658,9 +3648,9 @@ static void cm_remove_port_fs(struct cm_port *port)
3658 int i; 3648 int i;
3659 3649
3660 for (i = 0; i < CM_COUNTER_GROUPS; i++) 3650 for (i = 0; i < CM_COUNTER_GROUPS; i++)
3661 cm_remove_fs_obj(&port->counter_group[i].obj); 3651 kobject_put(&port->counter_group[i].obj);
3662 3652
3663 cm_remove_fs_obj(&port->port_obj); 3653 kobject_put(&port->port_obj);
3664} 3654}
3665 3655
3666static void cm_add_one(struct ib_device *device) 3656static void cm_add_one(struct ib_device *device)
@@ -3744,7 +3734,7 @@ error1:
3744 ib_unregister_mad_agent(port->mad_agent); 3734 ib_unregister_mad_agent(port->mad_agent);
3745 cm_remove_port_fs(port); 3735 cm_remove_port_fs(port);
3746 } 3736 }
3747 cm_remove_fs_obj(&cm_dev->dev_obj); 3737 kobject_put(&cm_dev->dev_obj);
3748} 3738}
3749 3739
3750static void cm_remove_one(struct ib_device *device) 3740static void cm_remove_one(struct ib_device *device)
@@ -3771,7 +3761,7 @@ static void cm_remove_one(struct ib_device *device)
3771 ib_unregister_mad_agent(port->mad_agent); 3761 ib_unregister_mad_agent(port->mad_agent);
3772 cm_remove_port_fs(port); 3762 cm_remove_port_fs(port);
3773 } 3763 }
3774 cm_remove_fs_obj(&cm_dev->dev_obj); 3764 kobject_put(&cm_dev->dev_obj);
3775} 3765}
3776 3766
3777static int __init ib_cm_init(void) 3767static int __init ib_cm_init(void)
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 1eff1b2c0e08..34507daaf9b6 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1107,7 +1107,6 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1107 event.param.ud.private_data_len = 1107 event.param.ud.private_data_len =
1108 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset; 1108 IB_CM_SIDR_REQ_PRIVATE_DATA_SIZE - offset;
1109 } else { 1109 } else {
1110 ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
1111 conn_id = cma_new_conn_id(&listen_id->id, ib_event); 1110 conn_id = cma_new_conn_id(&listen_id->id, ib_event);
1112 cma_set_req_event_data(&event, &ib_event->param.req_rcvd, 1111 cma_set_req_event_data(&event, &ib_event->param.req_rcvd,
1113 ib_event->private_data, offset); 1112 ib_event->private_data, offset);
@@ -1130,6 +1129,15 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1130 1129
1131 ret = conn_id->id.event_handler(&conn_id->id, &event); 1130 ret = conn_id->id.event_handler(&conn_id->id, &event);
1132 if (!ret) { 1131 if (!ret) {
1132 /*
1133 * Acquire mutex to prevent user executing rdma_destroy_id()
1134 * while we're accessing the cm_id.
1135 */
1136 mutex_lock(&lock);
1137 if (cma_comp(conn_id, CMA_CONNECT) &&
1138 !cma_is_ud_ps(conn_id->id.ps))
1139 ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
1140 mutex_unlock(&lock);
1133 cma_enable_remove(conn_id); 1141 cma_enable_remove(conn_id);
1134 goto out; 1142 goto out;
1135 } 1143 }
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index e9a08fa3dffe..320f2b6ddee6 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -35,6 +35,7 @@
35#include <linux/skbuff.h> 35#include <linux/skbuff.h>
36#include <linux/timer.h> 36#include <linux/timer.h>
37#include <linux/notifier.h> 37#include <linux/notifier.h>
38#include <linux/inetdevice.h>
38 39
39#include <net/neighbour.h> 40#include <net/neighbour.h>
40#include <net/netevent.h> 41#include <net/netevent.h>
@@ -1784,6 +1785,17 @@ err:
1784 return err; 1785 return err;
1785} 1786}
1786 1787
1788static int is_loopback_dst(struct iw_cm_id *cm_id)
1789{
1790 struct net_device *dev;
1791
1792 dev = ip_dev_find(&init_net, cm_id->remote_addr.sin_addr.s_addr);
1793 if (!dev)
1794 return 0;
1795 dev_put(dev);
1796 return 1;
1797}
1798
1787int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param) 1799int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1788{ 1800{
1789 int err = 0; 1801 int err = 0;
@@ -1791,6 +1803,11 @@ int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
1791 struct iwch_ep *ep; 1803 struct iwch_ep *ep;
1792 struct rtable *rt; 1804 struct rtable *rt;
1793 1805
1806 if (is_loopback_dst(cm_id)) {
1807 err = -ENOSYS;
1808 goto out;
1809 }
1810
1794 ep = alloc_ep(sizeof(*ep), GFP_KERNEL); 1811 ep = alloc_ep(sizeof(*ep), GFP_KERNEL);
1795 if (!ep) { 1812 if (!ep) {
1796 printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__); 1813 printk(KERN_ERR MOD "%s - cannot alloc ep.\n", __FUNCTION__);
diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
index 7dc91a3e712d..fe2c2e94a5f8 100644
--- a/drivers/infiniband/hw/mlx4/mr.c
+++ b/drivers/infiniband/hw/mlx4/mr.c
@@ -199,7 +199,7 @@ struct ib_fmr *mlx4_ib_fmr_alloc(struct ib_pd *pd, int acc,
199 if (err) 199 if (err)
200 goto err_free; 200 goto err_free;
201 201
202 err = mlx4_mr_enable(to_mdev(pd->device)->dev, &fmr->mfmr.mr); 202 err = mlx4_fmr_enable(to_mdev(pd->device)->dev, &fmr->mfmr);
203 if (err) 203 if (err)
204 goto err_mr; 204 goto err_mr;
205 205
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 6bd9f1393349..1e1e336d3ef9 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -473,7 +473,7 @@ static void handle_error_cqe(struct mthca_dev *dev, struct mthca_cq *cq,
473 if (!(new_wqe & cpu_to_be32(0x3f)) || (!cqe->db_cnt && dbd)) 473 if (!(new_wqe & cpu_to_be32(0x3f)) || (!cqe->db_cnt && dbd))
474 return; 474 return;
475 475
476 cqe->db_cnt = cpu_to_be16(be16_to_cpu(cqe->db_cnt) - dbd); 476 be16_add_cpu(&cqe->db_cnt, -dbd);
477 cqe->wqe = new_wqe; 477 cqe->wqe = new_wqe;
478 cqe->syndrome = SYNDROME_WR_FLUSH_ERR; 478 cqe->syndrome = SYNDROME_WR_FLUSH_ERR;
479 479
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 1f4d27d7c16d..252db0822f6c 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -542,6 +542,7 @@ struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev)
542 for (i = 0; i < npages; ++i) { 542 for (i = 0; i < npages; ++i) {
543 db_tab->page[i].refcount = 0; 543 db_tab->page[i].refcount = 0;
544 db_tab->page[i].uvirt = 0; 544 db_tab->page[i].uvirt = 0;
545 sg_init_table(&db_tab->page[i].mem, 1);
545 } 546 }
546 547
547 return db_tab; 548 return db_tab;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index f9b7caa54143..054fab8e27a0 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -209,7 +209,6 @@ struct ipoib_cm_tx {
209 unsigned tx_tail; 209 unsigned tx_tail;
210 unsigned long flags; 210 unsigned long flags;
211 u32 mtu; 211 u32 mtu;
212 struct ib_wc ibwc[IPOIB_NUM_WC];
213}; 212};
214 213
215struct ipoib_cm_rx_buf { 214struct ipoib_cm_rx_buf {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 9d3e778dc56d..08c4396cf418 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -780,6 +780,7 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
780 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) { 780 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) {
781 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 781 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
782 ipoib_ib_dev_down(dev, 0); 782 ipoib_ib_dev_down(dev, 0);
783 ipoib_ib_dev_stop(dev, 0);
783 ipoib_pkey_dev_delay_open(dev); 784 ipoib_pkey_dev_delay_open(dev);
784 return; 785 return;
785 } 786 }
diff --git a/drivers/macintosh/mediabay.c b/drivers/macintosh/mediabay.c
index 936788272a5f..51a112815f46 100644
--- a/drivers/macintosh/mediabay.c
+++ b/drivers/macintosh/mediabay.c
@@ -416,7 +416,6 @@ static void poll_media_bay(struct media_bay_info* bay)
416 } 416 }
417} 417}
418 418
419#ifdef CONFIG_MAC_FLOPPY
420int check_media_bay(struct device_node *which_bay, int what) 419int check_media_bay(struct device_node *which_bay, int what)
421{ 420{
422 int i; 421 int i;
@@ -431,7 +430,6 @@ int check_media_bay(struct device_node *which_bay, int what)
431 return -ENODEV; 430 return -ENODEV;
432} 431}
433EXPORT_SYMBOL(check_media_bay); 432EXPORT_SYMBOL(check_media_bay);
434#endif /* CONFIG_MAC_FLOPPY */
435 433
436#ifdef CONFIG_BLK_DEV_IDE_PMAC 434#ifdef CONFIG_BLK_DEV_IDE_PMAC
437int check_media_bay_by_base(unsigned long base, int what) 435int check_media_bay_by_base(unsigned long base, int what)
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index a0585fb6da94..7aeceedcf7d4 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -206,16 +206,10 @@ static void bitmap_checkfree(struct bitmap *bitmap, unsigned long page)
206/* copy the pathname of a file to a buffer */ 206/* copy the pathname of a file to a buffer */
207char *file_path(struct file *file, char *buf, int count) 207char *file_path(struct file *file, char *buf, int count)
208{ 208{
209 struct dentry *d;
210 struct vfsmount *v;
211
212 if (!buf) 209 if (!buf)
213 return NULL; 210 return NULL;
214 211
215 d = file->f_path.dentry; 212 buf = d_path(&file->f_path, buf, count);
216 v = file->f_path.mnt;
217
218 buf = d_path(d, v, buf, count);
219 213
220 return IS_ERR(buf) ? NULL : buf; 214 return IS_ERR(buf) ? NULL : buf;
221} 215}
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index f16062982383..e75b1437b58b 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -361,7 +361,7 @@ static int lookup_device(const char *path, dev_t *dev)
361 if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd))) 361 if ((r = path_lookup(path, LOOKUP_FOLLOW, &nd)))
362 return r; 362 return r;
363 363
364 inode = nd.dentry->d_inode; 364 inode = nd.path.dentry->d_inode;
365 if (!inode) { 365 if (!inode) {
366 r = -ENOENT; 366 r = -ENOENT;
367 goto out; 367 goto out;
@@ -375,7 +375,7 @@ static int lookup_device(const char *path, dev_t *dev)
375 *dev = inode->i_rdev; 375 *dev = inode->i_rdev;
376 376
377 out: 377 out:
378 path_release(&nd); 378 path_put(&nd.path);
379 return r; 379 return r;
380} 380}
381 381
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 5fc326d3970e..7da6ec244e15 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5197,8 +5197,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
5197 chunk_kb ? "KB" : "B"); 5197 chunk_kb ? "KB" : "B");
5198 if (bitmap->file) { 5198 if (bitmap->file) {
5199 seq_printf(seq, ", file: "); 5199 seq_printf(seq, ", file: ");
5200 seq_path(seq, bitmap->file->f_path.mnt, 5200 seq_path(seq, &bitmap->file->f_path, " \t\n");
5201 bitmap->file->f_path.dentry," \t\n");
5202 } 5201 }
5203 5202
5204 seq_printf(seq, "\n"); 5203 seq_printf(seq, "\n");
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 7ba1acad5402..e2c7edd206a6 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1689,7 +1689,7 @@ static ssize_t hotkey_wakeup_reason_show(struct device *dev,
1689static struct device_attribute dev_attr_hotkey_wakeup_reason = 1689static struct device_attribute dev_attr_hotkey_wakeup_reason =
1690 __ATTR(wakeup_reason, S_IRUGO, hotkey_wakeup_reason_show, NULL); 1690 __ATTR(wakeup_reason, S_IRUGO, hotkey_wakeup_reason_show, NULL);
1691 1691
1692void hotkey_wakeup_reason_notify_change(void) 1692static void hotkey_wakeup_reason_notify_change(void)
1693{ 1693{
1694 if (tp_features.hotkey_mask) 1694 if (tp_features.hotkey_mask)
1695 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, 1695 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL,
@@ -1708,7 +1708,7 @@ static struct device_attribute dev_attr_hotkey_wakeup_hotunplug_complete =
1708 __ATTR(wakeup_hotunplug_complete, S_IRUGO, 1708 __ATTR(wakeup_hotunplug_complete, S_IRUGO,
1709 hotkey_wakeup_hotunplug_complete_show, NULL); 1709 hotkey_wakeup_hotunplug_complete_show, NULL);
1710 1710
1711void hotkey_wakeup_hotunplug_complete_notify_change(void) 1711static void hotkey_wakeup_hotunplug_complete_notify_change(void)
1712{ 1712{
1713 if (tp_features.hotkey_mask) 1713 if (tp_features.hotkey_mask)
1714 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, 1714 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL,
diff --git a/drivers/mtd/mtdsuper.c b/drivers/mtd/mtdsuper.c
index 9b430f20b640..28cc6787a800 100644
--- a/drivers/mtd/mtdsuper.c
+++ b/drivers/mtd/mtdsuper.c
@@ -184,26 +184,26 @@ int get_sb_mtd(struct file_system_type *fs_type, int flags,
184 ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); 184 ret = path_lookup(dev_name, LOOKUP_FOLLOW, &nd);
185 185
186 DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n", 186 DEBUG(1, "MTDSB: path_lookup() returned %d, inode %p\n",
187 ret, nd.dentry ? nd.dentry->d_inode : NULL); 187 ret, nd.path.dentry ? nd.path.dentry->d_inode : NULL);
188 188
189 if (ret) 189 if (ret)
190 return ret; 190 return ret;
191 191
192 ret = -EINVAL; 192 ret = -EINVAL;
193 193
194 if (!S_ISBLK(nd.dentry->d_inode->i_mode)) 194 if (!S_ISBLK(nd.path.dentry->d_inode->i_mode))
195 goto out; 195 goto out;
196 196
197 if (nd.mnt->mnt_flags & MNT_NODEV) { 197 if (nd.path.mnt->mnt_flags & MNT_NODEV) {
198 ret = -EACCES; 198 ret = -EACCES;
199 goto out; 199 goto out;
200 } 200 }
201 201
202 if (imajor(nd.dentry->d_inode) != MTD_BLOCK_MAJOR) 202 if (imajor(nd.path.dentry->d_inode) != MTD_BLOCK_MAJOR)
203 goto not_an_MTD_device; 203 goto not_an_MTD_device;
204 204
205 mtdnr = iminor(nd.dentry->d_inode); 205 mtdnr = iminor(nd.path.dentry->d_inode);
206 path_release(&nd); 206 path_put(&nd.path);
207 207
208 return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super, 208 return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super,
209 mnt); 209 mnt);
@@ -214,7 +214,7 @@ not_an_MTD_device:
214 "MTD: Attempt to mount non-MTD device \"%s\"\n", 214 "MTD: Attempt to mount non-MTD device \"%s\"\n",
215 dev_name); 215 dev_name);
216out: 216out:
217 path_release(&nd); 217 path_put(&nd.path);
218 return ret; 218 return ret;
219 219
220} 220}
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index eef6fecfff2a..be6e918456d9 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -168,7 +168,7 @@ static int debug = -1;
168 * Warning: 64K ring has hardware issues and may lock up. 168 * Warning: 64K ring has hardware issues and may lock up.
169 */ 169 */
170#if defined(CONFIG_SH_DREAMCAST) 170#if defined(CONFIG_SH_DREAMCAST)
171#define RX_BUF_IDX 1 /* 16K ring */ 171#define RX_BUF_IDX 0 /* 8K ring */
172#else 172#else
173#define RX_BUF_IDX 2 /* 32K ring */ 173#define RX_BUF_IDX 2 /* 32K ring */
174#endif 174#endif
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 50c2b60e1fee..f337800076c0 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -931,6 +931,14 @@ config ENC28J60_WRITEVERIFY
931 Enable the verify after the buffer write useful for debugging purpose. 931 Enable the verify after the buffer write useful for debugging purpose.
932 If unsure, say N. 932 If unsure, say N.
933 933
934config DM9000_DEBUGLEVEL
935 int "DM9000 maximum debug level"
936 depends on DM9000
937 default 4
938 help
939 The maximum level of debugging code compiled into the DM9000
940 driver.
941
934config SMC911X 942config SMC911X
935 tristate "SMSC LAN911[5678] support" 943 tristate "SMSC LAN911[5678] support"
936 select CRC32 944 select CRC32
@@ -2352,6 +2360,16 @@ config GELIC_NET
2352 To compile this driver as a module, choose M here: the 2360 To compile this driver as a module, choose M here: the
2353 module will be called ps3_gelic. 2361 module will be called ps3_gelic.
2354 2362
2363config GELIC_WIRELESS
2364 bool "PS3 Wireless support"
2365 depends on GELIC_NET
2366 help
2367 This option adds the support for the wireless feature of PS3.
2368 If you have the wireless-less model of PS3 or have no plan to
2369 use wireless feature, disabling this option saves memory. As
2370 the driver automatically distinguishes the models, you can
2371 safely enable this option even if you have a wireless-less model.
2372
2355config GIANFAR 2373config GIANFAR
2356 tristate "Gianfar Ethernet" 2374 tristate "Gianfar Ethernet"
2357 depends on FSL_SOC 2375 depends on FSL_SOC
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 9fc7794e88ea..3b1ea321dc05 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -70,7 +70,8 @@ obj-$(CONFIG_BNX2X) += bnx2x.o
70spidernet-y += spider_net.o spider_net_ethtool.o 70spidernet-y += spider_net.o spider_net_ethtool.o
71obj-$(CONFIG_SPIDER_NET) += spidernet.o sungem_phy.o 71obj-$(CONFIG_SPIDER_NET) += spidernet.o sungem_phy.o
72obj-$(CONFIG_GELIC_NET) += ps3_gelic.o 72obj-$(CONFIG_GELIC_NET) += ps3_gelic.o
73ps3_gelic-objs += ps3_gelic_net.o 73gelic_wireless-$(CONFIG_GELIC_WIRELESS) += ps3_gelic_wireless.o
74ps3_gelic-objs += ps3_gelic_net.o $(gelic_wireless-y)
74obj-$(CONFIG_TC35815) += tc35815.o 75obj-$(CONFIG_TC35815) += tc35815.o
75obj-$(CONFIG_SKGE) += skge.o 76obj-$(CONFIG_SKGE) += skge.o
76obj-$(CONFIG_SKY2) += sky2.o 77obj-$(CONFIG_SKY2) += sky2.o
diff --git a/drivers/net/cxgb3/l2t.c b/drivers/net/cxgb3/l2t.c
index 17ed4c3527b7..865faee53e17 100644
--- a/drivers/net/cxgb3/l2t.c
+++ b/drivers/net/cxgb3/l2t.c
@@ -404,7 +404,7 @@ found:
404 if (neigh->nud_state & NUD_FAILED) { 404 if (neigh->nud_state & NUD_FAILED) {
405 arpq = e->arpq_head; 405 arpq = e->arpq_head;
406 e->arpq_head = e->arpq_tail = NULL; 406 e->arpq_head = e->arpq_tail = NULL;
407 } else if (neigh_is_connected(neigh)) 407 } else if (neigh->nud_state & (NUD_CONNECTED|NUD_STALE))
408 setup_l2e_send_pending(dev, NULL, e); 408 setup_l2e_send_pending(dev, NULL, e);
409 } else { 409 } else {
410 e->state = neigh_is_connected(neigh) ? 410 e->state = neigh_is_connected(neigh) ?
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 9ca8c66abd16..979f3fc5e765 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -1059,6 +1059,14 @@ static void write_tx_pkt_wr(struct adapter *adap, struct sk_buff *skb,
1059 htonl(V_WR_TID(q->token))); 1059 htonl(V_WR_TID(q->token)));
1060} 1060}
1061 1061
1062static inline void t3_stop_queue(struct net_device *dev, struct sge_qset *qs,
1063 struct sge_txq *q)
1064{
1065 netif_stop_queue(dev);
1066 set_bit(TXQ_ETH, &qs->txq_stopped);
1067 q->stops++;
1068}
1069
1062/** 1070/**
1063 * eth_xmit - add a packet to the Ethernet Tx queue 1071 * eth_xmit - add a packet to the Ethernet Tx queue
1064 * @skb: the packet 1072 * @skb: the packet
@@ -1090,31 +1098,18 @@ int t3_eth_xmit(struct sk_buff *skb, struct net_device *dev)
1090 ndesc = calc_tx_descs(skb); 1098 ndesc = calc_tx_descs(skb);
1091 1099
1092 if (unlikely(credits < ndesc)) { 1100 if (unlikely(credits < ndesc)) {
1093 if (!netif_queue_stopped(dev)) { 1101 t3_stop_queue(dev, qs, q);
1094 netif_stop_queue(dev); 1102 dev_err(&adap->pdev->dev,
1095 set_bit(TXQ_ETH, &qs->txq_stopped); 1103 "%s: Tx ring %u full while queue awake!\n",
1096 q->stops++; 1104 dev->name, q->cntxt_id & 7);
1097 dev_err(&adap->pdev->dev,
1098 "%s: Tx ring %u full while queue awake!\n",
1099 dev->name, q->cntxt_id & 7);
1100 }
1101 spin_unlock(&q->lock); 1105 spin_unlock(&q->lock);
1102 return NETDEV_TX_BUSY; 1106 return NETDEV_TX_BUSY;
1103 } 1107 }
1104 1108
1105 q->in_use += ndesc; 1109 q->in_use += ndesc;
1106 if (unlikely(credits - ndesc < q->stop_thres)) { 1110 if (unlikely(credits - ndesc < q->stop_thres))
1107 q->stops++; 1111 if (USE_GTS || !should_restart_tx(q))
1108 netif_stop_queue(dev); 1112 t3_stop_queue(dev, qs, q);
1109 set_bit(TXQ_ETH, &qs->txq_stopped);
1110#if !USE_GTS
1111 if (should_restart_tx(q) &&
1112 test_and_clear_bit(TXQ_ETH, &qs->txq_stopped)) {
1113 q->restarts++;
1114 netif_wake_queue(dev);
1115 }
1116#endif
1117 }
1118 1113
1119 gen = q->gen; 1114 gen = q->gen;
1120 q->unacked += ndesc; 1115 q->unacked += ndesc;
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 6a20a5491a96..1fe305ca2cf0 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -1,7 +1,5 @@
1/* 1/*
2 * dm9000.c: Version 1.2 03/18/2003 2 * Davicom DM9000 Fast Ethernet driver for Linux.
3 *
4 * A Davicom DM9000 ISA NIC fast Ethernet driver for Linux.
5 * Copyright (C) 1997 Sten Wang 3 * Copyright (C) 1997 Sten Wang
6 * 4 *
7 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
@@ -14,44 +12,11 @@
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details. 13 * GNU General Public License for more details.
16 * 14 *
17 * (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved. 15 * (C) Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
18 *
19 * V0.11 06/20/2001 REG_0A bit3=1, default enable BP with DA match
20 * 06/22/2001 Support DM9801 progrmming
21 * E3: R25 = ((R24 + NF) & 0x00ff) | 0xf000
22 * E4: R25 = ((R24 + NF) & 0x00ff) | 0xc200
23 * R17 = (R17 & 0xfff0) | NF + 3
24 * E5: R25 = ((R24 + NF - 3) & 0x00ff) | 0xc200
25 * R17 = (R17 & 0xfff0) | NF
26 *
27 * v1.00 modify by simon 2001.9.5
28 * change for kernel 2.4.x
29 *
30 * v1.1 11/09/2001 fix force mode bug
31 *
32 * v1.2 03/18/2003 Weilun Huang <weilun_huang@davicom.com.tw>:
33 * Fixed phy reset.
34 * Added tx/rx 32 bit mode.
35 * Cleaned up for kernel merge.
36 *
37 * 03/03/2004 Sascha Hauer <s.hauer@pengutronix.de>
38 * Port to 2.6 kernel
39 *
40 * 24-Sep-2004 Ben Dooks <ben@simtec.co.uk>
41 * Cleanup of code to remove ifdefs
42 * Allowed platform device data to influence access width
43 * Reformatting areas of code
44 *
45 * 17-Mar-2005 Sascha Hauer <s.hauer@pengutronix.de>
46 * * removed 2.4 style module parameters
47 * * removed removed unused stat counter and fixed
48 * net_device_stats
49 * * introduced tx_timeout function
50 * * reworked locking
51 * 16 *
52 * 01-Jul-2005 Ben Dooks <ben@simtec.co.uk> 17 * Additional updates, Copyright:
53 * * fixed spinlock call without pointer 18 * Ben Dooks <ben@simtec.co.uk>
54 * * ensure spinlock is initialised 19 * Sascha Hauer <s.hauer@pengutronix.de>
55 */ 20 */
56 21
57#include <linux/module.h> 22#include <linux/module.h>
@@ -63,6 +28,7 @@
63#include <linux/spinlock.h> 28#include <linux/spinlock.h>
64#include <linux/crc32.h> 29#include <linux/crc32.h>
65#include <linux/mii.h> 30#include <linux/mii.h>
31#include <linux/ethtool.h>
66#include <linux/dm9000.h> 32#include <linux/dm9000.h>
67#include <linux/delay.h> 33#include <linux/delay.h>
68#include <linux/platform_device.h> 34#include <linux/platform_device.h>
@@ -80,30 +46,7 @@
80 46
81#define CARDNAME "dm9000" 47#define CARDNAME "dm9000"
82#define PFX CARDNAME ": " 48#define PFX CARDNAME ": "
83 49#define DRV_VERSION "1.30"
84#define DM9000_TIMER_WUT jiffies+(HZ*2) /* timer wakeup time : 2 second */
85
86#define DM9000_DEBUG 0
87
88#if DM9000_DEBUG > 2
89#define PRINTK3(args...) printk(CARDNAME ": " args)
90#else
91#define PRINTK3(args...) do { } while(0)
92#endif
93
94#if DM9000_DEBUG > 1
95#define PRINTK2(args...) printk(CARDNAME ": " args)
96#else
97#define PRINTK2(args...) do { } while(0)
98#endif
99
100#if DM9000_DEBUG > 0
101#define PRINTK1(args...) printk(CARDNAME ": " args)
102#define PRINTK(args...) printk(CARDNAME ": " args)
103#else
104#define PRINTK1(args...) do { } while(0)
105#define PRINTK(args...) printk(KERN_DEBUG args)
106#endif
107 50
108#ifdef CONFIG_BLACKFIN 51#ifdef CONFIG_BLACKFIN
109#define readsb insb 52#define readsb insb
@@ -112,9 +55,9 @@
112#define writesb outsb 55#define writesb outsb
113#define writesw outsw 56#define writesw outsw
114#define writesl outsl 57#define writesl outsl
115#define DM9000_IRQ_FLAGS (IRQF_SHARED | IRQF_TRIGGER_HIGH) 58#define DEFAULT_TRIGGER IRQF_TRIGGER_HIGH
116#else 59#else
117#define DM9000_IRQ_FLAGS (IRQF_SHARED | IRQT_RISING) 60#define DEFAULT_TRIGGER (0)
118#endif 61#endif
119 62
120/* 63/*
@@ -124,6 +67,24 @@ static int watchdog = 5000;
124module_param(watchdog, int, 0400); 67module_param(watchdog, int, 0400);
125MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds"); 68MODULE_PARM_DESC(watchdog, "transmit timeout in milliseconds");
126 69
70/* DM9000 register address locking.
71 *
72 * The DM9000 uses an address register to control where data written
73 * to the data register goes. This means that the address register
74 * must be preserved over interrupts or similar calls.
75 *
76 * During interrupt and other critical calls, a spinlock is used to
77 * protect the system, but the calls themselves save the address
78 * in the address register in case they are interrupting another
79 * access to the device.
80 *
81 * For general accesses a lock is provided so that calls which are
82 * allowed to sleep are serialised so that the address register does
83 * not need to be saved. This lock also serves to serialise access
84 * to the EEPROM and PHY access registers which are shared between
85 * these two devices.
86 */
87
127/* Structure/enum declaration ------------------------------- */ 88/* Structure/enum declaration ------------------------------- */
128typedef struct board_info { 89typedef struct board_info {
129 90
@@ -137,33 +98,52 @@ typedef struct board_info {
137 u16 dbug_cnt; 98 u16 dbug_cnt;
138 u8 io_mode; /* 0:word, 2:byte */ 99 u8 io_mode; /* 0:word, 2:byte */
139 u8 phy_addr; 100 u8 phy_addr;
101 unsigned int flags;
102 unsigned int in_suspend :1;
103
104 int debug_level;
140 105
141 void (*inblk)(void __iomem *port, void *data, int length); 106 void (*inblk)(void __iomem *port, void *data, int length);
142 void (*outblk)(void __iomem *port, void *data, int length); 107 void (*outblk)(void __iomem *port, void *data, int length);
143 void (*dumpblk)(void __iomem *port, int length); 108 void (*dumpblk)(void __iomem *port, int length);
144 109
110 struct device *dev; /* parent device */
111
145 struct resource *addr_res; /* resources found */ 112 struct resource *addr_res; /* resources found */
146 struct resource *data_res; 113 struct resource *data_res;
147 struct resource *addr_req; /* resources requested */ 114 struct resource *addr_req; /* resources requested */
148 struct resource *data_req; 115 struct resource *data_req;
149 struct resource *irq_res; 116 struct resource *irq_res;
150 117
151 struct timer_list timer; 118 struct mutex addr_lock; /* phy and eeprom access lock */
152 unsigned char srom[128]; 119
153 spinlock_t lock; 120 spinlock_t lock;
154 121
155 struct mii_if_info mii; 122 struct mii_if_info mii;
156 u32 msg_enable; 123 u32 msg_enable;
157} board_info_t; 124} board_info_t;
158 125
126/* debug code */
127
128#define dm9000_dbg(db, lev, msg...) do { \
129 if ((lev) < CONFIG_DM9000_DEBUGLEVEL && \
130 (lev) < db->debug_level) { \
131 dev_dbg(db->dev, msg); \
132 } \
133} while (0)
134
135static inline board_info_t *to_dm9000_board(struct net_device *dev)
136{
137 return dev->priv;
138}
139
159/* function declaration ------------------------------------- */ 140/* function declaration ------------------------------------- */
160static int dm9000_probe(struct platform_device *); 141static int dm9000_probe(struct platform_device *);
161static int dm9000_open(struct net_device *); 142static int dm9000_open(struct net_device *);
162static int dm9000_start_xmit(struct sk_buff *, struct net_device *); 143static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
163static int dm9000_stop(struct net_device *); 144static int dm9000_stop(struct net_device *);
145static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd);
164 146
165
166static void dm9000_timer(unsigned long);
167static void dm9000_init_dm9000(struct net_device *); 147static void dm9000_init_dm9000(struct net_device *);
168 148
169static irqreturn_t dm9000_interrupt(int, void *); 149static irqreturn_t dm9000_interrupt(int, void *);
@@ -171,20 +151,19 @@ static irqreturn_t dm9000_interrupt(int, void *);
171static int dm9000_phy_read(struct net_device *dev, int phyaddr_unsused, int reg); 151static int dm9000_phy_read(struct net_device *dev, int phyaddr_unsused, int reg);
172static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, 152static void dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg,
173 int value); 153 int value);
174static u16 read_srom_word(board_info_t *, int); 154
155static void dm9000_read_eeprom(board_info_t *, int addr, u8 *to);
156static void dm9000_write_eeprom(board_info_t *, int addr, u8 *dp);
175static void dm9000_rx(struct net_device *); 157static void dm9000_rx(struct net_device *);
176static void dm9000_hash_table(struct net_device *); 158static void dm9000_hash_table(struct net_device *);
177 159
178//#define DM9000_PROGRAM_EEPROM
179#ifdef DM9000_PROGRAM_EEPROM
180static void program_eeprom(board_info_t * db);
181#endif
182/* DM9000 network board routine ---------------------------- */ 160/* DM9000 network board routine ---------------------------- */
183 161
184static void 162static void
185dm9000_reset(board_info_t * db) 163dm9000_reset(board_info_t * db)
186{ 164{
187 PRINTK1("dm9000x: resetting\n"); 165 dev_dbg(db->dev, "resetting device\n");
166
188 /* RESET device */ 167 /* RESET device */
189 writeb(DM9000_NCR, db->io_addr); 168 writeb(DM9000_NCR, db->io_addr);
190 udelay(200); 169 udelay(200);
@@ -300,14 +279,10 @@ static void dm9000_set_io(struct board_info *db, int byte_width)
300 db->inblk = dm9000_inblk_8bit; 279 db->inblk = dm9000_inblk_8bit;
301 break; 280 break;
302 281
303 case 2:
304 db->dumpblk = dm9000_dumpblk_16bit;
305 db->outblk = dm9000_outblk_16bit;
306 db->inblk = dm9000_inblk_16bit;
307 break;
308 282
309 case 3: 283 case 3:
310 printk(KERN_ERR PFX ": 3 byte IO, falling back to 16bit\n"); 284 dev_dbg(db->dev, ": 3 byte IO, falling back to 16bit\n");
285 case 2:
311 db->dumpblk = dm9000_dumpblk_16bit; 286 db->dumpblk = dm9000_dumpblk_16bit;
312 db->outblk = dm9000_outblk_16bit; 287 db->outblk = dm9000_outblk_16bit;
313 db->inblk = dm9000_inblk_16bit; 288 db->inblk = dm9000_inblk_16bit;
@@ -358,6 +333,139 @@ static void dm9000_poll_controller(struct net_device *dev)
358} 333}
359#endif 334#endif
360 335
336static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
337{
338 board_info_t *dm = to_dm9000_board(dev);
339
340 if (!netif_running(dev))
341 return -EINVAL;
342
343 return generic_mii_ioctl(&dm->mii, if_mii(req), cmd, NULL);
344}
345
346/* ethtool ops */
347
348static void dm9000_get_drvinfo(struct net_device *dev,
349 struct ethtool_drvinfo *info)
350{
351 board_info_t *dm = to_dm9000_board(dev);
352
353 strcpy(info->driver, CARDNAME);
354 strcpy(info->version, DRV_VERSION);
355 strcpy(info->bus_info, to_platform_device(dm->dev)->name);
356}
357
358static u32 dm9000_get_msglevel(struct net_device *dev)
359{
360 board_info_t *dm = to_dm9000_board(dev);
361
362 return dm->msg_enable;
363}
364
365static void dm9000_set_msglevel(struct net_device *dev, u32 value)
366{
367 board_info_t *dm = to_dm9000_board(dev);
368
369 dm->msg_enable = value;
370}
371
372static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
373{
374 board_info_t *dm = to_dm9000_board(dev);
375
376 mii_ethtool_gset(&dm->mii, cmd);
377 return 0;
378}
379
380static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
381{
382 board_info_t *dm = to_dm9000_board(dev);
383
384 return mii_ethtool_sset(&dm->mii, cmd);
385}
386
387static int dm9000_nway_reset(struct net_device *dev)
388{
389 board_info_t *dm = to_dm9000_board(dev);
390 return mii_nway_restart(&dm->mii);
391}
392
393static u32 dm9000_get_link(struct net_device *dev)
394{
395 board_info_t *dm = to_dm9000_board(dev);
396 return mii_link_ok(&dm->mii);
397}
398
399#define DM_EEPROM_MAGIC (0x444D394B)
400
401static int dm9000_get_eeprom_len(struct net_device *dev)
402{
403 return 128;
404}
405
406static int dm9000_get_eeprom(struct net_device *dev,
407 struct ethtool_eeprom *ee, u8 *data)
408{
409 board_info_t *dm = to_dm9000_board(dev);
410 int offset = ee->offset;
411 int len = ee->len;
412 int i;
413
414 /* EEPROM access is aligned to two bytes */
415
416 if ((len & 1) != 0 || (offset & 1) != 0)
417 return -EINVAL;
418
419 if (dm->flags & DM9000_PLATF_NO_EEPROM)
420 return -ENOENT;
421
422 ee->magic = DM_EEPROM_MAGIC;
423
424 for (i = 0; i < len; i += 2)
425 dm9000_read_eeprom(dm, (offset + i) / 2, data + i);
426
427 return 0;
428}
429
430static int dm9000_set_eeprom(struct net_device *dev,
431 struct ethtool_eeprom *ee, u8 *data)
432{
433 board_info_t *dm = to_dm9000_board(dev);
434 int offset = ee->offset;
435 int len = ee->len;
436 int i;
437
438 /* EEPROM access is aligned to two bytes */
439
440 if ((len & 1) != 0 || (offset & 1) != 0)
441 return -EINVAL;
442
443 if (dm->flags & DM9000_PLATF_NO_EEPROM)
444 return -ENOENT;
445
446 if (ee->magic != DM_EEPROM_MAGIC)
447 return -EINVAL;
448
449 for (i = 0; i < len; i += 2)
450 dm9000_write_eeprom(dm, (offset + i) / 2, data + i);
451
452 return 0;
453}
454
455static const struct ethtool_ops dm9000_ethtool_ops = {
456 .get_drvinfo = dm9000_get_drvinfo,
457 .get_settings = dm9000_get_settings,
458 .set_settings = dm9000_set_settings,
459 .get_msglevel = dm9000_get_msglevel,
460 .set_msglevel = dm9000_set_msglevel,
461 .nway_reset = dm9000_nway_reset,
462 .get_link = dm9000_get_link,
463 .get_eeprom_len = dm9000_get_eeprom_len,
464 .get_eeprom = dm9000_get_eeprom,
465 .set_eeprom = dm9000_set_eeprom,
466};
467
468
361/* dm9000_release_board 469/* dm9000_release_board
362 * 470 *
363 * release a board, and any mapped resources 471 * release a board, and any mapped resources
@@ -401,6 +509,7 @@ dm9000_probe(struct platform_device *pdev)
401 struct dm9000_plat_data *pdata = pdev->dev.platform_data; 509 struct dm9000_plat_data *pdata = pdev->dev.platform_data;
402 struct board_info *db; /* Point a board information structure */ 510 struct board_info *db; /* Point a board information structure */
403 struct net_device *ndev; 511 struct net_device *ndev;
512 const unsigned char *mac_src;
404 unsigned long base; 513 unsigned long base;
405 int ret = 0; 514 int ret = 0;
406 int iosize; 515 int iosize;
@@ -410,19 +519,22 @@ dm9000_probe(struct platform_device *pdev)
410 /* Init network device */ 519 /* Init network device */
411 ndev = alloc_etherdev(sizeof (struct board_info)); 520 ndev = alloc_etherdev(sizeof (struct board_info));
412 if (!ndev) { 521 if (!ndev) {
413 printk("%s: could not allocate device.\n", CARDNAME); 522 dev_err(&pdev->dev, "could not allocate device.\n");
414 return -ENOMEM; 523 return -ENOMEM;
415 } 524 }
416 525
417 SET_NETDEV_DEV(ndev, &pdev->dev); 526 SET_NETDEV_DEV(ndev, &pdev->dev);
418 527
419 PRINTK2("dm9000_probe()"); 528 dev_dbg(&pdev->dev, "dm9000_probe()");
420 529
421 /* setup board info structure */ 530 /* setup board info structure */
422 db = (struct board_info *) ndev->priv; 531 db = (struct board_info *) ndev->priv;
423 memset(db, 0, sizeof (*db)); 532 memset(db, 0, sizeof (*db));
424 533
534 db->dev = &pdev->dev;
535
425 spin_lock_init(&db->lock); 536 spin_lock_init(&db->lock);
537 mutex_init(&db->addr_lock);
426 538
427 if (pdev->num_resources < 2) { 539 if (pdev->num_resources < 2) {
428 ret = -ENODEV; 540 ret = -ENODEV;
@@ -450,7 +562,7 @@ dm9000_probe(struct platform_device *pdev)
450 562
451 if (db->addr_res == NULL || db->data_res == NULL || 563 if (db->addr_res == NULL || db->data_res == NULL ||
452 db->irq_res == NULL) { 564 db->irq_res == NULL) {
453 printk(KERN_ERR PFX "insufficient resources\n"); 565 dev_err(db->dev, "insufficient resources\n");
454 ret = -ENOENT; 566 ret = -ENOENT;
455 goto out; 567 goto out;
456 } 568 }
@@ -460,7 +572,7 @@ dm9000_probe(struct platform_device *pdev)
460 pdev->name); 572 pdev->name);
461 573
462 if (db->addr_req == NULL) { 574 if (db->addr_req == NULL) {
463 printk(KERN_ERR PFX "cannot claim address reg area\n"); 575 dev_err(db->dev, "cannot claim address reg area\n");
464 ret = -EIO; 576 ret = -EIO;
465 goto out; 577 goto out;
466 } 578 }
@@ -468,7 +580,7 @@ dm9000_probe(struct platform_device *pdev)
468 db->io_addr = ioremap(db->addr_res->start, i); 580 db->io_addr = ioremap(db->addr_res->start, i);
469 581
470 if (db->io_addr == NULL) { 582 if (db->io_addr == NULL) {
471 printk(KERN_ERR "failed to ioremap address reg\n"); 583 dev_err(db->dev, "failed to ioremap address reg\n");
472 ret = -EINVAL; 584 ret = -EINVAL;
473 goto out; 585 goto out;
474 } 586 }
@@ -478,7 +590,7 @@ dm9000_probe(struct platform_device *pdev)
478 pdev->name); 590 pdev->name);
479 591
480 if (db->data_req == NULL) { 592 if (db->data_req == NULL) {
481 printk(KERN_ERR PFX "cannot claim data reg area\n"); 593 dev_err(db->dev, "cannot claim data reg area\n");
482 ret = -EIO; 594 ret = -EIO;
483 goto out; 595 goto out;
484 } 596 }
@@ -486,7 +598,7 @@ dm9000_probe(struct platform_device *pdev)
486 db->io_data = ioremap(db->data_res->start, iosize); 598 db->io_data = ioremap(db->data_res->start, iosize);
487 599
488 if (db->io_data == NULL) { 600 if (db->io_data == NULL) {
489 printk(KERN_ERR "failed to ioremap data reg\n"); 601 dev_err(db->dev,"failed to ioremap data reg\n");
490 ret = -EINVAL; 602 ret = -EINVAL;
491 goto out; 603 goto out;
492 } 604 }
@@ -525,12 +637,14 @@ dm9000_probe(struct platform_device *pdev)
525 637
526 if (pdata->dumpblk != NULL) 638 if (pdata->dumpblk != NULL)
527 db->dumpblk = pdata->dumpblk; 639 db->dumpblk = pdata->dumpblk;
640
641 db->flags = pdata->flags;
528 } 642 }
529 643
530 dm9000_reset(db); 644 dm9000_reset(db);
531 645
532 /* try two times, DM9000 sometimes gets the first read wrong */ 646 /* try two times, DM9000 sometimes gets the first read wrong */
533 for (i = 0; i < 2; i++) { 647 for (i = 0; i < 8; i++) {
534 id_val = ior(db, DM9000_VIDL); 648 id_val = ior(db, DM9000_VIDL);
535 id_val |= (u32)ior(db, DM9000_VIDH) << 8; 649 id_val |= (u32)ior(db, DM9000_VIDH) << 8;
536 id_val |= (u32)ior(db, DM9000_PIDL) << 16; 650 id_val |= (u32)ior(db, DM9000_PIDL) << 16;
@@ -538,11 +652,11 @@ dm9000_probe(struct platform_device *pdev)
538 652
539 if (id_val == DM9000_ID) 653 if (id_val == DM9000_ID)
540 break; 654 break;
541 printk("%s: read wrong id 0x%08x\n", CARDNAME, id_val); 655 dev_err(db->dev, "read wrong id 0x%08x\n", id_val);
542 } 656 }
543 657
544 if (id_val != DM9000_ID) { 658 if (id_val != DM9000_ID) {
545 printk("%s: wrong id: 0x%08x\n", CARDNAME, id_val); 659 dev_err(db->dev, "wrong id: 0x%08x\n", id_val);
546 ret = -ENODEV; 660 ret = -ENODEV;
547 goto out; 661 goto out;
548 } 662 }
@@ -558,13 +672,13 @@ dm9000_probe(struct platform_device *pdev)
558 ndev->watchdog_timeo = msecs_to_jiffies(watchdog); 672 ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
559 ndev->stop = &dm9000_stop; 673 ndev->stop = &dm9000_stop;
560 ndev->set_multicast_list = &dm9000_hash_table; 674 ndev->set_multicast_list = &dm9000_hash_table;
675 ndev->ethtool_ops = &dm9000_ethtool_ops;
676 ndev->do_ioctl = &dm9000_ioctl;
677
561#ifdef CONFIG_NET_POLL_CONTROLLER 678#ifdef CONFIG_NET_POLL_CONTROLLER
562 ndev->poll_controller = &dm9000_poll_controller; 679 ndev->poll_controller = &dm9000_poll_controller;
563#endif 680#endif
564 681
565#ifdef DM9000_PROGRAM_EEPROM
566 program_eeprom(db);
567#endif
568 db->msg_enable = NETIF_MSG_LINK; 682 db->msg_enable = NETIF_MSG_LINK;
569 db->mii.phy_id_mask = 0x1f; 683 db->mii.phy_id_mask = 0x1f;
570 db->mii.reg_num_mask = 0x1f; 684 db->mii.reg_num_mask = 0x1f;
@@ -574,38 +688,37 @@ dm9000_probe(struct platform_device *pdev)
574 db->mii.mdio_read = dm9000_phy_read; 688 db->mii.mdio_read = dm9000_phy_read;
575 db->mii.mdio_write = dm9000_phy_write; 689 db->mii.mdio_write = dm9000_phy_write;
576 690
577 /* Read SROM content */ 691 mac_src = "eeprom";
578 for (i = 0; i < 64; i++)
579 ((u16 *) db->srom)[i] = read_srom_word(db, i);
580 692
581 /* Set Node Address */ 693 /* try reading the node address from the attached EEPROM */
582 for (i = 0; i < 6; i++) 694 for (i = 0; i < 6; i += 2)
583 ndev->dev_addr[i] = db->srom[i]; 695 dm9000_read_eeprom(db, i / 2, ndev->dev_addr+i);
584 696
585 if (!is_valid_ether_addr(ndev->dev_addr)) { 697 if (!is_valid_ether_addr(ndev->dev_addr)) {
586 /* try reading from mac */ 698 /* try reading from mac */
587 699
700 mac_src = "chip";
588 for (i = 0; i < 6; i++) 701 for (i = 0; i < 6; i++)
589 ndev->dev_addr[i] = ior(db, i+DM9000_PAR); 702 ndev->dev_addr[i] = ior(db, i+DM9000_PAR);
590 } 703 }
591 704
592 if (!is_valid_ether_addr(ndev->dev_addr)) 705 if (!is_valid_ether_addr(ndev->dev_addr))
593 printk("%s: Invalid ethernet MAC address. Please " 706 dev_warn(db->dev, "%s: Invalid ethernet MAC address. Please "
594 "set using ifconfig\n", ndev->name); 707 "set using ifconfig\n", ndev->name);
595 708
596 platform_set_drvdata(pdev, ndev); 709 platform_set_drvdata(pdev, ndev);
597 ret = register_netdev(ndev); 710 ret = register_netdev(ndev);
598 711
599 if (ret == 0) { 712 if (ret == 0) {
600 DECLARE_MAC_BUF(mac); 713 DECLARE_MAC_BUF(mac);
601 printk("%s: dm9000 at %p,%p IRQ %d MAC: %s\n", 714 printk("%s: dm9000 at %p,%p IRQ %d MAC: %s (%s)\n",
602 ndev->name, db->io_addr, db->io_data, ndev->irq, 715 ndev->name, db->io_addr, db->io_data, ndev->irq,
603 print_mac(mac, ndev->dev_addr)); 716 print_mac(mac, ndev->dev_addr), mac_src);
604 } 717 }
605 return 0; 718 return 0;
606 719
607out: 720out:
608 printk("%s: not found (%d).\n", CARDNAME, ret); 721 dev_err(db->dev, "not found (%d).\n", ret);
609 722
610 dm9000_release_board(pdev, db); 723 dm9000_release_board(pdev, db);
611 free_netdev(ndev); 724 free_netdev(ndev);
@@ -621,10 +734,22 @@ static int
621dm9000_open(struct net_device *dev) 734dm9000_open(struct net_device *dev)
622{ 735{
623 board_info_t *db = (board_info_t *) dev->priv; 736 board_info_t *db = (board_info_t *) dev->priv;
737 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
624 738
625 PRINTK2("entering dm9000_open\n"); 739 if (netif_msg_ifup(db))
740 dev_dbg(db->dev, "enabling %s\n", dev->name);
626 741
627 if (request_irq(dev->irq, &dm9000_interrupt, DM9000_IRQ_FLAGS, dev->name, dev)) 742 /* If there is no IRQ type specified, default to something that
743 * may work, and tell the user that this is a problem */
744
745 if (irqflags == IRQF_TRIGGER_NONE) {
746 dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
747 irqflags = DEFAULT_TRIGGER;
748 }
749
750 irqflags |= IRQF_SHARED;
751
752 if (request_irq(dev->irq, &dm9000_interrupt, irqflags, dev->name, dev))
628 return -EAGAIN; 753 return -EAGAIN;
629 754
630 /* Initialize DM9000 board */ 755 /* Initialize DM9000 board */
@@ -634,13 +759,6 @@ dm9000_open(struct net_device *dev)
634 /* Init driver variable */ 759 /* Init driver variable */
635 db->dbug_cnt = 0; 760 db->dbug_cnt = 0;
636 761
637 /* set and active a timer process */
638 init_timer(&db->timer);
639 db->timer.expires = DM9000_TIMER_WUT;
640 db->timer.data = (unsigned long) dev;
641 db->timer.function = &dm9000_timer;
642 add_timer(&db->timer);
643
644 mii_check_media(&db->mii, netif_msg_link(db), 1); 762 mii_check_media(&db->mii, netif_msg_link(db), 1);
645 netif_start_queue(dev); 763 netif_start_queue(dev);
646 764
@@ -655,7 +773,7 @@ dm9000_init_dm9000(struct net_device *dev)
655{ 773{
656 board_info_t *db = (board_info_t *) dev->priv; 774 board_info_t *db = (board_info_t *) dev->priv;
657 775
658 PRINTK1("entering %s\n",__FUNCTION__); 776 dm9000_dbg(db, 1, "entering %s\n", __func__);
659 777
660 /* I/O mode */ 778 /* I/O mode */
661 db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */ 779 db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */
@@ -665,6 +783,9 @@ dm9000_init_dm9000(struct net_device *dev)
665 iow(db, DM9000_GPCR, GPCR_GEP_CNTL); /* Let GPIO0 output */ 783 iow(db, DM9000_GPCR, GPCR_GEP_CNTL); /* Let GPIO0 output */
666 iow(db, DM9000_GPR, 0); /* Enable PHY */ 784 iow(db, DM9000_GPR, 0); /* Enable PHY */
667 785
786 if (db->flags & DM9000_PLATF_EXT_PHY)
787 iow(db, DM9000_NCR, NCR_EXT_PHY);
788
668 /* Program operating register */ 789 /* Program operating register */
669 iow(db, DM9000_TCR, 0); /* TX Polling clear */ 790 iow(db, DM9000_TCR, 0); /* TX Polling clear */
670 iow(db, DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */ 791 iow(db, DM9000_BPTR, 0x3f); /* Less 3Kb, 200us */
@@ -698,7 +819,7 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
698 unsigned long flags; 819 unsigned long flags;
699 board_info_t *db = (board_info_t *) dev->priv; 820 board_info_t *db = (board_info_t *) dev->priv;
700 821
701 PRINTK3("dm9000_start_xmit\n"); 822 dm9000_dbg(db, 3, "%s:\n", __func__);
702 823
703 if (db->tx_pkt_cnt > 1) 824 if (db->tx_pkt_cnt > 1)
704 return 1; 825 return 1;
@@ -715,8 +836,8 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
715 /* TX control: First packet immediately send, second packet queue */ 836 /* TX control: First packet immediately send, second packet queue */
716 if (db->tx_pkt_cnt == 1) { 837 if (db->tx_pkt_cnt == 1) {
717 /* Set TX length to DM9000 */ 838 /* Set TX length to DM9000 */
718 iow(db, DM9000_TXPLL, skb->len & 0xff); 839 iow(db, DM9000_TXPLL, skb->len);
719 iow(db, DM9000_TXPLH, (skb->len >> 8) & 0xff); 840 iow(db, DM9000_TXPLH, skb->len >> 8);
720 841
721 /* Issue TX polling command */ 842 /* Issue TX polling command */
722 iow(db, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */ 843 iow(db, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */
@@ -757,10 +878,8 @@ dm9000_stop(struct net_device *ndev)
757{ 878{
758 board_info_t *db = (board_info_t *) ndev->priv; 879 board_info_t *db = (board_info_t *) ndev->priv;
759 880
760 PRINTK1("entering %s\n",__FUNCTION__); 881 if (netif_msg_ifdown(db))
761 882 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
762 /* deleted timer */
763 del_timer(&db->timer);
764 883
765 netif_stop_queue(ndev); 884 netif_stop_queue(ndev);
766 netif_carrier_off(ndev); 885 netif_carrier_off(ndev);
@@ -788,10 +907,13 @@ dm9000_tx_done(struct net_device *dev, board_info_t * db)
788 db->tx_pkt_cnt--; 907 db->tx_pkt_cnt--;
789 dev->stats.tx_packets++; 908 dev->stats.tx_packets++;
790 909
910 if (netif_msg_tx_done(db))
911 dev_dbg(db->dev, "tx done, NSR %02x\n", tx_status);
912
791 /* Queue packet check & send */ 913 /* Queue packet check & send */
792 if (db->tx_pkt_cnt > 0) { 914 if (db->tx_pkt_cnt > 0) {
793 iow(db, DM9000_TXPLL, db->queue_pkt_len & 0xff); 915 iow(db, DM9000_TXPLL, db->queue_pkt_len);
794 iow(db, DM9000_TXPLH, (db->queue_pkt_len >> 8) & 0xff); 916 iow(db, DM9000_TXPLH, db->queue_pkt_len >> 8);
795 iow(db, DM9000_TCR, TCR_TXREQ); 917 iow(db, DM9000_TCR, TCR_TXREQ);
796 dev->trans_start = jiffies; 918 dev->trans_start = jiffies;
797 } 919 }
@@ -803,19 +925,14 @@ static irqreturn_t
803dm9000_interrupt(int irq, void *dev_id) 925dm9000_interrupt(int irq, void *dev_id)
804{ 926{
805 struct net_device *dev = dev_id; 927 struct net_device *dev = dev_id;
806 board_info_t *db; 928 board_info_t *db = (board_info_t *) dev->priv;
807 int int_status; 929 int int_status;
808 u8 reg_save; 930 u8 reg_save;
809 931
810 PRINTK3("entering %s\n",__FUNCTION__); 932 dm9000_dbg(db, 3, "entering %s\n", __func__);
811
812 if (!dev) {
813 PRINTK1("dm9000_interrupt() without DEVICE arg\n");
814 return IRQ_HANDLED;
815 }
816 933
817 /* A real interrupt coming */ 934 /* A real interrupt coming */
818 db = (board_info_t *) dev->priv; 935
819 spin_lock(&db->lock); 936 spin_lock(&db->lock);
820 937
821 /* Save previous register address */ 938 /* Save previous register address */
@@ -828,6 +945,9 @@ dm9000_interrupt(int irq, void *dev_id)
828 int_status = ior(db, DM9000_ISR); /* Got ISR */ 945 int_status = ior(db, DM9000_ISR); /* Got ISR */
829 iow(db, DM9000_ISR, int_status); /* Clear ISR status */ 946 iow(db, DM9000_ISR, int_status); /* Clear ISR status */
830 947
948 if (netif_msg_intr(db))
949 dev_dbg(db->dev, "interrupt status %02x\n", int_status);
950
831 /* Received the coming packet */ 951 /* Received the coming packet */
832 if (int_status & ISR_PRS) 952 if (int_status & ISR_PRS)
833 dm9000_rx(dev); 953 dm9000_rx(dev);
@@ -847,27 +967,9 @@ dm9000_interrupt(int irq, void *dev_id)
847 return IRQ_HANDLED; 967 return IRQ_HANDLED;
848} 968}
849 969
850/*
851 * A periodic timer routine
852 * Dynamic media sense, allocated Rx buffer...
853 */
854static void
855dm9000_timer(unsigned long data)
856{
857 struct net_device *dev = (struct net_device *) data;
858 board_info_t *db = (board_info_t *) dev->priv;
859
860 PRINTK3("dm9000_timer()\n");
861
862 mii_check_media(&db->mii, netif_msg_link(db), 0);
863
864 /* Set timer again */
865 db->timer.expires = DM9000_TIMER_WUT;
866 add_timer(&db->timer);
867}
868
869struct dm9000_rxhdr { 970struct dm9000_rxhdr {
870 u16 RxStatus; 971 u8 RxPktReady;
972 u8 RxStatus;
871 u16 RxLen; 973 u16 RxLen;
872} __attribute__((__packed__)); 974} __attribute__((__packed__));
873 975
@@ -893,7 +995,7 @@ dm9000_rx(struct net_device *dev)
893 995
894 /* Status check: this byte must be 0 or 1 */ 996 /* Status check: this byte must be 0 or 1 */
895 if (rxbyte > DM9000_PKT_RDY) { 997 if (rxbyte > DM9000_PKT_RDY) {
896 printk("status check failed: %d\n", rxbyte); 998 dev_warn(db->dev, "status check fail: %d\n", rxbyte);
897 iow(db, DM9000_RCR, 0x00); /* Stop Device */ 999 iow(db, DM9000_RCR, 0x00); /* Stop Device */
898 iow(db, DM9000_ISR, IMR_PAR); /* Stop INT request */ 1000 iow(db, DM9000_ISR, IMR_PAR); /* Stop INT request */
899 return; 1001 return;
@@ -908,30 +1010,38 @@ dm9000_rx(struct net_device *dev)
908 1010
909 (db->inblk)(db->io_data, &rxhdr, sizeof(rxhdr)); 1011 (db->inblk)(db->io_data, &rxhdr, sizeof(rxhdr));
910 1012
911 RxLen = rxhdr.RxLen; 1013 RxLen = le16_to_cpu(rxhdr.RxLen);
1014
1015 if (netif_msg_rx_status(db))
1016 dev_dbg(db->dev, "RX: status %02x, length %04x\n",
1017 rxhdr.RxStatus, RxLen);
912 1018
913 /* Packet Status check */ 1019 /* Packet Status check */
914 if (RxLen < 0x40) { 1020 if (RxLen < 0x40) {
915 GoodPacket = false; 1021 GoodPacket = false;
916 PRINTK1("Bad Packet received (runt)\n"); 1022 if (netif_msg_rx_err(db))
1023 dev_dbg(db->dev, "RX: Bad Packet (runt)\n");
917 } 1024 }
918 1025
919 if (RxLen > DM9000_PKT_MAX) { 1026 if (RxLen > DM9000_PKT_MAX) {
920 PRINTK1("RST: RX Len:%x\n", RxLen); 1027 dev_dbg(db->dev, "RST: RX Len:%x\n", RxLen);
921 } 1028 }
922 1029
923 if (rxhdr.RxStatus & 0xbf00) { 1030 if (rxhdr.RxStatus & 0xbf) {
924 GoodPacket = false; 1031 GoodPacket = false;
925 if (rxhdr.RxStatus & 0x100) { 1032 if (rxhdr.RxStatus & 0x01) {
926 PRINTK1("fifo error\n"); 1033 if (netif_msg_rx_err(db))
1034 dev_dbg(db->dev, "fifo error\n");
927 dev->stats.rx_fifo_errors++; 1035 dev->stats.rx_fifo_errors++;
928 } 1036 }
929 if (rxhdr.RxStatus & 0x200) { 1037 if (rxhdr.RxStatus & 0x02) {
930 PRINTK1("crc error\n"); 1038 if (netif_msg_rx_err(db))
1039 dev_dbg(db->dev, "crc error\n");
931 dev->stats.rx_crc_errors++; 1040 dev->stats.rx_crc_errors++;
932 } 1041 }
933 if (rxhdr.RxStatus & 0x8000) { 1042 if (rxhdr.RxStatus & 0x80) {
934 PRINTK1("length error\n"); 1043 if (netif_msg_rx_err(db))
1044 dev_dbg(db->dev, "length error\n");
935 dev->stats.rx_length_errors++; 1045 dev->stats.rx_length_errors++;
936 } 1046 }
937 } 1047 }
@@ -960,72 +1070,119 @@ dm9000_rx(struct net_device *dev)
960 } while (rxbyte == DM9000_PKT_RDY); 1070 } while (rxbyte == DM9000_PKT_RDY);
961} 1071}
962 1072
963/* 1073static unsigned int
964 * Read a word data from SROM 1074dm9000_read_locked(board_info_t *db, int reg)
965 */
966static u16
967read_srom_word(board_info_t * db, int offset)
968{ 1075{
969 iow(db, DM9000_EPAR, offset); 1076 unsigned long flags;
970 iow(db, DM9000_EPCR, EPCR_ERPRR); 1077 unsigned int ret;
971 mdelay(8); /* according to the datasheet 200us should be enough, 1078
972 but it doesn't work */ 1079 spin_lock_irqsave(&db->lock, flags);
973 iow(db, DM9000_EPCR, 0x0); 1080 ret = ior(db, reg);
974 return (ior(db, DM9000_EPDRL) + (ior(db, DM9000_EPDRH) << 8)); 1081 spin_unlock_irqrestore(&db->lock, flags);
1082
1083 return ret;
1084}
1085
1086static int dm9000_wait_eeprom(board_info_t *db)
1087{
1088 unsigned int status;
1089 int timeout = 8; /* wait max 8msec */
1090
1091 /* The DM9000 data sheets say we should be able to
1092 * poll the ERRE bit in EPCR to wait for the EEPROM
1093 * operation. From testing several chips, this bit
1094 * does not seem to work.
1095 *
1096 * We attempt to use the bit, but fall back to the
1097 * timeout (which is why we do not return an error
1098 * on expiry) to say that the EEPROM operation has
1099 * completed.
1100 */
1101
1102 while (1) {
1103 status = dm9000_read_locked(db, DM9000_EPCR);
1104
1105 if ((status & EPCR_ERRE) == 0)
1106 break;
1107
1108 if (timeout-- < 0) {
1109 dev_dbg(db->dev, "timeout waiting EEPROM\n");
1110 break;
1111 }
1112 }
1113
1114 return 0;
975} 1115}
976 1116
977#ifdef DM9000_PROGRAM_EEPROM
978/* 1117/*
979 * Write a word data to SROM 1118 * Read a word data from EEPROM
980 */ 1119 */
981static void 1120static void
982write_srom_word(board_info_t * db, int offset, u16 val) 1121dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
983{ 1122{
1123 unsigned long flags;
1124
1125 if (db->flags & DM9000_PLATF_NO_EEPROM) {
1126 to[0] = 0xff;
1127 to[1] = 0xff;
1128 return;
1129 }
1130
1131 mutex_lock(&db->addr_lock);
1132
1133 spin_lock_irqsave(&db->lock, flags);
1134
984 iow(db, DM9000_EPAR, offset); 1135 iow(db, DM9000_EPAR, offset);
985 iow(db, DM9000_EPDRH, ((val >> 8) & 0xff)); 1136 iow(db, DM9000_EPCR, EPCR_ERPRR);
986 iow(db, DM9000_EPDRL, (val & 0xff)); 1137
987 iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW); 1138 spin_unlock_irqrestore(&db->lock, flags);
988 mdelay(8); /* same shit */ 1139
989 iow(db, DM9000_EPCR, 0); 1140 dm9000_wait_eeprom(db);
1141
1142 /* delay for at-least 150uS */
1143 msleep(1);
1144
1145 spin_lock_irqsave(&db->lock, flags);
1146
1147 iow(db, DM9000_EPCR, 0x0);
1148
1149 to[0] = ior(db, DM9000_EPDRL);
1150 to[1] = ior(db, DM9000_EPDRH);
1151
1152 spin_unlock_irqrestore(&db->lock, flags);
1153
1154 mutex_unlock(&db->addr_lock);
990} 1155}
991 1156
992/* 1157/*
993 * Only for development: 1158 * Write a word data to SROM
994 * Here we write static data to the eeprom in case
995 * we don't have valid content on a new board
996 */ 1159 */
997static void 1160static void
998program_eeprom(board_info_t * db) 1161dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
999{ 1162{
1000 u16 eeprom[] = { 0x0c00, 0x007f, 0x1300, /* MAC Address */ 1163 unsigned long flags;
1001 0x0000, /* Autoload: accept nothing */
1002 0x0a46, 0x9000, /* Vendor / Product ID */
1003 0x0000, /* pin control */
1004 0x0000,
1005 }; /* Wake-up mode control */
1006 int i;
1007 for (i = 0; i < 8; i++)
1008 write_srom_word(db, i, eeprom[i]);
1009}
1010#endif
1011 1164
1165 if (db->flags & DM9000_PLATF_NO_EEPROM)
1166 return;
1012 1167
1013/* 1168 mutex_lock(&db->addr_lock);
1014 * Calculate the CRC valude of the Rx packet
1015 * flag = 1 : return the reverse CRC (for the received packet CRC)
1016 * 0 : return the normal CRC (for Hash Table index)
1017 */
1018 1169
1019static unsigned long 1170 spin_lock_irqsave(&db->lock, flags);
1020cal_CRC(unsigned char *Data, unsigned int Len, u8 flag) 1171 iow(db, DM9000_EPAR, offset);
1021{ 1172 iow(db, DM9000_EPDRH, data[1]);
1173 iow(db, DM9000_EPDRL, data[0]);
1174 iow(db, DM9000_EPCR, EPCR_WEP | EPCR_ERPRW);
1175 spin_unlock_irqrestore(&db->lock, flags);
1176
1177 dm9000_wait_eeprom(db);
1022 1178
1023 u32 crc = ether_crc_le(Len, Data); 1179 mdelay(1); /* wait at least 150uS to clear */
1024 1180
1025 if (flag) 1181 spin_lock_irqsave(&db->lock, flags);
1026 return ~crc; 1182 iow(db, DM9000_EPCR, 0);
1183 spin_unlock_irqrestore(&db->lock, flags);
1027 1184
1028 return crc; 1185 mutex_unlock(&db->addr_lock);
1029} 1186}
1030 1187
1031/* 1188/*
@@ -1037,15 +1194,16 @@ dm9000_hash_table(struct net_device *dev)
1037 board_info_t *db = (board_info_t *) dev->priv; 1194 board_info_t *db = (board_info_t *) dev->priv;
1038 struct dev_mc_list *mcptr = dev->mc_list; 1195 struct dev_mc_list *mcptr = dev->mc_list;
1039 int mc_cnt = dev->mc_count; 1196 int mc_cnt = dev->mc_count;
1197 int i, oft;
1040 u32 hash_val; 1198 u32 hash_val;
1041 u16 i, oft, hash_table[4]; 1199 u16 hash_table[4];
1042 unsigned long flags; 1200 unsigned long flags;
1043 1201
1044 PRINTK2("dm9000_hash_table()\n"); 1202 dm9000_dbg(db, 1, "entering %s\n", __func__);
1045 1203
1046 spin_lock_irqsave(&db->lock,flags); 1204 spin_lock_irqsave(&db->lock, flags);
1047 1205
1048 for (i = 0, oft = 0x10; i < 6; i++, oft++) 1206 for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
1049 iow(db, oft, dev->dev_addr[i]); 1207 iow(db, oft, dev->dev_addr[i]);
1050 1208
1051 /* Clear Hash Table */ 1209 /* Clear Hash Table */
@@ -1057,21 +1215,33 @@ dm9000_hash_table(struct net_device *dev)
1057 1215
1058 /* the multicast address in Hash Table : 64 bits */ 1216 /* the multicast address in Hash Table : 64 bits */
1059 for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) { 1217 for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) {
1060 hash_val = cal_CRC((char *) mcptr->dmi_addr, 6, 0) & 0x3f; 1218 hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
1061 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16); 1219 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
1062 } 1220 }
1063 1221
1064 /* Write the hash table to MAC MD table */ 1222 /* Write the hash table to MAC MD table */
1065 for (i = 0, oft = 0x16; i < 4; i++) { 1223 for (i = 0, oft = DM9000_MAR; i < 4; i++) {
1066 iow(db, oft++, hash_table[i] & 0xff); 1224 iow(db, oft++, hash_table[i]);
1067 iow(db, oft++, (hash_table[i] >> 8) & 0xff); 1225 iow(db, oft++, hash_table[i] >> 8);
1068 } 1226 }
1069 1227
1070 spin_unlock_irqrestore(&db->lock,flags); 1228 spin_unlock_irqrestore(&db->lock, flags);
1071} 1229}
1072 1230
1073 1231
1074/* 1232/*
1233 * Sleep, either by using msleep() or if we are suspending, then
1234 * use mdelay() to sleep.
1235 */
1236static void dm9000_msleep(board_info_t *db, unsigned int ms)
1237{
1238 if (db->in_suspend)
1239 mdelay(ms);
1240 else
1241 msleep(ms);
1242}
1243
1244/*
1075 * Read a word from phyxcer 1245 * Read a word from phyxcer
1076 */ 1246 */
1077static int 1247static int
@@ -1082,6 +1252,8 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1082 unsigned int reg_save; 1252 unsigned int reg_save;
1083 int ret; 1253 int ret;
1084 1254
1255 mutex_lock(&db->addr_lock);
1256
1085 spin_lock_irqsave(&db->lock,flags); 1257 spin_lock_irqsave(&db->lock,flags);
1086 1258
1087 /* Save previous register address */ 1259 /* Save previous register address */
@@ -1091,7 +1263,15 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1091 iow(db, DM9000_EPAR, DM9000_PHY | reg); 1263 iow(db, DM9000_EPAR, DM9000_PHY | reg);
1092 1264
1093 iow(db, DM9000_EPCR, 0xc); /* Issue phyxcer read command */ 1265 iow(db, DM9000_EPCR, 0xc); /* Issue phyxcer read command */
1094 udelay(100); /* Wait read complete */ 1266
1267 writeb(reg_save, db->io_addr);
1268 spin_unlock_irqrestore(&db->lock,flags);
1269
1270 dm9000_msleep(db, 1); /* Wait read complete */
1271
1272 spin_lock_irqsave(&db->lock,flags);
1273 reg_save = readb(db->io_addr);
1274
1095 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer read command */ 1275 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer read command */
1096 1276
1097 /* The read data keeps on REG_0D & REG_0E */ 1277 /* The read data keeps on REG_0D & REG_0E */
@@ -1099,9 +1279,9 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1099 1279
1100 /* restore the previous address */ 1280 /* restore the previous address */
1101 writeb(reg_save, db->io_addr); 1281 writeb(reg_save, db->io_addr);
1102
1103 spin_unlock_irqrestore(&db->lock,flags); 1282 spin_unlock_irqrestore(&db->lock,flags);
1104 1283
1284 mutex_unlock(&db->addr_lock);
1105 return ret; 1285 return ret;
1106} 1286}
1107 1287
@@ -1115,6 +1295,8 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1115 unsigned long flags; 1295 unsigned long flags;
1116 unsigned long reg_save; 1296 unsigned long reg_save;
1117 1297
1298 mutex_lock(&db->addr_lock);
1299
1118 spin_lock_irqsave(&db->lock,flags); 1300 spin_lock_irqsave(&db->lock,flags);
1119 1301
1120 /* Save previous register address */ 1302 /* Save previous register address */
@@ -1124,25 +1306,38 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1124 iow(db, DM9000_EPAR, DM9000_PHY | reg); 1306 iow(db, DM9000_EPAR, DM9000_PHY | reg);
1125 1307
1126 /* Fill the written data into REG_0D & REG_0E */ 1308 /* Fill the written data into REG_0D & REG_0E */
1127 iow(db, DM9000_EPDRL, (value & 0xff)); 1309 iow(db, DM9000_EPDRL, value);
1128 iow(db, DM9000_EPDRH, ((value >> 8) & 0xff)); 1310 iow(db, DM9000_EPDRH, value >> 8);
1129 1311
1130 iow(db, DM9000_EPCR, 0xa); /* Issue phyxcer write command */ 1312 iow(db, DM9000_EPCR, 0xa); /* Issue phyxcer write command */
1131 udelay(500); /* Wait write complete */ 1313
1314 writeb(reg_save, db->io_addr);
1315 spin_unlock_irqrestore(&db->lock, flags);
1316
1317 dm9000_msleep(db, 1); /* Wait write complete */
1318
1319 spin_lock_irqsave(&db->lock,flags);
1320 reg_save = readb(db->io_addr);
1321
1132 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer write command */ 1322 iow(db, DM9000_EPCR, 0x0); /* Clear phyxcer write command */
1133 1323
1134 /* restore the previous address */ 1324 /* restore the previous address */
1135 writeb(reg_save, db->io_addr); 1325 writeb(reg_save, db->io_addr);
1136 1326
1137 spin_unlock_irqrestore(&db->lock,flags); 1327 spin_unlock_irqrestore(&db->lock, flags);
1328 mutex_unlock(&db->addr_lock);
1138} 1329}
1139 1330
1140static int 1331static int
1141dm9000_drv_suspend(struct platform_device *dev, pm_message_t state) 1332dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
1142{ 1333{
1143 struct net_device *ndev = platform_get_drvdata(dev); 1334 struct net_device *ndev = platform_get_drvdata(dev);
1335 board_info_t *db;
1144 1336
1145 if (ndev) { 1337 if (ndev) {
1338 db = (board_info_t *) ndev->priv;
1339 db->in_suspend = 1;
1340
1146 if (netif_running(ndev)) { 1341 if (netif_running(ndev)) {
1147 netif_device_detach(ndev); 1342 netif_device_detach(ndev);
1148 dm9000_shutdown(ndev); 1343 dm9000_shutdown(ndev);
@@ -1165,6 +1360,8 @@ dm9000_drv_resume(struct platform_device *dev)
1165 1360
1166 netif_device_attach(ndev); 1361 netif_device_attach(ndev);
1167 } 1362 }
1363
1364 db->in_suspend = 0;
1168 } 1365 }
1169 return 0; 1366 return 0;
1170} 1367}
@@ -1180,8 +1377,7 @@ dm9000_drv_remove(struct platform_device *pdev)
1180 dm9000_release_board(pdev, (board_info_t *) ndev->priv); 1377 dm9000_release_board(pdev, (board_info_t *) ndev->priv);
1181 free_netdev(ndev); /* free device structure */ 1378 free_netdev(ndev); /* free device structure */
1182 1379
1183 PRINTK1("clean_module() exit\n"); 1380 dev_dbg(&pdev->dev, "released and freed device\n");
1184
1185 return 0; 1381 return 0;
1186} 1382}
1187 1383
@@ -1199,7 +1395,7 @@ static struct platform_driver dm9000_driver = {
1199static int __init 1395static int __init
1200dm9000_init(void) 1396dm9000_init(void)
1201{ 1397{
1202 printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME); 1398 printk(KERN_INFO "%s Ethernet Driver, V%s\n", CARDNAME, DRV_VERSION);
1203 1399
1204 return platform_driver_register(&dm9000_driver); /* search board and register */ 1400 return platform_driver_register(&dm9000_driver); /* search board and register */
1205} 1401}
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 7c5b05a82f0e..d4ee8ec34b56 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -926,8 +926,6 @@ e1000_probe(struct pci_dev *pdev,
926{ 926{
927 struct net_device *netdev; 927 struct net_device *netdev;
928 struct e1000_adapter *adapter; 928 struct e1000_adapter *adapter;
929 unsigned long mmio_start, mmio_len;
930 unsigned long flash_start, flash_len;
931 929
932 static int cards_found = 0; 930 static int cards_found = 0;
933 static int global_quad_port_a = 0; /* global ksp3 port a indication */ 931 static int global_quad_port_a = 0; /* global ksp3 port a indication */
@@ -970,11 +968,9 @@ e1000_probe(struct pci_dev *pdev,
970 adapter->hw.back = adapter; 968 adapter->hw.back = adapter;
971 adapter->msg_enable = (1 << debug) - 1; 969 adapter->msg_enable = (1 << debug) - 1;
972 970
973 mmio_start = pci_resource_start(pdev, BAR_0);
974 mmio_len = pci_resource_len(pdev, BAR_0);
975
976 err = -EIO; 971 err = -EIO;
977 adapter->hw.hw_addr = ioremap(mmio_start, mmio_len); 972 adapter->hw.hw_addr = ioremap(pci_resource_start(pdev, BAR_0),
973 pci_resource_len(pdev, BAR_0));
978 if (!adapter->hw.hw_addr) 974 if (!adapter->hw.hw_addr)
979 goto err_ioremap; 975 goto err_ioremap;
980 976
@@ -1009,10 +1005,6 @@ e1000_probe(struct pci_dev *pdev,
1009#endif 1005#endif
1010 strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1); 1006 strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
1011 1007
1012 netdev->mem_start = mmio_start;
1013 netdev->mem_end = mmio_start + mmio_len;
1014 netdev->base_addr = adapter->hw.io_base;
1015
1016 adapter->bd_number = cards_found; 1008 adapter->bd_number = cards_found;
1017 1009
1018 /* setup the private structure */ 1010 /* setup the private structure */
@@ -1025,9 +1017,9 @@ e1000_probe(struct pci_dev *pdev,
1025 * because it depends on mac_type */ 1017 * because it depends on mac_type */
1026 if ((adapter->hw.mac_type == e1000_ich8lan) && 1018 if ((adapter->hw.mac_type == e1000_ich8lan) &&
1027 (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { 1019 (pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) {
1028 flash_start = pci_resource_start(pdev, 1); 1020 adapter->hw.flash_address =
1029 flash_len = pci_resource_len(pdev, 1); 1021 ioremap(pci_resource_start(pdev, 1),
1030 adapter->hw.flash_address = ioremap(flash_start, flash_len); 1022 pci_resource_len(pdev, 1));
1031 if (!adapter->hw.flash_address) 1023 if (!adapter->hw.flash_address)
1032 goto err_flashmap; 1024 goto err_flashmap;
1033 } 1025 }
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index d4843d014bc9..801b4d9cd972 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -166,21 +166,24 @@
166 * Hardware access: 166 * Hardware access:
167 */ 167 */
168 168
169#define DEV_NEED_TIMERIRQ 0x0001 /* set the timer irq flag in the irq mask */ 169#define DEV_NEED_TIMERIRQ 0x00001 /* set the timer irq flag in the irq mask */
170#define DEV_NEED_LINKTIMER 0x0002 /* poll link settings. Relies on the timer irq */ 170#define DEV_NEED_LINKTIMER 0x00002 /* poll link settings. Relies on the timer irq */
171#define DEV_HAS_LARGEDESC 0x0004 /* device supports jumbo frames and needs packet format 2 */ 171#define DEV_HAS_LARGEDESC 0x00004 /* device supports jumbo frames and needs packet format 2 */
172#define DEV_HAS_HIGH_DMA 0x0008 /* device supports 64bit dma */ 172#define DEV_HAS_HIGH_DMA 0x00008 /* device supports 64bit dma */
173#define DEV_HAS_CHECKSUM 0x0010 /* device supports tx and rx checksum offloads */ 173#define DEV_HAS_CHECKSUM 0x00010 /* device supports tx and rx checksum offloads */
174#define DEV_HAS_VLAN 0x0020 /* device supports vlan tagging and striping */ 174#define DEV_HAS_VLAN 0x00020 /* device supports vlan tagging and striping */
175#define DEV_HAS_MSI 0x0040 /* device supports MSI */ 175#define DEV_HAS_MSI 0x00040 /* device supports MSI */
176#define DEV_HAS_MSI_X 0x0080 /* device supports MSI-X */ 176#define DEV_HAS_MSI_X 0x00080 /* device supports MSI-X */
177#define DEV_HAS_POWER_CNTRL 0x0100 /* device supports power savings */ 177#define DEV_HAS_POWER_CNTRL 0x00100 /* device supports power savings */
178#define DEV_HAS_PAUSEFRAME_TX 0x0200 /* device supports tx pause frames */ 178#define DEV_HAS_STATISTICS_V1 0x00200 /* device supports hw statistics version 1 */
179#define DEV_HAS_STATISTICS_V1 0x0400 /* device supports hw statistics version 1 */ 179#define DEV_HAS_STATISTICS_V2 0x00400 /* device supports hw statistics version 2 */
180#define DEV_HAS_STATISTICS_V2 0x0800 /* device supports hw statistics version 2 */ 180#define DEV_HAS_TEST_EXTENDED 0x00800 /* device supports extended diagnostic test */
181#define DEV_HAS_TEST_EXTENDED 0x1000 /* device supports extended diagnostic test */ 181#define DEV_HAS_MGMT_UNIT 0x01000 /* device supports management unit */
182#define DEV_HAS_MGMT_UNIT 0x2000 /* device supports management unit */ 182#define DEV_HAS_CORRECT_MACADDR 0x02000 /* device supports correct mac address order */
183#define DEV_HAS_CORRECT_MACADDR 0x4000 /* device supports correct mac address order */ 183#define DEV_HAS_COLLISION_FIX 0x04000 /* device supports tx collision fix */
184#define DEV_HAS_PAUSEFRAME_TX_V1 0x08000 /* device supports tx pause frames version 1 */
185#define DEV_HAS_PAUSEFRAME_TX_V2 0x10000 /* device supports tx pause frames version 2 */
186#define DEV_HAS_PAUSEFRAME_TX_V3 0x20000 /* device supports tx pause frames version 3 */
184 187
185enum { 188enum {
186 NvRegIrqStatus = 0x000, 189 NvRegIrqStatus = 0x000,
@@ -266,9 +269,12 @@ enum {
266#define NVREG_RNDSEED_FORCE3 0x7400 269#define NVREG_RNDSEED_FORCE3 0x7400
267 270
268 NvRegTxDeferral = 0xA0, 271 NvRegTxDeferral = 0xA0,
269#define NVREG_TX_DEFERRAL_DEFAULT 0x15050f 272#define NVREG_TX_DEFERRAL_DEFAULT 0x15050f
270#define NVREG_TX_DEFERRAL_RGMII_10_100 0x16070f 273#define NVREG_TX_DEFERRAL_RGMII_10_100 0x16070f
271#define NVREG_TX_DEFERRAL_RGMII_1000 0x14050f 274#define NVREG_TX_DEFERRAL_RGMII_1000 0x14050f
275#define NVREG_TX_DEFERRAL_RGMII_STRETCH_10 0x16190f
276#define NVREG_TX_DEFERRAL_RGMII_STRETCH_100 0x16300f
277#define NVREG_TX_DEFERRAL_MII_STRETCH 0x152000
272 NvRegRxDeferral = 0xA4, 278 NvRegRxDeferral = 0xA4,
273#define NVREG_RX_DEFERRAL_DEFAULT 0x16 279#define NVREG_RX_DEFERRAL_DEFAULT 0x16
274 NvRegMacAddrA = 0xA8, 280 NvRegMacAddrA = 0xA8,
@@ -318,8 +324,10 @@ enum {
318 NvRegTxRingPhysAddrHigh = 0x148, 324 NvRegTxRingPhysAddrHigh = 0x148,
319 NvRegRxRingPhysAddrHigh = 0x14C, 325 NvRegRxRingPhysAddrHigh = 0x14C,
320 NvRegTxPauseFrame = 0x170, 326 NvRegTxPauseFrame = 0x170,
321#define NVREG_TX_PAUSEFRAME_DISABLE 0x01ff0080 327#define NVREG_TX_PAUSEFRAME_DISABLE 0x0fff0080
322#define NVREG_TX_PAUSEFRAME_ENABLE 0x01800010 328#define NVREG_TX_PAUSEFRAME_ENABLE_V1 0x01800010
329#define NVREG_TX_PAUSEFRAME_ENABLE_V2 0x056003f0
330#define NVREG_TX_PAUSEFRAME_ENABLE_V3 0x09f00880
323 NvRegMIIStatus = 0x180, 331 NvRegMIIStatus = 0x180,
324#define NVREG_MIISTAT_ERROR 0x0001 332#define NVREG_MIISTAT_ERROR 0x0001
325#define NVREG_MIISTAT_LINKCHANGE 0x0008 333#define NVREG_MIISTAT_LINKCHANGE 0x0008
@@ -2751,7 +2759,12 @@ static void nv_update_pause(struct net_device *dev, u32 pause_flags)
2751 if (np->pause_flags & NV_PAUSEFRAME_TX_CAPABLE) { 2759 if (np->pause_flags & NV_PAUSEFRAME_TX_CAPABLE) {
2752 u32 regmisc = readl(base + NvRegMisc1) & ~NVREG_MISC1_PAUSE_TX; 2760 u32 regmisc = readl(base + NvRegMisc1) & ~NVREG_MISC1_PAUSE_TX;
2753 if (pause_flags & NV_PAUSEFRAME_TX_ENABLE) { 2761 if (pause_flags & NV_PAUSEFRAME_TX_ENABLE) {
2754 writel(NVREG_TX_PAUSEFRAME_ENABLE, base + NvRegTxPauseFrame); 2762 u32 pause_enable = NVREG_TX_PAUSEFRAME_ENABLE_V1;
2763 if (np->driver_data & DEV_HAS_PAUSEFRAME_TX_V2)
2764 pause_enable = NVREG_TX_PAUSEFRAME_ENABLE_V2;
2765 if (np->driver_data & DEV_HAS_PAUSEFRAME_TX_V3)
2766 pause_enable = NVREG_TX_PAUSEFRAME_ENABLE_V3;
2767 writel(pause_enable, base + NvRegTxPauseFrame);
2755 writel(regmisc|NVREG_MISC1_PAUSE_TX, base + NvRegMisc1); 2768 writel(regmisc|NVREG_MISC1_PAUSE_TX, base + NvRegMisc1);
2756 np->pause_flags |= NV_PAUSEFRAME_TX_ENABLE; 2769 np->pause_flags |= NV_PAUSEFRAME_TX_ENABLE;
2757 } else { 2770 } else {
@@ -2785,6 +2798,7 @@ static int nv_update_linkspeed(struct net_device *dev)
2785 int retval = 0; 2798 int retval = 0;
2786 u32 control_1000, status_1000, phyreg, pause_flags, txreg; 2799 u32 control_1000, status_1000, phyreg, pause_flags, txreg;
2787 u32 txrxFlags = 0; 2800 u32 txrxFlags = 0;
2801 u32 phy_exp;
2788 2802
2789 /* BMSR_LSTATUS is latched, read it twice: 2803 /* BMSR_LSTATUS is latched, read it twice:
2790 * we want the current value. 2804 * we want the current value.
@@ -2912,13 +2926,25 @@ set_speed:
2912 phyreg |= PHY_1000; 2926 phyreg |= PHY_1000;
2913 writel(phyreg, base + NvRegPhyInterface); 2927 writel(phyreg, base + NvRegPhyInterface);
2914 2928
2929 phy_exp = mii_rw(dev, np->phyaddr, MII_EXPANSION, MII_READ) & EXPANSION_NWAY; /* autoneg capable */
2915 if (phyreg & PHY_RGMII) { 2930 if (phyreg & PHY_RGMII) {
2916 if ((np->linkspeed & NVREG_LINKSPEED_MASK) == NVREG_LINKSPEED_1000) 2931 if ((np->linkspeed & NVREG_LINKSPEED_MASK) == NVREG_LINKSPEED_1000) {
2917 txreg = NVREG_TX_DEFERRAL_RGMII_1000; 2932 txreg = NVREG_TX_DEFERRAL_RGMII_1000;
2918 else 2933 } else {
2919 txreg = NVREG_TX_DEFERRAL_RGMII_10_100; 2934 if (!phy_exp && !np->duplex && (np->driver_data & DEV_HAS_COLLISION_FIX)) {
2935 if ((np->linkspeed & NVREG_LINKSPEED_MASK) == NVREG_LINKSPEED_10)
2936 txreg = NVREG_TX_DEFERRAL_RGMII_STRETCH_10;
2937 else
2938 txreg = NVREG_TX_DEFERRAL_RGMII_STRETCH_100;
2939 } else {
2940 txreg = NVREG_TX_DEFERRAL_RGMII_10_100;
2941 }
2942 }
2920 } else { 2943 } else {
2921 txreg = NVREG_TX_DEFERRAL_DEFAULT; 2944 if (!phy_exp && !np->duplex && (np->driver_data & DEV_HAS_COLLISION_FIX))
2945 txreg = NVREG_TX_DEFERRAL_MII_STRETCH;
2946 else
2947 txreg = NVREG_TX_DEFERRAL_DEFAULT;
2922 } 2948 }
2923 writel(txreg, base + NvRegTxDeferral); 2949 writel(txreg, base + NvRegTxDeferral);
2924 2950
@@ -5155,7 +5181,9 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
5155 } 5181 }
5156 5182
5157 np->pause_flags = NV_PAUSEFRAME_RX_CAPABLE | NV_PAUSEFRAME_RX_REQ | NV_PAUSEFRAME_AUTONEG; 5183 np->pause_flags = NV_PAUSEFRAME_RX_CAPABLE | NV_PAUSEFRAME_RX_REQ | NV_PAUSEFRAME_AUTONEG;
5158 if (id->driver_data & DEV_HAS_PAUSEFRAME_TX) { 5184 if ((id->driver_data & DEV_HAS_PAUSEFRAME_TX_V1) ||
5185 (id->driver_data & DEV_HAS_PAUSEFRAME_TX_V2) ||
5186 (id->driver_data & DEV_HAS_PAUSEFRAME_TX_V3)) {
5159 np->pause_flags |= NV_PAUSEFRAME_TX_CAPABLE | NV_PAUSEFRAME_TX_REQ; 5187 np->pause_flags |= NV_PAUSEFRAME_TX_CAPABLE | NV_PAUSEFRAME_TX_REQ;
5160 } 5188 }
5161 5189
@@ -5559,107 +5587,107 @@ static struct pci_device_id pci_tbl[] = {
5559 }, 5587 },
5560 { /* MCP55 Ethernet Controller */ 5588 { /* MCP55 Ethernet Controller */
5561 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14), 5589 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14),
5562 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5590 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
5563 }, 5591 },
5564 { /* MCP55 Ethernet Controller */ 5592 { /* MCP55 Ethernet Controller */
5565 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15), 5593 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15),
5566 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT, 5594 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT,
5567 }, 5595 },
5568 { /* MCP61 Ethernet Controller */ 5596 { /* MCP61 Ethernet Controller */
5569 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_16), 5597 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_16),
5570 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5598 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5571 }, 5599 },
5572 { /* MCP61 Ethernet Controller */ 5600 { /* MCP61 Ethernet Controller */
5573 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_17), 5601 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_17),
5574 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5602 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5575 }, 5603 },
5576 { /* MCP61 Ethernet Controller */ 5604 { /* MCP61 Ethernet Controller */
5577 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_18), 5605 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_18),
5578 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5606 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5579 }, 5607 },
5580 { /* MCP61 Ethernet Controller */ 5608 { /* MCP61 Ethernet Controller */
5581 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_19), 5609 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_19),
5582 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5610 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5583 }, 5611 },
5584 { /* MCP65 Ethernet Controller */ 5612 { /* MCP65 Ethernet Controller */
5585 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_20), 5613 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_20),
5586 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5614 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5587 }, 5615 },
5588 { /* MCP65 Ethernet Controller */ 5616 { /* MCP65 Ethernet Controller */
5589 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_21), 5617 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_21),
5590 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5618 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5591 }, 5619 },
5592 { /* MCP65 Ethernet Controller */ 5620 { /* MCP65 Ethernet Controller */
5593 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_22), 5621 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_22),
5594 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5622 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5595 }, 5623 },
5596 { /* MCP65 Ethernet Controller */ 5624 { /* MCP65 Ethernet Controller */
5597 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_23), 5625 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_23),
5598 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5626 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5599 }, 5627 },
5600 { /* MCP67 Ethernet Controller */ 5628 { /* MCP67 Ethernet Controller */
5601 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_24), 5629 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_24),
5602 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5630 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5603 }, 5631 },
5604 { /* MCP67 Ethernet Controller */ 5632 { /* MCP67 Ethernet Controller */
5605 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_25), 5633 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_25),
5606 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5634 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5607 }, 5635 },
5608 { /* MCP67 Ethernet Controller */ 5636 { /* MCP67 Ethernet Controller */
5609 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_26), 5637 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_26),
5610 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5638 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5611 }, 5639 },
5612 { /* MCP67 Ethernet Controller */ 5640 { /* MCP67 Ethernet Controller */
5613 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_27), 5641 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_27),
5614 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5642 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR,
5615 }, 5643 },
5616 { /* MCP73 Ethernet Controller */ 5644 { /* MCP73 Ethernet Controller */
5617 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_28), 5645 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_28),
5618 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5646 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5619 }, 5647 },
5620 { /* MCP73 Ethernet Controller */ 5648 { /* MCP73 Ethernet Controller */
5621 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_29), 5649 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_29),
5622 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5650 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5623 }, 5651 },
5624 { /* MCP73 Ethernet Controller */ 5652 { /* MCP73 Ethernet Controller */
5625 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_30), 5653 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_30),
5626 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5654 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5627 }, 5655 },
5628 { /* MCP73 Ethernet Controller */ 5656 { /* MCP73 Ethernet Controller */
5629 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_31), 5657 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_31),
5630 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5658 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL|DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5631 }, 5659 },
5632 { /* MCP77 Ethernet Controller */ 5660 { /* MCP77 Ethernet Controller */
5633 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_32), 5661 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_32),
5634 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5662 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5635 }, 5663 },
5636 { /* MCP77 Ethernet Controller */ 5664 { /* MCP77 Ethernet Controller */
5637 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_33), 5665 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_33),
5638 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5666 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5639 }, 5667 },
5640 { /* MCP77 Ethernet Controller */ 5668 { /* MCP77 Ethernet Controller */
5641 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_34), 5669 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_34),
5642 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5670 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5643 }, 5671 },
5644 { /* MCP77 Ethernet Controller */ 5672 { /* MCP77 Ethernet Controller */
5645 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_35), 5673 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_35),
5646 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5674 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5647 }, 5675 },
5648 { /* MCP79 Ethernet Controller */ 5676 { /* MCP79 Ethernet Controller */
5649 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_36), 5677 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_36),
5650 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5678 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5651 }, 5679 },
5652 { /* MCP79 Ethernet Controller */ 5680 { /* MCP79 Ethernet Controller */
5653 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_37), 5681 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_37),
5654 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5682 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5655 }, 5683 },
5656 { /* MCP79 Ethernet Controller */ 5684 { /* MCP79 Ethernet Controller */
5657 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_38), 5685 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_38),
5658 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5686 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5659 }, 5687 },
5660 { /* MCP79 Ethernet Controller */ 5688 { /* MCP79 Ethernet Controller */
5661 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_39), 5689 PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_39),
5662 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR, 5690 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX,
5663 }, 5691 },
5664 {0,}, 5692 {0,},
5665}; 5693};
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c
index 679dfdb6807f..79b317b88c86 100644
--- a/drivers/net/mlx4/mr.c
+++ b/drivers/net/mlx4/mr.c
@@ -578,13 +578,6 @@ int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages,
578 goto err_free; 578 goto err_free;
579 } 579 }
580 580
581 fmr->mpt = mlx4_table_find(&priv->mr_table.dmpt_table,
582 key_to_hw_index(fmr->mr.key), NULL);
583 if (!fmr->mpt) {
584 err = -ENOMEM;
585 goto err_free;
586 }
587
588 return 0; 581 return 0;
589 582
590err_free: 583err_free:
@@ -595,7 +588,19 @@ EXPORT_SYMBOL_GPL(mlx4_fmr_alloc);
595 588
596int mlx4_fmr_enable(struct mlx4_dev *dev, struct mlx4_fmr *fmr) 589int mlx4_fmr_enable(struct mlx4_dev *dev, struct mlx4_fmr *fmr)
597{ 590{
598 return mlx4_mr_enable(dev, &fmr->mr); 591 struct mlx4_priv *priv = mlx4_priv(dev);
592 int err;
593
594 err = mlx4_mr_enable(dev, &fmr->mr);
595 if (err)
596 return err;
597
598 fmr->mpt = mlx4_table_find(&priv->mr_table.dmpt_table,
599 key_to_hw_index(fmr->mr.key), NULL);
600 if (!fmr->mpt)
601 return -ENOMEM;
602
603 return 0;
599} 604}
600EXPORT_SYMBOL_GPL(mlx4_fmr_enable); 605EXPORT_SYMBOL_GPL(mlx4_fmr_enable);
601 606
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 31e047dd7bb3..501e451be911 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -309,8 +309,8 @@ static ssize_t show_local_mac(struct netconsole_target *nt, char *buf)
309 struct net_device *dev = nt->np.dev; 309 struct net_device *dev = nt->np.dev;
310 310
311 DECLARE_MAC_BUF(mac); 311 DECLARE_MAC_BUF(mac);
312 return snprintf(buf, PAGE_SIZE, "%s\n", 312 return snprintf(buf, PAGE_SIZE, "%s\n", dev ?
313 print_mac(mac, dev->dev_addr)); 313 print_mac(mac, dev->dev_addr) : "ff:ff:ff:ff:ff:ff");
314} 314}
315 315
316static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf) 316static ssize_t show_remote_mac(struct netconsole_target *nt, char *buf)
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c
index 6b3384a24f07..26aa8fe1fb2d 100644
--- a/drivers/net/ni52.c
+++ b/drivers/net/ni52.c
@@ -33,20 +33,20 @@
33 * I have also done a look in the following sources: (mail me if you need them) 33 * I have also done a look in the following sources: (mail me if you need them)
34 * crynwr-packet-driver by Russ Nelson 34 * crynwr-packet-driver by Russ Nelson
35 * Garret A. Wollman's (fourth) i82586-driver for BSD 35 * Garret A. Wollman's (fourth) i82586-driver for BSD
36 * (before getting an i82596 (yes 596 not 586) manual, the existing drivers helped 36 * (before getting an i82596 (yes 596 not 586) manual, the existing drivers
37 * me a lot to understand this tricky chip.) 37 * helped me a lot to understand this tricky chip.)
38 * 38 *
39 * Known Problems: 39 * Known Problems:
40 * The internal sysbus seems to be slow. So we often lose packets because of 40 * The internal sysbus seems to be slow. So we often lose packets because of
41 * overruns while receiving from a fast remote host. 41 * overruns while receiving from a fast remote host.
42 * This can slow down TCP connections. Maybe the newer ni5210 cards are better. 42 * This can slow down TCP connections. Maybe the newer ni5210 cards are
43 * my experience is, that if a machine sends with more than about 500-600K/s 43 * better. My experience is, that if a machine sends with more than about
44 * the fifo/sysbus overflows. 44 * 500-600K/s the fifo/sysbus overflows.
45 * 45 *
46 * IMPORTANT NOTE: 46 * IMPORTANT NOTE:
47 * On fast networks, it's a (very) good idea to have 16K shared memory. With 47 * On fast networks, it's a (very) good idea to have 16K shared memory. With
48 * 8K, we can store only 4 receive frames, so it can (easily) happen that a remote 48 * 8K, we can store only 4 receive frames, so it can (easily) happen that a
49 * machine 'overruns' our system. 49 * remote machine 'overruns' our system.
50 * 50 *
51 * Known i82586/card problems (I'm sure, there are many more!): 51 * Known i82586/card problems (I'm sure, there are many more!):
52 * Running the NOP-mode, the i82586 sometimes seems to forget to report 52 * Running the NOP-mode, the i82586 sometimes seems to forget to report
@@ -60,7 +60,8 @@
60 * 60 *
61 * results from ftp performance tests with Linux 1.2.5 61 * results from ftp performance tests with Linux 1.2.5
62 * send and receive about 350-400 KByte/s (peak up to 460 kbytes/s) 62 * send and receive about 350-400 KByte/s (peak up to 460 kbytes/s)
63 * sending in NOP-mode: peak performance up to 530K/s (but better don't run this mode) 63 * sending in NOP-mode: peak performance up to 530K/s (but better don't
64 * run this mode)
64 */ 65 */
65 66
66/* 67/*
@@ -94,7 +95,8 @@
94 * 95 *
95 * 26.March.94: patches for Linux 1.0 and iomem-auto-probe (MH) 96 * 26.March.94: patches for Linux 1.0 and iomem-auto-probe (MH)
96 * 97 *
97 * 30.Sep.93: Added nop-chain .. driver now runs with only one Xmit-Buff, too (MH) 98 * 30.Sep.93: Added nop-chain .. driver now runs with only one Xmit-Buff,
99 * too (MH)
98 * 100 *
99 * < 30.Sep.93: first versions 101 * < 30.Sep.93: first versions
100 */ 102 */
@@ -102,7 +104,7 @@
102static int debuglevel; /* debug-printk 0: off 1: a few 2: more */ 104static int debuglevel; /* debug-printk 0: off 1: a few 2: more */
103static int automatic_resume; /* experimental .. better should be zero */ 105static int automatic_resume; /* experimental .. better should be zero */
104static int rfdadd; /* rfdadd=1 may be better for 8K MEM cards */ 106static int rfdadd; /* rfdadd=1 may be better for 8K MEM cards */
105static int fifo=0x8; /* don't change */ 107static int fifo = 0x8; /* don't change */
106 108
107#include <linux/module.h> 109#include <linux/module.h>
108#include <linux/kernel.h> 110#include <linux/kernel.h>
@@ -127,14 +129,15 @@ static int fifo=0x8; /* don't change */
127#define DEBUG /* debug on */ 129#define DEBUG /* debug on */
128#define SYSBUSVAL 1 /* 8 Bit */ 130#define SYSBUSVAL 1 /* 8 Bit */
129 131
130#define ni_attn586() {outb(0,dev->base_addr+NI52_ATTENTION);} 132#define ni_attn586() { outb(0, dev->base_addr + NI52_ATTENTION); }
131#define ni_reset586() {outb(0,dev->base_addr+NI52_RESET);} 133#define ni_reset586() { outb(0, dev->base_addr + NI52_RESET); }
132#define ni_disint() {outb(0,dev->base_addr+NI52_INTDIS);} 134#define ni_disint() { outb(0, dev->base_addr + NI52_INTDIS); }
133#define ni_enaint() {outb(0,dev->base_addr+NI52_INTENA);} 135#define ni_enaint() { outb(0, dev->base_addr + NI52_INTENA); }
134 136
135#define make32(ptr16) (p->memtop + (short) (ptr16) ) 137#define make32(ptr16) (p->memtop + (short) (ptr16))
136#define make24(ptr32) ( ((char *) (ptr32)) - p->base) 138#define make24(ptr32) ((unsigned long)(ptr32)) - p->base
137#define make16(ptr32) ((unsigned short) ((unsigned long)(ptr32) - (unsigned long) p->memtop )) 139#define make16(ptr32) ((unsigned short) ((unsigned long)(ptr32)\
140 - (unsigned long) p->memtop))
138 141
139/******************* how to calculate the buffers ***************************** 142/******************* how to calculate the buffers *****************************
140 143
@@ -159,96 +162,112 @@ sizeof(nop_cmd) = 8;
159 162
160/**************************************************************************/ 163/**************************************************************************/
161 164
162/* different DELAYs */
163#define DELAY(x) mdelay(32 * x);
164#define DELAY_16(); { udelay(16); }
165#define DELAY_18(); { udelay(4); }
166
167/* wait for command with timeout: */
168#define WAIT_4_SCB_CMD() \
169{ int i; \
170 for(i=0;i<16384;i++) { \
171 if(!p->scb->cmd_cuc) break; \
172 DELAY_18(); \
173 if(i == 16383) { \
174 printk("%s: scb_cmd timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_cuc,p->scb->cus); \
175 if(!p->reseted) { p->reseted = 1; ni_reset586(); } } } }
176
177#define WAIT_4_SCB_CMD_RUC() { int i; \
178 for(i=0;i<16384;i++) { \
179 if(!p->scb->cmd_ruc) break; \
180 DELAY_18(); \
181 if(i == 16383) { \
182 printk("%s: scb_cmd (ruc) timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_ruc,p->scb->rus); \
183 if(!p->reseted) { p->reseted = 1; ni_reset586(); } } } }
184
185#define WAIT_4_STAT_COMPL(addr) { int i; \
186 for(i=0;i<32767;i++) { \
187 if((addr)->cmd_status & STAT_COMPL) break; \
188 DELAY_16(); DELAY_16(); } }
189 165
190#define NI52_TOTAL_SIZE 16 166#define NI52_TOTAL_SIZE 16
191#define NI52_ADDR0 0x02 167#define NI52_ADDR0 0x02
192#define NI52_ADDR1 0x07 168#define NI52_ADDR1 0x07
193#define NI52_ADDR2 0x01 169#define NI52_ADDR2 0x01
194 170
195static int ni52_probe1(struct net_device *dev,int ioaddr); 171static int ni52_probe1(struct net_device *dev, int ioaddr);
196static irqreturn_t ni52_interrupt(int irq,void *dev_id); 172static irqreturn_t ni52_interrupt(int irq, void *dev_id);
197static int ni52_open(struct net_device *dev); 173static int ni52_open(struct net_device *dev);
198static int ni52_close(struct net_device *dev); 174static int ni52_close(struct net_device *dev);
199static int ni52_send_packet(struct sk_buff *,struct net_device *); 175static int ni52_send_packet(struct sk_buff *, struct net_device *);
200static struct net_device_stats *ni52_get_stats(struct net_device *dev); 176static struct net_device_stats *ni52_get_stats(struct net_device *dev);
201static void set_multicast_list(struct net_device *dev); 177static void set_multicast_list(struct net_device *dev);
202static void ni52_timeout(struct net_device *dev); 178static void ni52_timeout(struct net_device *dev);
203#if 0
204static void ni52_dump(struct net_device *,void *);
205#endif
206 179
207/* helper-functions */ 180/* helper-functions */
208static int init586(struct net_device *dev); 181static int init586(struct net_device *dev);
209static int check586(struct net_device *dev,char *where,unsigned size); 182static int check586(struct net_device *dev, char *where, unsigned size);
210static void alloc586(struct net_device *dev); 183static void alloc586(struct net_device *dev);
211static void startrecv586(struct net_device *dev); 184static void startrecv586(struct net_device *dev);
212static void *alloc_rfa(struct net_device *dev,void *ptr); 185static void *alloc_rfa(struct net_device *dev, void *ptr);
213static void ni52_rcv_int(struct net_device *dev); 186static void ni52_rcv_int(struct net_device *dev);
214static void ni52_xmt_int(struct net_device *dev); 187static void ni52_xmt_int(struct net_device *dev);
215static void ni52_rnr_int(struct net_device *dev); 188static void ni52_rnr_int(struct net_device *dev);
216 189
217struct priv 190struct priv {
218{
219 struct net_device_stats stats; 191 struct net_device_stats stats;
220 unsigned long base; 192 unsigned long base;
221 char *memtop; 193 char *memtop;
222 long int lock; 194 spinlock_t spinlock;
223 int reseted; 195 int reset;
224 volatile struct rfd_struct *rfd_last,*rfd_top,*rfd_first; 196 struct rfd_struct *rfd_last, *rfd_top, *rfd_first;
225 volatile struct scp_struct *scp; /* volatile is important */ 197 struct scp_struct *scp;
226 volatile struct iscp_struct *iscp; /* volatile is important */ 198 struct iscp_struct *iscp;
227 volatile struct scb_struct *scb; /* volatile is important */ 199 struct scb_struct *scb;
228 volatile struct tbd_struct *xmit_buffs[NUM_XMIT_BUFFS]; 200 struct tbd_struct *xmit_buffs[NUM_XMIT_BUFFS];
229#if (NUM_XMIT_BUFFS == 1) 201#if (NUM_XMIT_BUFFS == 1)
230 volatile struct transmit_cmd_struct *xmit_cmds[2]; 202 struct transmit_cmd_struct *xmit_cmds[2];
231 volatile struct nop_cmd_struct *nop_cmds[2]; 203 struct nop_cmd_struct *nop_cmds[2];
232#else 204#else
233 volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS]; 205 struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
234 volatile struct nop_cmd_struct *nop_cmds[NUM_XMIT_BUFFS]; 206 struct nop_cmd_struct *nop_cmds[NUM_XMIT_BUFFS];
235#endif 207#endif
236 volatile int nop_point,num_recv_buffs; 208 int nop_point, num_recv_buffs;
237 volatile char *xmit_cbuffs[NUM_XMIT_BUFFS]; 209 char *xmit_cbuffs[NUM_XMIT_BUFFS];
238 volatile int xmit_count,xmit_last; 210 int xmit_count, xmit_last;
239}; 211};
240 212
213/* wait for command with timeout: */
214static void wait_for_scb_cmd(struct net_device *dev)
215{
216 struct priv *p = dev->priv;
217 int i;
218 for (i = 0; i < 16384; i++) {
219 if (readb(&p->scb->cmd_cuc) == 0)
220 break;
221 udelay(4);
222 if (i == 16383) {
223 printk(KERN_ERR "%s: scb_cmd timed out: %04x,%04x .. disabling i82586!!\n",
224 dev->name, readb(&p->scb->cmd_cuc), readb(&p->scb->cus));
225 if (!p->reset) {
226 p->reset = 1;
227 ni_reset586();
228 }
229 }
230 }
231}
232
233static void wait_for_scb_cmd_ruc(struct net_device *dev)
234{
235 struct priv *p = dev->priv;
236 int i;
237 for (i = 0; i < 16384; i++) {
238 if (readb(&p->scb->cmd_ruc) == 0)
239 break;
240 udelay(4);
241 if (i == 16383) {
242 printk(KERN_ERR "%s: scb_cmd (ruc) timed out: %04x,%04x .. disabling i82586!!\n",
243 dev->name, p->scb->cmd_ruc, p->scb->rus);
244 if (!p->reset) {
245 p->reset = 1;
246 ni_reset586();
247 }
248 }
249 }
250}
251
252static void wait_for_stat_compl(void *p)
253{
254 struct nop_cmd_struct *addr = p;
255 int i;
256 for (i = 0; i < 32767; i++) {
257 if (readw(&((addr)->cmd_status)) & STAT_COMPL)
258 break;
259 udelay(32);
260 }
261}
262
241/********************************************** 263/**********************************************
242 * close device 264 * close device
243 */ 265 */
244static int ni52_close(struct net_device *dev) 266static int ni52_close(struct net_device *dev)
245{ 267{
246 free_irq(dev->irq, dev); 268 free_irq(dev->irq, dev);
247
248 ni_reset586(); /* the hard way to stop the receiver */ 269 ni_reset586(); /* the hard way to stop the receiver */
249
250 netif_stop_queue(dev); 270 netif_stop_queue(dev);
251
252 return 0; 271 return 0;
253} 272}
254 273
@@ -265,55 +284,53 @@ static int ni52_open(struct net_device *dev)
265 startrecv586(dev); 284 startrecv586(dev);
266 ni_enaint(); 285 ni_enaint();
267 286
268 ret = request_irq(dev->irq, &ni52_interrupt,0,dev->name,dev); 287 ret = request_irq(dev->irq, &ni52_interrupt, 0, dev->name, dev);
269 if (ret) 288 if (ret) {
270 {
271 ni_reset586(); 289 ni_reset586();
272 return ret; 290 return ret;
273 } 291 }
274
275 netif_start_queue(dev); 292 netif_start_queue(dev);
276
277 return 0; /* most done by init */ 293 return 0; /* most done by init */
278} 294}
279 295
280/********************************************** 296/**********************************************
281 * Check to see if there's an 82586 out there. 297 * Check to see if there's an 82586 out there.
282 */ 298 */
283static int check586(struct net_device *dev,char *where,unsigned size) 299static int check586(struct net_device *dev, char *where, unsigned size)
284{ 300{
285 struct priv pb; 301 struct priv pb;
286 struct priv *p = /* (struct priv *) dev->priv*/ &pb; 302 struct priv *p = /* (struct priv *) dev->priv*/ &pb;
287 char *iscp_addrs[2]; 303 char *iscp_addrs[2];
288 int i; 304 int i;
289 305
290 p->base = (unsigned long) isa_bus_to_virt((unsigned long)where) + size - 0x01000000; 306 p->base = (unsigned long) isa_bus_to_virt((unsigned long)where)
307 + size - 0x01000000;
291 p->memtop = isa_bus_to_virt((unsigned long)where) + size; 308 p->memtop = isa_bus_to_virt((unsigned long)where) + size;
292 p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS); 309 p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS);
293 memset((char *)p->scp,0, sizeof(struct scp_struct)); 310 memset_io((char *)p->scp, 0, sizeof(struct scp_struct));
294 for(i=0;i<sizeof(struct scp_struct);i++) /* memory was writeable? */ 311 for (i = 0; i < sizeof(struct scp_struct); i++)
295 if(((char *)p->scp)[i]) 312 /* memory was writeable? */
313 if (readb((char *)p->scp + i))
296 return 0; 314 return 0;
297 p->scp->sysbus = SYSBUSVAL; /* 1 = 8Bit-Bus, 0 = 16 Bit */ 315 writeb(SYSBUSVAL, &p->scp->sysbus); /* 1 = 8Bit-Bus, 0 = 16 Bit */
298 if(p->scp->sysbus != SYSBUSVAL) 316 if (readb(&p->scp->sysbus) != SYSBUSVAL)
299 return 0; 317 return 0;
300 318
301 iscp_addrs[0] = isa_bus_to_virt((unsigned long)where); 319 iscp_addrs[0] = isa_bus_to_virt((unsigned long)where);
302 iscp_addrs[1]= (char *) p->scp - sizeof(struct iscp_struct); 320 iscp_addrs[1] = (char *) p->scp - sizeof(struct iscp_struct);
303 321
304 for(i=0;i<2;i++) 322 for (i = 0; i < 2; i++) {
305 {
306 p->iscp = (struct iscp_struct *) iscp_addrs[i]; 323 p->iscp = (struct iscp_struct *) iscp_addrs[i];
307 memset((char *)p->iscp,0, sizeof(struct iscp_struct)); 324 memset_io((char *)p->iscp, 0, sizeof(struct iscp_struct));
308 325
309 p->scp->iscp = make24(p->iscp); 326 writel(make24(p->iscp), &p->scp->iscp);
310 p->iscp->busy = 1; 327 writeb(1, &p->iscp->busy);
311 328
312 ni_reset586(); 329 ni_reset586();
313 ni_attn586(); 330 ni_attn586();
314 DELAY(1); /* wait a while... */ 331 mdelay(32); /* wait a while... */
315 332 /* i82586 clears 'busy' after successful init */
316 if(p->iscp->busy) /* i82586 clears 'busy' after successful init */ 333 if (readb(&p->iscp->busy))
317 return 0; 334 return 0;
318 } 335 }
319 return 1; 336 return 1;
@@ -327,36 +344,39 @@ static void alloc586(struct net_device *dev)
327 struct priv *p = (struct priv *) dev->priv; 344 struct priv *p = (struct priv *) dev->priv;
328 345
329 ni_reset586(); 346 ni_reset586();
330 DELAY(1); 347 mdelay(32);
348
349 spin_lock_init(&p->spinlock);
331 350
332 p->scp = (struct scp_struct *) (p->base + SCP_DEFAULT_ADDRESS); 351 p->scp = (struct scp_struct *) (p->base + SCP_DEFAULT_ADDRESS);
333 p->scb = (struct scb_struct *) isa_bus_to_virt(dev->mem_start); 352 p->scb = (struct scb_struct *) isa_bus_to_virt(dev->mem_start);
334 p->iscp = (struct iscp_struct *) ((char *)p->scp - sizeof(struct iscp_struct)); 353 p->iscp = (struct iscp_struct *)
354 ((char *)p->scp - sizeof(struct iscp_struct));
335 355
336 memset((char *) p->iscp,0,sizeof(struct iscp_struct)); 356 memset_io(p->iscp, 0, sizeof(struct iscp_struct));
337 memset((char *) p->scp ,0,sizeof(struct scp_struct)); 357 memset_io(p->scp , 0, sizeof(struct scp_struct));
338 358
339 p->scp->iscp = make24(p->iscp); 359 writel(make24(p->iscp), &p->scp->iscp);
340 p->scp->sysbus = SYSBUSVAL; 360 writeb(SYSBUSVAL, &p->scp->sysbus);
341 p->iscp->scb_offset = make16(p->scb); 361 writew(make16(p->scb), &p->iscp->scb_offset);
342 362
343 p->iscp->busy = 1; 363 writeb(1, &p->iscp->busy);
344 ni_reset586(); 364 ni_reset586();
345 ni_attn586(); 365 ni_attn586();
346 366
347 DELAY(1); 367 mdelay(32);
348 368
349 if(p->iscp->busy) 369 if (readb(&p->iscp->busy))
350 printk("%s: Init-Problems (alloc).\n",dev->name); 370 printk(KERN_ERR "%s: Init-Problems (alloc).\n", dev->name);
351 371
352 p->reseted = 0; 372 p->reset = 0;
353 373
354 memset((char *)p->scb,0,sizeof(struct scb_struct)); 374 memset_io((char *)p->scb, 0, sizeof(struct scb_struct));
355} 375}
356 376
357/* set: io,irq,memstart,memend or set it when calling insmod */ 377/* set: io,irq,memstart,memend or set it when calling insmod */
358static int irq=9; 378static int irq = 9;
359static int io=0x300; 379static int io = 0x300;
360static long memstart; /* e.g 0xd0000 */ 380static long memstart; /* e.g 0xd0000 */
361static long memend; /* e.g 0xd4000 */ 381static long memend; /* e.g 0xd4000 */
362 382
@@ -413,7 +433,7 @@ out:
413 return ERR_PTR(err); 433 return ERR_PTR(err);
414} 434}
415 435
416static int __init ni52_probe1(struct net_device *dev,int ioaddr) 436static int __init ni52_probe1(struct net_device *dev, int ioaddr)
417{ 437{
418 int i, size, retval; 438 int i, size, retval;
419 439
@@ -425,90 +445,96 @@ static int __init ni52_probe1(struct net_device *dev,int ioaddr)
425 if (!request_region(ioaddr, NI52_TOTAL_SIZE, DRV_NAME)) 445 if (!request_region(ioaddr, NI52_TOTAL_SIZE, DRV_NAME))
426 return -EBUSY; 446 return -EBUSY;
427 447
428 if( !(inb(ioaddr+NI52_MAGIC1) == NI52_MAGICVAL1) || 448 if (!(inb(ioaddr+NI52_MAGIC1) == NI52_MAGICVAL1) ||
429 !(inb(ioaddr+NI52_MAGIC2) == NI52_MAGICVAL2)) { 449 !(inb(ioaddr+NI52_MAGIC2) == NI52_MAGICVAL2)) {
430 retval = -ENODEV; 450 retval = -ENODEV;
431 goto out; 451 goto out;
432 } 452 }
433 453
434 for(i=0;i<ETH_ALEN;i++) 454 for (i = 0; i < ETH_ALEN; i++)
435 dev->dev_addr[i] = inb(dev->base_addr+i); 455 dev->dev_addr[i] = inb(dev->base_addr+i);
436 456
437 if(dev->dev_addr[0] != NI52_ADDR0 || dev->dev_addr[1] != NI52_ADDR1 457 if (dev->dev_addr[0] != NI52_ADDR0 || dev->dev_addr[1] != NI52_ADDR1
438 || dev->dev_addr[2] != NI52_ADDR2) { 458 || dev->dev_addr[2] != NI52_ADDR2) {
439 retval = -ENODEV; 459 retval = -ENODEV;
440 goto out; 460 goto out;
441 } 461 }
442 462
443 printk(KERN_INFO "%s: NI5210 found at %#3lx, ",dev->name,dev->base_addr); 463 printk(KERN_INFO "%s: NI5210 found at %#3lx, ",
464 dev->name, dev->base_addr);
444 465
445 /* 466 /*
446 * check (or search) IO-Memory, 8K and 16K 467 * check (or search) IO-Memory, 8K and 16K
447 */ 468 */
448#ifdef MODULE 469#ifdef MODULE
449 size = dev->mem_end - dev->mem_start; 470 size = dev->mem_end - dev->mem_start;
450 if(size != 0x2000 && size != 0x4000) { 471 if (size != 0x2000 && size != 0x4000) {
451 printk("\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 bytes.\n",dev->name,size); 472 printk("\n");
473 printk(KERN_ERR "%s: Invalid memory size %d. Allowed is 0x2000 or 0x4000 bytes.\n", dev->name, size);
452 retval = -ENODEV; 474 retval = -ENODEV;
453 goto out; 475 goto out;
454 } 476 }
455 if(!check586(dev,(char *) dev->mem_start,size)) { 477 if (!check586(dev, (char *)dev->mem_start, size)) {
456 printk("?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->mem_start,size); 478 printk(KERN_ERR "?memcheck, Can't find memory at 0x%lx with size %d!\n", dev->mem_start, size);
457 retval = -ENODEV; 479 retval = -ENODEV;
458 goto out; 480 goto out;
459 } 481 }
460#else 482#else
461 if(dev->mem_start != 0) /* no auto-mem-probe */ 483 if (dev->mem_start != 0) {
462 { 484 /* no auto-mem-probe */
463 size = 0x4000; /* check for 16K mem */ 485 size = 0x4000; /* check for 16K mem */
464 if(!check586(dev,(char *) dev->mem_start,size)) { 486 if (!check586(dev, (char *) dev->mem_start, size)) {
465 size = 0x2000; /* check for 8K mem */ 487 size = 0x2000; /* check for 8K mem */
466 if(!check586(dev,(char *) dev->mem_start,size)) { 488 if (!check586(dev, (char *)dev->mem_start, size)) {
467 printk("?memprobe, Can't find memory at 0x%lx!\n",dev->mem_start); 489 printk(KERN_ERR "?memprobe, Can't find memory at 0x%lx!\n", dev->mem_start);
468 retval = -ENODEV; 490 retval = -ENODEV;
469 goto out; 491 goto out;
470 } 492 }
471 } 493 }
472 } 494 } else {
473 else 495 static const unsigned long memaddrs[] = {
474 { 496 0xc8000, 0xca000, 0xcc000, 0xce000, 0xd0000, 0xd2000,
475 static long memaddrs[] = { 0xc8000,0xca000,0xcc000,0xce000,0xd0000,0xd2000, 497 0xd4000, 0xd6000, 0xd8000, 0xda000, 0xdc000, 0
476 0xd4000,0xd6000,0xd8000,0xda000,0xdc000, 0 }; 498 };
477 for(i=0;;i++) 499 for (i = 0;; i++) {
478 { 500 if (!memaddrs[i]) {
479 if(!memaddrs[i]) { 501 printk(KERN_ERR "?memprobe, Can't find io-memory!\n");
480 printk("?memprobe, Can't find io-memory!\n");
481 retval = -ENODEV; 502 retval = -ENODEV;
482 goto out; 503 goto out;
483 } 504 }
484 dev->mem_start = memaddrs[i]; 505 dev->mem_start = memaddrs[i];
485 size = 0x2000; /* check for 8K mem */ 506 size = 0x2000; /* check for 8K mem */
486 if(check586(dev,(char *)dev->mem_start,size)) /* 8K-check */ 507 if (check586(dev, (char *)dev->mem_start, size))
508 /* 8K-check */
487 break; 509 break;
488 size = 0x4000; /* check for 16K mem */ 510 size = 0x4000; /* check for 16K mem */
489 if(check586(dev,(char *)dev->mem_start,size)) /* 16K-check */ 511 if (check586(dev, (char *)dev->mem_start, size))
512 /* 16K-check */
490 break; 513 break;
491 } 514 }
492 } 515 }
493 dev->mem_end = dev->mem_start + size; /* set mem_end showed by 'ifconfig' */ 516 /* set mem_end showed by 'ifconfig' */
517 dev->mem_end = dev->mem_start + size;
494#endif 518#endif
495 519
496 memset((char *) dev->priv,0,sizeof(struct priv)); 520 memset((char *)dev->priv, 0, sizeof(struct priv));
497 521
498 ((struct priv *) (dev->priv))->memtop = isa_bus_to_virt(dev->mem_start) + size; 522 ((struct priv *)(dev->priv))->memtop =
499 ((struct priv *) (dev->priv))->base = (unsigned long) isa_bus_to_virt(dev->mem_start) + size - 0x01000000; 523 isa_bus_to_virt(dev->mem_start) + size;
524 ((struct priv *)(dev->priv))->base = (unsigned long)
525 isa_bus_to_virt(dev->mem_start) + size - 0x01000000;
500 alloc586(dev); 526 alloc586(dev);
501 527
502 /* set number of receive-buffs according to memsize */ 528 /* set number of receive-buffs according to memsize */
503 if(size == 0x2000) 529 if (size == 0x2000)
504 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_8; 530 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_8;
505 else 531 else
506 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_16; 532 ((struct priv *) dev->priv)->num_recv_buffs = NUM_RECV_BUFFS_16;
507 533
508 printk("Memaddr: 0x%lx, Memsize: %d, ",dev->mem_start,size); 534 printk(KERN_DEBUG "Memaddr: 0x%lx, Memsize: %d, ",
535 dev->mem_start, size);
509 536
510 if(dev->irq < 2) 537 if (dev->irq < 2) {
511 {
512 unsigned long irq_mask; 538 unsigned long irq_mask;
513 539
514 irq_mask = probe_irq_on(); 540 irq_mask = probe_irq_on();
@@ -517,18 +543,16 @@ static int __init ni52_probe1(struct net_device *dev,int ioaddr)
517 543
518 mdelay(20); 544 mdelay(20);
519 dev->irq = probe_irq_off(irq_mask); 545 dev->irq = probe_irq_off(irq_mask);
520 if(!dev->irq) 546 if (!dev->irq) {
521 {
522 printk("?autoirq, Failed to detect IRQ line!\n"); 547 printk("?autoirq, Failed to detect IRQ line!\n");
523 retval = -EAGAIN; 548 retval = -EAGAIN;
524 goto out; 549 goto out;
525 } 550 }
526 printk("IRQ %d (autodetected).\n",dev->irq); 551 printk("IRQ %d (autodetected).\n", dev->irq);
527 } 552 } else {
528 else { 553 if (dev->irq == 2)
529 if(dev->irq == 2)
530 dev->irq = 9; 554 dev->irq = 9;
531 printk("IRQ %d (assigned and not checked!).\n",dev->irq); 555 printk("IRQ %d (assigned and not checked!).\n", dev->irq);
532 } 556 }
533 557
534 dev->open = ni52_open; 558 dev->open = ni52_open;
@@ -555,56 +579,58 @@ out:
555static int init586(struct net_device *dev) 579static int init586(struct net_device *dev)
556{ 580{
557 void *ptr; 581 void *ptr;
558 int i,result=0; 582 int i, result = 0;
559 struct priv *p = (struct priv *) dev->priv; 583 struct priv *p = (struct priv *)dev->priv;
560 volatile struct configure_cmd_struct *cfg_cmd; 584 struct configure_cmd_struct *cfg_cmd;
561 volatile struct iasetup_cmd_struct *ias_cmd; 585 struct iasetup_cmd_struct *ias_cmd;
562 volatile struct tdr_cmd_struct *tdr_cmd; 586 struct tdr_cmd_struct *tdr_cmd;
563 volatile struct mcsetup_cmd_struct *mc_cmd; 587 struct mcsetup_cmd_struct *mc_cmd;
564 struct dev_mc_list *dmi=dev->mc_list; 588 struct dev_mc_list *dmi = dev->mc_list;
565 int num_addrs=dev->mc_count; 589 int num_addrs = dev->mc_count;
566 590
567 ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct)); 591 ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct));
568 592
569 cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */ 593 cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */
570 cfg_cmd->cmd_status = 0; 594 writew(0, &cfg_cmd->cmd_status);
571 cfg_cmd->cmd_cmd = CMD_CONFIGURE | CMD_LAST; 595 writew(CMD_CONFIGURE | CMD_LAST, &cfg_cmd->cmd_cmd);
572 cfg_cmd->cmd_link = 0xffff; 596 writew(0xFFFF, &cfg_cmd->cmd_link);
573 597
574 cfg_cmd->byte_cnt = 0x0a; /* number of cfg bytes */ 598 /* number of cfg bytes */
575 cfg_cmd->fifo = fifo; /* fifo-limit (8=tx:32/rx:64) */ 599 writeb(0x0a, &cfg_cmd->byte_cnt);
576 cfg_cmd->sav_bf = 0x40; /* hold or discard bad recv frames (bit 7) */ 600 /* fifo-limit (8=tx:32/rx:64) */
577 cfg_cmd->adr_len = 0x2e; /* addr_len |!src_insert |pre-len |loopback */ 601 writeb(fifo, &cfg_cmd->fifo);
578 cfg_cmd->priority = 0x00; 602 /* hold or discard bad recv frames (bit 7) */
579 cfg_cmd->ifs = 0x60; 603 writeb(0x40, &cfg_cmd->sav_bf);
580 cfg_cmd->time_low = 0x00; 604 /* addr_len |!src_insert |pre-len |loopback */
581 cfg_cmd->time_high = 0xf2; 605 writeb(0x2e, &cfg_cmd->adr_len);
582 cfg_cmd->promisc = 0; 606 writeb(0x00, &cfg_cmd->priority);
583 if(dev->flags & IFF_ALLMULTI) { 607 writeb(0x60, &cfg_cmd->ifs);;
608 writeb(0x00, &cfg_cmd->time_low);
609 writeb(0xf2, &cfg_cmd->time_high);
610 writeb(0x00, &cfg_cmd->promisc);;
611 if (dev->flags & IFF_ALLMULTI) {
584 int len = ((char *) p->iscp - (char *) ptr - 8) / 6; 612 int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
585 if(num_addrs > len) { 613 if (num_addrs > len) {
586 printk("%s: switching to promisc. mode\n",dev->name); 614 printk(KERN_ERR "%s: switching to promisc. mode\n",
587 dev->flags|=IFF_PROMISC; 615 dev->name);
616 dev->flags |= IFF_PROMISC;
588 } 617 }
589 } 618 }
590 if(dev->flags&IFF_PROMISC) 619 if (dev->flags & IFF_PROMISC)
591 { 620 writeb(0x01, &cfg_cmd->promisc);
592 cfg_cmd->promisc=1; 621 writeb(0x00, &cfg_cmd->carr_coll);
593 dev->flags|=IFF_PROMISC; 622 writew(make16(cfg_cmd), &p->scb->cbl_offset);
594 } 623 writew(0, &p->scb->cmd_ruc);
595 cfg_cmd->carr_coll = 0x00;
596 624
597 p->scb->cbl_offset = make16(cfg_cmd); 625 writeb(CUC_START, &p->scb->cmd_cuc); /* cmd.-unit start */
598 p->scb->cmd_ruc = 0;
599
600 p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
601 ni_attn586(); 626 ni_attn586();
602 627
603 WAIT_4_STAT_COMPL(cfg_cmd); 628 wait_for_stat_compl(cfg_cmd);
604 629
605 if((cfg_cmd->cmd_status & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK)) 630 if ((readw(&cfg_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) !=
606 { 631 (STAT_COMPL|STAT_OK)) {
607 printk("%s: configure command failed: %x\n",dev->name,cfg_cmd->cmd_status); 632 printk(KERN_ERR "%s: configure command failed: %x\n",
633 dev->name, readw(&cfg_cmd->cmd_status));
608 return 1; 634 return 1;
609 } 635 }
610 636
@@ -614,21 +640,22 @@ static int init586(struct net_device *dev)
614 640
615 ias_cmd = (struct iasetup_cmd_struct *)ptr; 641 ias_cmd = (struct iasetup_cmd_struct *)ptr;
616 642
617 ias_cmd->cmd_status = 0; 643 writew(0, &ias_cmd->cmd_status);
618 ias_cmd->cmd_cmd = CMD_IASETUP | CMD_LAST; 644 writew(CMD_IASETUP | CMD_LAST, &ias_cmd->cmd_cmd);
619 ias_cmd->cmd_link = 0xffff; 645 writew(0xffff, &ias_cmd->cmd_link);
620 646
621 memcpy((char *)&ias_cmd->iaddr,(char *) dev->dev_addr,ETH_ALEN); 647 memcpy_toio((char *)&ias_cmd->iaddr, (char *)dev->dev_addr, ETH_ALEN);
622 648
623 p->scb->cbl_offset = make16(ias_cmd); 649 writew(make16(ias_cmd), &p->scb->cbl_offset);
624 650
625 p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */ 651 writeb(CUC_START, &p->scb->cmd_cuc); /* cmd.-unit start */
626 ni_attn586(); 652 ni_attn586();
627 653
628 WAIT_4_STAT_COMPL(ias_cmd); 654 wait_for_stat_compl(ias_cmd);
629 655
630 if((ias_cmd->cmd_status & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) { 656 if ((readw(&ias_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) !=
631 printk("%s (ni52): individual address setup command failed: %04x\n",dev->name,ias_cmd->cmd_status); 657 (STAT_OK|STAT_COMPL)) {
658 printk(KERN_ERR "%s (ni52): individual address setup command failed: %04x\n", dev->name, readw(&ias_cmd->cmd_status));
632 return 1; 659 return 1;
633 } 660 }
634 661
@@ -638,117 +665,119 @@ static int init586(struct net_device *dev)
638 665
639 tdr_cmd = (struct tdr_cmd_struct *)ptr; 666 tdr_cmd = (struct tdr_cmd_struct *)ptr;
640 667
641 tdr_cmd->cmd_status = 0; 668 writew(0, &tdr_cmd->cmd_status);
642 tdr_cmd->cmd_cmd = CMD_TDR | CMD_LAST; 669 writew(CMD_TDR | CMD_LAST, &tdr_cmd->cmd_cmd);
643 tdr_cmd->cmd_link = 0xffff; 670 writew(0xffff, &tdr_cmd->cmd_link);
644 tdr_cmd->status = 0; 671 writew(0, &tdr_cmd->status);
645 672
646 p->scb->cbl_offset = make16(tdr_cmd); 673 writew(make16(tdr_cmd), &p->scb->cbl_offset);
647 p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */ 674 writeb(CUC_START, &p->scb->cmd_cuc); /* cmd.-unit start */
648 ni_attn586(); 675 ni_attn586();
649 676
650 WAIT_4_STAT_COMPL(tdr_cmd); 677 wait_for_stat_compl(tdr_cmd);
651
652 if(!(tdr_cmd->cmd_status & STAT_COMPL))
653 {
654 printk("%s: Problems while running the TDR.\n",dev->name);
655 }
656 else
657 {
658 DELAY_16(); /* wait for result */
659 result = tdr_cmd->status;
660 678
661 p->scb->cmd_cuc = p->scb->cus & STAT_MASK; 679 if (!(readw(&tdr_cmd->cmd_status) & STAT_COMPL))
680 printk(KERN_ERR "%s: Problems while running the TDR.\n",
681 dev->name);
682 else {
683 udelay(16);
684 result = readw(&tdr_cmd->status);
685 writeb(readb(&p->scb->cus) & STAT_MASK, &p->scb->cmd_cuc);
662 ni_attn586(); /* ack the interrupts */ 686 ni_attn586(); /* ack the interrupts */
663 687
664 if(result & TDR_LNK_OK) 688 if (result & TDR_LNK_OK)
665 ; 689 ;
666 else if(result & TDR_XCVR_PRB) 690 else if (result & TDR_XCVR_PRB)
667 printk("%s: TDR: Transceiver problem. Check the cable(s)!\n",dev->name); 691 printk(KERN_ERR "%s: TDR: Transceiver problem. Check the cable(s)!\n",
668 else if(result & TDR_ET_OPN) 692 dev->name);
669 printk("%s: TDR: No correct termination %d clocks away.\n",dev->name,result & TDR_TIMEMASK); 693 else if (result & TDR_ET_OPN)
670 else if(result & TDR_ET_SRT) 694 printk(KERN_ERR "%s: TDR: No correct termination %d clocks away.\n",
671 { 695 dev->name, result & TDR_TIMEMASK);
672 if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */ 696 else if (result & TDR_ET_SRT) {
673 printk("%s: TDR: Detected a short circuit %d clocks away.\n",dev->name,result & TDR_TIMEMASK); 697 /* time == 0 -> strange :-) */
674 } 698 if (result & TDR_TIMEMASK)
675 else 699 printk(KERN_ERR "%s: TDR: Detected a short circuit %d clocks away.\n",
676 printk("%s: TDR: Unknown status %04x\n",dev->name,result); 700 dev->name, result & TDR_TIMEMASK);
701 } else
702 printk(KERN_ERR "%s: TDR: Unknown status %04x\n",
703 dev->name, result);
677 } 704 }
678 705
679 /* 706 /*
680 * Multicast setup 707 * Multicast setup
681 */ 708 */
682 if(num_addrs && !(dev->flags & IFF_PROMISC) ) 709 if (num_addrs && !(dev->flags & IFF_PROMISC)) {
683 {
684 mc_cmd = (struct mcsetup_cmd_struct *) ptr; 710 mc_cmd = (struct mcsetup_cmd_struct *) ptr;
685 mc_cmd->cmd_status = 0; 711 writew(0, &mc_cmd->cmd_status);
686 mc_cmd->cmd_cmd = CMD_MCSETUP | CMD_LAST; 712 writew(CMD_MCSETUP | CMD_LAST, &mc_cmd->cmd_cmd);
687 mc_cmd->cmd_link = 0xffff; 713 writew(0xffff, &mc_cmd->cmd_link);
688 mc_cmd->mc_cnt = num_addrs * 6; 714 writew(num_addrs * 6, &mc_cmd->mc_cnt);
689 715
690 for(i=0;i<num_addrs;i++,dmi=dmi->next) 716 for (i = 0; i < num_addrs; i++, dmi = dmi->next)
691 memcpy((char *) mc_cmd->mc_list[i], dmi->dmi_addr,6); 717 memcpy_toio((char *) mc_cmd->mc_list[i],
718 dmi->dmi_addr, 6);
692 719
693 p->scb->cbl_offset = make16(mc_cmd); 720 writew(make16(mc_cmd), &p->scb->cbl_offset);
694 p->scb->cmd_cuc = CUC_START; 721 writeb(CUC_START, &p->scb->cmd_cuc);
695 ni_attn586(); 722 ni_attn586();
696 723
697 WAIT_4_STAT_COMPL(mc_cmd); 724 wait_for_stat_compl(mc_cmd);
698 725
699 if( (mc_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) ) 726 if ((readw(&mc_cmd->cmd_status) & (STAT_COMPL|STAT_OK))
700 printk("%s: Can't apply multicast-address-list.\n",dev->name); 727 != (STAT_COMPL|STAT_OK))
728 printk(KERN_ERR "%s: Can't apply multicast-address-list.\n", dev->name);
701 } 729 }
702 730
703 /* 731 /*
704 * alloc nop/xmit-cmds 732 * alloc nop/xmit-cmds
705 */ 733 */
706#if (NUM_XMIT_BUFFS == 1) 734#if (NUM_XMIT_BUFFS == 1)
707 for(i=0;i<2;i++) 735 for (i = 0; i < 2; i++) {
708 { 736 p->nop_cmds[i] = (struct nop_cmd_struct *)ptr;
709 p->nop_cmds[i] = (struct nop_cmd_struct *)ptr; 737 writew(CMD_NOP, &p->nop_cmds[i]->cmd_cmd);
710 p->nop_cmds[i]->cmd_cmd = CMD_NOP; 738 writew(0, &p->nop_cmds[i]->cmd_status);
711 p->nop_cmds[i]->cmd_status = 0; 739 writew(make16(p->nop_cmds[i]), &p->nop_cmds[i]->cmd_link);
712 p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
713 ptr = (char *) ptr + sizeof(struct nop_cmd_struct); 740 ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
714 } 741 }
715#else 742#else
716 for(i=0;i<NUM_XMIT_BUFFS;i++) 743 for (i = 0; i < NUM_XMIT_BUFFS; i++) {
717 { 744 p->nop_cmds[i] = (struct nop_cmd_struct *)ptr;
718 p->nop_cmds[i] = (struct nop_cmd_struct *)ptr; 745 writew(CMD_NOP, &p->nop_cmds[i]->cmd_cmd);
719 p->nop_cmds[i]->cmd_cmd = CMD_NOP; 746 writew(0, &p->nop_cmds[i]->cmd_status);
720 p->nop_cmds[i]->cmd_status = 0; 747 writew(make16(p->nop_cmds[i]), &p->nop_cmds[i]->cmd_link);
721 p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
722 ptr = (char *) ptr + sizeof(struct nop_cmd_struct); 748 ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
723 } 749 }
724#endif 750#endif
725 751
726 ptr = alloc_rfa(dev,(void *)ptr); /* init receive-frame-area */ 752 ptr = alloc_rfa(dev, (void *)ptr); /* init receive-frame-area */
727 753
728 /* 754 /*
729 * alloc xmit-buffs / init xmit_cmds 755 * alloc xmit-buffs / init xmit_cmds
730 */ 756 */
731 for(i=0;i<NUM_XMIT_BUFFS;i++) 757 for (i = 0; i < NUM_XMIT_BUFFS; i++) {
732 { 758 /* Transmit cmd/buff 0 */
733 p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr; /*transmit cmd/buff 0*/ 759 p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr;
734 ptr = (char *) ptr + sizeof(struct transmit_cmd_struct); 760 ptr = (char *) ptr + sizeof(struct transmit_cmd_struct);
735 p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */ 761 p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */
736 ptr = (char *) ptr + XMIT_BUFF_SIZE; 762 ptr = (char *) ptr + XMIT_BUFF_SIZE;
737 p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */ 763 p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */
738 ptr = (char *) ptr + sizeof(struct tbd_struct); 764 ptr = (char *) ptr + sizeof(struct tbd_struct);
739 if((void *)ptr > (void *)p->iscp) 765 if ((void *)ptr > (void *)p->iscp) {
740 { 766 printk(KERN_ERR "%s: not enough shared-mem for your configuration!\n",
741 printk("%s: not enough shared-mem for your configuration!\n",dev->name); 767 dev->name);
742 return 1; 768 return 1;
743 } 769 }
744 memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct)); 770 memset_io((char *)(p->xmit_cmds[i]), 0,
745 memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct)); 771 sizeof(struct transmit_cmd_struct));
746 p->xmit_cmds[i]->cmd_link = make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]); 772 memset_io((char *)(p->xmit_buffs[i]), 0,
747 p->xmit_cmds[i]->cmd_status = STAT_COMPL; 773 sizeof(struct tbd_struct));
748 p->xmit_cmds[i]->cmd_cmd = CMD_XMIT | CMD_INT; 774 writew(make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]),
749 p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i])); 775 &p->xmit_cmds[i]->cmd_link);
750 p->xmit_buffs[i]->next = 0xffff; 776 writew(STAT_COMPL, &p->xmit_cmds[i]->cmd_status);
751 p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i])); 777 writew(CMD_XMIT|CMD_INT, &p->xmit_cmds[i]->cmd_cmd);
778 writew(make16(p->xmit_buffs[i]), &p->xmit_cmds[i]->tbd_offset);
779 writew(0xffff, &p->xmit_buffs[i]->next);
780 writel(make24(p->xmit_cbuffs[i]), &p->xmit_buffs[i]->buffer);
752 } 781 }
753 782
754 p->xmit_count = 0; 783 p->xmit_count = 0;
@@ -761,21 +790,21 @@ static int init586(struct net_device *dev)
761 * 'start transmitter' 790 * 'start transmitter'
762 */ 791 */
763#ifndef NO_NOPCOMMANDS 792#ifndef NO_NOPCOMMANDS
764 p->scb->cbl_offset = make16(p->nop_cmds[0]); 793 writew(make16(p->nop_cmds[0]), &p->scb->cbl_offset);
765 p->scb->cmd_cuc = CUC_START; 794 writeb(CUC_START, &p->scb->cmd_cuc);
766 ni_attn586(); 795 ni_attn586();
767 WAIT_4_SCB_CMD(); 796 wait_for_scb_cmd(dev);
768#else 797#else
769 p->xmit_cmds[0]->cmd_link = make16(p->xmit_cmds[0]); 798 writew(make16(p->xmit_cmds[0]), &p->xmit_cmds[0]->cmd_link);
770 p->xmit_cmds[0]->cmd_cmd = CMD_XMIT | CMD_SUSPEND | CMD_INT; 799 writew(CMD_XMIT | CMD_SUSPEND | CMD_INT, &p->xmit_cmds[0]->cmd_cmd);
771#endif 800#endif
772 801
773 /* 802 /*
774 * ack. interrupts 803 * ack. interrupts
775 */ 804 */
776 p->scb->cmd_cuc = p->scb->cus & STAT_MASK; 805 writeb(readb(&p->scb->cus) & STAT_MASK, &p->scb->cmd_cuc);
777 ni_attn586(); 806 ni_attn586();
778 DELAY_16(); 807 udelay(16);
779 808
780 ni_enaint(); 809 ni_enaint();
781 810
@@ -787,43 +816,45 @@ static int init586(struct net_device *dev)
787 * It sets up the Receive Frame Area (RFA). 816 * It sets up the Receive Frame Area (RFA).
788 */ 817 */
789 818
790static void *alloc_rfa(struct net_device *dev,void *ptr) 819static void *alloc_rfa(struct net_device *dev, void *ptr)
791{ 820{
792 volatile struct rfd_struct *rfd = (struct rfd_struct *)ptr; 821 struct rfd_struct *rfd = (struct rfd_struct *)ptr;
793 volatile struct rbd_struct *rbd; 822 struct rbd_struct *rbd;
794 int i; 823 int i;
795 struct priv *p = (struct priv *) dev->priv; 824 struct priv *p = (struct priv *) dev->priv;
796 825
797 memset((char *) rfd,0,sizeof(struct rfd_struct)*(p->num_recv_buffs+rfdadd)); 826 memset_io((char *) rfd, 0,
827 sizeof(struct rfd_struct) * (p->num_recv_buffs + rfdadd));
798 p->rfd_first = rfd; 828 p->rfd_first = rfd;
799 829
800 for(i = 0; i < (p->num_recv_buffs+rfdadd); i++) { 830 for (i = 0; i < (p->num_recv_buffs + rfdadd); i++) {
801 rfd[i].next = make16(rfd + (i+1) % (p->num_recv_buffs+rfdadd) ); 831 writew(make16(rfd + (i+1) % (p->num_recv_buffs+rfdadd)),
802 rfd[i].rbd_offset = 0xffff; 832 &rfd[i].next);
833 writew(0xffff, &rfd[i].rbd_offset);
803 } 834 }
804 rfd[p->num_recv_buffs-1+rfdadd].last = RFD_SUSP; /* RU suspend */ 835 /* RU suspend */
836 writeb(RFD_SUSP, &rfd[p->num_recv_buffs-1+rfdadd].last);
805 837
806 ptr = (void *) (rfd + (p->num_recv_buffs + rfdadd) ); 838 ptr = (void *) (rfd + (p->num_recv_buffs + rfdadd));
807 839
808 rbd = (struct rbd_struct *) ptr; 840 rbd = (struct rbd_struct *) ptr;
809 ptr = (void *) (rbd + p->num_recv_buffs); 841 ptr = (void *) (rbd + p->num_recv_buffs);
810 842
811 /* clr descriptors */ 843 /* clr descriptors */
812 memset((char *) rbd,0,sizeof(struct rbd_struct)*(p->num_recv_buffs)); 844 memset_io((char *)rbd, 0,
845 sizeof(struct rbd_struct) * (p->num_recv_buffs));
813 846
814 for(i=0;i<p->num_recv_buffs;i++) 847 for (i = 0; i < p->num_recv_buffs; i++) {
815 { 848 writew(make16(rbd + (i+1) % p->num_recv_buffs), &rbd[i].next);
816 rbd[i].next = make16((rbd + (i+1) % p->num_recv_buffs)); 849 writew(RECV_BUFF_SIZE, &rbd[i].size);
817 rbd[i].size = RECV_BUFF_SIZE; 850 writel(make24(ptr), &rbd[i].buffer);
818 rbd[i].buffer = make24(ptr);
819 ptr = (char *) ptr + RECV_BUFF_SIZE; 851 ptr = (char *) ptr + RECV_BUFF_SIZE;
820 } 852 }
821
822 p->rfd_top = p->rfd_first; 853 p->rfd_top = p->rfd_first;
823 p->rfd_last = p->rfd_first + (p->num_recv_buffs - 1 + rfdadd); 854 p->rfd_last = p->rfd_first + (p->num_recv_buffs - 1 + rfdadd);
824 855
825 p->scb->rfa_offset = make16(p->rfd_first); 856 writew(make16(p->rfd_first), &p->scb->rfa_offset);
826 p->rfd_first->rbd_offset = make16(rbd); 857 writew(make16(rbd), &p->rfd_first->rbd_offset);
827 858
828 return ptr; 859 return ptr;
829} 860}
@@ -833,73 +864,71 @@ static void *alloc_rfa(struct net_device *dev,void *ptr)
833 * Interrupt Handler ... 864 * Interrupt Handler ...
834 */ 865 */
835 866
836static irqreturn_t ni52_interrupt(int irq,void *dev_id) 867static irqreturn_t ni52_interrupt(int irq, void *dev_id)
837{ 868{
838 struct net_device *dev = dev_id; 869 struct net_device *dev = dev_id;
839 unsigned short stat; 870 unsigned int stat;
840 int cnt=0; 871 int cnt = 0;
841 struct priv *p; 872 struct priv *p;
842 873
843 if (!dev) {
844 printk ("ni5210-interrupt: irq %d for unknown device.\n",irq);
845 return IRQ_NONE;
846 }
847 p = (struct priv *) dev->priv; 874 p = (struct priv *) dev->priv;
848 875
849 if(debuglevel > 1) 876 if (debuglevel > 1)
850 printk("I"); 877 printk("I");
851 878
852 WAIT_4_SCB_CMD(); /* wait for last command */ 879 spin_lock(&p->spinlock);
853 880
854 while((stat=p->scb->cus & STAT_MASK)) 881 wait_for_scb_cmd(dev); /* wait for last command */
855 { 882
856 p->scb->cmd_cuc = stat; 883 while ((stat = readb(&p->scb->cus) & STAT_MASK)) {
884 writeb(stat, &p->scb->cmd_cuc);
857 ni_attn586(); 885 ni_attn586();
858 886
859 if(stat & STAT_FR) /* received a frame */ 887 if (stat & STAT_FR) /* received a frame */
860 ni52_rcv_int(dev); 888 ni52_rcv_int(dev);
861 889
862 if(stat & STAT_RNR) /* RU went 'not ready' */ 890 if (stat & STAT_RNR) { /* RU went 'not ready' */
863 {
864 printk("(R)"); 891 printk("(R)");
865 if(p->scb->rus & RU_SUSPEND) /* special case: RU_SUSPEND */ 892 if (readb(&p->scb->rus) & RU_SUSPEND) {
866 { 893 /* special case: RU_SUSPEND */
867 WAIT_4_SCB_CMD(); 894 wait_for_scb_cmd(dev);
868 p->scb->cmd_ruc = RUC_RESUME; 895 p->scb->cmd_ruc = RUC_RESUME;
869 ni_attn586(); 896 ni_attn586();
870 WAIT_4_SCB_CMD_RUC(); 897 wait_for_scb_cmd_ruc(dev);
871 } 898 } else {
872 else 899 printk(KERN_ERR "%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",
873 { 900 dev->name, stat, readb(&p->scb->rus));
874 printk("%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->rus);
875 ni52_rnr_int(dev); 901 ni52_rnr_int(dev);
876 } 902 }
877 } 903 }
878 904
879 if(stat & STAT_CX) /* command with I-bit set complete */ 905 /* Command with I-bit set complete */
906 if (stat & STAT_CX)
880 ni52_xmt_int(dev); 907 ni52_xmt_int(dev);
881 908
882#ifndef NO_NOPCOMMANDS 909#ifndef NO_NOPCOMMANDS
883 if(stat & STAT_CNA) /* CU went 'not ready' */ 910 if (stat & STAT_CNA) { /* CU went 'not ready' */
884 { 911 if (netif_running(dev))
885 if(netif_running(dev)) 912 printk(KERN_ERR "%s: oops! CU has left active state. stat: %04x/%02x.\n",
886 printk("%s: oops! CU has left active state. stat: %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->cus); 913 dev->name, stat, readb(&p->scb->cus));
887 } 914 }
888#endif 915#endif
889 916
890 if(debuglevel > 1) 917 if (debuglevel > 1)
891 printk("%d",cnt++); 918 printk("%d", cnt++);
892 919
893 WAIT_4_SCB_CMD(); /* wait for ack. (ni52_xmt_int can be faster than ack!!) */ 920 /* Wait for ack. (ni52_xmt_int can be faster than ack!!) */
894 if(p->scb->cmd_cuc) /* timed out? */ 921 wait_for_scb_cmd(dev);
895 { 922 if (p->scb->cmd_cuc) { /* timed out? */
896 printk("%s: Acknowledge timed out.\n",dev->name); 923 printk(KERN_ERR "%s: Acknowledge timed out.\n",
924 dev->name);
897 ni_disint(); 925 ni_disint();
898 break; 926 break;
899 } 927 }
900 } 928 }
929 spin_unlock(&p->spinlock);
901 930
902 if(debuglevel > 1) 931 if (debuglevel > 1)
903 printk("i"); 932 printk("i");
904 return IRQ_HANDLED; 933 return IRQ_HANDLED;
905} 934}
@@ -910,121 +939,91 @@ static irqreturn_t ni52_interrupt(int irq,void *dev_id)
910 939
911static void ni52_rcv_int(struct net_device *dev) 940static void ni52_rcv_int(struct net_device *dev)
912{ 941{
913 int status,cnt=0; 942 int status, cnt = 0;
914 unsigned short totlen; 943 unsigned short totlen;
915 struct sk_buff *skb; 944 struct sk_buff *skb;
916 struct rbd_struct *rbd; 945 struct rbd_struct *rbd;
917 struct priv *p = (struct priv *) dev->priv; 946 struct priv *p = (struct priv *)dev->priv;
918 947
919 if(debuglevel > 0) 948 if (debuglevel > 0)
920 printk("R"); 949 printk("R");
921 950
922 for(;(status = p->rfd_top->stat_high) & RFD_COMPL;) 951 for (; (status = readb(&p->rfd_top->stat_high)) & RFD_COMPL;) {
923 { 952 rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);
924 rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset); 953 if (status & RFD_OK) { /* frame received without error? */
925 954 totlen = readw(&rbd->status);
926 if(status & RFD_OK) /* frame received without error? */ 955 if (totlen & RBD_LAST) {
927 { 956 /* the first and the last buffer? */
928 if( (totlen = rbd->status) & RBD_LAST) /* the first and the last buffer? */ 957 totlen &= RBD_MASK; /* length of this frame */
929 { 958 writew(0x00, &rbd->status);
930 totlen &= RBD_MASK; /* length of this frame */ 959 skb = (struct sk_buff *)dev_alloc_skb(totlen+2);
931 rbd->status = 0; 960 if (skb != NULL) {
932 skb = (struct sk_buff *) dev_alloc_skb(totlen+2); 961 skb_reserve(skb, 2);
933 if(skb != NULL) 962 skb_put(skb, totlen);
934 { 963 skb_copy_to_linear_data(skb, (char *)p->base + (unsigned long) rbd->buffer, totlen);
935 skb_reserve(skb,2); 964 skb->protocol = eth_type_trans(skb, dev);
936 skb_put(skb,totlen); 965 netif_rx(skb);
937 skb_copy_to_linear_data(skb,(char *) p->base+(unsigned long) rbd->buffer,totlen); 966 dev->last_rx = jiffies;
938 skb->protocol=eth_type_trans(skb,dev); 967 p->stats.rx_packets++;
939 netif_rx(skb); 968 p->stats.rx_bytes += totlen;
940 dev->last_rx = jiffies; 969 } else
941 p->stats.rx_packets++; 970 p->stats.rx_dropped++;
942 p->stats.rx_bytes += totlen; 971 } else {
972 int rstat;
973 /* free all RBD's until RBD_LAST is set */
974 totlen = 0;
975 while (!((rstat = readw(&rbd->status)) & RBD_LAST)) {
976 totlen += rstat & RBD_MASK;
977 if (!rstat) {
978 printk(KERN_ERR "%s: Whoops .. no end mark in RBD list\n", dev->name);
979 break;
943 } 980 }
944 else 981 writew(0, &rbd->status);
945 p->stats.rx_dropped++; 982 rbd = (struct rbd_struct *) make32(readl(&rbd->next));
946 } 983 }
947 else 984 totlen += rstat & RBD_MASK;
948 { 985 writew(0, &rbd->status);
949 int rstat; 986 printk(KERN_ERR "%s: received oversized frame! length: %d\n",
950 /* free all RBD's until RBD_LAST is set */ 987 dev->name, totlen);
951 totlen = 0; 988 p->stats.rx_dropped++;
952 while(!((rstat=rbd->status) & RBD_LAST))
953 {
954 totlen += rstat & RBD_MASK;
955 if(!rstat)
956 {
957 printk("%s: Whoops .. no end mark in RBD list\n",dev->name);
958 break;
959 }
960 rbd->status = 0;
961 rbd = (struct rbd_struct *) make32(rbd->next);
962 }
963 totlen += rstat & RBD_MASK;
964 rbd->status = 0;
965 printk("%s: received oversized frame! length: %d\n",dev->name,totlen);
966 p->stats.rx_dropped++;
967 } 989 }
968 } 990 } else {/* frame !(ok), only with 'save-bad-frames' */
969 else /* frame !(ok), only with 'save-bad-frames' */ 991 printk(KERN_ERR "%s: oops! rfd-error-status: %04x\n",
970 { 992 dev->name, status);
971 printk("%s: oops! rfd-error-status: %04x\n",dev->name,status);
972 p->stats.rx_errors++; 993 p->stats.rx_errors++;
973 } 994 }
974 p->rfd_top->stat_high = 0; 995 writeb(0, &p->rfd_top->stat_high);
975 p->rfd_top->last = RFD_SUSP; /* maybe exchange by RFD_LAST */ 996 writeb(RFD_SUSP, &p->rfd_top->last); /* maybe exchange by RFD_LAST */
976 p->rfd_top->rbd_offset = 0xffff; 997 writew(0xffff, &p->rfd_top->rbd_offset);
977 p->rfd_last->last = 0; /* delete RFD_SUSP */ 998 writeb(0, &p->rfd_last->last); /* delete RFD_SUSP */
978 p->rfd_last = p->rfd_top; 999 p->rfd_last = p->rfd_top;
979 p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */ 1000 p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */
980 p->scb->rfa_offset = make16(p->rfd_top); 1001 writew(make16(p->rfd_top), &p->scb->rfa_offset);
981 1002
982 if(debuglevel > 0) 1003 if (debuglevel > 0)
983 printk("%d",cnt++); 1004 printk("%d", cnt++);
984 } 1005 }
985 1006
986 if(automatic_resume) 1007 if (automatic_resume) {
987 { 1008 wait_for_scb_cmd(dev);
988 WAIT_4_SCB_CMD(); 1009 writeb(RUC_RESUME, &p->scb->cmd_ruc);
989 p->scb->cmd_ruc = RUC_RESUME;
990 ni_attn586(); 1010 ni_attn586();
991 WAIT_4_SCB_CMD_RUC(); 1011 wait_for_scb_cmd_ruc(dev);
992 } 1012 }
993 1013
994#ifdef WAIT_4_BUSY 1014#ifdef WAIT_4_BUSY
995 { 1015 {
996 int i; 1016 int i;
997 for(i=0;i<1024;i++) 1017 for (i = 0; i < 1024; i++) {
998 { 1018 if (p->rfd_top->status)
999 if(p->rfd_top->status)
1000 break; 1019 break;
1001 DELAY_16(); 1020 udelay(16);
1002 if(i == 1023) 1021 if (i == 1023)
1003 printk("%s: RU hasn't fetched next RFD (not busy/complete)\n",dev->name); 1022 printk(KERN_ERR "%s: RU hasn't fetched next RFD (not busy/complete)\n", dev->name);
1004 } 1023 }
1005 } 1024 }
1006#endif 1025#endif
1007 1026 if (debuglevel > 0)
1008#if 0
1009 if(!at_least_one)
1010 {
1011 int i;
1012 volatile struct rfd_struct *rfds=p->rfd_top;
1013 volatile struct rbd_struct *rbds;
1014 printk("%s: received a FC intr. without having a frame: %04x %d\n",dev->name,status,old_at_least);
1015 for(i=0;i< (p->num_recv_buffs+4);i++)
1016 {
1017 rbds = (struct rbd_struct *) make32(rfds->rbd_offset);
1018 printk("%04x:%04x ",rfds->status,rbds->status);
1019 rfds = (struct rfd_struct *) make32(rfds->next);
1020 }
1021 printk("\nerrs: %04x %04x stat: %04x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->status);
1022 printk("\nerrs: %04x %04x rus: %02x, cus: %02x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->rus,(int)p->scb->cus);
1023 }
1024 old_at_least = at_least_one;
1025#endif
1026
1027 if(debuglevel > 0)
1028 printk("r"); 1027 printk("r");
1029} 1028}
1030 1029
@@ -1038,16 +1037,16 @@ static void ni52_rnr_int(struct net_device *dev)
1038 1037
1039 p->stats.rx_errors++; 1038 p->stats.rx_errors++;
1040 1039
1041 WAIT_4_SCB_CMD(); /* wait for the last cmd, WAIT_4_FULLSTAT?? */ 1040 wait_for_scb_cmd(dev); /* wait for the last cmd, WAIT_4_FULLSTAT?? */
1042 p->scb->cmd_ruc = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */ 1041 writeb(RUC_ABORT, &p->scb->cmd_ruc); /* usually the RU is in the 'no resource'-state .. abort it now. */
1043 ni_attn586(); 1042 ni_attn586();
1044 WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. */ 1043 wait_for_scb_cmd_ruc(dev); /* wait for accept cmd. */
1045 1044
1046 alloc_rfa(dev,(char *)p->rfd_first); 1045 alloc_rfa(dev, (char *)p->rfd_first);
1047/* maybe add a check here, before restarting the RU */ 1046 /* maybe add a check here, before restarting the RU */
1048 startrecv586(dev); /* restart RU */ 1047 startrecv586(dev); /* restart RU */
1049 1048
1050 printk("%s: Receive-Unit restarted. Status: %04x\n",dev->name,p->scb->rus); 1049 printk(KERN_ERR "%s: Receive-Unit restarted. Status: %04x\n", dev->name, p->scb->rus);
1051 1050
1052} 1051}
1053 1052
@@ -1060,43 +1059,41 @@ static void ni52_xmt_int(struct net_device *dev)
1060 int status; 1059 int status;
1061 struct priv *p = (struct priv *) dev->priv; 1060 struct priv *p = (struct priv *) dev->priv;
1062 1061
1063 if(debuglevel > 0) 1062 if (debuglevel > 0)
1064 printk("X"); 1063 printk("X");
1065 1064
1066 status = p->xmit_cmds[p->xmit_last]->cmd_status; 1065 status = readw(&p->xmit_cmds[p->xmit_last]->cmd_status);
1067 if(!(status & STAT_COMPL)) 1066 if (!(status & STAT_COMPL))
1068 printk("%s: strange .. xmit-int without a 'COMPLETE'\n",dev->name); 1067 printk(KERN_ERR "%s: strange .. xmit-int without a 'COMPLETE'\n", dev->name);
1069 1068
1070 if(status & STAT_OK) 1069 if (status & STAT_OK) {
1071 {
1072 p->stats.tx_packets++; 1070 p->stats.tx_packets++;
1073 p->stats.collisions += (status & TCMD_MAXCOLLMASK); 1071 p->stats.collisions += (status & TCMD_MAXCOLLMASK);
1074 } 1072 } else {
1075 else
1076 {
1077 p->stats.tx_errors++; 1073 p->stats.tx_errors++;
1078 if(status & TCMD_LATECOLL) { 1074 if (status & TCMD_LATECOLL) {
1079 printk("%s: late collision detected.\n",dev->name); 1075 printk(KERN_ERR "%s: late collision detected.\n",
1076 dev->name);
1080 p->stats.collisions++; 1077 p->stats.collisions++;
1081 } 1078 } else if (status & TCMD_NOCARRIER) {
1082 else if(status & TCMD_NOCARRIER) {
1083 p->stats.tx_carrier_errors++; 1079 p->stats.tx_carrier_errors++;
1084 printk("%s: no carrier detected.\n",dev->name); 1080 printk(KERN_ERR "%s: no carrier detected.\n",
1085 } 1081 dev->name);
1086 else if(status & TCMD_LOSTCTS) 1082 } else if (status & TCMD_LOSTCTS)
1087 printk("%s: loss of CTS detected.\n",dev->name); 1083 printk(KERN_ERR "%s: loss of CTS detected.\n",
1088 else if(status & TCMD_UNDERRUN) { 1084 dev->name);
1085 else if (status & TCMD_UNDERRUN) {
1089 p->stats.tx_fifo_errors++; 1086 p->stats.tx_fifo_errors++;
1090 printk("%s: DMA underrun detected.\n",dev->name); 1087 printk(KERN_ERR "%s: DMA underrun detected.\n",
1091 } 1088 dev->name);
1092 else if(status & TCMD_MAXCOLL) { 1089 } else if (status & TCMD_MAXCOLL) {
1093 printk("%s: Max. collisions exceeded.\n",dev->name); 1090 printk(KERN_ERR "%s: Max. collisions exceeded.\n",
1091 dev->name);
1094 p->stats.collisions += 16; 1092 p->stats.collisions += 16;
1095 } 1093 }
1096 } 1094 }
1097
1098#if (NUM_XMIT_BUFFS > 1) 1095#if (NUM_XMIT_BUFFS > 1)
1099 if( (++p->xmit_last) == NUM_XMIT_BUFFS) 1096 if ((++p->xmit_last) == NUM_XMIT_BUFFS)
1100 p->xmit_last = 0; 1097 p->xmit_last = 0;
1101#endif 1098#endif
1102 netif_wake_queue(dev); 1099 netif_wake_queue(dev);
@@ -1110,41 +1107,51 @@ static void startrecv586(struct net_device *dev)
1110{ 1107{
1111 struct priv *p = (struct priv *) dev->priv; 1108 struct priv *p = (struct priv *) dev->priv;
1112 1109
1113 WAIT_4_SCB_CMD(); 1110 wait_for_scb_cmd(dev);
1114 WAIT_4_SCB_CMD_RUC(); 1111 wait_for_scb_cmd_ruc(dev);
1115 p->scb->rfa_offset = make16(p->rfd_first); 1112 writew(make16(p->rfd_first), &p->scb->rfa_offset);
1116 p->scb->cmd_ruc = RUC_START; 1113 writeb(RUC_START, &p->scb->cmd_ruc);
1117 ni_attn586(); /* start cmd. */ 1114 ni_attn586(); /* start cmd. */
1118 WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. (no timeout!!) */ 1115 wait_for_scb_cmd_ruc(dev);
1116 /* wait for accept cmd. (no timeout!!) */
1119} 1117}
1120 1118
1121static void ni52_timeout(struct net_device *dev) 1119static void ni52_timeout(struct net_device *dev)
1122{ 1120{
1123 struct priv *p = (struct priv *) dev->priv; 1121 struct priv *p = (struct priv *) dev->priv;
1124#ifndef NO_NOPCOMMANDS 1122#ifndef NO_NOPCOMMANDS
1125 if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */ 1123 if (readb(&p->scb->cus) & CU_ACTIVE) { /* COMMAND-UNIT active? */
1126 {
1127 netif_wake_queue(dev); 1124 netif_wake_queue(dev);
1128#ifdef DEBUG 1125#ifdef DEBUG
1129 printk("%s: strange ... timeout with CU active?!?\n",dev->name); 1126 printk(KERN_ERR "%s: strange ... timeout with CU active?!?\n",
1130 printk("%s: X0: %04x N0: %04x N1: %04x %d\n",dev->name,(int)p->xmit_cmds[0]->cmd_status,(int)p->nop_cmds[0]->cmd_status,(int)p->nop_cmds[1]->cmd_status,(int)p->nop_point); 1127 dev->name);
1128 printk(KERN_ERR "%s: X0: %04x N0: %04x N1: %04x %d\n",
1129 dev->name, (int)p->xmit_cmds[0]->cmd_status,
1130 readw(&p->nop_cmds[0]->cmd_status),
1131 readw(&p->nop_cmds[1]->cmd_status),
1132 p->nop_point);
1131#endif 1133#endif
1132 p->scb->cmd_cuc = CUC_ABORT; 1134 writeb(CUC_ABORT, &p->scb->cmd_cuc);
1133 ni_attn586(); 1135 ni_attn586();
1134 WAIT_4_SCB_CMD(); 1136 wait_for_scb_cmd(dev);
1135 p->scb->cbl_offset = make16(p->nop_cmds[p->nop_point]); 1137 writew(make16(p->nop_cmds[p->nop_point]), &p->scb->cbl_offset);
1136 p->scb->cmd_cuc = CUC_START; 1138 writeb(CUC_START, &p->scb->cmd_cuc);
1137 ni_attn586(); 1139 ni_attn586();
1138 WAIT_4_SCB_CMD(); 1140 wait_for_scb_cmd(dev);
1139 dev->trans_start = jiffies; 1141 dev->trans_start = jiffies;
1140 return 0; 1142 return 0;
1141 } 1143 }
1142#endif 1144#endif
1143 { 1145 {
1144#ifdef DEBUG 1146#ifdef DEBUG
1145 printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus); 1147 printk(KERN_ERR "%s: xmitter timed out, try to restart! stat: %02x\n",
1146 printk("%s: command-stats: %04x %04x\n",dev->name,p->xmit_cmds[0]->cmd_status,p->xmit_cmds[1]->cmd_status); 1148 dev->name, readb(&p->scb->cus));
1147 printk("%s: check, whether you set the right interrupt number!\n",dev->name); 1149 printk(KERN_ERR "%s: command-stats: %04x %04x\n",
1150 dev->name,
1151 readw(&p->xmit_cmds[0]->cmd_status),
1152 readw(&p->xmit_cmds[1]->cmd_status));
1153 printk(KERN_ERR "%s: check, whether you set the right interrupt number!\n",
1154 dev->name);
1148#endif 1155#endif
1149 ni52_close(dev); 1156 ni52_close(dev);
1150 ni52_open(dev); 1157 ni52_open(dev);
@@ -1158,110 +1165,99 @@ static void ni52_timeout(struct net_device *dev)
1158 1165
1159static int ni52_send_packet(struct sk_buff *skb, struct net_device *dev) 1166static int ni52_send_packet(struct sk_buff *skb, struct net_device *dev)
1160{ 1167{
1161 int len,i; 1168 int len, i;
1162#ifndef NO_NOPCOMMANDS 1169#ifndef NO_NOPCOMMANDS
1163 int next_nop; 1170 int next_nop;
1164#endif 1171#endif
1165 struct priv *p = (struct priv *) dev->priv; 1172 struct priv *p = (struct priv *) dev->priv;
1166 1173
1167 if(skb->len > XMIT_BUFF_SIZE) 1174 if (skb->len > XMIT_BUFF_SIZE) {
1168 { 1175 printk(KERN_ERR "%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n", dev->name, XMIT_BUFF_SIZE, skb->len);
1169 printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len);
1170 return 0; 1176 return 0;
1171 } 1177 }
1172 1178
1173 netif_stop_queue(dev); 1179 netif_stop_queue(dev);
1174 1180
1175#if(NUM_XMIT_BUFFS > 1) 1181 skb_copy_from_linear_data(skb, (char *)p->xmit_cbuffs[p->xmit_count],
1176 if(test_and_set_bit(0,(void *) &p->lock)) { 1182 skb->len);
1177 printk("%s: Queue was locked\n",dev->name); 1183 len = skb->len;
1178 return 1; 1184 if (len < ETH_ZLEN) {
1185 len = ETH_ZLEN;
1186 memset((char *)p->xmit_cbuffs[p->xmit_count]+skb->len, 0,
1187 len - skb->len);
1179 } 1188 }
1180 else
1181#endif
1182 {
1183 skb_copy_from_linear_data(skb, (char *) p->xmit_cbuffs[p->xmit_count], skb->len);
1184 len = skb->len;
1185 if (len < ETH_ZLEN) {
1186 len = ETH_ZLEN;
1187 memset((char *)p->xmit_cbuffs[p->xmit_count]+skb->len, 0, len - skb->len);
1188 }
1189 1189
1190#if (NUM_XMIT_BUFFS == 1) 1190#if (NUM_XMIT_BUFFS == 1)
1191# ifdef NO_NOPCOMMANDS 1191# ifdef NO_NOPCOMMANDS
1192 1192
1193#ifdef DEBUG 1193#ifdef DEBUG
1194 if(p->scb->cus & CU_ACTIVE) 1194 if (p->scb->cus & CU_ACTIVE) {
1195 { 1195 printk(KERN_ERR "%s: Hmmm .. CU is still running and we wanna send a new packet.\n", dev->name);
1196 printk("%s: Hmmm .. CU is still running and we wanna send a new packet.\n",dev->name); 1196 printk(KERN_ERR "%s: stat: %04x %04x\n",
1197 printk("%s: stat: %04x %04x\n",dev->name,p->scb->cus,p->xmit_cmds[0]->cmd_status); 1197 dev->name, readb(&p->scb->cus),
1198 } 1198 readw(&p->xmit_cmds[0]->cmd_status));
1199 }
1199#endif 1200#endif
1200 1201 writew(TBD_LAST | len, &p->xmit_buffs[0]->size);;
1201 p->xmit_buffs[0]->size = TBD_LAST | len; 1202 for (i = 0; i < 16; i++) {
1202 for(i=0;i<16;i++) 1203 writew(0, &p->xmit_cmds[0]->cmd_status);
1203 { 1204 wait_for_scb_cmd(dev);
1204 p->xmit_cmds[0]->cmd_status = 0; 1205 if ((readb(&p->scb->cus) & CU_STATUS) == CU_SUSPEND)
1205 WAIT_4_SCB_CMD(); 1206 writeb(CUC_RESUME, &p->scb->cmd_cuc);
1206 if( (p->scb->cus & CU_STATUS) == CU_SUSPEND) 1207 else {
1207 p->scb->cmd_cuc = CUC_RESUME; 1208 writew(make16(p->xmit_cmds[0]), &p->scb->cbl_offset);
1208 else 1209 writeb(CUC_START, &p->scb->cmd_cuc);
1209 {
1210 p->scb->cbl_offset = make16(p->xmit_cmds[0]);
1211 p->scb->cmd_cuc = CUC_START;
1212 }
1213
1214 ni_attn586();
1215 dev->trans_start = jiffies;
1216 if(!i)
1217 dev_kfree_skb(skb);
1218 WAIT_4_SCB_CMD();
1219 if( (p->scb->cus & CU_ACTIVE)) /* test it, because CU sometimes doesn't start immediately */
1220 break;
1221 if(p->xmit_cmds[0]->cmd_status)
1222 break;
1223 if(i==15)
1224 printk("%s: Can't start transmit-command.\n",dev->name);
1225 } 1210 }
1226# else 1211 ni_attn586();
1227 next_nop = (p->nop_point + 1) & 0x1;
1228 p->xmit_buffs[0]->size = TBD_LAST | len;
1229
1230 p->xmit_cmds[0]->cmd_link = p->nop_cmds[next_nop]->cmd_link
1231 = make16((p->nop_cmds[next_nop]));
1232 p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0;
1233
1234 p->nop_cmds[p->nop_point]->cmd_link = make16((p->xmit_cmds[0]));
1235 dev->trans_start = jiffies; 1212 dev->trans_start = jiffies;
1236 p->nop_point = next_nop; 1213 if (!i)
1237 dev_kfree_skb(skb); 1214 dev_kfree_skb(skb);
1215 wait_for_scb_cmd(dev);
1216 /* test it, because CU sometimes doesn't start immediately */
1217 if (readb(&p->scb->cus) & CU_ACTIVE)
1218 break;
1219 if (readw(&p->xmit_cmds[0]->cmd_status))
1220 break;
1221 if (i == 15)
1222 printk(KERN_WARNING "%s: Can't start transmit-command.\n", dev->name);
1223 }
1224# else
1225 next_nop = (p->nop_point + 1) & 0x1;
1226 writew(TBD_LAST | len, &p->xmit_buffs[0]->size);
1227 writew(make16(p->nop_cmds[next_nop]), &p->xmit_cmds[0]->cmd_link);
1228 writew(make16(p->nop_cmds[next_nop]),
1229 &p->nop_cmds[next_nop]->cmd_link);
1230 writew(0, &p->xmit_cmds[0]->cmd_status);
1231 writew(0, &p->nop_cmds[next_nop]->cmd_status);
1232
1233 writew(make16(p->xmit_cmds[0]), &p->nop_cmds[p->nop_point]->cmd_link);
1234 dev->trans_start = jiffies;
1235 p->nop_point = next_nop;
1236 dev_kfree_skb(skb);
1238# endif 1237# endif
1239#else 1238#else
1240 p->xmit_buffs[p->xmit_count]->size = TBD_LAST | len; 1239 writew(TBD_LAST | len, &p->xmit_buffs[p->xmit_count]->size);
1241 if( (next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS ) 1240 next_nop = p->xmit_count + 1
1242 next_nop = 0; 1241 if (next_nop == NUM_XMIT_BUFFS)
1243 1242 next_nop = 0;
1244 p->xmit_cmds[p->xmit_count]->cmd_status = 0; 1243 writew(0, &p->xmit_cmds[p->xmit_count]->cmd_status);
1245 /* linkpointer of xmit-command already points to next nop cmd */ 1244 /* linkpointer of xmit-command already points to next nop cmd */
1246 p->nop_cmds[next_nop]->cmd_link = make16((p->nop_cmds[next_nop])); 1245 writew(make16(p->nop_cmds[next_nop]),
1247 p->nop_cmds[next_nop]->cmd_status = 0; 1246 &p->nop_cmds[next_nop]->cmd_link);
1248 1247 writew(0, &p->nop_cmds[next_nop]->cmd_status);
1249 p->nop_cmds[p->xmit_count]->cmd_link = make16((p->xmit_cmds[p->xmit_count])); 1248 writew(make16(p->xmit_cmds[p->xmit_count]),
1250 dev->trans_start = jiffies; 1249 &p->nop_cmds[p->xmit_count]->cmd_link);
1251 p->xmit_count = next_nop; 1250 dev->trans_start = jiffies;
1252 1251 p->xmit_count = next_nop;
1253 { 1252 {
1254 unsigned long flags; 1253 unsigned long flags;
1255 save_flags(flags); 1254 spin_lock_irqsave(&p->spinlock);
1256 cli(); 1255 if (p->xmit_count != p->xmit_last)
1257 if(p->xmit_count != p->xmit_last) 1256 netif_wake_queue(dev);
1258 netif_wake_queue(dev); 1257 spin_unlock_irqrestore(&p->spinlock);
1259 p->lock = 0;
1260 restore_flags(flags);
1261 }
1262 dev_kfree_skb(skb);
1263#endif
1264 } 1258 }
1259 dev_kfree_skb(skb);
1260#endif
1265 return 0; 1261 return 0;
1266} 1262}
1267 1263
@@ -1272,16 +1268,17 @@ static int ni52_send_packet(struct sk_buff *skb, struct net_device *dev)
1272static struct net_device_stats *ni52_get_stats(struct net_device *dev) 1268static struct net_device_stats *ni52_get_stats(struct net_device *dev)
1273{ 1269{
1274 struct priv *p = (struct priv *) dev->priv; 1270 struct priv *p = (struct priv *) dev->priv;
1275 unsigned short crc,aln,rsc,ovrn; 1271 unsigned short crc, aln, rsc, ovrn;
1276 1272
1277 crc = p->scb->crc_errs; /* get error-statistic from the ni82586 */ 1273 /* Get error-statistics from the ni82586 */
1278 p->scb->crc_errs = 0; 1274 crc = readw(&p->scb->crc_errs);
1279 aln = p->scb->aln_errs; 1275 writew(0, &p->scb->crc_errs);
1280 p->scb->aln_errs = 0; 1276 aln = readw(&p->scb->aln_errs);
1281 rsc = p->scb->rsc_errs; 1277 writew(0, &p->scb->aln_errs);
1282 p->scb->rsc_errs = 0; 1278 rsc = readw(&p->scb->rsc_errs);
1283 ovrn = p->scb->ovrn_errs; 1279 writew(0, &p->scb->rsc_errs);
1284 p->scb->ovrn_errs = 0; 1280 ovrn = readw(&p->scb->ovrn_errs);
1281 writew(0, &p->scb->ovrn_errs);
1285 1282
1286 p->stats.rx_crc_errors += crc; 1283 p->stats.rx_crc_errors += crc;
1287 p->stats.rx_fifo_errors += ovrn; 1284 p->stats.rx_fifo_errors += ovrn;
@@ -1320,8 +1317,9 @@ MODULE_PARM_DESC(memend, "NI5210 memory end address,required");
1320 1317
1321int __init init_module(void) 1318int __init init_module(void)
1322{ 1319{
1323 if(io <= 0x0 || !memend || !memstart || irq < 2) { 1320 if (io <= 0x0 || !memend || !memstart || irq < 2) {
1324 printk("ni52: Autoprobing not allowed for modules.\nni52: Set symbols 'io' 'irq' 'memstart' and 'memend'\n"); 1321 printk(KERN_ERR "ni52: Autoprobing not allowed for modules.\n");
1322 printk(KERN_ERR "ni52: Set symbols 'io' 'irq' 'memstart' and 'memend'\n");
1325 return -ENODEV; 1323 return -ENODEV;
1326 } 1324 }
1327 dev_ni52 = ni52_probe(-1); 1325 dev_ni52 = ni52_probe(-1);
@@ -1338,42 +1336,6 @@ void __exit cleanup_module(void)
1338} 1336}
1339#endif /* MODULE */ 1337#endif /* MODULE */
1340 1338
1341#if 0
1342/*
1343 * DUMP .. we expect a not running CMD unit and enough space
1344 */
1345void ni52_dump(struct net_device *dev,void *ptr)
1346{
1347 struct priv *p = (struct priv *) dev->priv;
1348 struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr;
1349 int i;
1350
1351 p->scb->cmd_cuc = CUC_ABORT;
1352 ni_attn586();
1353 WAIT_4_SCB_CMD();
1354 WAIT_4_SCB_CMD_RUC();
1355
1356 dump_cmd->cmd_status = 0;
1357 dump_cmd->cmd_cmd = CMD_DUMP | CMD_LAST;
1358 dump_cmd->dump_offset = make16((dump_cmd + 1));
1359 dump_cmd->cmd_link = 0xffff;
1360
1361 p->scb->cbl_offset = make16(dump_cmd);
1362 p->scb->cmd_cuc = CUC_START;
1363 ni_attn586();
1364 WAIT_4_STAT_COMPL(dump_cmd);
1365
1366 if( (dump_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
1367 printk("%s: Can't get dump information.\n",dev->name);
1368
1369 for(i=0;i<170;i++) {
1370 printk("%02x ",(int) ((unsigned char *) (dump_cmd + 1))[i]);
1371 if(i % 24 == 23)
1372 printk("\n");
1373 }
1374 printk("\n");
1375}
1376#endif
1377MODULE_LICENSE("GPL"); 1339MODULE_LICENSE("GPL");
1378 1340
1379/* 1341/*
diff --git a/drivers/net/ni52.h b/drivers/net/ni52.h
index a33ea0884aaf..1f28a4d1a319 100644
--- a/drivers/net/ni52.h
+++ b/drivers/net/ni52.h
@@ -36,12 +36,12 @@
36 36
37struct scp_struct 37struct scp_struct
38{ 38{
39 unsigned short zero_dum0; /* has to be zero */ 39 u16 zero_dum0; /* has to be zero */
40 unsigned char sysbus; /* 0=16Bit,1=8Bit */ 40 u8 sysbus; /* 0=16Bit,1=8Bit */
41 unsigned char zero_dum1; /* has to be zero for 586 */ 41 u8 zero_dum1; /* has to be zero for 586 */
42 unsigned short zero_dum2; 42 u8 zero_dum2;
43 unsigned short zero_dum3; 43 u8 zero_dum3;
44 char *iscp; /* pointer to the iscp-block */ 44 u32 iscp; /* pointer to the iscp-block */
45}; 45};
46 46
47 47
@@ -50,10 +50,10 @@ struct scp_struct
50 */ 50 */
51struct iscp_struct 51struct iscp_struct
52{ 52{
53 unsigned char busy; /* 586 clears after successful init */ 53 u8 busy; /* 586 clears after successful init */
54 unsigned char zero_dummy; /* has to be zero */ 54 u8 zero_dummy; /* has to be zero */
55 unsigned short scb_offset; /* pointeroffset to the scb_base */ 55 u16 scb_offset; /* pointeroffset to the scb_base */
56 char *scb_base; /* base-address of all 16-bit offsets */ 56 u32 scb_base; /* base-address of all 16-bit offsets */
57}; 57};
58 58
59/* 59/*
@@ -61,16 +61,16 @@ struct iscp_struct
61 */ 61 */
62struct scb_struct 62struct scb_struct
63{ 63{
64 unsigned char rus; 64 u8 rus;
65 unsigned char cus; 65 u8 cus;
66 unsigned char cmd_ruc; /* command word: RU part */ 66 u8 cmd_ruc; /* command word: RU part */
67 unsigned char cmd_cuc; /* command word: CU part & ACK */ 67 u8 cmd_cuc; /* command word: CU part & ACK */
68 unsigned short cbl_offset; /* pointeroffset, command block list */ 68 u16 cbl_offset; /* pointeroffset, command block list */
69 unsigned short rfa_offset; /* pointeroffset, receive frame area */ 69 u16 rfa_offset; /* pointeroffset, receive frame area */
70 unsigned short crc_errs; /* CRC-Error counter */ 70 u16 crc_errs; /* CRC-Error counter */
71 unsigned short aln_errs; /* alignmenterror counter */ 71 u16 aln_errs; /* alignmenterror counter */
72 unsigned short rsc_errs; /* Resourceerror counter */ 72 u16 rsc_errs; /* Resourceerror counter */
73 unsigned short ovrn_errs; /* OVerrunerror counter */ 73 u16 ovrn_errs; /* OVerrunerror counter */
74}; 74};
75 75
76/* 76/*
@@ -119,16 +119,16 @@ struct scb_struct
119 */ 119 */
120struct rfd_struct 120struct rfd_struct
121{ 121{
122 unsigned char stat_low; /* status word */ 122 u8 stat_low; /* status word */
123 unsigned char stat_high; /* status word */ 123 u8 stat_high; /* status word */
124 unsigned char rfd_sf; /* 82596 mode only */ 124 u8 rfd_sf; /* 82596 mode only */
125 unsigned char last; /* Bit15,Last Frame on List / Bit14,suspend */ 125 u8 last; /* Bit15,Last Frame on List / Bit14,suspend */
126 unsigned short next; /* linkoffset to next RFD */ 126 u16 next; /* linkoffset to next RFD */
127 unsigned short rbd_offset; /* pointeroffset to RBD-buffer */ 127 u16 rbd_offset; /* pointeroffset to RBD-buffer */
128 unsigned char dest[6]; /* ethernet-address, destination */ 128 u8 dest[6]; /* ethernet-address, destination */
129 unsigned char source[6]; /* ethernet-address, source */ 129 u8 source[6]; /* ethernet-address, source */
130 unsigned short length; /* 802.3 frame-length */ 130 u16 length; /* 802.3 frame-length */
131 unsigned short zero_dummy; /* dummy */ 131 u16 zero_dummy; /* dummy */
132}; 132};
133 133
134#define RFD_LAST 0x80 /* last: last rfd in the list */ 134#define RFD_LAST 0x80 /* last: last rfd in the list */
@@ -153,11 +153,11 @@ struct rfd_struct
153 */ 153 */
154struct rbd_struct 154struct rbd_struct
155{ 155{
156 unsigned short status; /* status word,number of used bytes in buff */ 156 u16 status; /* status word,number of used bytes in buff */
157 unsigned short next; /* pointeroffset to next RBD */ 157 u16 next; /* pointeroffset to next RBD */
158 char *buffer; /* receive buffer address pointer */ 158 u32 buffer; /* receive buffer address pointer */
159 unsigned short size; /* size of this buffer */ 159 u16 size; /* size of this buffer */
160 unsigned short zero_dummy; /* dummy */ 160 u16 zero_dummy; /* dummy */
161}; 161};
162 162
163#define RBD_LAST 0x8000 /* last buffer */ 163#define RBD_LAST 0x8000 /* last buffer */
@@ -195,9 +195,9 @@ struct rbd_struct
195 */ 195 */
196struct nop_cmd_struct 196struct nop_cmd_struct
197{ 197{
198 unsigned short cmd_status; /* status of this command */ 198 u16 cmd_status; /* status of this command */
199 unsigned short cmd_cmd; /* the command itself (+bits) */ 199 u16 cmd_cmd; /* the command itself (+bits) */
200 unsigned short cmd_link; /* offsetpointer to next command */ 200 u16 cmd_link; /* offsetpointer to next command */
201}; 201};
202 202
203/* 203/*
@@ -205,10 +205,10 @@ struct nop_cmd_struct
205 */ 205 */
206struct iasetup_cmd_struct 206struct iasetup_cmd_struct
207{ 207{
208 unsigned short cmd_status; 208 u16 cmd_status;
209 unsigned short cmd_cmd; 209 u16 cmd_cmd;
210 unsigned short cmd_link; 210 u16 cmd_link;
211 unsigned char iaddr[6]; 211 u8 iaddr[6];
212}; 212};
213 213
214/* 214/*
@@ -216,21 +216,21 @@ struct iasetup_cmd_struct
216 */ 216 */
217struct configure_cmd_struct 217struct configure_cmd_struct
218{ 218{
219 unsigned short cmd_status; 219 u16 cmd_status;
220 unsigned short cmd_cmd; 220 u16 cmd_cmd;
221 unsigned short cmd_link; 221 u16 cmd_link;
222 unsigned char byte_cnt; /* size of the config-cmd */ 222 u8 byte_cnt; /* size of the config-cmd */
223 unsigned char fifo; /* fifo/recv monitor */ 223 u8 fifo; /* fifo/recv monitor */
224 unsigned char sav_bf; /* save bad frames (bit7=1)*/ 224 u8 sav_bf; /* save bad frames (bit7=1)*/
225 unsigned char adr_len; /* adr_len(0-2),al_loc(3),pream(4-5),loopbak(6-7)*/ 225 u8 adr_len; /* adr_len(0-2),al_loc(3),pream(4-5),loopbak(6-7)*/
226 unsigned char priority; /* lin_prio(0-2),exp_prio(4-6),bof_metd(7) */ 226 u8 priority; /* lin_prio(0-2),exp_prio(4-6),bof_metd(7) */
227 unsigned char ifs; /* inter frame spacing */ 227 u8 ifs; /* inter frame spacing */
228 unsigned char time_low; /* slot time low */ 228 u8 time_low; /* slot time low */
229 unsigned char time_high; /* slot time high(0-2) and max. retries(4-7) */ 229 u8 time_high; /* slot time high(0-2) and max. retries(4-7) */
230 unsigned char promisc; /* promisc-mode(0) , et al (1-7) */ 230 u8 promisc; /* promisc-mode(0) , et al (1-7) */
231 unsigned char carr_coll; /* carrier(0-3)/collision(4-7) stuff */ 231 u8 carr_coll; /* carrier(0-3)/collision(4-7) stuff */
232 unsigned char fram_len; /* minimal frame len */ 232 u8 fram_len; /* minimal frame len */
233 unsigned char dummy; /* dummy */ 233 u8 dummy; /* dummy */
234}; 234};
235 235
236/* 236/*
@@ -238,11 +238,11 @@ struct configure_cmd_struct
238 */ 238 */
239struct mcsetup_cmd_struct 239struct mcsetup_cmd_struct
240{ 240{
241 unsigned short cmd_status; 241 u16 cmd_status;
242 unsigned short cmd_cmd; 242 u16 cmd_cmd;
243 unsigned short cmd_link; 243 u16 cmd_link;
244 unsigned short mc_cnt; /* number of bytes in the MC-List */ 244 u16 mc_cnt; /* number of bytes in the MC-List */
245 unsigned char mc_list[0][6]; /* pointer to 6 bytes entries */ 245 u8 mc_list[0][6]; /* pointer to 6 bytes entries */
246}; 246};
247 247
248/* 248/*
@@ -250,10 +250,10 @@ struct mcsetup_cmd_struct
250 */ 250 */
251struct dump_cmd_struct 251struct dump_cmd_struct
252{ 252{
253 unsigned short cmd_status; 253 u16 cmd_status;
254 unsigned short cmd_cmd; 254 u16 cmd_cmd;
255 unsigned short cmd_link; 255 u16 cmd_link;
256 unsigned short dump_offset; /* pointeroffset to DUMP space */ 256 u16 dump_offset; /* pointeroffset to DUMP space */
257}; 257};
258 258
259/* 259/*
@@ -261,12 +261,12 @@ struct dump_cmd_struct
261 */ 261 */
262struct transmit_cmd_struct 262struct transmit_cmd_struct
263{ 263{
264 unsigned short cmd_status; 264 u16 cmd_status;
265 unsigned short cmd_cmd; 265 u16 cmd_cmd;
266 unsigned short cmd_link; 266 u16 cmd_link;
267 unsigned short tbd_offset; /* pointeroffset to TBD */ 267 u16 tbd_offset; /* pointeroffset to TBD */
268 unsigned char dest[6]; /* destination address of the frame */ 268 u8 dest[6]; /* destination address of the frame */
269 unsigned short length; /* user defined: 802.3 length / Ether type */ 269 u16 length; /* user defined: 802.3 length / Ether type */
270}; 270};
271 271
272#define TCMD_ERRMASK 0x0fa0 272#define TCMD_ERRMASK 0x0fa0
@@ -281,10 +281,10 @@ struct transmit_cmd_struct
281 281
282struct tdr_cmd_struct 282struct tdr_cmd_struct
283{ 283{
284 unsigned short cmd_status; 284 u16 cmd_status;
285 unsigned short cmd_cmd; 285 u16 cmd_cmd;
286 unsigned short cmd_link; 286 u16 cmd_link;
287 unsigned short status; 287 u16 status;
288}; 288};
289 289
290#define TDR_LNK_OK 0x8000 /* No link problem identified */ 290#define TDR_LNK_OK 0x8000 /* No link problem identified */
@@ -298,9 +298,9 @@ struct tdr_cmd_struct
298 */ 298 */
299struct tbd_struct 299struct tbd_struct
300{ 300{
301 unsigned short size; /* size + EOF-Flag(15) */ 301 u16 size; /* size + EOF-Flag(15) */
302 unsigned short next; /* pointeroffset to next TBD */ 302 u16 next; /* pointeroffset to next TBD */
303 char *buffer; /* pointer to buffer */ 303 u32 buffer; /* pointer to buffer */
304}; 304};
305 305
306#define TBD_LAST 0x8000 /* EOF-Flag, indicates last buffer in list */ 306#define TBD_LAST 0x8000 /* EOF-Flag, indicates last buffer in list */
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index c4b74e9fed20..4eb322e5273d 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -174,7 +174,11 @@ static int homepna[MAX_UNITS];
174#define RX_RING_SIZE (1 << (PCNET32_LOG_RX_BUFFERS)) 174#define RX_RING_SIZE (1 << (PCNET32_LOG_RX_BUFFERS))
175#define RX_MAX_RING_SIZE (1 << (PCNET32_LOG_MAX_RX_BUFFERS)) 175#define RX_MAX_RING_SIZE (1 << (PCNET32_LOG_MAX_RX_BUFFERS))
176 176
177#define PKT_BUF_SZ 1544 177#define PKT_BUF_SKB 1544
178/* actual buffer length after being aligned */
179#define PKT_BUF_SIZE (PKT_BUF_SKB - NET_IP_ALIGN)
180/* chip wants twos complement of the (aligned) buffer length */
181#define NEG_BUF_SIZE (NET_IP_ALIGN - PKT_BUF_SKB)
178 182
179/* Offsets from base I/O address. */ 183/* Offsets from base I/O address. */
180#define PCNET32_WIO_RDP 0x10 184#define PCNET32_WIO_RDP 0x10
@@ -604,7 +608,7 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
604 /* now allocate any new buffers needed */ 608 /* now allocate any new buffers needed */
605 for (; new < size; new++ ) { 609 for (; new < size; new++ ) {
606 struct sk_buff *rx_skbuff; 610 struct sk_buff *rx_skbuff;
607 new_skb_list[new] = dev_alloc_skb(PKT_BUF_SZ); 611 new_skb_list[new] = dev_alloc_skb(PKT_BUF_SKB);
608 if (!(rx_skbuff = new_skb_list[new])) { 612 if (!(rx_skbuff = new_skb_list[new])) {
609 /* keep the original lists and buffers */ 613 /* keep the original lists and buffers */
610 if (netif_msg_drv(lp)) 614 if (netif_msg_drv(lp))
@@ -613,20 +617,20 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
613 dev->name); 617 dev->name);
614 goto free_all_new; 618 goto free_all_new;
615 } 619 }
616 skb_reserve(rx_skbuff, 2); 620 skb_reserve(rx_skbuff, NET_IP_ALIGN);
617 621
618 new_dma_addr_list[new] = 622 new_dma_addr_list[new] =
619 pci_map_single(lp->pci_dev, rx_skbuff->data, 623 pci_map_single(lp->pci_dev, rx_skbuff->data,
620 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE); 624 PKT_BUF_SIZE, PCI_DMA_FROMDEVICE);
621 new_rx_ring[new].base = cpu_to_le32(new_dma_addr_list[new]); 625 new_rx_ring[new].base = cpu_to_le32(new_dma_addr_list[new]);
622 new_rx_ring[new].buf_length = cpu_to_le16(2 - PKT_BUF_SZ); 626 new_rx_ring[new].buf_length = cpu_to_le16(NEG_BUF_SIZE);
623 new_rx_ring[new].status = cpu_to_le16(0x8000); 627 new_rx_ring[new].status = cpu_to_le16(0x8000);
624 } 628 }
625 /* and free any unneeded buffers */ 629 /* and free any unneeded buffers */
626 for (; new < lp->rx_ring_size; new++) { 630 for (; new < lp->rx_ring_size; new++) {
627 if (lp->rx_skbuff[new]) { 631 if (lp->rx_skbuff[new]) {
628 pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[new], 632 pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[new],
629 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE); 633 PKT_BUF_SIZE, PCI_DMA_FROMDEVICE);
630 dev_kfree_skb(lp->rx_skbuff[new]); 634 dev_kfree_skb(lp->rx_skbuff[new]);
631 } 635 }
632 } 636 }
@@ -651,7 +655,7 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
651 for (; --new >= lp->rx_ring_size; ) { 655 for (; --new >= lp->rx_ring_size; ) {
652 if (new_skb_list[new]) { 656 if (new_skb_list[new]) {
653 pci_unmap_single(lp->pci_dev, new_dma_addr_list[new], 657 pci_unmap_single(lp->pci_dev, new_dma_addr_list[new],
654 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE); 658 PKT_BUF_SIZE, PCI_DMA_FROMDEVICE);
655 dev_kfree_skb(new_skb_list[new]); 659 dev_kfree_skb(new_skb_list[new]);
656 } 660 }
657 } 661 }
@@ -678,7 +682,7 @@ static void pcnet32_purge_rx_ring(struct net_device *dev)
678 wmb(); /* Make sure adapter sees owner change */ 682 wmb(); /* Make sure adapter sees owner change */
679 if (lp->rx_skbuff[i]) { 683 if (lp->rx_skbuff[i]) {
680 pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[i], 684 pci_unmap_single(lp->pci_dev, lp->rx_dma_addr[i],
681 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE); 685 PKT_BUF_SIZE, PCI_DMA_FROMDEVICE);
682 dev_kfree_skb_any(lp->rx_skbuff[i]); 686 dev_kfree_skb_any(lp->rx_skbuff[i]);
683 } 687 }
684 lp->rx_skbuff[i] = NULL; 688 lp->rx_skbuff[i] = NULL;
@@ -1201,7 +1205,7 @@ static void pcnet32_rx_entry(struct net_device *dev,
1201 pkt_len = (le32_to_cpu(rxp->msg_length) & 0xfff) - 4; 1205 pkt_len = (le32_to_cpu(rxp->msg_length) & 0xfff) - 4;
1202 1206
1203 /* Discard oversize frames. */ 1207 /* Discard oversize frames. */
1204 if (unlikely(pkt_len > PKT_BUF_SZ - 2)) { 1208 if (unlikely(pkt_len > PKT_BUF_SIZE)) {
1205 if (netif_msg_drv(lp)) 1209 if (netif_msg_drv(lp))
1206 printk(KERN_ERR "%s: Impossible packet size %d!\n", 1210 printk(KERN_ERR "%s: Impossible packet size %d!\n",
1207 dev->name, pkt_len); 1211 dev->name, pkt_len);
@@ -1218,26 +1222,26 @@ static void pcnet32_rx_entry(struct net_device *dev,
1218 if (pkt_len > rx_copybreak) { 1222 if (pkt_len > rx_copybreak) {
1219 struct sk_buff *newskb; 1223 struct sk_buff *newskb;
1220 1224
1221 if ((newskb = dev_alloc_skb(PKT_BUF_SZ))) { 1225 if ((newskb = dev_alloc_skb(PKT_BUF_SKB))) {
1222 skb_reserve(newskb, 2); 1226 skb_reserve(newskb, NET_IP_ALIGN);
1223 skb = lp->rx_skbuff[entry]; 1227 skb = lp->rx_skbuff[entry];
1224 pci_unmap_single(lp->pci_dev, 1228 pci_unmap_single(lp->pci_dev,
1225 lp->rx_dma_addr[entry], 1229 lp->rx_dma_addr[entry],
1226 PKT_BUF_SZ - 2, 1230 PKT_BUF_SIZE,
1227 PCI_DMA_FROMDEVICE); 1231 PCI_DMA_FROMDEVICE);
1228 skb_put(skb, pkt_len); 1232 skb_put(skb, pkt_len);
1229 lp->rx_skbuff[entry] = newskb; 1233 lp->rx_skbuff[entry] = newskb;
1230 lp->rx_dma_addr[entry] = 1234 lp->rx_dma_addr[entry] =
1231 pci_map_single(lp->pci_dev, 1235 pci_map_single(lp->pci_dev,
1232 newskb->data, 1236 newskb->data,
1233 PKT_BUF_SZ - 2, 1237 PKT_BUF_SIZE,
1234 PCI_DMA_FROMDEVICE); 1238 PCI_DMA_FROMDEVICE);
1235 rxp->base = cpu_to_le32(lp->rx_dma_addr[entry]); 1239 rxp->base = cpu_to_le32(lp->rx_dma_addr[entry]);
1236 rx_in_place = 1; 1240 rx_in_place = 1;
1237 } else 1241 } else
1238 skb = NULL; 1242 skb = NULL;
1239 } else { 1243 } else {
1240 skb = dev_alloc_skb(pkt_len + 2); 1244 skb = dev_alloc_skb(pkt_len + NET_IP_ALIGN);
1241 } 1245 }
1242 1246
1243 if (skb == NULL) { 1247 if (skb == NULL) {
@@ -1250,7 +1254,7 @@ static void pcnet32_rx_entry(struct net_device *dev,
1250 } 1254 }
1251 skb->dev = dev; 1255 skb->dev = dev;
1252 if (!rx_in_place) { 1256 if (!rx_in_place) {
1253 skb_reserve(skb, 2); /* 16 byte align */ 1257 skb_reserve(skb, NET_IP_ALIGN);
1254 skb_put(skb, pkt_len); /* Make room */ 1258 skb_put(skb, pkt_len); /* Make room */
1255 pci_dma_sync_single_for_cpu(lp->pci_dev, 1259 pci_dma_sync_single_for_cpu(lp->pci_dev,
1256 lp->rx_dma_addr[entry], 1260 lp->rx_dma_addr[entry],
@@ -1291,7 +1295,7 @@ static int pcnet32_rx(struct net_device *dev, int budget)
1291 * The docs say that the buffer length isn't touched, but Andrew 1295 * The docs say that the buffer length isn't touched, but Andrew
1292 * Boyd of QNX reports that some revs of the 79C965 clear it. 1296 * Boyd of QNX reports that some revs of the 79C965 clear it.
1293 */ 1297 */
1294 rxp->buf_length = cpu_to_le16(2 - PKT_BUF_SZ); 1298 rxp->buf_length = cpu_to_le16(NEG_BUF_SIZE);
1295 wmb(); /* Make sure owner changes after others are visible */ 1299 wmb(); /* Make sure owner changes after others are visible */
1296 rxp->status = cpu_to_le16(0x8000); 1300 rxp->status = cpu_to_le16(0x8000);
1297 entry = (++lp->cur_rx) & lp->rx_mod_mask; 1301 entry = (++lp->cur_rx) & lp->rx_mod_mask;
@@ -1774,8 +1778,8 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1774 memset(dev->dev_addr, 0, sizeof(dev->dev_addr)); 1778 memset(dev->dev_addr, 0, sizeof(dev->dev_addr));
1775 1779
1776 if (pcnet32_debug & NETIF_MSG_PROBE) { 1780 if (pcnet32_debug & NETIF_MSG_PROBE) {
1777 for (i = 0; i < 6; i++) 1781 DECLARE_MAC_BUF(mac);
1778 printk(" %2.2x", dev->dev_addr[i]); 1782 printk(" %s", print_mac(mac, dev->dev_addr));
1779 1783
1780 /* Version 0x2623 and 0x2624 */ 1784 /* Version 0x2623 and 0x2624 */
1781 if (((chip_version + 1) & 0xfffe) == 0x2624) { 1785 if (((chip_version + 1) & 0xfffe) == 0x2624) {
@@ -2396,7 +2400,7 @@ static int pcnet32_init_ring(struct net_device *dev)
2396 if (rx_skbuff == NULL) { 2400 if (rx_skbuff == NULL) {
2397 if (! 2401 if (!
2398 (rx_skbuff = lp->rx_skbuff[i] = 2402 (rx_skbuff = lp->rx_skbuff[i] =
2399 dev_alloc_skb(PKT_BUF_SZ))) { 2403 dev_alloc_skb(PKT_BUF_SKB))) {
2400 /* there is not much, we can do at this point */ 2404 /* there is not much, we can do at this point */
2401 if (netif_msg_drv(lp)) 2405 if (netif_msg_drv(lp))
2402 printk(KERN_ERR 2406 printk(KERN_ERR
@@ -2404,16 +2408,16 @@ static int pcnet32_init_ring(struct net_device *dev)
2404 dev->name); 2408 dev->name);
2405 return -1; 2409 return -1;
2406 } 2410 }
2407 skb_reserve(rx_skbuff, 2); 2411 skb_reserve(rx_skbuff, NET_IP_ALIGN);
2408 } 2412 }
2409 2413
2410 rmb(); 2414 rmb();
2411 if (lp->rx_dma_addr[i] == 0) 2415 if (lp->rx_dma_addr[i] == 0)
2412 lp->rx_dma_addr[i] = 2416 lp->rx_dma_addr[i] =
2413 pci_map_single(lp->pci_dev, rx_skbuff->data, 2417 pci_map_single(lp->pci_dev, rx_skbuff->data,
2414 PKT_BUF_SZ - 2, PCI_DMA_FROMDEVICE); 2418 PKT_BUF_SIZE, PCI_DMA_FROMDEVICE);
2415 lp->rx_ring[i].base = cpu_to_le32(lp->rx_dma_addr[i]); 2419 lp->rx_ring[i].base = cpu_to_le32(lp->rx_dma_addr[i]);
2416 lp->rx_ring[i].buf_length = cpu_to_le16(2 - PKT_BUF_SZ); 2420 lp->rx_ring[i].buf_length = cpu_to_le16(NEG_BUF_SIZE);
2417 wmb(); /* Make sure owner changes after all others are visible */ 2421 wmb(); /* Make sure owner changes after all others are visible */
2418 lp->rx_ring[i].status = cpu_to_le16(0x8000); 2422 lp->rx_ring[i].status = cpu_to_le16(0x8000);
2419 } 2423 }
diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c
index 73b6d39ef6b0..ca9b040f9ad9 100644
--- a/drivers/net/phy/fixed.c
+++ b/drivers/net/phy/fixed.c
@@ -236,12 +236,12 @@ module_init(fixed_mdio_bus_init);
236static void __exit fixed_mdio_bus_exit(void) 236static void __exit fixed_mdio_bus_exit(void)
237{ 237{
238 struct fixed_mdio_bus *fmb = &platform_fmb; 238 struct fixed_mdio_bus *fmb = &platform_fmb;
239 struct fixed_phy *fp; 239 struct fixed_phy *fp, *tmp;
240 240
241 mdiobus_unregister(&fmb->mii_bus); 241 mdiobus_unregister(&fmb->mii_bus);
242 platform_device_unregister(pdev); 242 platform_device_unregister(pdev);
243 243
244 list_for_each_entry(fp, &fmb->phys, node) { 244 list_for_each_entry_safe(fp, tmp, &fmb->phys, node) {
245 list_del(&fp->node); 245 list_del(&fp->node);
246 kfree(fp); 246 kfree(fp);
247 } 247 }
diff --git a/drivers/net/ps3_gelic_net.c b/drivers/net/ps3_gelic_net.c
index 055af081e027..7eb6e7e848f4 100644
--- a/drivers/net/ps3_gelic_net.c
+++ b/drivers/net/ps3_gelic_net.c
@@ -46,29 +46,25 @@
46#include <asm/lv1call.h> 46#include <asm/lv1call.h>
47 47
48#include "ps3_gelic_net.h" 48#include "ps3_gelic_net.h"
49#include "ps3_gelic_wireless.h"
49 50
50#define DRV_NAME "Gelic Network Driver" 51#define DRV_NAME "Gelic Network Driver"
51#define DRV_VERSION "1.0" 52#define DRV_VERSION "2.0"
52 53
53MODULE_AUTHOR("SCE Inc."); 54MODULE_AUTHOR("SCE Inc.");
54MODULE_DESCRIPTION("Gelic Network driver"); 55MODULE_DESCRIPTION("Gelic Network driver");
55MODULE_LICENSE("GPL"); 56MODULE_LICENSE("GPL");
56 57
57static inline struct device *ctodev(struct gelic_net_card *card) 58
58{ 59static inline void gelic_card_enable_rxdmac(struct gelic_card *card);
59 return &card->dev->core; 60static inline void gelic_card_disable_rxdmac(struct gelic_card *card);
60} 61static inline void gelic_card_disable_txdmac(struct gelic_card *card);
61static inline u64 bus_id(struct gelic_net_card *card) 62static inline void gelic_card_reset_chain(struct gelic_card *card,
62{ 63 struct gelic_descr_chain *chain,
63 return card->dev->bus_id; 64 struct gelic_descr *start_descr);
64}
65static inline u64 dev_id(struct gelic_net_card *card)
66{
67 return card->dev->dev_id;
68}
69 65
70/* set irq_mask */ 66/* set irq_mask */
71static int gelic_net_set_irq_mask(struct gelic_net_card *card, u64 mask) 67int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask)
72{ 68{
73 int status; 69 int status;
74 70
@@ -76,54 +72,110 @@ static int gelic_net_set_irq_mask(struct gelic_net_card *card, u64 mask)
76 mask, 0); 72 mask, 0);
77 if (status) 73 if (status)
78 dev_info(ctodev(card), 74 dev_info(ctodev(card),
79 "lv1_net_set_interrupt_mask failed %d\n", status); 75 "%s failed %d\n", __func__, status);
80 return status; 76 return status;
81} 77}
82static inline void gelic_net_rx_irq_on(struct gelic_net_card *card) 78
79static inline void gelic_card_rx_irq_on(struct gelic_card *card)
83{ 80{
84 gelic_net_set_irq_mask(card, card->ghiintmask | GELIC_NET_RXINT); 81 card->irq_mask |= GELIC_CARD_RXINT;
82 gelic_card_set_irq_mask(card, card->irq_mask);
85} 83}
86static inline void gelic_net_rx_irq_off(struct gelic_net_card *card) 84static inline void gelic_card_rx_irq_off(struct gelic_card *card)
87{ 85{
88 gelic_net_set_irq_mask(card, card->ghiintmask & ~GELIC_NET_RXINT); 86 card->irq_mask &= ~GELIC_CARD_RXINT;
87 gelic_card_set_irq_mask(card, card->irq_mask);
88}
89
90static void gelic_card_get_ether_port_status(struct gelic_card *card,
91 int inform)
92{
93 u64 v2;
94 struct net_device *ether_netdev;
95
96 lv1_net_control(bus_id(card), dev_id(card),
97 GELIC_LV1_GET_ETH_PORT_STATUS,
98 GELIC_LV1_VLAN_TX_ETHERNET, 0, 0,
99 &card->ether_port_status, &v2);
100
101 if (inform) {
102 ether_netdev = card->netdev[GELIC_PORT_ETHERNET];
103 if (card->ether_port_status & GELIC_LV1_ETHER_LINK_UP)
104 netif_carrier_on(ether_netdev);
105 else
106 netif_carrier_off(ether_netdev);
107 }
108}
109
110void gelic_card_up(struct gelic_card *card)
111{
112 pr_debug("%s: called\n", __func__);
113 down(&card->updown_lock);
114 if (atomic_inc_return(&card->users) == 1) {
115 pr_debug("%s: real do\n", __func__);
116 /* enable irq */
117 gelic_card_set_irq_mask(card, card->irq_mask);
118 /* start rx */
119 gelic_card_enable_rxdmac(card);
120
121 napi_enable(&card->napi);
122 }
123 up(&card->updown_lock);
124 pr_debug("%s: done\n", __func__);
89} 125}
126
127void gelic_card_down(struct gelic_card *card)
128{
129 u64 mask;
130 pr_debug("%s: called\n", __func__);
131 down(&card->updown_lock);
132 if (atomic_dec_if_positive(&card->users) == 0) {
133 pr_debug("%s: real do\n", __func__);
134 napi_disable(&card->napi);
135 /*
136 * Disable irq. Wireless interrupts will
137 * be disabled later if any
138 */
139 mask = card->irq_mask & (GELIC_CARD_WLAN_EVENT_RECEIVED |
140 GELIC_CARD_WLAN_COMMAND_COMPLETED);
141 gelic_card_set_irq_mask(card, mask);
142 /* stop rx */
143 gelic_card_disable_rxdmac(card);
144 gelic_card_reset_chain(card, &card->rx_chain,
145 card->descr + GELIC_NET_TX_DESCRIPTORS);
146 /* stop tx */
147 gelic_card_disable_txdmac(card);
148 }
149 up(&card->updown_lock);
150 pr_debug("%s: done\n", __func__);
151}
152
90/** 153/**
91 * gelic_net_get_descr_status -- returns the status of a descriptor 154 * gelic_descr_get_status -- returns the status of a descriptor
92 * @descr: descriptor to look at 155 * @descr: descriptor to look at
93 * 156 *
94 * returns the status as in the dmac_cmd_status field of the descriptor 157 * returns the status as in the dmac_cmd_status field of the descriptor
95 */ 158 */
96static enum gelic_net_descr_status 159static enum gelic_descr_dma_status
97gelic_net_get_descr_status(struct gelic_net_descr *descr) 160gelic_descr_get_status(struct gelic_descr *descr)
98{ 161{
99 u32 cmd_status; 162 return be32_to_cpu(descr->dmac_cmd_status) & GELIC_DESCR_DMA_STAT_MASK;
100
101 cmd_status = descr->dmac_cmd_status;
102 cmd_status >>= GELIC_NET_DESCR_IND_PROC_SHIFT;
103 return cmd_status;
104} 163}
105 164
106/** 165/**
107 * gelic_net_set_descr_status -- sets the status of a descriptor 166 * gelic_descr_set_status -- sets the status of a descriptor
108 * @descr: descriptor to change 167 * @descr: descriptor to change
109 * @status: status to set in the descriptor 168 * @status: status to set in the descriptor
110 * 169 *
111 * changes the status to the specified value. Doesn't change other bits 170 * changes the status to the specified value. Doesn't change other bits
112 * in the status 171 * in the status
113 */ 172 */
114static void gelic_net_set_descr_status(struct gelic_net_descr *descr, 173static void gelic_descr_set_status(struct gelic_descr *descr,
115 enum gelic_net_descr_status status) 174 enum gelic_descr_dma_status status)
116{ 175{
117 u32 cmd_status; 176 descr->dmac_cmd_status = cpu_to_be32(status |
118 177 (be32_to_cpu(descr->dmac_cmd_status) &
119 /* read the status */ 178 ~GELIC_DESCR_DMA_STAT_MASK));
120 cmd_status = descr->dmac_cmd_status;
121 /* clean the upper 4 bits */
122 cmd_status &= GELIC_NET_DESCR_IND_PROC_MASKO;
123 /* add the status to it */
124 cmd_status |= ((u32)status) << GELIC_NET_DESCR_IND_PROC_SHIFT;
125 /* and write it back */
126 descr->dmac_cmd_status = cmd_status;
127 /* 179 /*
128 * dma_cmd_status field is used to indicate whether the descriptor 180 * dma_cmd_status field is used to indicate whether the descriptor
129 * is valid or not. 181 * is valid or not.
@@ -134,24 +186,24 @@ static void gelic_net_set_descr_status(struct gelic_net_descr *descr,
134} 186}
135 187
136/** 188/**
137 * gelic_net_free_chain - free descriptor chain 189 * gelic_card_free_chain - free descriptor chain
138 * @card: card structure 190 * @card: card structure
139 * @descr_in: address of desc 191 * @descr_in: address of desc
140 */ 192 */
141static void gelic_net_free_chain(struct gelic_net_card *card, 193static void gelic_card_free_chain(struct gelic_card *card,
142 struct gelic_net_descr *descr_in) 194 struct gelic_descr *descr_in)
143{ 195{
144 struct gelic_net_descr *descr; 196 struct gelic_descr *descr;
145 197
146 for (descr = descr_in; descr && descr->bus_addr; descr = descr->next) { 198 for (descr = descr_in; descr && descr->bus_addr; descr = descr->next) {
147 dma_unmap_single(ctodev(card), descr->bus_addr, 199 dma_unmap_single(ctodev(card), descr->bus_addr,
148 GELIC_NET_DESCR_SIZE, DMA_BIDIRECTIONAL); 200 GELIC_DESCR_SIZE, DMA_BIDIRECTIONAL);
149 descr->bus_addr = 0; 201 descr->bus_addr = 0;
150 } 202 }
151} 203}
152 204
153/** 205/**
154 * gelic_net_init_chain - links descriptor chain 206 * gelic_card_init_chain - links descriptor chain
155 * @card: card structure 207 * @card: card structure
156 * @chain: address of chain 208 * @chain: address of chain
157 * @start_descr: address of descriptor array 209 * @start_descr: address of descriptor array
@@ -162,22 +214,22 @@ static void gelic_net_free_chain(struct gelic_net_card *card,
162 * 214 *
163 * returns 0 on success, <0 on failure 215 * returns 0 on success, <0 on failure
164 */ 216 */
165static int gelic_net_init_chain(struct gelic_net_card *card, 217static int gelic_card_init_chain(struct gelic_card *card,
166 struct gelic_net_descr_chain *chain, 218 struct gelic_descr_chain *chain,
167 struct gelic_net_descr *start_descr, int no) 219 struct gelic_descr *start_descr, int no)
168{ 220{
169 int i; 221 int i;
170 struct gelic_net_descr *descr; 222 struct gelic_descr *descr;
171 223
172 descr = start_descr; 224 descr = start_descr;
173 memset(descr, 0, sizeof(*descr) * no); 225 memset(descr, 0, sizeof(*descr) * no);
174 226
175 /* set up the hardware pointers in each descriptor */ 227 /* set up the hardware pointers in each descriptor */
176 for (i = 0; i < no; i++, descr++) { 228 for (i = 0; i < no; i++, descr++) {
177 gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); 229 gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
178 descr->bus_addr = 230 descr->bus_addr =
179 dma_map_single(ctodev(card), descr, 231 dma_map_single(ctodev(card), descr,
180 GELIC_NET_DESCR_SIZE, 232 GELIC_DESCR_SIZE,
181 DMA_BIDIRECTIONAL); 233 DMA_BIDIRECTIONAL);
182 234
183 if (!descr->bus_addr) 235 if (!descr->bus_addr)
@@ -193,7 +245,7 @@ static int gelic_net_init_chain(struct gelic_net_card *card,
193 /* chain bus addr of hw descriptor */ 245 /* chain bus addr of hw descriptor */
194 descr = start_descr; 246 descr = start_descr;
195 for (i = 0; i < no; i++, descr++) { 247 for (i = 0; i < no; i++, descr++) {
196 descr->next_descr_addr = descr->next->bus_addr; 248 descr->next_descr_addr = cpu_to_be32(descr->next->bus_addr);
197 } 249 }
198 250
199 chain->head = start_descr; 251 chain->head = start_descr;
@@ -208,13 +260,38 @@ iommu_error:
208 for (i--, descr--; 0 <= i; i--, descr--) 260 for (i--, descr--; 0 <= i; i--, descr--)
209 if (descr->bus_addr) 261 if (descr->bus_addr)
210 dma_unmap_single(ctodev(card), descr->bus_addr, 262 dma_unmap_single(ctodev(card), descr->bus_addr,
211 GELIC_NET_DESCR_SIZE, 263 GELIC_DESCR_SIZE,
212 DMA_BIDIRECTIONAL); 264 DMA_BIDIRECTIONAL);
213 return -ENOMEM; 265 return -ENOMEM;
214} 266}
215 267
216/** 268/**
217 * gelic_net_prepare_rx_descr - reinitializes a rx descriptor 269 * gelic_card_reset_chain - reset status of a descriptor chain
270 * @card: card structure
271 * @chain: address of chain
272 * @start_descr: address of descriptor array
273 *
274 * Reset the status of dma descriptors to ready state
275 * and re-initialize the hardware chain for later use
276 */
277static void gelic_card_reset_chain(struct gelic_card *card,
278 struct gelic_descr_chain *chain,
279 struct gelic_descr *start_descr)
280{
281 struct gelic_descr *descr;
282
283 for (descr = start_descr; start_descr != descr->next; descr++) {
284 gelic_descr_set_status(descr, GELIC_DESCR_DMA_CARDOWNED);
285 descr->next_descr_addr = cpu_to_be32(descr->next->bus_addr);
286 }
287
288 chain->head = start_descr;
289 chain->tail = (descr - 1);
290
291 (descr - 1)->next_descr_addr = 0;
292}
293/**
294 * gelic_descr_prepare_rx - reinitializes a rx descriptor
218 * @card: card structure 295 * @card: card structure
219 * @descr: descriptor to re-init 296 * @descr: descriptor to re-init
220 * 297 *
@@ -223,29 +300,27 @@ iommu_error:
223 * allocates a new rx skb, iommu-maps it and attaches it to the descriptor. 300 * allocates a new rx skb, iommu-maps it and attaches it to the descriptor.
224 * Activate the descriptor state-wise 301 * Activate the descriptor state-wise
225 */ 302 */
226static int gelic_net_prepare_rx_descr(struct gelic_net_card *card, 303static int gelic_descr_prepare_rx(struct gelic_card *card,
227 struct gelic_net_descr *descr) 304 struct gelic_descr *descr)
228{ 305{
229 int offset; 306 int offset;
230 unsigned int bufsize; 307 unsigned int bufsize;
231 308
232 if (gelic_net_get_descr_status(descr) != GELIC_NET_DESCR_NOT_IN_USE) { 309 if (gelic_descr_get_status(descr) != GELIC_DESCR_DMA_NOT_IN_USE)
233 dev_info(ctodev(card), "%s: ERROR status \n", __func__); 310 dev_info(ctodev(card), "%s: ERROR status \n", __func__);
234 }
235 /* we need to round up the buffer size to a multiple of 128 */ 311 /* we need to round up the buffer size to a multiple of 128 */
236 bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN); 312 bufsize = ALIGN(GELIC_NET_MAX_MTU, GELIC_NET_RXBUF_ALIGN);
237 313
238 /* and we need to have it 128 byte aligned, therefore we allocate a 314 /* and we need to have it 128 byte aligned, therefore we allocate a
239 * bit more */ 315 * bit more */
240 descr->skb = netdev_alloc_skb(card->netdev, 316 descr->skb = dev_alloc_skb(bufsize + GELIC_NET_RXBUF_ALIGN - 1);
241 bufsize + GELIC_NET_RXBUF_ALIGN - 1);
242 if (!descr->skb) { 317 if (!descr->skb) {
243 descr->buf_addr = 0; /* tell DMAC don't touch memory */ 318 descr->buf_addr = 0; /* tell DMAC don't touch memory */
244 dev_info(ctodev(card), 319 dev_info(ctodev(card),
245 "%s:allocate skb failed !!\n", __func__); 320 "%s:allocate skb failed !!\n", __func__);
246 return -ENOMEM; 321 return -ENOMEM;
247 } 322 }
248 descr->buf_size = bufsize; 323 descr->buf_size = cpu_to_be32(bufsize);
249 descr->dmac_cmd_status = 0; 324 descr->dmac_cmd_status = 0;
250 descr->result_size = 0; 325 descr->result_size = 0;
251 descr->valid_size = 0; 326 descr->valid_size = 0;
@@ -256,63 +331,64 @@ static int gelic_net_prepare_rx_descr(struct gelic_net_card *card,
256 if (offset) 331 if (offset)
257 skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset); 332 skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset);
258 /* io-mmu-map the skb */ 333 /* io-mmu-map the skb */
259 descr->buf_addr = dma_map_single(ctodev(card), descr->skb->data, 334 descr->buf_addr = cpu_to_be32(dma_map_single(ctodev(card),
260 GELIC_NET_MAX_MTU, 335 descr->skb->data,
261 DMA_FROM_DEVICE); 336 GELIC_NET_MAX_MTU,
337 DMA_FROM_DEVICE));
262 if (!descr->buf_addr) { 338 if (!descr->buf_addr) {
263 dev_kfree_skb_any(descr->skb); 339 dev_kfree_skb_any(descr->skb);
264 descr->skb = NULL; 340 descr->skb = NULL;
265 dev_info(ctodev(card), 341 dev_info(ctodev(card),
266 "%s:Could not iommu-map rx buffer\n", __func__); 342 "%s:Could not iommu-map rx buffer\n", __func__);
267 gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); 343 gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
268 return -ENOMEM; 344 return -ENOMEM;
269 } else { 345 } else {
270 gelic_net_set_descr_status(descr, GELIC_NET_DESCR_CARDOWNED); 346 gelic_descr_set_status(descr, GELIC_DESCR_DMA_CARDOWNED);
271 return 0; 347 return 0;
272 } 348 }
273} 349}
274 350
275/** 351/**
276 * gelic_net_release_rx_chain - free all skb of rx descr 352 * gelic_card_release_rx_chain - free all skb of rx descr
277 * @card: card structure 353 * @card: card structure
278 * 354 *
279 */ 355 */
280static void gelic_net_release_rx_chain(struct gelic_net_card *card) 356static void gelic_card_release_rx_chain(struct gelic_card *card)
281{ 357{
282 struct gelic_net_descr *descr = card->rx_chain.head; 358 struct gelic_descr *descr = card->rx_chain.head;
283 359
284 do { 360 do {
285 if (descr->skb) { 361 if (descr->skb) {
286 dma_unmap_single(ctodev(card), 362 dma_unmap_single(ctodev(card),
287 descr->buf_addr, 363 be32_to_cpu(descr->buf_addr),
288 descr->skb->len, 364 descr->skb->len,
289 DMA_FROM_DEVICE); 365 DMA_FROM_DEVICE);
290 descr->buf_addr = 0; 366 descr->buf_addr = 0;
291 dev_kfree_skb_any(descr->skb); 367 dev_kfree_skb_any(descr->skb);
292 descr->skb = NULL; 368 descr->skb = NULL;
293 gelic_net_set_descr_status(descr, 369 gelic_descr_set_status(descr,
294 GELIC_NET_DESCR_NOT_IN_USE); 370 GELIC_DESCR_DMA_NOT_IN_USE);
295 } 371 }
296 descr = descr->next; 372 descr = descr->next;
297 } while (descr != card->rx_chain.head); 373 } while (descr != card->rx_chain.head);
298} 374}
299 375
300/** 376/**
301 * gelic_net_fill_rx_chain - fills descriptors/skbs in the rx chains 377 * gelic_card_fill_rx_chain - fills descriptors/skbs in the rx chains
302 * @card: card structure 378 * @card: card structure
303 * 379 *
304 * fills all descriptors in the rx chain: allocates skbs 380 * fills all descriptors in the rx chain: allocates skbs
305 * and iommu-maps them. 381 * and iommu-maps them.
306 * returns 0 on success, <0 on failure 382 * returns 0 on success, < 0 on failure
307 */ 383 */
308static int gelic_net_fill_rx_chain(struct gelic_net_card *card) 384static int gelic_card_fill_rx_chain(struct gelic_card *card)
309{ 385{
310 struct gelic_net_descr *descr = card->rx_chain.head; 386 struct gelic_descr *descr = card->rx_chain.head;
311 int ret; 387 int ret;
312 388
313 do { 389 do {
314 if (!descr->skb) { 390 if (!descr->skb) {
315 ret = gelic_net_prepare_rx_descr(card, descr); 391 ret = gelic_descr_prepare_rx(card, descr);
316 if (ret) 392 if (ret)
317 goto rewind; 393 goto rewind;
318 } 394 }
@@ -321,41 +397,41 @@ static int gelic_net_fill_rx_chain(struct gelic_net_card *card)
321 397
322 return 0; 398 return 0;
323rewind: 399rewind:
324 gelic_net_release_rx_chain(card); 400 gelic_card_release_rx_chain(card);
325 return ret; 401 return ret;
326} 402}
327 403
328/** 404/**
329 * gelic_net_alloc_rx_skbs - allocates rx skbs in rx descriptor chains 405 * gelic_card_alloc_rx_skbs - allocates rx skbs in rx descriptor chains
330 * @card: card structure 406 * @card: card structure
331 * 407 *
332 * returns 0 on success, <0 on failure 408 * returns 0 on success, < 0 on failure
333 */ 409 */
334static int gelic_net_alloc_rx_skbs(struct gelic_net_card *card) 410static int gelic_card_alloc_rx_skbs(struct gelic_card *card)
335{ 411{
336 struct gelic_net_descr_chain *chain; 412 struct gelic_descr_chain *chain;
337 int ret; 413 int ret;
338 chain = &card->rx_chain; 414 chain = &card->rx_chain;
339 ret = gelic_net_fill_rx_chain(card); 415 ret = gelic_card_fill_rx_chain(card);
340 chain->head = card->rx_top->prev; /* point to the last */ 416 chain->tail = card->rx_top->prev; /* point to the last */
341 return ret; 417 return ret;
342} 418}
343 419
344/** 420/**
345 * gelic_net_release_tx_descr - processes a used tx descriptor 421 * gelic_descr_release_tx - processes a used tx descriptor
346 * @card: card structure 422 * @card: card structure
347 * @descr: descriptor to release 423 * @descr: descriptor to release
348 * 424 *
349 * releases a used tx descriptor (unmapping, freeing of skb) 425 * releases a used tx descriptor (unmapping, freeing of skb)
350 */ 426 */
351static void gelic_net_release_tx_descr(struct gelic_net_card *card, 427static void gelic_descr_release_tx(struct gelic_card *card,
352 struct gelic_net_descr *descr) 428 struct gelic_descr *descr)
353{ 429{
354 struct sk_buff *skb = descr->skb; 430 struct sk_buff *skb = descr->skb;
355 431
356 BUG_ON(!(descr->data_status & (1 << GELIC_NET_TXDESC_TAIL))); 432 BUG_ON(!(be32_to_cpu(descr->data_status) & GELIC_DESCR_TX_TAIL));
357 433
358 dma_unmap_single(ctodev(card), descr->buf_addr, skb->len, 434 dma_unmap_single(ctodev(card), be32_to_cpu(descr->buf_addr), skb->len,
359 DMA_TO_DEVICE); 435 DMA_TO_DEVICE);
360 dev_kfree_skb_any(skb); 436 dev_kfree_skb_any(skb);
361 437
@@ -369,59 +445,75 @@ static void gelic_net_release_tx_descr(struct gelic_net_card *card,
369 descr->skb = NULL; 445 descr->skb = NULL;
370 446
371 /* set descr status */ 447 /* set descr status */
372 gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); 448 gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
449}
450
451static void gelic_card_stop_queues(struct gelic_card *card)
452{
453 netif_stop_queue(card->netdev[GELIC_PORT_ETHERNET]);
454
455 if (card->netdev[GELIC_PORT_WIRELESS])
456 netif_stop_queue(card->netdev[GELIC_PORT_WIRELESS]);
373} 457}
458static void gelic_card_wake_queues(struct gelic_card *card)
459{
460 netif_wake_queue(card->netdev[GELIC_PORT_ETHERNET]);
374 461
462 if (card->netdev[GELIC_PORT_WIRELESS])
463 netif_wake_queue(card->netdev[GELIC_PORT_WIRELESS]);
464}
375/** 465/**
376 * gelic_net_release_tx_chain - processes sent tx descriptors 466 * gelic_card_release_tx_chain - processes sent tx descriptors
377 * @card: adapter structure 467 * @card: adapter structure
378 * @stop: net_stop sequence 468 * @stop: net_stop sequence
379 * 469 *
380 * releases the tx descriptors that gelic has finished with 470 * releases the tx descriptors that gelic has finished with
381 */ 471 */
382static void gelic_net_release_tx_chain(struct gelic_net_card *card, int stop) 472static void gelic_card_release_tx_chain(struct gelic_card *card, int stop)
383{ 473{
384 struct gelic_net_descr_chain *tx_chain; 474 struct gelic_descr_chain *tx_chain;
385 enum gelic_net_descr_status status; 475 enum gelic_descr_dma_status status;
476 struct net_device *netdev;
386 int release = 0; 477 int release = 0;
387 478
388 for (tx_chain = &card->tx_chain; 479 for (tx_chain = &card->tx_chain;
389 tx_chain->head != tx_chain->tail && tx_chain->tail; 480 tx_chain->head != tx_chain->tail && tx_chain->tail;
390 tx_chain->tail = tx_chain->tail->next) { 481 tx_chain->tail = tx_chain->tail->next) {
391 status = gelic_net_get_descr_status(tx_chain->tail); 482 status = gelic_descr_get_status(tx_chain->tail);
483 netdev = tx_chain->tail->skb->dev;
392 switch (status) { 484 switch (status) {
393 case GELIC_NET_DESCR_RESPONSE_ERROR: 485 case GELIC_DESCR_DMA_RESPONSE_ERROR:
394 case GELIC_NET_DESCR_PROTECTION_ERROR: 486 case GELIC_DESCR_DMA_PROTECTION_ERROR:
395 case GELIC_NET_DESCR_FORCE_END: 487 case GELIC_DESCR_DMA_FORCE_END:
396 if (printk_ratelimit()) 488 if (printk_ratelimit())
397 dev_info(ctodev(card), 489 dev_info(ctodev(card),
398 "%s: forcing end of tx descriptor " \ 490 "%s: forcing end of tx descriptor " \
399 "with status %x\n", 491 "with status %x\n",
400 __func__, status); 492 __func__, status);
401 card->netdev->stats.tx_dropped++; 493 netdev->stats.tx_dropped++;
402 break; 494 break;
403 495
404 case GELIC_NET_DESCR_COMPLETE: 496 case GELIC_DESCR_DMA_COMPLETE:
405 if (tx_chain->tail->skb) { 497 if (tx_chain->tail->skb) {
406 card->netdev->stats.tx_packets++; 498 netdev->stats.tx_packets++;
407 card->netdev->stats.tx_bytes += 499 netdev->stats.tx_bytes +=
408 tx_chain->tail->skb->len; 500 tx_chain->tail->skb->len;
409 } 501 }
410 break; 502 break;
411 503
412 case GELIC_NET_DESCR_CARDOWNED: 504 case GELIC_DESCR_DMA_CARDOWNED:
413 /* pending tx request */ 505 /* pending tx request */
414 default: 506 default:
415 /* any other value (== GELIC_NET_DESCR_NOT_IN_USE) */ 507 /* any other value (== GELIC_DESCR_DMA_NOT_IN_USE) */
416 if (!stop) 508 if (!stop)
417 goto out; 509 goto out;
418 } 510 }
419 gelic_net_release_tx_descr(card, tx_chain->tail); 511 gelic_descr_release_tx(card, tx_chain->tail);
420 release ++; 512 release ++;
421 } 513 }
422out: 514out:
423 if (!stop && release) 515 if (!stop && release)
424 netif_wake_queue(card->netdev); 516 gelic_card_wake_queues(card);
425} 517}
426 518
427/** 519/**
@@ -432,9 +524,9 @@ out:
432 * netdev interface. It also sets up multicast, allmulti and promisc 524 * netdev interface. It also sets up multicast, allmulti and promisc
433 * flags appropriately 525 * flags appropriately
434 */ 526 */
435static void gelic_net_set_multi(struct net_device *netdev) 527void gelic_net_set_multi(struct net_device *netdev)
436{ 528{
437 struct gelic_net_card *card = netdev_priv(netdev); 529 struct gelic_card *card = netdev_card(netdev);
438 struct dev_mc_list *mc; 530 struct dev_mc_list *mc;
439 unsigned int i; 531 unsigned int i;
440 uint8_t *p; 532 uint8_t *p;
@@ -456,8 +548,8 @@ static void gelic_net_set_multi(struct net_device *netdev)
456 "lv1_net_add_multicast_address failed, %d\n", 548 "lv1_net_add_multicast_address failed, %d\n",
457 status); 549 status);
458 550
459 if (netdev->flags & IFF_ALLMULTI 551 if ((netdev->flags & IFF_ALLMULTI) ||
460 || netdev->mc_count > GELIC_NET_MC_COUNT_MAX) { /* list max */ 552 (netdev->mc_count > GELIC_NET_MC_COUNT_MAX)) {
461 status = lv1_net_add_multicast_address(bus_id(card), 553 status = lv1_net_add_multicast_address(bus_id(card),
462 dev_id(card), 554 dev_id(card),
463 0, 1); 555 0, 1);
@@ -468,7 +560,7 @@ static void gelic_net_set_multi(struct net_device *netdev)
468 return; 560 return;
469 } 561 }
470 562
471 /* set multicast address */ 563 /* set multicast addresses */
472 for (mc = netdev->mc_list; mc; mc = mc->next) { 564 for (mc = netdev->mc_list; mc; mc = mc->next) {
473 addr = 0; 565 addr = 0;
474 p = mc->dmi_addr; 566 p = mc->dmi_addr;
@@ -487,31 +579,42 @@ static void gelic_net_set_multi(struct net_device *netdev)
487} 579}
488 580
489/** 581/**
490 * gelic_net_enable_rxdmac - enables the receive DMA controller 582 * gelic_card_enable_rxdmac - enables the receive DMA controller
491 * @card: card structure 583 * @card: card structure
492 * 584 *
493 * gelic_net_enable_rxdmac enables the DMA controller by setting RX_DMA_EN 585 * gelic_card_enable_rxdmac enables the DMA controller by setting RX_DMA_EN
494 * in the GDADMACCNTR register 586 * in the GDADMACCNTR register
495 */ 587 */
496static inline void gelic_net_enable_rxdmac(struct gelic_net_card *card) 588static inline void gelic_card_enable_rxdmac(struct gelic_card *card)
497{ 589{
498 int status; 590 int status;
499 591
592#ifdef DEBUG
593 if (gelic_descr_get_status(card->rx_chain.head) !=
594 GELIC_DESCR_DMA_CARDOWNED) {
595 printk(KERN_ERR "%s: status=%x\n", __func__,
596 be32_to_cpu(card->rx_chain.head->dmac_cmd_status));
597 printk(KERN_ERR "%s: nextphy=%x\n", __func__,
598 be32_to_cpu(card->rx_chain.head->next_descr_addr));
599 printk(KERN_ERR "%s: head=%p\n", __func__,
600 card->rx_chain.head);
601 }
602#endif
500 status = lv1_net_start_rx_dma(bus_id(card), dev_id(card), 603 status = lv1_net_start_rx_dma(bus_id(card), dev_id(card),
501 card->rx_chain.tail->bus_addr, 0); 604 card->rx_chain.head->bus_addr, 0);
502 if (status) 605 if (status)
503 dev_info(ctodev(card), 606 dev_info(ctodev(card),
504 "lv1_net_start_rx_dma failed, status=%d\n", status); 607 "lv1_net_start_rx_dma failed, status=%d\n", status);
505} 608}
506 609
507/** 610/**
508 * gelic_net_disable_rxdmac - disables the receive DMA controller 611 * gelic_card_disable_rxdmac - disables the receive DMA controller
509 * @card: card structure 612 * @card: card structure
510 * 613 *
511 * gelic_net_disable_rxdmac terminates processing on the DMA controller by 614 * gelic_card_disable_rxdmac terminates processing on the DMA controller by
512 * turing off DMA and issueing a force end 615 * turing off DMA and issueing a force end
513 */ 616 */
514static inline void gelic_net_disable_rxdmac(struct gelic_net_card *card) 617static inline void gelic_card_disable_rxdmac(struct gelic_card *card)
515{ 618{
516 int status; 619 int status;
517 620
@@ -523,13 +626,13 @@ static inline void gelic_net_disable_rxdmac(struct gelic_net_card *card)
523} 626}
524 627
525/** 628/**
526 * gelic_net_disable_txdmac - disables the transmit DMA controller 629 * gelic_card_disable_txdmac - disables the transmit DMA controller
527 * @card: card structure 630 * @card: card structure
528 * 631 *
529 * gelic_net_disable_txdmac terminates processing on the DMA controller by 632 * gelic_card_disable_txdmac terminates processing on the DMA controller by
530 * turing off DMA and issueing a force end 633 * turing off DMA and issueing a force end
531 */ 634 */
532static inline void gelic_net_disable_txdmac(struct gelic_net_card *card) 635static inline void gelic_card_disable_txdmac(struct gelic_card *card)
533{ 636{
534 int status; 637 int status;
535 638
@@ -546,51 +649,37 @@ static inline void gelic_net_disable_txdmac(struct gelic_net_card *card)
546 * 649 *
547 * always returns 0 650 * always returns 0
548 */ 651 */
549static int gelic_net_stop(struct net_device *netdev) 652int gelic_net_stop(struct net_device *netdev)
550{ 653{
551 struct gelic_net_card *card = netdev_priv(netdev); 654 struct gelic_card *card;
552
553 napi_disable(&card->napi);
554 netif_stop_queue(netdev);
555 655
556 /* turn off DMA, force end */ 656 pr_debug("%s: start\n", __func__);
557 gelic_net_disable_rxdmac(card);
558 gelic_net_disable_txdmac(card);
559
560 gelic_net_set_irq_mask(card, 0);
561
562 /* disconnect event port */
563 free_irq(card->netdev->irq, card->netdev);
564 ps3_sb_event_receive_port_destroy(card->dev, card->netdev->irq);
565 card->netdev->irq = NO_IRQ;
566 657
658 netif_stop_queue(netdev);
567 netif_carrier_off(netdev); 659 netif_carrier_off(netdev);
568 660
569 /* release chains */ 661 card = netdev_card(netdev);
570 gelic_net_release_tx_chain(card, 1); 662 gelic_card_down(card);
571 gelic_net_release_rx_chain(card);
572
573 gelic_net_free_chain(card, card->tx_top);
574 gelic_net_free_chain(card, card->rx_top);
575 663
664 pr_debug("%s: done\n", __func__);
576 return 0; 665 return 0;
577} 666}
578 667
579/** 668/**
580 * gelic_net_get_next_tx_descr - returns the next available tx descriptor 669 * gelic_card_get_next_tx_descr - returns the next available tx descriptor
581 * @card: device structure to get descriptor from 670 * @card: device structure to get descriptor from
582 * 671 *
583 * returns the address of the next descriptor, or NULL if not available. 672 * returns the address of the next descriptor, or NULL if not available.
584 */ 673 */
585static struct gelic_net_descr * 674static struct gelic_descr *
586gelic_net_get_next_tx_descr(struct gelic_net_card *card) 675gelic_card_get_next_tx_descr(struct gelic_card *card)
587{ 676{
588 if (!card->tx_chain.head) 677 if (!card->tx_chain.head)
589 return NULL; 678 return NULL;
590 /* see if the next descriptor is free */ 679 /* see if the next descriptor is free */
591 if (card->tx_chain.tail != card->tx_chain.head->next && 680 if (card->tx_chain.tail != card->tx_chain.head->next &&
592 gelic_net_get_descr_status(card->tx_chain.head) == 681 gelic_descr_get_status(card->tx_chain.head) ==
593 GELIC_NET_DESCR_NOT_IN_USE) 682 GELIC_DESCR_DMA_NOT_IN_USE)
594 return card->tx_chain.head; 683 return card->tx_chain.head;
595 else 684 else
596 return NULL; 685 return NULL;
@@ -606,32 +695,33 @@ gelic_net_get_next_tx_descr(struct gelic_net_card *card)
606 * depending on hardware checksum settings. This function assumes a wmb() 695 * depending on hardware checksum settings. This function assumes a wmb()
607 * has executed before. 696 * has executed before.
608 */ 697 */
609static void gelic_net_set_txdescr_cmdstat(struct gelic_net_descr *descr, 698static void gelic_descr_set_tx_cmdstat(struct gelic_descr *descr,
610 struct sk_buff *skb) 699 struct sk_buff *skb)
611{ 700{
612 if (skb->ip_summed != CHECKSUM_PARTIAL) 701 if (skb->ip_summed != CHECKSUM_PARTIAL)
613 descr->dmac_cmd_status = GELIC_NET_DMAC_CMDSTAT_NOCS | 702 descr->dmac_cmd_status =
614 GELIC_NET_DMAC_CMDSTAT_END_FRAME; 703 cpu_to_be32(GELIC_DESCR_DMA_CMD_NO_CHKSUM |
704 GELIC_DESCR_TX_DMA_FRAME_TAIL);
615 else { 705 else {
616 /* is packet ip? 706 /* is packet ip?
617 * if yes: tcp? udp? */ 707 * if yes: tcp? udp? */
618 if (skb->protocol == htons(ETH_P_IP)) { 708 if (skb->protocol == htons(ETH_P_IP)) {
619 if (ip_hdr(skb)->protocol == IPPROTO_TCP) 709 if (ip_hdr(skb)->protocol == IPPROTO_TCP)
620 descr->dmac_cmd_status = 710 descr->dmac_cmd_status =
621 GELIC_NET_DMAC_CMDSTAT_TCPCS | 711 cpu_to_be32(GELIC_DESCR_DMA_CMD_TCP_CHKSUM |
622 GELIC_NET_DMAC_CMDSTAT_END_FRAME; 712 GELIC_DESCR_TX_DMA_FRAME_TAIL);
623 713
624 else if (ip_hdr(skb)->protocol == IPPROTO_UDP) 714 else if (ip_hdr(skb)->protocol == IPPROTO_UDP)
625 descr->dmac_cmd_status = 715 descr->dmac_cmd_status =
626 GELIC_NET_DMAC_CMDSTAT_UDPCS | 716 cpu_to_be32(GELIC_DESCR_DMA_CMD_UDP_CHKSUM |
627 GELIC_NET_DMAC_CMDSTAT_END_FRAME; 717 GELIC_DESCR_TX_DMA_FRAME_TAIL);
628 else /* 718 else /*
629 * the stack should checksum non-tcp and non-udp 719 * the stack should checksum non-tcp and non-udp
630 * packets on his own: NETIF_F_IP_CSUM 720 * packets on his own: NETIF_F_IP_CSUM
631 */ 721 */
632 descr->dmac_cmd_status = 722 descr->dmac_cmd_status =
633 GELIC_NET_DMAC_CMDSTAT_NOCS | 723 cpu_to_be32(GELIC_DESCR_DMA_CMD_NO_CHKSUM |
634 GELIC_NET_DMAC_CMDSTAT_END_FRAME; 724 GELIC_DESCR_TX_DMA_FRAME_TAIL);
635 } 725 }
636 } 726 }
637} 727}
@@ -662,7 +752,7 @@ static inline struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb,
662} 752}
663 753
664/** 754/**
665 * gelic_net_prepare_tx_descr_v - get dma address of skb_data 755 * gelic_descr_prepare_tx - setup a descriptor for sending packets
666 * @card: card structure 756 * @card: card structure
667 * @descr: descriptor structure 757 * @descr: descriptor structure
668 * @skb: packet to use 758 * @skb: packet to use
@@ -670,16 +760,19 @@ static inline struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb,
670 * returns 0 on success, <0 on failure. 760 * returns 0 on success, <0 on failure.
671 * 761 *
672 */ 762 */
673static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card, 763static int gelic_descr_prepare_tx(struct gelic_card *card,
674 struct gelic_net_descr *descr, 764 struct gelic_descr *descr,
675 struct sk_buff *skb) 765 struct sk_buff *skb)
676{ 766{
677 dma_addr_t buf; 767 dma_addr_t buf;
678 768
679 if (card->vlan_index != -1) { 769 if (card->vlan_required) {
680 struct sk_buff *skb_tmp; 770 struct sk_buff *skb_tmp;
771 enum gelic_port_type type;
772
773 type = netdev_port(skb->dev)->type;
681 skb_tmp = gelic_put_vlan_tag(skb, 774 skb_tmp = gelic_put_vlan_tag(skb,
682 card->vlan_id[card->vlan_index]); 775 card->vlan[type].tx);
683 if (!skb_tmp) 776 if (!skb_tmp)
684 return -ENOMEM; 777 return -ENOMEM;
685 skb = skb_tmp; 778 skb = skb_tmp;
@@ -694,12 +787,12 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card,
694 return -ENOMEM; 787 return -ENOMEM;
695 } 788 }
696 789
697 descr->buf_addr = buf; 790 descr->buf_addr = cpu_to_be32(buf);
698 descr->buf_size = skb->len; 791 descr->buf_size = cpu_to_be32(skb->len);
699 descr->skb = skb; 792 descr->skb = skb;
700 descr->data_status = 0; 793 descr->data_status = 0;
701 descr->next_descr_addr = 0; /* terminate hw descr */ 794 descr->next_descr_addr = 0; /* terminate hw descr */
702 gelic_net_set_txdescr_cmdstat(descr, skb); 795 gelic_descr_set_tx_cmdstat(descr, skb);
703 796
704 /* bump free descriptor pointer */ 797 /* bump free descriptor pointer */
705 card->tx_chain.head = descr->next; 798 card->tx_chain.head = descr->next;
@@ -707,20 +800,20 @@ static int gelic_net_prepare_tx_descr_v(struct gelic_net_card *card,
707} 800}
708 801
709/** 802/**
710 * gelic_net_kick_txdma - enables TX DMA processing 803 * gelic_card_kick_txdma - enables TX DMA processing
711 * @card: card structure 804 * @card: card structure
712 * @descr: descriptor address to enable TX processing at 805 * @descr: descriptor address to enable TX processing at
713 * 806 *
714 */ 807 */
715static int gelic_net_kick_txdma(struct gelic_net_card *card, 808static int gelic_card_kick_txdma(struct gelic_card *card,
716 struct gelic_net_descr *descr) 809 struct gelic_descr *descr)
717{ 810{
718 int status = 0; 811 int status = 0;
719 812
720 if (card->tx_dma_progress) 813 if (card->tx_dma_progress)
721 return 0; 814 return 0;
722 815
723 if (gelic_net_get_descr_status(descr) == GELIC_NET_DESCR_CARDOWNED) { 816 if (gelic_descr_get_status(descr) == GELIC_DESCR_DMA_CARDOWNED) {
724 card->tx_dma_progress = 1; 817 card->tx_dma_progress = 1;
725 status = lv1_net_start_tx_dma(bus_id(card), dev_id(card), 818 status = lv1_net_start_tx_dma(bus_id(card), dev_id(card),
726 descr->bus_addr, 0); 819 descr->bus_addr, 0);
@@ -738,56 +831,56 @@ static int gelic_net_kick_txdma(struct gelic_net_card *card,
738 * 831 *
739 * returns 0 on success, <0 on failure 832 * returns 0 on success, <0 on failure
740 */ 833 */
741static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev) 834int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
742{ 835{
743 struct gelic_net_card *card = netdev_priv(netdev); 836 struct gelic_card *card = netdev_card(netdev);
744 struct gelic_net_descr *descr; 837 struct gelic_descr *descr;
745 int result; 838 int result;
746 unsigned long flags; 839 unsigned long flags;
747 840
748 spin_lock_irqsave(&card->tx_dma_lock, flags); 841 spin_lock_irqsave(&card->tx_lock, flags);
749 842
750 gelic_net_release_tx_chain(card, 0); 843 gelic_card_release_tx_chain(card, 0);
751 844
752 descr = gelic_net_get_next_tx_descr(card); 845 descr = gelic_card_get_next_tx_descr(card);
753 if (!descr) { 846 if (!descr) {
754 /* 847 /*
755 * no more descriptors free 848 * no more descriptors free
756 */ 849 */
757 netif_stop_queue(netdev); 850 gelic_card_stop_queues(card);
758 spin_unlock_irqrestore(&card->tx_dma_lock, flags); 851 spin_unlock_irqrestore(&card->tx_lock, flags);
759 return NETDEV_TX_BUSY; 852 return NETDEV_TX_BUSY;
760 } 853 }
761 854
762 result = gelic_net_prepare_tx_descr_v(card, descr, skb); 855 result = gelic_descr_prepare_tx(card, descr, skb);
763 if (result) { 856 if (result) {
764 /* 857 /*
765 * DMA map failed. As chanses are that failure 858 * DMA map failed. As chanses are that failure
766 * would continue, just release skb and return 859 * would continue, just release skb and return
767 */ 860 */
768 card->netdev->stats.tx_dropped++; 861 netdev->stats.tx_dropped++;
769 dev_kfree_skb_any(skb); 862 dev_kfree_skb_any(skb);
770 spin_unlock_irqrestore(&card->tx_dma_lock, flags); 863 spin_unlock_irqrestore(&card->tx_lock, flags);
771 return NETDEV_TX_OK; 864 return NETDEV_TX_OK;
772 } 865 }
773 /* 866 /*
774 * link this prepared descriptor to previous one 867 * link this prepared descriptor to previous one
775 * to achieve high performance 868 * to achieve high performance
776 */ 869 */
777 descr->prev->next_descr_addr = descr->bus_addr; 870 descr->prev->next_descr_addr = cpu_to_be32(descr->bus_addr);
778 /* 871 /*
779 * as hardware descriptor is modified in the above lines, 872 * as hardware descriptor is modified in the above lines,
780 * ensure that the hardware sees it 873 * ensure that the hardware sees it
781 */ 874 */
782 wmb(); 875 wmb();
783 if (gelic_net_kick_txdma(card, descr)) { 876 if (gelic_card_kick_txdma(card, descr)) {
784 /* 877 /*
785 * kick failed. 878 * kick failed.
786 * release descriptors which were just prepared 879 * release descriptors which were just prepared
787 */ 880 */
788 card->netdev->stats.tx_dropped++; 881 netdev->stats.tx_dropped++;
789 gelic_net_release_tx_descr(card, descr); 882 gelic_descr_release_tx(card, descr);
790 gelic_net_release_tx_descr(card, descr->next); 883 gelic_descr_release_tx(card, descr->next);
791 card->tx_chain.tail = descr->next->next; 884 card->tx_chain.tail = descr->next->next;
792 dev_info(ctodev(card), "%s: kick failure\n", __func__); 885 dev_info(ctodev(card), "%s: kick failure\n", __func__);
793 } else { 886 } else {
@@ -795,7 +888,7 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
795 netdev->trans_start = jiffies; 888 netdev->trans_start = jiffies;
796 } 889 }
797 890
798 spin_unlock_irqrestore(&card->tx_dma_lock, flags); 891 spin_unlock_irqrestore(&card->tx_lock, flags);
799 return NETDEV_TX_OK; 892 return NETDEV_TX_OK;
800} 893}
801 894
@@ -803,30 +896,34 @@ static int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev)
803 * gelic_net_pass_skb_up - takes an skb from a descriptor and passes it on 896 * gelic_net_pass_skb_up - takes an skb from a descriptor and passes it on
804 * @descr: descriptor to process 897 * @descr: descriptor to process
805 * @card: card structure 898 * @card: card structure
899 * @netdev: net_device structure to be passed packet
806 * 900 *
807 * iommu-unmaps the skb, fills out skb structure and passes the data to the 901 * iommu-unmaps the skb, fills out skb structure and passes the data to the
808 * stack. The descriptor state is not changed. 902 * stack. The descriptor state is not changed.
809 */ 903 */
810static void gelic_net_pass_skb_up(struct gelic_net_descr *descr, 904static void gelic_net_pass_skb_up(struct gelic_descr *descr,
811 struct gelic_net_card *card) 905 struct gelic_card *card,
906 struct net_device *netdev)
907
812{ 908{
813 struct sk_buff *skb; 909 struct sk_buff *skb = descr->skb;
814 struct net_device *netdev;
815 u32 data_status, data_error; 910 u32 data_status, data_error;
816 911
817 data_status = descr->data_status; 912 data_status = be32_to_cpu(descr->data_status);
818 data_error = descr->data_error; 913 data_error = be32_to_cpu(descr->data_error);
819 netdev = card->netdev;
820 /* unmap skb buffer */ 914 /* unmap skb buffer */
821 skb = descr->skb; 915 dma_unmap_single(ctodev(card), be32_to_cpu(descr->buf_addr),
822 dma_unmap_single(ctodev(card), descr->buf_addr, GELIC_NET_MAX_MTU, 916 GELIC_NET_MAX_MTU,
823 DMA_FROM_DEVICE); 917 DMA_FROM_DEVICE);
824 918
825 skb_put(skb, descr->valid_size? descr->valid_size : descr->result_size); 919 skb_put(skb, be32_to_cpu(descr->valid_size)?
920 be32_to_cpu(descr->valid_size) :
921 be32_to_cpu(descr->result_size));
826 if (!descr->valid_size) 922 if (!descr->valid_size)
827 dev_info(ctodev(card), "buffer full %x %x %x\n", 923 dev_info(ctodev(card), "buffer full %x %x %x\n",
828 descr->result_size, descr->buf_size, 924 be32_to_cpu(descr->result_size),
829 descr->dmac_cmd_status); 925 be32_to_cpu(descr->buf_size),
926 be32_to_cpu(descr->dmac_cmd_status));
830 927
831 descr->skb = NULL; 928 descr->skb = NULL;
832 /* 929 /*
@@ -838,8 +935,8 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr,
838 935
839 /* checksum offload */ 936 /* checksum offload */
840 if (card->rx_csum) { 937 if (card->rx_csum) {
841 if ((data_status & GELIC_NET_DATA_STATUS_CHK_MASK) && 938 if ((data_status & GELIC_DESCR_DATA_STATUS_CHK_MASK) &&
842 (!(data_error & GELIC_NET_DATA_ERROR_CHK_MASK))) 939 (!(data_error & GELIC_DESCR_DATA_ERROR_CHK_MASK)))
843 skb->ip_summed = CHECKSUM_UNNECESSARY; 940 skb->ip_summed = CHECKSUM_UNNECESSARY;
844 else 941 else
845 skb->ip_summed = CHECKSUM_NONE; 942 skb->ip_summed = CHECKSUM_NONE;
@@ -847,15 +944,15 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr,
847 skb->ip_summed = CHECKSUM_NONE; 944 skb->ip_summed = CHECKSUM_NONE;
848 945
849 /* update netdevice statistics */ 946 /* update netdevice statistics */
850 card->netdev->stats.rx_packets++; 947 netdev->stats.rx_packets++;
851 card->netdev->stats.rx_bytes += skb->len; 948 netdev->stats.rx_bytes += skb->len;
852 949
853 /* pass skb up to stack */ 950 /* pass skb up to stack */
854 netif_receive_skb(skb); 951 netif_receive_skb(skb);
855} 952}
856 953
857/** 954/**
858 * gelic_net_decode_one_descr - processes an rx descriptor 955 * gelic_card_decode_one_descr - processes an rx descriptor
859 * @card: card structure 956 * @card: card structure
860 * 957 *
861 * returns 1 if a packet has been sent to the stack, otherwise 0 958 * returns 1 if a packet has been sent to the stack, otherwise 0
@@ -863,36 +960,56 @@ static void gelic_net_pass_skb_up(struct gelic_net_descr *descr,
863 * processes an rx descriptor by iommu-unmapping the data buffer and passing 960 * processes an rx descriptor by iommu-unmapping the data buffer and passing
864 * the packet up to the stack 961 * the packet up to the stack
865 */ 962 */
866static int gelic_net_decode_one_descr(struct gelic_net_card *card) 963static int gelic_card_decode_one_descr(struct gelic_card *card)
867{ 964{
868 enum gelic_net_descr_status status; 965 enum gelic_descr_dma_status status;
869 struct gelic_net_descr_chain *chain = &card->rx_chain; 966 struct gelic_descr_chain *chain = &card->rx_chain;
870 struct gelic_net_descr *descr = chain->tail; 967 struct gelic_descr *descr = chain->head;
968 struct net_device *netdev = NULL;
871 int dmac_chain_ended; 969 int dmac_chain_ended;
872 970
873 status = gelic_net_get_descr_status(descr); 971 status = gelic_descr_get_status(descr);
874 /* is this descriptor terminated with next_descr == NULL? */ 972 /* is this descriptor terminated with next_descr == NULL? */
875 dmac_chain_ended = 973 dmac_chain_ended =
876 descr->dmac_cmd_status & GELIC_NET_DMAC_CMDSTAT_RXDCEIS; 974 be32_to_cpu(descr->dmac_cmd_status) &
975 GELIC_DESCR_RX_DMA_CHAIN_END;
877 976
878 if (status == GELIC_NET_DESCR_CARDOWNED) 977 if (status == GELIC_DESCR_DMA_CARDOWNED)
879 return 0; 978 return 0;
880 979
881 if (status == GELIC_NET_DESCR_NOT_IN_USE) { 980 if (status == GELIC_DESCR_DMA_NOT_IN_USE) {
882 dev_dbg(ctodev(card), "dormant descr? %p\n", descr); 981 dev_dbg(ctodev(card), "dormant descr? %p\n", descr);
883 return 0; 982 return 0;
884 } 983 }
885 984
886 if ((status == GELIC_NET_DESCR_RESPONSE_ERROR) || 985 /* netdevice select */
887 (status == GELIC_NET_DESCR_PROTECTION_ERROR) || 986 if (card->vlan_required) {
888 (status == GELIC_NET_DESCR_FORCE_END)) { 987 unsigned int i;
988 u16 vid;
989 vid = *(u16 *)(descr->skb->data) & VLAN_VID_MASK;
990 for (i = 0; i < GELIC_PORT_MAX; i++) {
991 if (card->vlan[i].rx == vid) {
992 netdev = card->netdev[i];
993 break;
994 }
995 };
996 if (GELIC_PORT_MAX <= i) {
997 pr_info("%s: unknown packet vid=%x\n", __func__, vid);
998 goto refill;
999 }
1000 } else
1001 netdev = card->netdev[GELIC_PORT_ETHERNET];
1002
1003 if ((status == GELIC_DESCR_DMA_RESPONSE_ERROR) ||
1004 (status == GELIC_DESCR_DMA_PROTECTION_ERROR) ||
1005 (status == GELIC_DESCR_DMA_FORCE_END)) {
889 dev_info(ctodev(card), "dropping RX descriptor with state %x\n", 1006 dev_info(ctodev(card), "dropping RX descriptor with state %x\n",
890 status); 1007 status);
891 card->netdev->stats.rx_dropped++; 1008 netdev->stats.rx_dropped++;
892 goto refill; 1009 goto refill;
893 } 1010 }
894 1011
895 if (status == GELIC_NET_DESCR_BUFFER_FULL) { 1012 if (status == GELIC_DESCR_DMA_BUFFER_FULL) {
896 /* 1013 /*
897 * Buffer full would occur if and only if 1014 * Buffer full would occur if and only if
898 * the frame length was longer than the size of this 1015 * the frame length was longer than the size of this
@@ -909,14 +1026,14 @@ static int gelic_net_decode_one_descr(struct gelic_net_card *card)
909 * descriptoers any other than FRAME_END here should 1026 * descriptoers any other than FRAME_END here should
910 * be treated as error. 1027 * be treated as error.
911 */ 1028 */
912 if (status != GELIC_NET_DESCR_FRAME_END) { 1029 if (status != GELIC_DESCR_DMA_FRAME_END) {
913 dev_dbg(ctodev(card), "RX descriptor with state %x\n", 1030 dev_dbg(ctodev(card), "RX descriptor with state %x\n",
914 status); 1031 status);
915 goto refill; 1032 goto refill;
916 } 1033 }
917 1034
918 /* ok, we've got a packet in descr */ 1035 /* ok, we've got a packet in descr */
919 gelic_net_pass_skb_up(descr, card); 1036 gelic_net_pass_skb_up(descr, card, netdev);
920refill: 1037refill:
921 /* 1038 /*
922 * So that always DMAC can see the end 1039 * So that always DMAC can see the end
@@ -926,21 +1043,21 @@ refill:
926 descr->next_descr_addr = 0; 1043 descr->next_descr_addr = 0;
927 1044
928 /* change the descriptor state: */ 1045 /* change the descriptor state: */
929 gelic_net_set_descr_status(descr, GELIC_NET_DESCR_NOT_IN_USE); 1046 gelic_descr_set_status(descr, GELIC_DESCR_DMA_NOT_IN_USE);
930 1047
931 /* 1048 /*
932 * this call can fail, but for now, just leave this 1049 * this call can fail, but for now, just leave this
933 * decriptor without skb 1050 * decriptor without skb
934 */ 1051 */
935 gelic_net_prepare_rx_descr(card, descr); 1052 gelic_descr_prepare_rx(card, descr);
936 1053
937 chain->head = descr; 1054 chain->tail = descr;
938 chain->tail = descr->next; 1055 chain->head = descr->next;
939 1056
940 /* 1057 /*
941 * Set this descriptor the end of the chain. 1058 * Set this descriptor the end of the chain.
942 */ 1059 */
943 descr->prev->next_descr_addr = descr->bus_addr; 1060 descr->prev->next_descr_addr = cpu_to_be32(descr->bus_addr);
944 1061
945 /* 1062 /*
946 * If dmac chain was met, DMAC stopped. 1063 * If dmac chain was met, DMAC stopped.
@@ -956,29 +1073,27 @@ refill:
956 1073
957/** 1074/**
958 * gelic_net_poll - NAPI poll function called by the stack to return packets 1075 * gelic_net_poll - NAPI poll function called by the stack to return packets
959 * @netdev: interface device structure 1076 * @napi: napi structure
960 * @budget: number of packets we can pass to the stack at most 1077 * @budget: number of packets we can pass to the stack at most
961 * 1078 *
962 * returns 0 if no more packets available to the driver/stack. Returns 1, 1079 * returns the number of the processed packets
963 * if the quota is exceeded, but the driver has still packets.
964 * 1080 *
965 */ 1081 */
966static int gelic_net_poll(struct napi_struct *napi, int budget) 1082static int gelic_net_poll(struct napi_struct *napi, int budget)
967{ 1083{
968 struct gelic_net_card *card = container_of(napi, struct gelic_net_card, napi); 1084 struct gelic_card *card = container_of(napi, struct gelic_card, napi);
969 struct net_device *netdev = card->netdev;
970 int packets_done = 0; 1085 int packets_done = 0;
971 1086
972 while (packets_done < budget) { 1087 while (packets_done < budget) {
973 if (!gelic_net_decode_one_descr(card)) 1088 if (!gelic_card_decode_one_descr(card))
974 break; 1089 break;
975 1090
976 packets_done++; 1091 packets_done++;
977 } 1092 }
978 1093
979 if (packets_done < budget) { 1094 if (packets_done < budget) {
980 netif_rx_complete(netdev, napi); 1095 napi_complete(napi);
981 gelic_net_rx_irq_on(card); 1096 gelic_card_rx_irq_on(card);
982 } 1097 }
983 return packets_done; 1098 return packets_done;
984} 1099}
@@ -989,7 +1104,7 @@ static int gelic_net_poll(struct napi_struct *napi, int budget)
989 * 1104 *
990 * returns 0 on success, <0 on failure 1105 * returns 0 on success, <0 on failure
991 */ 1106 */
992static int gelic_net_change_mtu(struct net_device *netdev, int new_mtu) 1107int gelic_net_change_mtu(struct net_device *netdev, int new_mtu)
993{ 1108{
994 /* no need to re-alloc skbs or so -- the max mtu is about 2.3k 1109 /* no need to re-alloc skbs or so -- the max mtu is about 2.3k
995 * and mtu is outbound only anyway */ 1110 * and mtu is outbound only anyway */
@@ -1002,13 +1117,12 @@ static int gelic_net_change_mtu(struct net_device *netdev, int new_mtu)
1002} 1117}
1003 1118
1004/** 1119/**
1005 * gelic_net_interrupt - event handler for gelic_net 1120 * gelic_card_interrupt - event handler for gelic_net
1006 */ 1121 */
1007static irqreturn_t gelic_net_interrupt(int irq, void *ptr) 1122static irqreturn_t gelic_card_interrupt(int irq, void *ptr)
1008{ 1123{
1009 unsigned long flags; 1124 unsigned long flags;
1010 struct net_device *netdev = ptr; 1125 struct gelic_card *card = ptr;
1011 struct gelic_net_card *card = netdev_priv(netdev);
1012 u64 status; 1126 u64 status;
1013 1127
1014 status = card->irq_status; 1128 status = card->irq_status;
@@ -1016,24 +1130,37 @@ static irqreturn_t gelic_net_interrupt(int irq, void *ptr)
1016 if (!status) 1130 if (!status)
1017 return IRQ_NONE; 1131 return IRQ_NONE;
1018 1132
1133 status &= card->irq_mask;
1134
1019 if (card->rx_dma_restart_required) { 1135 if (card->rx_dma_restart_required) {
1020 card->rx_dma_restart_required = 0; 1136 card->rx_dma_restart_required = 0;
1021 gelic_net_enable_rxdmac(card); 1137 gelic_card_enable_rxdmac(card);
1022 } 1138 }
1023 1139
1024 if (status & GELIC_NET_RXINT) { 1140 if (status & GELIC_CARD_RXINT) {
1025 gelic_net_rx_irq_off(card); 1141 gelic_card_rx_irq_off(card);
1026 netif_rx_schedule(netdev, &card->napi); 1142 napi_schedule(&card->napi);
1027 } 1143 }
1028 1144
1029 if (status & GELIC_NET_TXINT) { 1145 if (status & GELIC_CARD_TXINT) {
1030 spin_lock_irqsave(&card->tx_dma_lock, flags); 1146 spin_lock_irqsave(&card->tx_lock, flags);
1031 card->tx_dma_progress = 0; 1147 card->tx_dma_progress = 0;
1032 gelic_net_release_tx_chain(card, 0); 1148 gelic_card_release_tx_chain(card, 0);
1033 /* kick outstanding tx descriptor if any */ 1149 /* kick outstanding tx descriptor if any */
1034 gelic_net_kick_txdma(card, card->tx_chain.tail); 1150 gelic_card_kick_txdma(card, card->tx_chain.tail);
1035 spin_unlock_irqrestore(&card->tx_dma_lock, flags); 1151 spin_unlock_irqrestore(&card->tx_lock, flags);
1036 } 1152 }
1153
1154 /* ether port status changed */
1155 if (status & GELIC_CARD_PORT_STATUS_CHANGED)
1156 gelic_card_get_ether_port_status(card, 1);
1157
1158#ifdef CONFIG_GELIC_WIRELESS
1159 if (status & (GELIC_CARD_WLAN_EVENT_RECEIVED |
1160 GELIC_CARD_WLAN_COMMAND_COMPLETED))
1161 gelic_wl_interrupt(card->netdev[GELIC_PORT_WIRELESS], status);
1162#endif
1163
1037 return IRQ_HANDLED; 1164 return IRQ_HANDLED;
1038} 1165}
1039 1166
@@ -1044,55 +1171,17 @@ static irqreturn_t gelic_net_interrupt(int irq, void *ptr)
1044 * 1171 *
1045 * see Documentation/networking/netconsole.txt 1172 * see Documentation/networking/netconsole.txt
1046 */ 1173 */
1047static void gelic_net_poll_controller(struct net_device *netdev) 1174void gelic_net_poll_controller(struct net_device *netdev)
1048{ 1175{
1049 struct gelic_net_card *card = netdev_priv(netdev); 1176 struct gelic_card *card = netdev_card(netdev);
1050 1177
1051 gelic_net_set_irq_mask(card, 0); 1178 gelic_card_set_irq_mask(card, 0);
1052 gelic_net_interrupt(netdev->irq, netdev); 1179 gelic_card_interrupt(netdev->irq, netdev);
1053 gelic_net_set_irq_mask(card, card->ghiintmask); 1180 gelic_card_set_irq_mask(card, card->irq_mask);
1054} 1181}
1055#endif /* CONFIG_NET_POLL_CONTROLLER */ 1182#endif /* CONFIG_NET_POLL_CONTROLLER */
1056 1183
1057/** 1184/**
1058 * gelic_net_open_device - open device and map dma region
1059 * @card: card structure
1060 */
1061static int gelic_net_open_device(struct gelic_net_card *card)
1062{
1063 int result;
1064
1065 result = ps3_sb_event_receive_port_setup(card->dev, PS3_BINDING_CPU_ANY,
1066 &card->netdev->irq);
1067
1068 if (result) {
1069 dev_info(ctodev(card),
1070 "%s:%d: gelic_net_open_device failed (%d)\n",
1071 __func__, __LINE__, result);
1072 result = -EPERM;
1073 goto fail_alloc_irq;
1074 }
1075
1076 result = request_irq(card->netdev->irq, gelic_net_interrupt,
1077 IRQF_DISABLED, card->netdev->name, card->netdev);
1078
1079 if (result) {
1080 dev_info(ctodev(card), "%s:%d: request_irq failed (%d)\n",
1081 __func__, __LINE__, result);
1082 goto fail_request_irq;
1083 }
1084
1085 return 0;
1086
1087fail_request_irq:
1088 ps3_sb_event_receive_port_destroy(card->dev, card->netdev->irq);
1089 card->netdev->irq = NO_IRQ;
1090fail_alloc_irq:
1091 return result;
1092}
1093
1094
1095/**
1096 * gelic_net_open - called upon ifonfig up 1185 * gelic_net_open - called upon ifonfig up
1097 * @netdev: interface device structure 1186 * @netdev: interface device structure
1098 * 1187 *
@@ -1101,169 +1190,88 @@ fail_alloc_irq:
1101 * gelic_net_open allocates all the descriptors and memory needed for 1190 * gelic_net_open allocates all the descriptors and memory needed for
1102 * operation, sets up multicast list and enables interrupts 1191 * operation, sets up multicast list and enables interrupts
1103 */ 1192 */
1104static int gelic_net_open(struct net_device *netdev) 1193int gelic_net_open(struct net_device *netdev)
1105{ 1194{
1106 struct gelic_net_card *card = netdev_priv(netdev); 1195 struct gelic_card *card = netdev_card(netdev);
1107
1108 dev_dbg(ctodev(card), " -> %s:%d\n", __func__, __LINE__);
1109
1110 gelic_net_open_device(card);
1111
1112 if (gelic_net_init_chain(card, &card->tx_chain,
1113 card->descr, GELIC_NET_TX_DESCRIPTORS))
1114 goto alloc_tx_failed;
1115 if (gelic_net_init_chain(card, &card->rx_chain,
1116 card->descr + GELIC_NET_TX_DESCRIPTORS,
1117 GELIC_NET_RX_DESCRIPTORS))
1118 goto alloc_rx_failed;
1119
1120 /* head of chain */
1121 card->tx_top = card->tx_chain.head;
1122 card->rx_top = card->rx_chain.head;
1123 dev_dbg(ctodev(card), "descr rx %p, tx %p, size %#lx, num %#x\n",
1124 card->rx_top, card->tx_top, sizeof(struct gelic_net_descr),
1125 GELIC_NET_RX_DESCRIPTORS);
1126 /* allocate rx skbs */
1127 if (gelic_net_alloc_rx_skbs(card))
1128 goto alloc_skbs_failed;
1129 1196
1130 napi_enable(&card->napi); 1197 dev_dbg(ctodev(card), " -> %s %p\n", __func__, netdev);
1131
1132 card->tx_dma_progress = 0;
1133 card->ghiintmask = GELIC_NET_RXINT | GELIC_NET_TXINT;
1134 1198
1135 gelic_net_set_irq_mask(card, card->ghiintmask); 1199 gelic_card_up(card);
1136 gelic_net_enable_rxdmac(card);
1137 1200
1138 netif_start_queue(netdev); 1201 netif_start_queue(netdev);
1139 netif_carrier_on(netdev); 1202 gelic_card_get_ether_port_status(card, 1);
1140 1203
1204 dev_dbg(ctodev(card), " <- %s\n", __func__);
1141 return 0; 1205 return 0;
1142
1143alloc_skbs_failed:
1144 gelic_net_free_chain(card, card->rx_top);
1145alloc_rx_failed:
1146 gelic_net_free_chain(card, card->tx_top);
1147alloc_tx_failed:
1148 return -ENOMEM;
1149} 1206}
1150 1207
1151static void gelic_net_get_drvinfo (struct net_device *netdev, 1208void gelic_net_get_drvinfo(struct net_device *netdev,
1152 struct ethtool_drvinfo *info) 1209 struct ethtool_drvinfo *info)
1153{ 1210{
1154 strncpy(info->driver, DRV_NAME, sizeof(info->driver) - 1); 1211 strncpy(info->driver, DRV_NAME, sizeof(info->driver) - 1);
1155 strncpy(info->version, DRV_VERSION, sizeof(info->version) - 1); 1212 strncpy(info->version, DRV_VERSION, sizeof(info->version) - 1);
1156} 1213}
1157 1214
1158static int gelic_net_get_settings(struct net_device *netdev, 1215static int gelic_ether_get_settings(struct net_device *netdev,
1159 struct ethtool_cmd *cmd) 1216 struct ethtool_cmd *cmd)
1160{ 1217{
1161 struct gelic_net_card *card = netdev_priv(netdev); 1218 struct gelic_card *card = netdev_card(netdev);
1162 int status;
1163 u64 v1, v2;
1164 int speed, duplex;
1165 1219
1166 speed = duplex = -1; 1220 gelic_card_get_ether_port_status(card, 0);
1167 status = lv1_net_control(bus_id(card), dev_id(card),
1168 GELIC_NET_GET_ETH_PORT_STATUS, GELIC_NET_PORT, 0, 0,
1169 &v1, &v2);
1170 if (status) {
1171 /* link down */
1172 } else {
1173 if (v1 & GELIC_NET_FULL_DUPLEX) {
1174 duplex = DUPLEX_FULL;
1175 } else {
1176 duplex = DUPLEX_HALF;
1177 }
1178 1221
1179 if (v1 & GELIC_NET_SPEED_10 ) { 1222 if (card->ether_port_status & GELIC_LV1_ETHER_FULL_DUPLEX)
1180 speed = SPEED_10; 1223 cmd->duplex = DUPLEX_FULL;
1181 } else if (v1 & GELIC_NET_SPEED_100) { 1224 else
1182 speed = SPEED_100; 1225 cmd->duplex = DUPLEX_HALF;
1183 } else if (v1 & GELIC_NET_SPEED_1000) { 1226
1184 speed = SPEED_1000; 1227 switch (card->ether_port_status & GELIC_LV1_ETHER_SPEED_MASK) {
1185 } 1228 case GELIC_LV1_ETHER_SPEED_10:
1229 cmd->speed = SPEED_10;
1230 break;
1231 case GELIC_LV1_ETHER_SPEED_100:
1232 cmd->speed = SPEED_100;
1233 break;
1234 case GELIC_LV1_ETHER_SPEED_1000:
1235 cmd->speed = SPEED_1000;
1236 break;
1237 default:
1238 pr_info("%s: speed unknown\n", __func__);
1239 cmd->speed = SPEED_10;
1240 break;
1186 } 1241 }
1242
1187 cmd->supported = SUPPORTED_TP | SUPPORTED_Autoneg | 1243 cmd->supported = SUPPORTED_TP | SUPPORTED_Autoneg |
1188 SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full | 1244 SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
1189 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full | 1245 SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
1190 SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full; 1246 SUPPORTED_1000baseT_Half | SUPPORTED_1000baseT_Full;
1191 cmd->advertising = cmd->supported; 1247 cmd->advertising = cmd->supported;
1192 cmd->speed = speed;
1193 cmd->duplex = duplex;
1194 cmd->autoneg = AUTONEG_ENABLE; /* always enabled */ 1248 cmd->autoneg = AUTONEG_ENABLE; /* always enabled */
1195 cmd->port = PORT_TP; 1249 cmd->port = PORT_TP;
1196 1250
1197 return 0; 1251 return 0;
1198} 1252}
1199 1253
1200static u32 gelic_net_get_link(struct net_device *netdev) 1254u32 gelic_net_get_rx_csum(struct net_device *netdev)
1201{ 1255{
1202 struct gelic_net_card *card = netdev_priv(netdev); 1256 struct gelic_card *card = netdev_card(netdev);
1203 int status;
1204 u64 v1, v2;
1205 int link;
1206
1207 status = lv1_net_control(bus_id(card), dev_id(card),
1208 GELIC_NET_GET_ETH_PORT_STATUS, GELIC_NET_PORT, 0, 0,
1209 &v1, &v2);
1210 if (status)
1211 return 0; /* link down */
1212
1213 if (v1 & GELIC_NET_LINK_UP)
1214 link = 1;
1215 else
1216 link = 0;
1217
1218 return link;
1219}
1220
1221static int gelic_net_nway_reset(struct net_device *netdev)
1222{
1223 if (netif_running(netdev)) {
1224 gelic_net_stop(netdev);
1225 gelic_net_open(netdev);
1226 }
1227 return 0;
1228}
1229
1230static u32 gelic_net_get_tx_csum(struct net_device *netdev)
1231{
1232 return (netdev->features & NETIF_F_IP_CSUM) != 0;
1233}
1234
1235static int gelic_net_set_tx_csum(struct net_device *netdev, u32 data)
1236{
1237 if (data)
1238 netdev->features |= NETIF_F_IP_CSUM;
1239 else
1240 netdev->features &= ~NETIF_F_IP_CSUM;
1241
1242 return 0;
1243}
1244
1245static u32 gelic_net_get_rx_csum(struct net_device *netdev)
1246{
1247 struct gelic_net_card *card = netdev_priv(netdev);
1248 1257
1249 return card->rx_csum; 1258 return card->rx_csum;
1250} 1259}
1251 1260
1252static int gelic_net_set_rx_csum(struct net_device *netdev, u32 data) 1261int gelic_net_set_rx_csum(struct net_device *netdev, u32 data)
1253{ 1262{
1254 struct gelic_net_card *card = netdev_priv(netdev); 1263 struct gelic_card *card = netdev_card(netdev);
1255 1264
1256 card->rx_csum = data; 1265 card->rx_csum = data;
1257 return 0; 1266 return 0;
1258} 1267}
1259 1268
1260static struct ethtool_ops gelic_net_ethtool_ops = { 1269static struct ethtool_ops gelic_ether_ethtool_ops = {
1261 .get_drvinfo = gelic_net_get_drvinfo, 1270 .get_drvinfo = gelic_net_get_drvinfo,
1262 .get_settings = gelic_net_get_settings, 1271 .get_settings = gelic_ether_get_settings,
1263 .get_link = gelic_net_get_link, 1272 .get_link = ethtool_op_get_link,
1264 .nway_reset = gelic_net_nway_reset, 1273 .get_tx_csum = ethtool_op_get_tx_csum,
1265 .get_tx_csum = gelic_net_get_tx_csum, 1274 .set_tx_csum = ethtool_op_set_tx_csum,
1266 .set_tx_csum = gelic_net_set_tx_csum,
1267 .get_rx_csum = gelic_net_get_rx_csum, 1275 .get_rx_csum = gelic_net_get_rx_csum,
1268 .set_rx_csum = gelic_net_set_rx_csum, 1276 .set_rx_csum = gelic_net_set_rx_csum,
1269}; 1277};
@@ -1277,9 +1285,9 @@ static struct ethtool_ops gelic_net_ethtool_ops = {
1277 */ 1285 */
1278static void gelic_net_tx_timeout_task(struct work_struct *work) 1286static void gelic_net_tx_timeout_task(struct work_struct *work)
1279{ 1287{
1280 struct gelic_net_card *card = 1288 struct gelic_card *card =
1281 container_of(work, struct gelic_net_card, tx_timeout_task); 1289 container_of(work, struct gelic_card, tx_timeout_task);
1282 struct net_device *netdev = card->netdev; 1290 struct net_device *netdev = card->netdev[GELIC_PORT_ETHERNET];
1283 1291
1284 dev_info(ctodev(card), "%s:Timed out. Restarting... \n", __func__); 1292 dev_info(ctodev(card), "%s:Timed out. Restarting... \n", __func__);
1285 1293
@@ -1302,11 +1310,11 @@ out:
1302 * 1310 *
1303 * called, if tx hangs. Schedules a task that resets the interface 1311 * called, if tx hangs. Schedules a task that resets the interface
1304 */ 1312 */
1305static void gelic_net_tx_timeout(struct net_device *netdev) 1313void gelic_net_tx_timeout(struct net_device *netdev)
1306{ 1314{
1307 struct gelic_net_card *card; 1315 struct gelic_card *card;
1308 1316
1309 card = netdev_priv(netdev); 1317 card = netdev_card(netdev);
1310 atomic_inc(&card->tx_timeout_task_counter); 1318 atomic_inc(&card->tx_timeout_task_counter);
1311 if (netdev->flags & IFF_UP) 1319 if (netdev->flags & IFF_UP)
1312 schedule_work(&card->tx_timeout_task); 1320 schedule_work(&card->tx_timeout_task);
@@ -1315,12 +1323,13 @@ static void gelic_net_tx_timeout(struct net_device *netdev)
1315} 1323}
1316 1324
1317/** 1325/**
1318 * gelic_net_setup_netdev_ops - initialization of net_device operations 1326 * gelic_ether_setup_netdev_ops - initialization of net_device operations
1319 * @netdev: net_device structure 1327 * @netdev: net_device structure
1320 * 1328 *
1321 * fills out function pointers in the net_device structure 1329 * fills out function pointers in the net_device structure
1322 */ 1330 */
1323static void gelic_net_setup_netdev_ops(struct net_device *netdev) 1331static void gelic_ether_setup_netdev_ops(struct net_device *netdev,
1332 struct napi_struct *napi)
1324{ 1333{
1325 netdev->open = &gelic_net_open; 1334 netdev->open = &gelic_net_open;
1326 netdev->stop = &gelic_net_stop; 1335 netdev->stop = &gelic_net_stop;
@@ -1330,163 +1339,239 @@ static void gelic_net_setup_netdev_ops(struct net_device *netdev)
1330 /* tx watchdog */ 1339 /* tx watchdog */
1331 netdev->tx_timeout = &gelic_net_tx_timeout; 1340 netdev->tx_timeout = &gelic_net_tx_timeout;
1332 netdev->watchdog_timeo = GELIC_NET_WATCHDOG_TIMEOUT; 1341 netdev->watchdog_timeo = GELIC_NET_WATCHDOG_TIMEOUT;
1333 netdev->ethtool_ops = &gelic_net_ethtool_ops; 1342 /* NAPI */
1343 netif_napi_add(netdev, napi,
1344 gelic_net_poll, GELIC_NET_NAPI_WEIGHT);
1345 netdev->ethtool_ops = &gelic_ether_ethtool_ops;
1346#ifdef CONFIG_NET_POLL_CONTROLLER
1347 netdev->poll_controller = gelic_net_poll_controller;
1348#endif
1334} 1349}
1335 1350
1336/** 1351/**
1337 * gelic_net_setup_netdev - initialization of net_device 1352 * gelic_ether_setup_netdev - initialization of net_device
1353 * @netdev: net_device structure
1338 * @card: card structure 1354 * @card: card structure
1339 * 1355 *
1340 * Returns 0 on success or <0 on failure 1356 * Returns 0 on success or <0 on failure
1341 * 1357 *
1342 * gelic_net_setup_netdev initializes the net_device structure 1358 * gelic_ether_setup_netdev initializes the net_device structure
1359 * and register it.
1343 **/ 1360 **/
1344static int gelic_net_setup_netdev(struct gelic_net_card *card) 1361int gelic_net_setup_netdev(struct net_device *netdev, struct gelic_card *card)
1345{ 1362{
1346 struct net_device *netdev = card->netdev;
1347 struct sockaddr addr;
1348 unsigned int i;
1349 int status; 1363 int status;
1350 u64 v1, v2; 1364 u64 v1, v2;
1351 DECLARE_MAC_BUF(mac); 1365 DECLARE_MAC_BUF(mac);
1352 1366
1353 SET_NETDEV_DEV(netdev, &card->dev->core);
1354 spin_lock_init(&card->tx_dma_lock);
1355
1356 card->rx_csum = GELIC_NET_RX_CSUM_DEFAULT;
1357
1358 gelic_net_setup_netdev_ops(netdev);
1359
1360 netif_napi_add(netdev, &card->napi,
1361 gelic_net_poll, GELIC_NET_NAPI_WEIGHT);
1362
1363 netdev->features = NETIF_F_IP_CSUM; 1367 netdev->features = NETIF_F_IP_CSUM;
1364 1368
1365 status = lv1_net_control(bus_id(card), dev_id(card), 1369 status = lv1_net_control(bus_id(card), dev_id(card),
1366 GELIC_NET_GET_MAC_ADDRESS, 1370 GELIC_LV1_GET_MAC_ADDRESS,
1367 0, 0, 0, &v1, &v2); 1371 0, 0, 0, &v1, &v2);
1372 v1 <<= 16;
1368 if (status || !is_valid_ether_addr((u8 *)&v1)) { 1373 if (status || !is_valid_ether_addr((u8 *)&v1)) {
1369 dev_info(ctodev(card), 1374 dev_info(ctodev(card),
1370 "%s:lv1_net_control GET_MAC_ADDR failed %d\n", 1375 "%s:lv1_net_control GET_MAC_ADDR failed %d\n",
1371 __func__, status); 1376 __func__, status);
1372 return -EINVAL; 1377 return -EINVAL;
1373 } 1378 }
1374 v1 <<= 16; 1379 memcpy(netdev->dev_addr, &v1, ETH_ALEN);
1375 memcpy(addr.sa_data, &v1, ETH_ALEN);
1376 memcpy(netdev->dev_addr, addr.sa_data, ETH_ALEN);
1377 dev_info(ctodev(card), "MAC addr %s\n",
1378 print_mac(mac, netdev->dev_addr));
1379 1380
1380 card->vlan_index = -1; /* no vlan */ 1381 if (card->vlan_required) {
1381 for (i = 0; i < GELIC_NET_VLAN_MAX; i++) {
1382 status = lv1_net_control(bus_id(card), dev_id(card),
1383 GELIC_NET_GET_VLAN_ID,
1384 i + 1, /* index; one based */
1385 0, 0, &v1, &v2);
1386 if (status == GELIC_NET_VLAN_NO_ENTRY) {
1387 dev_dbg(ctodev(card),
1388 "GELIC_VLAN_ID no entry:%d, VLAN disabled\n",
1389 status);
1390 card->vlan_id[i] = 0;
1391 } else if (status) {
1392 dev_dbg(ctodev(card),
1393 "%s:GELIC_NET_VLAN_ID faild, status=%d\n",
1394 __func__, status);
1395 card->vlan_id[i] = 0;
1396 } else {
1397 card->vlan_id[i] = (u32)v1;
1398 dev_dbg(ctodev(card), "vlan_id:%d, %lx\n", i, v1);
1399 }
1400 }
1401
1402 if (card->vlan_id[GELIC_NET_VLAN_WIRED - 1]) {
1403 card->vlan_index = GELIC_NET_VLAN_WIRED - 1;
1404 netdev->hard_header_len += VLAN_HLEN; 1382 netdev->hard_header_len += VLAN_HLEN;
1383 /*
1384 * As vlan is internally used,
1385 * we can not receive vlan packets
1386 */
1387 netdev->features |= NETIF_F_VLAN_CHALLENGED;
1405 } 1388 }
1406 1389
1407 status = register_netdev(netdev); 1390 status = register_netdev(netdev);
1408 if (status) { 1391 if (status) {
1409 dev_err(ctodev(card), "%s:Couldn't register net_device: %d\n", 1392 dev_err(ctodev(card), "%s:Couldn't register %s %d\n",
1410 __func__, status); 1393 __func__, netdev->name, status);
1411 return status; 1394 return status;
1412 } 1395 }
1396 dev_info(ctodev(card), "%s: MAC addr %s\n",
1397 netdev->name,
1398 print_mac(mac, netdev->dev_addr));
1413 1399
1414 return 0; 1400 return 0;
1415} 1401}
1416 1402
1417/** 1403/**
1418 * gelic_net_alloc_card - allocates net_device and card structure 1404 * gelic_alloc_card_net - allocates net_device and card structure
1419 * 1405 *
1420 * returns the card structure or NULL in case of errors 1406 * returns the card structure or NULL in case of errors
1421 * 1407 *
1422 * the card and net_device structures are linked to each other 1408 * the card and net_device structures are linked to each other
1423 */ 1409 */
1424static struct gelic_net_card *gelic_net_alloc_card(void) 1410#define GELIC_ALIGN (32)
1411static struct gelic_card *gelic_alloc_card_net(struct net_device **netdev)
1425{ 1412{
1426 struct net_device *netdev; 1413 struct gelic_card *card;
1427 struct gelic_net_card *card; 1414 struct gelic_port *port;
1415 void *p;
1428 size_t alloc_size; 1416 size_t alloc_size;
1429
1430 alloc_size = sizeof (*card) +
1431 sizeof (struct gelic_net_descr) * GELIC_NET_RX_DESCRIPTORS +
1432 sizeof (struct gelic_net_descr) * GELIC_NET_TX_DESCRIPTORS;
1433 /* 1417 /*
1434 * we assume private data is allocated 32 bytes (or more) aligned 1418 * gelic requires dma descriptor is 32 bytes aligned and
1435 * so that gelic_net_descr should be 32 bytes aligned. 1419 * the hypervisor requires irq_status is 8 bytes aligned.
1436 * Current alloc_etherdev() does do it because NETDEV_ALIGN
1437 * is 32.
1438 * check this assumption here.
1439 */ 1420 */
1440 BUILD_BUG_ON(NETDEV_ALIGN < 32); 1421 BUILD_BUG_ON(offsetof(struct gelic_card, irq_status) % 8);
1441 BUILD_BUG_ON(offsetof(struct gelic_net_card, irq_status) % 8); 1422 BUILD_BUG_ON(offsetof(struct gelic_card, descr) % 32);
1442 BUILD_BUG_ON(offsetof(struct gelic_net_card, descr) % 32); 1423 alloc_size =
1424 sizeof(struct gelic_card) +
1425 sizeof(struct gelic_descr) * GELIC_NET_RX_DESCRIPTORS +
1426 sizeof(struct gelic_descr) * GELIC_NET_TX_DESCRIPTORS +
1427 GELIC_ALIGN - 1;
1428
1429 p = kzalloc(alloc_size, GFP_KERNEL);
1430 if (!p)
1431 return NULL;
1432 card = PTR_ALIGN(p, GELIC_ALIGN);
1433 card->unalign = p;
1443 1434
1444 netdev = alloc_etherdev(alloc_size); 1435 /*
1445 if (!netdev) 1436 * alloc netdev
1437 */
1438 *netdev = alloc_etherdev(sizeof(struct gelic_port));
1439 if (!netdev) {
1440 kfree(card->unalign);
1446 return NULL; 1441 return NULL;
1442 }
1443 port = netdev_priv(*netdev);
1444
1445 /* gelic_port */
1446 port->netdev = *netdev;
1447 port->card = card;
1448 port->type = GELIC_PORT_ETHERNET;
1449
1450 /* gelic_card */
1451 card->netdev[GELIC_PORT_ETHERNET] = *netdev;
1447 1452
1448 card = netdev_priv(netdev);
1449 card->netdev = netdev;
1450 INIT_WORK(&card->tx_timeout_task, gelic_net_tx_timeout_task); 1453 INIT_WORK(&card->tx_timeout_task, gelic_net_tx_timeout_task);
1451 init_waitqueue_head(&card->waitq); 1454 init_waitqueue_head(&card->waitq);
1452 atomic_set(&card->tx_timeout_task_counter, 0); 1455 atomic_set(&card->tx_timeout_task_counter, 0);
1456 init_MUTEX(&card->updown_lock);
1457 atomic_set(&card->users, 0);
1453 1458
1454 return card; 1459 return card;
1455} 1460}
1456 1461
1462static void gelic_card_get_vlan_info(struct gelic_card *card)
1463{
1464 u64 v1, v2;
1465 int status;
1466 unsigned int i;
1467 struct {
1468 int tx;
1469 int rx;
1470 } vlan_id_ix[2] = {
1471 [GELIC_PORT_ETHERNET] = {
1472 .tx = GELIC_LV1_VLAN_TX_ETHERNET,
1473 .rx = GELIC_LV1_VLAN_RX_ETHERNET
1474 },
1475 [GELIC_PORT_WIRELESS] = {
1476 .tx = GELIC_LV1_VLAN_TX_WIRELESS,
1477 .rx = GELIC_LV1_VLAN_RX_WIRELESS
1478 }
1479 };
1480
1481 for (i = 0; i < ARRAY_SIZE(vlan_id_ix); i++) {
1482 /* tx tag */
1483 status = lv1_net_control(bus_id(card), dev_id(card),
1484 GELIC_LV1_GET_VLAN_ID,
1485 vlan_id_ix[i].tx,
1486 0, 0, &v1, &v2);
1487 if (status || !v1) {
1488 if (status != LV1_NO_ENTRY)
1489 dev_dbg(ctodev(card),
1490 "get vlan id for tx(%d) failed(%d)\n",
1491 vlan_id_ix[i].tx, status);
1492 card->vlan[i].tx = 0;
1493 card->vlan[i].rx = 0;
1494 continue;
1495 }
1496 card->vlan[i].tx = (u16)v1;
1497
1498 /* rx tag */
1499 status = lv1_net_control(bus_id(card), dev_id(card),
1500 GELIC_LV1_GET_VLAN_ID,
1501 vlan_id_ix[i].rx,
1502 0, 0, &v1, &v2);
1503 if (status || !v1) {
1504 if (status != LV1_NO_ENTRY)
1505 dev_info(ctodev(card),
1506 "get vlan id for rx(%d) failed(%d)\n",
1507 vlan_id_ix[i].rx, status);
1508 card->vlan[i].tx = 0;
1509 card->vlan[i].rx = 0;
1510 continue;
1511 }
1512 card->vlan[i].rx = (u16)v1;
1513
1514 dev_dbg(ctodev(card), "vlan_id[%d] tx=%02x rx=%02x\n",
1515 i, card->vlan[i].tx, card->vlan[i].rx);
1516 }
1517
1518 if (card->vlan[GELIC_PORT_ETHERNET].tx) {
1519 BUG_ON(!card->vlan[GELIC_PORT_WIRELESS].tx);
1520 card->vlan_required = 1;
1521 } else
1522 card->vlan_required = 0;
1523
1524 /* check wirelss capable firmware */
1525 if (ps3_compare_firmware_version(1, 6, 0) < 0) {
1526 card->vlan[GELIC_PORT_WIRELESS].tx = 0;
1527 card->vlan[GELIC_PORT_WIRELESS].rx = 0;
1528 }
1529
1530 dev_info(ctodev(card), "internal vlan %s\n",
1531 card->vlan_required? "enabled" : "disabled");
1532}
1457/** 1533/**
1458 * ps3_gelic_driver_probe - add a device to the control of this driver 1534 * ps3_gelic_driver_probe - add a device to the control of this driver
1459 */ 1535 */
1460static int ps3_gelic_driver_probe (struct ps3_system_bus_device *dev) 1536static int ps3_gelic_driver_probe(struct ps3_system_bus_device *dev)
1461{ 1537{
1462 struct gelic_net_card *card = gelic_net_alloc_card(); 1538 struct gelic_card *card;
1539 struct net_device *netdev;
1463 int result; 1540 int result;
1464 1541
1465 if (!card) { 1542 pr_debug("%s: called\n", __func__);
1466 dev_info(&dev->core, "gelic_net_alloc_card failed\n");
1467 result = -ENOMEM;
1468 goto fail_alloc_card;
1469 }
1470
1471 ps3_system_bus_set_driver_data(dev, card);
1472 card->dev = dev;
1473
1474 result = ps3_open_hv_device(dev); 1543 result = ps3_open_hv_device(dev);
1475 1544
1476 if (result) { 1545 if (result) {
1477 dev_dbg(&dev->core, "ps3_open_hv_device failed\n"); 1546 dev_dbg(&dev->core, "%s:ps3_open_hv_device failed\n",
1547 __func__);
1478 goto fail_open; 1548 goto fail_open;
1479 } 1549 }
1480 1550
1481 result = ps3_dma_region_create(dev->d_region); 1551 result = ps3_dma_region_create(dev->d_region);
1482 1552
1483 if (result) { 1553 if (result) {
1484 dev_dbg(&dev->core, "ps3_dma_region_create failed(%d)\n", 1554 dev_dbg(&dev->core, "%s:ps3_dma_region_create failed(%d)\n",
1485 result); 1555 __func__, result);
1486 BUG_ON("check region type"); 1556 BUG_ON("check region type");
1487 goto fail_dma_region; 1557 goto fail_dma_region;
1488 } 1558 }
1489 1559
1560 /* alloc card/netdevice */
1561 card = gelic_alloc_card_net(&netdev);
1562 if (!card) {
1563 dev_info(&dev->core, "%s:gelic_net_alloc_card failed\n",
1564 __func__);
1565 result = -ENOMEM;
1566 goto fail_alloc_card;
1567 }
1568 ps3_system_bus_set_driver_data(dev, card);
1569 card->dev = dev;
1570
1571 /* get internal vlan info */
1572 gelic_card_get_vlan_info(card);
1573
1574 /* setup interrupt */
1490 result = lv1_net_set_interrupt_status_indicator(bus_id(card), 1575 result = lv1_net_set_interrupt_status_indicator(bus_id(card),
1491 dev_id(card), 1576 dev_id(card),
1492 ps3_mm_phys_to_lpar(__pa(&card->irq_status)), 1577 ps3_mm_phys_to_lpar(__pa(&card->irq_status)),
@@ -1494,34 +1579,101 @@ static int ps3_gelic_driver_probe (struct ps3_system_bus_device *dev)
1494 1579
1495 if (result) { 1580 if (result) {
1496 dev_dbg(&dev->core, 1581 dev_dbg(&dev->core,
1497 "lv1_net_set_interrupt_status_indicator failed: %s\n", 1582 "%s:set_interrupt_status_indicator failed: %s\n",
1498 ps3_result(result)); 1583 __func__, ps3_result(result));
1499 result = -EIO; 1584 result = -EIO;
1500 goto fail_status_indicator; 1585 goto fail_status_indicator;
1501 } 1586 }
1502 1587
1503 result = gelic_net_setup_netdev(card); 1588 result = ps3_sb_event_receive_port_setup(dev, PS3_BINDING_CPU_ANY,
1589 &card->irq);
1590
1591 if (result) {
1592 dev_info(ctodev(card),
1593 "%s:gelic_net_open_device failed (%d)\n",
1594 __func__, result);
1595 result = -EPERM;
1596 goto fail_alloc_irq;
1597 }
1598 result = request_irq(card->irq, gelic_card_interrupt,
1599 IRQF_DISABLED, netdev->name, card);
1600
1601 if (result) {
1602 dev_info(ctodev(card), "%s:request_irq failed (%d)\n",
1603 __func__, result);
1604 goto fail_request_irq;
1605 }
1606
1607 /* setup card structure */
1608 card->irq_mask = GELIC_CARD_RXINT | GELIC_CARD_TXINT |
1609 GELIC_CARD_PORT_STATUS_CHANGED;
1610 card->rx_csum = GELIC_CARD_RX_CSUM_DEFAULT;
1504 1611
1612
1613 if (gelic_card_init_chain(card, &card->tx_chain,
1614 card->descr, GELIC_NET_TX_DESCRIPTORS))
1615 goto fail_alloc_tx;
1616 if (gelic_card_init_chain(card, &card->rx_chain,
1617 card->descr + GELIC_NET_TX_DESCRIPTORS,
1618 GELIC_NET_RX_DESCRIPTORS))
1619 goto fail_alloc_rx;
1620
1621 /* head of chain */
1622 card->tx_top = card->tx_chain.head;
1623 card->rx_top = card->rx_chain.head;
1624 dev_dbg(ctodev(card), "descr rx %p, tx %p, size %#lx, num %#x\n",
1625 card->rx_top, card->tx_top, sizeof(struct gelic_descr),
1626 GELIC_NET_RX_DESCRIPTORS);
1627 /* allocate rx skbs */
1628 if (gelic_card_alloc_rx_skbs(card))
1629 goto fail_alloc_skbs;
1630
1631 spin_lock_init(&card->tx_lock);
1632 card->tx_dma_progress = 0;
1633
1634 /* setup net_device structure */
1635 netdev->irq = card->irq;
1636 SET_NETDEV_DEV(netdev, &card->dev->core);
1637 gelic_ether_setup_netdev_ops(netdev, &card->napi);
1638 result = gelic_net_setup_netdev(netdev, card);
1505 if (result) { 1639 if (result) {
1506 dev_dbg(&dev->core, "%s:%d: ps3_dma_region_create failed: " 1640 dev_dbg(&dev->core, "%s: setup_netdev failed %d",
1507 "(%d)\n", __func__, __LINE__, result); 1641 __func__, result);
1508 goto fail_setup_netdev; 1642 goto fail_setup_netdev;
1509 } 1643 }
1510 1644
1645#ifdef CONFIG_GELIC_WIRELESS
1646 if (gelic_wl_driver_probe(card)) {
1647 dev_dbg(&dev->core, "%s: WL init failed\n", __func__);
1648 goto fail_setup_netdev;
1649 }
1650#endif
1651 pr_debug("%s: done\n", __func__);
1511 return 0; 1652 return 0;
1512 1653
1513fail_setup_netdev: 1654fail_setup_netdev:
1655fail_alloc_skbs:
1656 gelic_card_free_chain(card, card->rx_chain.head);
1657fail_alloc_rx:
1658 gelic_card_free_chain(card, card->tx_chain.head);
1659fail_alloc_tx:
1660 free_irq(card->irq, card);
1661 netdev->irq = NO_IRQ;
1662fail_request_irq:
1663 ps3_sb_event_receive_port_destroy(dev, card->irq);
1664fail_alloc_irq:
1514 lv1_net_set_interrupt_status_indicator(bus_id(card), 1665 lv1_net_set_interrupt_status_indicator(bus_id(card),
1515 bus_id(card), 1666 bus_id(card),
1516 0 , 0); 1667 0, 0);
1517fail_status_indicator: 1668fail_status_indicator:
1669 ps3_system_bus_set_driver_data(dev, NULL);
1670 kfree(netdev_card(netdev)->unalign);
1671 free_netdev(netdev);
1672fail_alloc_card:
1518 ps3_dma_region_free(dev->d_region); 1673 ps3_dma_region_free(dev->d_region);
1519fail_dma_region: 1674fail_dma_region:
1520 ps3_close_hv_device(dev); 1675 ps3_close_hv_device(dev);
1521fail_open: 1676fail_open:
1522 ps3_system_bus_set_driver_data(dev, NULL);
1523 free_netdev(card->netdev);
1524fail_alloc_card:
1525 return result; 1677 return result;
1526} 1678}
1527 1679
@@ -1529,9 +1681,34 @@ fail_alloc_card:
1529 * ps3_gelic_driver_remove - remove a device from the control of this driver 1681 * ps3_gelic_driver_remove - remove a device from the control of this driver
1530 */ 1682 */
1531 1683
1532static int ps3_gelic_driver_remove (struct ps3_system_bus_device *dev) 1684static int ps3_gelic_driver_remove(struct ps3_system_bus_device *dev)
1533{ 1685{
1534 struct gelic_net_card *card = ps3_system_bus_get_driver_data(dev); 1686 struct gelic_card *card = ps3_system_bus_get_driver_data(dev);
1687 struct net_device *netdev0;
1688 pr_debug("%s: called\n", __func__);
1689
1690#ifdef CONFIG_GELIC_WIRELESS
1691 gelic_wl_driver_remove(card);
1692#endif
1693 /* stop interrupt */
1694 gelic_card_set_irq_mask(card, 0);
1695
1696 /* turn off DMA, force end */
1697 gelic_card_disable_rxdmac(card);
1698 gelic_card_disable_txdmac(card);
1699
1700 /* release chains */
1701 gelic_card_release_tx_chain(card, 1);
1702 gelic_card_release_rx_chain(card);
1703
1704 gelic_card_free_chain(card, card->tx_top);
1705 gelic_card_free_chain(card, card->rx_top);
1706
1707 netdev0 = card->netdev[GELIC_PORT_ETHERNET];
1708 /* disconnect event port */
1709 free_irq(card->irq, card);
1710 netdev0->irq = NO_IRQ;
1711 ps3_sb_event_receive_port_destroy(card->dev, card->irq);
1535 1712
1536 wait_event(card->waitq, 1713 wait_event(card->waitq,
1537 atomic_read(&card->tx_timeout_task_counter) == 0); 1714 atomic_read(&card->tx_timeout_task_counter) == 0);
@@ -1539,8 +1716,9 @@ static int ps3_gelic_driver_remove (struct ps3_system_bus_device *dev)
1539 lv1_net_set_interrupt_status_indicator(bus_id(card), dev_id(card), 1716 lv1_net_set_interrupt_status_indicator(bus_id(card), dev_id(card),
1540 0 , 0); 1717 0 , 0);
1541 1718
1542 unregister_netdev(card->netdev); 1719 unregister_netdev(netdev0);
1543 free_netdev(card->netdev); 1720 kfree(netdev_card(netdev0)->unalign);
1721 free_netdev(netdev0);
1544 1722
1545 ps3_system_bus_set_driver_data(dev, NULL); 1723 ps3_system_bus_set_driver_data(dev, NULL);
1546 1724
@@ -1548,6 +1726,7 @@ static int ps3_gelic_driver_remove (struct ps3_system_bus_device *dev)
1548 1726
1549 ps3_close_hv_device(dev); 1727 ps3_close_hv_device(dev);
1550 1728
1729 pr_debug("%s: done\n", __func__);
1551 return 0; 1730 return 0;
1552} 1731}
1553 1732
@@ -1572,8 +1751,8 @@ static void __exit ps3_gelic_driver_exit (void)
1572 ps3_system_bus_driver_unregister(&ps3_gelic_driver); 1751 ps3_system_bus_driver_unregister(&ps3_gelic_driver);
1573} 1752}
1574 1753
1575module_init (ps3_gelic_driver_init); 1754module_init(ps3_gelic_driver_init);
1576module_exit (ps3_gelic_driver_exit); 1755module_exit(ps3_gelic_driver_exit);
1577 1756
1578MODULE_ALIAS(PS3_MODULE_ALIAS_GELIC); 1757MODULE_ALIAS(PS3_MODULE_ALIAS_GELIC);
1579 1758
diff --git a/drivers/net/ps3_gelic_net.h b/drivers/net/ps3_gelic_net.h
index 968560269a3b..1d39d06797e4 100644
--- a/drivers/net/ps3_gelic_net.h
+++ b/drivers/net/ps3_gelic_net.h
@@ -35,198 +35,323 @@
35#define GELIC_NET_MAX_MTU VLAN_ETH_FRAME_LEN 35#define GELIC_NET_MAX_MTU VLAN_ETH_FRAME_LEN
36#define GELIC_NET_MIN_MTU VLAN_ETH_ZLEN 36#define GELIC_NET_MIN_MTU VLAN_ETH_ZLEN
37#define GELIC_NET_RXBUF_ALIGN 128 37#define GELIC_NET_RXBUF_ALIGN 128
38#define GELIC_NET_RX_CSUM_DEFAULT 1 /* hw chksum */ 38#define GELIC_CARD_RX_CSUM_DEFAULT 1 /* hw chksum */
39#define GELIC_NET_WATCHDOG_TIMEOUT 5*HZ 39#define GELIC_NET_WATCHDOG_TIMEOUT 5*HZ
40#define GELIC_NET_NAPI_WEIGHT (GELIC_NET_RX_DESCRIPTORS) 40#define GELIC_NET_NAPI_WEIGHT (GELIC_NET_RX_DESCRIPTORS)
41#define GELIC_NET_BROADCAST_ADDR 0xffffffffffffL 41#define GELIC_NET_BROADCAST_ADDR 0xffffffffffffL
42#define GELIC_NET_VLAN_POS (VLAN_ETH_ALEN * 2) 42
43#define GELIC_NET_VLAN_MAX 4
44#define GELIC_NET_MC_COUNT_MAX 32 /* multicast address list */ 43#define GELIC_NET_MC_COUNT_MAX 32 /* multicast address list */
45 44
46enum gelic_net_int0_status { 45/* virtual interrupt status register bits */
47 GELIC_NET_GDTDCEINT = 24, 46 /* INT1 */
48 GELIC_NET_GRFANMINT = 28, 47#define GELIC_CARD_TX_RAM_FULL_ERR 0x0000000000000001L
49}; 48#define GELIC_CARD_RX_RAM_FULL_ERR 0x0000000000000002L
49#define GELIC_CARD_TX_SHORT_FRAME_ERR 0x0000000000000004L
50#define GELIC_CARD_TX_INVALID_DESCR_ERR 0x0000000000000008L
51#define GELIC_CARD_RX_FIFO_FULL_ERR 0x0000000000002000L
52#define GELIC_CARD_RX_DESCR_CHAIN_END 0x0000000000004000L
53#define GELIC_CARD_RX_INVALID_DESCR_ERR 0x0000000000008000L
54#define GELIC_CARD_TX_RESPONCE_ERR 0x0000000000010000L
55#define GELIC_CARD_RX_RESPONCE_ERR 0x0000000000100000L
56#define GELIC_CARD_TX_PROTECTION_ERR 0x0000000000400000L
57#define GELIC_CARD_RX_PROTECTION_ERR 0x0000000004000000L
58#define GELIC_CARD_TX_TCP_UDP_CHECKSUM_ERR 0x0000000008000000L
59#define GELIC_CARD_PORT_STATUS_CHANGED 0x0000000020000000L
60#define GELIC_CARD_WLAN_EVENT_RECEIVED 0x0000000040000000L
61#define GELIC_CARD_WLAN_COMMAND_COMPLETED 0x0000000080000000L
62 /* INT 0 */
63#define GELIC_CARD_TX_FLAGGED_DESCR 0x0004000000000000L
64#define GELIC_CARD_RX_FLAGGED_DESCR 0x0040000000000000L
65#define GELIC_CARD_TX_TRANSFER_END 0x0080000000000000L
66#define GELIC_CARD_TX_DESCR_CHAIN_END 0x0100000000000000L
67#define GELIC_CARD_NUMBER_OF_RX_FRAME 0x1000000000000000L
68#define GELIC_CARD_ONE_TIME_COUNT_TIMER 0x4000000000000000L
69#define GELIC_CARD_FREE_RUN_COUNT_TIMER 0x8000000000000000L
70
71/* initial interrupt mask */
72#define GELIC_CARD_TXINT GELIC_CARD_TX_DESCR_CHAIN_END
50 73
51/* GHIINT1STS bits */ 74#define GELIC_CARD_RXINT (GELIC_CARD_RX_DESCR_CHAIN_END | \
52enum gelic_net_int1_status { 75 GELIC_CARD_NUMBER_OF_RX_FRAME)
53 GELIC_NET_GDADCEINT = 14, 76
77 /* RX descriptor data_status bits */
78enum gelic_descr_rx_status {
79 GELIC_DESCR_RXDMADU = 0x80000000, /* destination MAC addr unknown */
80 GELIC_DESCR_RXLSTFBF = 0x40000000, /* last frame buffer */
81 GELIC_DESCR_RXIPCHK = 0x20000000, /* IP checksum performed */
82 GELIC_DESCR_RXTCPCHK = 0x10000000, /* TCP/UDP checksup performed */
83 GELIC_DESCR_RXWTPKT = 0x00C00000, /*
84 * wakeup trigger packet
85 * 01: Magic Packet (TM)
86 * 10: ARP packet
87 * 11: Multicast MAC addr
88 */
89 GELIC_DESCR_RXVLNPKT = 0x00200000, /* VLAN packet */
90 /* bit 20..16 reserved */
91 GELIC_DESCR_RXRRECNUM = 0x0000ff00, /* reception receipt number */
92 /* bit 7..0 reserved */
54}; 93};
55 94
56/* interrupt mask */ 95#define GELIC_DESCR_DATA_STATUS_CHK_MASK \
57#define GELIC_NET_TXINT (1L << (GELIC_NET_GDTDCEINT + 32)) 96 (GELIC_DESCR_RXIPCHK | GELIC_DESCR_RXTCPCHK)
58 97
59#define GELIC_NET_RXINT0 (1L << (GELIC_NET_GRFANMINT + 32)) 98 /* TX descriptor data_status bits */
60#define GELIC_NET_RXINT1 (1L << GELIC_NET_GDADCEINT) 99enum gelic_descr_tx_status {
61#define GELIC_NET_RXINT (GELIC_NET_RXINT0 | GELIC_NET_RXINT1) 100 GELIC_DESCR_TX_TAIL = 0x00000001, /* gelic treated this
101 * descriptor was end of
102 * a tx frame
103 */
104};
62 105
63 /* RX descriptor data_status bits */ 106/* RX descriptor data error bits */
64#define GELIC_NET_RXDMADU 0x80000000 /* destination MAC addr unknown */ 107enum gelic_descr_rx_error {
65#define GELIC_NET_RXLSTFBF 0x40000000 /* last frame buffer */ 108 /* bit 31 reserved */
66#define GELIC_NET_RXIPCHK 0x20000000 /* IP checksum performed */ 109 GELIC_DESCR_RXALNERR = 0x40000000, /* alignement error 10/100M */
67#define GELIC_NET_RXTCPCHK 0x10000000 /* TCP/UDP checksup performed */ 110 GELIC_DESCR_RXOVERERR = 0x20000000, /* oversize error */
68#define GELIC_NET_RXIPSPKT 0x08000000 /* IPsec packet */ 111 GELIC_DESCR_RXRNTERR = 0x10000000, /* Runt error */
69#define GELIC_NET_RXIPSAHPRT 0x04000000 /* IPsec AH protocol performed */ 112 GELIC_DESCR_RXIPCHKERR = 0x08000000, /* IP checksum error */
70#define GELIC_NET_RXIPSESPPRT 0x02000000 /* IPsec ESP protocol performed */ 113 GELIC_DESCR_RXTCPCHKERR = 0x04000000, /* TCP/UDP checksum error */
71#define GELIC_NET_RXSESPAH 0x01000000 /* 114 GELIC_DESCR_RXDRPPKT = 0x00100000, /* drop packet */
72 * IPsec ESP protocol auth 115 GELIC_DESCR_RXIPFMTERR = 0x00080000, /* IP packet format error */
73 * performed 116 /* bit 18 reserved */
74 */ 117 GELIC_DESCR_RXDATAERR = 0x00020000, /* IP packet format error */
75 118 GELIC_DESCR_RXCALERR = 0x00010000, /* cariier extension length
76#define GELIC_NET_RXWTPKT 0x00C00000 /* 119 * error */
77 * wakeup trigger packet 120 GELIC_DESCR_RXCREXERR = 0x00008000, /* carrier extention error */
78 * 01: Magic Packet (TM) 121 GELIC_DESCR_RXMLTCST = 0x00004000, /* multicast address frame */
79 * 10: ARP packet 122 /* bit 13..0 reserved */
80 * 11: Multicast MAC addr 123};
81 */ 124#define GELIC_DESCR_DATA_ERROR_CHK_MASK \
82#define GELIC_NET_RXVLNPKT 0x00200000 /* VLAN packet */ 125 (GELIC_DESCR_RXIPCHKERR | GELIC_DESCR_RXTCPCHKERR)
83/* bit 20..16 reserved */
84#define GELIC_NET_RXRRECNUM 0x0000ff00 /* reception receipt number */
85#define GELIC_NET_RXRRECNUM_SHIFT 8
86/* bit 7..0 reserved */
87
88#define GELIC_NET_TXDESC_TAIL 0
89#define GELIC_NET_DATA_STATUS_CHK_MASK (GELIC_NET_RXIPCHK | GELIC_NET_RXTCPCHK)
90
91/* RX descriptor data_error bits */
92/* bit 31 reserved */
93#define GELIC_NET_RXALNERR 0x40000000 /* alignement error 10/100M */
94#define GELIC_NET_RXOVERERR 0x20000000 /* oversize error */
95#define GELIC_NET_RXRNTERR 0x10000000 /* Runt error */
96#define GELIC_NET_RXIPCHKERR 0x08000000 /* IP checksum error */
97#define GELIC_NET_RXTCPCHKERR 0x04000000 /* TCP/UDP checksum error */
98#define GELIC_NET_RXUMCHSP 0x02000000 /* unmatched sp on sp */
99#define GELIC_NET_RXUMCHSPI 0x01000000 /* unmatched SPI on SAD */
100#define GELIC_NET_RXUMCHSAD 0x00800000 /* unmatched SAD */
101#define GELIC_NET_RXIPSAHERR 0x00400000 /* auth error on AH protocol
102 * processing */
103#define GELIC_NET_RXIPSESPAHERR 0x00200000 /* auth error on ESP protocol
104 * processing */
105#define GELIC_NET_RXDRPPKT 0x00100000 /* drop packet */
106#define GELIC_NET_RXIPFMTERR 0x00080000 /* IP packet format error */
107/* bit 18 reserved */
108#define GELIC_NET_RXDATAERR 0x00020000 /* IP packet format error */
109#define GELIC_NET_RXCALERR 0x00010000 /* cariier extension length
110 * error */
111#define GELIC_NET_RXCREXERR 0x00008000 /* carrier extention error */
112#define GELIC_NET_RXMLTCST 0x00004000 /* multicast address frame */
113/* bit 13..0 reserved */
114#define GELIC_NET_DATA_ERROR_CHK_MASK \
115 (GELIC_NET_RXIPCHKERR | GELIC_NET_RXTCPCHKERR)
116 126
127/* DMA command and status (RX and TX)*/
128enum gelic_descr_dma_status {
129 GELIC_DESCR_DMA_COMPLETE = 0x00000000, /* used in tx */
130 GELIC_DESCR_DMA_BUFFER_FULL = 0x00000000, /* used in rx */
131 GELIC_DESCR_DMA_RESPONSE_ERROR = 0x10000000, /* used in rx, tx */
132 GELIC_DESCR_DMA_PROTECTION_ERROR = 0x20000000, /* used in rx, tx */
133 GELIC_DESCR_DMA_FRAME_END = 0x40000000, /* used in rx */
134 GELIC_DESCR_DMA_FORCE_END = 0x50000000, /* used in rx, tx */
135 GELIC_DESCR_DMA_CARDOWNED = 0xa0000000, /* used in rx, tx */
136 GELIC_DESCR_DMA_NOT_IN_USE = 0xb0000000, /* any other value */
137};
138
139#define GELIC_DESCR_DMA_STAT_MASK (0xf0000000)
117 140
118/* tx descriptor command and status */ 141/* tx descriptor command and status */
119#define GELIC_NET_DMAC_CMDSTAT_NOCS 0xa0080000 /* middle of frame */ 142enum gelic_descr_tx_dma_status {
120#define GELIC_NET_DMAC_CMDSTAT_TCPCS 0xa00a0000 143 /* [19] */
121#define GELIC_NET_DMAC_CMDSTAT_UDPCS 0xa00b0000 144 GELIC_DESCR_TX_DMA_IKE = 0x00080000, /* IPSEC off */
122#define GELIC_NET_DMAC_CMDSTAT_END_FRAME 0x00040000 /* end of frame */ 145 /* [18] */
123 146 GELIC_DESCR_TX_DMA_FRAME_TAIL = 0x00040000, /* last descriptor of
124#define GELIC_NET_DMAC_CMDSTAT_RXDCEIS 0x00000002 /* descriptor chain end 147 * the packet
125 * interrupt status */ 148 */
126 149 /* [17..16] */
127#define GELIC_NET_DMAC_CMDSTAT_CHAIN_END 0x00000002 /* RXDCEIS:DMA stopped */ 150 GELIC_DESCR_TX_DMA_TCP_CHKSUM = 0x00020000, /* TCP packet */
128#define GELIC_NET_DESCR_IND_PROC_SHIFT 28 151 GELIC_DESCR_TX_DMA_UDP_CHKSUM = 0x00030000, /* UDP packet */
129#define GELIC_NET_DESCR_IND_PROC_MASKO 0x0fffffff 152 GELIC_DESCR_TX_DMA_NO_CHKSUM = 0x00000000, /* no checksum */
130 153
131 154 /* [1] */
132enum gelic_net_descr_status { 155 GELIC_DESCR_TX_DMA_CHAIN_END = 0x00000002, /* DMA terminated
133 GELIC_NET_DESCR_COMPLETE = 0x00, /* used in tx */ 156 * due to chain end
134 GELIC_NET_DESCR_BUFFER_FULL = 0x00, /* used in rx */ 157 */
135 GELIC_NET_DESCR_RESPONSE_ERROR = 0x01, /* used in rx and tx */
136 GELIC_NET_DESCR_PROTECTION_ERROR = 0x02, /* used in rx and tx */
137 GELIC_NET_DESCR_FRAME_END = 0x04, /* used in rx */
138 GELIC_NET_DESCR_FORCE_END = 0x05, /* used in rx and tx */
139 GELIC_NET_DESCR_CARDOWNED = 0x0a, /* used in rx and tx */
140 GELIC_NET_DESCR_NOT_IN_USE = 0x0b /* any other value */
141}; 158};
159
160#define GELIC_DESCR_DMA_CMD_NO_CHKSUM \
161 (GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
162 GELIC_DESCR_TX_DMA_NO_CHKSUM)
163
164#define GELIC_DESCR_DMA_CMD_TCP_CHKSUM \
165 (GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
166 GELIC_DESCR_TX_DMA_TCP_CHKSUM)
167
168#define GELIC_DESCR_DMA_CMD_UDP_CHKSUM \
169 (GELIC_DESCR_DMA_CARDOWNED | GELIC_DESCR_TX_DMA_IKE | \
170 GELIC_DESCR_TX_DMA_UDP_CHKSUM)
171
172enum gelic_descr_rx_dma_status {
173 /* [ 1 ] */
174 GELIC_DESCR_RX_DMA_CHAIN_END = 0x00000002, /* DMA terminated
175 * due to chain end
176 */
177};
178
142/* for lv1_net_control */ 179/* for lv1_net_control */
143#define GELIC_NET_GET_MAC_ADDRESS 0x0000000000000001 180enum gelic_lv1_net_control_code {
144#define GELIC_NET_GET_ETH_PORT_STATUS 0x0000000000000002 181 GELIC_LV1_GET_MAC_ADDRESS = 1,
145#define GELIC_NET_SET_NEGOTIATION_MODE 0x0000000000000003 182 GELIC_LV1_GET_ETH_PORT_STATUS = 2,
146#define GELIC_NET_GET_VLAN_ID 0x0000000000000004 183 GELIC_LV1_SET_NEGOTIATION_MODE = 3,
147 184 GELIC_LV1_GET_VLAN_ID = 4,
148#define GELIC_NET_LINK_UP 0x0000000000000001 185 GELIC_LV1_GET_CHANNEL = 6,
149#define GELIC_NET_FULL_DUPLEX 0x0000000000000002 186 GELIC_LV1_POST_WLAN_CMD = 9,
150#define GELIC_NET_AUTO_NEG 0x0000000000000004 187 GELIC_LV1_GET_WLAN_CMD_RESULT = 10,
151#define GELIC_NET_SPEED_10 0x0000000000000010 188 GELIC_LV1_GET_WLAN_EVENT = 11
152#define GELIC_NET_SPEED_100 0x0000000000000020 189};
153#define GELIC_NET_SPEED_1000 0x0000000000000040 190
154 191/* status returened from GET_ETH_PORT_STATUS */
155#define GELIC_NET_VLAN_ALL 0x0000000000000001 192enum gelic_lv1_ether_port_status {
156#define GELIC_NET_VLAN_WIRED 0x0000000000000002 193 GELIC_LV1_ETHER_LINK_UP = 0x0000000000000001L,
157#define GELIC_NET_VLAN_WIRELESS 0x0000000000000003 194 GELIC_LV1_ETHER_FULL_DUPLEX = 0x0000000000000002L,
158#define GELIC_NET_VLAN_PSP 0x0000000000000004 195 GELIC_LV1_ETHER_AUTO_NEG = 0x0000000000000004L,
159#define GELIC_NET_VLAN_PORT0 0x0000000000000010 196
160#define GELIC_NET_VLAN_PORT1 0x0000000000000011 197 GELIC_LV1_ETHER_SPEED_10 = 0x0000000000000010L,
161#define GELIC_NET_VLAN_PORT2 0x0000000000000012 198 GELIC_LV1_ETHER_SPEED_100 = 0x0000000000000020L,
162#define GELIC_NET_VLAN_DAEMON_CLIENT_BSS 0x0000000000000013 199 GELIC_LV1_ETHER_SPEED_1000 = 0x0000000000000040L,
163#define GELIC_NET_VLAN_LIBERO_CLIENT_BSS 0x0000000000000014 200 GELIC_LV1_ETHER_SPEED_MASK = 0x0000000000000070L
164#define GELIC_NET_VLAN_NO_ENTRY -6 201};
165 202
166#define GELIC_NET_PORT 2 /* for port status */ 203enum gelic_lv1_vlan_index {
204 /* for outgoing packets */
205 GELIC_LV1_VLAN_TX_ETHERNET = 0x0000000000000002L,
206 GELIC_LV1_VLAN_TX_WIRELESS = 0x0000000000000003L,
207 /* for incoming packets */
208 GELIC_LV1_VLAN_RX_ETHERNET = 0x0000000000000012L,
209 GELIC_LV1_VLAN_RX_WIRELESS = 0x0000000000000013L
210};
167 211
168/* size of hardware part of gelic descriptor */ 212/* size of hardware part of gelic descriptor */
169#define GELIC_NET_DESCR_SIZE (32) 213#define GELIC_DESCR_SIZE (32)
170struct gelic_net_descr { 214
215enum gelic_port_type {
216 GELIC_PORT_ETHERNET = 0,
217 GELIC_PORT_WIRELESS = 1,
218 GELIC_PORT_MAX
219};
220
221struct gelic_descr {
171 /* as defined by the hardware */ 222 /* as defined by the hardware */
172 u32 buf_addr; 223 __be32 buf_addr;
173 u32 buf_size; 224 __be32 buf_size;
174 u32 next_descr_addr; 225 __be32 next_descr_addr;
175 u32 dmac_cmd_status; 226 __be32 dmac_cmd_status;
176 u32 result_size; 227 __be32 result_size;
177 u32 valid_size; /* all zeroes for tx */ 228 __be32 valid_size; /* all zeroes for tx */
178 u32 data_status; 229 __be32 data_status;
179 u32 data_error; /* all zeroes for tx */ 230 __be32 data_error; /* all zeroes for tx */
180 231
181 /* used in the driver */ 232 /* used in the driver */
182 struct sk_buff *skb; 233 struct sk_buff *skb;
183 dma_addr_t bus_addr; 234 dma_addr_t bus_addr;
184 struct gelic_net_descr *next; 235 struct gelic_descr *next;
185 struct gelic_net_descr *prev; 236 struct gelic_descr *prev;
186 struct vlan_ethhdr vlan;
187} __attribute__((aligned(32))); 237} __attribute__((aligned(32)));
188 238
189struct gelic_net_descr_chain { 239struct gelic_descr_chain {
190 /* we walk from tail to head */ 240 /* we walk from tail to head */
191 struct gelic_net_descr *head; 241 struct gelic_descr *head;
192 struct gelic_net_descr *tail; 242 struct gelic_descr *tail;
193}; 243};
194 244
195struct gelic_net_card { 245struct gelic_vlan_id {
196 struct net_device *netdev; 246 u16 tx;
247 u16 rx;
248};
249
250struct gelic_card {
197 struct napi_struct napi; 251 struct napi_struct napi;
252 struct net_device *netdev[GELIC_PORT_MAX];
198 /* 253 /*
199 * hypervisor requires irq_status should be 254 * hypervisor requires irq_status should be
200 * 8 bytes aligned, but u64 member is 255 * 8 bytes aligned, but u64 member is
201 * always disposed in that manner 256 * always disposed in that manner
202 */ 257 */
203 u64 irq_status; 258 u64 irq_status;
204 u64 ghiintmask; 259 u64 irq_mask;
205 260
206 struct ps3_system_bus_device *dev; 261 struct ps3_system_bus_device *dev;
207 u32 vlan_id[GELIC_NET_VLAN_MAX]; 262 struct gelic_vlan_id vlan[GELIC_PORT_MAX];
208 int vlan_index; 263 int vlan_required;
209 264
210 struct gelic_net_descr_chain tx_chain; 265 struct gelic_descr_chain tx_chain;
211 struct gelic_net_descr_chain rx_chain; 266 struct gelic_descr_chain rx_chain;
212 int rx_dma_restart_required; 267 int rx_dma_restart_required;
213 /* gurad dmac descriptor chain*/
214 spinlock_t chain_lock;
215
216 int rx_csum; 268 int rx_csum;
217 /* guard tx_dma_progress */ 269 /*
218 spinlock_t tx_dma_lock; 270 * tx_lock guards tx descriptor list and
271 * tx_dma_progress.
272 */
273 spinlock_t tx_lock;
219 int tx_dma_progress; 274 int tx_dma_progress;
220 275
221 struct work_struct tx_timeout_task; 276 struct work_struct tx_timeout_task;
222 atomic_t tx_timeout_task_counter; 277 atomic_t tx_timeout_task_counter;
223 wait_queue_head_t waitq; 278 wait_queue_head_t waitq;
224 279
225 struct gelic_net_descr *tx_top, *rx_top; 280 /* only first user should up the card */
226 struct gelic_net_descr descr[0]; 281 struct semaphore updown_lock;
282 atomic_t users;
283
284 u64 ether_port_status;
285 /* original address returned by kzalloc */
286 void *unalign;
287
288 /*
289 * each netdevice has copy of irq
290 */
291 unsigned int irq;
292 struct gelic_descr *tx_top, *rx_top;
293 struct gelic_descr descr[0]; /* must be the last */
294};
295
296struct gelic_port {
297 struct gelic_card *card;
298 struct net_device *netdev;
299 enum gelic_port_type type;
300 long priv[0]; /* long for alignment */
227}; 301};
228 302
303static inline struct gelic_card *port_to_card(struct gelic_port *p)
304{
305 return p->card;
306}
307static inline struct net_device *port_to_netdev(struct gelic_port *p)
308{
309 return p->netdev;
310}
311static inline struct gelic_card *netdev_card(struct net_device *d)
312{
313 return ((struct gelic_port *)netdev_priv(d))->card;
314}
315static inline struct gelic_port *netdev_port(struct net_device *d)
316{
317 return (struct gelic_port *)netdev_priv(d);
318}
319static inline struct device *ctodev(struct gelic_card *card)
320{
321 return &card->dev->core;
322}
323static inline u64 bus_id(struct gelic_card *card)
324{
325 return card->dev->bus_id;
326}
327static inline u64 dev_id(struct gelic_card *card)
328{
329 return card->dev->dev_id;
330}
331
332static inline void *port_priv(struct gelic_port *port)
333{
334 return port->priv;
335}
336
337extern int gelic_card_set_irq_mask(struct gelic_card *card, u64 mask);
338/* shared netdev ops */
339extern void gelic_card_up(struct gelic_card *card);
340extern void gelic_card_down(struct gelic_card *card);
341extern int gelic_net_open(struct net_device *netdev);
342extern int gelic_net_stop(struct net_device *netdev);
343extern int gelic_net_xmit(struct sk_buff *skb, struct net_device *netdev);
344extern void gelic_net_set_multi(struct net_device *netdev);
345extern void gelic_net_tx_timeout(struct net_device *netdev);
346extern int gelic_net_change_mtu(struct net_device *netdev, int new_mtu);
347extern int gelic_net_setup_netdev(struct net_device *netdev,
348 struct gelic_card *card);
229 349
230extern unsigned long p_to_lp(long pa); 350/* shared ethtool ops */
351extern void gelic_net_get_drvinfo(struct net_device *netdev,
352 struct ethtool_drvinfo *info);
353extern u32 gelic_net_get_rx_csum(struct net_device *netdev);
354extern int gelic_net_set_rx_csum(struct net_device *netdev, u32 data);
355extern void gelic_net_poll_controller(struct net_device *netdev);
231 356
232#endif /* _GELIC_NET_H */ 357#endif /* _GELIC_NET_H */
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
new file mode 100644
index 000000000000..750d2a99cb4f
--- /dev/null
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -0,0 +1,2753 @@
1/*
2 * PS3 gelic network driver.
3 *
4 * Copyright (C) 2007 Sony Computer Entertainment Inc.
5 * Copyright 2007 Sony Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20#undef DEBUG
21
22#include <linux/kernel.h>
23#include <linux/module.h>
24
25#include <linux/etherdevice.h>
26#include <linux/ethtool.h>
27#include <linux/if_vlan.h>
28
29#include <linux/in.h>
30#include <linux/ip.h>
31#include <linux/tcp.h>
32#include <linux/wireless.h>
33#include <linux/ctype.h>
34#include <linux/string.h>
35#include <net/iw_handler.h>
36#include <net/ieee80211.h>
37
38#include <linux/dma-mapping.h>
39#include <net/checksum.h>
40#include <asm/firmware.h>
41#include <asm/ps3.h>
42#include <asm/lv1call.h>
43
44#include "ps3_gelic_net.h"
45#include "ps3_gelic_wireless.h"
46
47
48static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan);
49static int gelic_wl_try_associate(struct net_device *netdev);
50
51/*
52 * tables
53 */
54
55/* 802.11b/g channel to freq in MHz */
56static const int channel_freq[] = {
57 2412, 2417, 2422, 2427, 2432,
58 2437, 2442, 2447, 2452, 2457,
59 2462, 2467, 2472, 2484
60};
61#define NUM_CHANNELS ARRAY_SIZE(channel_freq)
62
63/* in bps */
64static const int bitrate_list[] = {
65 1000000,
66 2000000,
67 5500000,
68 11000000,
69 6000000,
70 9000000,
71 12000000,
72 18000000,
73 24000000,
74 36000000,
75 48000000,
76 54000000
77};
78#define NUM_BITRATES ARRAY_SIZE(bitrate_list)
79
80/*
81 * wpa2 support requires the hypervisor version 2.0 or later
82 */
83static inline int wpa2_capable(void)
84{
85 return (0 <= ps3_compare_firmware_version(2, 0, 0));
86}
87
88static inline int precise_ie(void)
89{
90 return 0; /* FIXME */
91}
92/*
93 * post_eurus_cmd helpers
94 */
95struct eurus_cmd_arg_info {
96 int pre_arg; /* command requres arg1, arg2 at POST COMMAND */
97 int post_arg; /* command requires arg1, arg2 at GET_RESULT */
98};
99
100static const struct eurus_cmd_arg_info cmd_info[GELIC_EURUS_CMD_MAX_INDEX] = {
101 [GELIC_EURUS_CMD_SET_COMMON_CFG] = { .pre_arg = 1},
102 [GELIC_EURUS_CMD_SET_WEP_CFG] = { .pre_arg = 1},
103 [GELIC_EURUS_CMD_SET_WPA_CFG] = { .pre_arg = 1},
104 [GELIC_EURUS_CMD_GET_COMMON_CFG] = { .post_arg = 1},
105 [GELIC_EURUS_CMD_GET_WEP_CFG] = { .post_arg = 1},
106 [GELIC_EURUS_CMD_GET_WPA_CFG] = { .post_arg = 1},
107 [GELIC_EURUS_CMD_GET_RSSI_CFG] = { .post_arg = 1},
108 [GELIC_EURUS_CMD_GET_SCAN] = { .post_arg = 1},
109};
110
111#ifdef DEBUG
112static const char *cmdstr(enum gelic_eurus_command ix)
113{
114 switch (ix) {
115 case GELIC_EURUS_CMD_ASSOC:
116 return "ASSOC";
117 case GELIC_EURUS_CMD_DISASSOC:
118 return "DISASSOC";
119 case GELIC_EURUS_CMD_START_SCAN:
120 return "SCAN";
121 case GELIC_EURUS_CMD_GET_SCAN:
122 return "GET SCAN";
123 case GELIC_EURUS_CMD_SET_COMMON_CFG:
124 return "SET_COMMON_CFG";
125 case GELIC_EURUS_CMD_GET_COMMON_CFG:
126 return "GET_COMMON_CFG";
127 case GELIC_EURUS_CMD_SET_WEP_CFG:
128 return "SET_WEP_CFG";
129 case GELIC_EURUS_CMD_GET_WEP_CFG:
130 return "GET_WEP_CFG";
131 case GELIC_EURUS_CMD_SET_WPA_CFG:
132 return "SET_WPA_CFG";
133 case GELIC_EURUS_CMD_GET_WPA_CFG:
134 return "GET_WPA_CFG";
135 case GELIC_EURUS_CMD_GET_RSSI_CFG:
136 return "GET_RSSI";
137 default:
138 break;
139 }
140 return "";
141};
142#else
143static inline const char *cmdstr(enum gelic_eurus_command ix)
144{
145 return "";
146}
147#endif
148
149/* synchronously do eurus commands */
150static void gelic_eurus_sync_cmd_worker(struct work_struct *work)
151{
152 struct gelic_eurus_cmd *cmd;
153 struct gelic_card *card;
154 struct gelic_wl_info *wl;
155
156 u64 arg1, arg2;
157
158 pr_debug("%s: <-\n", __func__);
159 cmd = container_of(work, struct gelic_eurus_cmd, work);
160 BUG_ON(cmd_info[cmd->cmd].pre_arg &&
161 cmd_info[cmd->cmd].post_arg);
162 wl = cmd->wl;
163 card = port_to_card(wl_port(wl));
164
165 if (cmd_info[cmd->cmd].pre_arg) {
166 arg1 = ps3_mm_phys_to_lpar(__pa(cmd->buffer));
167 arg2 = cmd->buf_size;
168 } else {
169 arg1 = 0;
170 arg2 = 0;
171 }
172 init_completion(&wl->cmd_done_intr);
173 pr_debug("%s: cmd='%s' start\n", __func__, cmdstr(cmd->cmd));
174 cmd->status = lv1_net_control(bus_id(card), dev_id(card),
175 GELIC_LV1_POST_WLAN_CMD,
176 cmd->cmd, arg1, arg2,
177 &cmd->tag, &cmd->size);
178 if (cmd->status) {
179 complete(&cmd->done);
180 pr_info("%s: cmd issue failed\n", __func__);
181 return;
182 }
183
184 wait_for_completion(&wl->cmd_done_intr);
185
186 if (cmd_info[cmd->cmd].post_arg) {
187 arg1 = ps3_mm_phys_to_lpar(__pa(cmd->buffer));
188 arg2 = cmd->buf_size;
189 } else {
190 arg1 = 0;
191 arg2 = 0;
192 }
193
194 cmd->status = lv1_net_control(bus_id(card), dev_id(card),
195 GELIC_LV1_GET_WLAN_CMD_RESULT,
196 cmd->tag, arg1, arg2,
197 &cmd->cmd_status, &cmd->size);
198#ifdef DEBUG
199 if (cmd->status || cmd->cmd_status) {
200 pr_debug("%s: cmd done tag=%#lx arg1=%#lx, arg2=%#lx\n", __func__,
201 cmd->tag, arg1, arg2);
202 pr_debug("%s: cmd done status=%#x cmd_status=%#lx size=%#lx\n",
203 __func__, cmd->status, cmd->cmd_status, cmd->size);
204 }
205#endif
206 complete(&cmd->done);
207 pr_debug("%s: cmd='%s' done\n", __func__, cmdstr(cmd->cmd));
208}
209
210static struct gelic_eurus_cmd *gelic_eurus_sync_cmd(struct gelic_wl_info *wl,
211 unsigned int eurus_cmd,
212 void *buffer,
213 unsigned int buf_size)
214{
215 struct gelic_eurus_cmd *cmd;
216
217 /* allocate cmd */
218 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
219 if (!cmd)
220 return NULL;
221
222 /* initialize members */
223 cmd->cmd = eurus_cmd;
224 cmd->buffer = buffer;
225 cmd->buf_size = buf_size;
226 cmd->wl = wl;
227 INIT_WORK(&cmd->work, gelic_eurus_sync_cmd_worker);
228 init_completion(&cmd->done);
229 queue_work(wl->eurus_cmd_queue, &cmd->work);
230
231 /* wait for command completion */
232 wait_for_completion(&cmd->done);
233
234 return cmd;
235}
236
237static u32 gelic_wl_get_link(struct net_device *netdev)
238{
239 struct gelic_wl_info *wl = port_wl(netdev_port(netdev));
240 u32 ret;
241
242 pr_debug("%s: <-\n", __func__);
243 down(&wl->assoc_stat_lock);
244 if (wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED)
245 ret = 1;
246 else
247 ret = 0;
248 up(&wl->assoc_stat_lock);
249 pr_debug("%s: ->\n", __func__);
250 return ret;
251}
252
253static void gelic_wl_send_iwap_event(struct gelic_wl_info *wl, u8 *bssid)
254{
255 union iwreq_data data;
256
257 memset(&data, 0, sizeof(data));
258 if (bssid)
259 memcpy(data.ap_addr.sa_data, bssid, ETH_ALEN);
260 data.ap_addr.sa_family = ARPHRD_ETHER;
261 wireless_send_event(port_to_netdev(wl_port(wl)), SIOCGIWAP,
262 &data, NULL);
263}
264
265/*
266 * wireless extension handlers and helpers
267 */
268
269/* SIOGIWNAME */
270static int gelic_wl_get_name(struct net_device *dev,
271 struct iw_request_info *info,
272 union iwreq_data *iwreq, char *extra)
273{
274 strcpy(iwreq->name, "IEEE 802.11bg");
275 return 0;
276}
277
278static void gelic_wl_get_ch_info(struct gelic_wl_info *wl)
279{
280 struct gelic_card *card = port_to_card(wl_port(wl));
281 u64 ch_info_raw, tmp;
282 int status;
283
284 if (!test_and_set_bit(GELIC_WL_STAT_CH_INFO, &wl->stat)) {
285 status = lv1_net_control(bus_id(card), dev_id(card),
286 GELIC_LV1_GET_CHANNEL, 0, 0, 0,
287 &ch_info_raw,
288 &tmp);
289 /* some fw versions may return error */
290 if (status) {
291 if (status != LV1_NO_ENTRY)
292 pr_info("%s: available ch unknown\n", __func__);
293 wl->ch_info = 0x07ff;/* 11 ch */
294 } else
295 /* 16 bits of MSB has available channels */
296 wl->ch_info = ch_info_raw >> 48;
297 }
298 return;
299}
300
301/* SIOGIWRANGE */
302static int gelic_wl_get_range(struct net_device *netdev,
303 struct iw_request_info *info,
304 union iwreq_data *iwreq, char *extra)
305{
306 struct iw_point *point = &iwreq->data;
307 struct iw_range *range = (struct iw_range *)extra;
308 struct gelic_wl_info *wl = port_wl(netdev_port(netdev));
309 unsigned int i, chs;
310
311 pr_debug("%s: <-\n", __func__);
312 point->length = sizeof(struct iw_range);
313 memset(range, 0, sizeof(struct iw_range));
314
315 range->we_version_compiled = WIRELESS_EXT;
316 range->we_version_source = 22;
317
318 /* available channels and frequencies */
319 gelic_wl_get_ch_info(wl);
320
321 for (i = 0, chs = 0;
322 i < NUM_CHANNELS && chs < IW_MAX_FREQUENCIES; i++)
323 if (wl->ch_info & (1 << i)) {
324 range->freq[chs].i = i + 1;
325 range->freq[chs].m = channel_freq[i];
326 range->freq[chs].e = 6;
327 chs++;
328 }
329 range->num_frequency = chs;
330 range->old_num_frequency = chs;
331 range->num_channels = chs;
332 range->old_num_channels = chs;
333
334 /* bitrates */
335 for (i = 0; i < NUM_BITRATES; i++)
336 range->bitrate[i] = bitrate_list[i];
337 range->num_bitrates = i;
338
339 /* signal levels */
340 range->max_qual.qual = 100; /* relative value */
341 range->max_qual.level = 100;
342 range->avg_qual.qual = 50;
343 range->avg_qual.level = 50;
344 range->sensitivity = 0;
345
346 /* Event capability */
347 IW_EVENT_CAPA_SET_KERNEL(range->event_capa);
348 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP);
349 IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN);
350
351 /* encryption capability */
352 range->enc_capa = IW_ENC_CAPA_WPA |
353 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
354 if (wpa2_capable())
355 range->enc_capa |= IW_ENC_CAPA_WPA2;
356 range->encoding_size[0] = 5; /* 40bit WEP */
357 range->encoding_size[1] = 13; /* 104bit WEP */
358 range->encoding_size[2] = 32; /* WPA-PSK */
359 range->num_encoding_sizes = 3;
360 range->max_encoding_tokens = GELIC_WEP_KEYS;
361
362 pr_debug("%s: ->\n", __func__);
363 return 0;
364
365}
366
367/* SIOC{G,S}IWSCAN */
368static int gelic_wl_set_scan(struct net_device *netdev,
369 struct iw_request_info *info,
370 union iwreq_data *wrqu, char *extra)
371{
372 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
373
374 return gelic_wl_start_scan(wl, 1);
375}
376
377#define OUI_LEN 3
378static const u8 rsn_oui[OUI_LEN] = { 0x00, 0x0f, 0xac };
379static const u8 wpa_oui[OUI_LEN] = { 0x00, 0x50, 0xf2 };
380
381/*
382 * synthesize WPA/RSN IE data
383 * See WiFi WPA specification and IEEE 802.11-2007 7.3.2.25
384 * for the format
385 */
386static size_t gelic_wl_synthesize_ie(u8 *buf,
387 struct gelic_eurus_scan_info *scan)
388{
389
390 const u8 *oui_header;
391 u8 *start = buf;
392 int rsn;
393 int ccmp;
394
395 pr_debug("%s: <- sec=%16x\n", __func__, scan->security);
396 switch (be16_to_cpu(scan->security) & GELIC_EURUS_SCAN_SEC_MASK) {
397 case GELIC_EURUS_SCAN_SEC_WPA:
398 rsn = 0;
399 break;
400 case GELIC_EURUS_SCAN_SEC_WPA2:
401 rsn = 1;
402 break;
403 default:
404 /* WEP or none. No IE returned */
405 return 0;
406 }
407
408 switch (be16_to_cpu(scan->security) & GELIC_EURUS_SCAN_SEC_WPA_MASK) {
409 case GELIC_EURUS_SCAN_SEC_WPA_TKIP:
410 ccmp = 0;
411 break;
412 case GELIC_EURUS_SCAN_SEC_WPA_AES:
413 ccmp = 1;
414 break;
415 default:
416 if (rsn) {
417 ccmp = 1;
418 pr_info("%s: no cipher info. defaulted to CCMP\n",
419 __func__);
420 } else {
421 ccmp = 0;
422 pr_info("%s: no cipher info. defaulted to TKIP\n",
423 __func__);
424 }
425 }
426
427 if (rsn)
428 oui_header = rsn_oui;
429 else
430 oui_header = wpa_oui;
431
432 /* element id */
433 if (rsn)
434 *buf++ = MFIE_TYPE_RSN;
435 else
436 *buf++ = MFIE_TYPE_GENERIC;
437
438 /* length filed; set later */
439 buf++;
440
441 /* wpa special header */
442 if (!rsn) {
443 memcpy(buf, wpa_oui, OUI_LEN);
444 buf += OUI_LEN;
445 *buf++ = 0x01;
446 }
447
448 /* version */
449 *buf++ = 0x01; /* version 1.0 */
450 *buf++ = 0x00;
451
452 /* group cipher */
453 memcpy(buf, oui_header, OUI_LEN);
454 buf += OUI_LEN;
455
456 if (ccmp)
457 *buf++ = 0x04; /* CCMP */
458 else
459 *buf++ = 0x02; /* TKIP */
460
461 /* pairwise key count always 1 */
462 *buf++ = 0x01;
463 *buf++ = 0x00;
464
465 /* pairwise key suit */
466 memcpy(buf, oui_header, OUI_LEN);
467 buf += OUI_LEN;
468 if (ccmp)
469 *buf++ = 0x04; /* CCMP */
470 else
471 *buf++ = 0x02; /* TKIP */
472
473 /* AKM count is 1 */
474 *buf++ = 0x01;
475 *buf++ = 0x00;
476
477 /* AKM suite is assumed as PSK*/
478 memcpy(buf, oui_header, OUI_LEN);
479 buf += OUI_LEN;
480 *buf++ = 0x02; /* PSK */
481
482 /* RSN capabilities is 0 */
483 *buf++ = 0x00;
484 *buf++ = 0x00;
485
486 /* set length field */
487 start[1] = (buf - start - 2);
488
489 pr_debug("%s: ->\n", __func__);
490 return (buf - start);
491}
492
493struct ie_item {
494 u8 *data;
495 u8 len;
496};
497
498struct ie_info {
499 struct ie_item wpa;
500 struct ie_item rsn;
501};
502
503static void gelic_wl_parse_ie(u8 *data, size_t len,
504 struct ie_info *ie_info)
505{
506 size_t data_left = len;
507 u8 *pos = data;
508 u8 item_len;
509 u8 item_id;
510
511 pr_debug("%s: data=%p len=%ld \n", __func__,
512 data, len);
513 memset(ie_info, 0, sizeof(struct ie_info));
514
515 while (0 < data_left) {
516 item_id = *pos++;
517 item_len = *pos++;
518
519 switch (item_id) {
520 case MFIE_TYPE_GENERIC:
521 if (!memcmp(pos, wpa_oui, OUI_LEN) &&
522 pos[OUI_LEN] == 0x01) {
523 ie_info->wpa.data = pos - 2;
524 ie_info->wpa.len = item_len + 2;
525 }
526 break;
527 case MFIE_TYPE_RSN:
528 ie_info->rsn.data = pos - 2;
529 /* length includes the header */
530 ie_info->rsn.len = item_len + 2;
531 break;
532 default:
533 pr_debug("%s: ignore %#x,%d\n", __func__,
534 item_id, item_len);
535 break;
536 }
537 pos += item_len;
538 data_left -= item_len + 2;
539 }
540 pr_debug("%s: wpa=%p,%d wpa2=%p,%d\n", __func__,
541 ie_info->wpa.data, ie_info->wpa.len,
542 ie_info->rsn.data, ie_info->rsn.len);
543}
544
545
546/*
547 * translate the scan informations from hypervisor to a
548 * independent format
549 */
550static char *gelic_wl_translate_scan(struct net_device *netdev,
551 char *ev,
552 char *stop,
553 struct gelic_wl_scan_info *network)
554{
555 struct iw_event iwe;
556 struct gelic_eurus_scan_info *scan = network->hwinfo;
557 char *tmp;
558 u8 rate;
559 unsigned int i, j, len;
560 u8 buf[MAX_WPA_IE_LEN];
561
562 pr_debug("%s: <-\n", __func__);
563
564 /* first entry should be AP's mac address */
565 iwe.cmd = SIOCGIWAP;
566 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
567 memcpy(iwe.u.ap_addr.sa_data, &scan->bssid[2], ETH_ALEN);
568 ev = iwe_stream_add_event(ev, stop, &iwe, IW_EV_ADDR_LEN);
569
570 /* ESSID */
571 iwe.cmd = SIOCGIWESSID;
572 iwe.u.data.flags = 1;
573 iwe.u.data.length = strnlen(scan->essid, 32);
574 ev = iwe_stream_add_point(ev, stop, &iwe, scan->essid);
575
576 /* FREQUENCY */
577 iwe.cmd = SIOCGIWFREQ;
578 iwe.u.freq.m = be16_to_cpu(scan->channel);
579 iwe.u.freq.e = 0; /* table value in MHz */
580 iwe.u.freq.i = 0;
581 ev = iwe_stream_add_event(ev, stop, &iwe, IW_EV_FREQ_LEN);
582
583 /* RATES */
584 iwe.cmd = SIOCGIWRATE;
585 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
586 /* to stuff multiple values in one event */
587 tmp = ev + IW_EV_LCP_LEN;
588 /* put them in ascendant order (older is first) */
589 i = 0;
590 j = 0;
591 pr_debug("%s: rates=%d rate=%d\n", __func__,
592 network->rate_len, network->rate_ext_len);
593 while (i < network->rate_len) {
594 if (j < network->rate_ext_len &&
595 ((scan->ext_rate[j] & 0x7f) < (scan->rate[i] & 0x7f)))
596 rate = scan->ext_rate[j++] & 0x7f;
597 else
598 rate = scan->rate[i++] & 0x7f;
599 iwe.u.bitrate.value = rate * 500000; /* 500kbps unit */
600 tmp = iwe_stream_add_value(ev, tmp, stop, &iwe,
601 IW_EV_PARAM_LEN);
602 }
603 while (j < network->rate_ext_len) {
604 iwe.u.bitrate.value = (scan->ext_rate[j++] & 0x7f) * 500000;
605 tmp = iwe_stream_add_value(ev, tmp, stop, &iwe,
606 IW_EV_PARAM_LEN);
607 }
608 /* Check if we added any rate */
609 if (IW_EV_LCP_LEN < (tmp - ev))
610 ev = tmp;
611
612 /* ENCODE */
613 iwe.cmd = SIOCGIWENCODE;
614 if (be16_to_cpu(scan->capability) & WLAN_CAPABILITY_PRIVACY)
615 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
616 else
617 iwe.u.data.flags = IW_ENCODE_DISABLED;
618 iwe.u.data.length = 0;
619 ev = iwe_stream_add_point(ev, stop, &iwe, scan->essid);
620
621 /* MODE */
622 iwe.cmd = SIOCGIWMODE;
623 if (be16_to_cpu(scan->capability) &
624 (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) {
625 if (be16_to_cpu(scan->capability) & WLAN_CAPABILITY_ESS)
626 iwe.u.mode = IW_MODE_MASTER;
627 else
628 iwe.u.mode = IW_MODE_ADHOC;
629 ev = iwe_stream_add_event(ev, stop, &iwe, IW_EV_UINT_LEN);
630 }
631
632 /* QUAL */
633 iwe.cmd = IWEVQUAL;
634 iwe.u.qual.updated = IW_QUAL_ALL_UPDATED |
635 IW_QUAL_QUAL_INVALID | IW_QUAL_NOISE_INVALID;
636 iwe.u.qual.level = be16_to_cpu(scan->rssi);
637 iwe.u.qual.qual = be16_to_cpu(scan->rssi);
638 iwe.u.qual.noise = 0;
639 ev = iwe_stream_add_event(ev, stop, &iwe, IW_EV_QUAL_LEN);
640
641 /* RSN */
642 memset(&iwe, 0, sizeof(iwe));
643 if (be16_to_cpu(scan->size) <= sizeof(*scan)) {
644 /* If wpa[2] capable station, synthesize IE and put it */
645 len = gelic_wl_synthesize_ie(buf, scan);
646 if (len) {
647 iwe.cmd = IWEVGENIE;
648 iwe.u.data.length = len;
649 ev = iwe_stream_add_point(ev, stop, &iwe, buf);
650 }
651 } else {
652 /* this scan info has IE data */
653 struct ie_info ie_info;
654 size_t data_len;
655
656 data_len = be16_to_cpu(scan->size) - sizeof(*scan);
657
658 gelic_wl_parse_ie(scan->elements, data_len, &ie_info);
659
660 if (ie_info.wpa.len && (ie_info.wpa.len <= sizeof(buf))) {
661 memcpy(buf, ie_info.wpa.data, ie_info.wpa.len);
662 iwe.cmd = IWEVGENIE;
663 iwe.u.data.length = ie_info.wpa.len;
664 ev = iwe_stream_add_point(ev, stop, &iwe, buf);
665 }
666
667 if (ie_info.rsn.len && (ie_info.rsn.len <= sizeof(buf))) {
668 memset(&iwe, 0, sizeof(iwe));
669 memcpy(buf, ie_info.rsn.data, ie_info.rsn.len);
670 iwe.cmd = IWEVGENIE;
671 iwe.u.data.length = ie_info.rsn.len;
672 ev = iwe_stream_add_point(ev, stop, &iwe, buf);
673 }
674 }
675
676 pr_debug("%s: ->\n", __func__);
677 return ev;
678}
679
680
681static int gelic_wl_get_scan(struct net_device *netdev,
682 struct iw_request_info *info,
683 union iwreq_data *wrqu, char *extra)
684{
685 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
686 struct gelic_wl_scan_info *scan_info;
687 char *ev = extra;
688 char *stop = ev + wrqu->data.length;
689 int ret = 0;
690 unsigned long this_time = jiffies;
691
692 pr_debug("%s: <-\n", __func__);
693 if (down_interruptible(&wl->scan_lock))
694 return -EAGAIN;
695
696 switch (wl->scan_stat) {
697 case GELIC_WL_SCAN_STAT_SCANNING:
698 /* If a scan in progress, caller should call me again */
699 ret = -EAGAIN;
700 goto out;
701 break;
702
703 case GELIC_WL_SCAN_STAT_INIT:
704 /* last scan request failed or never issued */
705 ret = -ENODEV;
706 goto out;
707 break;
708 case GELIC_WL_SCAN_STAT_GOT_LIST:
709 /* ok, use current list */
710 break;
711 }
712
713 list_for_each_entry(scan_info, &wl->network_list, list) {
714 if (wl->scan_age == 0 ||
715 time_after(scan_info->last_scanned + wl->scan_age,
716 this_time))
717 ev = gelic_wl_translate_scan(netdev, ev, stop,
718 scan_info);
719 else
720 pr_debug("%s:entry too old\n", __func__);
721
722 if (stop - ev <= IW_EV_ADDR_LEN) {
723 ret = -E2BIG;
724 goto out;
725 }
726 }
727
728 wrqu->data.length = ev - extra;
729 wrqu->data.flags = 0;
730out:
731 up(&wl->scan_lock);
732 pr_debug("%s: -> %d %d\n", __func__, ret, wrqu->data.length);
733 return ret;
734}
735
736#ifdef DEBUG
737static void scan_list_dump(struct gelic_wl_info *wl)
738{
739 struct gelic_wl_scan_info *scan_info;
740 int i;
741 DECLARE_MAC_BUF(mac);
742
743 i = 0;
744 list_for_each_entry(scan_info, &wl->network_list, list) {
745 pr_debug("%s: item %d\n", __func__, i++);
746 pr_debug("valid=%d eurusindex=%d last=%lx\n",
747 scan_info->valid, scan_info->eurus_index,
748 scan_info->last_scanned);
749 pr_debug("r_len=%d r_ext_len=%d essid_len=%d\n",
750 scan_info->rate_len, scan_info->rate_ext_len,
751 scan_info->essid_len);
752 /* -- */
753 pr_debug("bssid=%s\n",
754 print_mac(mac, &scan_info->hwinfo->bssid[2]));
755 pr_debug("essid=%s\n", scan_info->hwinfo->essid);
756 }
757}
758#endif
759
760static int gelic_wl_set_auth(struct net_device *netdev,
761 struct iw_request_info *info,
762 union iwreq_data *data, char *extra)
763{
764 struct iw_param *param = &data->param;
765 struct gelic_wl_info *wl = port_wl(netdev_port(netdev));
766 unsigned long irqflag;
767 int ret = 0;
768
769 pr_debug("%s: <- %d\n", __func__, param->flags & IW_AUTH_INDEX);
770 spin_lock_irqsave(&wl->lock, irqflag);
771 switch (param->flags & IW_AUTH_INDEX) {
772 case IW_AUTH_WPA_VERSION:
773 if (param->value & IW_AUTH_WPA_VERSION_DISABLED) {
774 pr_debug("%s: NO WPA selected\n", __func__);
775 wl->wpa_level = GELIC_WL_WPA_LEVEL_NONE;
776 wl->group_cipher_method = GELIC_WL_CIPHER_WEP;
777 wl->pairwise_cipher_method = GELIC_WL_CIPHER_WEP;
778 }
779 if (param->value & IW_AUTH_WPA_VERSION_WPA) {
780 pr_debug("%s: WPA version 1 selected\n", __func__);
781 wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA;
782 wl->group_cipher_method = GELIC_WL_CIPHER_TKIP;
783 wl->pairwise_cipher_method = GELIC_WL_CIPHER_TKIP;
784 wl->auth_method = GELIC_EURUS_AUTH_OPEN;
785 }
786 if (param->value & IW_AUTH_WPA_VERSION_WPA2) {
787 /*
788 * As the hypervisor may not tell the cipher
789 * information of the AP if it is WPA2,
790 * you will not decide suitable cipher from
791 * its beacon.
792 * You should have knowledge about the AP's
793 * cipher infomation in other method prior to
794 * the association.
795 */
796 if (!precise_ie())
797 pr_info("%s: WPA2 may not work\n", __func__);
798 if (wpa2_capable()) {
799 wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA2;
800 wl->group_cipher_method = GELIC_WL_CIPHER_AES;
801 wl->pairwise_cipher_method =
802 GELIC_WL_CIPHER_AES;
803 wl->auth_method = GELIC_EURUS_AUTH_OPEN;
804 } else
805 ret = -EINVAL;
806 }
807 break;
808
809 case IW_AUTH_CIPHER_PAIRWISE:
810 if (param->value &
811 (IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_WEP40)) {
812 pr_debug("%s: WEP selected\n", __func__);
813 wl->pairwise_cipher_method = GELIC_WL_CIPHER_WEP;
814 }
815 if (param->value & IW_AUTH_CIPHER_TKIP) {
816 pr_debug("%s: TKIP selected\n", __func__);
817 wl->pairwise_cipher_method = GELIC_WL_CIPHER_TKIP;
818 }
819 if (param->value & IW_AUTH_CIPHER_CCMP) {
820 pr_debug("%s: CCMP selected\n", __func__);
821 wl->pairwise_cipher_method = GELIC_WL_CIPHER_AES;
822 }
823 if (param->value & IW_AUTH_CIPHER_NONE) {
824 pr_debug("%s: no auth selected\n", __func__);
825 wl->pairwise_cipher_method = GELIC_WL_CIPHER_NONE;
826 }
827 break;
828 case IW_AUTH_CIPHER_GROUP:
829 if (param->value &
830 (IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_WEP40)) {
831 pr_debug("%s: WEP selected\n", __func__);
832 wl->group_cipher_method = GELIC_WL_CIPHER_WEP;
833 }
834 if (param->value & IW_AUTH_CIPHER_TKIP) {
835 pr_debug("%s: TKIP selected\n", __func__);
836 wl->group_cipher_method = GELIC_WL_CIPHER_TKIP;
837 }
838 if (param->value & IW_AUTH_CIPHER_CCMP) {
839 pr_debug("%s: CCMP selected\n", __func__);
840 wl->group_cipher_method = GELIC_WL_CIPHER_AES;
841 }
842 if (param->value & IW_AUTH_CIPHER_NONE) {
843 pr_debug("%s: no auth selected\n", __func__);
844 wl->group_cipher_method = GELIC_WL_CIPHER_NONE;
845 }
846 break;
847 case IW_AUTH_80211_AUTH_ALG:
848 if (param->value & IW_AUTH_ALG_SHARED_KEY) {
849 pr_debug("%s: shared key specified\n", __func__);
850 wl->auth_method = GELIC_EURUS_AUTH_SHARED;
851 } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
852 pr_debug("%s: open system specified\n", __func__);
853 wl->auth_method = GELIC_EURUS_AUTH_OPEN;
854 } else
855 ret = -EINVAL;
856 break;
857
858 case IW_AUTH_WPA_ENABLED:
859 if (param->value) {
860 pr_debug("%s: WPA enabled\n", __func__);
861 wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA;
862 } else {
863 pr_debug("%s: WPA disabled\n", __func__);
864 wl->wpa_level = GELIC_WL_WPA_LEVEL_NONE;
865 }
866 break;
867
868 case IW_AUTH_KEY_MGMT:
869 if (param->value & IW_AUTH_KEY_MGMT_PSK)
870 break;
871 /* intentionally fall through */
872 default:
873 ret = -EOPNOTSUPP;
874 break;
875 };
876
877 if (!ret)
878 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
879
880 spin_unlock_irqrestore(&wl->lock, irqflag);
881 pr_debug("%s: -> %d\n", __func__, ret);
882 return ret;
883}
884
885static int gelic_wl_get_auth(struct net_device *netdev,
886 struct iw_request_info *info,
887 union iwreq_data *iwreq, char *extra)
888{
889 struct iw_param *param = &iwreq->param;
890 struct gelic_wl_info *wl = port_wl(netdev_port(netdev));
891 unsigned long irqflag;
892 int ret = 0;
893
894 pr_debug("%s: <- %d\n", __func__, param->flags & IW_AUTH_INDEX);
895 spin_lock_irqsave(&wl->lock, irqflag);
896 switch (param->flags & IW_AUTH_INDEX) {
897 case IW_AUTH_WPA_VERSION:
898 switch (wl->wpa_level) {
899 case GELIC_WL_WPA_LEVEL_WPA:
900 param->value |= IW_AUTH_WPA_VERSION_WPA;
901 break;
902 case GELIC_WL_WPA_LEVEL_WPA2:
903 param->value |= IW_AUTH_WPA_VERSION_WPA2;
904 break;
905 default:
906 param->value |= IW_AUTH_WPA_VERSION_DISABLED;
907 }
908 break;
909
910 case IW_AUTH_80211_AUTH_ALG:
911 if (wl->auth_method == GELIC_EURUS_AUTH_SHARED)
912 param->value = IW_AUTH_ALG_SHARED_KEY;
913 else if (wl->auth_method == GELIC_EURUS_AUTH_OPEN)
914 param->value = IW_AUTH_ALG_OPEN_SYSTEM;
915 break;
916
917 case IW_AUTH_WPA_ENABLED:
918 switch (wl->wpa_level) {
919 case GELIC_WL_WPA_LEVEL_WPA:
920 case GELIC_WL_WPA_LEVEL_WPA2:
921 param->value = 1;
922 break;
923 default:
924 param->value = 0;
925 break;
926 }
927 break;
928 default:
929 ret = -EOPNOTSUPP;
930 }
931
932 spin_unlock_irqrestore(&wl->lock, irqflag);
933 pr_debug("%s: -> %d\n", __func__, ret);
934 return ret;
935}
936
937/* SIOC{S,G}IWESSID */
938static int gelic_wl_set_essid(struct net_device *netdev,
939 struct iw_request_info *info,
940 union iwreq_data *data, char *extra)
941{
942 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
943 unsigned long irqflag;
944
945 pr_debug("%s: <- l=%d f=%d\n", __func__,
946 data->essid.length, data->essid.flags);
947 if (IW_ESSID_MAX_SIZE < data->essid.length)
948 return -EINVAL;
949
950 spin_lock_irqsave(&wl->lock, irqflag);
951 if (data->essid.flags) {
952 wl->essid_len = data->essid.length;
953 memcpy(wl->essid, extra, wl->essid_len);
954 pr_debug("%s: essid = '%s'\n", __func__, extra);
955 set_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat);
956 } else {
957 pr_debug("%s: ESSID any \n", __func__);
958 clear_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat);
959 }
960 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
961 spin_unlock_irqrestore(&wl->lock, irqflag);
962
963
964 gelic_wl_try_associate(netdev); /* FIXME */
965 pr_debug("%s: -> \n", __func__);
966 return 0;
967}
968
969static int gelic_wl_get_essid(struct net_device *netdev,
970 struct iw_request_info *info,
971 union iwreq_data *data, char *extra)
972{
973 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
974 unsigned long irqflag;
975
976 pr_debug("%s: <- \n", __func__);
977 down(&wl->assoc_stat_lock);
978 spin_lock_irqsave(&wl->lock, irqflag);
979 if (test_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat) ||
980 wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED) {
981 memcpy(extra, wl->essid, wl->essid_len);
982 data->essid.length = wl->essid_len;
983 data->essid.flags = 1;
984 } else
985 data->essid.flags = 0;
986
987 up(&wl->assoc_stat_lock);
988 spin_unlock_irqrestore(&wl->lock, irqflag);
989 pr_debug("%s: -> len=%d \n", __func__, data->essid.length);
990
991 return 0;
992}
993
994/* SIO{S,G}IWENCODE */
995static int gelic_wl_set_encode(struct net_device *netdev,
996 struct iw_request_info *info,
997 union iwreq_data *data, char *extra)
998{
999 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
1000 struct iw_point *enc = &data->encoding;
1001 __u16 flags;
1002 unsigned int irqflag;
1003 int key_index, index_specified;
1004 int ret = 0;
1005
1006 pr_debug("%s: <- \n", __func__);
1007 flags = enc->flags & IW_ENCODE_FLAGS;
1008 key_index = enc->flags & IW_ENCODE_INDEX;
1009
1010 pr_debug("%s: key_index = %d\n", __func__, key_index);
1011 pr_debug("%s: key_len = %d\n", __func__, enc->length);
1012 pr_debug("%s: flag=%x\n", __func__, enc->flags & IW_ENCODE_FLAGS);
1013
1014 if (GELIC_WEP_KEYS < key_index)
1015 return -EINVAL;
1016
1017 spin_lock_irqsave(&wl->lock, irqflag);
1018 if (key_index) {
1019 index_specified = 1;
1020 key_index--;
1021 } else {
1022 index_specified = 0;
1023 key_index = wl->current_key;
1024 }
1025
1026 if (flags & IW_ENCODE_NOKEY) {
1027 /* if just IW_ENCODE_NOKEY, change current key index */
1028 if (!flags && index_specified) {
1029 wl->current_key = key_index;
1030 goto done;
1031 }
1032
1033 if (flags & IW_ENCODE_DISABLED) {
1034 if (!index_specified) {
1035 /* disable encryption */
1036 wl->group_cipher_method = GELIC_WL_CIPHER_NONE;
1037 wl->pairwise_cipher_method =
1038 GELIC_WL_CIPHER_NONE;
1039 /* invalidate all key */
1040 wl->key_enabled = 0;
1041 } else
1042 clear_bit(key_index, &wl->key_enabled);
1043 }
1044
1045 if (flags & IW_ENCODE_OPEN)
1046 wl->auth_method = GELIC_EURUS_AUTH_OPEN;
1047 if (flags & IW_ENCODE_RESTRICTED) {
1048 pr_info("%s: shared key mode enabled\n", __func__);
1049 wl->auth_method = GELIC_EURUS_AUTH_SHARED;
1050 }
1051 } else {
1052 if (IW_ENCODING_TOKEN_MAX < enc->length) {
1053 ret = -EINVAL;
1054 goto done;
1055 }
1056 wl->key_len[key_index] = enc->length;
1057 memcpy(wl->key[key_index], extra, enc->length);
1058 set_bit(key_index, &wl->key_enabled);
1059 wl->pairwise_cipher_method = GELIC_WL_CIPHER_WEP;
1060 wl->group_cipher_method = GELIC_WL_CIPHER_WEP;
1061 }
1062 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
1063done:
1064 spin_unlock_irqrestore(&wl->lock, irqflag);
1065 pr_debug("%s: -> \n", __func__);
1066 return ret;
1067}
1068
1069static int gelic_wl_get_encode(struct net_device *netdev,
1070 struct iw_request_info *info,
1071 union iwreq_data *data, char *extra)
1072{
1073 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
1074 struct iw_point *enc = &data->encoding;
1075 unsigned int irqflag;
1076 unsigned int key_index, index_specified;
1077 int ret = 0;
1078
1079 pr_debug("%s: <- \n", __func__);
1080 key_index = enc->flags & IW_ENCODE_INDEX;
1081 pr_debug("%s: flag=%#x point=%p len=%d extra=%p\n", __func__,
1082 enc->flags, enc->pointer, enc->length, extra);
1083 if (GELIC_WEP_KEYS < key_index)
1084 return -EINVAL;
1085
1086 spin_lock_irqsave(&wl->lock, irqflag);
1087 if (key_index) {
1088 index_specified = 1;
1089 key_index--;
1090 } else {
1091 index_specified = 0;
1092 key_index = wl->current_key;
1093 }
1094
1095 if (wl->group_cipher_method == GELIC_WL_CIPHER_WEP) {
1096 switch (wl->auth_method) {
1097 case GELIC_EURUS_AUTH_OPEN:
1098 enc->flags = IW_ENCODE_OPEN;
1099 break;
1100 case GELIC_EURUS_AUTH_SHARED:
1101 enc->flags = IW_ENCODE_RESTRICTED;
1102 break;
1103 }
1104 } else
1105 enc->flags = IW_ENCODE_DISABLED;
1106
1107 if (test_bit(key_index, &wl->key_enabled)) {
1108 if (enc->length < wl->key_len[key_index]) {
1109 ret = -EINVAL;
1110 goto done;
1111 }
1112 enc->length = wl->key_len[key_index];
1113 memcpy(extra, wl->key[key_index], wl->key_len[key_index]);
1114 } else {
1115 enc->length = 0;
1116 enc->flags |= IW_ENCODE_NOKEY;
1117 }
1118 enc->flags |= key_index + 1;
1119 pr_debug("%s: -> flag=%x len=%d\n", __func__,
1120 enc->flags, enc->length);
1121
1122done:
1123 spin_unlock_irqrestore(&wl->lock, irqflag);
1124 return ret;
1125}
1126
1127/* SIOC{S,G}IWAP */
1128static int gelic_wl_set_ap(struct net_device *netdev,
1129 struct iw_request_info *info,
1130 union iwreq_data *data, char *extra)
1131{
1132 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
1133 unsigned long irqflag;
1134
1135 pr_debug("%s: <-\n", __func__);
1136 if (data->ap_addr.sa_family != ARPHRD_ETHER)
1137 return -EINVAL;
1138
1139 spin_lock_irqsave(&wl->lock, irqflag);
1140 if (is_valid_ether_addr(data->ap_addr.sa_data)) {
1141 memcpy(wl->bssid, data->ap_addr.sa_data,
1142 ETH_ALEN);
1143 set_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat);
1144 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
1145 pr_debug("%s: bss=%02x:%02x:%02x:%02x:%02x:%02x\n",
1146 __func__,
1147 wl->bssid[0], wl->bssid[1],
1148 wl->bssid[2], wl->bssid[3],
1149 wl->bssid[4], wl->bssid[5]);
1150 } else {
1151 pr_debug("%s: clear bssid\n", __func__);
1152 clear_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat);
1153 memset(wl->bssid, 0, ETH_ALEN);
1154 }
1155 spin_unlock_irqrestore(&wl->lock, irqflag);
1156 pr_debug("%s: ->\n", __func__);
1157 return 0;
1158}
1159
1160static int gelic_wl_get_ap(struct net_device *netdev,
1161 struct iw_request_info *info,
1162 union iwreq_data *data, char *extra)
1163{
1164 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
1165 unsigned long irqflag;
1166
1167 pr_debug("%s: <-\n", __func__);
1168 down(&wl->assoc_stat_lock);
1169 spin_lock_irqsave(&wl->lock, irqflag);
1170 if (wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED) {
1171 data->ap_addr.sa_family = ARPHRD_ETHER;
1172 memcpy(data->ap_addr.sa_data, wl->active_bssid,
1173 ETH_ALEN);
1174 } else
1175 memset(data->ap_addr.sa_data, 0, ETH_ALEN);
1176
1177 spin_unlock_irqrestore(&wl->lock, irqflag);
1178 up(&wl->assoc_stat_lock);
1179 pr_debug("%s: ->\n", __func__);
1180 return 0;
1181}
1182
1183/* SIOC{S,G}IWENCODEEXT */
1184static int gelic_wl_set_encodeext(struct net_device *netdev,
1185 struct iw_request_info *info,
1186 union iwreq_data *data, char *extra)
1187{
1188 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
1189 struct iw_point *enc = &data->encoding;
1190 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1191 __u16 alg;
1192 __u16 flags;
1193 unsigned int irqflag;
1194 int key_index;
1195 int ret = 0;
1196
1197 pr_debug("%s: <- \n", __func__);
1198 flags = enc->flags & IW_ENCODE_FLAGS;
1199 alg = ext->alg;
1200 key_index = enc->flags & IW_ENCODE_INDEX;
1201
1202 pr_debug("%s: key_index = %d\n", __func__, key_index);
1203 pr_debug("%s: key_len = %d\n", __func__, enc->length);
1204 pr_debug("%s: flag=%x\n", __func__, enc->flags & IW_ENCODE_FLAGS);
1205 pr_debug("%s: ext_flag=%x\n", __func__, ext->ext_flags);
1206 pr_debug("%s: ext_key_len=%x\n", __func__, ext->key_len);
1207
1208 if (GELIC_WEP_KEYS < key_index)
1209 return -EINVAL;
1210
1211 spin_lock_irqsave(&wl->lock, irqflag);
1212 if (key_index)
1213 key_index--;
1214 else
1215 key_index = wl->current_key;
1216
1217 if (!enc->length && (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) {
1218 /* reques to change default key index */
1219 pr_debug("%s: request to change default key to %d\n",
1220 __func__, key_index);
1221 wl->current_key = key_index;
1222 goto done;
1223 }
1224
1225 if (alg == IW_ENCODE_ALG_NONE || (flags & IW_ENCODE_DISABLED)) {
1226 pr_debug("%s: alg disabled\n", __func__);
1227 wl->wpa_level = GELIC_WL_WPA_LEVEL_NONE;
1228 wl->group_cipher_method = GELIC_WL_CIPHER_NONE;
1229 wl->pairwise_cipher_method = GELIC_WL_CIPHER_NONE;
1230 wl->auth_method = GELIC_EURUS_AUTH_OPEN; /* should be open */
1231 } else if (alg == IW_ENCODE_ALG_WEP) {
1232 pr_debug("%s: WEP requested\n", __func__);
1233 if (flags & IW_ENCODE_OPEN) {
1234 pr_debug("%s: open key mode\n", __func__);
1235 wl->auth_method = GELIC_EURUS_AUTH_OPEN;
1236 }
1237 if (flags & IW_ENCODE_RESTRICTED) {
1238 pr_debug("%s: shared key mode\n", __func__);
1239 wl->auth_method = GELIC_EURUS_AUTH_SHARED;
1240 }
1241 if (IW_ENCODING_TOKEN_MAX < ext->key_len) {
1242 pr_info("%s: key is too long %d\n", __func__,
1243 ext->key_len);
1244 ret = -EINVAL;
1245 goto done;
1246 }
1247 /* OK, update the key */
1248 wl->key_len[key_index] = ext->key_len;
1249 memset(wl->key[key_index], 0, IW_ENCODING_TOKEN_MAX);
1250 memcpy(wl->key[key_index], ext->key, ext->key_len);
1251 set_bit(key_index, &wl->key_enabled);
1252 /* remember wep info changed */
1253 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
1254 } else if ((alg == IW_ENCODE_ALG_TKIP) || (alg == IW_ENCODE_ALG_CCMP)) {
1255 pr_debug("%s: TKIP/CCMP requested alg=%d\n", __func__, alg);
1256 /* check key length */
1257 if (IW_ENCODING_TOKEN_MAX < ext->key_len) {
1258 pr_info("%s: key is too long %d\n", __func__,
1259 ext->key_len);
1260 ret = -EINVAL;
1261 goto done;
1262 }
1263 if (alg == IW_ENCODE_ALG_CCMP) {
1264 pr_debug("%s: AES selected\n", __func__);
1265 wl->group_cipher_method = GELIC_WL_CIPHER_AES;
1266 wl->pairwise_cipher_method = GELIC_WL_CIPHER_AES;
1267 wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA2;
1268 } else {
1269 pr_debug("%s: TKIP selected, WPA forced\n", __func__);
1270 wl->group_cipher_method = GELIC_WL_CIPHER_TKIP;
1271 wl->pairwise_cipher_method = GELIC_WL_CIPHER_TKIP;
1272 /* FIXME: how do we do if WPA2 + TKIP? */
1273 wl->wpa_level = GELIC_WL_WPA_LEVEL_WPA;
1274 }
1275 if (flags & IW_ENCODE_RESTRICTED)
1276 BUG();
1277 wl->auth_method = GELIC_EURUS_AUTH_OPEN;
1278 /* We should use same key for both and unicast */
1279 if (ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)
1280 pr_debug("%s: group key \n", __func__);
1281 else
1282 pr_debug("%s: unicast key \n", __func__);
1283 /* OK, update the key */
1284 wl->key_len[key_index] = ext->key_len;
1285 memset(wl->key[key_index], 0, IW_ENCODING_TOKEN_MAX);
1286 memcpy(wl->key[key_index], ext->key, ext->key_len);
1287 set_bit(key_index, &wl->key_enabled);
1288 /* remember info changed */
1289 set_bit(GELIC_WL_STAT_CONFIGURED, &wl->stat);
1290 }
1291done:
1292 spin_unlock_irqrestore(&wl->lock, irqflag);
1293 pr_debug("%s: -> \n", __func__);
1294 return ret;
1295}
1296
1297static int gelic_wl_get_encodeext(struct net_device *netdev,
1298 struct iw_request_info *info,
1299 union iwreq_data *data, char *extra)
1300{
1301 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
1302 struct iw_point *enc = &data->encoding;
1303 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1304 unsigned int irqflag;
1305 int key_index;
1306 int ret = 0;
1307 int max_key_len;
1308
1309 pr_debug("%s: <- \n", __func__);
1310
1311 max_key_len = enc->length - sizeof(struct iw_encode_ext);
1312 if (max_key_len < 0)
1313 return -EINVAL;
1314 key_index = enc->flags & IW_ENCODE_INDEX;
1315
1316 pr_debug("%s: key_index = %d\n", __func__, key_index);
1317 pr_debug("%s: key_len = %d\n", __func__, enc->length);
1318 pr_debug("%s: flag=%x\n", __func__, enc->flags & IW_ENCODE_FLAGS);
1319
1320 if (GELIC_WEP_KEYS < key_index)
1321 return -EINVAL;
1322
1323 spin_lock_irqsave(&wl->lock, irqflag);
1324 if (key_index)
1325 key_index--;
1326 else
1327 key_index = wl->current_key;
1328
1329 memset(ext, 0, sizeof(struct iw_encode_ext));
1330 switch (wl->group_cipher_method) {
1331 case GELIC_WL_CIPHER_WEP:
1332 ext->alg = IW_ENCODE_ALG_WEP;
1333 enc->flags |= IW_ENCODE_ENABLED;
1334 break;
1335 case GELIC_WL_CIPHER_TKIP:
1336 ext->alg = IW_ENCODE_ALG_TKIP;
1337 enc->flags |= IW_ENCODE_ENABLED;
1338 break;
1339 case GELIC_WL_CIPHER_AES:
1340 ext->alg = IW_ENCODE_ALG_CCMP;
1341 enc->flags |= IW_ENCODE_ENABLED;
1342 break;
1343 case GELIC_WL_CIPHER_NONE:
1344 default:
1345 ext->alg = IW_ENCODE_ALG_NONE;
1346 enc->flags |= IW_ENCODE_NOKEY;
1347 break;
1348 }
1349
1350 if (!(enc->flags & IW_ENCODE_NOKEY)) {
1351 if (max_key_len < wl->key_len[key_index]) {
1352 ret = -E2BIG;
1353 goto out;
1354 }
1355 if (test_bit(key_index, &wl->key_enabled))
1356 memcpy(ext->key, wl->key[key_index],
1357 wl->key_len[key_index]);
1358 else
1359 pr_debug("%s: disabled key requested ix=%d\n",
1360 __func__, key_index);
1361 }
1362out:
1363 spin_unlock_irqrestore(&wl->lock, irqflag);
1364 pr_debug("%s: -> \n", __func__);
1365 return ret;
1366}
1367/* SIOC{S,G}IWMODE */
1368static int gelic_wl_set_mode(struct net_device *netdev,
1369 struct iw_request_info *info,
1370 union iwreq_data *data, char *extra)
1371{
1372 __u32 mode = data->mode;
1373 int ret;
1374
1375 pr_debug("%s: <- \n", __func__);
1376 if (mode == IW_MODE_INFRA)
1377 ret = 0;
1378 else
1379 ret = -EOPNOTSUPP;
1380 pr_debug("%s: -> %d\n", __func__, ret);
1381 return ret;
1382}
1383
1384static int gelic_wl_get_mode(struct net_device *netdev,
1385 struct iw_request_info *info,
1386 union iwreq_data *data, char *extra)
1387{
1388 __u32 *mode = &data->mode;
1389 pr_debug("%s: <- \n", __func__);
1390 *mode = IW_MODE_INFRA;
1391 pr_debug("%s: ->\n", __func__);
1392 return 0;
1393}
1394
1395/* SIOCIWFIRSTPRIV */
1396static int hex2bin(u8 *str, u8 *bin, unsigned int len)
1397{
1398 unsigned int i;
1399 static unsigned char *hex = "0123456789ABCDEF";
1400 unsigned char *p, *q;
1401 u8 tmp;
1402
1403 if (len != WPA_PSK_LEN * 2)
1404 return -EINVAL;
1405
1406 for (i = 0; i < WPA_PSK_LEN * 2; i += 2) {
1407 p = strchr(hex, toupper(str[i]));
1408 q = strchr(hex, toupper(str[i + 1]));
1409 if (!p || !q) {
1410 pr_info("%s: unconvertible PSK digit=%d\n",
1411 __func__, i);
1412 return -EINVAL;
1413 }
1414 tmp = ((p - hex) << 4) + (q - hex);
1415 *bin++ = tmp;
1416 }
1417 return 0;
1418};
1419
1420static int gelic_wl_priv_set_psk(struct net_device *net_dev,
1421 struct iw_request_info *info,
1422 union iwreq_data *data, char *extra)
1423{
1424 struct gelic_wl_info *wl = port_wl(netdev_priv(net_dev));
1425 unsigned int len;
1426 unsigned int irqflag;
1427 int ret = 0;
1428
1429 pr_debug("%s:<- len=%d\n", __func__, data->data.length);
1430 len = data->data.length - 1;
1431 if (len <= 2)
1432 return -EINVAL;
1433
1434 spin_lock_irqsave(&wl->lock, irqflag);
1435 if (extra[0] == '"' && extra[len - 1] == '"') {
1436 pr_debug("%s: passphrase mode\n", __func__);
1437 /* pass phrase */
1438 if (GELIC_WL_EURUS_PSK_MAX_LEN < (len - 2)) {
1439 pr_info("%s: passphrase too long\n", __func__);
1440 ret = -E2BIG;
1441 goto out;
1442 }
1443 memset(wl->psk, 0, sizeof(wl->psk));
1444 wl->psk_len = len - 2;
1445 memcpy(wl->psk, &(extra[1]), wl->psk_len);
1446 wl->psk_type = GELIC_EURUS_WPA_PSK_PASSPHRASE;
1447 } else {
1448 ret = hex2bin(extra, wl->psk, len);
1449 if (ret)
1450 goto out;
1451 wl->psk_len = WPA_PSK_LEN;
1452 wl->psk_type = GELIC_EURUS_WPA_PSK_BIN;
1453 }
1454 set_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat);
1455out:
1456 spin_unlock_irqrestore(&wl->lock, irqflag);
1457 pr_debug("%s:->\n", __func__);
1458 return ret;
1459}
1460
1461static int gelic_wl_priv_get_psk(struct net_device *net_dev,
1462 struct iw_request_info *info,
1463 union iwreq_data *data, char *extra)
1464{
1465 struct gelic_wl_info *wl = port_wl(netdev_priv(net_dev));
1466 char *p;
1467 unsigned int irqflag;
1468 unsigned int i;
1469
1470 pr_debug("%s:<-\n", __func__);
1471 if (!capable(CAP_NET_ADMIN))
1472 return -EPERM;
1473
1474 spin_lock_irqsave(&wl->lock, irqflag);
1475 p = extra;
1476 if (test_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat)) {
1477 if (wl->psk_type == GELIC_EURUS_WPA_PSK_BIN) {
1478 for (i = 0; i < wl->psk_len; i++) {
1479 sprintf(p, "%02xu", wl->psk[i]);
1480 p += 2;
1481 }
1482 *p = '\0';
1483 data->data.length = wl->psk_len * 2;
1484 } else {
1485 *p++ = '"';
1486 memcpy(p, wl->psk, wl->psk_len);
1487 p += wl->psk_len;
1488 *p++ = '"';
1489 *p = '\0';
1490 data->data.length = wl->psk_len + 2;
1491 }
1492 } else
1493 /* no psk set */
1494 data->data.length = 0;
1495 spin_unlock_irqrestore(&wl->lock, irqflag);
1496 pr_debug("%s:-> %d\n", __func__, data->data.length);
1497 return 0;
1498}
1499
1500/* SIOCGIWNICKN */
1501static int gelic_wl_get_nick(struct net_device *net_dev,
1502 struct iw_request_info *info,
1503 union iwreq_data *data, char *extra)
1504{
1505 strcpy(extra, "gelic_wl");
1506 data->data.length = strlen(extra);
1507 data->data.flags = 1;
1508 return 0;
1509}
1510
1511
1512/* --- */
1513
1514static struct iw_statistics *gelic_wl_get_wireless_stats(
1515 struct net_device *netdev)
1516{
1517
1518 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
1519 struct gelic_eurus_cmd *cmd;
1520 struct iw_statistics *is;
1521 struct gelic_eurus_rssi_info *rssi;
1522
1523 pr_debug("%s: <-\n", __func__);
1524
1525 is = &wl->iwstat;
1526 memset(is, 0, sizeof(*is));
1527 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_GET_RSSI_CFG,
1528 wl->buf, sizeof(*rssi));
1529 if (cmd && !cmd->status && !cmd->cmd_status) {
1530 rssi = wl->buf;
1531 is->qual.level = be16_to_cpu(rssi->rssi);
1532 is->qual.updated = IW_QUAL_LEVEL_UPDATED |
1533 IW_QUAL_QUAL_INVALID | IW_QUAL_NOISE_INVALID;
1534 } else
1535 /* not associated */
1536 is->qual.updated = IW_QUAL_ALL_INVALID;
1537
1538 kfree(cmd);
1539 pr_debug("%s: ->\n", __func__);
1540 return is;
1541}
1542
1543/*
1544 * scanning helpers
1545 */
1546static int gelic_wl_start_scan(struct gelic_wl_info *wl, int always_scan)
1547{
1548 struct gelic_eurus_cmd *cmd;
1549 int ret = 0;
1550
1551 pr_debug("%s: <- always=%d\n", __func__, always_scan);
1552 if (down_interruptible(&wl->scan_lock))
1553 return -ERESTARTSYS;
1554
1555 /*
1556 * If already a scan in progress, do not trigger more
1557 */
1558 if (wl->scan_stat == GELIC_WL_SCAN_STAT_SCANNING) {
1559 pr_debug("%s: scanning now\n", __func__);
1560 goto out;
1561 }
1562
1563 init_completion(&wl->scan_done);
1564 /*
1565 * If we have already a bss list, don't try to get new
1566 */
1567 if (!always_scan && wl->scan_stat == GELIC_WL_SCAN_STAT_GOT_LIST) {
1568 pr_debug("%s: already has the list\n", __func__);
1569 complete(&wl->scan_done);
1570 goto out;
1571 }
1572 /*
1573 * issue start scan request
1574 */
1575 wl->scan_stat = GELIC_WL_SCAN_STAT_SCANNING;
1576 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_START_SCAN,
1577 NULL, 0);
1578 if (!cmd || cmd->status || cmd->cmd_status) {
1579 wl->scan_stat = GELIC_WL_SCAN_STAT_INIT;
1580 complete(&wl->scan_done);
1581 ret = -ENOMEM;
1582 goto out;
1583 }
1584 kfree(cmd);
1585out:
1586 up(&wl->scan_lock);
1587 pr_debug("%s: ->\n", __func__);
1588 return ret;
1589}
1590
1591/*
1592 * retrieve scan result from the chip (hypervisor)
1593 * this function is invoked by schedule work.
1594 */
1595static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
1596{
1597 struct gelic_eurus_cmd *cmd = NULL;
1598 struct gelic_wl_scan_info *target, *tmp;
1599 struct gelic_wl_scan_info *oldest = NULL;
1600 struct gelic_eurus_scan_info *scan_info;
1601 unsigned int scan_info_size;
1602 union iwreq_data data;
1603 unsigned long this_time = jiffies;
1604 unsigned int data_len, i, found, r;
1605 DECLARE_MAC_BUF(mac);
1606
1607 pr_debug("%s:start\n", __func__);
1608 down(&wl->scan_lock);
1609
1610 if (wl->scan_stat != GELIC_WL_SCAN_STAT_SCANNING) {
1611 /*
1612 * stop() may be called while scanning, ignore result
1613 */
1614 pr_debug("%s: scan complete when stat != scanning(%d)\n",
1615 __func__, wl->scan_stat);
1616 goto out;
1617 }
1618
1619 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_GET_SCAN,
1620 wl->buf, PAGE_SIZE);
1621 if (!cmd || cmd->status || cmd->cmd_status) {
1622 wl->scan_stat = GELIC_WL_SCAN_STAT_INIT;
1623 pr_info("%s:cmd failed\n", __func__);
1624 kfree(cmd);
1625 goto out;
1626 }
1627 data_len = cmd->size;
1628 pr_debug("%s: data_len = %d\n", __func__, data_len);
1629 kfree(cmd);
1630
1631 /* OK, bss list retrieved */
1632 wl->scan_stat = GELIC_WL_SCAN_STAT_GOT_LIST;
1633
1634 /* mark all entries are old */
1635 list_for_each_entry_safe(target, tmp, &wl->network_list, list) {
1636 target->valid = 0;
1637 /* expire too old entries */
1638 if (time_before(target->last_scanned + wl->scan_age,
1639 this_time)) {
1640 kfree(target->hwinfo);
1641 target->hwinfo = NULL;
1642 list_move_tail(&target->list, &wl->network_free_list);
1643 }
1644 }
1645
1646 /* put them in the newtork_list */
1647 scan_info = wl->buf;
1648 scan_info_size = 0;
1649 i = 0;
1650 while (scan_info_size < data_len) {
1651 pr_debug("%s:size=%d bssid=%s scan_info=%p\n", __func__,
1652 be16_to_cpu(scan_info->size),
1653 print_mac(mac, &scan_info->bssid[2]), scan_info);
1654 found = 0;
1655 oldest = NULL;
1656 list_for_each_entry(target, &wl->network_list, list) {
1657 if (!compare_ether_addr(&target->hwinfo->bssid[2],
1658 &scan_info->bssid[2])) {
1659 found = 1;
1660 pr_debug("%s: same BBS found scanned list\n",
1661 __func__);
1662 break;
1663 }
1664 if (!oldest ||
1665 (target->last_scanned < oldest->last_scanned))
1666 oldest = target;
1667 }
1668
1669 if (!found) {
1670 /* not found in the list */
1671 if (list_empty(&wl->network_free_list)) {
1672 /* expire oldest */
1673 target = oldest;
1674 } else {
1675 target = list_entry(wl->network_free_list.next,
1676 struct gelic_wl_scan_info,
1677 list);
1678 }
1679 }
1680
1681 /* update the item */
1682 target->last_scanned = this_time;
1683 target->valid = 1;
1684 target->eurus_index = i;
1685 kfree(target->hwinfo);
1686 target->hwinfo = kzalloc(be16_to_cpu(scan_info->size),
1687 GFP_KERNEL);
1688 if (!target->hwinfo) {
1689 pr_info("%s: kzalloc failed\n", __func__);
1690 i++;
1691 scan_info_size += be16_to_cpu(scan_info->size);
1692 scan_info = (void *)scan_info +
1693 be16_to_cpu(scan_info->size);
1694 continue;
1695 }
1696 /* copy hw scan info */
1697 memcpy(target->hwinfo, scan_info, scan_info->size);
1698 target->essid_len = strnlen(scan_info->essid,
1699 sizeof(scan_info->essid));
1700 target->rate_len = 0;
1701 for (r = 0; r < MAX_RATES_LENGTH; r++)
1702 if (scan_info->rate[r])
1703 target->rate_len++;
1704 if (8 < target->rate_len)
1705 pr_info("%s: AP returns %d rates\n", __func__,
1706 target->rate_len);
1707 target->rate_ext_len = 0;
1708 for (r = 0; r < MAX_RATES_EX_LENGTH; r++)
1709 if (scan_info->ext_rate[r])
1710 target->rate_ext_len++;
1711 list_move_tail(&target->list, &wl->network_list);
1712 /* bump pointer */
1713 i++;
1714 scan_info_size += be16_to_cpu(scan_info->size);
1715 scan_info = (void *)scan_info + be16_to_cpu(scan_info->size);
1716 }
1717 memset(&data, 0, sizeof(data));
1718 wireless_send_event(port_to_netdev(wl_port(wl)), SIOCGIWSCAN, &data,
1719 NULL);
1720out:
1721 complete(&wl->scan_done);
1722 up(&wl->scan_lock);
1723 pr_debug("%s:end\n", __func__);
1724}
1725
1726/*
1727 * Select an appropriate bss from current scan list regarding
1728 * current settings from userspace.
1729 * The caller must hold wl->scan_lock,
1730 * and on the state of wl->scan_state == GELIC_WL_SCAN_GOT_LIST
1731 */
1732static void update_best(struct gelic_wl_scan_info **best,
1733 struct gelic_wl_scan_info *candid,
1734 int *best_weight,
1735 int *weight)
1736{
1737 if (*best_weight < ++(*weight)) {
1738 *best_weight = *weight;
1739 *best = candid;
1740 }
1741}
1742
1743static
1744struct gelic_wl_scan_info *gelic_wl_find_best_bss(struct gelic_wl_info *wl)
1745{
1746 struct gelic_wl_scan_info *scan_info;
1747 struct gelic_wl_scan_info *best_bss;
1748 int weight, best_weight;
1749 u16 security;
1750 DECLARE_MAC_BUF(mac);
1751
1752 pr_debug("%s: <-\n", __func__);
1753
1754 best_bss = NULL;
1755 best_weight = 0;
1756
1757 list_for_each_entry(scan_info, &wl->network_list, list) {
1758 pr_debug("%s: station %p\n", __func__, scan_info);
1759
1760 if (!scan_info->valid) {
1761 pr_debug("%s: station invalid\n", __func__);
1762 continue;
1763 }
1764
1765 /* If bss specified, check it only */
1766 if (test_bit(GELIC_WL_STAT_BSSID_SET, &wl->stat)) {
1767 if (!compare_ether_addr(&scan_info->hwinfo->bssid[2],
1768 wl->bssid)) {
1769 best_bss = scan_info;
1770 pr_debug("%s: bssid matched\n", __func__);
1771 break;
1772 } else {
1773 pr_debug("%s: bssid unmached\n", __func__);
1774 continue;
1775 }
1776 }
1777
1778 weight = 0;
1779
1780 /* security */
1781 security = be16_to_cpu(scan_info->hwinfo->security) &
1782 GELIC_EURUS_SCAN_SEC_MASK;
1783 if (wl->wpa_level == GELIC_WL_WPA_LEVEL_WPA2) {
1784 if (security == GELIC_EURUS_SCAN_SEC_WPA2)
1785 update_best(&best_bss, scan_info,
1786 &best_weight, &weight);
1787 else
1788 continue;
1789 } else if (wl->wpa_level == GELIC_WL_WPA_LEVEL_WPA) {
1790 if (security == GELIC_EURUS_SCAN_SEC_WPA)
1791 update_best(&best_bss, scan_info,
1792 &best_weight, &weight);
1793 else
1794 continue;
1795 } else if (wl->wpa_level == GELIC_WL_WPA_LEVEL_NONE &&
1796 wl->group_cipher_method == GELIC_WL_CIPHER_WEP) {
1797 if (security == GELIC_EURUS_SCAN_SEC_WEP)
1798 update_best(&best_bss, scan_info,
1799 &best_weight, &weight);
1800 else
1801 continue;
1802 }
1803
1804 /* If ESSID is set, check it */
1805 if (test_bit(GELIC_WL_STAT_ESSID_SET, &wl->stat)) {
1806 if ((scan_info->essid_len == wl->essid_len) &&
1807 !strncmp(wl->essid,
1808 scan_info->hwinfo->essid,
1809 scan_info->essid_len))
1810 update_best(&best_bss, scan_info,
1811 &best_weight, &weight);
1812 else
1813 continue;
1814 }
1815 }
1816
1817#ifdef DEBUG
1818 pr_debug("%s: -> bss=%p\n", __func__, best_bss);
1819 if (best_bss) {
1820 pr_debug("%s:addr=%s\n", __func__,
1821 print_mac(mac, &best_bss->hwinfo->bssid[2]));
1822 }
1823#endif
1824 return best_bss;
1825}
1826
1827/*
1828 * Setup WEP configuration to the chip
1829 * The caller must hold wl->scan_lock,
1830 * and on the state of wl->scan_state == GELIC_WL_SCAN_GOT_LIST
1831 */
1832static int gelic_wl_do_wep_setup(struct gelic_wl_info *wl)
1833{
1834 unsigned int i;
1835 struct gelic_eurus_wep_cfg *wep;
1836 struct gelic_eurus_cmd *cmd;
1837 int wep104 = 0;
1838 int have_key = 0;
1839 int ret = 0;
1840
1841 pr_debug("%s: <-\n", __func__);
1842 /* we can assume no one should uses the buffer */
1843 wep = wl->buf;
1844 memset(wep, 0, sizeof(*wep));
1845
1846 if (wl->group_cipher_method == GELIC_WL_CIPHER_WEP) {
1847 pr_debug("%s: WEP mode\n", __func__);
1848 for (i = 0; i < GELIC_WEP_KEYS; i++) {
1849 if (!test_bit(i, &wl->key_enabled))
1850 continue;
1851
1852 pr_debug("%s: key#%d enabled\n", __func__, i);
1853 have_key = 1;
1854 if (wl->key_len[i] == 13)
1855 wep104 = 1;
1856 else if (wl->key_len[i] != 5) {
1857 pr_info("%s: wrong wep key[%d]=%d\n",
1858 __func__, i, wl->key_len[i]);
1859 ret = -EINVAL;
1860 goto out;
1861 }
1862 memcpy(wep->key[i], wl->key[i], wl->key_len[i]);
1863 }
1864
1865 if (!have_key) {
1866 pr_info("%s: all wep key disabled\n", __func__);
1867 ret = -EINVAL;
1868 goto out;
1869 }
1870
1871 if (wep104) {
1872 pr_debug("%s: 104bit key\n", __func__);
1873 wep->security = cpu_to_be16(GELIC_EURUS_WEP_SEC_104BIT);
1874 } else {
1875 pr_debug("%s: 40bit key\n", __func__);
1876 wep->security = cpu_to_be16(GELIC_EURUS_WEP_SEC_40BIT);
1877 }
1878 } else {
1879 pr_debug("%s: NO encryption\n", __func__);
1880 wep->security = cpu_to_be16(GELIC_EURUS_WEP_SEC_NONE);
1881 }
1882
1883 /* issue wep setup */
1884 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_SET_WEP_CFG,
1885 wep, sizeof(*wep));
1886 if (!cmd)
1887 ret = -ENOMEM;
1888 else if (cmd->status || cmd->cmd_status)
1889 ret = -ENXIO;
1890
1891 kfree(cmd);
1892out:
1893 pr_debug("%s: ->\n", __func__);
1894 return ret;
1895}
1896
1897#ifdef DEBUG
1898static const char *wpasecstr(enum gelic_eurus_wpa_security sec)
1899{
1900 switch (sec) {
1901 case GELIC_EURUS_WPA_SEC_NONE:
1902 return "NONE";
1903 break;
1904 case GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP:
1905 return "WPA_TKIP_TKIP";
1906 break;
1907 case GELIC_EURUS_WPA_SEC_WPA_TKIP_AES:
1908 return "WPA_TKIP_AES";
1909 break;
1910 case GELIC_EURUS_WPA_SEC_WPA_AES_AES:
1911 return "WPA_AES_AES";
1912 break;
1913 case GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP:
1914 return "WPA2_TKIP_TKIP";
1915 break;
1916 case GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES:
1917 return "WPA2_TKIP_AES";
1918 break;
1919 case GELIC_EURUS_WPA_SEC_WPA2_AES_AES:
1920 return "WPA2_AES_AES";
1921 break;
1922 }
1923 return "";
1924};
1925#endif
1926
1927static int gelic_wl_do_wpa_setup(struct gelic_wl_info *wl)
1928{
1929 struct gelic_eurus_wpa_cfg *wpa;
1930 struct gelic_eurus_cmd *cmd;
1931 u16 security;
1932 int ret = 0;
1933
1934 pr_debug("%s: <-\n", __func__);
1935 /* we can assume no one should uses the buffer */
1936 wpa = wl->buf;
1937 memset(wpa, 0, sizeof(*wpa));
1938
1939 if (!test_bit(GELIC_WL_STAT_WPA_PSK_SET, &wl->stat))
1940 pr_info("%s: PSK not configured yet\n", __func__);
1941
1942 /* copy key */
1943 memcpy(wpa->psk, wl->psk, wl->psk_len);
1944
1945 /* set security level */
1946 if (wl->wpa_level == GELIC_WL_WPA_LEVEL_WPA2) {
1947 if (wl->group_cipher_method == GELIC_WL_CIPHER_AES) {
1948 security = GELIC_EURUS_WPA_SEC_WPA2_AES_AES;
1949 } else {
1950 if (wl->pairwise_cipher_method == GELIC_WL_CIPHER_AES &&
1951 precise_ie())
1952 security = GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES;
1953 else
1954 security = GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP;
1955 }
1956 } else {
1957 if (wl->group_cipher_method == GELIC_WL_CIPHER_AES) {
1958 security = GELIC_EURUS_WPA_SEC_WPA_AES_AES;
1959 } else {
1960 if (wl->pairwise_cipher_method == GELIC_WL_CIPHER_AES &&
1961 precise_ie())
1962 security = GELIC_EURUS_WPA_SEC_WPA_TKIP_AES;
1963 else
1964 security = GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP;
1965 }
1966 }
1967 wpa->security = cpu_to_be16(security);
1968
1969 /* PSK type */
1970 wpa->psk_type = cpu_to_be16(wl->psk_type);
1971#ifdef DEBUG
1972 pr_debug("%s: sec=%s psktype=%s\nn", __func__,
1973 wpasecstr(wpa->security),
1974 (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ?
1975 "BIN" : "passphrase");
1976#if 0
1977 /*
1978 * don't enable here if you plan to submit
1979 * the debug log because this dumps your precious
1980 * passphrase/key.
1981 */
1982 pr_debug("%s: psk=%s\n",
1983 (wpa->psk_type == GELIC_EURUS_WPA_PSK_BIN) ?
1984 (char *)"N/A" : (char *)wpa->psk);
1985#endif
1986#endif
1987 /* issue wpa setup */
1988 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_SET_WPA_CFG,
1989 wpa, sizeof(*wpa));
1990 if (!cmd)
1991 ret = -ENOMEM;
1992 else if (cmd->status || cmd->cmd_status)
1993 ret = -ENXIO;
1994 kfree(cmd);
1995 pr_debug("%s: --> %d\n", __func__, ret);
1996 return ret;
1997}
1998
1999/*
2000 * Start association. caller must hold assoc_stat_lock
2001 */
2002static int gelic_wl_associate_bss(struct gelic_wl_info *wl,
2003 struct gelic_wl_scan_info *bss)
2004{
2005 struct gelic_eurus_cmd *cmd;
2006 struct gelic_eurus_common_cfg *common;
2007 int ret = 0;
2008 unsigned long rc;
2009
2010 pr_debug("%s: <-\n", __func__);
2011
2012 /* do common config */
2013 common = wl->buf;
2014 memset(common, 0, sizeof(*common));
2015 common->bss_type = cpu_to_be16(GELIC_EURUS_BSS_INFRA);
2016 common->op_mode = cpu_to_be16(GELIC_EURUS_OPMODE_11BG);
2017
2018 common->scan_index = cpu_to_be16(bss->eurus_index);
2019 switch (wl->auth_method) {
2020 case GELIC_EURUS_AUTH_OPEN:
2021 common->auth_method = cpu_to_be16(GELIC_EURUS_AUTH_OPEN);
2022 break;
2023 case GELIC_EURUS_AUTH_SHARED:
2024 common->auth_method = cpu_to_be16(GELIC_EURUS_AUTH_SHARED);
2025 break;
2026 }
2027
2028#ifdef DEBUG
2029 scan_list_dump(wl);
2030#endif
2031 pr_debug("%s: common cfg index=%d bsstype=%d auth=%d\n", __func__,
2032 be16_to_cpu(common->scan_index),
2033 be16_to_cpu(common->bss_type),
2034 be16_to_cpu(common->auth_method));
2035
2036 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_SET_COMMON_CFG,
2037 common, sizeof(*common));
2038 if (!cmd || cmd->status || cmd->cmd_status) {
2039 ret = -ENOMEM;
2040 kfree(cmd);
2041 goto out;
2042 }
2043 kfree(cmd);
2044
2045 /* WEP/WPA */
2046 switch (wl->wpa_level) {
2047 case GELIC_WL_WPA_LEVEL_NONE:
2048 /* If WEP or no security, setup WEP config */
2049 ret = gelic_wl_do_wep_setup(wl);
2050 break;
2051 case GELIC_WL_WPA_LEVEL_WPA:
2052 case GELIC_WL_WPA_LEVEL_WPA2:
2053 ret = gelic_wl_do_wpa_setup(wl);
2054 break;
2055 };
2056
2057 if (ret) {
2058 pr_debug("%s: WEP/WPA setup failed %d\n", __func__,
2059 ret);
2060 }
2061
2062 /* start association */
2063 init_completion(&wl->assoc_done);
2064 wl->assoc_stat = GELIC_WL_ASSOC_STAT_ASSOCIATING;
2065 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_ASSOC,
2066 NULL, 0);
2067 if (!cmd || cmd->status || cmd->cmd_status) {
2068 pr_debug("%s: assoc request failed\n", __func__);
2069 wl->assoc_stat = GELIC_WL_ASSOC_STAT_DISCONN;
2070 kfree(cmd);
2071 ret = -ENOMEM;
2072 gelic_wl_send_iwap_event(wl, NULL);
2073 goto out;
2074 }
2075 kfree(cmd);
2076
2077 /* wait for connected event */
2078 rc = wait_for_completion_timeout(&wl->assoc_done, HZ * 4);/*FIXME*/
2079
2080 if (!rc) {
2081 /* timeouted. Maybe key or cyrpt mode is wrong */
2082 pr_info("%s: connect timeout \n", __func__);
2083 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_DISASSOC,
2084 NULL, 0);
2085 kfree(cmd);
2086 wl->assoc_stat = GELIC_WL_ASSOC_STAT_DISCONN;
2087 gelic_wl_send_iwap_event(wl, NULL);
2088 ret = -ENXIO;
2089 } else {
2090 wl->assoc_stat = GELIC_WL_ASSOC_STAT_ASSOCIATED;
2091 /* copy bssid */
2092 memcpy(wl->active_bssid, &bss->hwinfo->bssid[2], ETH_ALEN);
2093
2094 /* send connect event */
2095 gelic_wl_send_iwap_event(wl, wl->active_bssid);
2096 pr_info("%s: connected\n", __func__);
2097 }
2098out:
2099 pr_debug("%s: ->\n", __func__);
2100 return ret;
2101}
2102
2103/*
2104 * connected event
2105 */
2106static void gelic_wl_connected_event(struct gelic_wl_info *wl,
2107 u64 event)
2108{
2109 u64 desired_event = 0;
2110
2111 switch (wl->wpa_level) {
2112 case GELIC_WL_WPA_LEVEL_NONE:
2113 desired_event = GELIC_LV1_WL_EVENT_CONNECTED;
2114 break;
2115 case GELIC_WL_WPA_LEVEL_WPA:
2116 case GELIC_WL_WPA_LEVEL_WPA2:
2117 desired_event = GELIC_LV1_WL_EVENT_WPA_CONNECTED;
2118 break;
2119 }
2120
2121 if (desired_event == event) {
2122 pr_debug("%s: completed \n", __func__);
2123 complete(&wl->assoc_done);
2124 netif_carrier_on(port_to_netdev(wl_port(wl)));
2125 } else
2126 pr_debug("%s: event %#lx under wpa\n",
2127 __func__, event);
2128}
2129
2130/*
2131 * disconnect event
2132 */
2133static void gelic_wl_disconnect_event(struct gelic_wl_info *wl,
2134 u64 event)
2135{
2136 struct gelic_eurus_cmd *cmd;
2137 int lock;
2138
2139 /*
2140 * If we fall here in the middle of association,
2141 * associate_bss() should be waiting for complation of
2142 * wl->assoc_done.
2143 * As it waits with timeout, just leave assoc_done
2144 * uncompleted, then it terminates with timeout
2145 */
2146 if (down_trylock(&wl->assoc_stat_lock)) {
2147 pr_debug("%s: already locked\n", __func__);
2148 lock = 0;
2149 } else {
2150 pr_debug("%s: obtain lock\n", __func__);
2151 lock = 1;
2152 }
2153
2154 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_DISASSOC, NULL, 0);
2155 kfree(cmd);
2156
2157 /* send disconnected event to the supplicant */
2158 if (wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED)
2159 gelic_wl_send_iwap_event(wl, NULL);
2160
2161 wl->assoc_stat = GELIC_WL_ASSOC_STAT_DISCONN;
2162 netif_carrier_off(port_to_netdev(wl_port(wl)));
2163
2164 if (lock)
2165 up(&wl->assoc_stat_lock);
2166}
2167/*
2168 * event worker
2169 */
2170#ifdef DEBUG
2171static const char *eventstr(enum gelic_lv1_wl_event event)
2172{
2173 static char buf[32];
2174 char *ret;
2175 if (event & GELIC_LV1_WL_EVENT_DEVICE_READY)
2176 ret = "EURUS_READY";
2177 else if (event & GELIC_LV1_WL_EVENT_SCAN_COMPLETED)
2178 ret = "SCAN_COMPLETED";
2179 else if (event & GELIC_LV1_WL_EVENT_DEAUTH)
2180 ret = "DEAUTH";
2181 else if (event & GELIC_LV1_WL_EVENT_BEACON_LOST)
2182 ret = "BEACON_LOST";
2183 else if (event & GELIC_LV1_WL_EVENT_CONNECTED)
2184 ret = "CONNECTED";
2185 else if (event & GELIC_LV1_WL_EVENT_WPA_CONNECTED)
2186 ret = "WPA_CONNECTED";
2187 else if (event & GELIC_LV1_WL_EVENT_WPA_ERROR)
2188 ret = "WPA_ERROR";
2189 else {
2190 sprintf(buf, "Unknown(%#x)", event);
2191 ret = buf;
2192 }
2193 return ret;
2194}
2195#else
2196static const char *eventstr(enum gelic_lv1_wl_event event)
2197{
2198 return NULL;
2199}
2200#endif
2201static void gelic_wl_event_worker(struct work_struct *work)
2202{
2203 struct gelic_wl_info *wl;
2204 struct gelic_port *port;
2205 u64 event, tmp;
2206 int status;
2207
2208 pr_debug("%s:start\n", __func__);
2209 wl = container_of(work, struct gelic_wl_info, event_work.work);
2210 port = wl_port(wl);
2211 while (1) {
2212 status = lv1_net_control(bus_id(port->card), dev_id(port->card),
2213 GELIC_LV1_GET_WLAN_EVENT, 0, 0, 0,
2214 &event, &tmp);
2215 if (status) {
2216 if (status != LV1_NO_ENTRY)
2217 pr_debug("%s:wlan event failed %d\n",
2218 __func__, status);
2219 /* got all events */
2220 pr_debug("%s:end\n", __func__);
2221 return;
2222 }
2223 pr_debug("%s: event=%s\n", __func__, eventstr(event));
2224 switch (event) {
2225 case GELIC_LV1_WL_EVENT_SCAN_COMPLETED:
2226 gelic_wl_scan_complete_event(wl);
2227 break;
2228 case GELIC_LV1_WL_EVENT_BEACON_LOST:
2229 case GELIC_LV1_WL_EVENT_DEAUTH:
2230 gelic_wl_disconnect_event(wl, event);
2231 break;
2232 case GELIC_LV1_WL_EVENT_CONNECTED:
2233 case GELIC_LV1_WL_EVENT_WPA_CONNECTED:
2234 gelic_wl_connected_event(wl, event);
2235 break;
2236 default:
2237 break;
2238 }
2239 } /* while */
2240}
2241/*
2242 * association worker
2243 */
2244static void gelic_wl_assoc_worker(struct work_struct *work)
2245{
2246 struct gelic_wl_info *wl;
2247
2248 struct gelic_wl_scan_info *best_bss;
2249 int ret;
2250
2251 wl = container_of(work, struct gelic_wl_info, assoc_work.work);
2252
2253 down(&wl->assoc_stat_lock);
2254
2255 if (wl->assoc_stat != GELIC_WL_ASSOC_STAT_DISCONN)
2256 goto out;
2257
2258 ret = gelic_wl_start_scan(wl, 0);
2259 if (ret == -ERESTARTSYS) {
2260 pr_debug("%s: scan start failed association\n", __func__);
2261 schedule_delayed_work(&wl->assoc_work, HZ/10); /*FIXME*/
2262 goto out;
2263 } else if (ret) {
2264 pr_info("%s: scan prerequisite failed\n", __func__);
2265 goto out;
2266 }
2267
2268 /*
2269 * Wait for bss scan completion
2270 * If we have scan list already, gelic_wl_start_scan()
2271 * returns OK and raises the complete. Thus,
2272 * it's ok to wait unconditionally here
2273 */
2274 wait_for_completion(&wl->scan_done);
2275
2276 pr_debug("%s: scan done\n", __func__);
2277 down(&wl->scan_lock);
2278 if (wl->scan_stat != GELIC_WL_SCAN_STAT_GOT_LIST) {
2279 gelic_wl_send_iwap_event(wl, NULL);
2280 pr_info("%s: no scan list. association failed\n", __func__);
2281 goto scan_lock_out;
2282 }
2283
2284 /* find best matching bss */
2285 best_bss = gelic_wl_find_best_bss(wl);
2286 if (!best_bss) {
2287 gelic_wl_send_iwap_event(wl, NULL);
2288 pr_info("%s: no bss matched. association failed\n", __func__);
2289 goto scan_lock_out;
2290 }
2291
2292 /* ok, do association */
2293 ret = gelic_wl_associate_bss(wl, best_bss);
2294 if (ret)
2295 pr_info("%s: association failed %d\n", __func__, ret);
2296scan_lock_out:
2297 up(&wl->scan_lock);
2298out:
2299 up(&wl->assoc_stat_lock);
2300}
2301/*
2302 * Interrupt handler
2303 * Called from the ethernet interrupt handler
2304 * Processes wireless specific virtual interrupts only
2305 */
2306void gelic_wl_interrupt(struct net_device *netdev, u64 status)
2307{
2308 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
2309
2310 if (status & GELIC_CARD_WLAN_COMMAND_COMPLETED) {
2311 pr_debug("%s:cmd complete\n", __func__);
2312 complete(&wl->cmd_done_intr);
2313 }
2314
2315 if (status & GELIC_CARD_WLAN_EVENT_RECEIVED) {
2316 pr_debug("%s:event received\n", __func__);
2317 queue_delayed_work(wl->event_queue, &wl->event_work, 0);
2318 }
2319}
2320
2321/*
2322 * driver helpers
2323 */
2324#define IW_IOCTL(n) [(n) - SIOCSIWCOMMIT]
2325static const iw_handler gelic_wl_wext_handler[] =
2326{
2327 IW_IOCTL(SIOCGIWNAME) = gelic_wl_get_name,
2328 IW_IOCTL(SIOCGIWRANGE) = gelic_wl_get_range,
2329 IW_IOCTL(SIOCSIWSCAN) = gelic_wl_set_scan,
2330 IW_IOCTL(SIOCGIWSCAN) = gelic_wl_get_scan,
2331 IW_IOCTL(SIOCSIWAUTH) = gelic_wl_set_auth,
2332 IW_IOCTL(SIOCGIWAUTH) = gelic_wl_get_auth,
2333 IW_IOCTL(SIOCSIWESSID) = gelic_wl_set_essid,
2334 IW_IOCTL(SIOCGIWESSID) = gelic_wl_get_essid,
2335 IW_IOCTL(SIOCSIWENCODE) = gelic_wl_set_encode,
2336 IW_IOCTL(SIOCGIWENCODE) = gelic_wl_get_encode,
2337 IW_IOCTL(SIOCSIWAP) = gelic_wl_set_ap,
2338 IW_IOCTL(SIOCGIWAP) = gelic_wl_get_ap,
2339 IW_IOCTL(SIOCSIWENCODEEXT) = gelic_wl_set_encodeext,
2340 IW_IOCTL(SIOCGIWENCODEEXT) = gelic_wl_get_encodeext,
2341 IW_IOCTL(SIOCSIWMODE) = gelic_wl_set_mode,
2342 IW_IOCTL(SIOCGIWMODE) = gelic_wl_get_mode,
2343 IW_IOCTL(SIOCGIWNICKN) = gelic_wl_get_nick,
2344};
2345
2346static struct iw_priv_args gelic_wl_private_args[] =
2347{
2348 {
2349 .cmd = GELIC_WL_PRIV_SET_PSK,
2350 .set_args = IW_PRIV_TYPE_CHAR |
2351 (GELIC_WL_EURUS_PSK_MAX_LEN + 2),
2352 .name = "set_psk"
2353 },
2354 {
2355 .cmd = GELIC_WL_PRIV_GET_PSK,
2356 .get_args = IW_PRIV_TYPE_CHAR |
2357 (GELIC_WL_EURUS_PSK_MAX_LEN + 2),
2358 .name = "get_psk"
2359 }
2360};
2361
2362static const iw_handler gelic_wl_private_handler[] =
2363{
2364 gelic_wl_priv_set_psk,
2365 gelic_wl_priv_get_psk,
2366};
2367
2368static const struct iw_handler_def gelic_wl_wext_handler_def = {
2369 .num_standard = ARRAY_SIZE(gelic_wl_wext_handler),
2370 .standard = gelic_wl_wext_handler,
2371 .get_wireless_stats = gelic_wl_get_wireless_stats,
2372 .num_private = ARRAY_SIZE(gelic_wl_private_handler),
2373 .num_private_args = ARRAY_SIZE(gelic_wl_private_args),
2374 .private = gelic_wl_private_handler,
2375 .private_args = gelic_wl_private_args,
2376};
2377
2378static struct net_device *gelic_wl_alloc(struct gelic_card *card)
2379{
2380 struct net_device *netdev;
2381 struct gelic_port *port;
2382 struct gelic_wl_info *wl;
2383 unsigned int i;
2384
2385 pr_debug("%s:start\n", __func__);
2386 netdev = alloc_etherdev(sizeof(struct gelic_port) +
2387 sizeof(struct gelic_wl_info));
2388 pr_debug("%s: netdev =%p card=%p \np", __func__, netdev, card);
2389 if (!netdev)
2390 return NULL;
2391
2392 port = netdev_priv(netdev);
2393 port->netdev = netdev;
2394 port->card = card;
2395 port->type = GELIC_PORT_WIRELESS;
2396
2397 wl = port_wl(port);
2398 pr_debug("%s: wl=%p port=%p\n", __func__, wl, port);
2399
2400 /* allocate scan list */
2401 wl->networks = kzalloc(sizeof(struct gelic_wl_scan_info) *
2402 GELIC_WL_BSS_MAX_ENT, GFP_KERNEL);
2403
2404 if (!wl->networks)
2405 goto fail_bss;
2406
2407 wl->eurus_cmd_queue = create_singlethread_workqueue("gelic_cmd");
2408 if (!wl->eurus_cmd_queue)
2409 goto fail_cmd_workqueue;
2410
2411 wl->event_queue = create_singlethread_workqueue("gelic_event");
2412 if (!wl->event_queue)
2413 goto fail_event_workqueue;
2414
2415 INIT_LIST_HEAD(&wl->network_free_list);
2416 INIT_LIST_HEAD(&wl->network_list);
2417 for (i = 0; i < GELIC_WL_BSS_MAX_ENT; i++)
2418 list_add_tail(&wl->networks[i].list,
2419 &wl->network_free_list);
2420 init_completion(&wl->cmd_done_intr);
2421
2422 INIT_DELAYED_WORK(&wl->event_work, gelic_wl_event_worker);
2423 INIT_DELAYED_WORK(&wl->assoc_work, gelic_wl_assoc_worker);
2424 init_MUTEX(&wl->scan_lock);
2425 init_MUTEX(&wl->assoc_stat_lock);
2426
2427 init_completion(&wl->scan_done);
2428 /* for the case that no scan request is issued and stop() is called */
2429 complete(&wl->scan_done);
2430
2431 spin_lock_init(&wl->lock);
2432
2433 wl->scan_age = 5*HZ; /* FIXME */
2434
2435 /* buffer for receiving scanned list etc */
2436 BUILD_BUG_ON(PAGE_SIZE <
2437 sizeof(struct gelic_eurus_scan_info) *
2438 GELIC_EURUS_MAX_SCAN);
2439 wl->buf = (void *)get_zeroed_page(GFP_KERNEL);
2440 if (!wl->buf) {
2441 pr_info("%s:buffer allocation failed\n", __func__);
2442 goto fail_getpage;
2443 }
2444 pr_debug("%s:end\n", __func__);
2445 return netdev;
2446
2447fail_getpage:
2448 destroy_workqueue(wl->event_queue);
2449fail_event_workqueue:
2450 destroy_workqueue(wl->eurus_cmd_queue);
2451fail_cmd_workqueue:
2452 kfree(wl->networks);
2453fail_bss:
2454 free_netdev(netdev);
2455 pr_debug("%s:end error\n", __func__);
2456 return NULL;
2457
2458}
2459
2460static void gelic_wl_free(struct gelic_wl_info *wl)
2461{
2462 struct gelic_wl_scan_info *scan_info;
2463 unsigned int i;
2464
2465 pr_debug("%s: <-\n", __func__);
2466
2467 pr_debug("%s: destroy queues\n", __func__);
2468 destroy_workqueue(wl->eurus_cmd_queue);
2469 destroy_workqueue(wl->event_queue);
2470
2471 scan_info = wl->networks;
2472 for (i = 0; i < GELIC_WL_BSS_MAX_ENT; i++, scan_info++)
2473 kfree(scan_info->hwinfo);
2474 kfree(wl->networks);
2475
2476 free_netdev(port_to_netdev(wl_port(wl)));
2477
2478 pr_debug("%s: ->\n", __func__);
2479}
2480
2481static int gelic_wl_try_associate(struct net_device *netdev)
2482{
2483 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev));
2484 int ret = -1;
2485 unsigned int i;
2486
2487 pr_debug("%s: <-\n", __func__);
2488
2489 /* check constraits for start association */
2490 /* for no access restriction AP */
2491 if (wl->group_cipher_method == GELIC_WL_CIPHER_NONE) {
2492 if (test_bit(GELIC_WL_STAT_CONFIGURED,
2493 &wl->stat))
2494 goto do_associate;
2495 else {
2496 pr_debug("%s: no wep, not configured\n", __func__);
2497 return ret;
2498 }
2499 }
2500
2501 /* for WEP, one of four keys should be set */
2502 if (wl->group_cipher_method == GELIC_WL_CIPHER_WEP) {
2503 /* one of keys set */
2504 for (i = 0; i < GELIC_WEP_KEYS; i++) {
2505 if (test_bit(i, &wl->key_enabled))
2506 goto do_associate;
2507 }
2508 pr_debug("%s: WEP, but no key specified\n", __func__);
2509 return ret;
2510 }
2511
2512 /* for WPA[2], psk should be set */
2513 if ((wl->group_cipher_method == GELIC_WL_CIPHER_TKIP) ||
2514 (wl->group_cipher_method == GELIC_WL_CIPHER_AES)) {
2515 if (test_bit(GELIC_WL_STAT_WPA_PSK_SET,
2516 &wl->stat))
2517 goto do_associate;
2518 else {
2519 pr_debug("%s: AES/TKIP, but PSK not configured\n",
2520 __func__);
2521 return ret;
2522 }
2523 }
2524
2525do_associate:
2526 ret = schedule_delayed_work(&wl->assoc_work, 0);
2527 pr_debug("%s: start association work %d\n", __func__, ret);
2528 return ret;
2529}
2530
2531/*
2532 * netdev handlers
2533 */
2534static int gelic_wl_open(struct net_device *netdev)
2535{
2536 struct gelic_card *card = netdev_card(netdev);
2537
2538 pr_debug("%s:->%p\n", __func__, netdev);
2539
2540 gelic_card_up(card);
2541
2542 /* try to associate */
2543 gelic_wl_try_associate(netdev);
2544
2545 netif_start_queue(netdev);
2546
2547 pr_debug("%s:<-\n", __func__);
2548 return 0;
2549}
2550
2551/*
2552 * reset state machine
2553 */
2554static int gelic_wl_reset_state(struct gelic_wl_info *wl)
2555{
2556 struct gelic_wl_scan_info *target;
2557 struct gelic_wl_scan_info *tmp;
2558
2559 /* empty scan list */
2560 list_for_each_entry_safe(target, tmp, &wl->network_list, list) {
2561 list_move_tail(&target->list, &wl->network_free_list);
2562 }
2563 wl->scan_stat = GELIC_WL_SCAN_STAT_INIT;
2564
2565 /* clear configuration */
2566 wl->auth_method = GELIC_EURUS_AUTH_OPEN;
2567 wl->group_cipher_method = GELIC_WL_CIPHER_NONE;
2568 wl->pairwise_cipher_method = GELIC_WL_CIPHER_NONE;
2569 wl->wpa_level = GELIC_WL_WPA_LEVEL_NONE;
2570
2571 wl->key_enabled = 0;
2572 wl->current_key = 0;
2573
2574 wl->psk_type = GELIC_EURUS_WPA_PSK_PASSPHRASE;
2575 wl->psk_len = 0;
2576
2577 wl->essid_len = 0;
2578 memset(wl->essid, 0, sizeof(wl->essid));
2579 memset(wl->bssid, 0, sizeof(wl->bssid));
2580 memset(wl->active_bssid, 0, sizeof(wl->active_bssid));
2581
2582 wl->assoc_stat = GELIC_WL_ASSOC_STAT_DISCONN;
2583
2584 memset(&wl->iwstat, 0, sizeof(wl->iwstat));
2585 /* all status bit clear */
2586 wl->stat = 0;
2587 return 0;
2588}
2589
2590/*
2591 * Tell eurus to terminate association
2592 */
2593static void gelic_wl_disconnect(struct net_device *netdev)
2594{
2595 struct gelic_port *port = netdev_priv(netdev);
2596 struct gelic_wl_info *wl = port_wl(port);
2597 struct gelic_eurus_cmd *cmd;
2598
2599 /*
2600 * If scann process is running on chip,
2601 * further requests will be rejected
2602 */
2603 if (wl->scan_stat == GELIC_WL_SCAN_STAT_SCANNING)
2604 wait_for_completion_timeout(&wl->scan_done, HZ);
2605
2606 cmd = gelic_eurus_sync_cmd(wl, GELIC_EURUS_CMD_DISASSOC, NULL, 0);
2607 kfree(cmd);
2608 gelic_wl_send_iwap_event(wl, NULL);
2609};
2610
2611static int gelic_wl_stop(struct net_device *netdev)
2612{
2613 struct gelic_port *port = netdev_priv(netdev);
2614 struct gelic_wl_info *wl = port_wl(port);
2615 struct gelic_card *card = netdev_card(netdev);
2616
2617 pr_debug("%s:<-\n", __func__);
2618
2619 /*
2620 * Cancel pending association work.
2621 * event work can run after netdev down
2622 */
2623 cancel_delayed_work(&wl->assoc_work);
2624
2625 if (wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED)
2626 gelic_wl_disconnect(netdev);
2627
2628 /* reset our state machine */
2629 gelic_wl_reset_state(wl);
2630
2631 netif_stop_queue(netdev);
2632
2633 gelic_card_down(card);
2634
2635 pr_debug("%s:->\n", __func__);
2636 return 0;
2637}
2638
2639/* -- */
2640
2641static struct ethtool_ops gelic_wl_ethtool_ops = {
2642 .get_drvinfo = gelic_net_get_drvinfo,
2643 .get_link = gelic_wl_get_link,
2644 .get_tx_csum = ethtool_op_get_tx_csum,
2645 .set_tx_csum = ethtool_op_set_tx_csum,
2646 .get_rx_csum = gelic_net_get_rx_csum,
2647 .set_rx_csum = gelic_net_set_rx_csum,
2648};
2649
2650static void gelic_wl_setup_netdev_ops(struct net_device *netdev)
2651{
2652 struct gelic_wl_info *wl;
2653 wl = port_wl(netdev_priv(netdev));
2654 BUG_ON(!wl);
2655 netdev->open = &gelic_wl_open;
2656 netdev->stop = &gelic_wl_stop;
2657 netdev->hard_start_xmit = &gelic_net_xmit;
2658 netdev->set_multicast_list = &gelic_net_set_multi;
2659 netdev->change_mtu = &gelic_net_change_mtu;
2660 netdev->wireless_data = &wl->wireless_data;
2661 netdev->wireless_handlers = &gelic_wl_wext_handler_def;
2662 /* tx watchdog */
2663 netdev->tx_timeout = &gelic_net_tx_timeout;
2664 netdev->watchdog_timeo = GELIC_NET_WATCHDOG_TIMEOUT;
2665
2666 netdev->ethtool_ops = &gelic_wl_ethtool_ops;
2667#ifdef CONFIG_NET_POLL_CONTROLLER
2668 netdev->poll_controller = gelic_net_poll_controller;
2669#endif
2670}
2671
2672/*
2673 * driver probe/remove
2674 */
2675int gelic_wl_driver_probe(struct gelic_card *card)
2676{
2677 int ret;
2678 struct net_device *netdev;
2679
2680 pr_debug("%s:start\n", __func__);
2681
2682 if (ps3_compare_firmware_version(1, 6, 0) < 0)
2683 return 0;
2684 if (!card->vlan[GELIC_PORT_WIRELESS].tx)
2685 return 0;
2686
2687 /* alloc netdevice for wireless */
2688 netdev = gelic_wl_alloc(card);
2689 if (!netdev)
2690 return -ENOMEM;
2691
2692 /* setup net_device structure */
2693 gelic_wl_setup_netdev_ops(netdev);
2694
2695 /* setup some of net_device and register it */
2696 ret = gelic_net_setup_netdev(netdev, card);
2697 if (ret)
2698 goto fail_setup;
2699 card->netdev[GELIC_PORT_WIRELESS] = netdev;
2700
2701 /* add enable wireless interrupt */
2702 card->irq_mask |= GELIC_CARD_WLAN_EVENT_RECEIVED |
2703 GELIC_CARD_WLAN_COMMAND_COMPLETED;
2704 /* to allow wireless commands while both interfaces are down */
2705 gelic_card_set_irq_mask(card, GELIC_CARD_WLAN_EVENT_RECEIVED |
2706 GELIC_CARD_WLAN_COMMAND_COMPLETED);
2707 pr_debug("%s:end\n", __func__);
2708 return 0;
2709
2710fail_setup:
2711 gelic_wl_free(port_wl(netdev_port(netdev)));
2712
2713 return ret;
2714}
2715
2716int gelic_wl_driver_remove(struct gelic_card *card)
2717{
2718 struct gelic_wl_info *wl;
2719 struct net_device *netdev;
2720
2721 pr_debug("%s:start\n", __func__);
2722
2723 if (ps3_compare_firmware_version(1, 6, 0) < 0)
2724 return 0;
2725 if (!card->vlan[GELIC_PORT_WIRELESS].tx)
2726 return 0;
2727
2728 netdev = card->netdev[GELIC_PORT_WIRELESS];
2729 wl = port_wl(netdev_priv(netdev));
2730
2731 /* if the interface was not up, but associated */
2732 if (wl->assoc_stat == GELIC_WL_ASSOC_STAT_ASSOCIATED)
2733 gelic_wl_disconnect(netdev);
2734
2735 complete(&wl->cmd_done_intr);
2736
2737 /* cancel all work queue */
2738 cancel_delayed_work(&wl->assoc_work);
2739 cancel_delayed_work(&wl->event_work);
2740 flush_workqueue(wl->eurus_cmd_queue);
2741 flush_workqueue(wl->event_queue);
2742
2743 unregister_netdev(netdev);
2744
2745 /* disable wireless interrupt */
2746 pr_debug("%s: disable intr\n", __func__);
2747 card->irq_mask &= ~(GELIC_CARD_WLAN_EVENT_RECEIVED |
2748 GELIC_CARD_WLAN_COMMAND_COMPLETED);
2749 /* free bss list, netdev*/
2750 gelic_wl_free(wl);
2751 pr_debug("%s:end\n", __func__);
2752 return 0;
2753}
diff --git a/drivers/net/ps3_gelic_wireless.h b/drivers/net/ps3_gelic_wireless.h
new file mode 100644
index 000000000000..103697166720
--- /dev/null
+++ b/drivers/net/ps3_gelic_wireless.h
@@ -0,0 +1,329 @@
1/*
2 * PS3 gelic network driver.
3 *
4 * Copyright (C) 2007 Sony Computer Entertainment Inc.
5 * Copyright 2007 Sony Corporation
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation version 2.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20#ifndef _GELIC_WIRELESS_H
21#define _GELIC_WIRELESS_H
22
23#include <linux/wireless.h>
24#include <net/iw_handler.h>
25
26
27/* return value from GELIC_LV1_GET_WLAN_EVENT netcontrol */
28enum gelic_lv1_wl_event {
29 GELIC_LV1_WL_EVENT_DEVICE_READY = 0x01, /* Eurus ready */
30 GELIC_LV1_WL_EVENT_SCAN_COMPLETED = 0x02, /* Scan has completed */
31 GELIC_LV1_WL_EVENT_DEAUTH = 0x04, /* Deauthed by the AP */
32 GELIC_LV1_WL_EVENT_BEACON_LOST = 0x08, /* Beacon lost detected */
33 GELIC_LV1_WL_EVENT_CONNECTED = 0x10, /* Connected to AP */
34 GELIC_LV1_WL_EVENT_WPA_CONNECTED = 0x20, /* WPA connection */
35 GELIC_LV1_WL_EVENT_WPA_ERROR = 0x40, /* MIC error */
36};
37
38/* arguments for GELIC_LV1_POST_WLAN_COMMAND netcontrol */
39enum gelic_eurus_command {
40 GELIC_EURUS_CMD_ASSOC = 1, /* association start */
41 GELIC_EURUS_CMD_DISASSOC = 2, /* disassociate */
42 GELIC_EURUS_CMD_START_SCAN = 3, /* scan start */
43 GELIC_EURUS_CMD_GET_SCAN = 4, /* get scan result */
44 GELIC_EURUS_CMD_SET_COMMON_CFG = 5, /* set common config */
45 GELIC_EURUS_CMD_GET_COMMON_CFG = 6, /* set common config */
46 GELIC_EURUS_CMD_SET_WEP_CFG = 7, /* set WEP config */
47 GELIC_EURUS_CMD_GET_WEP_CFG = 8, /* get WEP config */
48 GELIC_EURUS_CMD_SET_WPA_CFG = 9, /* set WPA config */
49 GELIC_EURUS_CMD_GET_WPA_CFG = 10, /* get WPA config */
50 GELIC_EURUS_CMD_GET_RSSI_CFG = 11, /* get RSSI info. */
51 GELIC_EURUS_CMD_MAX_INDEX
52};
53
54/* for GELIC_EURUS_CMD_COMMON_CFG */
55enum gelic_eurus_bss_type {
56 GELIC_EURUS_BSS_INFRA = 0,
57 GELIC_EURUS_BSS_ADHOC = 1, /* not supported */
58};
59
60enum gelic_eurus_auth_method {
61 GELIC_EURUS_AUTH_OPEN = 0, /* FIXME: WLAN_AUTH_OPEN */
62 GELIC_EURUS_AUTH_SHARED = 1, /* not supported */
63};
64
65enum gelic_eurus_opmode {
66 GELIC_EURUS_OPMODE_11BG = 0, /* 802.11b/g */
67 GELIC_EURUS_OPMODE_11B = 1, /* 802.11b only */
68 GELIC_EURUS_OPMODE_11G = 2, /* 802.11g only */
69};
70
71struct gelic_eurus_common_cfg {
72 /* all fields are big endian */
73 u16 scan_index;
74 u16 bss_type; /* infra or adhoc */
75 u16 auth_method; /* shared key or open */
76 u16 op_mode; /* B/G */
77} __attribute__((packed));
78
79
80/* for GELIC_EURUS_CMD_WEP_CFG */
81enum gelic_eurus_wep_security {
82 GELIC_EURUS_WEP_SEC_NONE = 0,
83 GELIC_EURUS_WEP_SEC_40BIT = 1,
84 GELIC_EURUS_WEP_SEC_104BIT = 2,
85};
86
87struct gelic_eurus_wep_cfg {
88 /* all fields are big endian */
89 u16 security;
90 u8 key[4][16];
91} __attribute__((packed));
92
93/* for GELIC_EURUS_CMD_WPA_CFG */
94enum gelic_eurus_wpa_security {
95 GELIC_EURUS_WPA_SEC_NONE = 0x0000,
96 /* group=TKIP, pairwise=TKIP */
97 GELIC_EURUS_WPA_SEC_WPA_TKIP_TKIP = 0x0001,
98 /* group=AES, pairwise=AES */
99 GELIC_EURUS_WPA_SEC_WPA_AES_AES = 0x0002,
100 /* group=TKIP, pairwise=TKIP */
101 GELIC_EURUS_WPA_SEC_WPA2_TKIP_TKIP = 0x0004,
102 /* group=AES, pairwise=AES */
103 GELIC_EURUS_WPA_SEC_WPA2_AES_AES = 0x0008,
104 /* group=TKIP, pairwise=AES */
105 GELIC_EURUS_WPA_SEC_WPA_TKIP_AES = 0x0010,
106 /* group=TKIP, pairwise=AES */
107 GELIC_EURUS_WPA_SEC_WPA2_TKIP_AES = 0x0020,
108};
109
110enum gelic_eurus_wpa_psk_type {
111 GELIC_EURUS_WPA_PSK_PASSPHRASE = 0, /* passphrase string */
112 GELIC_EURUS_WPA_PSK_BIN = 1, /* 32 bytes binary key */
113};
114
115#define GELIC_WL_EURUS_PSK_MAX_LEN 64
116#define WPA_PSK_LEN 32 /* WPA spec says 256bit */
117
118struct gelic_eurus_wpa_cfg {
119 /* all fields are big endian */
120 u16 security;
121 u16 psk_type; /* psk key encoding type */
122 u8 psk[GELIC_WL_EURUS_PSK_MAX_LEN]; /* psk key; hex or passphrase */
123} __attribute__((packed));
124
125/* for GELIC_EURUS_CMD_{START,GET}_SCAN */
126enum gelic_eurus_scan_capability {
127 GELIC_EURUS_SCAN_CAP_ADHOC = 0x0000,
128 GELIC_EURUS_SCAN_CAP_INFRA = 0x0001,
129 GELIC_EURUS_SCAN_CAP_MASK = 0x0001,
130};
131
132enum gelic_eurus_scan_sec_type {
133 GELIC_EURUS_SCAN_SEC_NONE = 0x0000,
134 GELIC_EURUS_SCAN_SEC_WEP = 0x0100,
135 GELIC_EURUS_SCAN_SEC_WPA = 0x0200,
136 GELIC_EURUS_SCAN_SEC_WPA2 = 0x0400,
137 GELIC_EURUS_SCAN_SEC_MASK = 0x0f00,
138};
139
140enum gelic_eurus_scan_sec_wep_type {
141 GELIC_EURUS_SCAN_SEC_WEP_UNKNOWN = 0x0000,
142 GELIC_EURUS_SCAN_SEC_WEP_40 = 0x0001,
143 GELIC_EURUS_SCAN_SEC_WEP_104 = 0x0002,
144 GELIC_EURUS_SCAN_SEC_WEP_MASK = 0x0003,
145};
146
147enum gelic_eurus_scan_sec_wpa_type {
148 GELIC_EURUS_SCAN_SEC_WPA_UNKNOWN = 0x0000,
149 GELIC_EURUS_SCAN_SEC_WPA_TKIP = 0x0001,
150 GELIC_EURUS_SCAN_SEC_WPA_AES = 0x0002,
151 GELIC_EURUS_SCAN_SEC_WPA_MASK = 0x0003,
152};
153
154/*
155 * hw BSS information structure returned from GELIC_EURUS_CMD_GET_SCAN
156 */
157struct gelic_eurus_scan_info {
158 /* all fields are big endian */
159 __be16 size;
160 __be16 rssi; /* percentage */
161 __be16 channel; /* channel number */
162 __be16 beacon_period; /* FIXME: in msec unit */
163 __be16 capability;
164 __be16 security;
165 u8 bssid[8]; /* last ETH_ALEN are valid. bssid[0],[1] are unused */
166 u8 essid[32]; /* IW_ESSID_MAX_SIZE */
167 u8 rate[16]; /* first MAX_RATES_LENGTH(12) are valid */
168 u8 ext_rate[16]; /* first MAX_RATES_EX_LENGTH(16) are valid */
169 __be32 reserved1;
170 __be32 reserved2;
171 __be32 reserved3;
172 __be32 reserved4;
173 u8 elements[0]; /* ie */
174} __attribute__ ((packed));
175
176/* the hypervisor returns bbs up to 16 */
177#define GELIC_EURUS_MAX_SCAN (16)
178struct gelic_wl_scan_info {
179 struct list_head list;
180 struct gelic_eurus_scan_info *hwinfo;
181
182 int valid; /* set 1 if this entry was in latest scanned list
183 * from Eurus */
184 unsigned int eurus_index; /* index in the Eurus list */
185 unsigned long last_scanned; /* acquired time */
186
187 unsigned int rate_len;
188 unsigned int rate_ext_len;
189 unsigned int essid_len;
190};
191
192/* for GELIC_EURUS_CMD_GET_RSSI */
193struct gelic_eurus_rssi_info {
194 /* big endian */
195 __be16 rssi;
196} __attribute__ ((packed));
197
198
199/* for 'stat' member of gelic_wl_info */
200enum gelic_wl_info_status_bit {
201 GELIC_WL_STAT_CONFIGURED,
202 GELIC_WL_STAT_CH_INFO, /* ch info aquired */
203 GELIC_WL_STAT_ESSID_SET, /* ESSID specified by userspace */
204 GELIC_WL_STAT_BSSID_SET, /* BSSID specified by userspace */
205 GELIC_WL_STAT_WPA_PSK_SET, /* PMK specified by userspace */
206 GELIC_WL_STAT_WPA_LEVEL_SET, /* WEP or WPA[2] selected */
207};
208
209/* for 'scan_stat' member of gelic_wl_info */
210enum gelic_wl_scan_state {
211 /* just initialized or get last scan result failed */
212 GELIC_WL_SCAN_STAT_INIT,
213 /* scan request issued, accepted or chip is scanning */
214 GELIC_WL_SCAN_STAT_SCANNING,
215 /* scan results retrieved */
216 GELIC_WL_SCAN_STAT_GOT_LIST,
217};
218
219/* for 'cipher_method' */
220enum gelic_wl_cipher_method {
221 GELIC_WL_CIPHER_NONE,
222 GELIC_WL_CIPHER_WEP,
223 GELIC_WL_CIPHER_TKIP,
224 GELIC_WL_CIPHER_AES,
225};
226
227/* for 'wpa_level' */
228enum gelic_wl_wpa_level {
229 GELIC_WL_WPA_LEVEL_NONE,
230 GELIC_WL_WPA_LEVEL_WPA,
231 GELIC_WL_WPA_LEVEL_WPA2,
232};
233
234/* for 'assoc_stat' */
235enum gelic_wl_assoc_state {
236 GELIC_WL_ASSOC_STAT_DISCONN,
237 GELIC_WL_ASSOC_STAT_ASSOCIATING,
238 GELIC_WL_ASSOC_STAT_ASSOCIATED,
239};
240/* part of private data alloc_etherdev() allocated */
241#define GELIC_WEP_KEYS 4
242struct gelic_wl_info {
243 /* bss list */
244 struct semaphore scan_lock;
245 struct list_head network_list;
246 struct list_head network_free_list;
247 struct gelic_wl_scan_info *networks;
248
249 unsigned long scan_age; /* last scanned time */
250 enum gelic_wl_scan_state scan_stat;
251 struct completion scan_done;
252
253 /* eurus command queue */
254 struct workqueue_struct *eurus_cmd_queue;
255 struct completion cmd_done_intr;
256
257 /* eurus event handling */
258 struct workqueue_struct *event_queue;
259 struct delayed_work event_work;
260
261 /* wl status bits */
262 unsigned long stat;
263 enum gelic_eurus_auth_method auth_method; /* open/shared */
264 enum gelic_wl_cipher_method group_cipher_method;
265 enum gelic_wl_cipher_method pairwise_cipher_method;
266 enum gelic_wl_wpa_level wpa_level; /* wpa/wpa2 */
267
268 /* association handling */
269 struct semaphore assoc_stat_lock;
270 struct delayed_work assoc_work;
271 enum gelic_wl_assoc_state assoc_stat;
272 struct completion assoc_done;
273
274 spinlock_t lock;
275 u16 ch_info; /* available channels. bit0 = ch1 */
276 /* WEP keys */
277 u8 key[GELIC_WEP_KEYS][IW_ENCODING_TOKEN_MAX];
278 unsigned long key_enabled;
279 unsigned int key_len[GELIC_WEP_KEYS];
280 unsigned int current_key;
281 /* WWPA PSK */
282 u8 psk[GELIC_WL_EURUS_PSK_MAX_LEN];
283 enum gelic_eurus_wpa_psk_type psk_type;
284 unsigned int psk_len;
285
286 u8 essid[IW_ESSID_MAX_SIZE];
287 u8 bssid[ETH_ALEN]; /* userland requested */
288 u8 active_bssid[ETH_ALEN]; /* associated bssid */
289 unsigned int essid_len;
290
291 /* buffer for hypervisor IO */
292 void *buf;
293
294 struct iw_public_data wireless_data;
295 struct iw_statistics iwstat;
296};
297
298#define GELIC_WL_BSS_MAX_ENT 32
299#define GELIC_WL_ASSOC_RETRY 50
300static inline struct gelic_port *wl_port(struct gelic_wl_info *wl)
301{
302 return container_of((void *)wl, struct gelic_port, priv);
303}
304static inline struct gelic_wl_info *port_wl(struct gelic_port *port)
305{
306 return port_priv(port);
307}
308
309struct gelic_eurus_cmd {
310 struct work_struct work;
311 struct gelic_wl_info *wl;
312 unsigned int cmd; /* command code */
313 u64 tag;
314 u64 size;
315 void *buffer;
316 unsigned int buf_size;
317 struct completion done;
318 int status;
319 u64 cmd_status;
320};
321
322/* private ioctls to pass PSK */
323#define GELIC_WL_PRIV_SET_PSK (SIOCIWFIRSTPRIV + 0)
324#define GELIC_WL_PRIV_GET_PSK (SIOCIWFIRSTPRIV + 1)
325
326extern int gelic_wl_driver_probe(struct gelic_card *card);
327extern int gelic_wl_driver_remove(struct gelic_card *card);
328extern void gelic_wl_interrupt(struct net_device *netdev, u64 status);
329#endif /* _GELIC_WIRELESS_H */
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c
index 2334f4ebf907..19184e486ae9 100644
--- a/drivers/net/r6040.c
+++ b/drivers/net/r6040.c
@@ -61,7 +61,6 @@
61 61
62/* Time in jiffies before concluding the transmitter is hung. */ 62/* Time in jiffies before concluding the transmitter is hung. */
63#define TX_TIMEOUT (6000 * HZ / 1000) 63#define TX_TIMEOUT (6000 * HZ / 1000)
64#define TIMER_WUT (jiffies + HZ * 1)/* timer wakeup time : 1 second */
65 64
66/* RDC MAC I/O Size */ 65/* RDC MAC I/O Size */
67#define R6040_IO_SIZE 256 66#define R6040_IO_SIZE 256
@@ -174,8 +173,6 @@ struct r6040_private {
174 struct net_device *dev; 173 struct net_device *dev;
175 struct mii_if_info mii_if; 174 struct mii_if_info mii_if;
176 struct napi_struct napi; 175 struct napi_struct napi;
177 struct net_device_stats stats;
178 u16 napi_rx_running;
179 void __iomem *base; 176 void __iomem *base;
180}; 177};
181 178
@@ -235,17 +232,53 @@ static void mdio_write(struct net_device *dev, int mii_id, int reg, int val)
235 phy_write(ioaddr, lp->phy_addr, reg, val); 232 phy_write(ioaddr, lp->phy_addr, reg, val);
236} 233}
237 234
238static void r6040_tx_timeout(struct net_device *dev) 235static void r6040_free_txbufs(struct net_device *dev)
239{ 236{
240 struct r6040_private *priv = netdev_priv(dev); 237 struct r6040_private *lp = netdev_priv(dev);
238 int i;
241 239
242 disable_irq(dev->irq); 240 for (i = 0; i < TX_DCNT; i++) {
243 napi_disable(&priv->napi); 241 if (lp->tx_insert_ptr->skb_ptr) {
244 spin_lock(&priv->lock); 242 pci_unmap_single(lp->pdev, lp->tx_insert_ptr->buf,
245 dev->stats.tx_errors++; 243 MAX_BUF_SIZE, PCI_DMA_TODEVICE);
246 spin_unlock(&priv->lock); 244 dev_kfree_skb(lp->tx_insert_ptr->skb_ptr);
245 lp->rx_insert_ptr->skb_ptr = NULL;
246 }
247 lp->tx_insert_ptr = lp->tx_insert_ptr->vndescp;
248 }
249}
247 250
248 netif_stop_queue(dev); 251static void r6040_free_rxbufs(struct net_device *dev)
252{
253 struct r6040_private *lp = netdev_priv(dev);
254 int i;
255
256 for (i = 0; i < RX_DCNT; i++) {
257 if (lp->rx_insert_ptr->skb_ptr) {
258 pci_unmap_single(lp->pdev, lp->rx_insert_ptr->buf,
259 MAX_BUF_SIZE, PCI_DMA_FROMDEVICE);
260 dev_kfree_skb(lp->rx_insert_ptr->skb_ptr);
261 lp->rx_insert_ptr->skb_ptr = NULL;
262 }
263 lp->rx_insert_ptr = lp->rx_insert_ptr->vndescp;
264 }
265}
266
267static void r6040_init_ring_desc(struct r6040_descriptor *desc_ring,
268 dma_addr_t desc_dma, int size)
269{
270 struct r6040_descriptor *desc = desc_ring;
271 dma_addr_t mapping = desc_dma;
272
273 while (size-- > 0) {
274 mapping += sizeof(sizeof(*desc));
275 desc->ndesc = cpu_to_le32(mapping);
276 desc->vndescp = desc + 1;
277 desc++;
278 }
279 desc--;
280 desc->ndesc = cpu_to_le32(desc_dma);
281 desc->vndescp = desc_ring;
249} 282}
250 283
251/* Allocate skb buffer for rx descriptor */ 284/* Allocate skb buffer for rx descriptor */
@@ -256,7 +289,7 @@ static void rx_buf_alloc(struct r6040_private *lp, struct net_device *dev)
256 289
257 descptr = lp->rx_insert_ptr; 290 descptr = lp->rx_insert_ptr;
258 while (lp->rx_free_desc < RX_DCNT) { 291 while (lp->rx_free_desc < RX_DCNT) {
259 descptr->skb_ptr = dev_alloc_skb(MAX_BUF_SIZE); 292 descptr->skb_ptr = netdev_alloc_skb(dev, MAX_BUF_SIZE);
260 293
261 if (!descptr->skb_ptr) 294 if (!descptr->skb_ptr)
262 break; 295 break;
@@ -272,6 +305,63 @@ static void rx_buf_alloc(struct r6040_private *lp, struct net_device *dev)
272 lp->rx_insert_ptr = descptr; 305 lp->rx_insert_ptr = descptr;
273} 306}
274 307
308static void r6040_alloc_txbufs(struct net_device *dev)
309{
310 struct r6040_private *lp = netdev_priv(dev);
311 void __iomem *ioaddr = lp->base;
312
313 lp->tx_free_desc = TX_DCNT;
314
315 lp->tx_remove_ptr = lp->tx_insert_ptr = lp->tx_ring;
316 r6040_init_ring_desc(lp->tx_ring, lp->tx_ring_dma, TX_DCNT);
317
318 iowrite16(lp->tx_ring_dma, ioaddr + MTD_SA0);
319 iowrite16(lp->tx_ring_dma >> 16, ioaddr + MTD_SA1);
320}
321
322static void r6040_alloc_rxbufs(struct net_device *dev)
323{
324 struct r6040_private *lp = netdev_priv(dev);
325 void __iomem *ioaddr = lp->base;
326
327 lp->rx_free_desc = 0;
328
329 lp->rx_remove_ptr = lp->rx_insert_ptr = lp->rx_ring;
330 r6040_init_ring_desc(lp->rx_ring, lp->rx_ring_dma, RX_DCNT);
331
332 rx_buf_alloc(lp, dev);
333
334 iowrite16(lp->rx_ring_dma, ioaddr + MRD_SA0);
335 iowrite16(lp->rx_ring_dma >> 16, ioaddr + MRD_SA1);
336}
337
338static void r6040_tx_timeout(struct net_device *dev)
339{
340 struct r6040_private *priv = netdev_priv(dev);
341 void __iomem *ioaddr = priv->base;
342
343 printk(KERN_WARNING "%s: transmit timed out, status %4.4x, PHY status "
344 "%4.4x\n",
345 dev->name, ioread16(ioaddr + MIER),
346 mdio_read(dev, priv->mii_if.phy_id, MII_BMSR));
347
348 disable_irq(dev->irq);
349 napi_disable(&priv->napi);
350 spin_lock(&priv->lock);
351 /* Clear all descriptors */
352 r6040_free_txbufs(dev);
353 r6040_free_rxbufs(dev);
354 r6040_alloc_txbufs(dev);
355 r6040_alloc_rxbufs(dev);
356
357 /* Reset MAC */
358 iowrite16(MAC_RST, ioaddr + MCR1);
359 spin_unlock(&priv->lock);
360 enable_irq(dev->irq);
361
362 dev->stats.tx_errors++;
363 netif_wake_queue(dev);
364}
275 365
276static struct net_device_stats *r6040_get_stats(struct net_device *dev) 366static struct net_device_stats *r6040_get_stats(struct net_device *dev)
277{ 367{
@@ -280,11 +370,11 @@ static struct net_device_stats *r6040_get_stats(struct net_device *dev)
280 unsigned long flags; 370 unsigned long flags;
281 371
282 spin_lock_irqsave(&priv->lock, flags); 372 spin_lock_irqsave(&priv->lock, flags);
283 priv->stats.rx_crc_errors += ioread8(ioaddr + ME_CNT1); 373 dev->stats.rx_crc_errors += ioread8(ioaddr + ME_CNT1);
284 priv->stats.multicast += ioread8(ioaddr + ME_CNT0); 374 dev->stats.multicast += ioread8(ioaddr + ME_CNT0);
285 spin_unlock_irqrestore(&priv->lock, flags); 375 spin_unlock_irqrestore(&priv->lock, flags);
286 376
287 return &priv->stats; 377 return &dev->stats;
288} 378}
289 379
290/* Stop RDC MAC and Free the allocated resource */ 380/* Stop RDC MAC and Free the allocated resource */
@@ -293,7 +383,6 @@ static void r6040_down(struct net_device *dev)
293 struct r6040_private *lp = netdev_priv(dev); 383 struct r6040_private *lp = netdev_priv(dev);
294 void __iomem *ioaddr = lp->base; 384 void __iomem *ioaddr = lp->base;
295 struct pci_dev *pdev = lp->pdev; 385 struct pci_dev *pdev = lp->pdev;
296 int i;
297 int limit = 2048; 386 int limit = 2048;
298 u16 *adrp; 387 u16 *adrp;
299 u16 cmd; 388 u16 cmd;
@@ -313,27 +402,12 @@ static void r6040_down(struct net_device *dev)
313 iowrite16(adrp[1], ioaddr + MID_0M); 402 iowrite16(adrp[1], ioaddr + MID_0M);
314 iowrite16(adrp[2], ioaddr + MID_0H); 403 iowrite16(adrp[2], ioaddr + MID_0H);
315 free_irq(dev->irq, dev); 404 free_irq(dev->irq, dev);
405
316 /* Free RX buffer */ 406 /* Free RX buffer */
317 for (i = 0; i < RX_DCNT; i++) { 407 r6040_free_rxbufs(dev);
318 if (lp->rx_insert_ptr->skb_ptr) {
319 pci_unmap_single(lp->pdev, lp->rx_insert_ptr->buf,
320 MAX_BUF_SIZE, PCI_DMA_FROMDEVICE);
321 dev_kfree_skb(lp->rx_insert_ptr->skb_ptr);
322 lp->rx_insert_ptr->skb_ptr = NULL;
323 }
324 lp->rx_insert_ptr = lp->rx_insert_ptr->vndescp;
325 }
326 408
327 /* Free TX buffer */ 409 /* Free TX buffer */
328 for (i = 0; i < TX_DCNT; i++) { 410 r6040_free_txbufs(dev);
329 if (lp->tx_insert_ptr->skb_ptr) {
330 pci_unmap_single(lp->pdev, lp->tx_insert_ptr->buf,
331 MAX_BUF_SIZE, PCI_DMA_TODEVICE);
332 dev_kfree_skb(lp->tx_insert_ptr->skb_ptr);
333 lp->rx_insert_ptr->skb_ptr = NULL;
334 }
335 lp->tx_insert_ptr = lp->tx_insert_ptr->vndescp;
336 }
337 411
338 /* Free Descriptor memory */ 412 /* Free Descriptor memory */
339 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma); 413 pci_free_consistent(pdev, RX_DESC_SIZE, lp->rx_ring, lp->rx_ring_dma);
@@ -432,19 +506,24 @@ static int r6040_rx(struct net_device *dev, int limit)
432 506
433 /* Check for errors */ 507 /* Check for errors */
434 err = ioread16(ioaddr + MLSR); 508 err = ioread16(ioaddr + MLSR);
435 if (err & 0x0400) priv->stats.rx_errors++; 509 if (err & 0x0400)
510 dev->stats.rx_errors++;
436 /* RX FIFO over-run */ 511 /* RX FIFO over-run */
437 if (err & 0x8000) priv->stats.rx_fifo_errors++; 512 if (err & 0x8000)
513 dev->stats.rx_fifo_errors++;
438 /* RX descriptor unavailable */ 514 /* RX descriptor unavailable */
439 if (err & 0x0080) priv->stats.rx_frame_errors++; 515 if (err & 0x0080)
516 dev->stats.rx_frame_errors++;
440 /* Received packet with length over buffer lenght */ 517 /* Received packet with length over buffer lenght */
441 if (err & 0x0020) priv->stats.rx_over_errors++; 518 if (err & 0x0020)
519 dev->stats.rx_over_errors++;
442 /* Received packet with too long or short */ 520 /* Received packet with too long or short */
443 if (err & (0x0010|0x0008)) priv->stats.rx_length_errors++; 521 if (err & (0x0010 | 0x0008))
522 dev->stats.rx_length_errors++;
444 /* Received packet with CRC errors */ 523 /* Received packet with CRC errors */
445 if (err & 0x0004) { 524 if (err & 0x0004) {
446 spin_lock(&priv->lock); 525 spin_lock(&priv->lock);
447 priv->stats.rx_crc_errors++; 526 dev->stats.rx_crc_errors++;
448 spin_unlock(&priv->lock); 527 spin_unlock(&priv->lock);
449 } 528 }
450 529
@@ -469,8 +548,8 @@ static int r6040_rx(struct net_device *dev, int limit)
469 /* Send to upper layer */ 548 /* Send to upper layer */
470 netif_receive_skb(skb_ptr); 549 netif_receive_skb(skb_ptr);
471 dev->last_rx = jiffies; 550 dev->last_rx = jiffies;
472 priv->dev->stats.rx_packets++; 551 dev->stats.rx_packets++;
473 priv->dev->stats.rx_bytes += descptr->len; 552 dev->stats.rx_bytes += descptr->len;
474 /* To next descriptor */ 553 /* To next descriptor */
475 descptr = descptr->vndescp; 554 descptr = descptr->vndescp;
476 priv->rx_free_desc--; 555 priv->rx_free_desc--;
@@ -498,11 +577,13 @@ static void r6040_tx(struct net_device *dev)
498 /* Check for errors */ 577 /* Check for errors */
499 err = ioread16(ioaddr + MLSR); 578 err = ioread16(ioaddr + MLSR);
500 579
501 if (err & 0x0200) priv->stats.rx_fifo_errors++; 580 if (err & 0x0200)
502 if (err & (0x2000 | 0x4000)) priv->stats.tx_carrier_errors++; 581 dev->stats.rx_fifo_errors++;
582 if (err & (0x2000 | 0x4000))
583 dev->stats.tx_carrier_errors++;
503 584
504 if (descptr->status & 0x8000) 585 if (descptr->status & 0x8000)
505 break; /* Not complte */ 586 break; /* Not complete */
506 skb_ptr = descptr->skb_ptr; 587 skb_ptr = descptr->skb_ptr;
507 pci_unmap_single(priv->pdev, descptr->buf, 588 pci_unmap_single(priv->pdev, descptr->buf,
508 skb_ptr->len, PCI_DMA_TODEVICE); 589 skb_ptr->len, PCI_DMA_TODEVICE);
@@ -545,7 +626,6 @@ static irqreturn_t r6040_interrupt(int irq, void *dev_id)
545 struct r6040_private *lp = netdev_priv(dev); 626 struct r6040_private *lp = netdev_priv(dev);
546 void __iomem *ioaddr = lp->base; 627 void __iomem *ioaddr = lp->base;
547 u16 status; 628 u16 status;
548 int handled = 1;
549 629
550 /* Mask off RDC MAC interrupt */ 630 /* Mask off RDC MAC interrupt */
551 iowrite16(MSK_INT, ioaddr + MIER); 631 iowrite16(MSK_INT, ioaddr + MIER);
@@ -565,7 +645,7 @@ static irqreturn_t r6040_interrupt(int irq, void *dev_id)
565 if (status & 0x10) 645 if (status & 0x10)
566 r6040_tx(dev); 646 r6040_tx(dev);
567 647
568 return IRQ_RETVAL(handled); 648 return IRQ_HANDLED;
569} 649}
570 650
571#ifdef CONFIG_NET_POLL_CONTROLLER 651#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -577,53 +657,15 @@ static void r6040_poll_controller(struct net_device *dev)
577} 657}
578#endif 658#endif
579 659
580static void r6040_init_ring_desc(struct r6040_descriptor *desc_ring,
581 dma_addr_t desc_dma, int size)
582{
583 struct r6040_descriptor *desc = desc_ring;
584 dma_addr_t mapping = desc_dma;
585
586 while (size-- > 0) {
587 mapping += sizeof(sizeof(*desc));
588 desc->ndesc = cpu_to_le32(mapping);
589 desc->vndescp = desc + 1;
590 desc++;
591 }
592 desc--;
593 desc->ndesc = cpu_to_le32(desc_dma);
594 desc->vndescp = desc_ring;
595}
596
597/* Init RDC MAC */ 660/* Init RDC MAC */
598static void r6040_up(struct net_device *dev) 661static void r6040_up(struct net_device *dev)
599{ 662{
600 struct r6040_private *lp = netdev_priv(dev); 663 struct r6040_private *lp = netdev_priv(dev);
601 void __iomem *ioaddr = lp->base; 664 void __iomem *ioaddr = lp->base;
602 665
603 /* Initialize */ 666 /* Initialise and alloc RX/TX buffers */
604 lp->tx_free_desc = TX_DCNT; 667 r6040_alloc_txbufs(dev);
605 lp->rx_free_desc = 0; 668 r6040_alloc_rxbufs(dev);
606 /* Init descriptor */
607 lp->tx_remove_ptr = lp->tx_insert_ptr = lp->tx_ring;
608 lp->rx_remove_ptr = lp->rx_insert_ptr = lp->rx_ring;
609 /* Init TX descriptor */
610 r6040_init_ring_desc(lp->tx_ring, lp->tx_ring_dma, TX_DCNT);
611
612 /* Init RX descriptor */
613 r6040_init_ring_desc(lp->rx_ring, lp->rx_ring_dma, RX_DCNT);
614
615 /* Allocate buffer for RX descriptor */
616 rx_buf_alloc(lp, dev);
617
618 /*
619 * TX and RX descriptor start registers.
620 * Lower 16-bits to MxD_SA0. Higher 16-bits to MxD_SA1.
621 */
622 iowrite16(lp->tx_ring_dma, ioaddr + MTD_SA0);
623 iowrite16(lp->tx_ring_dma >> 16, ioaddr + MTD_SA1);
624
625 iowrite16(lp->rx_ring_dma, ioaddr + MRD_SA0);
626 iowrite16(lp->rx_ring_dma >> 16, ioaddr + MRD_SA1);
627 669
628 /* Buffer Size Register */ 670 /* Buffer Size Register */
629 iowrite16(MAX_BUF_SIZE, ioaddr + MR_BSR); 671 iowrite16(MAX_BUF_SIZE, ioaddr + MR_BSR);
@@ -689,8 +731,7 @@ static void r6040_timer(unsigned long data)
689 } 731 }
690 732
691 /* Timer active again */ 733 /* Timer active again */
692 lp->timer.expires = TIMER_WUT; 734 mod_timer(&lp->timer, jiffies + round_jiffies(HZ));
693 add_timer(&lp->timer);
694} 735}
695 736
696/* Read/set MAC address routines */ 737/* Read/set MAC address routines */
@@ -746,14 +787,10 @@ static int r6040_open(struct net_device *dev)
746 napi_enable(&lp->napi); 787 napi_enable(&lp->napi);
747 netif_start_queue(dev); 788 netif_start_queue(dev);
748 789
749 if (lp->switch_sig != ICPLUS_PHY_ID) { 790 /* set and active a timer process */
750 /* set and active a timer process */ 791 setup_timer(&lp->timer, r6040_timer, (unsigned long) dev);
751 init_timer(&lp->timer); 792 if (lp->switch_sig != ICPLUS_PHY_ID)
752 lp->timer.expires = TIMER_WUT; 793 mod_timer(&lp->timer, jiffies + HZ);
753 lp->timer.data = (unsigned long)dev;
754 lp->timer.function = &r6040_timer;
755 add_timer(&lp->timer);
756 }
757 return 0; 794 return 0;
758} 795}
759 796
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index 2e9e88be7b33..202fdf356621 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -1630,7 +1630,8 @@ static inline void sis190_init_rxfilter(struct net_device *dev)
1630 SIS_PCI_COMMIT(); 1630 SIS_PCI_COMMIT();
1631} 1631}
1632 1632
1633static int sis190_get_mac_addr(struct pci_dev *pdev, struct net_device *dev) 1633static int __devinit sis190_get_mac_addr(struct pci_dev *pdev,
1634 struct net_device *dev)
1634{ 1635{
1635 u8 from; 1636 u8 from;
1636 1637
diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
index 8134c7e198a5..b07ba2a14119 100644
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -187,23 +187,22 @@ void sync_stop(void)
187 end_sync(); 187 end_sync();
188} 188}
189 189
190 190
191/* Optimisation. We can manage without taking the dcookie sem 191/* Optimisation. We can manage without taking the dcookie sem
192 * because we cannot reach this code without at least one 192 * because we cannot reach this code without at least one
193 * dcookie user still being registered (namely, the reader 193 * dcookie user still being registered (namely, the reader
194 * of the event buffer). */ 194 * of the event buffer). */
195static inline unsigned long fast_get_dcookie(struct dentry * dentry, 195static inline unsigned long fast_get_dcookie(struct path *path)
196 struct vfsmount * vfsmnt)
197{ 196{
198 unsigned long cookie; 197 unsigned long cookie;
199 198
200 if (dentry->d_cookie) 199 if (path->dentry->d_cookie)
201 return (unsigned long)dentry; 200 return (unsigned long)path->dentry;
202 get_dcookie(dentry, vfsmnt, &cookie); 201 get_dcookie(path, &cookie);
203 return cookie; 202 return cookie;
204} 203}
205 204
206 205
207/* Look up the dcookie for the task's first VM_EXECUTABLE mapping, 206/* Look up the dcookie for the task's first VM_EXECUTABLE mapping,
208 * which corresponds loosely to "application name". This is 207 * which corresponds loosely to "application name". This is
209 * not strictly necessary but allows oprofile to associate 208 * not strictly necessary but allows oprofile to associate
@@ -222,8 +221,7 @@ static unsigned long get_exec_dcookie(struct mm_struct * mm)
222 continue; 221 continue;
223 if (!(vma->vm_flags & VM_EXECUTABLE)) 222 if (!(vma->vm_flags & VM_EXECUTABLE))
224 continue; 223 continue;
225 cookie = fast_get_dcookie(vma->vm_file->f_path.dentry, 224 cookie = fast_get_dcookie(&vma->vm_file->f_path);
226 vma->vm_file->f_path.mnt);
227 break; 225 break;
228 } 226 }
229 227
@@ -248,8 +246,7 @@ static unsigned long lookup_dcookie(struct mm_struct * mm, unsigned long addr, o
248 continue; 246 continue;
249 247
250 if (vma->vm_file) { 248 if (vma->vm_file) {
251 cookie = fast_get_dcookie(vma->vm_file->f_path.dentry, 249 cookie = fast_get_dcookie(&vma->vm_file->f_path);
252 vma->vm_file->f_path.mnt);
253 *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr - 250 *offset = (vma->vm_pgoff << PAGE_SHIFT) + addr -
254 vma->vm_start; 251 vma->vm_start;
255 } else { 252 } else {
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 662b4c279cfc..c283a9a70d83 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -36,7 +36,7 @@ static int num = 0;
36 * have irqs (PIC, Timer) because we call acpi_register_gsi. 36 * have irqs (PIC, Timer) because we call acpi_register_gsi.
37 * Finally, only devices that have a CRS method need to be in this list. 37 * Finally, only devices that have a CRS method need to be in this list.
38 */ 38 */
39static struct __initdata acpi_device_id excluded_id_list[] = { 39static struct acpi_device_id excluded_id_list[] __initdata = {
40 {"PNP0C09", 0}, /* EC */ 40 {"PNP0C09", 0}, /* EC */
41 {"PNP0C0F", 0}, /* Link device */ 41 {"PNP0C0F", 0}, /* Link device */
42 {"PNP0000", 0}, /* PIC */ 42 {"PNP0000", 0}, /* PIC */
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index f7e67197a568..a8a51500e1e9 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -105,8 +105,6 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
105 char *argv[3], **envp, *buf, *scratch; 105 char *argv[3], **envp, *buf, *scratch;
106 int i = 0, value; 106 int i = 0, value;
107 107
108 if (!current->fs->root)
109 return -EAGAIN;
110 if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL))) 108 if (!(envp = kcalloc(20, sizeof(char *), GFP_KERNEL)))
111 return -ENOMEM; 109 return -ENOMEM;
112 if (!(buf = kzalloc(256, GFP_KERNEL))) { 110 if (!(buf = kzalloc(256, GFP_KERNEL))) {
diff --git a/drivers/ps3/ps3-lpm.c b/drivers/ps3/ps3-lpm.c
index 4c066545d176..6c9592ce4996 100644
--- a/drivers/ps3/ps3-lpm.c
+++ b/drivers/ps3/ps3-lpm.c
@@ -76,7 +76,6 @@
76 * 76 *
77 * @pm_control: Shadow of the processor's pm_control register. 77 * @pm_control: Shadow of the processor's pm_control register.
78 * @pm_start_stop: Shadow of the processor's pm_start_stop register. 78 * @pm_start_stop: Shadow of the processor's pm_start_stop register.
79 * @pm_interval: Shadow of the processor's pm_interval register.
80 * @group_control: Shadow of the processor's group_control register. 79 * @group_control: Shadow of the processor's group_control register.
81 * @debug_bus_control: Shadow of the processor's debug_bus_control register. 80 * @debug_bus_control: Shadow of the processor's debug_bus_control register.
82 * 81 *
@@ -91,7 +90,6 @@
91struct ps3_lpm_shadow_regs { 90struct ps3_lpm_shadow_regs {
92 u64 pm_control; 91 u64 pm_control;
93 u64 pm_start_stop; 92 u64 pm_start_stop;
94 u64 pm_interval;
95 u64 group_control; 93 u64 group_control;
96 u64 debug_bus_control; 94 u64 debug_bus_control;
97}; 95};
@@ -181,9 +179,9 @@ void ps3_set_bookmark(u64 bookmark)
181 * includes cycles before the call. 179 * includes cycles before the call.
182 */ 180 */
183 181
184 asm volatile("or 29, 29, 29;"); /* db10cyc */ 182 asm volatile("nop;nop;nop;nop;nop;nop;nop;nop;nop;");
185 mtspr(SPRN_BKMK, bookmark); 183 mtspr(SPRN_BKMK, bookmark);
186 asm volatile("or 29, 29, 29;"); /* db10cyc */ 184 asm volatile("nop;nop;nop;nop;nop;nop;nop;nop;nop;");
187} 185}
188EXPORT_SYMBOL_GPL(ps3_set_bookmark); 186EXPORT_SYMBOL_GPL(ps3_set_bookmark);
189 187
@@ -408,7 +406,14 @@ u32 ps3_read_pm(u32 cpu, enum pm_reg_name reg)
408 case pm_start_stop: 406 case pm_start_stop:
409 return lpm_priv->shadow.pm_start_stop; 407 return lpm_priv->shadow.pm_start_stop;
410 case pm_interval: 408 case pm_interval:
411 return lpm_priv->shadow.pm_interval; 409 result = lv1_set_lpm_interval(lpm_priv->lpm_id, 0, 0, &val);
410 if (result) {
411 val = 0;
412 dev_dbg(sbd_core(), "%s:%u: lv1 set_inteval failed: "
413 "reg %u, %s\n", __func__, __LINE__, reg,
414 ps3_result(result));
415 }
416 return (u32)val;
412 case group_control: 417 case group_control:
413 return lpm_priv->shadow.group_control; 418 return lpm_priv->shadow.group_control;
414 case debug_bus_control: 419 case debug_bus_control:
@@ -475,10 +480,8 @@ void ps3_write_pm(u32 cpu, enum pm_reg_name reg, u32 val)
475 lpm_priv->shadow.pm_control = val; 480 lpm_priv->shadow.pm_control = val;
476 break; 481 break;
477 case pm_interval: 482 case pm_interval:
478 if (val != lpm_priv->shadow.pm_interval) 483 result = lv1_set_lpm_interval(lpm_priv->lpm_id, val,
479 result = lv1_set_lpm_interval(lpm_priv->lpm_id, val, 484 PS3_WRITE_PM_MASK, &dummy);
480 PS3_WRITE_PM_MASK, &dummy);
481 lpm_priv->shadow.pm_interval = val;
482 break; 485 break;
483 case pm_start_stop: 486 case pm_start_stop:
484 if (val != lpm_priv->shadow.pm_start_stop) 487 if (val != lpm_priv->shadow.pm_start_stop)
@@ -1140,7 +1143,6 @@ int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
1140 1143
1141 lpm_priv->shadow.pm_control = PS3_LPM_SHADOW_REG_INIT; 1144 lpm_priv->shadow.pm_control = PS3_LPM_SHADOW_REG_INIT;
1142 lpm_priv->shadow.pm_start_stop = PS3_LPM_SHADOW_REG_INIT; 1145 lpm_priv->shadow.pm_start_stop = PS3_LPM_SHADOW_REG_INIT;
1143 lpm_priv->shadow.pm_interval = PS3_LPM_SHADOW_REG_INIT;
1144 lpm_priv->shadow.group_control = PS3_LPM_SHADOW_REG_INIT; 1146 lpm_priv->shadow.group_control = PS3_LPM_SHADOW_REG_INIT;
1145 lpm_priv->shadow.debug_bus_control = PS3_LPM_SHADOW_REG_INIT; 1147 lpm_priv->shadow.debug_bus_control = PS3_LPM_SHADOW_REG_INIT;
1146 1148
diff --git a/drivers/ps3/ps3-sys-manager.c b/drivers/ps3/ps3-sys-manager.c
index c3c3aba3ffce..d4f6f960dd18 100644
--- a/drivers/ps3/ps3-sys-manager.c
+++ b/drivers/ps3/ps3-sys-manager.c
@@ -28,10 +28,6 @@
28 28
29#include "vuart.h" 29#include "vuart.h"
30 30
31MODULE_AUTHOR("Sony Corporation");
32MODULE_LICENSE("GPL v2");
33MODULE_DESCRIPTION("PS3 System Manager");
34
35/** 31/**
36 * ps3_sys_manager - PS3 system manager driver. 32 * ps3_sys_manager - PS3 system manager driver.
37 * 33 *
@@ -142,9 +138,11 @@ enum ps3_sys_manager_attr {
142 138
143/** 139/**
144 * enum ps3_sys_manager_event - External event type, reported by system manager. 140 * enum ps3_sys_manager_event - External event type, reported by system manager.
145 * @PS3_SM_EVENT_POWER_PRESSED: payload.value not used. 141 * @PS3_SM_EVENT_POWER_PRESSED: payload.value =
142 * enum ps3_sys_manager_button_event.
146 * @PS3_SM_EVENT_POWER_RELEASED: payload.value = time pressed in millisec. 143 * @PS3_SM_EVENT_POWER_RELEASED: payload.value = time pressed in millisec.
147 * @PS3_SM_EVENT_RESET_PRESSED: payload.value not used. 144 * @PS3_SM_EVENT_RESET_PRESSED: payload.value =
145 * enum ps3_sys_manager_button_event.
148 * @PS3_SM_EVENT_RESET_RELEASED: payload.value = time pressed in millisec. 146 * @PS3_SM_EVENT_RESET_RELEASED: payload.value = time pressed in millisec.
149 * @PS3_SM_EVENT_THERMAL_ALERT: payload.value = thermal zone id. 147 * @PS3_SM_EVENT_THERMAL_ALERT: payload.value = thermal zone id.
150 * @PS3_SM_EVENT_THERMAL_CLEARED: payload.value = thermal zone id. 148 * @PS3_SM_EVENT_THERMAL_CLEARED: payload.value = thermal zone id.
@@ -162,6 +160,17 @@ enum ps3_sys_manager_event {
162}; 160};
163 161
164/** 162/**
163 * enum ps3_sys_manager_button_event - Button event payload values.
164 * @PS3_SM_BUTTON_EVENT_HARD: Hardware generated event.
165 * @PS3_SM_BUTTON_EVENT_SOFT: Software generated event.
166 */
167
168enum ps3_sys_manager_button_event {
169 PS3_SM_BUTTON_EVENT_HARD = 0,
170 PS3_SM_BUTTON_EVENT_SOFT = 1,
171};
172
173/**
165 * enum ps3_sys_manager_next_op - Operation to perform after lpar is destroyed. 174 * enum ps3_sys_manager_next_op - Operation to perform after lpar is destroyed.
166 */ 175 */
167 176
@@ -181,7 +190,9 @@ enum ps3_sys_manager_next_op {
181 * @PS3_SM_WAKE_P_O_R: Power on reset. 190 * @PS3_SM_WAKE_P_O_R: Power on reset.
182 * 191 *
183 * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN. 192 * Additional wakeup sources when specifying PS3_SM_NEXT_OP_SYS_SHUTDOWN.
184 * System will always wake from the PS3_SM_WAKE_DEFAULT sources. 193 * The system will always wake from the PS3_SM_WAKE_DEFAULT sources.
194 * Sources listed here are the only ones available to guests in the
195 * other-os lpar.
185 */ 196 */
186 197
187enum ps3_sys_manager_wake_source { 198enum ps3_sys_manager_wake_source {
@@ -189,7 +200,7 @@ enum ps3_sys_manager_wake_source {
189 PS3_SM_WAKE_DEFAULT = 0, 200 PS3_SM_WAKE_DEFAULT = 0,
190 PS3_SM_WAKE_RTC = 0x00000040, 201 PS3_SM_WAKE_RTC = 0x00000040,
191 PS3_SM_WAKE_RTC_ERROR = 0x00000080, 202 PS3_SM_WAKE_RTC_ERROR = 0x00000080,
192 PS3_SM_WAKE_P_O_R = 0x10000000, 203 PS3_SM_WAKE_P_O_R = 0x80000000,
193}; 204};
194 205
195/** 206/**
@@ -418,8 +429,10 @@ static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev)
418 429
419 switch (event.type) { 430 switch (event.type) {
420 case PS3_SM_EVENT_POWER_PRESSED: 431 case PS3_SM_EVENT_POWER_PRESSED:
421 dev_dbg(&dev->core, "%s:%d: POWER_PRESSED\n", 432 dev_dbg(&dev->core, "%s:%d: POWER_PRESSED (%s)\n",
422 __func__, __LINE__); 433 __func__, __LINE__,
434 (event.value == PS3_SM_BUTTON_EVENT_SOFT ? "soft"
435 : "hard"));
423 ps3_sm_force_power_off = 1; 436 ps3_sm_force_power_off = 1;
424 /* 437 /*
425 * A memory barrier is use here to sync memory since 438 * A memory barrier is use here to sync memory since
@@ -434,8 +447,10 @@ static int ps3_sys_manager_handle_event(struct ps3_system_bus_device *dev)
434 __func__, __LINE__, event.value); 447 __func__, __LINE__, event.value);
435 break; 448 break;
436 case PS3_SM_EVENT_RESET_PRESSED: 449 case PS3_SM_EVENT_RESET_PRESSED:
437 dev_dbg(&dev->core, "%s:%d: RESET_PRESSED\n", 450 dev_dbg(&dev->core, "%s:%d: RESET_PRESSED (%s)\n",
438 __func__, __LINE__); 451 __func__, __LINE__,
452 (event.value == PS3_SM_BUTTON_EVENT_SOFT ? "soft"
453 : "hard"));
439 ps3_sm_force_power_off = 0; 454 ps3_sm_force_power_off = 0;
440 /* 455 /*
441 * A memory barrier is use here to sync memory since 456 * A memory barrier is use here to sync memory since
@@ -622,7 +637,7 @@ static void ps3_sys_manager_final_restart(struct ps3_system_bus_device *dev)
622 ps3_vuart_cancel_async(dev); 637 ps3_vuart_cancel_async(dev);
623 638
624 ps3_sys_manager_send_attr(dev, 0); 639 ps3_sys_manager_send_attr(dev, 0);
625 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_LPAR_REBOOT, 640 ps3_sys_manager_send_next_op(dev, PS3_SM_NEXT_OP_SYS_REBOOT,
626 PS3_SM_WAKE_DEFAULT); 641 PS3_SM_WAKE_DEFAULT);
627 ps3_sys_manager_send_request_shutdown(dev); 642 ps3_sys_manager_send_request_shutdown(dev);
628 643
@@ -699,4 +714,7 @@ static int __init ps3_sys_manager_init(void)
699module_init(ps3_sys_manager_init); 714module_init(ps3_sys_manager_init);
700/* Module remove not supported. */ 715/* Module remove not supported. */
701 716
717MODULE_AUTHOR("Sony Corporation");
718MODULE_LICENSE("GPL v2");
719MODULE_DESCRIPTION("PS3 System Manager");
702MODULE_ALIAS(PS3_MODULE_ALIAS_SYSTEM_MANAGER); 720MODULE_ALIAS(PS3_MODULE_ALIAS_SYSTEM_MANAGER);
diff --git a/drivers/s390/net/claw.h b/drivers/s390/net/claw.h
index 1ee9a6f06541..1a89d989f348 100644
--- a/drivers/s390/net/claw.h
+++ b/drivers/s390/net/claw.h
@@ -114,11 +114,20 @@ do { \
114 debug_event(claw_dbf_##name,level,(void*)(addr),len); \ 114 debug_event(claw_dbf_##name,level,(void*)(addr),len); \
115} while (0) 115} while (0)
116 116
117/* Allow to sort out low debug levels early to avoid wasted sprints */
118static inline int claw_dbf_passes(debug_info_t *dbf_grp, int level)
119{
120 return (level <= dbf_grp->level);
121}
122
117#define CLAW_DBF_TEXT_(level,name,text...) \ 123#define CLAW_DBF_TEXT_(level,name,text...) \
118do { \ 124 do { \
119 sprintf(debug_buffer, text); \ 125 if (claw_dbf_passes(claw_dbf_##name, level)) { \
120 debug_text_event(claw_dbf_##name,level, debug_buffer);\ 126 sprintf(debug_buffer, text); \
121} while (0) 127 debug_text_event(claw_dbf_##name, level, \
128 debug_buffer); \
129 } \
130 } while (0)
122 131
123/******************************************************* 132/*******************************************************
124* Define Control Blocks * 133* Define Control Blocks *
@@ -278,8 +287,6 @@ struct claw_env {
278 __u16 write_size; /* write buffer size */ 287 __u16 write_size; /* write buffer size */
279 __u16 dev_id; /* device ident */ 288 __u16 dev_id; /* device ident */
280 __u8 packing; /* are we packing? */ 289 __u8 packing; /* are we packing? */
281 volatile __u8 queme_switch; /* gate for imed packing */
282 volatile unsigned long pk_delay; /* Delay for adaptive packing */
283 __u8 in_use; /* device active flag */ 290 __u8 in_use; /* device active flag */
284 struct net_device *ndev; /* backward ptr to the net dev*/ 291 struct net_device *ndev; /* backward ptr to the net dev*/
285}; 292};
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 7bfe8d707a34..f51ed9972587 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -94,7 +94,7 @@ static int
94lcs_register_debug_facility(void) 94lcs_register_debug_facility(void)
95{ 95{
96 lcs_dbf_setup = debug_register("lcs_setup", 2, 1, 8); 96 lcs_dbf_setup = debug_register("lcs_setup", 2, 1, 8);
97 lcs_dbf_trace = debug_register("lcs_trace", 2, 2, 8); 97 lcs_dbf_trace = debug_register("lcs_trace", 4, 1, 8);
98 if (lcs_dbf_setup == NULL || lcs_dbf_trace == NULL) { 98 if (lcs_dbf_setup == NULL || lcs_dbf_trace == NULL) {
99 PRINT_ERR("Not enough memory for debug facility.\n"); 99 PRINT_ERR("Not enough memory for debug facility.\n");
100 lcs_unregister_debug_facility(); 100 lcs_unregister_debug_facility();
diff --git a/drivers/s390/net/lcs.h b/drivers/s390/net/lcs.h
index 8976fb0b070a..d58fea52557d 100644
--- a/drivers/s390/net/lcs.h
+++ b/drivers/s390/net/lcs.h
@@ -16,11 +16,19 @@ do { \
16 debug_event(lcs_dbf_##name,level,(void*)(addr),len); \ 16 debug_event(lcs_dbf_##name,level,(void*)(addr),len); \
17} while (0) 17} while (0)
18 18
19/* Allow to sort out low debug levels early to avoid wasted sprints */
20static inline int lcs_dbf_passes(debug_info_t *dbf_grp, int level)
21{
22 return (level <= dbf_grp->level);
23}
24
19#define LCS_DBF_TEXT_(level,name,text...) \ 25#define LCS_DBF_TEXT_(level,name,text...) \
20do { \ 26 do { \
21 sprintf(debug_buffer, text); \ 27 if (lcs_dbf_passes(lcs_dbf_##name, level)) { \
22 debug_text_event(lcs_dbf_##name,level, debug_buffer);\ 28 sprintf(debug_buffer, text); \
23} while (0) 29 debug_text_event(lcs_dbf_##name, level, debug_buffer); \
30 } \
31 } while (0)
24 32
25/** 33/**
26 * sysfs related stuff 34 * sysfs related stuff
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index f3d893cfe61d..874a19994489 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -97,12 +97,22 @@ MODULE_DESCRIPTION ("Linux for S/390 IUCV network driver");
97 97
98DECLARE_PER_CPU(char[256], iucv_dbf_txt_buf); 98DECLARE_PER_CPU(char[256], iucv_dbf_txt_buf);
99 99
100#define IUCV_DBF_TEXT_(name,level,text...) \ 100/* Allow to sort out low debug levels early to avoid wasted sprints */
101 do { \ 101static inline int iucv_dbf_passes(debug_info_t *dbf_grp, int level)
102 char* iucv_dbf_txt_buf = get_cpu_var(iucv_dbf_txt_buf); \ 102{
103 sprintf(iucv_dbf_txt_buf, text); \ 103 return (level <= dbf_grp->level);
104 debug_text_event(iucv_dbf_##name,level,iucv_dbf_txt_buf); \ 104}
105 put_cpu_var(iucv_dbf_txt_buf); \ 105
106#define IUCV_DBF_TEXT_(name, level, text...) \
107 do { \
108 if (iucv_dbf_passes(iucv_dbf_##name, level)) { \
109 char* iucv_dbf_txt_buf = \
110 get_cpu_var(iucv_dbf_txt_buf); \
111 sprintf(iucv_dbf_txt_buf, text); \
112 debug_text_event(iucv_dbf_##name, level, \
113 iucv_dbf_txt_buf); \
114 put_cpu_var(iucv_dbf_txt_buf); \
115 } \
106 } while (0) 116 } while (0)
107 117
108#define IUCV_DBF_SPRINTF(name,level,text...) \ 118#define IUCV_DBF_SPRINTF(name,level,text...) \
@@ -137,6 +147,7 @@ PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
137#define PRINTK_HEADER " iucv: " /* for debugging */ 147#define PRINTK_HEADER " iucv: " /* for debugging */
138 148
139static struct device_driver netiucv_driver = { 149static struct device_driver netiucv_driver = {
150 .owner = THIS_MODULE,
140 .name = "netiucv", 151 .name = "netiucv",
141 .bus = &iucv_bus, 152 .bus = &iucv_bus,
142}; 153};
@@ -572,9 +583,9 @@ static void netiucv_callback_connres(struct iucv_path *path, u8 ipuser[16])
572} 583}
573 584
574/** 585/**
575 * Dummy NOP action for all statemachines 586 * NOP action for statemachines
576 */ 587 */
577static void fsm_action_nop(fsm_instance *fi, int event, void *arg) 588static void netiucv_action_nop(fsm_instance *fi, int event, void *arg)
578{ 589{
579} 590}
580 591
@@ -1110,7 +1121,7 @@ static const fsm_node dev_fsm[] = {
1110 1121
1111 { DEV_STATE_RUNNING, DEV_EVENT_STOP, dev_action_stop }, 1122 { DEV_STATE_RUNNING, DEV_EVENT_STOP, dev_action_stop },
1112 { DEV_STATE_RUNNING, DEV_EVENT_CONDOWN, dev_action_conndown }, 1123 { DEV_STATE_RUNNING, DEV_EVENT_CONDOWN, dev_action_conndown },
1113 { DEV_STATE_RUNNING, DEV_EVENT_CONUP, fsm_action_nop }, 1124 { DEV_STATE_RUNNING, DEV_EVENT_CONUP, netiucv_action_nop },
1114}; 1125};
1115 1126
1116static const int DEV_FSM_LEN = sizeof(dev_fsm) / sizeof(fsm_node); 1127static const int DEV_FSM_LEN = sizeof(dev_fsm) / sizeof(fsm_node);
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index ddf639144538..9ce12cb2cebc 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -393,7 +393,7 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
393 if (cflag & CRTSCTS) { 393 if (cflag & CRTSCTS) {
394 fcr_val |= SCFCR_MCE; 394 fcr_val |= SCFCR_MCE;
395 } else { 395 } else {
396#ifdef CONFIG_CPU_SUBTYPE_SH7343 396#if defined(CONFIG_CPU_SUBTYPE_SH7343) || defined(CONFIG_CPU_SUBTYPE_SH7366)
397 /* Nothing */ 397 /* Nothing */
398#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 398#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \
399 defined(CONFIG_CPU_SUBTYPE_SH7780) || \ 399 defined(CONFIG_CPU_SUBTYPE_SH7780) || \
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index f5764ebcfe07..01a9dd715f5d 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -97,13 +97,18 @@
97# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 97# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
98# define SCIF_ONLY 98# define SCIF_ONLY
99# define PORT_PSCR 0xA405011E 99# define PORT_PSCR 0xA405011E
100#elif defined(CONFIG_CPU_SUBTYPE_SH7366)
101# define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */
102# define SCSPTR0 SCPDR0
103# define SCIF_ORER 0x0001 /* overrun error bit */
104# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
105# define SCIF_ONLY
100#elif defined(CONFIG_CPU_SUBTYPE_SH4_202) 106#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
101# define SCSPTR2 0xffe80020 /* 16 bit SCIF */ 107# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
102# define SCIF_ORER 0x0001 /* overrun error bit */ 108# define SCIF_ORER 0x0001 /* overrun error bit */
103# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 109# define SCSCR_INIT(port) 0x38 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
104# define SCIF_ONLY 110# define SCIF_ONLY
105#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) 111#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
106# include <asm/hardware.h>
107# define SCIF_BASE_ADDR 0x01030000 112# define SCIF_BASE_ADDR 0x01030000
108# define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR 113# define SCIF_ADDR_SH5 PHYS_PERIPHERAL_BLOCK+SCIF_BASE_ADDR
109# define SCIF_PTR2_OFFS 0x0000020 114# define SCIF_PTR2_OFFS 0x0000020
@@ -577,7 +582,7 @@ static inline int sci_rxd_in(struct uart_port *port)
577 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ 582 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
578 return 1; 583 return 1;
579} 584}
580#elif defined(CONFIG_CPU_SUBTYPE_SH7722) 585#elif defined(CONFIG_CPU_SUBTYPE_SH7722) || defined(CONFIG_CPU_SUBTYPE_SH7366)
581static inline int sci_rxd_in(struct uart_port *port) 586static inline int sci_rxd_in(struct uart_port *port)
582{ 587{
583 if (port->mapbase == 0xffe00000) 588 if (port->mapbase == 0xffe00000)
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
index e52a6296ca46..9cfcfd8dad5e 100644
--- a/drivers/sh/maple/maple.c
+++ b/drivers/sh/maple/maple.c
@@ -31,6 +31,7 @@
31#include <asm/mach/dma.h> 31#include <asm/mach/dma.h>
32#include <asm/mach/sysasic.h> 32#include <asm/mach/sysasic.h>
33#include <asm/mach/maple.h> 33#include <asm/mach/maple.h>
34#include <linux/delay.h>
34 35
35MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin"); 36MODULE_AUTHOR("Yaegshi Takeshi, Paul Mundt, M.R. Brown, Adrian McMenamin");
36MODULE_DESCRIPTION("Maple bus driver for Dreamcast"); 37MODULE_DESCRIPTION("Maple bus driver for Dreamcast");
@@ -53,12 +54,12 @@ static struct device maple_bus;
53static int subdevice_map[MAPLE_PORTS]; 54static int subdevice_map[MAPLE_PORTS];
54static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr; 55static unsigned long *maple_sendbuf, *maple_sendptr, *maple_lastptr;
55static unsigned long maple_pnp_time; 56static unsigned long maple_pnp_time;
56static int started, scanning, liststatus; 57static int started, scanning, liststatus, realscan;
57static struct kmem_cache *maple_queue_cache; 58static struct kmem_cache *maple_queue_cache;
58 59
59struct maple_device_specify { 60struct maple_device_specify {
60 int port; 61 int port;
61 int unit; 62 int unit;
62}; 63};
63 64
64/** 65/**
@@ -68,22 +69,22 @@ struct maple_device_specify {
68 */ 69 */
69int maple_driver_register(struct device_driver *drv) 70int maple_driver_register(struct device_driver *drv)
70{ 71{
71 if (!drv) 72 if (!drv)
72 return -EINVAL; 73 return -EINVAL;
73 drv->bus = &maple_bus_type; 74 drv->bus = &maple_bus_type;
74 return driver_register(drv); 75 return driver_register(drv);
75} 76}
76EXPORT_SYMBOL_GPL(maple_driver_register); 77EXPORT_SYMBOL_GPL(maple_driver_register);
77 78
78/* set hardware registers to enable next round of dma */ 79/* set hardware registers to enable next round of dma */
79static void maplebus_dma_reset(void) 80static void maplebus_dma_reset(void)
80{ 81{
81 ctrl_outl(MAPLE_MAGIC, MAPLE_RESET); 82 ctrl_outl(MAPLE_MAGIC, MAPLE_RESET);
82 /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */ 83 /* set trig type to 0 for software trigger, 1 for hardware (VBLANK) */
83 ctrl_outl(1, MAPLE_TRIGTYPE); 84 ctrl_outl(1, MAPLE_TRIGTYPE);
84 ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(50000), MAPLE_SPEED); 85 ctrl_outl(MAPLE_2MBPS | MAPLE_TIMEOUT(50000), MAPLE_SPEED);
85 ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR); 86 ctrl_outl(PHYSADDR(maple_sendbuf), MAPLE_DMAADDR);
86 ctrl_outl(1, MAPLE_ENABLE); 87 ctrl_outl(1, MAPLE_ENABLE);
87} 88}
88 89
89/** 90/**
@@ -94,27 +95,36 @@ static void maplebus_dma_reset(void)
94 * @function: the function code for the device 95 * @function: the function code for the device
95 */ 96 */
96void maple_getcond_callback(struct maple_device *dev, 97void maple_getcond_callback(struct maple_device *dev,
97 void (*callback) (struct mapleq * mq), 98 void (*callback) (struct mapleq *mq),
98 unsigned long interval, unsigned long function) 99 unsigned long interval, unsigned long function)
99{ 100{
100 dev->callback = callback; 101 dev->callback = callback;
101 dev->interval = interval; 102 dev->interval = interval;
102 dev->function = cpu_to_be32(function); 103 dev->function = cpu_to_be32(function);
103 dev->when = jiffies; 104 dev->when = jiffies;
104} 105}
105EXPORT_SYMBOL_GPL(maple_getcond_callback); 106EXPORT_SYMBOL_GPL(maple_getcond_callback);
106 107
107static int maple_dma_done(void) 108static int maple_dma_done(void)
108{ 109{
109 return (ctrl_inl(MAPLE_STATE) & 1) == 0; 110 return (ctrl_inl(MAPLE_STATE) & 1) == 0;
110} 111}
111 112
112static void maple_release_device(struct device *dev) 113static void maple_release_device(struct device *dev)
113{ 114{
114 if (dev->type) { 115 struct maple_device *mdev;
115 kfree(dev->type->name); 116 struct mapleq *mq;
116 kfree(dev->type); 117 if (!dev)
117 } 118 return;
119 mdev = to_maple_dev(dev);
120 mq = mdev->mq;
121 if (mq) {
122 if (mq->recvbufdcsp)
123 kmem_cache_free(maple_queue_cache, mq->recvbufdcsp);
124 kfree(mq);
125 mq = NULL;
126 }
127 kfree(mdev);
118} 128}
119 129
120/** 130/**
@@ -123,60 +133,64 @@ static void maple_release_device(struct device *dev)
123 */ 133 */
124void maple_add_packet(struct mapleq *mq) 134void maple_add_packet(struct mapleq *mq)
125{ 135{
126 mutex_lock(&maple_list_lock); 136 mutex_lock(&maple_list_lock);
127 list_add(&mq->list, &maple_waitq); 137 list_add(&mq->list, &maple_waitq);
128 mutex_unlock(&maple_list_lock); 138 mutex_unlock(&maple_list_lock);
129} 139}
130EXPORT_SYMBOL_GPL(maple_add_packet); 140EXPORT_SYMBOL_GPL(maple_add_packet);
131 141
132static struct mapleq *maple_allocq(struct maple_device *dev) 142static struct mapleq *maple_allocq(struct maple_device *mdev)
133{ 143{
134 struct mapleq *mq; 144 struct mapleq *mq;
135 145
136 mq = kmalloc(sizeof(*mq), GFP_KERNEL); 146 mq = kmalloc(sizeof(*mq), GFP_KERNEL);
137 if (!mq) 147 if (!mq)
138 return NULL; 148 return NULL;
139 149
140 mq->dev = dev; 150 mq->dev = mdev;
141 mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL); 151 mq->recvbufdcsp = kmem_cache_zalloc(maple_queue_cache, GFP_KERNEL);
142 mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp); 152 mq->recvbuf = (void *) P2SEGADDR(mq->recvbufdcsp);
143 if (!mq->recvbuf) { 153 if (!mq->recvbuf) {
144 kfree(mq); 154 kfree(mq);
145 return NULL; 155 return NULL;
146 } 156 }
147 157
148 return mq; 158 return mq;
149} 159}
150 160
151static struct maple_device *maple_alloc_dev(int port, int unit) 161static struct maple_device *maple_alloc_dev(int port, int unit)
152{ 162{
153 struct maple_device *dev; 163 struct maple_device *mdev;
154 164
155 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 165 mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
156 if (!dev) 166 if (!mdev)
157 return NULL; 167 return NULL;
158 168
159 dev->port = port; 169 mdev->port = port;
160 dev->unit = unit; 170 mdev->unit = unit;
161 dev->mq = maple_allocq(dev); 171 mdev->mq = maple_allocq(mdev);
162 172
163 if (!dev->mq) { 173 if (!mdev->mq) {
164 kfree(dev); 174 kfree(mdev);
165 return NULL; 175 return NULL;
166 } 176 }
167 177 mdev->dev.bus = &maple_bus_type;
168 return dev; 178 mdev->dev.parent = &maple_bus;
179 mdev->function = 0;
180 return mdev;
169} 181}
170 182
171static void maple_free_dev(struct maple_device *mdev) 183static void maple_free_dev(struct maple_device *mdev)
172{ 184{
173 if (!mdev) 185 if (!mdev)
174 return; 186 return;
175 if (mdev->mq) { 187 if (mdev->mq) {
176 kmem_cache_free(maple_queue_cache, mdev->mq->recvbufdcsp); 188 if (mdev->mq->recvbufdcsp)
177 kfree(mdev->mq); 189 kmem_cache_free(maple_queue_cache,
178 } 190 mdev->mq->recvbufdcsp);
179 kfree(mdev); 191 kfree(mdev->mq);
192 }
193 kfree(mdev);
180} 194}
181 195
182/* process the command queue into a maple command block 196/* process the command queue into a maple command block
@@ -184,153 +198,162 @@ static void maple_free_dev(struct maple_device *mdev)
184 */ 198 */
185static void maple_build_block(struct mapleq *mq) 199static void maple_build_block(struct mapleq *mq)
186{ 200{
187 int port, unit, from, to, len; 201 int port, unit, from, to, len;
188 unsigned long *lsendbuf = mq->sendbuf; 202 unsigned long *lsendbuf = mq->sendbuf;
189 203
190 port = mq->dev->port & 3; 204 port = mq->dev->port & 3;
191 unit = mq->dev->unit; 205 unit = mq->dev->unit;
192 len = mq->length; 206 len = mq->length;
193 from = port << 6; 207 from = port << 6;
194 to = (port << 6) | (unit > 0 ? (1 << (unit - 1)) & 0x1f : 0x20); 208 to = (port << 6) | (unit > 0 ? (1 << (unit - 1)) & 0x1f : 0x20);
195 209
196 *maple_lastptr &= 0x7fffffff; 210 *maple_lastptr &= 0x7fffffff;
197 maple_lastptr = maple_sendptr; 211 maple_lastptr = maple_sendptr;
198 212
199 *maple_sendptr++ = (port << 16) | len | 0x80000000; 213 *maple_sendptr++ = (port << 16) | len | 0x80000000;
200 *maple_sendptr++ = PHYSADDR(mq->recvbuf); 214 *maple_sendptr++ = PHYSADDR(mq->recvbuf);
201 *maple_sendptr++ = 215 *maple_sendptr++ =
202 mq->command | (to << 8) | (from << 16) | (len << 24); 216 mq->command | (to << 8) | (from << 16) | (len << 24);
203 217
204 while (len-- > 0) 218 while (len-- > 0)
205 *maple_sendptr++ = *lsendbuf++; 219 *maple_sendptr++ = *lsendbuf++;
206} 220}
207 221
208/* build up command queue */ 222/* build up command queue */
209static void maple_send(void) 223static void maple_send(void)
210{ 224{
211 int i; 225 int i;
212 int maple_packets; 226 int maple_packets;
213 struct mapleq *mq, *nmq; 227 struct mapleq *mq, *nmq;
214 228
215 if (!list_empty(&maple_sentq)) 229 if (!list_empty(&maple_sentq))
216 return; 230 return;
217 if (list_empty(&maple_waitq) || !maple_dma_done()) 231 if (list_empty(&maple_waitq) || !maple_dma_done())
218 return; 232 return;
219 maple_packets = 0; 233 maple_packets = 0;
220 maple_sendptr = maple_lastptr = maple_sendbuf; 234 maple_sendptr = maple_lastptr = maple_sendbuf;
221 list_for_each_entry_safe(mq, nmq, &maple_waitq, list) { 235 list_for_each_entry_safe(mq, nmq, &maple_waitq, list) {
222 maple_build_block(mq); 236 maple_build_block(mq);
223 list_move(&mq->list, &maple_sentq); 237 list_move(&mq->list, &maple_sentq);
224 if (maple_packets++ > MAPLE_MAXPACKETS) 238 if (maple_packets++ > MAPLE_MAXPACKETS)
225 break; 239 break;
226 } 240 }
227 if (maple_packets > 0) { 241 if (maple_packets > 0) {
228 for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++) 242 for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++)
229 dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE, 243 dma_cache_sync(0, maple_sendbuf + i * PAGE_SIZE,
230 PAGE_SIZE, DMA_BIDIRECTIONAL); 244 PAGE_SIZE, DMA_BIDIRECTIONAL);
231 } 245 }
232} 246}
233 247
234static int attach_matching_maple_driver(struct device_driver *driver, 248static int attach_matching_maple_driver(struct device_driver *driver,
235 void *devptr) 249 void *devptr)
236{ 250{
237 struct maple_driver *maple_drv; 251 struct maple_driver *maple_drv;
238 struct maple_device *mdev; 252 struct maple_device *mdev;
239 253
240 mdev = devptr; 254 mdev = devptr;
241 maple_drv = to_maple_driver(driver); 255 maple_drv = to_maple_driver(driver);
242 if (mdev->devinfo.function & be32_to_cpu(maple_drv->function)) { 256 if (mdev->devinfo.function & be32_to_cpu(maple_drv->function)) {
243 if (maple_drv->connect(mdev) == 0) { 257 if (maple_drv->connect(mdev) == 0) {
244 mdev->driver = maple_drv; 258 mdev->driver = maple_drv;
245 return 1; 259 return 1;
246 } 260 }
247 } 261 }
248 return 0; 262 return 0;
249} 263}
250 264
251static void maple_detach_driver(struct maple_device *mdev) 265static void maple_detach_driver(struct maple_device *mdev)
252{ 266{
253 if (!mdev) 267 if (!mdev)
254 return; 268 return;
255 if (mdev->driver) { 269 if (mdev->driver) {
256 if (mdev->driver->disconnect) 270 if (mdev->driver->disconnect)
257 mdev->driver->disconnect(mdev); 271 mdev->driver->disconnect(mdev);
258 } 272 }
259 mdev->driver = NULL; 273 mdev->driver = NULL;
260 if (mdev->registered) { 274 device_unregister(&mdev->dev);
261 maple_release_device(&mdev->dev); 275 mdev = NULL;
262 device_unregister(&mdev->dev);
263 }
264 mdev->registered = 0;
265 maple_free_dev(mdev);
266} 276}
267 277
268/* process initial MAPLE_COMMAND_DEVINFO for each device or port */ 278/* process initial MAPLE_COMMAND_DEVINFO for each device or port */
269static void maple_attach_driver(struct maple_device *dev) 279static void maple_attach_driver(struct maple_device *mdev)
270{ 280{
271 char *p; 281 char *p, *recvbuf;
272 282 unsigned long function;
273 char *recvbuf; 283 int matched, retval;
274 unsigned long function; 284
275 int matched, retval; 285 recvbuf = mdev->mq->recvbuf;
276 286 /* copy the data as individual elements in
277 recvbuf = dev->mq->recvbuf; 287 * case of memory optimisation */
278 memcpy(&dev->devinfo, recvbuf + 4, sizeof(dev->devinfo)); 288 memcpy(&mdev->devinfo.function, recvbuf + 4, 4);
279 memcpy(dev->product_name, dev->devinfo.product_name, 30); 289 memcpy(&mdev->devinfo.function_data[0], recvbuf + 8, 12);
280 memcpy(dev->product_licence, dev->devinfo.product_licence, 60); 290 memcpy(&mdev->devinfo.area_code, recvbuf + 20, 1);
281 dev->product_name[30] = '\0'; 291 memcpy(&mdev->devinfo.connector_direction, recvbuf + 21, 1);
282 dev->product_licence[60] = '\0'; 292 memcpy(&mdev->devinfo.product_name[0], recvbuf + 22, 30);
283 293 memcpy(&mdev->devinfo.product_licence[0], recvbuf + 52, 60);
284 for (p = dev->product_name + 29; dev->product_name <= p; p--) 294 memcpy(&mdev->devinfo.standby_power, recvbuf + 112, 2);
285 if (*p == ' ') 295 memcpy(&mdev->devinfo.max_power, recvbuf + 114, 2);
286 *p = '\0'; 296 memcpy(mdev->product_name, mdev->devinfo.product_name, 30);
287 else 297 mdev->product_name[30] = '\0';
288 break; 298 memcpy(mdev->product_licence, mdev->devinfo.product_licence, 60);
289 299 mdev->product_licence[60] = '\0';
290 for (p = dev->product_licence + 59; dev->product_licence <= p; p--) 300
291 if (*p == ' ') 301 for (p = mdev->product_name + 29; mdev->product_name <= p; p--)
292 *p = '\0'; 302 if (*p == ' ')
293 else 303 *p = '\0';
294 break; 304 else
295 305 break;
296 function = be32_to_cpu(dev->devinfo.function); 306 for (p = mdev->product_licence + 59; mdev->product_licence <= p; p--)
297 307 if (*p == ' ')
298 if (function > 0x200) { 308 *p = '\0';
299 /* Do this silently - as not a real device */ 309 else
300 function = 0; 310 break;
301 dev->driver = &maple_dummy_driver; 311
302 sprintf(dev->dev.bus_id, "%d:0.port", dev->port); 312 if (realscan) {
303 } else { 313 printk(KERN_INFO "Maple device detected: %s\n",
304 printk(KERN_INFO 314 mdev->product_name);
305 "Maple bus at (%d, %d): Connected function 0x%lX\n", 315 printk(KERN_INFO "Maple device: %s\n", mdev->product_licence);
306 dev->port, dev->unit, function); 316 }
307 317
308 matched = 318 function = be32_to_cpu(mdev->devinfo.function);
309 bus_for_each_drv(&maple_bus_type, NULL, dev, 319
310 attach_matching_maple_driver); 320 if (function > 0x200) {
311 321 /* Do this silently - as not a real device */
312 if (matched == 0) { 322 function = 0;
313 /* Driver does not exist yet */ 323 mdev->driver = &maple_dummy_driver;
314 printk(KERN_INFO 324 sprintf(mdev->dev.bus_id, "%d:0.port", mdev->port);
315 "No maple driver found for this device\n"); 325 } else {
316 dev->driver = &maple_dummy_driver; 326 if (realscan)
317 } 327 printk(KERN_INFO
318 328 "Maple bus at (%d, %d): Function 0x%lX\n",
319 sprintf(dev->dev.bus_id, "%d:0%d.%lX", dev->port, 329 mdev->port, mdev->unit, function);
320 dev->unit, function); 330
321 } 331 matched =
322 dev->function = function; 332 bus_for_each_drv(&maple_bus_type, NULL, mdev,
323 dev->dev.bus = &maple_bus_type; 333 attach_matching_maple_driver);
324 dev->dev.parent = &maple_bus; 334
325 dev->dev.release = &maple_release_device; 335 if (matched == 0) {
326 retval = device_register(&dev->dev); 336 /* Driver does not exist yet */
327 if (retval) { 337 if (realscan)
328 printk(KERN_INFO 338 printk(KERN_INFO
329 "Maple bus: Attempt to register device (%x, %x) failed.\n", 339 "No maple driver found.\n");
330 dev->port, dev->unit); 340 mdev->driver = &maple_dummy_driver;
331 maple_free_dev(dev); 341 }
332 } 342 sprintf(mdev->dev.bus_id, "%d:0%d.%lX", mdev->port,
333 dev->registered = 1; 343 mdev->unit, function);
344 }
345 mdev->function = function;
346 mdev->dev.release = &maple_release_device;
347 retval = device_register(&mdev->dev);
348 if (retval) {
349 printk(KERN_INFO
350 "Maple bus: Attempt to register device"
351 " (%x, %x) failed.\n",
352 mdev->port, mdev->unit);
353 maple_free_dev(mdev);
354 mdev = NULL;
355 return;
356 }
334} 357}
335 358
336/* 359/*
@@ -340,270 +363,262 @@ static void maple_attach_driver(struct maple_device *dev)
340 */ 363 */
341static int detach_maple_device(struct device *device, void *portptr) 364static int detach_maple_device(struct device *device, void *portptr)
342{ 365{
343 struct maple_device_specify *ds; 366 struct maple_device_specify *ds;
344 struct maple_device *mdev; 367 struct maple_device *mdev;
345 368
346 ds = portptr; 369 ds = portptr;
347 mdev = to_maple_dev(device); 370 mdev = to_maple_dev(device);
348 if (mdev->port == ds->port && mdev->unit == ds->unit) 371 if (mdev->port == ds->port && mdev->unit == ds->unit)
349 return 1; 372 return 1;
350 return 0; 373 return 0;
351} 374}
352 375
353static int setup_maple_commands(struct device *device, void *ignored) 376static int setup_maple_commands(struct device *device, void *ignored)
354{ 377{
355 struct maple_device *maple_dev = to_maple_dev(device); 378 struct maple_device *maple_dev = to_maple_dev(device);
356 379
357 if ((maple_dev->interval > 0) 380 if ((maple_dev->interval > 0)
358 && time_after(jiffies, maple_dev->when)) { 381 && time_after(jiffies, maple_dev->when)) {
359 maple_dev->when = jiffies + maple_dev->interval; 382 maple_dev->when = jiffies + maple_dev->interval;
360 maple_dev->mq->command = MAPLE_COMMAND_GETCOND; 383 maple_dev->mq->command = MAPLE_COMMAND_GETCOND;
361 maple_dev->mq->sendbuf = &maple_dev->function; 384 maple_dev->mq->sendbuf = &maple_dev->function;
362 maple_dev->mq->length = 1; 385 maple_dev->mq->length = 1;
363 maple_add_packet(maple_dev->mq); 386 maple_add_packet(maple_dev->mq);
364 liststatus++; 387 liststatus++;
365 } else { 388 } else {
366 if (time_after(jiffies, maple_pnp_time)) { 389 if (time_after(jiffies, maple_pnp_time)) {
367 maple_dev->mq->command = MAPLE_COMMAND_DEVINFO; 390 maple_dev->mq->command = MAPLE_COMMAND_DEVINFO;
368 maple_dev->mq->length = 0; 391 maple_dev->mq->length = 0;
369 maple_add_packet(maple_dev->mq); 392 maple_add_packet(maple_dev->mq);
370 liststatus++; 393 liststatus++;
371 } 394 }
372 } 395 }
373 396
374 return 0; 397 return 0;
375} 398}
376 399
377/* VBLANK bottom half - implemented via workqueue */ 400/* VBLANK bottom half - implemented via workqueue */
378static void maple_vblank_handler(struct work_struct *work) 401static void maple_vblank_handler(struct work_struct *work)
379{ 402{
380 if (!maple_dma_done()) 403 if (!maple_dma_done())
381 return; 404 return;
382 if (!list_empty(&maple_sentq)) 405 if (!list_empty(&maple_sentq))
383 return; 406 return;
384 ctrl_outl(0, MAPLE_ENABLE); 407 ctrl_outl(0, MAPLE_ENABLE);
385 liststatus = 0; 408 liststatus = 0;
386 bus_for_each_dev(&maple_bus_type, NULL, NULL, 409 bus_for_each_dev(&maple_bus_type, NULL, NULL,
387 setup_maple_commands); 410 setup_maple_commands);
388 if (time_after(jiffies, maple_pnp_time)) 411 if (time_after(jiffies, maple_pnp_time))
389 maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL; 412 maple_pnp_time = jiffies + MAPLE_PNP_INTERVAL;
390 if (liststatus && list_empty(&maple_sentq)) { 413 if (liststatus && list_empty(&maple_sentq)) {
391 INIT_LIST_HEAD(&maple_sentq); 414 INIT_LIST_HEAD(&maple_sentq);
392 maple_send(); 415 maple_send();
393 } 416 }
394 maplebus_dma_reset(); 417 maplebus_dma_reset();
395} 418}
396 419
397/* handle devices added via hotplugs - placing them on queue for DEVINFO*/ 420/* handle devices added via hotplugs - placing them on queue for DEVINFO*/
398static void maple_map_subunits(struct maple_device *mdev, int submask) 421static void maple_map_subunits(struct maple_device *mdev, int submask)
399{ 422{
400 int retval, k, devcheck; 423 int retval, k, devcheck;
401 struct maple_device *mdev_add; 424 struct maple_device *mdev_add;
402 struct maple_device_specify ds; 425 struct maple_device_specify ds;
403 426
404 for (k = 0; k < 5; k++) { 427 for (k = 0; k < 5; k++) {
405 ds.port = mdev->port; 428 ds.port = mdev->port;
406 ds.unit = k + 1; 429 ds.unit = k + 1;
407 retval = 430 retval =
408 bus_for_each_dev(&maple_bus_type, NULL, &ds, 431 bus_for_each_dev(&maple_bus_type, NULL, &ds,
409 detach_maple_device); 432 detach_maple_device);
410 if (retval) { 433 if (retval) {
411 submask = submask >> 1; 434 submask = submask >> 1;
412 continue; 435 continue;
413 } 436 }
414 devcheck = submask & 0x01; 437 devcheck = submask & 0x01;
415 if (devcheck) { 438 if (devcheck) {
416 mdev_add = maple_alloc_dev(mdev->port, k + 1); 439 mdev_add = maple_alloc_dev(mdev->port, k + 1);
417 if (!mdev_add) 440 if (!mdev_add)
418 return; 441 return;
419 mdev_add->mq->command = MAPLE_COMMAND_DEVINFO; 442 mdev_add->mq->command = MAPLE_COMMAND_DEVINFO;
420 mdev_add->mq->length = 0; 443 mdev_add->mq->length = 0;
421 maple_add_packet(mdev_add->mq); 444 maple_add_packet(mdev_add->mq);
422 scanning = 1; 445 scanning = 1;
423 } 446 }
424 submask = submask >> 1; 447 submask = submask >> 1;
425 } 448 }
426} 449}
427 450
428/* mark a device as removed */ 451/* mark a device as removed */
429static void maple_clean_submap(struct maple_device *mdev) 452static void maple_clean_submap(struct maple_device *mdev)
430{ 453{
431 int killbit; 454 int killbit;
432 455
433 killbit = (mdev->unit > 0 ? (1 << (mdev->unit - 1)) & 0x1f : 0x20); 456 killbit = (mdev->unit > 0 ? (1 << (mdev->unit - 1)) & 0x1f : 0x20);
434 killbit = ~killbit; 457 killbit = ~killbit;
435 killbit &= 0xFF; 458 killbit &= 0xFF;
436 subdevice_map[mdev->port] = subdevice_map[mdev->port] & killbit; 459 subdevice_map[mdev->port] = subdevice_map[mdev->port] & killbit;
437} 460}
438 461
439/* handle empty port or hotplug removal */ 462/* handle empty port or hotplug removal */
440static void maple_response_none(struct maple_device *mdev, 463static void maple_response_none(struct maple_device *mdev,
441 struct mapleq *mq) 464 struct mapleq *mq)
442{ 465{
443 if (mdev->unit != 0) { 466 if (mdev->unit != 0) {
444 list_del(&mq->list); 467 list_del(&mq->list);
445 maple_clean_submap(mdev); 468 maple_clean_submap(mdev);
446 printk(KERN_INFO 469 printk(KERN_INFO
447 "Maple bus device detaching at (%d, %d)\n", 470 "Maple bus device detaching at (%d, %d)\n",
448 mdev->port, mdev->unit); 471 mdev->port, mdev->unit);
449 maple_detach_driver(mdev); 472 maple_detach_driver(mdev);
450 return; 473 return;
451 } 474 }
452 if (!started) { 475 if (!started) {
453 printk(KERN_INFO "No maple devices attached to port %d\n", 476 printk(KERN_INFO "No maple devices attached to port %d\n",
454 mdev->port); 477 mdev->port);
455 return; 478 return;
456 } 479 }
457 maple_clean_submap(mdev); 480 maple_clean_submap(mdev);
458} 481}
459 482
460/* preprocess hotplugs or scans */ 483/* preprocess hotplugs or scans */
461static void maple_response_devinfo(struct maple_device *mdev, 484static void maple_response_devinfo(struct maple_device *mdev,
462 char *recvbuf) 485 char *recvbuf)
463{ 486{
464 char submask; 487 char submask;
465 if ((!started) || (scanning == 2)) { 488 if ((!started) || (scanning == 2)) {
466 maple_attach_driver(mdev); 489 maple_attach_driver(mdev);
467 return; 490 return;
468 } 491 }
469 if (mdev->unit == 0) { 492 if (mdev->unit == 0) {
470 submask = recvbuf[2] & 0x1F; 493 submask = recvbuf[2] & 0x1F;
471 if (submask ^ subdevice_map[mdev->port]) { 494 if (submask ^ subdevice_map[mdev->port]) {
472 maple_map_subunits(mdev, submask); 495 maple_map_subunits(mdev, submask);
473 subdevice_map[mdev->port] = submask; 496 subdevice_map[mdev->port] = submask;
474 } 497 }
475 } 498 }
476} 499}
477 500
478/* maple dma end bottom half - implemented via workqueue */ 501/* maple dma end bottom half - implemented via workqueue */
479static void maple_dma_handler(struct work_struct *work) 502static void maple_dma_handler(struct work_struct *work)
480{ 503{
481 struct mapleq *mq, *nmq; 504 struct mapleq *mq, *nmq;
482 struct maple_device *dev; 505 struct maple_device *dev;
483 char *recvbuf; 506 char *recvbuf;
484 enum maple_code code; 507 enum maple_code code;
485 508
486 if (!maple_dma_done()) 509 if (!maple_dma_done())
487 return; 510 return;
488 ctrl_outl(0, MAPLE_ENABLE); 511 ctrl_outl(0, MAPLE_ENABLE);
489 if (!list_empty(&maple_sentq)) { 512 if (!list_empty(&maple_sentq)) {
490 list_for_each_entry_safe(mq, nmq, &maple_sentq, list) { 513 list_for_each_entry_safe(mq, nmq, &maple_sentq, list) {
491 recvbuf = mq->recvbuf; 514 recvbuf = mq->recvbuf;
492 code = recvbuf[0]; 515 code = recvbuf[0];
493 dev = mq->dev; 516 dev = mq->dev;
494 switch (code) { 517 switch (code) {
495 case MAPLE_RESPONSE_NONE: 518 case MAPLE_RESPONSE_NONE:
496 maple_response_none(dev, mq); 519 maple_response_none(dev, mq);
497 break; 520 break;
498 521
499 case MAPLE_RESPONSE_DEVINFO: 522 case MAPLE_RESPONSE_DEVINFO:
500 maple_response_devinfo(dev, recvbuf); 523 maple_response_devinfo(dev, recvbuf);
501 break; 524 break;
502 525
503 case MAPLE_RESPONSE_DATATRF: 526 case MAPLE_RESPONSE_DATATRF:
504 if (dev->callback) 527 if (dev->callback)
505 dev->callback(mq); 528 dev->callback(mq);
506 break; 529 break;
507 530
508 case MAPLE_RESPONSE_FILEERR: 531 case MAPLE_RESPONSE_FILEERR:
509 case MAPLE_RESPONSE_AGAIN: 532 case MAPLE_RESPONSE_AGAIN:
510 case MAPLE_RESPONSE_BADCMD: 533 case MAPLE_RESPONSE_BADCMD:
511 case MAPLE_RESPONSE_BADFUNC: 534 case MAPLE_RESPONSE_BADFUNC:
512 printk(KERN_DEBUG 535 printk(KERN_DEBUG
513 "Maple non-fatal error 0x%X\n", 536 "Maple non-fatal error 0x%X\n",
514 code); 537 code);
515 break; 538 break;
516 539
517 case MAPLE_RESPONSE_ALLINFO: 540 case MAPLE_RESPONSE_ALLINFO:
518 printk(KERN_DEBUG 541 printk(KERN_DEBUG
519 "Maple - extended device information not supported\n"); 542 "Maple - extended device information"
520 break; 543 " not supported\n");
521 544 break;
522 case MAPLE_RESPONSE_OK: 545
523 break; 546 case MAPLE_RESPONSE_OK:
524 547 break;
525 default: 548
526 break; 549 default:
527 } 550 break;
528 } 551 }
529 INIT_LIST_HEAD(&maple_sentq); 552 }
530 if (scanning == 1) { 553 INIT_LIST_HEAD(&maple_sentq);
531 maple_send(); 554 if (scanning == 1) {
532 scanning = 2; 555 maple_send();
533 } else 556 scanning = 2;
534 scanning = 0; 557 } else
535 558 scanning = 0;
536 if (started == 0) 559
537 started = 1; 560 if (started == 0)
538 } 561 started = 1;
539 maplebus_dma_reset(); 562 }
563 maplebus_dma_reset();
540} 564}
541 565
542static irqreturn_t maplebus_dma_interrupt(int irq, void *dev_id) 566static irqreturn_t maplebus_dma_interrupt(int irq, void *dev_id)
543{ 567{
544 /* Load everything into the bottom half */ 568 /* Load everything into the bottom half */
545 schedule_work(&maple_dma_process); 569 schedule_work(&maple_dma_process);
546 return IRQ_HANDLED; 570 return IRQ_HANDLED;
547} 571}
548 572
549static irqreturn_t maplebus_vblank_interrupt(int irq, void *dev_id) 573static irqreturn_t maplebus_vblank_interrupt(int irq, void *dev_id)
550{ 574{
551 schedule_work(&maple_vblank_process); 575 schedule_work(&maple_vblank_process);
552 return IRQ_HANDLED; 576 return IRQ_HANDLED;
553} 577}
554 578
555static struct irqaction maple_dma_irq = {
556 .name = "maple bus DMA handler",
557 .handler = maplebus_dma_interrupt,
558 .flags = IRQF_SHARED,
559};
560
561static struct irqaction maple_vblank_irq = {
562 .name = "maple bus VBLANK handler",
563 .handler = maplebus_vblank_interrupt,
564 .flags = IRQF_SHARED,
565};
566
567static int maple_set_dma_interrupt_handler(void) 579static int maple_set_dma_interrupt_handler(void)
568{ 580{
569 return setup_irq(HW_EVENT_MAPLE_DMA, &maple_dma_irq); 581 return request_irq(HW_EVENT_MAPLE_DMA, maplebus_dma_interrupt,
582 IRQF_SHARED, "maple bus DMA", &maple_dummy_driver);
570} 583}
571 584
572static int maple_set_vblank_interrupt_handler(void) 585static int maple_set_vblank_interrupt_handler(void)
573{ 586{
574 return setup_irq(HW_EVENT_VSYNC, &maple_vblank_irq); 587 return request_irq(HW_EVENT_VSYNC, maplebus_vblank_interrupt,
588 IRQF_SHARED, "maple bus VBLANK", &maple_dummy_driver);
575} 589}
576 590
577static int maple_get_dma_buffer(void) 591static int maple_get_dma_buffer(void)
578{ 592{
579 maple_sendbuf = 593 maple_sendbuf =
580 (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO, 594 (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
581 MAPLE_DMA_PAGES); 595 MAPLE_DMA_PAGES);
582 if (!maple_sendbuf) 596 if (!maple_sendbuf)
583 return -ENOMEM; 597 return -ENOMEM;
584 return 0; 598 return 0;
585} 599}
586 600
587static int match_maple_bus_driver(struct device *devptr, 601static int match_maple_bus_driver(struct device *devptr,
588 struct device_driver *drvptr) 602 struct device_driver *drvptr)
589{ 603{
590 struct maple_driver *maple_drv; 604 struct maple_driver *maple_drv;
591 struct maple_device *maple_dev; 605 struct maple_device *maple_dev;
592 606
593 maple_drv = container_of(drvptr, struct maple_driver, drv); 607 maple_drv = container_of(drvptr, struct maple_driver, drv);
594 maple_dev = container_of(devptr, struct maple_device, dev); 608 maple_dev = container_of(devptr, struct maple_device, dev);
595 /* Trap empty port case */ 609 /* Trap empty port case */
596 if (maple_dev->devinfo.function == 0xFFFFFFFF) 610 if (maple_dev->devinfo.function == 0xFFFFFFFF)
597 return 0; 611 return 0;
598 else if (maple_dev->devinfo.function & 612 else if (maple_dev->devinfo.function &
599 be32_to_cpu(maple_drv->function)) 613 be32_to_cpu(maple_drv->function))
600 return 1; 614 return 1;
601 return 0; 615 return 0;
602} 616}
603 617
604static int maple_bus_uevent(struct device *dev, struct kobj_uevent_env *env) 618static int maple_bus_uevent(struct device *dev,
619 struct kobj_uevent_env *env)
605{ 620{
606 return 0; 621 return 0;
607} 622}
608 623
609static void maple_bus_release(struct device *dev) 624static void maple_bus_release(struct device *dev)
@@ -611,124 +626,122 @@ static void maple_bus_release(struct device *dev)
611} 626}
612 627
613static struct maple_driver maple_dummy_driver = { 628static struct maple_driver maple_dummy_driver = {
614 .drv = { 629 .drv = {
615 .name = "maple_dummy_driver", 630 .name = "maple_dummy_driver",
616 .bus = &maple_bus_type, 631 .bus = &maple_bus_type,
617 }, 632 },
618}; 633};
619 634
620struct bus_type maple_bus_type = { 635struct bus_type maple_bus_type = {
621 .name = "maple", 636 .name = "maple",
622 .match = match_maple_bus_driver, 637 .match = match_maple_bus_driver,
623 .uevent = maple_bus_uevent, 638 .uevent = maple_bus_uevent,
624}; 639};
625EXPORT_SYMBOL_GPL(maple_bus_type); 640EXPORT_SYMBOL_GPL(maple_bus_type);
626 641
627static struct device maple_bus = { 642static struct device maple_bus = {
628 .bus_id = "maple", 643 .bus_id = "maple",
629 .release = maple_bus_release, 644 .release = maple_bus_release,
630}; 645};
631 646
632static int __init maple_bus_init(void) 647static int __init maple_bus_init(void)
633{ 648{
634 int retval, i; 649 int retval, i;
635 struct maple_device *mdev[MAPLE_PORTS]; 650 struct maple_device *mdev[MAPLE_PORTS];
636 ctrl_outl(0, MAPLE_STATE); 651 ctrl_outl(0, MAPLE_STATE);
637 652
638 retval = device_register(&maple_bus); 653 retval = device_register(&maple_bus);
639 if (retval) 654 if (retval)
640 goto cleanup; 655 goto cleanup;
641 656
642 retval = bus_register(&maple_bus_type); 657 retval = bus_register(&maple_bus_type);
643 if (retval) 658 if (retval)
644 goto cleanup_device; 659 goto cleanup_device;
645 660
646 retval = driver_register(&maple_dummy_driver.drv); 661 retval = driver_register(&maple_dummy_driver.drv);
647 662 if (retval)
648 if (retval) 663 goto cleanup_bus;
649 goto cleanup_bus; 664
650 665 /* allocate memory for maple bus dma */
651 /* allocate memory for maple bus dma */ 666 retval = maple_get_dma_buffer();
652 retval = maple_get_dma_buffer(); 667 if (retval) {
653 if (retval) { 668 printk(KERN_INFO
654 printk(KERN_INFO 669 "Maple bus: Failed to allocate Maple DMA buffers\n");
655 "Maple bus: Failed to allocate Maple DMA buffers\n"); 670 goto cleanup_basic;
656 goto cleanup_basic; 671 }
657 } 672
658 673 /* set up DMA interrupt handler */
659 /* set up DMA interrupt handler */ 674 retval = maple_set_dma_interrupt_handler();
660 retval = maple_set_dma_interrupt_handler(); 675 if (retval) {
661 if (retval) { 676 printk(KERN_INFO
662 printk(KERN_INFO 677 "Maple bus: Failed to grab maple DMA IRQ\n");
663 "Maple bus: Failed to grab maple DMA IRQ\n"); 678 goto cleanup_dma;
664 goto cleanup_dma; 679 }
665 } 680
666 681 /* set up VBLANK interrupt handler */
667 /* set up VBLANK interrupt handler */ 682 retval = maple_set_vblank_interrupt_handler();
668 retval = maple_set_vblank_interrupt_handler(); 683 if (retval) {
669 if (retval) { 684 printk(KERN_INFO "Maple bus: Failed to grab VBLANK IRQ\n");
670 printk(KERN_INFO "Maple bus: Failed to grab VBLANK IRQ\n"); 685 goto cleanup_irq;
671 goto cleanup_irq; 686 }
672 } 687
673 688 maple_queue_cache =
674 maple_queue_cache = 689 kmem_cache_create("maple_queue_cache", 0x400, 0,
675 kmem_cache_create("maple_queue_cache", 0x400, 0, 690 SLAB_POISON|SLAB_HWCACHE_ALIGN, NULL);
676 SLAB_HWCACHE_ALIGN, NULL); 691
677 692 if (!maple_queue_cache)
678 if (!maple_queue_cache) 693 goto cleanup_bothirqs;
679 goto cleanup_bothirqs; 694
680 695 /* setup maple ports */
681 /* setup maple ports */ 696 for (i = 0; i < MAPLE_PORTS; i++) {
682 for (i = 0; i < MAPLE_PORTS; i++) { 697 mdev[i] = maple_alloc_dev(i, 0);
683 mdev[i] = maple_alloc_dev(i, 0); 698 if (!mdev[i]) {
684 if (!mdev[i]) { 699 while (i-- > 0)
685 while (i-- > 0) 700 maple_free_dev(mdev[i]);
686 maple_free_dev(mdev[i]); 701 goto cleanup_cache;
687 goto cleanup_cache; 702 }
688 } 703 mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO;
689 mdev[i]->registered = 0; 704 mdev[i]->mq->length = 0;
690 mdev[i]->mq->command = MAPLE_COMMAND_DEVINFO; 705 maple_add_packet(mdev[i]->mq);
691 mdev[i]->mq->length = 0; 706 /* delay aids hardware detection */
692 maple_attach_driver(mdev[i]); 707 mdelay(5);
693 maple_add_packet(mdev[i]->mq); 708 subdevice_map[i] = 0;
694 subdevice_map[i] = 0; 709 }
695 } 710
696 711 realscan = 1;
697 /* setup maplebus hardware */ 712 /* setup maplebus hardware */
698 maplebus_dma_reset(); 713 maplebus_dma_reset();
699 714 /* initial detection */
700 /* initial detection */ 715 maple_send();
701 maple_send(); 716 maple_pnp_time = jiffies;
702 717 printk(KERN_INFO "Maple bus core now registered.\n");
703 maple_pnp_time = jiffies; 718
704 719 return 0;
705 printk(KERN_INFO "Maple bus core now registered.\n");
706
707 return 0;
708 720
709cleanup_cache: 721cleanup_cache:
710 kmem_cache_destroy(maple_queue_cache); 722 kmem_cache_destroy(maple_queue_cache);
711 723
712cleanup_bothirqs: 724cleanup_bothirqs:
713 free_irq(HW_EVENT_VSYNC, 0); 725 free_irq(HW_EVENT_VSYNC, 0);
714 726
715cleanup_irq: 727cleanup_irq:
716 free_irq(HW_EVENT_MAPLE_DMA, 0); 728 free_irq(HW_EVENT_MAPLE_DMA, 0);
717 729
718cleanup_dma: 730cleanup_dma:
719 free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES); 731 free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES);
720 732
721cleanup_basic: 733cleanup_basic:
722 driver_unregister(&maple_dummy_driver.drv); 734 driver_unregister(&maple_dummy_driver.drv);
723 735
724cleanup_bus: 736cleanup_bus:
725 bus_unregister(&maple_bus_type); 737 bus_unregister(&maple_bus_type);
726 738
727cleanup_device: 739cleanup_device:
728 device_unregister(&maple_bus); 740 device_unregister(&maple_bus);
729 741
730cleanup: 742cleanup:
731 printk(KERN_INFO "Maple bus registration failed\n"); 743 printk(KERN_INFO "Maple bus registration failed\n");
732 return retval; 744 return retval;
733} 745}
734subsys_initcall(maple_bus_init); 746/* Push init to later to ensure hardware gets detected */
747fs_initcall(maple_bus_init);
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index 3301167d4f2a..017a196d041f 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -3563,8 +3563,7 @@ static ssize_t show_file(struct device *dev, struct device_attribute *attr,
3563 3563
3564 down_read(&fsg->filesem); 3564 down_read(&fsg->filesem);
3565 if (backing_file_is_open(curlun)) { // Get the complete pathname 3565 if (backing_file_is_open(curlun)) { // Get the complete pathname
3566 p = d_path(curlun->filp->f_path.dentry, 3566 p = d_path(&curlun->filp->f_path, buf, PAGE_SIZE - 1);
3567 curlun->filp->f_path.mnt, buf, PAGE_SIZE - 1);
3568 if (IS_ERR(p)) 3567 if (IS_ERR(p))
3569 rc = PTR_ERR(p); 3568 rc = PTR_ERR(p);
3570 else { 3569 else {
@@ -3981,9 +3980,8 @@ static int __init fsg_bind(struct usb_gadget *gadget)
3981 if (backing_file_is_open(curlun)) { 3980 if (backing_file_is_open(curlun)) {
3982 p = NULL; 3981 p = NULL;
3983 if (pathbuf) { 3982 if (pathbuf) {
3984 p = d_path(curlun->filp->f_path.dentry, 3983 p = d_path(&curlun->filp->f_path,
3985 curlun->filp->f_path.mnt, 3984 pathbuf, PATH_MAX);
3986 pathbuf, PATH_MAX);
3987 if (IS_ERR(p)) 3985 if (IS_ERR(p))
3988 p = NULL; 3986 p = NULL;
3989 } 3987 }
diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c
index 5ce43b63c60e..a3510b8ba3e7 100644
--- a/fs/afs/mntpt.c
+++ b/fs/afs/mntpt.c
@@ -218,16 +218,16 @@ static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
218 _enter("%p{%s},{%s:%p{%s},}", 218 _enter("%p{%s},{%s:%p{%s},}",
219 dentry, 219 dentry,
220 dentry->d_name.name, 220 dentry->d_name.name,
221 nd->mnt->mnt_devname, 221 nd->path.mnt->mnt_devname,
222 dentry, 222 dentry,
223 nd->dentry->d_name.name); 223 nd->path.dentry->d_name.name);
224 224
225 dput(nd->dentry); 225 dput(nd->path.dentry);
226 nd->dentry = dget(dentry); 226 nd->path.dentry = dget(dentry);
227 227
228 newmnt = afs_mntpt_do_automount(nd->dentry); 228 newmnt = afs_mntpt_do_automount(nd->path.dentry);
229 if (IS_ERR(newmnt)) { 229 if (IS_ERR(newmnt)) {
230 path_release(nd); 230 path_put(&nd->path);
231 return (void *)newmnt; 231 return (void *)newmnt;
232 } 232 }
233 233
@@ -235,17 +235,16 @@ static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd)
235 err = do_add_mount(newmnt, nd, MNT_SHRINKABLE, &afs_vfsmounts); 235 err = do_add_mount(newmnt, nd, MNT_SHRINKABLE, &afs_vfsmounts);
236 switch (err) { 236 switch (err) {
237 case 0: 237 case 0:
238 dput(nd->dentry); 238 path_put(&nd->path);
239 mntput(nd->mnt); 239 nd->path.mnt = newmnt;
240 nd->mnt = newmnt; 240 nd->path.dentry = dget(newmnt->mnt_root);
241 nd->dentry = dget(newmnt->mnt_root);
242 schedule_delayed_work(&afs_mntpt_expiry_timer, 241 schedule_delayed_work(&afs_mntpt_expiry_timer,
243 afs_mntpt_expiry_timeout * HZ); 242 afs_mntpt_expiry_timeout * HZ);
244 break; 243 break;
245 case -EBUSY: 244 case -EBUSY:
246 /* someone else made a mount here whilst we were busy */ 245 /* someone else made a mount here whilst we were busy */
247 while (d_mountpoint(nd->dentry) && 246 while (d_mountpoint(nd->path.dentry) &&
248 follow_down(&nd->mnt, &nd->dentry)) 247 follow_down(&nd->path.mnt, &nd->path.dentry))
249 ; 248 ;
250 err = 0; 249 err = 0;
251 default: 250 default:
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 2bbcc8151dc3..a54a946a50ae 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -368,7 +368,8 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
368 * so we don't need to follow the mount. 368 * so we don't need to follow the mount.
369 */ 369 */
370 if (d_mountpoint(dentry)) { 370 if (d_mountpoint(dentry)) {
371 if (!autofs4_follow_mount(&nd->mnt, &nd->dentry)) { 371 if (!autofs4_follow_mount(&nd->path.mnt,
372 &nd->path.dentry)) {
372 status = -ENOENT; 373 status = -ENOENT;
373 goto out_error; 374 goto out_error;
374 } 375 }
@@ -382,7 +383,7 @@ done:
382 return NULL; 383 return NULL;
383 384
384out_error: 385out_error:
385 path_release(nd); 386 path_put(&nd->path);
386 return ERR_PTR(status); 387 return ERR_PTR(status);
387} 388}
388 389
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index d8a02f1e08cc..0498b181dd52 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -443,12 +443,12 @@ static int load_flat_file(struct linux_binprm * bprm,
443 443
444 if (strncmp(hdr->magic, "bFLT", 4)) { 444 if (strncmp(hdr->magic, "bFLT", 4)) {
445 /* 445 /*
446 * Previously, here was a printk to tell people
447 * "BINFMT_FLAT: bad header magic".
448 * But for the kernel which also use ELF FD-PIC format, this
449 * error message is confusing.
446 * because a lot of people do not manage to produce good 450 * because a lot of people do not manage to produce good
447 * flat binaries, we leave this printk to help them realise
448 * the problem. We only print the error if its not a script file
449 */ 451 */
450 if (strncmp(hdr->magic, "#!", 2))
451 printk("BINFMT_FLAT: bad header magic\n");
452 ret = -ENOEXEC; 452 ret = -ENOEXEC;
453 goto err; 453 goto err;
454 } 454 }
diff --git a/fs/block_dev.c b/fs/block_dev.c
index e63067d25cdb..67fe72ce6ac7 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1397,19 +1397,19 @@ struct block_device *lookup_bdev(const char *path)
1397 if (error) 1397 if (error)
1398 return ERR_PTR(error); 1398 return ERR_PTR(error);
1399 1399
1400 inode = nd.dentry->d_inode; 1400 inode = nd.path.dentry->d_inode;
1401 error = -ENOTBLK; 1401 error = -ENOTBLK;
1402 if (!S_ISBLK(inode->i_mode)) 1402 if (!S_ISBLK(inode->i_mode))
1403 goto fail; 1403 goto fail;
1404 error = -EACCES; 1404 error = -EACCES;
1405 if (nd.mnt->mnt_flags & MNT_NODEV) 1405 if (nd.path.mnt->mnt_flags & MNT_NODEV)
1406 goto fail; 1406 goto fail;
1407 error = -ENOMEM; 1407 error = -ENOMEM;
1408 bdev = bd_acquire(inode); 1408 bdev = bd_acquire(inode);
1409 if (!bdev) 1409 if (!bdev)
1410 goto fail; 1410 goto fail;
1411out: 1411out:
1412 path_release(&nd); 1412 path_put(&nd.path);
1413 return bdev; 1413 return bdev;
1414fail: 1414fail:
1415 bdev = ERR_PTR(error); 1415 bdev = ERR_PTR(error);
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index 413ee2349d1a..6ad447529961 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -259,18 +259,18 @@ static int add_mount_helper(struct vfsmount *newmnt, struct nameidata *nd,
259 int err; 259 int err;
260 260
261 mntget(newmnt); 261 mntget(newmnt);
262 err = do_add_mount(newmnt, nd, nd->mnt->mnt_flags, mntlist); 262 err = do_add_mount(newmnt, nd, nd->path.mnt->mnt_flags, mntlist);
263 switch (err) { 263 switch (err) {
264 case 0: 264 case 0:
265 dput(nd->dentry); 265 dput(nd->path.dentry);
266 mntput(nd->mnt); 266 mntput(nd->path.mnt);
267 nd->mnt = newmnt; 267 nd->path.mnt = newmnt;
268 nd->dentry = dget(newmnt->mnt_root); 268 nd->path.dentry = dget(newmnt->mnt_root);
269 break; 269 break;
270 case -EBUSY: 270 case -EBUSY:
271 /* someone else made a mount here whilst we were busy */ 271 /* someone else made a mount here whilst we were busy */
272 while (d_mountpoint(nd->dentry) && 272 while (d_mountpoint(nd->path.dentry) &&
273 follow_down(&nd->mnt, &nd->dentry)) 273 follow_down(&nd->path.mnt, &nd->path.dentry))
274 ; 274 ;
275 err = 0; 275 err = 0;
276 default: 276 default:
@@ -307,8 +307,8 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
307 307
308 xid = GetXid(); 308 xid = GetXid();
309 309
310 dput(nd->dentry); 310 dput(nd->path.dentry);
311 nd->dentry = dget(dentry); 311 nd->path.dentry = dget(dentry);
312 312
313 cifs_sb = CIFS_SB(dentry->d_inode->i_sb); 313 cifs_sb = CIFS_SB(dentry->d_inode->i_sb);
314 ses = cifs_sb->tcon->ses; 314 ses = cifs_sb->tcon->ses;
@@ -340,7 +340,8 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
340 rc = -EINVAL; 340 rc = -EINVAL;
341 goto out_err; 341 goto out_err;
342 } 342 }
343 mnt = cifs_dfs_do_refmount(nd->mnt, nd->dentry, 343 mnt = cifs_dfs_do_refmount(nd->path.mnt,
344 nd->path.dentry,
344 referrals[i].node_name); 345 referrals[i].node_name);
345 cFYI(1, ("%s: cifs_dfs_do_refmount:%s , mnt:%p", 346 cFYI(1, ("%s: cifs_dfs_do_refmount:%s , mnt:%p",
346 __FUNCTION__, 347 __FUNCTION__,
@@ -357,7 +358,7 @@ cifs_dfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
357 if (IS_ERR(mnt)) 358 if (IS_ERR(mnt))
358 goto out_err; 359 goto out_err;
359 360
360 nd->mnt->mnt_flags |= MNT_SHRINKABLE; 361 nd->path.mnt->mnt_flags |= MNT_SHRINKABLE;
361 rc = add_mount_helper(mnt, nd, &cifs_dfs_automount_list); 362 rc = add_mount_helper(mnt, nd, &cifs_dfs_automount_list);
362 363
363out: 364out:
@@ -367,7 +368,7 @@ out:
367 cFYI(1, ("leaving %s" , __FUNCTION__)); 368 cFYI(1, ("leaving %s" , __FUNCTION__));
368 return ERR_PTR(rc); 369 return ERR_PTR(rc);
369out_err: 370out_err:
370 path_release(nd); 371 path_put(&nd->path);
371 goto out; 372 goto out;
372} 373}
373 374
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index 2bf3026adc80..c21a1f552a63 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -75,12 +75,12 @@ static int coda_pioctl(struct inode * inode, struct file * filp,
75 if ( error ) { 75 if ( error ) {
76 return error; 76 return error;
77 } else { 77 } else {
78 target_inode = nd.dentry->d_inode; 78 target_inode = nd.path.dentry->d_inode;
79 } 79 }
80 80
81 /* return if it is not a Coda inode */ 81 /* return if it is not a Coda inode */
82 if ( target_inode->i_sb != inode->i_sb ) { 82 if ( target_inode->i_sb != inode->i_sb ) {
83 path_release(&nd); 83 path_put(&nd.path);
84 return -EINVAL; 84 return -EINVAL;
85 } 85 }
86 86
@@ -89,7 +89,7 @@ static int coda_pioctl(struct inode * inode, struct file * filp,
89 89
90 error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data); 90 error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);
91 91
92 path_release(&nd); 92 path_put(&nd.path);
93 return error; 93 return error;
94} 94}
95 95
diff --git a/fs/compat.c b/fs/compat.c
index ee80ff341d37..2ce4456aad30 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -241,10 +241,10 @@ asmlinkage long compat_sys_statfs(const char __user *path, struct compat_statfs
241 error = user_path_walk(path, &nd); 241 error = user_path_walk(path, &nd);
242 if (!error) { 242 if (!error) {
243 struct kstatfs tmp; 243 struct kstatfs tmp;
244 error = vfs_statfs(nd.dentry, &tmp); 244 error = vfs_statfs(nd.path.dentry, &tmp);
245 if (!error) 245 if (!error)
246 error = put_compat_statfs(buf, &tmp); 246 error = put_compat_statfs(buf, &tmp);
247 path_release(&nd); 247 path_put(&nd.path);
248 } 248 }
249 return error; 249 return error;
250} 250}
@@ -309,10 +309,10 @@ asmlinkage long compat_sys_statfs64(const char __user *path, compat_size_t sz, s
309 error = user_path_walk(path, &nd); 309 error = user_path_walk(path, &nd);
310 if (!error) { 310 if (!error) {
311 struct kstatfs tmp; 311 struct kstatfs tmp;
312 error = vfs_statfs(nd.dentry, &tmp); 312 error = vfs_statfs(nd.path.dentry, &tmp);
313 if (!error) 313 if (!error)
314 error = put_compat_statfs64(buf, &tmp); 314 error = put_compat_statfs64(buf, &tmp);
315 path_release(&nd); 315 path_put(&nd.path);
316 } 316 }
317 return error; 317 return error;
318} 318}
@@ -702,9 +702,6 @@ static int do_nfs4_super_data_conv(void *raw_data)
702 real->flags = raw->flags; 702 real->flags = raw->flags;
703 real->version = raw->version; 703 real->version = raw->version;
704 } 704 }
705 else {
706 return -EINVAL;
707 }
708 705
709 return 0; 706 return 0;
710} 707}
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index ee32c0eac7c1..c6e72aebd16b 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -2853,7 +2853,7 @@ static void compat_ioctl_error(struct file *filp, unsigned int fd,
2853 /* find the name of the device. */ 2853 /* find the name of the device. */
2854 path = (char *)__get_free_page(GFP_KERNEL); 2854 path = (char *)__get_free_page(GFP_KERNEL);
2855 if (path) { 2855 if (path) {
2856 fn = d_path(filp->f_path.dentry, filp->f_path.mnt, path, PAGE_SIZE); 2856 fn = d_path(&filp->f_path, path, PAGE_SIZE);
2857 if (IS_ERR(fn)) 2857 if (IS_ERR(fn))
2858 fn = "?"; 2858 fn = "?";
2859 } 2859 }
diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c
index 22700d2857da..78929ea84ff2 100644
--- a/fs/configfs/symlink.c
+++ b/fs/configfs/symlink.c
@@ -99,11 +99,11 @@ static int get_target(const char *symname, struct nameidata *nd,
99 99
100 ret = path_lookup(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, nd); 100 ret = path_lookup(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, nd);
101 if (!ret) { 101 if (!ret) {
102 if (nd->dentry->d_sb == configfs_sb) { 102 if (nd->path.dentry->d_sb == configfs_sb) {
103 *target = configfs_get_config_item(nd->dentry); 103 *target = configfs_get_config_item(nd->path.dentry);
104 if (!*target) { 104 if (!*target) {
105 ret = -ENOENT; 105 ret = -ENOENT;
106 path_release(nd); 106 path_put(&nd->path);
107 } 107 }
108 } else 108 } else
109 ret = -EPERM; 109 ret = -EPERM;
@@ -141,7 +141,7 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna
141 ret = create_link(parent_item, target_item, dentry); 141 ret = create_link(parent_item, target_item, dentry);
142 142
143 config_item_put(target_item); 143 config_item_put(target_item);
144 path_release(&nd); 144 path_put(&nd.path);
145 145
146out_put: 146out_put:
147 config_item_put(parent_item); 147 config_item_put(parent_item);
diff --git a/fs/dcache.c b/fs/dcache.c
index 44f6cf23b70e..43455776711e 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -95,6 +95,14 @@ static void d_free(struct dentry *dentry)
95 call_rcu(&dentry->d_u.d_rcu, d_callback); 95 call_rcu(&dentry->d_u.d_rcu, d_callback);
96} 96}
97 97
98static void dentry_lru_remove(struct dentry *dentry)
99{
100 if (!list_empty(&dentry->d_lru)) {
101 list_del_init(&dentry->d_lru);
102 dentry_stat.nr_unused--;
103 }
104}
105
98/* 106/*
99 * Release the dentry's inode, using the filesystem 107 * Release the dentry's inode, using the filesystem
100 * d_iput() operation if defined. 108 * d_iput() operation if defined.
@@ -211,13 +219,7 @@ repeat:
211unhash_it: 219unhash_it:
212 __d_drop(dentry); 220 __d_drop(dentry);
213kill_it: 221kill_it:
214 /* If dentry was on d_lru list 222 dentry_lru_remove(dentry);
215 * delete it from there
216 */
217 if (!list_empty(&dentry->d_lru)) {
218 list_del(&dentry->d_lru);
219 dentry_stat.nr_unused--;
220 }
221 dentry = d_kill(dentry); 223 dentry = d_kill(dentry);
222 if (dentry) 224 if (dentry)
223 goto repeat; 225 goto repeat;
@@ -285,10 +287,7 @@ int d_invalidate(struct dentry * dentry)
285static inline struct dentry * __dget_locked(struct dentry *dentry) 287static inline struct dentry * __dget_locked(struct dentry *dentry)
286{ 288{
287 atomic_inc(&dentry->d_count); 289 atomic_inc(&dentry->d_count);
288 if (!list_empty(&dentry->d_lru)) { 290 dentry_lru_remove(dentry);
289 dentry_stat.nr_unused--;
290 list_del_init(&dentry->d_lru);
291 }
292 return dentry; 291 return dentry;
293} 292}
294 293
@@ -404,10 +403,7 @@ static void prune_one_dentry(struct dentry * dentry)
404 403
405 if (dentry->d_op && dentry->d_op->d_delete) 404 if (dentry->d_op && dentry->d_op->d_delete)
406 dentry->d_op->d_delete(dentry); 405 dentry->d_op->d_delete(dentry);
407 if (!list_empty(&dentry->d_lru)) { 406 dentry_lru_remove(dentry);
408 list_del(&dentry->d_lru);
409 dentry_stat.nr_unused--;
410 }
411 __d_drop(dentry); 407 __d_drop(dentry);
412 dentry = d_kill(dentry); 408 dentry = d_kill(dentry);
413 spin_lock(&dcache_lock); 409 spin_lock(&dcache_lock);
@@ -596,10 +592,7 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry)
596 592
597 /* detach this root from the system */ 593 /* detach this root from the system */
598 spin_lock(&dcache_lock); 594 spin_lock(&dcache_lock);
599 if (!list_empty(&dentry->d_lru)) { 595 dentry_lru_remove(dentry);
600 dentry_stat.nr_unused--;
601 list_del_init(&dentry->d_lru);
602 }
603 __d_drop(dentry); 596 __d_drop(dentry);
604 spin_unlock(&dcache_lock); 597 spin_unlock(&dcache_lock);
605 598
@@ -613,11 +606,7 @@ static void shrink_dcache_for_umount_subtree(struct dentry *dentry)
613 spin_lock(&dcache_lock); 606 spin_lock(&dcache_lock);
614 list_for_each_entry(loop, &dentry->d_subdirs, 607 list_for_each_entry(loop, &dentry->d_subdirs,
615 d_u.d_child) { 608 d_u.d_child) {
616 if (!list_empty(&loop->d_lru)) { 609 dentry_lru_remove(loop);
617 dentry_stat.nr_unused--;
618 list_del_init(&loop->d_lru);
619 }
620
621 __d_drop(loop); 610 __d_drop(loop);
622 cond_resched_lock(&dcache_lock); 611 cond_resched_lock(&dcache_lock);
623 } 612 }
@@ -799,10 +788,7 @@ resume:
799 struct dentry *dentry = list_entry(tmp, struct dentry, d_u.d_child); 788 struct dentry *dentry = list_entry(tmp, struct dentry, d_u.d_child);
800 next = tmp->next; 789 next = tmp->next;
801 790
802 if (!list_empty(&dentry->d_lru)) { 791 dentry_lru_remove(dentry);
803 dentry_stat.nr_unused--;
804 list_del_init(&dentry->d_lru);
805 }
806 /* 792 /*
807 * move only zero ref count dentries to the end 793 * move only zero ref count dentries to the end
808 * of the unused list for prune_dcache 794 * of the unused list for prune_dcache
@@ -1776,9 +1762,8 @@ shouldnt_be_hashed:
1776 * 1762 *
1777 * "buflen" should be positive. Caller holds the dcache_lock. 1763 * "buflen" should be positive. Caller holds the dcache_lock.
1778 */ 1764 */
1779static char * __d_path( struct dentry *dentry, struct vfsmount *vfsmnt, 1765static char *__d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
1780 struct dentry *root, struct vfsmount *rootmnt, 1766 struct path *root, char *buffer, int buflen)
1781 char *buffer, int buflen)
1782{ 1767{
1783 char * end = buffer+buflen; 1768 char * end = buffer+buflen;
1784 char * retval; 1769 char * retval;
@@ -1803,7 +1788,7 @@ static char * __d_path( struct dentry *dentry, struct vfsmount *vfsmnt,
1803 for (;;) { 1788 for (;;) {
1804 struct dentry * parent; 1789 struct dentry * parent;
1805 1790
1806 if (dentry == root && vfsmnt == rootmnt) 1791 if (dentry == root->dentry && vfsmnt == root->mnt)
1807 break; 1792 break;
1808 if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) { 1793 if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
1809 /* Global root? */ 1794 /* Global root? */
@@ -1844,13 +1829,23 @@ Elong:
1844 return ERR_PTR(-ENAMETOOLONG); 1829 return ERR_PTR(-ENAMETOOLONG);
1845} 1830}
1846 1831
1847/* write full pathname into buffer and return start of pathname */ 1832/**
1848char * d_path(struct dentry *dentry, struct vfsmount *vfsmnt, 1833 * d_path - return the path of a dentry
1849 char *buf, int buflen) 1834 * @path: path to report
1835 * @buf: buffer to return value in
1836 * @buflen: buffer length
1837 *
1838 * Convert a dentry into an ASCII path name. If the entry has been deleted
1839 * the string " (deleted)" is appended. Note that this is ambiguous.
1840 *
1841 * Returns the buffer or an error code if the path was too long.
1842 *
1843 * "buflen" should be positive. Caller holds the dcache_lock.
1844 */
1845char *d_path(struct path *path, char *buf, int buflen)
1850{ 1846{
1851 char *res; 1847 char *res;
1852 struct vfsmount *rootmnt; 1848 struct path root;
1853 struct dentry *root;
1854 1849
1855 /* 1850 /*
1856 * We have various synthetic filesystems that never get mounted. On 1851 * We have various synthetic filesystems that never get mounted. On
@@ -1859,18 +1854,17 @@ char * d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
1859 * user wants to identify the object in /proc/pid/fd/. The little hack 1854 * user wants to identify the object in /proc/pid/fd/. The little hack
1860 * below allows us to generate a name for these objects on demand: 1855 * below allows us to generate a name for these objects on demand:
1861 */ 1856 */
1862 if (dentry->d_op && dentry->d_op->d_dname) 1857 if (path->dentry->d_op && path->dentry->d_op->d_dname)
1863 return dentry->d_op->d_dname(dentry, buf, buflen); 1858 return path->dentry->d_op->d_dname(path->dentry, buf, buflen);
1864 1859
1865 read_lock(&current->fs->lock); 1860 read_lock(&current->fs->lock);
1866 rootmnt = mntget(current->fs->rootmnt); 1861 root = current->fs->root;
1867 root = dget(current->fs->root); 1862 path_get(&current->fs->root);
1868 read_unlock(&current->fs->lock); 1863 read_unlock(&current->fs->lock);
1869 spin_lock(&dcache_lock); 1864 spin_lock(&dcache_lock);
1870 res = __d_path(dentry, vfsmnt, root, rootmnt, buf, buflen); 1865 res = __d_path(path->dentry, path->mnt, &root, buf, buflen);
1871 spin_unlock(&dcache_lock); 1866 spin_unlock(&dcache_lock);
1872 dput(root); 1867 path_put(&root);
1873 mntput(rootmnt);
1874 return res; 1868 return res;
1875} 1869}
1876 1870
@@ -1916,28 +1910,27 @@ char *dynamic_dname(struct dentry *dentry, char *buffer, int buflen,
1916asmlinkage long sys_getcwd(char __user *buf, unsigned long size) 1910asmlinkage long sys_getcwd(char __user *buf, unsigned long size)
1917{ 1911{
1918 int error; 1912 int error;
1919 struct vfsmount *pwdmnt, *rootmnt; 1913 struct path pwd, root;
1920 struct dentry *pwd, *root;
1921 char *page = (char *) __get_free_page(GFP_USER); 1914 char *page = (char *) __get_free_page(GFP_USER);
1922 1915
1923 if (!page) 1916 if (!page)
1924 return -ENOMEM; 1917 return -ENOMEM;
1925 1918
1926 read_lock(&current->fs->lock); 1919 read_lock(&current->fs->lock);
1927 pwdmnt = mntget(current->fs->pwdmnt); 1920 pwd = current->fs->pwd;
1928 pwd = dget(current->fs->pwd); 1921 path_get(&current->fs->pwd);
1929 rootmnt = mntget(current->fs->rootmnt); 1922 root = current->fs->root;
1930 root = dget(current->fs->root); 1923 path_get(&current->fs->root);
1931 read_unlock(&current->fs->lock); 1924 read_unlock(&current->fs->lock);
1932 1925
1933 error = -ENOENT; 1926 error = -ENOENT;
1934 /* Has the current directory has been unlinked? */ 1927 /* Has the current directory has been unlinked? */
1935 spin_lock(&dcache_lock); 1928 spin_lock(&dcache_lock);
1936 if (pwd->d_parent == pwd || !d_unhashed(pwd)) { 1929 if (pwd.dentry->d_parent == pwd.dentry || !d_unhashed(pwd.dentry)) {
1937 unsigned long len; 1930 unsigned long len;
1938 char * cwd; 1931 char * cwd;
1939 1932
1940 cwd = __d_path(pwd, pwdmnt, root, rootmnt, page, PAGE_SIZE); 1933 cwd = __d_path(pwd.dentry, pwd.mnt, &root, page, PAGE_SIZE);
1941 spin_unlock(&dcache_lock); 1934 spin_unlock(&dcache_lock);
1942 1935
1943 error = PTR_ERR(cwd); 1936 error = PTR_ERR(cwd);
@@ -1955,10 +1948,8 @@ asmlinkage long sys_getcwd(char __user *buf, unsigned long size)
1955 spin_unlock(&dcache_lock); 1948 spin_unlock(&dcache_lock);
1956 1949
1957out: 1950out:
1958 dput(pwd); 1951 path_put(&pwd);
1959 mntput(pwdmnt); 1952 path_put(&root);
1960 dput(root);
1961 mntput(rootmnt);
1962 free_page((unsigned long) page); 1953 free_page((unsigned long) page);
1963 return error; 1954 return error;
1964} 1955}
diff --git a/fs/dcookies.c b/fs/dcookies.c
index 792cbf55fa95..855d4b1d619a 100644
--- a/fs/dcookies.c
+++ b/fs/dcookies.c
@@ -24,6 +24,7 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/dcookies.h> 25#include <linux/dcookies.h>
26#include <linux/mutex.h> 26#include <linux/mutex.h>
27#include <linux/path.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28 29
29/* The dcookies are allocated from a kmem_cache and 30/* The dcookies are allocated from a kmem_cache and
@@ -31,8 +32,7 @@
31 * code here is particularly performance critical 32 * code here is particularly performance critical
32 */ 33 */
33struct dcookie_struct { 34struct dcookie_struct {
34 struct dentry * dentry; 35 struct path path;
35 struct vfsmount * vfsmnt;
36 struct list_head hash_list; 36 struct list_head hash_list;
37}; 37};
38 38
@@ -51,7 +51,7 @@ static inline int is_live(void)
51/* The dentry is locked, its address will do for the cookie */ 51/* The dentry is locked, its address will do for the cookie */
52static inline unsigned long dcookie_value(struct dcookie_struct * dcs) 52static inline unsigned long dcookie_value(struct dcookie_struct * dcs)
53{ 53{
54 return (unsigned long)dcs->dentry; 54 return (unsigned long)dcs->path.dentry;
55} 55}
56 56
57 57
@@ -89,19 +89,17 @@ static void hash_dcookie(struct dcookie_struct * dcs)
89} 89}
90 90
91 91
92static struct dcookie_struct * alloc_dcookie(struct dentry * dentry, 92static struct dcookie_struct *alloc_dcookie(struct path *path)
93 struct vfsmount * vfsmnt)
94{ 93{
95 struct dcookie_struct * dcs = kmem_cache_alloc(dcookie_cache, GFP_KERNEL); 94 struct dcookie_struct *dcs = kmem_cache_alloc(dcookie_cache,
95 GFP_KERNEL);
96 if (!dcs) 96 if (!dcs)
97 return NULL; 97 return NULL;
98 98
99 dentry->d_cookie = dcs; 99 path->dentry->d_cookie = dcs;
100 100 dcs->path = *path;
101 dcs->dentry = dget(dentry); 101 path_get(path);
102 dcs->vfsmnt = mntget(vfsmnt);
103 hash_dcookie(dcs); 102 hash_dcookie(dcs);
104
105 return dcs; 103 return dcs;
106} 104}
107 105
@@ -109,8 +107,7 @@ static struct dcookie_struct * alloc_dcookie(struct dentry * dentry,
109/* This is the main kernel-side routine that retrieves the cookie 107/* This is the main kernel-side routine that retrieves the cookie
110 * value for a dentry/vfsmnt pair. 108 * value for a dentry/vfsmnt pair.
111 */ 109 */
112int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt, 110int get_dcookie(struct path *path, unsigned long *cookie)
113 unsigned long * cookie)
114{ 111{
115 int err = 0; 112 int err = 0;
116 struct dcookie_struct * dcs; 113 struct dcookie_struct * dcs;
@@ -122,10 +119,10 @@ int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt,
122 goto out; 119 goto out;
123 } 120 }
124 121
125 dcs = dentry->d_cookie; 122 dcs = path->dentry->d_cookie;
126 123
127 if (!dcs) 124 if (!dcs)
128 dcs = alloc_dcookie(dentry, vfsmnt); 125 dcs = alloc_dcookie(path);
129 126
130 if (!dcs) { 127 if (!dcs) {
131 err = -ENOMEM; 128 err = -ENOMEM;
@@ -174,7 +171,7 @@ asmlinkage long sys_lookup_dcookie(u64 cookie64, char __user * buf, size_t len)
174 goto out; 171 goto out;
175 172
176 /* FIXME: (deleted) ? */ 173 /* FIXME: (deleted) ? */
177 path = d_path(dcs->dentry, dcs->vfsmnt, kbuf, PAGE_SIZE); 174 path = d_path(&dcs->path, kbuf, PAGE_SIZE);
178 175
179 if (IS_ERR(path)) { 176 if (IS_ERR(path)) {
180 err = PTR_ERR(path); 177 err = PTR_ERR(path);
@@ -254,9 +251,8 @@ out_kmem:
254 251
255static void free_dcookie(struct dcookie_struct * dcs) 252static void free_dcookie(struct dcookie_struct * dcs)
256{ 253{
257 dcs->dentry->d_cookie = NULL; 254 dcs->path.dentry->d_cookie = NULL;
258 dput(dcs->dentry); 255 path_put(&dcs->path);
259 mntput(dcs->vfsmnt);
260 kmem_cache_free(dcookie_cache, dcs); 256 kmem_cache_free(dcookie_cache, dcs);
261} 257}
262 258
diff --git a/fs/dquot.c b/fs/dquot.c
index def4e969df77..9c7feb62eed1 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -1633,16 +1633,17 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
1633 error = path_lookup(path, LOOKUP_FOLLOW, &nd); 1633 error = path_lookup(path, LOOKUP_FOLLOW, &nd);
1634 if (error < 0) 1634 if (error < 0)
1635 return error; 1635 return error;
1636 error = security_quota_on(nd.dentry); 1636 error = security_quota_on(nd.path.dentry);
1637 if (error) 1637 if (error)
1638 goto out_path; 1638 goto out_path;
1639 /* Quota file not on the same filesystem? */ 1639 /* Quota file not on the same filesystem? */
1640 if (nd.mnt->mnt_sb != sb) 1640 if (nd.path.mnt->mnt_sb != sb)
1641 error = -EXDEV; 1641 error = -EXDEV;
1642 else 1642 else
1643 error = vfs_quota_on_inode(nd.dentry->d_inode, type, format_id); 1643 error = vfs_quota_on_inode(nd.path.dentry->d_inode, type,
1644 format_id);
1644out_path: 1645out_path:
1645 path_release(&nd); 1646 path_put(&nd.path);
1646 return error; 1647 return error;
1647} 1648}
1648 1649
diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c
index cb20b964419f..841a032050a7 100644
--- a/fs/ecryptfs/dentry.c
+++ b/fs/ecryptfs/dentry.c
@@ -51,13 +51,13 @@ static int ecryptfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
51 51
52 if (!lower_dentry->d_op || !lower_dentry->d_op->d_revalidate) 52 if (!lower_dentry->d_op || !lower_dentry->d_op->d_revalidate)
53 goto out; 53 goto out;
54 dentry_save = nd->dentry; 54 dentry_save = nd->path.dentry;
55 vfsmount_save = nd->mnt; 55 vfsmount_save = nd->path.mnt;
56 nd->dentry = lower_dentry; 56 nd->path.dentry = lower_dentry;
57 nd->mnt = lower_mnt; 57 nd->path.mnt = lower_mnt;
58 rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd); 58 rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd);
59 nd->dentry = dentry_save; 59 nd->path.dentry = dentry_save;
60 nd->mnt = vfsmount_save; 60 nd->path.mnt = vfsmount_save;
61 if (dentry->d_inode) { 61 if (dentry->d_inode) {
62 struct inode *lower_inode = 62 struct inode *lower_inode =
63 ecryptfs_inode_to_lower(dentry->d_inode); 63 ecryptfs_inode_to_lower(dentry->d_inode);
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index edd1e44e9d47..e23861152101 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -77,13 +77,13 @@ ecryptfs_create_underlying_file(struct inode *lower_dir_inode,
77 struct vfsmount *vfsmount_save; 77 struct vfsmount *vfsmount_save;
78 int rc; 78 int rc;
79 79
80 dentry_save = nd->dentry; 80 dentry_save = nd->path.dentry;
81 vfsmount_save = nd->mnt; 81 vfsmount_save = nd->path.mnt;
82 nd->dentry = lower_dentry; 82 nd->path.dentry = lower_dentry;
83 nd->mnt = lower_mnt; 83 nd->path.mnt = lower_mnt;
84 rc = vfs_create(lower_dir_inode, lower_dentry, mode, nd); 84 rc = vfs_create(lower_dir_inode, lower_dentry, mode, nd);
85 nd->dentry = dentry_save; 85 nd->path.dentry = dentry_save;
86 nd->mnt = vfsmount_save; 86 nd->path.mnt = vfsmount_save;
87 return rc; 87 return rc;
88} 88}
89 89
@@ -819,14 +819,14 @@ ecryptfs_permission(struct inode *inode, int mask, struct nameidata *nd)
819 int rc; 819 int rc;
820 820
821 if (nd) { 821 if (nd) {
822 struct vfsmount *vfsmnt_save = nd->mnt; 822 struct vfsmount *vfsmnt_save = nd->path.mnt;
823 struct dentry *dentry_save = nd->dentry; 823 struct dentry *dentry_save = nd->path.dentry;
824 824
825 nd->mnt = ecryptfs_dentry_to_lower_mnt(nd->dentry); 825 nd->path.mnt = ecryptfs_dentry_to_lower_mnt(nd->path.dentry);
826 nd->dentry = ecryptfs_dentry_to_lower(nd->dentry); 826 nd->path.dentry = ecryptfs_dentry_to_lower(nd->path.dentry);
827 rc = permission(ecryptfs_inode_to_lower(inode), mask, nd); 827 rc = permission(ecryptfs_inode_to_lower(inode), mask, nd);
828 nd->mnt = vfsmnt_save; 828 nd->path.mnt = vfsmnt_save;
829 nd->dentry = dentry_save; 829 nd->path.dentry = dentry_save;
830 } else 830 } else
831 rc = permission(ecryptfs_inode_to_lower(inode), mask, NULL); 831 rc = permission(ecryptfs_inode_to_lower(inode), mask, NULL);
832 return rc; 832 return rc;
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 778c420e4cac..d25ac9500a92 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -513,8 +513,8 @@ static int ecryptfs_read_super(struct super_block *sb, const char *dev_name)
513 ecryptfs_printk(KERN_WARNING, "path_lookup() failed\n"); 513 ecryptfs_printk(KERN_WARNING, "path_lookup() failed\n");
514 goto out; 514 goto out;
515 } 515 }
516 lower_root = nd.dentry; 516 lower_root = nd.path.dentry;
517 lower_mnt = nd.mnt; 517 lower_mnt = nd.path.mnt;
518 ecryptfs_set_superblock_lower(sb, lower_root->d_sb); 518 ecryptfs_set_superblock_lower(sb, lower_root->d_sb);
519 sb->s_maxbytes = lower_root->d_sb->s_maxbytes; 519 sb->s_maxbytes = lower_root->d_sb->s_maxbytes;
520 sb->s_blocksize = lower_root->d_sb->s_blocksize; 520 sb->s_blocksize = lower_root->d_sb->s_blocksize;
@@ -526,7 +526,7 @@ static int ecryptfs_read_super(struct super_block *sb, const char *dev_name)
526 rc = 0; 526 rc = 0;
527 goto out; 527 goto out;
528out_free: 528out_free:
529 path_release(&nd); 529 path_put(&nd.path);
530out: 530out:
531 return rc; 531 return rc;
532} 532}
diff --git a/fs/exec.c b/fs/exec.c
index 9ff6069094d8..a44b142fb460 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -112,7 +112,7 @@ asmlinkage long sys_uselib(const char __user * library)
112 goto out; 112 goto out;
113 113
114 error = -EINVAL; 114 error = -EINVAL;
115 if (!S_ISREG(nd.dentry->d_inode->i_mode)) 115 if (!S_ISREG(nd.path.dentry->d_inode->i_mode))
116 goto exit; 116 goto exit;
117 117
118 error = vfs_permission(&nd, MAY_READ | MAY_EXEC); 118 error = vfs_permission(&nd, MAY_READ | MAY_EXEC);
@@ -148,7 +148,7 @@ out:
148 return error; 148 return error;
149exit: 149exit:
150 release_open_intent(&nd); 150 release_open_intent(&nd);
151 path_release(&nd); 151 path_put(&nd.path);
152 goto out; 152 goto out;
153} 153}
154 154
@@ -652,7 +652,7 @@ struct file *open_exec(const char *name)
652 file = ERR_PTR(err); 652 file = ERR_PTR(err);
653 653
654 if (!err) { 654 if (!err) {
655 struct inode *inode = nd.dentry->d_inode; 655 struct inode *inode = nd.path.dentry->d_inode;
656 file = ERR_PTR(-EACCES); 656 file = ERR_PTR(-EACCES);
657 if (S_ISREG(inode->i_mode)) { 657 if (S_ISREG(inode->i_mode)) {
658 int err = vfs_permission(&nd, MAY_EXEC); 658 int err = vfs_permission(&nd, MAY_EXEC);
@@ -672,7 +672,7 @@ out:
672 } 672 }
673 } 673 }
674 release_open_intent(&nd); 674 release_open_intent(&nd);
675 path_release(&nd); 675 path_put(&nd.path);
676 } 676 }
677 goto out; 677 goto out;
678} 678}
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 8e02cbfb1123..18769cc32377 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -2758,16 +2758,16 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,
2758 if (err) 2758 if (err)
2759 return err; 2759 return err;
2760 /* Quotafile not on the same filesystem? */ 2760 /* Quotafile not on the same filesystem? */
2761 if (nd.mnt->mnt_sb != sb) { 2761 if (nd.path.mnt->mnt_sb != sb) {
2762 path_release(&nd); 2762 path_put(&nd.path);
2763 return -EXDEV; 2763 return -EXDEV;
2764 } 2764 }
2765 /* Quotafile not of fs root? */ 2765 /* Quotafile not of fs root? */
2766 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode) 2766 if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode)
2767 printk(KERN_WARNING 2767 printk(KERN_WARNING
2768 "EXT3-fs: Quota file not on filesystem root. " 2768 "EXT3-fs: Quota file not on filesystem root. "
2769 "Journalled quota will not work.\n"); 2769 "Journalled quota will not work.\n");
2770 path_release(&nd); 2770 path_put(&nd.path);
2771 return vfs_quota_on(sb, type, format_id, path); 2771 return vfs_quota_on(sb, type, format_id, path);
2772} 2772}
2773 2773
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 0072da75221f..13383ba18f1d 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3158,16 +3158,16 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,
3158 if (err) 3158 if (err)
3159 return err; 3159 return err;
3160 /* Quotafile not on the same filesystem? */ 3160 /* Quotafile not on the same filesystem? */
3161 if (nd.mnt->mnt_sb != sb) { 3161 if (nd.path.mnt->mnt_sb != sb) {
3162 path_release(&nd); 3162 path_put(&nd.path);
3163 return -EXDEV; 3163 return -EXDEV;
3164 } 3164 }
3165 /* Quotafile not of fs root? */ 3165 /* Quotafile not of fs root? */
3166 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode) 3166 if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode)
3167 printk(KERN_WARNING 3167 printk(KERN_WARNING
3168 "EXT4-fs: Quota file not on filesystem root. " 3168 "EXT4-fs: Quota file not on filesystem root. "
3169 "Journalled quota will not work.\n"); 3169 "Journalled quota will not work.\n");
3170 path_release(&nd); 3170 path_put(&nd.path);
3171 return vfs_quota_on(sb, type, format_id, path); 3171 return vfs_quota_on(sb, type, format_id, path);
3172} 3172}
3173 3173
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 43d511bba52d..4bee6aa845e4 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -884,12 +884,13 @@ static struct super_block* get_gfs2_sb(const char *dev_name)
884 dev_name); 884 dev_name);
885 goto out; 885 goto out;
886 } 886 }
887 error = vfs_getattr(nd.mnt, nd.dentry, &stat); 887 error = vfs_getattr(nd.path.mnt, nd.path.dentry, &stat);
888 888
889 fstype = get_fs_type("gfs2"); 889 fstype = get_fs_type("gfs2");
890 list_for_each_entry(s, &fstype->fs_supers, s_instances) { 890 list_for_each_entry(s, &fstype->fs_supers, s_instances) {
891 if ((S_ISBLK(stat.mode) && s->s_dev == stat.rdev) || 891 if ((S_ISBLK(stat.mode) && s->s_dev == stat.rdev) ||
892 (S_ISDIR(stat.mode) && s == nd.dentry->d_inode->i_sb)) { 892 (S_ISDIR(stat.mode) &&
893 s == nd.path.dentry->d_inode->i_sb)) {
893 sb = s; 894 sb = s;
894 goto free_nd; 895 goto free_nd;
895 } 896 }
@@ -899,7 +900,7 @@ static struct super_block* get_gfs2_sb(const char *dev_name)
899 "mount point %s\n", dev_name); 900 "mount point %s\n", dev_name);
900 901
901free_nd: 902free_nd:
902 path_release(&nd); 903 path_put(&nd.path);
903out: 904out:
904 return sb; 905 return sb;
905} 906}
diff --git a/fs/inotify_user.c b/fs/inotify_user.c
index 3ab09a65c456..7b94a1e3c015 100644
--- a/fs/inotify_user.c
+++ b/fs/inotify_user.c
@@ -41,9 +41,9 @@ static struct kmem_cache *event_cachep __read_mostly;
41static struct vfsmount *inotify_mnt __read_mostly; 41static struct vfsmount *inotify_mnt __read_mostly;
42 42
43/* these are configurable via /proc/sys/fs/inotify/ */ 43/* these are configurable via /proc/sys/fs/inotify/ */
44int inotify_max_user_instances __read_mostly; 44static int inotify_max_user_instances __read_mostly;
45int inotify_max_user_watches __read_mostly; 45static int inotify_max_user_watches __read_mostly;
46int inotify_max_queued_events __read_mostly; 46static int inotify_max_queued_events __read_mostly;
47 47
48/* 48/*
49 * Lock ordering: 49 * Lock ordering:
@@ -367,7 +367,7 @@ static int find_inode(const char __user *dirname, struct nameidata *nd,
367 /* you can only watch an inode if you have read permissions on it */ 367 /* you can only watch an inode if you have read permissions on it */
368 error = vfs_permission(nd, MAY_READ); 368 error = vfs_permission(nd, MAY_READ);
369 if (error) 369 if (error)
370 path_release(nd); 370 path_put(&nd->path);
371 return error; 371 return error;
372} 372}
373 373
@@ -667,7 +667,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
667 goto fput_and_out; 667 goto fput_and_out;
668 668
669 /* inode held in place by reference to nd; dev by fget on fd */ 669 /* inode held in place by reference to nd; dev by fget on fd */
670 inode = nd.dentry->d_inode; 670 inode = nd.path.dentry->d_inode;
671 dev = filp->private_data; 671 dev = filp->private_data;
672 672
673 mutex_lock(&dev->up_mutex); 673 mutex_lock(&dev->up_mutex);
@@ -676,7 +676,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
676 ret = create_watch(dev, inode, mask); 676 ret = create_watch(dev, inode, mask);
677 mutex_unlock(&dev->up_mutex); 677 mutex_unlock(&dev->up_mutex);
678 678
679 path_release(&nd); 679 path_put(&nd.path);
680fput_and_out: 680fput_and_out:
681 fput_light(filp, fput_needed); 681 fput_light(filp, fput_needed);
682 return ret; 682 return ret;
diff --git a/fs/namei.c b/fs/namei.c
index 52703986323a..941c8e8228c0 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -231,7 +231,7 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
231 struct vfsmount *mnt = NULL; 231 struct vfsmount *mnt = NULL;
232 232
233 if (nd) 233 if (nd)
234 mnt = nd->mnt; 234 mnt = nd->path.mnt;
235 235
236 if (mask & MAY_WRITE) { 236 if (mask & MAY_WRITE) {
237 umode_t mode = inode->i_mode; 237 umode_t mode = inode->i_mode;
@@ -296,7 +296,7 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)
296 */ 296 */
297int vfs_permission(struct nameidata *nd, int mask) 297int vfs_permission(struct nameidata *nd, int mask)
298{ 298{
299 return permission(nd->dentry->d_inode, mask, nd); 299 return permission(nd->path.dentry->d_inode, mask, nd);
300} 300}
301 301
302/** 302/**
@@ -362,21 +362,31 @@ int deny_write_access(struct file * file)
362 return 0; 362 return 0;
363} 363}
364 364
365void path_release(struct nameidata *nd) 365/**
366 * path_get - get a reference to a path
367 * @path: path to get the reference to
368 *
369 * Given a path increment the reference count to the dentry and the vfsmount.
370 */
371void path_get(struct path *path)
366{ 372{
367 dput(nd->dentry); 373 mntget(path->mnt);
368 mntput(nd->mnt); 374 dget(path->dentry);
369} 375}
376EXPORT_SYMBOL(path_get);
370 377
371/* 378/**
372 * umount() mustn't call path_release()/mntput() as that would clear 379 * path_put - put a reference to a path
373 * mnt_expiry_mark 380 * @path: path to put the reference to
381 *
382 * Given a path decrement the reference count to the dentry and the vfsmount.
374 */ 383 */
375void path_release_on_umount(struct nameidata *nd) 384void path_put(struct path *path)
376{ 385{
377 dput(nd->dentry); 386 dput(path->dentry);
378 mntput_no_expire(nd->mnt); 387 mntput(path->mnt);
379} 388}
389EXPORT_SYMBOL(path_put);
380 390
381/** 391/**
382 * release_open_intent - free up open intent resources 392 * release_open_intent - free up open intent resources
@@ -539,16 +549,16 @@ walk_init_root(const char *name, struct nameidata *nd)
539 struct fs_struct *fs = current->fs; 549 struct fs_struct *fs = current->fs;
540 550
541 read_lock(&fs->lock); 551 read_lock(&fs->lock);
542 if (fs->altroot && !(nd->flags & LOOKUP_NOALT)) { 552 if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) {
543 nd->mnt = mntget(fs->altrootmnt); 553 nd->path = fs->altroot;
544 nd->dentry = dget(fs->altroot); 554 path_get(&fs->altroot);
545 read_unlock(&fs->lock); 555 read_unlock(&fs->lock);
546 if (__emul_lookup_dentry(name,nd)) 556 if (__emul_lookup_dentry(name,nd))
547 return 0; 557 return 0;
548 read_lock(&fs->lock); 558 read_lock(&fs->lock);
549 } 559 }
550 nd->mnt = mntget(fs->rootmnt); 560 nd->path = fs->root;
551 nd->dentry = dget(fs->root); 561 path_get(&fs->root);
552 read_unlock(&fs->lock); 562 read_unlock(&fs->lock);
553 return 1; 563 return 1;
554} 564}
@@ -561,7 +571,7 @@ static __always_inline int __vfs_follow_link(struct nameidata *nd, const char *l
561 goto fail; 571 goto fail;
562 572
563 if (*link == '/') { 573 if (*link == '/') {
564 path_release(nd); 574 path_put(&nd->path);
565 if (!walk_init_root(link, nd)) 575 if (!walk_init_root(link, nd))
566 /* weird __emul_prefix() stuff did it */ 576 /* weird __emul_prefix() stuff did it */
567 goto out; 577 goto out;
@@ -577,31 +587,31 @@ out:
577 */ 587 */
578 name = __getname(); 588 name = __getname();
579 if (unlikely(!name)) { 589 if (unlikely(!name)) {
580 path_release(nd); 590 path_put(&nd->path);
581 return -ENOMEM; 591 return -ENOMEM;
582 } 592 }
583 strcpy(name, nd->last.name); 593 strcpy(name, nd->last.name);
584 nd->last.name = name; 594 nd->last.name = name;
585 return 0; 595 return 0;
586fail: 596fail:
587 path_release(nd); 597 path_put(&nd->path);
588 return PTR_ERR(link); 598 return PTR_ERR(link);
589} 599}
590 600
591static inline void dput_path(struct path *path, struct nameidata *nd) 601static void path_put_conditional(struct path *path, struct nameidata *nd)
592{ 602{
593 dput(path->dentry); 603 dput(path->dentry);
594 if (path->mnt != nd->mnt) 604 if (path->mnt != nd->path.mnt)
595 mntput(path->mnt); 605 mntput(path->mnt);
596} 606}
597 607
598static inline void path_to_nameidata(struct path *path, struct nameidata *nd) 608static inline void path_to_nameidata(struct path *path, struct nameidata *nd)
599{ 609{
600 dput(nd->dentry); 610 dput(nd->path.dentry);
601 if (nd->mnt != path->mnt) 611 if (nd->path.mnt != path->mnt)
602 mntput(nd->mnt); 612 mntput(nd->path.mnt);
603 nd->mnt = path->mnt; 613 nd->path.mnt = path->mnt;
604 nd->dentry = path->dentry; 614 nd->path.dentry = path->dentry;
605} 615}
606 616
607static __always_inline int __do_follow_link(struct path *path, struct nameidata *nd) 617static __always_inline int __do_follow_link(struct path *path, struct nameidata *nd)
@@ -613,7 +623,7 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata
613 touch_atime(path->mnt, dentry); 623 touch_atime(path->mnt, dentry);
614 nd_set_link(nd, NULL); 624 nd_set_link(nd, NULL);
615 625
616 if (path->mnt != nd->mnt) { 626 if (path->mnt != nd->path.mnt) {
617 path_to_nameidata(path, nd); 627 path_to_nameidata(path, nd);
618 dget(dentry); 628 dget(dentry);
619 } 629 }
@@ -628,8 +638,7 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidata
628 if (dentry->d_inode->i_op->put_link) 638 if (dentry->d_inode->i_op->put_link)
629 dentry->d_inode->i_op->put_link(dentry, nd, cookie); 639 dentry->d_inode->i_op->put_link(dentry, nd, cookie);
630 } 640 }
631 dput(dentry); 641 path_put(path);
632 mntput(path->mnt);
633 642
634 return error; 643 return error;
635} 644}
@@ -661,8 +670,8 @@ static inline int do_follow_link(struct path *path, struct nameidata *nd)
661 nd->depth--; 670 nd->depth--;
662 return err; 671 return err;
663loop: 672loop:
664 dput_path(path, nd); 673 path_put_conditional(path, nd);
665 path_release(nd); 674 path_put(&nd->path);
666 return err; 675 return err;
667} 676}
668 677
@@ -743,37 +752,37 @@ static __always_inline void follow_dotdot(struct nameidata *nd)
743 752
744 while(1) { 753 while(1) {
745 struct vfsmount *parent; 754 struct vfsmount *parent;
746 struct dentry *old = nd->dentry; 755 struct dentry *old = nd->path.dentry;
747 756
748 read_lock(&fs->lock); 757 read_lock(&fs->lock);
749 if (nd->dentry == fs->root && 758 if (nd->path.dentry == fs->root.dentry &&
750 nd->mnt == fs->rootmnt) { 759 nd->path.mnt == fs->root.mnt) {
751 read_unlock(&fs->lock); 760 read_unlock(&fs->lock);
752 break; 761 break;
753 } 762 }
754 read_unlock(&fs->lock); 763 read_unlock(&fs->lock);
755 spin_lock(&dcache_lock); 764 spin_lock(&dcache_lock);
756 if (nd->dentry != nd->mnt->mnt_root) { 765 if (nd->path.dentry != nd->path.mnt->mnt_root) {
757 nd->dentry = dget(nd->dentry->d_parent); 766 nd->path.dentry = dget(nd->path.dentry->d_parent);
758 spin_unlock(&dcache_lock); 767 spin_unlock(&dcache_lock);
759 dput(old); 768 dput(old);
760 break; 769 break;
761 } 770 }
762 spin_unlock(&dcache_lock); 771 spin_unlock(&dcache_lock);
763 spin_lock(&vfsmount_lock); 772 spin_lock(&vfsmount_lock);
764 parent = nd->mnt->mnt_parent; 773 parent = nd->path.mnt->mnt_parent;
765 if (parent == nd->mnt) { 774 if (parent == nd->path.mnt) {
766 spin_unlock(&vfsmount_lock); 775 spin_unlock(&vfsmount_lock);
767 break; 776 break;
768 } 777 }
769 mntget(parent); 778 mntget(parent);
770 nd->dentry = dget(nd->mnt->mnt_mountpoint); 779 nd->path.dentry = dget(nd->path.mnt->mnt_mountpoint);
771 spin_unlock(&vfsmount_lock); 780 spin_unlock(&vfsmount_lock);
772 dput(old); 781 dput(old);
773 mntput(nd->mnt); 782 mntput(nd->path.mnt);
774 nd->mnt = parent; 783 nd->path.mnt = parent;
775 } 784 }
776 follow_mount(&nd->mnt, &nd->dentry); 785 follow_mount(&nd->path.mnt, &nd->path.dentry);
777} 786}
778 787
779/* 788/*
@@ -784,8 +793,8 @@ static __always_inline void follow_dotdot(struct nameidata *nd)
784static int do_lookup(struct nameidata *nd, struct qstr *name, 793static int do_lookup(struct nameidata *nd, struct qstr *name,
785 struct path *path) 794 struct path *path)
786{ 795{
787 struct vfsmount *mnt = nd->mnt; 796 struct vfsmount *mnt = nd->path.mnt;
788 struct dentry *dentry = __d_lookup(nd->dentry, name); 797 struct dentry *dentry = __d_lookup(nd->path.dentry, name);
789 798
790 if (!dentry) 799 if (!dentry)
791 goto need_lookup; 800 goto need_lookup;
@@ -798,7 +807,7 @@ done:
798 return 0; 807 return 0;
799 808
800need_lookup: 809need_lookup:
801 dentry = real_lookup(nd->dentry, name, nd); 810 dentry = real_lookup(nd->path.dentry, name, nd);
802 if (IS_ERR(dentry)) 811 if (IS_ERR(dentry))
803 goto fail; 812 goto fail;
804 goto done; 813 goto done;
@@ -835,7 +844,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
835 if (!*name) 844 if (!*name)
836 goto return_reval; 845 goto return_reval;
837 846
838 inode = nd->dentry->d_inode; 847 inode = nd->path.dentry->d_inode;
839 if (nd->depth) 848 if (nd->depth)
840 lookup_flags = LOOKUP_FOLLOW | (nd->flags & LOOKUP_CONTINUE); 849 lookup_flags = LOOKUP_FOLLOW | (nd->flags & LOOKUP_CONTINUE);
841 850
@@ -883,7 +892,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
883 if (this.name[1] != '.') 892 if (this.name[1] != '.')
884 break; 893 break;
885 follow_dotdot(nd); 894 follow_dotdot(nd);
886 inode = nd->dentry->d_inode; 895 inode = nd->path.dentry->d_inode;
887 /* fallthrough */ 896 /* fallthrough */
888 case 1: 897 case 1:
889 continue; 898 continue;
@@ -892,8 +901,9 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
892 * See if the low-level filesystem might want 901 * See if the low-level filesystem might want
893 * to use its own hash.. 902 * to use its own hash..
894 */ 903 */
895 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) { 904 if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) {
896 err = nd->dentry->d_op->d_hash(nd->dentry, &this); 905 err = nd->path.dentry->d_op->d_hash(nd->path.dentry,
906 &this);
897 if (err < 0) 907 if (err < 0)
898 break; 908 break;
899 } 909 }
@@ -915,7 +925,7 @@ static int __link_path_walk(const char *name, struct nameidata *nd)
915 if (err) 925 if (err)
916 goto return_err; 926 goto return_err;
917 err = -ENOENT; 927 err = -ENOENT;
918 inode = nd->dentry->d_inode; 928 inode = nd->path.dentry->d_inode;
919 if (!inode) 929 if (!inode)
920 break; 930 break;
921 err = -ENOTDIR; 931 err = -ENOTDIR;
@@ -943,13 +953,14 @@ last_component:
943 if (this.name[1] != '.') 953 if (this.name[1] != '.')
944 break; 954 break;
945 follow_dotdot(nd); 955 follow_dotdot(nd);
946 inode = nd->dentry->d_inode; 956 inode = nd->path.dentry->d_inode;
947 /* fallthrough */ 957 /* fallthrough */
948 case 1: 958 case 1:
949 goto return_reval; 959 goto return_reval;
950 } 960 }
951 if (nd->dentry->d_op && nd->dentry->d_op->d_hash) { 961 if (nd->path.dentry->d_op && nd->path.dentry->d_op->d_hash) {
952 err = nd->dentry->d_op->d_hash(nd->dentry, &this); 962 err = nd->path.dentry->d_op->d_hash(nd->path.dentry,
963 &this);
953 if (err < 0) 964 if (err < 0)
954 break; 965 break;
955 } 966 }
@@ -962,7 +973,7 @@ last_component:
962 err = do_follow_link(&next, nd); 973 err = do_follow_link(&next, nd);
963 if (err) 974 if (err)
964 goto return_err; 975 goto return_err;
965 inode = nd->dentry->d_inode; 976 inode = nd->path.dentry->d_inode;
966 } else 977 } else
967 path_to_nameidata(&next, nd); 978 path_to_nameidata(&next, nd);
968 err = -ENOENT; 979 err = -ENOENT;
@@ -990,20 +1001,21 @@ return_reval:
990 * We bypassed the ordinary revalidation routines. 1001 * We bypassed the ordinary revalidation routines.
991 * We may need to check the cached dentry for staleness. 1002 * We may need to check the cached dentry for staleness.
992 */ 1003 */
993 if (nd->dentry && nd->dentry->d_sb && 1004 if (nd->path.dentry && nd->path.dentry->d_sb &&
994 (nd->dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT)) { 1005 (nd->path.dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT)) {
995 err = -ESTALE; 1006 err = -ESTALE;
996 /* Note: we do not d_invalidate() */ 1007 /* Note: we do not d_invalidate() */
997 if (!nd->dentry->d_op->d_revalidate(nd->dentry, nd)) 1008 if (!nd->path.dentry->d_op->d_revalidate(
1009 nd->path.dentry, nd))
998 break; 1010 break;
999 } 1011 }
1000return_base: 1012return_base:
1001 return 0; 1013 return 0;
1002out_dput: 1014out_dput:
1003 dput_path(&next, nd); 1015 path_put_conditional(&next, nd);
1004 break; 1016 break;
1005 } 1017 }
1006 path_release(nd); 1018 path_put(&nd->path);
1007return_err: 1019return_err:
1008 return err; 1020 return err;
1009} 1021}
@@ -1021,20 +1033,19 @@ static int link_path_walk(const char *name, struct nameidata *nd)
1021 int result; 1033 int result;
1022 1034
1023 /* make sure the stuff we saved doesn't go away */ 1035 /* make sure the stuff we saved doesn't go away */
1024 dget(save.dentry); 1036 dget(save.path.dentry);
1025 mntget(save.mnt); 1037 mntget(save.path.mnt);
1026 1038
1027 result = __link_path_walk(name, nd); 1039 result = __link_path_walk(name, nd);
1028 if (result == -ESTALE) { 1040 if (result == -ESTALE) {
1029 *nd = save; 1041 *nd = save;
1030 dget(nd->dentry); 1042 dget(nd->path.dentry);
1031 mntget(nd->mnt); 1043 mntget(nd->path.mnt);
1032 nd->flags |= LOOKUP_REVAL; 1044 nd->flags |= LOOKUP_REVAL;
1033 result = __link_path_walk(name, nd); 1045 result = __link_path_walk(name, nd);
1034 } 1046 }
1035 1047
1036 dput(save.dentry); 1048 path_put(&save.path);
1037 mntput(save.mnt);
1038 1049
1039 return result; 1050 return result;
1040} 1051}
@@ -1054,9 +1065,9 @@ static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
1054 if (path_walk(name, nd)) 1065 if (path_walk(name, nd))
1055 return 0; /* something went wrong... */ 1066 return 0; /* something went wrong... */
1056 1067
1057 if (!nd->dentry->d_inode || S_ISDIR(nd->dentry->d_inode->i_mode)) { 1068 if (!nd->path.dentry->d_inode ||
1058 struct dentry *old_dentry = nd->dentry; 1069 S_ISDIR(nd->path.dentry->d_inode->i_mode)) {
1059 struct vfsmount *old_mnt = nd->mnt; 1070 struct path old_path = nd->path;
1060 struct qstr last = nd->last; 1071 struct qstr last = nd->last;
1061 int last_type = nd->last_type; 1072 int last_type = nd->last_type;
1062 struct fs_struct *fs = current->fs; 1073 struct fs_struct *fs = current->fs;
@@ -1067,19 +1078,17 @@ static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
1067 */ 1078 */
1068 nd->last_type = LAST_ROOT; 1079 nd->last_type = LAST_ROOT;
1069 read_lock(&fs->lock); 1080 read_lock(&fs->lock);
1070 nd->mnt = mntget(fs->rootmnt); 1081 nd->path = fs->root;
1071 nd->dentry = dget(fs->root); 1082 path_get(&fs->root);
1072 read_unlock(&fs->lock); 1083 read_unlock(&fs->lock);
1073 if (path_walk(name, nd) == 0) { 1084 if (path_walk(name, nd) == 0) {
1074 if (nd->dentry->d_inode) { 1085 if (nd->path.dentry->d_inode) {
1075 dput(old_dentry); 1086 path_put(&old_path);
1076 mntput(old_mnt);
1077 return 1; 1087 return 1;
1078 } 1088 }
1079 path_release(nd); 1089 path_put(&nd->path);
1080 } 1090 }
1081 nd->dentry = old_dentry; 1091 nd->path = old_path;
1082 nd->mnt = old_mnt;
1083 nd->last = last; 1092 nd->last = last;
1084 nd->last_type = last_type; 1093 nd->last_type = last_type;
1085 } 1094 }
@@ -1090,29 +1099,22 @@ void set_fs_altroot(void)
1090{ 1099{
1091 char *emul = __emul_prefix(); 1100 char *emul = __emul_prefix();
1092 struct nameidata nd; 1101 struct nameidata nd;
1093 struct vfsmount *mnt = NULL, *oldmnt; 1102 struct path path = {}, old_path;
1094 struct dentry *dentry = NULL, *olddentry;
1095 int err; 1103 int err;
1096 struct fs_struct *fs = current->fs; 1104 struct fs_struct *fs = current->fs;
1097 1105
1098 if (!emul) 1106 if (!emul)
1099 goto set_it; 1107 goto set_it;
1100 err = path_lookup(emul, LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_NOALT, &nd); 1108 err = path_lookup(emul, LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_NOALT, &nd);
1101 if (!err) { 1109 if (!err)
1102 mnt = nd.mnt; 1110 path = nd.path;
1103 dentry = nd.dentry;
1104 }
1105set_it: 1111set_it:
1106 write_lock(&fs->lock); 1112 write_lock(&fs->lock);
1107 oldmnt = fs->altrootmnt; 1113 old_path = fs->altroot;
1108 olddentry = fs->altroot; 1114 fs->altroot = path;
1109 fs->altrootmnt = mnt;
1110 fs->altroot = dentry;
1111 write_unlock(&fs->lock); 1115 write_unlock(&fs->lock);
1112 if (olddentry) { 1116 if (old_path.dentry)
1113 dput(olddentry); 1117 path_put(&old_path);
1114 mntput(oldmnt);
1115 }
1116} 1118}
1117 1119
1118/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ 1120/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
@@ -1130,21 +1132,21 @@ static int do_path_lookup(int dfd, const char *name,
1130 1132
1131 if (*name=='/') { 1133 if (*name=='/') {
1132 read_lock(&fs->lock); 1134 read_lock(&fs->lock);
1133 if (fs->altroot && !(nd->flags & LOOKUP_NOALT)) { 1135 if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) {
1134 nd->mnt = mntget(fs->altrootmnt); 1136 nd->path = fs->altroot;
1135 nd->dentry = dget(fs->altroot); 1137 path_get(&fs->altroot);
1136 read_unlock(&fs->lock); 1138 read_unlock(&fs->lock);
1137 if (__emul_lookup_dentry(name,nd)) 1139 if (__emul_lookup_dentry(name,nd))
1138 goto out; /* found in altroot */ 1140 goto out; /* found in altroot */
1139 read_lock(&fs->lock); 1141 read_lock(&fs->lock);
1140 } 1142 }
1141 nd->mnt = mntget(fs->rootmnt); 1143 nd->path = fs->root;
1142 nd->dentry = dget(fs->root); 1144 path_get(&fs->root);
1143 read_unlock(&fs->lock); 1145 read_unlock(&fs->lock);
1144 } else if (dfd == AT_FDCWD) { 1146 } else if (dfd == AT_FDCWD) {
1145 read_lock(&fs->lock); 1147 read_lock(&fs->lock);
1146 nd->mnt = mntget(fs->pwdmnt); 1148 nd->path = fs->pwd;
1147 nd->dentry = dget(fs->pwd); 1149 path_get(&fs->pwd);
1148 read_unlock(&fs->lock); 1150 read_unlock(&fs->lock);
1149 } else { 1151 } else {
1150 struct dentry *dentry; 1152 struct dentry *dentry;
@@ -1164,17 +1166,17 @@ static int do_path_lookup(int dfd, const char *name,
1164 if (retval) 1166 if (retval)
1165 goto fput_fail; 1167 goto fput_fail;
1166 1168
1167 nd->mnt = mntget(file->f_path.mnt); 1169 nd->path = file->f_path;
1168 nd->dentry = dget(dentry); 1170 path_get(&file->f_path);
1169 1171
1170 fput_light(file, fput_needed); 1172 fput_light(file, fput_needed);
1171 } 1173 }
1172 1174
1173 retval = path_walk(name, nd); 1175 retval = path_walk(name, nd);
1174out: 1176out:
1175 if (unlikely(!retval && !audit_dummy_context() && nd->dentry && 1177 if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry &&
1176 nd->dentry->d_inode)) 1178 nd->path.dentry->d_inode))
1177 audit_inode(name, nd->dentry); 1179 audit_inode(name, nd->path.dentry);
1178out_fail: 1180out_fail:
1179 return retval; 1181 return retval;
1180 1182
@@ -1208,13 +1210,13 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
1208 nd->flags = flags; 1210 nd->flags = flags;
1209 nd->depth = 0; 1211 nd->depth = 0;
1210 1212
1211 nd->mnt = mntget(mnt); 1213 nd->path.mnt = mntget(mnt);
1212 nd->dentry = dget(dentry); 1214 nd->path.dentry = dget(dentry);
1213 1215
1214 retval = path_walk(name, nd); 1216 retval = path_walk(name, nd);
1215 if (unlikely(!retval && !audit_dummy_context() && nd->dentry && 1217 if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry &&
1216 nd->dentry->d_inode)) 1218 nd->path.dentry->d_inode))
1217 audit_inode(name, nd->dentry); 1219 audit_inode(name, nd->path.dentry);
1218 1220
1219 return retval; 1221 return retval;
1220 1222
@@ -1236,7 +1238,7 @@ static int __path_lookup_intent_open(int dfd, const char *name,
1236 if (IS_ERR(nd->intent.open.file)) { 1238 if (IS_ERR(nd->intent.open.file)) {
1237 if (err == 0) { 1239 if (err == 0) {
1238 err = PTR_ERR(nd->intent.open.file); 1240 err = PTR_ERR(nd->intent.open.file);
1239 path_release(nd); 1241 path_put(&nd->path);
1240 } 1242 }
1241 } else if (err != 0) 1243 } else if (err != 0)
1242 release_open_intent(nd); 1244 release_open_intent(nd);
@@ -1333,10 +1335,10 @@ static struct dentry *lookup_hash(struct nameidata *nd)
1333{ 1335{
1334 int err; 1336 int err;
1335 1337
1336 err = permission(nd->dentry->d_inode, MAY_EXEC, nd); 1338 err = permission(nd->path.dentry->d_inode, MAY_EXEC, nd);
1337 if (err) 1339 if (err)
1338 return ERR_PTR(err); 1340 return ERR_PTR(err);
1339 return __lookup_hash(&nd->last, nd->dentry, nd); 1341 return __lookup_hash(&nd->last, nd->path.dentry, nd);
1340} 1342}
1341 1343
1342static int __lookup_one_len(const char *name, struct qstr *this, 1344static int __lookup_one_len(const char *name, struct qstr *this,
@@ -1595,7 +1597,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode,
1595 1597
1596int may_open(struct nameidata *nd, int acc_mode, int flag) 1598int may_open(struct nameidata *nd, int acc_mode, int flag)
1597{ 1599{
1598 struct dentry *dentry = nd->dentry; 1600 struct dentry *dentry = nd->path.dentry;
1599 struct inode *inode = dentry->d_inode; 1601 struct inode *inode = dentry->d_inode;
1600 int error; 1602 int error;
1601 1603
@@ -1616,7 +1618,7 @@ int may_open(struct nameidata *nd, int acc_mode, int flag)
1616 if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { 1618 if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
1617 flag &= ~O_TRUNC; 1619 flag &= ~O_TRUNC;
1618 } else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) { 1620 } else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
1619 if (nd->mnt->mnt_flags & MNT_NODEV) 1621 if (nd->path.mnt->mnt_flags & MNT_NODEV)
1620 return -EACCES; 1622 return -EACCES;
1621 1623
1622 flag &= ~O_TRUNC; 1624 flag &= ~O_TRUNC;
@@ -1678,14 +1680,14 @@ static int open_namei_create(struct nameidata *nd, struct path *path,
1678 int flag, int mode) 1680 int flag, int mode)
1679{ 1681{
1680 int error; 1682 int error;
1681 struct dentry *dir = nd->dentry; 1683 struct dentry *dir = nd->path.dentry;
1682 1684
1683 if (!IS_POSIXACL(dir->d_inode)) 1685 if (!IS_POSIXACL(dir->d_inode))
1684 mode &= ~current->fs->umask; 1686 mode &= ~current->fs->umask;
1685 error = vfs_create(dir->d_inode, path->dentry, mode, nd); 1687 error = vfs_create(dir->d_inode, path->dentry, mode, nd);
1686 mutex_unlock(&dir->d_inode->i_mutex); 1688 mutex_unlock(&dir->d_inode->i_mutex);
1687 dput(nd->dentry); 1689 dput(nd->path.dentry);
1688 nd->dentry = path->dentry; 1690 nd->path.dentry = path->dentry;
1689 if (error) 1691 if (error)
1690 return error; 1692 return error;
1691 /* Don't check for write permission, don't truncate */ 1693 /* Don't check for write permission, don't truncate */
@@ -1752,11 +1754,11 @@ int open_namei(int dfd, const char *pathname, int flag,
1752 if (nd->last_type != LAST_NORM || nd->last.name[nd->last.len]) 1754 if (nd->last_type != LAST_NORM || nd->last.name[nd->last.len])
1753 goto exit; 1755 goto exit;
1754 1756
1755 dir = nd->dentry; 1757 dir = nd->path.dentry;
1756 nd->flags &= ~LOOKUP_PARENT; 1758 nd->flags &= ~LOOKUP_PARENT;
1757 mutex_lock(&dir->d_inode->i_mutex); 1759 mutex_lock(&dir->d_inode->i_mutex);
1758 path.dentry = lookup_hash(nd); 1760 path.dentry = lookup_hash(nd);
1759 path.mnt = nd->mnt; 1761 path.mnt = nd->path.mnt;
1760 1762
1761do_last: 1763do_last:
1762 error = PTR_ERR(path.dentry); 1764 error = PTR_ERR(path.dentry);
@@ -1812,11 +1814,11 @@ ok:
1812 return 0; 1814 return 0;
1813 1815
1814exit_dput: 1816exit_dput:
1815 dput_path(&path, nd); 1817 path_put_conditional(&path, nd);
1816exit: 1818exit:
1817 if (!IS_ERR(nd->intent.open.file)) 1819 if (!IS_ERR(nd->intent.open.file))
1818 release_open_intent(nd); 1820 release_open_intent(nd);
1819 path_release(nd); 1821 path_put(&nd->path);
1820 return error; 1822 return error;
1821 1823
1822do_link: 1824do_link:
@@ -1861,10 +1863,10 @@ do_link:
1861 __putname(nd->last.name); 1863 __putname(nd->last.name);
1862 goto exit; 1864 goto exit;
1863 } 1865 }
1864 dir = nd->dentry; 1866 dir = nd->path.dentry;
1865 mutex_lock(&dir->d_inode->i_mutex); 1867 mutex_lock(&dir->d_inode->i_mutex);
1866 path.dentry = lookup_hash(nd); 1868 path.dentry = lookup_hash(nd);
1867 path.mnt = nd->mnt; 1869 path.mnt = nd->path.mnt;
1868 __putname(nd->last.name); 1870 __putname(nd->last.name);
1869 goto do_last; 1871 goto do_last;
1870} 1872}
@@ -1877,13 +1879,13 @@ do_link:
1877 * Simple function to lookup and return a dentry and create it 1879 * Simple function to lookup and return a dentry and create it
1878 * if it doesn't exist. Is SMP-safe. 1880 * if it doesn't exist. Is SMP-safe.
1879 * 1881 *
1880 * Returns with nd->dentry->d_inode->i_mutex locked. 1882 * Returns with nd->path.dentry->d_inode->i_mutex locked.
1881 */ 1883 */
1882struct dentry *lookup_create(struct nameidata *nd, int is_dir) 1884struct dentry *lookup_create(struct nameidata *nd, int is_dir)
1883{ 1885{
1884 struct dentry *dentry = ERR_PTR(-EEXIST); 1886 struct dentry *dentry = ERR_PTR(-EEXIST);
1885 1887
1886 mutex_lock_nested(&nd->dentry->d_inode->i_mutex, I_MUTEX_PARENT); 1888 mutex_lock_nested(&nd->path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
1887 /* 1889 /*
1888 * Yucky last component or no last component at all? 1890 * Yucky last component or no last component at all?
1889 * (foo/., foo/.., /////) 1891 * (foo/., foo/.., /////)
@@ -1962,19 +1964,19 @@ asmlinkage long sys_mknodat(int dfd, const char __user *filename, int mode,
1962 dentry = lookup_create(&nd, 0); 1964 dentry = lookup_create(&nd, 0);
1963 error = PTR_ERR(dentry); 1965 error = PTR_ERR(dentry);
1964 1966
1965 if (!IS_POSIXACL(nd.dentry->d_inode)) 1967 if (!IS_POSIXACL(nd.path.dentry->d_inode))
1966 mode &= ~current->fs->umask; 1968 mode &= ~current->fs->umask;
1967 if (!IS_ERR(dentry)) { 1969 if (!IS_ERR(dentry)) {
1968 switch (mode & S_IFMT) { 1970 switch (mode & S_IFMT) {
1969 case 0: case S_IFREG: 1971 case 0: case S_IFREG:
1970 error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); 1972 error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd);
1971 break; 1973 break;
1972 case S_IFCHR: case S_IFBLK: 1974 case S_IFCHR: case S_IFBLK:
1973 error = vfs_mknod(nd.dentry->d_inode,dentry,mode, 1975 error = vfs_mknod(nd.path.dentry->d_inode,dentry,mode,
1974 new_decode_dev(dev)); 1976 new_decode_dev(dev));
1975 break; 1977 break;
1976 case S_IFIFO: case S_IFSOCK: 1978 case S_IFIFO: case S_IFSOCK:
1977 error = vfs_mknod(nd.dentry->d_inode,dentry,mode,0); 1979 error = vfs_mknod(nd.path.dentry->d_inode,dentry,mode,0);
1978 break; 1980 break;
1979 case S_IFDIR: 1981 case S_IFDIR:
1980 error = -EPERM; 1982 error = -EPERM;
@@ -1984,8 +1986,8 @@ asmlinkage long sys_mknodat(int dfd, const char __user *filename, int mode,
1984 } 1986 }
1985 dput(dentry); 1987 dput(dentry);
1986 } 1988 }
1987 mutex_unlock(&nd.dentry->d_inode->i_mutex); 1989 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
1988 path_release(&nd); 1990 path_put(&nd.path);
1989out: 1991out:
1990 putname(tmp); 1992 putname(tmp);
1991 1993
@@ -2039,13 +2041,13 @@ asmlinkage long sys_mkdirat(int dfd, const char __user *pathname, int mode)
2039 if (IS_ERR(dentry)) 2041 if (IS_ERR(dentry))
2040 goto out_unlock; 2042 goto out_unlock;
2041 2043
2042 if (!IS_POSIXACL(nd.dentry->d_inode)) 2044 if (!IS_POSIXACL(nd.path.dentry->d_inode))
2043 mode &= ~current->fs->umask; 2045 mode &= ~current->fs->umask;
2044 error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); 2046 error = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode);
2045 dput(dentry); 2047 dput(dentry);
2046out_unlock: 2048out_unlock:
2047 mutex_unlock(&nd.dentry->d_inode->i_mutex); 2049 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2048 path_release(&nd); 2050 path_put(&nd.path);
2049out: 2051out:
2050 putname(tmp); 2052 putname(tmp);
2051out_err: 2053out_err:
@@ -2143,17 +2145,17 @@ static long do_rmdir(int dfd, const char __user *pathname)
2143 error = -EBUSY; 2145 error = -EBUSY;
2144 goto exit1; 2146 goto exit1;
2145 } 2147 }
2146 mutex_lock_nested(&nd.dentry->d_inode->i_mutex, I_MUTEX_PARENT); 2148 mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
2147 dentry = lookup_hash(&nd); 2149 dentry = lookup_hash(&nd);
2148 error = PTR_ERR(dentry); 2150 error = PTR_ERR(dentry);
2149 if (IS_ERR(dentry)) 2151 if (IS_ERR(dentry))
2150 goto exit2; 2152 goto exit2;
2151 error = vfs_rmdir(nd.dentry->d_inode, dentry); 2153 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
2152 dput(dentry); 2154 dput(dentry);
2153exit2: 2155exit2:
2154 mutex_unlock(&nd.dentry->d_inode->i_mutex); 2156 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2155exit1: 2157exit1:
2156 path_release(&nd); 2158 path_put(&nd.path);
2157exit: 2159exit:
2158 putname(name); 2160 putname(name);
2159 return error; 2161 return error;
@@ -2219,7 +2221,7 @@ static long do_unlinkat(int dfd, const char __user *pathname)
2219 error = -EISDIR; 2221 error = -EISDIR;
2220 if (nd.last_type != LAST_NORM) 2222 if (nd.last_type != LAST_NORM)
2221 goto exit1; 2223 goto exit1;
2222 mutex_lock_nested(&nd.dentry->d_inode->i_mutex, I_MUTEX_PARENT); 2224 mutex_lock_nested(&nd.path.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
2223 dentry = lookup_hash(&nd); 2225 dentry = lookup_hash(&nd);
2224 error = PTR_ERR(dentry); 2226 error = PTR_ERR(dentry);
2225 if (!IS_ERR(dentry)) { 2227 if (!IS_ERR(dentry)) {
@@ -2229,15 +2231,15 @@ static long do_unlinkat(int dfd, const char __user *pathname)
2229 inode = dentry->d_inode; 2231 inode = dentry->d_inode;
2230 if (inode) 2232 if (inode)
2231 atomic_inc(&inode->i_count); 2233 atomic_inc(&inode->i_count);
2232 error = vfs_unlink(nd.dentry->d_inode, dentry); 2234 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
2233 exit2: 2235 exit2:
2234 dput(dentry); 2236 dput(dentry);
2235 } 2237 }
2236 mutex_unlock(&nd.dentry->d_inode->i_mutex); 2238 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2237 if (inode) 2239 if (inode)
2238 iput(inode); /* truncate the inode here */ 2240 iput(inode); /* truncate the inode here */
2239exit1: 2241exit1:
2240 path_release(&nd); 2242 path_put(&nd.path);
2241exit: 2243exit:
2242 putname(name); 2244 putname(name);
2243 return error; 2245 return error;
@@ -2310,11 +2312,11 @@ asmlinkage long sys_symlinkat(const char __user *oldname,
2310 if (IS_ERR(dentry)) 2312 if (IS_ERR(dentry))
2311 goto out_unlock; 2313 goto out_unlock;
2312 2314
2313 error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); 2315 error = vfs_symlink(nd.path.dentry->d_inode, dentry, from, S_IALLUGO);
2314 dput(dentry); 2316 dput(dentry);
2315out_unlock: 2317out_unlock:
2316 mutex_unlock(&nd.dentry->d_inode->i_mutex); 2318 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2317 path_release(&nd); 2319 path_put(&nd.path);
2318out: 2320out:
2319 putname(to); 2321 putname(to);
2320out_putname: 2322out_putname:
@@ -2399,20 +2401,20 @@ asmlinkage long sys_linkat(int olddfd, const char __user *oldname,
2399 if (error) 2401 if (error)
2400 goto out; 2402 goto out;
2401 error = -EXDEV; 2403 error = -EXDEV;
2402 if (old_nd.mnt != nd.mnt) 2404 if (old_nd.path.mnt != nd.path.mnt)
2403 goto out_release; 2405 goto out_release;
2404 new_dentry = lookup_create(&nd, 0); 2406 new_dentry = lookup_create(&nd, 0);
2405 error = PTR_ERR(new_dentry); 2407 error = PTR_ERR(new_dentry);
2406 if (IS_ERR(new_dentry)) 2408 if (IS_ERR(new_dentry))
2407 goto out_unlock; 2409 goto out_unlock;
2408 error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); 2410 error = vfs_link(old_nd.path.dentry, nd.path.dentry->d_inode, new_dentry);
2409 dput(new_dentry); 2411 dput(new_dentry);
2410out_unlock: 2412out_unlock:
2411 mutex_unlock(&nd.dentry->d_inode->i_mutex); 2413 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
2412out_release: 2414out_release:
2413 path_release(&nd); 2415 path_put(&nd.path);
2414out: 2416out:
2415 path_release(&old_nd); 2417 path_put(&old_nd.path);
2416exit: 2418exit:
2417 putname(to); 2419 putname(to);
2418 2420
@@ -2588,15 +2590,15 @@ static int do_rename(int olddfd, const char *oldname,
2588 goto exit1; 2590 goto exit1;
2589 2591
2590 error = -EXDEV; 2592 error = -EXDEV;
2591 if (oldnd.mnt != newnd.mnt) 2593 if (oldnd.path.mnt != newnd.path.mnt)
2592 goto exit2; 2594 goto exit2;
2593 2595
2594 old_dir = oldnd.dentry; 2596 old_dir = oldnd.path.dentry;
2595 error = -EBUSY; 2597 error = -EBUSY;
2596 if (oldnd.last_type != LAST_NORM) 2598 if (oldnd.last_type != LAST_NORM)
2597 goto exit2; 2599 goto exit2;
2598 2600
2599 new_dir = newnd.dentry; 2601 new_dir = newnd.path.dentry;
2600 if (newnd.last_type != LAST_NORM) 2602 if (newnd.last_type != LAST_NORM)
2601 goto exit2; 2603 goto exit2;
2602 2604
@@ -2640,9 +2642,9 @@ exit4:
2640exit3: 2642exit3:
2641 unlock_rename(new_dir, old_dir); 2643 unlock_rename(new_dir, old_dir);
2642exit2: 2644exit2:
2643 path_release(&newnd); 2645 path_put(&newnd.path);
2644exit1: 2646exit1:
2645 path_release(&oldnd); 2647 path_put(&oldnd.path);
2646exit: 2648exit:
2647 return error; 2649 return error;
2648} 2650}
@@ -2816,7 +2818,6 @@ EXPORT_SYMBOL(page_symlink);
2816EXPORT_SYMBOL(page_symlink_inode_operations); 2818EXPORT_SYMBOL(page_symlink_inode_operations);
2817EXPORT_SYMBOL(path_lookup); 2819EXPORT_SYMBOL(path_lookup);
2818EXPORT_SYMBOL(vfs_path_lookup); 2820EXPORT_SYMBOL(vfs_path_lookup);
2819EXPORT_SYMBOL(path_release);
2820EXPORT_SYMBOL(permission); 2821EXPORT_SYMBOL(permission);
2821EXPORT_SYMBOL(vfs_permission); 2822EXPORT_SYMBOL(vfs_permission);
2822EXPORT_SYMBOL(file_permission); 2823EXPORT_SYMBOL(file_permission);
diff --git a/fs/namespace.c b/fs/namespace.c
index 63ced21c12dc..7953c96a2071 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -157,13 +157,13 @@ static void __touch_mnt_namespace(struct mnt_namespace *ns)
157 157
158static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd) 158static void detach_mnt(struct vfsmount *mnt, struct nameidata *old_nd)
159{ 159{
160 old_nd->dentry = mnt->mnt_mountpoint; 160 old_nd->path.dentry = mnt->mnt_mountpoint;
161 old_nd->mnt = mnt->mnt_parent; 161 old_nd->path.mnt = mnt->mnt_parent;
162 mnt->mnt_parent = mnt; 162 mnt->mnt_parent = mnt;
163 mnt->mnt_mountpoint = mnt->mnt_root; 163 mnt->mnt_mountpoint = mnt->mnt_root;
164 list_del_init(&mnt->mnt_child); 164 list_del_init(&mnt->mnt_child);
165 list_del_init(&mnt->mnt_hash); 165 list_del_init(&mnt->mnt_hash);
166 old_nd->dentry->d_mounted--; 166 old_nd->path.dentry->d_mounted--;
167} 167}
168 168
169void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry, 169void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry,
@@ -176,10 +176,10 @@ void mnt_set_mountpoint(struct vfsmount *mnt, struct dentry *dentry,
176 176
177static void attach_mnt(struct vfsmount *mnt, struct nameidata *nd) 177static void attach_mnt(struct vfsmount *mnt, struct nameidata *nd)
178{ 178{
179 mnt_set_mountpoint(nd->mnt, nd->dentry, mnt); 179 mnt_set_mountpoint(nd->path.mnt, nd->path.dentry, mnt);
180 list_add_tail(&mnt->mnt_hash, mount_hashtable + 180 list_add_tail(&mnt->mnt_hash, mount_hashtable +
181 hash(nd->mnt, nd->dentry)); 181 hash(nd->path.mnt, nd->path.dentry));
182 list_add_tail(&mnt->mnt_child, &nd->mnt->mnt_mounts); 182 list_add_tail(&mnt->mnt_child, &nd->path.mnt->mnt_mounts);
183} 183}
184 184
185/* 185/*
@@ -408,10 +408,11 @@ static int show_vfsmnt(struct seq_file *m, void *v)
408 { 0, NULL } 408 { 0, NULL }
409 }; 409 };
410 struct proc_fs_info *fs_infop; 410 struct proc_fs_info *fs_infop;
411 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
411 412
412 mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none"); 413 mangle(m, mnt->mnt_devname ? mnt->mnt_devname : "none");
413 seq_putc(m, ' '); 414 seq_putc(m, ' ');
414 seq_path(m, mnt, mnt->mnt_root, " \t\n\\"); 415 seq_path(m, &mnt_path, " \t\n\\");
415 seq_putc(m, ' '); 416 seq_putc(m, ' ');
416 mangle(m, mnt->mnt_sb->s_type->name); 417 mangle(m, mnt->mnt_sb->s_type->name);
417 if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) { 418 if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0]) {
@@ -443,6 +444,7 @@ struct seq_operations mounts_op = {
443static int show_vfsstat(struct seq_file *m, void *v) 444static int show_vfsstat(struct seq_file *m, void *v)
444{ 445{
445 struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list); 446 struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
447 struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };
446 int err = 0; 448 int err = 0;
447 449
448 /* device */ 450 /* device */
@@ -454,7 +456,7 @@ static int show_vfsstat(struct seq_file *m, void *v)
454 456
455 /* mount point */ 457 /* mount point */
456 seq_puts(m, " mounted on "); 458 seq_puts(m, " mounted on ");
457 seq_path(m, mnt, mnt->mnt_root, " \t\n\\"); 459 seq_path(m, &mnt_path, " \t\n\\");
458 seq_putc(m, ' '); 460 seq_putc(m, ' ');
459 461
460 /* file system type */ 462 /* file system type */
@@ -593,7 +595,7 @@ static int do_umount(struct vfsmount *mnt, int flags)
593 * (2) the usage count == 1 [parent vfsmount] + 1 [sys_umount] 595 * (2) the usage count == 1 [parent vfsmount] + 1 [sys_umount]
594 */ 596 */
595 if (flags & MNT_EXPIRE) { 597 if (flags & MNT_EXPIRE) {
596 if (mnt == current->fs->rootmnt || 598 if (mnt == current->fs->root.mnt ||
597 flags & (MNT_FORCE | MNT_DETACH)) 599 flags & (MNT_FORCE | MNT_DETACH))
598 return -EINVAL; 600 return -EINVAL;
599 601
@@ -628,7 +630,7 @@ static int do_umount(struct vfsmount *mnt, int flags)
628 * /reboot - static binary that would close all descriptors and 630 * /reboot - static binary that would close all descriptors and
629 * call reboot(9). Then init(8) could umount root and exec /reboot. 631 * call reboot(9). Then init(8) could umount root and exec /reboot.
630 */ 632 */
631 if (mnt == current->fs->rootmnt && !(flags & MNT_DETACH)) { 633 if (mnt == current->fs->root.mnt && !(flags & MNT_DETACH)) {
632 /* 634 /*
633 * Special case for "unmounting" root ... 635 * Special case for "unmounting" root ...
634 * we just try to remount it readonly. 636 * we just try to remount it readonly.
@@ -679,18 +681,20 @@ asmlinkage long sys_umount(char __user * name, int flags)
679 if (retval) 681 if (retval)
680 goto out; 682 goto out;
681 retval = -EINVAL; 683 retval = -EINVAL;
682 if (nd.dentry != nd.mnt->mnt_root) 684 if (nd.path.dentry != nd.path.mnt->mnt_root)
683 goto dput_and_out; 685 goto dput_and_out;
684 if (!check_mnt(nd.mnt)) 686 if (!check_mnt(nd.path.mnt))
685 goto dput_and_out; 687 goto dput_and_out;
686 688
687 retval = -EPERM; 689 retval = -EPERM;
688 if (!capable(CAP_SYS_ADMIN)) 690 if (!capable(CAP_SYS_ADMIN))
689 goto dput_and_out; 691 goto dput_and_out;
690 692
691 retval = do_umount(nd.mnt, flags); 693 retval = do_umount(nd.path.mnt, flags);
692dput_and_out: 694dput_and_out:
693 path_release_on_umount(&nd); 695 /* we mustn't call path_put() as that would clear mnt_expiry_mark */
696 dput(nd.path.dentry);
697 mntput_no_expire(nd.path.mnt);
694out: 698out:
695 return retval; 699 return retval;
696} 700}
@@ -713,10 +717,10 @@ static int mount_is_safe(struct nameidata *nd)
713 return 0; 717 return 0;
714 return -EPERM; 718 return -EPERM;
715#ifdef notyet 719#ifdef notyet
716 if (S_ISLNK(nd->dentry->d_inode->i_mode)) 720 if (S_ISLNK(nd->path.dentry->d_inode->i_mode))
717 return -EPERM; 721 return -EPERM;
718 if (nd->dentry->d_inode->i_mode & S_ISVTX) { 722 if (nd->path.dentry->d_inode->i_mode & S_ISVTX) {
719 if (current->uid != nd->dentry->d_inode->i_uid) 723 if (current->uid != nd->path.dentry->d_inode->i_uid)
720 return -EPERM; 724 return -EPERM;
721 } 725 }
722 if (vfs_permission(nd, MAY_WRITE)) 726 if (vfs_permission(nd, MAY_WRITE))
@@ -765,8 +769,8 @@ struct vfsmount *copy_tree(struct vfsmount *mnt, struct dentry *dentry,
765 q = q->mnt_parent; 769 q = q->mnt_parent;
766 } 770 }
767 p = s; 771 p = s;
768 nd.mnt = q; 772 nd.path.mnt = q;
769 nd.dentry = p->mnt_mountpoint; 773 nd.path.dentry = p->mnt_mountpoint;
770 q = clone_mnt(p, p->mnt_root, flag); 774 q = clone_mnt(p, p->mnt_root, flag);
771 if (!q) 775 if (!q)
772 goto Enomem; 776 goto Enomem;
@@ -875,8 +879,8 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
875 struct nameidata *nd, struct nameidata *parent_nd) 879 struct nameidata *nd, struct nameidata *parent_nd)
876{ 880{
877 LIST_HEAD(tree_list); 881 LIST_HEAD(tree_list);
878 struct vfsmount *dest_mnt = nd->mnt; 882 struct vfsmount *dest_mnt = nd->path.mnt;
879 struct dentry *dest_dentry = nd->dentry; 883 struct dentry *dest_dentry = nd->path.dentry;
880 struct vfsmount *child, *p; 884 struct vfsmount *child, *p;
881 885
882 if (propagate_mnt(dest_mnt, dest_dentry, source_mnt, &tree_list)) 886 if (propagate_mnt(dest_mnt, dest_dentry, source_mnt, &tree_list))
@@ -911,13 +915,13 @@ static int graft_tree(struct vfsmount *mnt, struct nameidata *nd)
911 if (mnt->mnt_sb->s_flags & MS_NOUSER) 915 if (mnt->mnt_sb->s_flags & MS_NOUSER)
912 return -EINVAL; 916 return -EINVAL;
913 917
914 if (S_ISDIR(nd->dentry->d_inode->i_mode) != 918 if (S_ISDIR(nd->path.dentry->d_inode->i_mode) !=
915 S_ISDIR(mnt->mnt_root->d_inode->i_mode)) 919 S_ISDIR(mnt->mnt_root->d_inode->i_mode))
916 return -ENOTDIR; 920 return -ENOTDIR;
917 921
918 err = -ENOENT; 922 err = -ENOENT;
919 mutex_lock(&nd->dentry->d_inode->i_mutex); 923 mutex_lock(&nd->path.dentry->d_inode->i_mutex);
920 if (IS_DEADDIR(nd->dentry->d_inode)) 924 if (IS_DEADDIR(nd->path.dentry->d_inode))
921 goto out_unlock; 925 goto out_unlock;
922 926
923 err = security_sb_check_sb(mnt, nd); 927 err = security_sb_check_sb(mnt, nd);
@@ -925,10 +929,10 @@ static int graft_tree(struct vfsmount *mnt, struct nameidata *nd)
925 goto out_unlock; 929 goto out_unlock;
926 930
927 err = -ENOENT; 931 err = -ENOENT;
928 if (IS_ROOT(nd->dentry) || !d_unhashed(nd->dentry)) 932 if (IS_ROOT(nd->path.dentry) || !d_unhashed(nd->path.dentry))
929 err = attach_recursive_mnt(mnt, nd, NULL); 933 err = attach_recursive_mnt(mnt, nd, NULL);
930out_unlock: 934out_unlock:
931 mutex_unlock(&nd->dentry->d_inode->i_mutex); 935 mutex_unlock(&nd->path.dentry->d_inode->i_mutex);
932 if (!err) 936 if (!err)
933 security_sb_post_addmount(mnt, nd); 937 security_sb_post_addmount(mnt, nd);
934 return err; 938 return err;
@@ -940,14 +944,14 @@ out_unlock:
940 */ 944 */
941static noinline int do_change_type(struct nameidata *nd, int flag) 945static noinline int do_change_type(struct nameidata *nd, int flag)
942{ 946{
943 struct vfsmount *m, *mnt = nd->mnt; 947 struct vfsmount *m, *mnt = nd->path.mnt;
944 int recurse = flag & MS_REC; 948 int recurse = flag & MS_REC;
945 int type = flag & ~MS_REC; 949 int type = flag & ~MS_REC;
946 950
947 if (!capable(CAP_SYS_ADMIN)) 951 if (!capable(CAP_SYS_ADMIN))
948 return -EPERM; 952 return -EPERM;
949 953
950 if (nd->dentry != nd->mnt->mnt_root) 954 if (nd->path.dentry != nd->path.mnt->mnt_root)
951 return -EINVAL; 955 return -EINVAL;
952 956
953 down_write(&namespace_sem); 957 down_write(&namespace_sem);
@@ -979,17 +983,17 @@ static noinline int do_loopback(struct nameidata *nd, char *old_name,
979 983
980 down_write(&namespace_sem); 984 down_write(&namespace_sem);
981 err = -EINVAL; 985 err = -EINVAL;
982 if (IS_MNT_UNBINDABLE(old_nd.mnt)) 986 if (IS_MNT_UNBINDABLE(old_nd.path.mnt))
983 goto out; 987 goto out;
984 988
985 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) 989 if (!check_mnt(nd->path.mnt) || !check_mnt(old_nd.path.mnt))
986 goto out; 990 goto out;
987 991
988 err = -ENOMEM; 992 err = -ENOMEM;
989 if (recurse) 993 if (recurse)
990 mnt = copy_tree(old_nd.mnt, old_nd.dentry, 0); 994 mnt = copy_tree(old_nd.path.mnt, old_nd.path.dentry, 0);
991 else 995 else
992 mnt = clone_mnt(old_nd.mnt, old_nd.dentry, 0); 996 mnt = clone_mnt(old_nd.path.mnt, old_nd.path.dentry, 0);
993 997
994 if (!mnt) 998 if (!mnt)
995 goto out; 999 goto out;
@@ -1005,7 +1009,7 @@ static noinline int do_loopback(struct nameidata *nd, char *old_name,
1005 1009
1006out: 1010out:
1007 up_write(&namespace_sem); 1011 up_write(&namespace_sem);
1008 path_release(&old_nd); 1012 path_put(&old_nd.path);
1009 return err; 1013 return err;
1010} 1014}
1011 1015
@@ -1019,24 +1023,24 @@ static noinline int do_remount(struct nameidata *nd, int flags, int mnt_flags,
1019 void *data) 1023 void *data)
1020{ 1024{
1021 int err; 1025 int err;
1022 struct super_block *sb = nd->mnt->mnt_sb; 1026 struct super_block *sb = nd->path.mnt->mnt_sb;
1023 1027
1024 if (!capable(CAP_SYS_ADMIN)) 1028 if (!capable(CAP_SYS_ADMIN))
1025 return -EPERM; 1029 return -EPERM;
1026 1030
1027 if (!check_mnt(nd->mnt)) 1031 if (!check_mnt(nd->path.mnt))
1028 return -EINVAL; 1032 return -EINVAL;
1029 1033
1030 if (nd->dentry != nd->mnt->mnt_root) 1034 if (nd->path.dentry != nd->path.mnt->mnt_root)
1031 return -EINVAL; 1035 return -EINVAL;
1032 1036
1033 down_write(&sb->s_umount); 1037 down_write(&sb->s_umount);
1034 err = do_remount_sb(sb, flags, data, 0); 1038 err = do_remount_sb(sb, flags, data, 0);
1035 if (!err) 1039 if (!err)
1036 nd->mnt->mnt_flags = mnt_flags; 1040 nd->path.mnt->mnt_flags = mnt_flags;
1037 up_write(&sb->s_umount); 1041 up_write(&sb->s_umount);
1038 if (!err) 1042 if (!err)
1039 security_sb_post_remount(nd->mnt, flags, data); 1043 security_sb_post_remount(nd->path.mnt, flags, data);
1040 return err; 1044 return err;
1041} 1045}
1042 1046
@@ -1067,61 +1071,65 @@ static noinline int do_move_mount(struct nameidata *nd, char *old_name)
1067 return err; 1071 return err;
1068 1072
1069 down_write(&namespace_sem); 1073 down_write(&namespace_sem);
1070 while (d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) 1074 while (d_mountpoint(nd->path.dentry) &&
1075 follow_down(&nd->path.mnt, &nd->path.dentry))
1071 ; 1076 ;
1072 err = -EINVAL; 1077 err = -EINVAL;
1073 if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) 1078 if (!check_mnt(nd->path.mnt) || !check_mnt(old_nd.path.mnt))
1074 goto out; 1079 goto out;
1075 1080
1076 err = -ENOENT; 1081 err = -ENOENT;
1077 mutex_lock(&nd->dentry->d_inode->i_mutex); 1082 mutex_lock(&nd->path.dentry->d_inode->i_mutex);
1078 if (IS_DEADDIR(nd->dentry->d_inode)) 1083 if (IS_DEADDIR(nd->path.dentry->d_inode))
1079 goto out1; 1084 goto out1;
1080 1085
1081 if (!IS_ROOT(nd->dentry) && d_unhashed(nd->dentry)) 1086 if (!IS_ROOT(nd->path.dentry) && d_unhashed(nd->path.dentry))
1082 goto out1; 1087 goto out1;
1083 1088
1084 err = -EINVAL; 1089 err = -EINVAL;
1085 if (old_nd.dentry != old_nd.mnt->mnt_root) 1090 if (old_nd.path.dentry != old_nd.path.mnt->mnt_root)
1086 goto out1; 1091 goto out1;
1087 1092
1088 if (old_nd.mnt == old_nd.mnt->mnt_parent) 1093 if (old_nd.path.mnt == old_nd.path.mnt->mnt_parent)
1089 goto out1; 1094 goto out1;
1090 1095
1091 if (S_ISDIR(nd->dentry->d_inode->i_mode) != 1096 if (S_ISDIR(nd->path.dentry->d_inode->i_mode) !=
1092 S_ISDIR(old_nd.dentry->d_inode->i_mode)) 1097 S_ISDIR(old_nd.path.dentry->d_inode->i_mode))
1093 goto out1; 1098 goto out1;
1094 /* 1099 /*
1095 * Don't move a mount residing in a shared parent. 1100 * Don't move a mount residing in a shared parent.
1096 */ 1101 */
1097 if (old_nd.mnt->mnt_parent && IS_MNT_SHARED(old_nd.mnt->mnt_parent)) 1102 if (old_nd.path.mnt->mnt_parent &&
1103 IS_MNT_SHARED(old_nd.path.mnt->mnt_parent))
1098 goto out1; 1104 goto out1;
1099 /* 1105 /*
1100 * Don't move a mount tree containing unbindable mounts to a destination 1106 * Don't move a mount tree containing unbindable mounts to a destination
1101 * mount which is shared. 1107 * mount which is shared.
1102 */ 1108 */
1103 if (IS_MNT_SHARED(nd->mnt) && tree_contains_unbindable(old_nd.mnt)) 1109 if (IS_MNT_SHARED(nd->path.mnt) &&
1110 tree_contains_unbindable(old_nd.path.mnt))
1104 goto out1; 1111 goto out1;
1105 err = -ELOOP; 1112 err = -ELOOP;
1106 for (p = nd->mnt; p->mnt_parent != p; p = p->mnt_parent) 1113 for (p = nd->path.mnt; p->mnt_parent != p; p = p->mnt_parent)
1107 if (p == old_nd.mnt) 1114 if (p == old_nd.path.mnt)
1108 goto out1; 1115 goto out1;
1109 1116
1110 if ((err = attach_recursive_mnt(old_nd.mnt, nd, &parent_nd))) 1117 err = attach_recursive_mnt(old_nd.path.mnt, nd, &parent_nd);
1118 if (err)
1111 goto out1; 1119 goto out1;
1112 1120
1113 spin_lock(&vfsmount_lock); 1121 spin_lock(&vfsmount_lock);
1114 /* if the mount is moved, it should no longer be expire 1122 /* if the mount is moved, it should no longer be expire
1115 * automatically */ 1123 * automatically */
1116 list_del_init(&old_nd.mnt->mnt_expire); 1124 list_del_init(&old_nd.path.mnt->mnt_expire);
1117 spin_unlock(&vfsmount_lock); 1125 spin_unlock(&vfsmount_lock);
1118out1: 1126out1:
1119 mutex_unlock(&nd->dentry->d_inode->i_mutex); 1127 mutex_unlock(&nd->path.dentry->d_inode->i_mutex);
1120out: 1128out:
1121 up_write(&namespace_sem); 1129 up_write(&namespace_sem);
1122 if (!err) 1130 if (!err)
1123 path_release(&parent_nd); 1131 path_put(&parent_nd.path);
1124 path_release(&old_nd); 1132 path_put(&old_nd.path);
1125 return err; 1133 return err;
1126} 1134}
1127 1135
@@ -1160,16 +1168,17 @@ int do_add_mount(struct vfsmount *newmnt, struct nameidata *nd,
1160 1168
1161 down_write(&namespace_sem); 1169 down_write(&namespace_sem);
1162 /* Something was mounted here while we slept */ 1170 /* Something was mounted here while we slept */
1163 while (d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) 1171 while (d_mountpoint(nd->path.dentry) &&
1172 follow_down(&nd->path.mnt, &nd->path.dentry))
1164 ; 1173 ;
1165 err = -EINVAL; 1174 err = -EINVAL;
1166 if (!check_mnt(nd->mnt)) 1175 if (!check_mnt(nd->path.mnt))
1167 goto unlock; 1176 goto unlock;
1168 1177
1169 /* Refuse the same filesystem on the same mount point */ 1178 /* Refuse the same filesystem on the same mount point */
1170 err = -EBUSY; 1179 err = -EBUSY;
1171 if (nd->mnt->mnt_sb == newmnt->mnt_sb && 1180 if (nd->path.mnt->mnt_sb == newmnt->mnt_sb &&
1172 nd->mnt->mnt_root == nd->dentry) 1181 nd->path.mnt->mnt_root == nd->path.dentry)
1173 goto unlock; 1182 goto unlock;
1174 1183
1175 err = -EINVAL; 1184 err = -EINVAL;
@@ -1505,7 +1514,7 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
1505 retval = do_new_mount(&nd, type_page, flags, mnt_flags, 1514 retval = do_new_mount(&nd, type_page, flags, mnt_flags,
1506 dev_name, data_page); 1515 dev_name, data_page);
1507dput_out: 1516dput_out:
1508 path_release(&nd); 1517 path_put(&nd.path);
1509 return retval; 1518 return retval;
1510} 1519}
1511 1520
@@ -1552,17 +1561,17 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
1552 while (p) { 1561 while (p) {
1553 q->mnt_ns = new_ns; 1562 q->mnt_ns = new_ns;
1554 if (fs) { 1563 if (fs) {
1555 if (p == fs->rootmnt) { 1564 if (p == fs->root.mnt) {
1556 rootmnt = p; 1565 rootmnt = p;
1557 fs->rootmnt = mntget(q); 1566 fs->root.mnt = mntget(q);
1558 } 1567 }
1559 if (p == fs->pwdmnt) { 1568 if (p == fs->pwd.mnt) {
1560 pwdmnt = p; 1569 pwdmnt = p;
1561 fs->pwdmnt = mntget(q); 1570 fs->pwd.mnt = mntget(q);
1562 } 1571 }
1563 if (p == fs->altrootmnt) { 1572 if (p == fs->altroot.mnt) {
1564 altrootmnt = p; 1573 altrootmnt = p;
1565 fs->altrootmnt = mntget(q); 1574 fs->altroot.mnt = mntget(q);
1566 } 1575 }
1567 } 1576 }
1568 p = next_mnt(p, mnt_ns->root); 1577 p = next_mnt(p, mnt_ns->root);
@@ -1643,44 +1652,35 @@ out1:
1643 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. 1652 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
1644 * It can block. Requires the big lock held. 1653 * It can block. Requires the big lock held.
1645 */ 1654 */
1646void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt, 1655void set_fs_root(struct fs_struct *fs, struct path *path)
1647 struct dentry *dentry)
1648{ 1656{
1649 struct dentry *old_root; 1657 struct path old_root;
1650 struct vfsmount *old_rootmnt; 1658
1651 write_lock(&fs->lock); 1659 write_lock(&fs->lock);
1652 old_root = fs->root; 1660 old_root = fs->root;
1653 old_rootmnt = fs->rootmnt; 1661 fs->root = *path;
1654 fs->rootmnt = mntget(mnt); 1662 path_get(path);
1655 fs->root = dget(dentry);
1656 write_unlock(&fs->lock); 1663 write_unlock(&fs->lock);
1657 if (old_root) { 1664 if (old_root.dentry)
1658 dput(old_root); 1665 path_put(&old_root);
1659 mntput(old_rootmnt);
1660 }
1661} 1666}
1662 1667
1663/* 1668/*
1664 * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. 1669 * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values.
1665 * It can block. Requires the big lock held. 1670 * It can block. Requires the big lock held.
1666 */ 1671 */
1667void set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt, 1672void set_fs_pwd(struct fs_struct *fs, struct path *path)
1668 struct dentry *dentry)
1669{ 1673{
1670 struct dentry *old_pwd; 1674 struct path old_pwd;
1671 struct vfsmount *old_pwdmnt;
1672 1675
1673 write_lock(&fs->lock); 1676 write_lock(&fs->lock);
1674 old_pwd = fs->pwd; 1677 old_pwd = fs->pwd;
1675 old_pwdmnt = fs->pwdmnt; 1678 fs->pwd = *path;
1676 fs->pwdmnt = mntget(mnt); 1679 path_get(path);
1677 fs->pwd = dget(dentry);
1678 write_unlock(&fs->lock); 1680 write_unlock(&fs->lock);
1679 1681
1680 if (old_pwd) { 1682 if (old_pwd.dentry)
1681 dput(old_pwd); 1683 path_put(&old_pwd);
1682 mntput(old_pwdmnt);
1683 }
1684} 1684}
1685 1685
1686static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd) 1686static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
@@ -1695,12 +1695,12 @@ static void chroot_fs_refs(struct nameidata *old_nd, struct nameidata *new_nd)
1695 if (fs) { 1695 if (fs) {
1696 atomic_inc(&fs->count); 1696 atomic_inc(&fs->count);
1697 task_unlock(p); 1697 task_unlock(p);
1698 if (fs->root == old_nd->dentry 1698 if (fs->root.dentry == old_nd->path.dentry
1699 && fs->rootmnt == old_nd->mnt) 1699 && fs->root.mnt == old_nd->path.mnt)
1700 set_fs_root(fs, new_nd->mnt, new_nd->dentry); 1700 set_fs_root(fs, &new_nd->path);
1701 if (fs->pwd == old_nd->dentry 1701 if (fs->pwd.dentry == old_nd->path.dentry
1702 && fs->pwdmnt == old_nd->mnt) 1702 && fs->pwd.mnt == old_nd->path.mnt)
1703 set_fs_pwd(fs, new_nd->mnt, new_nd->dentry); 1703 set_fs_pwd(fs, &new_nd->path);
1704 put_fs_struct(fs); 1704 put_fs_struct(fs);
1705 } else 1705 } else
1706 task_unlock(p); 1706 task_unlock(p);
@@ -1750,7 +1750,7 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
1750 if (error) 1750 if (error)
1751 goto out0; 1751 goto out0;
1752 error = -EINVAL; 1752 error = -EINVAL;
1753 if (!check_mnt(new_nd.mnt)) 1753 if (!check_mnt(new_nd.path.mnt))
1754 goto out1; 1754 goto out1;
1755 1755
1756 error = __user_walk(put_old, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &old_nd); 1756 error = __user_walk(put_old, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &old_nd);
@@ -1759,74 +1759,78 @@ asmlinkage long sys_pivot_root(const char __user * new_root,
1759 1759
1760 error = security_sb_pivotroot(&old_nd, &new_nd); 1760 error = security_sb_pivotroot(&old_nd, &new_nd);
1761 if (error) { 1761 if (error) {
1762 path_release(&old_nd); 1762 path_put(&old_nd.path);
1763 goto out1; 1763 goto out1;
1764 } 1764 }
1765 1765
1766 read_lock(&current->fs->lock); 1766 read_lock(&current->fs->lock);
1767 user_nd.mnt = mntget(current->fs->rootmnt); 1767 user_nd.path = current->fs->root;
1768 user_nd.dentry = dget(current->fs->root); 1768 path_get(&current->fs->root);
1769 read_unlock(&current->fs->lock); 1769 read_unlock(&current->fs->lock);
1770 down_write(&namespace_sem); 1770 down_write(&namespace_sem);
1771 mutex_lock(&old_nd.dentry->d_inode->i_mutex); 1771 mutex_lock(&old_nd.path.dentry->d_inode->i_mutex);
1772 error = -EINVAL; 1772 error = -EINVAL;
1773 if (IS_MNT_SHARED(old_nd.mnt) || 1773 if (IS_MNT_SHARED(old_nd.path.mnt) ||
1774 IS_MNT_SHARED(new_nd.mnt->mnt_parent) || 1774 IS_MNT_SHARED(new_nd.path.mnt->mnt_parent) ||
1775 IS_MNT_SHARED(user_nd.mnt->mnt_parent)) 1775 IS_MNT_SHARED(user_nd.path.mnt->mnt_parent))
1776 goto out2; 1776 goto out2;
1777 if (!check_mnt(user_nd.mnt)) 1777 if (!check_mnt(user_nd.path.mnt))
1778 goto out2; 1778 goto out2;
1779 error = -ENOENT; 1779 error = -ENOENT;
1780 if (IS_DEADDIR(new_nd.dentry->d_inode)) 1780 if (IS_DEADDIR(new_nd.path.dentry->d_inode))
1781 goto out2; 1781 goto out2;
1782 if (d_unhashed(new_nd.dentry) && !IS_ROOT(new_nd.dentry)) 1782 if (d_unhashed(new_nd.path.dentry) && !IS_ROOT(new_nd.path.dentry))
1783 goto out2; 1783 goto out2;
1784 if (d_unhashed(old_nd.dentry) && !IS_ROOT(old_nd.dentry)) 1784 if (d_unhashed(old_nd.path.dentry) && !IS_ROOT(old_nd.path.dentry))
1785 goto out2; 1785 goto out2;
1786 error = -EBUSY; 1786 error = -EBUSY;
1787 if (new_nd.mnt == user_nd.mnt || old_nd.mnt == user_nd.mnt) 1787 if (new_nd.path.mnt == user_nd.path.mnt ||
1788 old_nd.path.mnt == user_nd.path.mnt)
1788 goto out2; /* loop, on the same file system */ 1789 goto out2; /* loop, on the same file system */
1789 error = -EINVAL; 1790 error = -EINVAL;
1790 if (user_nd.mnt->mnt_root != user_nd.dentry) 1791 if (user_nd.path.mnt->mnt_root != user_nd.path.dentry)
1791 goto out2; /* not a mountpoint */ 1792 goto out2; /* not a mountpoint */
1792 if (user_nd.mnt->mnt_parent == user_nd.mnt) 1793 if (user_nd.path.mnt->mnt_parent == user_nd.path.mnt)
1793 goto out2; /* not attached */ 1794 goto out2; /* not attached */
1794 if (new_nd.mnt->mnt_root != new_nd.dentry) 1795 if (new_nd.path.mnt->mnt_root != new_nd.path.dentry)
1795 goto out2; /* not a mountpoint */ 1796 goto out2; /* not a mountpoint */
1796 if (new_nd.mnt->mnt_parent == new_nd.mnt) 1797 if (new_nd.path.mnt->mnt_parent == new_nd.path.mnt)
1797 goto out2; /* not attached */ 1798 goto out2; /* not attached */
1798 tmp = old_nd.mnt; /* make sure we can reach put_old from new_root */ 1799 /* make sure we can reach put_old from new_root */
1800 tmp = old_nd.path.mnt;
1799 spin_lock(&vfsmount_lock); 1801 spin_lock(&vfsmount_lock);
1800 if (tmp != new_nd.mnt) { 1802 if (tmp != new_nd.path.mnt) {
1801 for (;;) { 1803 for (;;) {
1802 if (tmp->mnt_parent == tmp) 1804 if (tmp->mnt_parent == tmp)
1803 goto out3; /* already mounted on put_old */ 1805 goto out3; /* already mounted on put_old */
1804 if (tmp->mnt_parent == new_nd.mnt) 1806 if (tmp->mnt_parent == new_nd.path.mnt)
1805 break; 1807 break;
1806 tmp = tmp->mnt_parent; 1808 tmp = tmp->mnt_parent;
1807 } 1809 }
1808 if (!is_subdir(tmp->mnt_mountpoint, new_nd.dentry)) 1810 if (!is_subdir(tmp->mnt_mountpoint, new_nd.path.dentry))
1809 goto out3; 1811 goto out3;
1810 } else if (!is_subdir(old_nd.dentry, new_nd.dentry)) 1812 } else if (!is_subdir(old_nd.path.dentry, new_nd.path.dentry))
1811 goto out3; 1813 goto out3;
1812 detach_mnt(new_nd.mnt, &parent_nd); 1814 detach_mnt(new_nd.path.mnt, &parent_nd);
1813 detach_mnt(user_nd.mnt, &root_parent); 1815 detach_mnt(user_nd.path.mnt, &root_parent);
1814 attach_mnt(user_nd.mnt, &old_nd); /* mount old root on put_old */ 1816 /* mount old root on put_old */
1815 attach_mnt(new_nd.mnt, &root_parent); /* mount new_root on / */ 1817 attach_mnt(user_nd.path.mnt, &old_nd);
1818 /* mount new_root on / */
1819 attach_mnt(new_nd.path.mnt, &root_parent);
1816 touch_mnt_namespace(current->nsproxy->mnt_ns); 1820 touch_mnt_namespace(current->nsproxy->mnt_ns);
1817 spin_unlock(&vfsmount_lock); 1821 spin_unlock(&vfsmount_lock);
1818 chroot_fs_refs(&user_nd, &new_nd); 1822 chroot_fs_refs(&user_nd, &new_nd);
1819 security_sb_post_pivotroot(&user_nd, &new_nd); 1823 security_sb_post_pivotroot(&user_nd, &new_nd);
1820 error = 0; 1824 error = 0;
1821 path_release(&root_parent); 1825 path_put(&root_parent.path);
1822 path_release(&parent_nd); 1826 path_put(&parent_nd.path);
1823out2: 1827out2:
1824 mutex_unlock(&old_nd.dentry->d_inode->i_mutex); 1828 mutex_unlock(&old_nd.path.dentry->d_inode->i_mutex);
1825 up_write(&namespace_sem); 1829 up_write(&namespace_sem);
1826 path_release(&user_nd); 1830 path_put(&user_nd.path);
1827 path_release(&old_nd); 1831 path_put(&old_nd.path);
1828out1: 1832out1:
1829 path_release(&new_nd); 1833 path_put(&new_nd.path);
1830out0: 1834out0:
1831 unlock_kernel(); 1835 unlock_kernel();
1832 return error; 1836 return error;
@@ -1839,6 +1843,7 @@ static void __init init_mount_tree(void)
1839{ 1843{
1840 struct vfsmount *mnt; 1844 struct vfsmount *mnt;
1841 struct mnt_namespace *ns; 1845 struct mnt_namespace *ns;
1846 struct path root;
1842 1847
1843 mnt = do_kern_mount("rootfs", 0, "rootfs", NULL); 1848 mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);
1844 if (IS_ERR(mnt)) 1849 if (IS_ERR(mnt))
@@ -1857,8 +1862,11 @@ static void __init init_mount_tree(void)
1857 init_task.nsproxy->mnt_ns = ns; 1862 init_task.nsproxy->mnt_ns = ns;
1858 get_mnt_ns(ns); 1863 get_mnt_ns(ns);
1859 1864
1860 set_fs_pwd(current->fs, ns->root, ns->root->mnt_root); 1865 root.mnt = ns->root;
1861 set_fs_root(current->fs, ns->root, ns->root->mnt_root); 1866 root.dentry = ns->root->mnt_root;
1867
1868 set_fs_pwd(current->fs, &root);
1869 set_fs_root(current->fs, &root);
1862} 1870}
1863 1871
1864void __init mnt_init(void) 1872void __init mnt_init(void)
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index bd185a572a23..ecc06c619494 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -105,7 +105,7 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
105 */ 105 */
106int nfs_callback_up(void) 106int nfs_callback_up(void)
107{ 107{
108 struct svc_serv *serv; 108 struct svc_serv *serv = NULL;
109 int ret = 0; 109 int ret = 0;
110 110
111 lock_kernel(); 111 lock_kernel();
@@ -122,24 +122,30 @@ int nfs_callback_up(void)
122 ret = svc_create_xprt(serv, "tcp", nfs_callback_set_tcpport, 122 ret = svc_create_xprt(serv, "tcp", nfs_callback_set_tcpport,
123 SVC_SOCK_ANONYMOUS); 123 SVC_SOCK_ANONYMOUS);
124 if (ret <= 0) 124 if (ret <= 0)
125 goto out_destroy; 125 goto out_err;
126 nfs_callback_tcpport = ret; 126 nfs_callback_tcpport = ret;
127 dprintk("Callback port = 0x%x\n", nfs_callback_tcpport); 127 dprintk("Callback port = 0x%x\n", nfs_callback_tcpport);
128 128
129 ret = svc_create_thread(nfs_callback_svc, serv); 129 ret = svc_create_thread(nfs_callback_svc, serv);
130 if (ret < 0) 130 if (ret < 0)
131 goto out_destroy; 131 goto out_err;
132 nfs_callback_info.serv = serv; 132 nfs_callback_info.serv = serv;
133 wait_for_completion(&nfs_callback_info.started); 133 wait_for_completion(&nfs_callback_info.started);
134out: 134out:
135 /*
136 * svc_create creates the svc_serv with sv_nrthreads == 1, and then
137 * svc_create_thread increments that. So we need to call svc_destroy
138 * on both success and failure so that the refcount is 1 when the
139 * thread exits.
140 */
141 if (serv)
142 svc_destroy(serv);
135 mutex_unlock(&nfs_callback_mutex); 143 mutex_unlock(&nfs_callback_mutex);
136 unlock_kernel(); 144 unlock_kernel();
137 return ret; 145 return ret;
138out_destroy: 146out_err:
139 dprintk("Couldn't create callback socket or server thread; err = %d\n", 147 dprintk("Couldn't create callback socket or server thread; err = %d\n",
140 ret); 148 ret);
141 svc_destroy(serv);
142out_err:
143 nfs_callback_info.users--; 149 nfs_callback_info.users--;
144 goto out; 150 goto out;
145} 151}
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 476cb0f837fd..ae04892a5e5d 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -154,7 +154,6 @@ typedef struct {
154 struct nfs_entry *entry; 154 struct nfs_entry *entry;
155 decode_dirent_t decode; 155 decode_dirent_t decode;
156 int plus; 156 int plus;
157 int error;
158 unsigned long timestamp; 157 unsigned long timestamp;
159 int timestamp_valid; 158 int timestamp_valid;
160} nfs_readdir_descriptor_t; 159} nfs_readdir_descriptor_t;
@@ -213,7 +212,6 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page)
213 return 0; 212 return 0;
214 error: 213 error:
215 unlock_page(page); 214 unlock_page(page);
216 desc->error = error;
217 return -EIO; 215 return -EIO;
218} 216}
219 217
@@ -483,13 +481,13 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent,
483 goto out; 481 goto out;
484 } 482 }
485 timestamp = jiffies; 483 timestamp = jiffies;
486 desc->error = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred, *desc->dir_cookie, 484 status = NFS_PROTO(inode)->readdir(file->f_path.dentry, cred,
487 page, 485 *desc->dir_cookie, page,
488 NFS_SERVER(inode)->dtsize, 486 NFS_SERVER(inode)->dtsize,
489 desc->plus); 487 desc->plus);
490 desc->page = page; 488 desc->page = page;
491 desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */ 489 desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */
492 if (desc->error >= 0) { 490 if (status >= 0) {
493 desc->timestamp = timestamp; 491 desc->timestamp = timestamp;
494 desc->timestamp_valid = 1; 492 desc->timestamp_valid = 1;
495 if ((status = dir_decode(desc)) == 0) 493 if ((status = dir_decode(desc)) == 0)
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index be4ce1c3a3d8..607f6eb9cdb5 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -107,38 +107,40 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd)
107 107
108 BUG_ON(IS_ROOT(dentry)); 108 BUG_ON(IS_ROOT(dentry));
109 dprintk("%s: enter\n", __FUNCTION__); 109 dprintk("%s: enter\n", __FUNCTION__);
110 dput(nd->dentry); 110 dput(nd->path.dentry);
111 nd->dentry = dget(dentry); 111 nd->path.dentry = dget(dentry);
112 112
113 /* Look it up again */ 113 /* Look it up again */
114 parent = dget_parent(nd->dentry); 114 parent = dget_parent(nd->path.dentry);
115 err = server->nfs_client->rpc_ops->lookup(parent->d_inode, 115 err = server->nfs_client->rpc_ops->lookup(parent->d_inode,
116 &nd->dentry->d_name, 116 &nd->path.dentry->d_name,
117 &fh, &fattr); 117 &fh, &fattr);
118 dput(parent); 118 dput(parent);
119 if (err != 0) 119 if (err != 0)
120 goto out_err; 120 goto out_err;
121 121
122 if (fattr.valid & NFS_ATTR_FATTR_V4_REFERRAL) 122 if (fattr.valid & NFS_ATTR_FATTR_V4_REFERRAL)
123 mnt = nfs_do_refmount(nd->mnt, nd->dentry); 123 mnt = nfs_do_refmount(nd->path.mnt, nd->path.dentry);
124 else 124 else
125 mnt = nfs_do_submount(nd->mnt, nd->dentry, &fh, &fattr); 125 mnt = nfs_do_submount(nd->path.mnt, nd->path.dentry, &fh,
126 &fattr);
126 err = PTR_ERR(mnt); 127 err = PTR_ERR(mnt);
127 if (IS_ERR(mnt)) 128 if (IS_ERR(mnt))
128 goto out_err; 129 goto out_err;
129 130
130 mntget(mnt); 131 mntget(mnt);
131 err = do_add_mount(mnt, nd, nd->mnt->mnt_flags|MNT_SHRINKABLE, &nfs_automount_list); 132 err = do_add_mount(mnt, nd, nd->path.mnt->mnt_flags|MNT_SHRINKABLE,
133 &nfs_automount_list);
132 if (err < 0) { 134 if (err < 0) {
133 mntput(mnt); 135 mntput(mnt);
134 if (err == -EBUSY) 136 if (err == -EBUSY)
135 goto out_follow; 137 goto out_follow;
136 goto out_err; 138 goto out_err;
137 } 139 }
138 mntput(nd->mnt); 140 mntput(nd->path.mnt);
139 dput(nd->dentry); 141 dput(nd->path.dentry);
140 nd->mnt = mnt; 142 nd->path.mnt = mnt;
141 nd->dentry = dget(mnt->mnt_root); 143 nd->path.dentry = dget(mnt->mnt_root);
142 schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout); 144 schedule_delayed_work(&nfs_automount_task, nfs_mountpoint_expiry_timeout);
143out: 145out:
144 dprintk("%s: done, returned %d\n", __FUNCTION__, err); 146 dprintk("%s: done, returned %d\n", __FUNCTION__, err);
@@ -146,10 +148,11 @@ out:
146 dprintk("<-- nfs_follow_mountpoint() = %d\n", err); 148 dprintk("<-- nfs_follow_mountpoint() = %d\n", err);
147 return ERR_PTR(err); 149 return ERR_PTR(err);
148out_err: 150out_err:
149 path_release(nd); 151 path_put(&nd->path);
150 goto out; 152 goto out;
151out_follow: 153out_follow:
152 while(d_mountpoint(nd->dentry) && follow_down(&nd->mnt, &nd->dentry)) 154 while (d_mountpoint(nd->path.dentry) &&
155 follow_down(&nd->path.mnt, &nd->path.dentry))
153 ; 156 ;
154 err = 0; 157 err = 0;
155 goto out; 158 goto out;
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 027e1095256e..7ce07862c2fb 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1384,11 +1384,11 @@ out_close:
1384struct dentry * 1384struct dentry *
1385nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd) 1385nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
1386{ 1386{
1387 struct dentry *parent;
1388 struct path path = { 1387 struct path path = {
1389 .mnt = nd->mnt, 1388 .mnt = nd->path.mnt,
1390 .dentry = dentry, 1389 .dentry = dentry,
1391 }; 1390 };
1391 struct dentry *parent;
1392 struct iattr attr; 1392 struct iattr attr;
1393 struct rpc_cred *cred; 1393 struct rpc_cred *cred;
1394 struct nfs4_state *state; 1394 struct nfs4_state *state;
@@ -1433,7 +1433,7 @@ int
1433nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, struct nameidata *nd) 1433nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, struct nameidata *nd)
1434{ 1434{
1435 struct path path = { 1435 struct path path = {
1436 .mnt = nd->mnt, 1436 .mnt = nd->path.mnt,
1437 .dentry = dentry, 1437 .dentry = dentry,
1438 }; 1438 };
1439 struct rpc_cred *cred; 1439 struct rpc_cred *cred;
@@ -1885,7 +1885,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
1885 int flags, struct nameidata *nd) 1885 int flags, struct nameidata *nd)
1886{ 1886{
1887 struct path path = { 1887 struct path path = {
1888 .mnt = nd->mnt, 1888 .mnt = nd->path.mnt,
1889 .dentry = dentry, 1889 .dentry = dentry,
1890 }; 1890 };
1891 struct nfs4_state *state; 1891 struct nfs4_state *state;
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index f9c7432471dc..6233eb5e98c1 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -682,8 +682,8 @@ static void nfs_increment_seqid(int status, struct nfs_seqid *seqid)
682 if (seqid->sequence->flags & NFS_SEQID_CONFIRMED) 682 if (seqid->sequence->flags & NFS_SEQID_CONFIRMED)
683 return; 683 return;
684 printk(KERN_WARNING "NFS: v4 server returned a bad" 684 printk(KERN_WARNING "NFS: v4 server returned a bad"
685 "sequence-id error on an" 685 " sequence-id error on an"
686 "unconfirmed sequence %p!\n", 686 " unconfirmed sequence %p!\n",
687 seqid->sequence); 687 seqid->sequence);
688 case -NFS4ERR_STALE_CLIENTID: 688 case -NFS4ERR_STALE_CLIENTID:
689 case -NFS4ERR_STALE_STATEID: 689 case -NFS4ERR_STALE_STATEID:
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 7f4505f6ac6f..1fb381843650 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -190,6 +190,10 @@ static match_table_t nfs_secflavor_tokens = {
190 { Opt_sec_lkeyi, "lkeyi" }, 190 { Opt_sec_lkeyi, "lkeyi" },
191 { Opt_sec_lkeyp, "lkeyp" }, 191 { Opt_sec_lkeyp, "lkeyp" },
192 192
193 { Opt_sec_spkm, "spkm3" },
194 { Opt_sec_spkmi, "spkm3i" },
195 { Opt_sec_spkmp, "spkm3p" },
196
193 { Opt_sec_err, NULL } 197 { Opt_sec_err, NULL }
194}; 198};
195 199
diff --git a/fs/nfsctl.c b/fs/nfsctl.c
index 51f1b31acbf6..aed8145d9087 100644
--- a/fs/nfsctl.c
+++ b/fs/nfsctl.c
@@ -41,9 +41,9 @@ static struct file *do_open(char *name, int flags)
41 error = may_open(&nd, MAY_WRITE, FMODE_WRITE); 41 error = may_open(&nd, MAY_WRITE, FMODE_WRITE);
42 42
43 if (!error) 43 if (!error)
44 return dentry_open(nd.dentry, nd.mnt, flags); 44 return dentry_open(nd.path.dentry, nd.path.mnt, flags);
45 45
46 path_release(&nd); 46 path_put(&nd.path);
47 return ERR_PTR(error); 47 return ERR_PTR(error);
48} 48}
49 49
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 346570f6d848..8a6f7c924c75 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -63,10 +63,8 @@ static void expkey_put(struct kref *ref)
63 struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref); 63 struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref);
64 64
65 if (test_bit(CACHE_VALID, &key->h.flags) && 65 if (test_bit(CACHE_VALID, &key->h.flags) &&
66 !test_bit(CACHE_NEGATIVE, &key->h.flags)) { 66 !test_bit(CACHE_NEGATIVE, &key->h.flags))
67 dput(key->ek_dentry); 67 path_put(&key->ek_path);
68 mntput(key->ek_mnt);
69 }
70 auth_domain_put(key->ek_client); 68 auth_domain_put(key->ek_client);
71 kfree(key); 69 kfree(key);
72} 70}
@@ -169,15 +167,14 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
169 goto out; 167 goto out;
170 168
171 dprintk("Found the path %s\n", buf); 169 dprintk("Found the path %s\n", buf);
172 key.ek_mnt = nd.mnt; 170 key.ek_path = nd.path;
173 key.ek_dentry = nd.dentry; 171
174
175 ek = svc_expkey_update(&key, ek); 172 ek = svc_expkey_update(&key, ek);
176 if (ek) 173 if (ek)
177 cache_put(&ek->h, &svc_expkey_cache); 174 cache_put(&ek->h, &svc_expkey_cache);
178 else 175 else
179 err = -ENOMEM; 176 err = -ENOMEM;
180 path_release(&nd); 177 path_put(&nd.path);
181 } 178 }
182 cache_flush(); 179 cache_flush();
183 out: 180 out:
@@ -206,7 +203,7 @@ static int expkey_show(struct seq_file *m,
206 if (test_bit(CACHE_VALID, &h->flags) && 203 if (test_bit(CACHE_VALID, &h->flags) &&
207 !test_bit(CACHE_NEGATIVE, &h->flags)) { 204 !test_bit(CACHE_NEGATIVE, &h->flags)) {
208 seq_printf(m, " "); 205 seq_printf(m, " ");
209 seq_path(m, ek->ek_mnt, ek->ek_dentry, "\\ \t\n"); 206 seq_path(m, &ek->ek_path, "\\ \t\n");
210 } 207 }
211 seq_printf(m, "\n"); 208 seq_printf(m, "\n");
212 return 0; 209 return 0;
@@ -243,8 +240,8 @@ static inline void expkey_update(struct cache_head *cnew,
243 struct svc_expkey *new = container_of(cnew, struct svc_expkey, h); 240 struct svc_expkey *new = container_of(cnew, struct svc_expkey, h);
244 struct svc_expkey *item = container_of(citem, struct svc_expkey, h); 241 struct svc_expkey *item = container_of(citem, struct svc_expkey, h);
245 242
246 new->ek_mnt = mntget(item->ek_mnt); 243 new->ek_path = item->ek_path;
247 new->ek_dentry = dget(item->ek_dentry); 244 path_get(&item->ek_path);
248} 245}
249 246
250static struct cache_head *expkey_alloc(void) 247static struct cache_head *expkey_alloc(void)
@@ -332,10 +329,9 @@ static void nfsd4_fslocs_free(struct nfsd4_fs_locations *fsloc)
332static void svc_export_put(struct kref *ref) 329static void svc_export_put(struct kref *ref)
333{ 330{
334 struct svc_export *exp = container_of(ref, struct svc_export, h.ref); 331 struct svc_export *exp = container_of(ref, struct svc_export, h.ref);
335 dput(exp->ex_dentry); 332 path_put(&exp->ex_path);
336 mntput(exp->ex_mnt);
337 auth_domain_put(exp->ex_client); 333 auth_domain_put(exp->ex_client);
338 kfree(exp->ex_path); 334 kfree(exp->ex_pathname);
339 nfsd4_fslocs_free(&exp->ex_fslocs); 335 nfsd4_fslocs_free(&exp->ex_fslocs);
340 kfree(exp); 336 kfree(exp);
341} 337}
@@ -349,7 +345,7 @@ static void svc_export_request(struct cache_detail *cd,
349 char *pth; 345 char *pth;
350 346
351 qword_add(bpp, blen, exp->ex_client->name); 347 qword_add(bpp, blen, exp->ex_client->name);
352 pth = d_path(exp->ex_dentry, exp->ex_mnt, *bpp, *blen); 348 pth = d_path(&exp->ex_path, *bpp, *blen);
353 if (IS_ERR(pth)) { 349 if (IS_ERR(pth)) {
354 /* is this correct? */ 350 /* is this correct? */
355 (*bpp)[0] = '\n'; 351 (*bpp)[0] = '\n';
@@ -507,8 +503,8 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
507 struct svc_export exp, *expp; 503 struct svc_export exp, *expp;
508 int an_int; 504 int an_int;
509 505
510 nd.dentry = NULL; 506 nd.path.dentry = NULL;
511 exp.ex_path = NULL; 507 exp.ex_pathname = NULL;
512 508
513 /* fs locations */ 509 /* fs locations */
514 exp.ex_fslocs.locations = NULL; 510 exp.ex_fslocs.locations = NULL;
@@ -547,11 +543,11 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
547 543
548 exp.h.flags = 0; 544 exp.h.flags = 0;
549 exp.ex_client = dom; 545 exp.ex_client = dom;
550 exp.ex_mnt = nd.mnt; 546 exp.ex_path.mnt = nd.path.mnt;
551 exp.ex_dentry = nd.dentry; 547 exp.ex_path.dentry = nd.path.dentry;
552 exp.ex_path = kstrdup(buf, GFP_KERNEL); 548 exp.ex_pathname = kstrdup(buf, GFP_KERNEL);
553 err = -ENOMEM; 549 err = -ENOMEM;
554 if (!exp.ex_path) 550 if (!exp.ex_pathname)
555 goto out; 551 goto out;
556 552
557 /* expiry */ 553 /* expiry */
@@ -610,7 +606,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
610 goto out; 606 goto out;
611 } 607 }
612 608
613 err = check_export(nd.dentry->d_inode, exp.ex_flags, 609 err = check_export(nd.path.dentry->d_inode, exp.ex_flags,
614 exp.ex_uuid); 610 exp.ex_uuid);
615 if (err) goto out; 611 if (err) goto out;
616 } 612 }
@@ -628,9 +624,9 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
628 out: 624 out:
629 nfsd4_fslocs_free(&exp.ex_fslocs); 625 nfsd4_fslocs_free(&exp.ex_fslocs);
630 kfree(exp.ex_uuid); 626 kfree(exp.ex_uuid);
631 kfree(exp.ex_path); 627 kfree(exp.ex_pathname);
632 if (nd.dentry) 628 if (nd.path.dentry)
633 path_release(&nd); 629 path_put(&nd.path);
634 out_no_path: 630 out_no_path:
635 if (dom) 631 if (dom)
636 auth_domain_put(dom); 632 auth_domain_put(dom);
@@ -653,7 +649,7 @@ static int svc_export_show(struct seq_file *m,
653 return 0; 649 return 0;
654 } 650 }
655 exp = container_of(h, struct svc_export, h); 651 exp = container_of(h, struct svc_export, h);
656 seq_path(m, exp->ex_mnt, exp->ex_dentry, " \t\n\\"); 652 seq_path(m, &exp->ex_path, " \t\n\\");
657 seq_putc(m, '\t'); 653 seq_putc(m, '\t');
658 seq_escape(m, exp->ex_client->name, " \t\n\\"); 654 seq_escape(m, exp->ex_client->name, " \t\n\\");
659 seq_putc(m, '('); 655 seq_putc(m, '(');
@@ -680,8 +676,8 @@ static int svc_export_match(struct cache_head *a, struct cache_head *b)
680 struct svc_export *orig = container_of(a, struct svc_export, h); 676 struct svc_export *orig = container_of(a, struct svc_export, h);
681 struct svc_export *new = container_of(b, struct svc_export, h); 677 struct svc_export *new = container_of(b, struct svc_export, h);
682 return orig->ex_client == new->ex_client && 678 return orig->ex_client == new->ex_client &&
683 orig->ex_dentry == new->ex_dentry && 679 orig->ex_path.dentry == new->ex_path.dentry &&
684 orig->ex_mnt == new->ex_mnt; 680 orig->ex_path.mnt == new->ex_path.mnt;
685} 681}
686 682
687static void svc_export_init(struct cache_head *cnew, struct cache_head *citem) 683static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
@@ -691,9 +687,9 @@ static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
691 687
692 kref_get(&item->ex_client->ref); 688 kref_get(&item->ex_client->ref);
693 new->ex_client = item->ex_client; 689 new->ex_client = item->ex_client;
694 new->ex_dentry = dget(item->ex_dentry); 690 new->ex_path.dentry = dget(item->ex_path.dentry);
695 new->ex_mnt = mntget(item->ex_mnt); 691 new->ex_path.mnt = mntget(item->ex_path.mnt);
696 new->ex_path = NULL; 692 new->ex_pathname = NULL;
697 new->ex_fslocs.locations = NULL; 693 new->ex_fslocs.locations = NULL;
698 new->ex_fslocs.locations_count = 0; 694 new->ex_fslocs.locations_count = 0;
699 new->ex_fslocs.migrated = 0; 695 new->ex_fslocs.migrated = 0;
@@ -711,8 +707,8 @@ static void export_update(struct cache_head *cnew, struct cache_head *citem)
711 new->ex_fsid = item->ex_fsid; 707 new->ex_fsid = item->ex_fsid;
712 new->ex_uuid = item->ex_uuid; 708 new->ex_uuid = item->ex_uuid;
713 item->ex_uuid = NULL; 709 item->ex_uuid = NULL;
714 new->ex_path = item->ex_path; 710 new->ex_pathname = item->ex_pathname;
715 item->ex_path = NULL; 711 item->ex_pathname = NULL;
716 new->ex_fslocs.locations = item->ex_fslocs.locations; 712 new->ex_fslocs.locations = item->ex_fslocs.locations;
717 item->ex_fslocs.locations = NULL; 713 item->ex_fslocs.locations = NULL;
718 new->ex_fslocs.locations_count = item->ex_fslocs.locations_count; 714 new->ex_fslocs.locations_count = item->ex_fslocs.locations_count;
@@ -755,8 +751,8 @@ svc_export_lookup(struct svc_export *exp)
755 struct cache_head *ch; 751 struct cache_head *ch;
756 int hash; 752 int hash;
757 hash = hash_ptr(exp->ex_client, EXPORT_HASHBITS); 753 hash = hash_ptr(exp->ex_client, EXPORT_HASHBITS);
758 hash ^= hash_ptr(exp->ex_dentry, EXPORT_HASHBITS); 754 hash ^= hash_ptr(exp->ex_path.dentry, EXPORT_HASHBITS);
759 hash ^= hash_ptr(exp->ex_mnt, EXPORT_HASHBITS); 755 hash ^= hash_ptr(exp->ex_path.mnt, EXPORT_HASHBITS);
760 756
761 ch = sunrpc_cache_lookup(&svc_export_cache, &exp->h, 757 ch = sunrpc_cache_lookup(&svc_export_cache, &exp->h,
762 hash); 758 hash);
@@ -772,8 +768,8 @@ svc_export_update(struct svc_export *new, struct svc_export *old)
772 struct cache_head *ch; 768 struct cache_head *ch;
773 int hash; 769 int hash;
774 hash = hash_ptr(old->ex_client, EXPORT_HASHBITS); 770 hash = hash_ptr(old->ex_client, EXPORT_HASHBITS);
775 hash ^= hash_ptr(old->ex_dentry, EXPORT_HASHBITS); 771 hash ^= hash_ptr(old->ex_path.dentry, EXPORT_HASHBITS);
776 hash ^= hash_ptr(old->ex_mnt, EXPORT_HASHBITS); 772 hash ^= hash_ptr(old->ex_path.mnt, EXPORT_HASHBITS);
777 773
778 ch = sunrpc_cache_update(&svc_export_cache, &new->h, 774 ch = sunrpc_cache_update(&svc_export_cache, &new->h,
779 &old->h, 775 &old->h,
@@ -815,8 +811,7 @@ static int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv,
815 key.ek_client = clp; 811 key.ek_client = clp;
816 key.ek_fsidtype = fsid_type; 812 key.ek_fsidtype = fsid_type;
817 memcpy(key.ek_fsid, fsidv, key_len(fsid_type)); 813 memcpy(key.ek_fsid, fsidv, key_len(fsid_type));
818 key.ek_mnt = exp->ex_mnt; 814 key.ek_path = exp->ex_path;
819 key.ek_dentry = exp->ex_dentry;
820 key.h.expiry_time = NEVER; 815 key.h.expiry_time = NEVER;
821 key.h.flags = 0; 816 key.h.flags = 0;
822 817
@@ -865,13 +860,13 @@ static svc_export *exp_get_by_name(svc_client *clp, struct vfsmount *mnt,
865{ 860{
866 struct svc_export *exp, key; 861 struct svc_export *exp, key;
867 int err; 862 int err;
868 863
869 if (!clp) 864 if (!clp)
870 return ERR_PTR(-ENOENT); 865 return ERR_PTR(-ENOENT);
871 866
872 key.ex_client = clp; 867 key.ex_client = clp;
873 key.ex_mnt = mnt; 868 key.ex_path.mnt = mnt;
874 key.ex_dentry = dentry; 869 key.ex_path.dentry = dentry;
875 870
876 exp = svc_export_lookup(&key); 871 exp = svc_export_lookup(&key);
877 if (exp == NULL) 872 if (exp == NULL)
@@ -968,7 +963,7 @@ static int exp_fsid_hash(svc_client *clp, struct svc_export *exp)
968static int exp_hash(struct auth_domain *clp, struct svc_export *exp) 963static int exp_hash(struct auth_domain *clp, struct svc_export *exp)
969{ 964{
970 u32 fsid[2]; 965 u32 fsid[2];
971 struct inode *inode = exp->ex_dentry->d_inode; 966 struct inode *inode = exp->ex_path.dentry->d_inode;
972 dev_t dev = inode->i_sb->s_dev; 967 dev_t dev = inode->i_sb->s_dev;
973 968
974 if (old_valid_dev(dev)) { 969 if (old_valid_dev(dev)) {
@@ -982,7 +977,7 @@ static int exp_hash(struct auth_domain *clp, struct svc_export *exp)
982static void exp_unhash(struct svc_export *exp) 977static void exp_unhash(struct svc_export *exp)
983{ 978{
984 struct svc_expkey *ek; 979 struct svc_expkey *ek;
985 struct inode *inode = exp->ex_dentry->d_inode; 980 struct inode *inode = exp->ex_path.dentry->d_inode;
986 981
987 ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino); 982 ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino);
988 if (!IS_ERR(ek)) { 983 if (!IS_ERR(ek)) {
@@ -1030,15 +1025,16 @@ exp_export(struct nfsctl_export *nxp)
1030 goto out_unlock; 1025 goto out_unlock;
1031 err = -EINVAL; 1026 err = -EINVAL;
1032 1027
1033 exp = exp_get_by_name(clp, nd.mnt, nd.dentry, NULL); 1028 exp = exp_get_by_name(clp, nd.path.mnt, nd.path.dentry, NULL);
1034 1029
1035 memset(&new, 0, sizeof(new)); 1030 memset(&new, 0, sizeof(new));
1036 1031
1037 /* must make sure there won't be an ex_fsid clash */ 1032 /* must make sure there won't be an ex_fsid clash */
1038 if ((nxp->ex_flags & NFSEXP_FSID) && 1033 if ((nxp->ex_flags & NFSEXP_FSID) &&
1039 (!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) && 1034 (!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) &&
1040 fsid_key->ek_mnt && 1035 fsid_key->ek_path.mnt &&
1041 (fsid_key->ek_mnt != nd.mnt || fsid_key->ek_dentry != nd.dentry) ) 1036 (fsid_key->ek_path.mnt != nd.path.mnt ||
1037 fsid_key->ek_path.dentry != nd.path.dentry))
1042 goto finish; 1038 goto finish;
1043 1039
1044 if (!IS_ERR(exp)) { 1040 if (!IS_ERR(exp)) {
@@ -1054,7 +1050,7 @@ exp_export(struct nfsctl_export *nxp)
1054 goto finish; 1050 goto finish;
1055 } 1051 }
1056 1052
1057 err = check_export(nd.dentry->d_inode, nxp->ex_flags, NULL); 1053 err = check_export(nd.path.dentry->d_inode, nxp->ex_flags, NULL);
1058 if (err) goto finish; 1054 if (err) goto finish;
1059 1055
1060 err = -ENOMEM; 1056 err = -ENOMEM;
@@ -1063,12 +1059,11 @@ exp_export(struct nfsctl_export *nxp)
1063 1059
1064 new.h.expiry_time = NEVER; 1060 new.h.expiry_time = NEVER;
1065 new.h.flags = 0; 1061 new.h.flags = 0;
1066 new.ex_path = kstrdup(nxp->ex_path, GFP_KERNEL); 1062 new.ex_pathname = kstrdup(nxp->ex_path, GFP_KERNEL);
1067 if (!new.ex_path) 1063 if (!new.ex_pathname)
1068 goto finish; 1064 goto finish;
1069 new.ex_client = clp; 1065 new.ex_client = clp;
1070 new.ex_mnt = nd.mnt; 1066 new.ex_path = nd.path;
1071 new.ex_dentry = nd.dentry;
1072 new.ex_flags = nxp->ex_flags; 1067 new.ex_flags = nxp->ex_flags;
1073 new.ex_anon_uid = nxp->ex_anon_uid; 1068 new.ex_anon_uid = nxp->ex_anon_uid;
1074 new.ex_anon_gid = nxp->ex_anon_gid; 1069 new.ex_anon_gid = nxp->ex_anon_gid;
@@ -1089,15 +1084,14 @@ exp_export(struct nfsctl_export *nxp)
1089 } else 1084 } else
1090 err = 0; 1085 err = 0;
1091finish: 1086finish:
1092 if (new.ex_path) 1087 kfree(new.ex_pathname);
1093 kfree(new.ex_path);
1094 if (exp) 1088 if (exp)
1095 exp_put(exp); 1089 exp_put(exp);
1096 if (fsid_key && !IS_ERR(fsid_key)) 1090 if (fsid_key && !IS_ERR(fsid_key))
1097 cache_put(&fsid_key->h, &svc_expkey_cache); 1091 cache_put(&fsid_key->h, &svc_expkey_cache);
1098 if (clp) 1092 if (clp)
1099 auth_domain_put(clp); 1093 auth_domain_put(clp);
1100 path_release(&nd); 1094 path_put(&nd.path);
1101out_unlock: 1095out_unlock:
1102 exp_writeunlock(); 1096 exp_writeunlock();
1103out: 1097out:
@@ -1148,8 +1142,8 @@ exp_unexport(struct nfsctl_export *nxp)
1148 goto out_domain; 1142 goto out_domain;
1149 1143
1150 err = -EINVAL; 1144 err = -EINVAL;
1151 exp = exp_get_by_name(dom, nd.mnt, nd.dentry, NULL); 1145 exp = exp_get_by_name(dom, nd.path.mnt, nd.path.dentry, NULL);
1152 path_release(&nd); 1146 path_put(&nd.path);
1153 if (IS_ERR(exp)) 1147 if (IS_ERR(exp))
1154 goto out_domain; 1148 goto out_domain;
1155 1149
@@ -1185,12 +1179,12 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
1185 printk("nfsd: exp_rootfh path not found %s", path); 1179 printk("nfsd: exp_rootfh path not found %s", path);
1186 return err; 1180 return err;
1187 } 1181 }
1188 inode = nd.dentry->d_inode; 1182 inode = nd.path.dentry->d_inode;
1189 1183
1190 dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n", 1184 dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n",
1191 path, nd.dentry, clp->name, 1185 path, nd.path.dentry, clp->name,
1192 inode->i_sb->s_id, inode->i_ino); 1186 inode->i_sb->s_id, inode->i_ino);
1193 exp = exp_parent(clp, nd.mnt, nd.dentry, NULL); 1187 exp = exp_parent(clp, nd.path.mnt, nd.path.dentry, NULL);
1194 if (IS_ERR(exp)) { 1188 if (IS_ERR(exp)) {
1195 err = PTR_ERR(exp); 1189 err = PTR_ERR(exp);
1196 goto out; 1190 goto out;
@@ -1200,7 +1194,7 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
1200 * fh must be initialized before calling fh_compose 1194 * fh must be initialized before calling fh_compose
1201 */ 1195 */
1202 fh_init(&fh, maxsize); 1196 fh_init(&fh, maxsize);
1203 if (fh_compose(&fh, exp, nd.dentry, NULL)) 1197 if (fh_compose(&fh, exp, nd.path.dentry, NULL))
1204 err = -EINVAL; 1198 err = -EINVAL;
1205 else 1199 else
1206 err = 0; 1200 err = 0;
@@ -1208,7 +1202,7 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
1208 fh_put(&fh); 1202 fh_put(&fh);
1209 exp_put(exp); 1203 exp_put(exp);
1210out: 1204out:
1211 path_release(&nd); 1205 path_put(&nd.path);
1212 return err; 1206 return err;
1213} 1207}
1214 1208
@@ -1220,7 +1214,7 @@ static struct svc_export *exp_find(struct auth_domain *clp, int fsid_type,
1220 if (IS_ERR(ek)) 1214 if (IS_ERR(ek))
1221 return ERR_CAST(ek); 1215 return ERR_CAST(ek);
1222 1216
1223 exp = exp_get_by_name(clp, ek->ek_mnt, ek->ek_dentry, reqp); 1217 exp = exp_get_by_name(clp, ek->ek_path.mnt, ek->ek_path.dentry, reqp);
1224 cache_put(&ek->h, &svc_expkey_cache); 1218 cache_put(&ek->h, &svc_expkey_cache);
1225 1219
1226 if (IS_ERR(exp)) 1220 if (IS_ERR(exp))
@@ -1359,7 +1353,7 @@ exp_pseudoroot(struct svc_rqst *rqstp, struct svc_fh *fhp)
1359 exp = rqst_exp_find(rqstp, FSID_NUM, fsidv); 1353 exp = rqst_exp_find(rqstp, FSID_NUM, fsidv);
1360 if (IS_ERR(exp)) 1354 if (IS_ERR(exp))
1361 return nfserrno(PTR_ERR(exp)); 1355 return nfserrno(PTR_ERR(exp));
1362 rv = fh_compose(fhp, exp, exp->ex_dentry, NULL); 1356 rv = fh_compose(fhp, exp, exp->ex_path.dentry, NULL);
1363 if (rv) 1357 if (rv)
1364 goto out; 1358 goto out;
1365 rv = check_nfsd_access(exp, rqstp); 1359 rv = check_nfsd_access(exp, rqstp);
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
index eac82830bfd7..c721a1e6e9dd 100644
--- a/fs/nfsd/nfs3proc.c
+++ b/fs/nfsd/nfs3proc.c
@@ -67,7 +67,7 @@ nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp,
67 if (nfserr) 67 if (nfserr)
68 RETURN_STATUS(nfserr); 68 RETURN_STATUS(nfserr);
69 69
70 err = vfs_getattr(resp->fh.fh_export->ex_mnt, 70 err = vfs_getattr(resp->fh.fh_export->ex_path.mnt,
71 resp->fh.fh_dentry, &resp->stat); 71 resp->fh.fh_dentry, &resp->stat);
72 nfserr = nfserrno(err); 72 nfserr = nfserrno(err);
73 73
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index d7647f70e02b..17d0dd997204 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -218,7 +218,7 @@ encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
218 int err; 218 int err;
219 struct kstat stat; 219 struct kstat stat;
220 220
221 err = vfs_getattr(fhp->fh_export->ex_mnt, dentry, &stat); 221 err = vfs_getattr(fhp->fh_export->ex_path.mnt, dentry, &stat);
222 if (!err) { 222 if (!err) {
223 *p++ = xdr_one; /* attributes follow */ 223 *p++ = xdr_one; /* attributes follow */
224 lease_get_mtime(dentry->d_inode, &stat.mtime); 224 lease_get_mtime(dentry->d_inode, &stat.mtime);
@@ -270,7 +270,7 @@ void fill_post_wcc(struct svc_fh *fhp)
270 if (fhp->fh_post_saved) 270 if (fhp->fh_post_saved)
271 printk("nfsd: inode locked twice during operation.\n"); 271 printk("nfsd: inode locked twice during operation.\n");
272 272
273 err = vfs_getattr(fhp->fh_export->ex_mnt, fhp->fh_dentry, 273 err = vfs_getattr(fhp->fh_export->ex_path.mnt, fhp->fh_dentry,
274 &fhp->fh_post_attr); 274 &fhp->fh_post_attr);
275 if (err) 275 if (err)
276 fhp->fh_post_saved = 0; 276 fhp->fh_post_saved = 0;
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 1602cd00dd45..1ff90625860f 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -120,9 +120,9 @@ out_no_tfm:
120static void 120static void
121nfsd4_sync_rec_dir(void) 121nfsd4_sync_rec_dir(void)
122{ 122{
123 mutex_lock(&rec_dir.dentry->d_inode->i_mutex); 123 mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex);
124 nfsd_sync_dir(rec_dir.dentry); 124 nfsd_sync_dir(rec_dir.path.dentry);
125 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); 125 mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex);
126} 126}
127 127
128int 128int
@@ -142,9 +142,9 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
142 nfs4_save_user(&uid, &gid); 142 nfs4_save_user(&uid, &gid);
143 143
144 /* lock the parent */ 144 /* lock the parent */
145 mutex_lock(&rec_dir.dentry->d_inode->i_mutex); 145 mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex);
146 146
147 dentry = lookup_one_len(dname, rec_dir.dentry, HEXDIR_LEN-1); 147 dentry = lookup_one_len(dname, rec_dir.path.dentry, HEXDIR_LEN-1);
148 if (IS_ERR(dentry)) { 148 if (IS_ERR(dentry)) {
149 status = PTR_ERR(dentry); 149 status = PTR_ERR(dentry);
150 goto out_unlock; 150 goto out_unlock;
@@ -154,11 +154,11 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
154 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n"); 154 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n");
155 goto out_put; 155 goto out_put;
156 } 156 }
157 status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU); 157 status = vfs_mkdir(rec_dir.path.dentry->d_inode, dentry, S_IRWXU);
158out_put: 158out_put:
159 dput(dentry); 159 dput(dentry);
160out_unlock: 160out_unlock:
161 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); 161 mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex);
162 if (status == 0) { 162 if (status == 0) {
163 clp->cl_firststate = 1; 163 clp->cl_firststate = 1;
164 nfsd4_sync_rec_dir(); 164 nfsd4_sync_rec_dir();
@@ -221,7 +221,7 @@ nfsd4_list_rec_dir(struct dentry *dir, recdir_func *f)
221 221
222 nfs4_save_user(&uid, &gid); 222 nfs4_save_user(&uid, &gid);
223 223
224 filp = dentry_open(dget(dir), mntget(rec_dir.mnt), O_RDONLY); 224 filp = dentry_open(dget(dir), mntget(rec_dir.path.mnt), O_RDONLY);
225 status = PTR_ERR(filp); 225 status = PTR_ERR(filp);
226 if (IS_ERR(filp)) 226 if (IS_ERR(filp))
227 goto out; 227 goto out;
@@ -286,9 +286,9 @@ nfsd4_unlink_clid_dir(char *name, int namlen)
286 286
287 dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); 287 dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name);
288 288
289 mutex_lock(&rec_dir.dentry->d_inode->i_mutex); 289 mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex);
290 dentry = lookup_one_len(name, rec_dir.dentry, namlen); 290 dentry = lookup_one_len(name, rec_dir.path.dentry, namlen);
291 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); 291 mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex);
292 if (IS_ERR(dentry)) { 292 if (IS_ERR(dentry)) {
293 status = PTR_ERR(dentry); 293 status = PTR_ERR(dentry);
294 return status; 294 return status;
@@ -297,7 +297,7 @@ nfsd4_unlink_clid_dir(char *name, int namlen)
297 if (!dentry->d_inode) 297 if (!dentry->d_inode)
298 goto out; 298 goto out;
299 299
300 status = nfsd4_clear_clid_dir(rec_dir.dentry, dentry); 300 status = nfsd4_clear_clid_dir(rec_dir.path.dentry, dentry);
301out: 301out:
302 dput(dentry); 302 dput(dentry);
303 return status; 303 return status;
@@ -347,12 +347,12 @@ nfsd4_recdir_purge_old(void) {
347 347
348 if (!rec_dir_init) 348 if (!rec_dir_init)
349 return; 349 return;
350 status = nfsd4_list_rec_dir(rec_dir.dentry, purge_old); 350 status = nfsd4_list_rec_dir(rec_dir.path.dentry, purge_old);
351 if (status == 0) 351 if (status == 0)
352 nfsd4_sync_rec_dir(); 352 nfsd4_sync_rec_dir();
353 if (status) 353 if (status)
354 printk("nfsd4: failed to purge old clients from recovery" 354 printk("nfsd4: failed to purge old clients from recovery"
355 " directory %s\n", rec_dir.dentry->d_name.name); 355 " directory %s\n", rec_dir.path.dentry->d_name.name);
356 return; 356 return;
357} 357}
358 358
@@ -373,10 +373,10 @@ int
373nfsd4_recdir_load(void) { 373nfsd4_recdir_load(void) {
374 int status; 374 int status;
375 375
376 status = nfsd4_list_rec_dir(rec_dir.dentry, load_recdir); 376 status = nfsd4_list_rec_dir(rec_dir.path.dentry, load_recdir);
377 if (status) 377 if (status)
378 printk("nfsd4: failed loading clients from recovery" 378 printk("nfsd4: failed loading clients from recovery"
379 " directory %s\n", rec_dir.dentry->d_name.name); 379 " directory %s\n", rec_dir.path.dentry->d_name.name);
380 return status; 380 return status;
381} 381}
382 382
@@ -415,5 +415,5 @@ nfsd4_shutdown_recdir(void)
415 if (!rec_dir_init) 415 if (!rec_dir_init)
416 return; 416 return;
417 rec_dir_init = 0; 417 rec_dir_init = 0;
418 path_release(&rec_dir); 418 path_put(&rec_dir.path);
419} 419}
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index f6744bc03dae..bcb97d8e8b8b 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3261,11 +3261,11 @@ nfs4_reset_recoverydir(char *recdir)
3261 if (status) 3261 if (status)
3262 return status; 3262 return status;
3263 status = -ENOTDIR; 3263 status = -ENOTDIR;
3264 if (S_ISDIR(nd.dentry->d_inode->i_mode)) { 3264 if (S_ISDIR(nd.path.dentry->d_inode->i_mode)) {
3265 nfs4_set_recdir(recdir); 3265 nfs4_set_recdir(recdir);
3266 status = 0; 3266 status = 0;
3267 } 3267 }
3268 path_release(&nd); 3268 path_put(&nd.path);
3269 return status; 3269 return status;
3270} 3270}
3271 3271
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index b0592e7c378d..0e6a179eccaf 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1330,9 +1330,9 @@ static char *nfsd4_path(struct svc_rqst *rqstp, struct svc_export *exp, __be32 *
1330 *stat = exp_pseudoroot(rqstp, &tmp_fh); 1330 *stat = exp_pseudoroot(rqstp, &tmp_fh);
1331 if (*stat) 1331 if (*stat)
1332 return NULL; 1332 return NULL;
1333 rootpath = tmp_fh.fh_export->ex_path; 1333 rootpath = tmp_fh.fh_export->ex_pathname;
1334 1334
1335 path = exp->ex_path; 1335 path = exp->ex_pathname;
1336 1336
1337 if (strncmp(path, rootpath, strlen(rootpath))) { 1337 if (strncmp(path, rootpath, strlen(rootpath))) {
1338 dprintk("nfsd: fs_locations failed;" 1338 dprintk("nfsd: fs_locations failed;"
@@ -1481,7 +1481,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
1481 goto out; 1481 goto out;
1482 } 1482 }
1483 1483
1484 err = vfs_getattr(exp->ex_mnt, dentry, &stat); 1484 err = vfs_getattr(exp->ex_path.mnt, dentry, &stat);
1485 if (err) 1485 if (err)
1486 goto out_nfserr; 1486 goto out_nfserr;
1487 if ((bmval0 & (FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL | 1487 if ((bmval0 & (FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL |
@@ -1838,9 +1838,9 @@ out_acl:
1838 * and this is the root of a cross-mounted filesystem. 1838 * and this is the root of a cross-mounted filesystem.
1839 */ 1839 */
1840 if (ignore_crossmnt == 0 && 1840 if (ignore_crossmnt == 0 &&
1841 exp->ex_mnt->mnt_root->d_inode == dentry->d_inode) { 1841 exp->ex_path.mnt->mnt_root->d_inode == dentry->d_inode) {
1842 err = vfs_getattr(exp->ex_mnt->mnt_parent, 1842 err = vfs_getattr(exp->ex_path.mnt->mnt_parent,
1843 exp->ex_mnt->mnt_mountpoint, &stat); 1843 exp->ex_path.mnt->mnt_mountpoint, &stat);
1844 if (err) 1844 if (err)
1845 goto out_nfserr; 1845 goto out_nfserr;
1846 } 1846 }
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 8fbd2dc08a92..0130b345234d 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -47,7 +47,7 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry)
47 return 1; 47 return 1;
48 48
49 tdentry = dget(dentry); 49 tdentry = dget(dentry);
50 while (tdentry != exp->ex_dentry && ! IS_ROOT(tdentry)) { 50 while (tdentry != exp->ex_path.dentry && !IS_ROOT(tdentry)) {
51 /* make sure parents give x permission to user */ 51 /* make sure parents give x permission to user */
52 int err; 52 int err;
53 parent = dget_parent(tdentry); 53 parent = dget_parent(tdentry);
@@ -59,9 +59,9 @@ static int nfsd_acceptable(void *expv, struct dentry *dentry)
59 dput(tdentry); 59 dput(tdentry);
60 tdentry = parent; 60 tdentry = parent;
61 } 61 }
62 if (tdentry != exp->ex_dentry) 62 if (tdentry != exp->ex_path.dentry)
63 dprintk("nfsd_acceptable failed at %p %s\n", tdentry, tdentry->d_name.name); 63 dprintk("nfsd_acceptable failed at %p %s\n", tdentry, tdentry->d_name.name);
64 rv = (tdentry == exp->ex_dentry); 64 rv = (tdentry == exp->ex_path.dentry);
65 dput(tdentry); 65 dput(tdentry);
66 return rv; 66 return rv;
67} 67}
@@ -209,9 +209,9 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, int access)
209 fileid_type = fh->fh_fileid_type; 209 fileid_type = fh->fh_fileid_type;
210 210
211 if (fileid_type == FILEID_ROOT) 211 if (fileid_type == FILEID_ROOT)
212 dentry = dget(exp->ex_dentry); 212 dentry = dget(exp->ex_path.dentry);
213 else { 213 else {
214 dentry = exportfs_decode_fh(exp->ex_mnt, fid, 214 dentry = exportfs_decode_fh(exp->ex_path.mnt, fid,
215 data_left, fileid_type, 215 data_left, fileid_type,
216 nfsd_acceptable, exp); 216 nfsd_acceptable, exp);
217 } 217 }
@@ -299,7 +299,7 @@ out:
299static void _fh_update(struct svc_fh *fhp, struct svc_export *exp, 299static void _fh_update(struct svc_fh *fhp, struct svc_export *exp,
300 struct dentry *dentry) 300 struct dentry *dentry)
301{ 301{
302 if (dentry != exp->ex_dentry) { 302 if (dentry != exp->ex_path.dentry) {
303 struct fid *fid = (struct fid *) 303 struct fid *fid = (struct fid *)
304 (fhp->fh_handle.fh_auth + fhp->fh_handle.fh_size/4 - 1); 304 (fhp->fh_handle.fh_auth + fhp->fh_handle.fh_size/4 - 1);
305 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4; 305 int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4;
@@ -344,12 +344,12 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
344 struct inode * inode = dentry->d_inode; 344 struct inode * inode = dentry->d_inode;
345 struct dentry *parent = dentry->d_parent; 345 struct dentry *parent = dentry->d_parent;
346 __u32 *datap; 346 __u32 *datap;
347 dev_t ex_dev = exp->ex_dentry->d_inode->i_sb->s_dev; 347 dev_t ex_dev = exp->ex_path.dentry->d_inode->i_sb->s_dev;
348 int root_export = (exp->ex_dentry == exp->ex_dentry->d_sb->s_root); 348 int root_export = (exp->ex_path.dentry == exp->ex_path.dentry->d_sb->s_root);
349 349
350 dprintk("nfsd: fh_compose(exp %02x:%02x/%ld %s/%s, ino=%ld)\n", 350 dprintk("nfsd: fh_compose(exp %02x:%02x/%ld %s/%s, ino=%ld)\n",
351 MAJOR(ex_dev), MINOR(ex_dev), 351 MAJOR(ex_dev), MINOR(ex_dev),
352 (long) exp->ex_dentry->d_inode->i_ino, 352 (long) exp->ex_path.dentry->d_inode->i_ino,
353 parent->d_name.name, dentry->d_name.name, 353 parent->d_name.name, dentry->d_name.name,
354 (inode ? inode->i_ino : 0)); 354 (inode ? inode->i_ino : 0));
355 355
@@ -391,7 +391,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
391 /* FALL THROUGH */ 391 /* FALL THROUGH */
392 case FSID_MAJOR_MINOR: 392 case FSID_MAJOR_MINOR:
393 case FSID_ENCODE_DEV: 393 case FSID_ENCODE_DEV:
394 if (!(exp->ex_dentry->d_inode->i_sb->s_type->fs_flags 394 if (!(exp->ex_path.dentry->d_inode->i_sb->s_type->fs_flags
395 & FS_REQUIRES_DEV)) 395 & FS_REQUIRES_DEV))
396 goto retry; 396 goto retry;
397 break; 397 break;
@@ -454,7 +454,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
454 fhp->fh_handle.ofh_dev = old_encode_dev(ex_dev); 454 fhp->fh_handle.ofh_dev = old_encode_dev(ex_dev);
455 fhp->fh_handle.ofh_xdev = fhp->fh_handle.ofh_dev; 455 fhp->fh_handle.ofh_xdev = fhp->fh_handle.ofh_dev;
456 fhp->fh_handle.ofh_xino = 456 fhp->fh_handle.ofh_xino =
457 ino_t_to_u32(exp->ex_dentry->d_inode->i_ino); 457 ino_t_to_u32(exp->ex_path.dentry->d_inode->i_ino);
458 fhp->fh_handle.ofh_dirino = ino_t_to_u32(parent_ino(dentry)); 458 fhp->fh_handle.ofh_dirino = ino_t_to_u32(parent_ino(dentry));
459 if (inode) 459 if (inode)
460 _fh_update_old(dentry, exp, &fhp->fh_handle); 460 _fh_update_old(dentry, exp, &fhp->fh_handle);
@@ -465,7 +465,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,
465 datap = fhp->fh_handle.fh_auth+0; 465 datap = fhp->fh_handle.fh_auth+0;
466 fhp->fh_handle.fh_fsid_type = fsid_type; 466 fhp->fh_handle.fh_fsid_type = fsid_type;
467 mk_fsid(fsid_type, datap, ex_dev, 467 mk_fsid(fsid_type, datap, ex_dev,
468 exp->ex_dentry->d_inode->i_ino, 468 exp->ex_path.dentry->d_inode->i_ino,
469 exp->ex_fsid, exp->ex_uuid); 469 exp->ex_fsid, exp->ex_uuid);
470 470
471 len = key_len(fsid_type); 471 len = key_len(fsid_type);
@@ -571,7 +571,7 @@ enum fsid_source fsid_source(struct svc_fh *fhp)
571 case FSID_DEV: 571 case FSID_DEV:
572 case FSID_ENCODE_DEV: 572 case FSID_ENCODE_DEV:
573 case FSID_MAJOR_MINOR: 573 case FSID_MAJOR_MINOR:
574 if (fhp->fh_export->ex_dentry->d_inode->i_sb->s_type->fs_flags 574 if (fhp->fh_export->ex_path.dentry->d_inode->i_sb->s_type->fs_flags
575 & FS_REQUIRES_DEV) 575 & FS_REQUIRES_DEV)
576 return FSIDSOURCE_DEV; 576 return FSIDSOURCE_DEV;
577 break; 577 break;
diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
index 977a71f64e19..6cfc96a12483 100644
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -41,7 +41,7 @@ static __be32
41nfsd_return_attrs(__be32 err, struct nfsd_attrstat *resp) 41nfsd_return_attrs(__be32 err, struct nfsd_attrstat *resp)
42{ 42{
43 if (err) return err; 43 if (err) return err;
44 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt, 44 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt,
45 resp->fh.fh_dentry, 45 resp->fh.fh_dentry,
46 &resp->stat)); 46 &resp->stat));
47} 47}
@@ -49,7 +49,7 @@ static __be32
49nfsd_return_dirop(__be32 err, struct nfsd_diropres *resp) 49nfsd_return_dirop(__be32 err, struct nfsd_diropres *resp)
50{ 50{
51 if (err) return err; 51 if (err) return err;
52 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt, 52 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt,
53 resp->fh.fh_dentry, 53 resp->fh.fh_dentry,
54 &resp->stat)); 54 &resp->stat));
55} 55}
@@ -164,7 +164,7 @@ nfsd_proc_read(struct svc_rqst *rqstp, struct nfsd_readargs *argp,
164 &resp->count); 164 &resp->count);
165 165
166 if (nfserr) return nfserr; 166 if (nfserr) return nfserr;
167 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt, 167 return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt,
168 resp->fh.fh_dentry, 168 resp->fh.fh_dentry,
169 &resp->stat)); 169 &resp->stat));
170} 170}
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index 61ad61743d94..afd08e2c90a5 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -207,7 +207,7 @@ encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
207__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp) 207__be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
208{ 208{
209 struct kstat stat; 209 struct kstat stat;
210 vfs_getattr(fhp->fh_export->ex_mnt, fhp->fh_dentry, &stat); 210 vfs_getattr(fhp->fh_export->ex_path.mnt, fhp->fh_dentry, &stat);
211 return encode_fattr(rqstp, p, fhp, &stat); 211 return encode_fattr(rqstp, p, fhp, &stat);
212} 212}
213 213
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index cc75e4fcd02b..46f59d5365a0 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -101,7 +101,7 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
101{ 101{
102 struct svc_export *exp = *expp, *exp2 = NULL; 102 struct svc_export *exp = *expp, *exp2 = NULL;
103 struct dentry *dentry = *dpp; 103 struct dentry *dentry = *dpp;
104 struct vfsmount *mnt = mntget(exp->ex_mnt); 104 struct vfsmount *mnt = mntget(exp->ex_path.mnt);
105 struct dentry *mounts = dget(dentry); 105 struct dentry *mounts = dget(dentry);
106 int err = 0; 106 int err = 0;
107 107
@@ -156,15 +156,15 @@ nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp,
156 if (isdotent(name, len)) { 156 if (isdotent(name, len)) {
157 if (len==1) 157 if (len==1)
158 dentry = dget(dparent); 158 dentry = dget(dparent);
159 else if (dparent != exp->ex_dentry) { 159 else if (dparent != exp->ex_path.dentry)
160 dentry = dget_parent(dparent); 160 dentry = dget_parent(dparent);
161 } else if (!EX_NOHIDE(exp)) 161 else if (!EX_NOHIDE(exp))
162 dentry = dget(dparent); /* .. == . just like at / */ 162 dentry = dget(dparent); /* .. == . just like at / */
163 else { 163 else {
164 /* checking mountpoint crossing is very different when stepping up */ 164 /* checking mountpoint crossing is very different when stepping up */
165 struct svc_export *exp2 = NULL; 165 struct svc_export *exp2 = NULL;
166 struct dentry *dp; 166 struct dentry *dp;
167 struct vfsmount *mnt = mntget(exp->ex_mnt); 167 struct vfsmount *mnt = mntget(exp->ex_path.mnt);
168 dentry = dget(dparent); 168 dentry = dget(dparent);
169 while(dentry == mnt->mnt_root && follow_up(&mnt, &dentry)) 169 while(dentry == mnt->mnt_root && follow_up(&mnt, &dentry))
170 ; 170 ;
@@ -721,7 +721,8 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
721 721
722 DQUOT_INIT(inode); 722 DQUOT_INIT(inode);
723 } 723 }
724 *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_mnt), flags); 724 *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt),
725 flags);
725 if (IS_ERR(*filp)) 726 if (IS_ERR(*filp))
726 host_err = PTR_ERR(*filp); 727 host_err = PTR_ERR(*filp);
727out_nfserr: 728out_nfserr:
@@ -1462,7 +1463,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
1462 if (!inode->i_op || !inode->i_op->readlink) 1463 if (!inode->i_op || !inode->i_op->readlink)
1463 goto out; 1464 goto out;
1464 1465
1465 touch_atime(fhp->fh_export->ex_mnt, dentry); 1466 touch_atime(fhp->fh_export->ex_path.mnt, dentry);
1466 /* N.B. Why does this call need a get_fs()?? 1467 /* N.B. Why does this call need a get_fs()??
1467 * Remove the set_fs and watch the fireworks:-) --okir 1468 * Remove the set_fs and watch the fireworks:-) --okir
1468 */ 1469 */
diff --git a/fs/open.c b/fs/open.c
index 43fcd6031969..54198538b67e 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -127,10 +127,10 @@ asmlinkage long sys_statfs(const char __user * path, struct statfs __user * buf)
127 error = user_path_walk(path, &nd); 127 error = user_path_walk(path, &nd);
128 if (!error) { 128 if (!error) {
129 struct statfs tmp; 129 struct statfs tmp;
130 error = vfs_statfs_native(nd.dentry, &tmp); 130 error = vfs_statfs_native(nd.path.dentry, &tmp);
131 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 131 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
132 error = -EFAULT; 132 error = -EFAULT;
133 path_release(&nd); 133 path_put(&nd.path);
134 } 134 }
135 return error; 135 return error;
136} 136}
@@ -146,10 +146,10 @@ asmlinkage long sys_statfs64(const char __user *path, size_t sz, struct statfs64
146 error = user_path_walk(path, &nd); 146 error = user_path_walk(path, &nd);
147 if (!error) { 147 if (!error) {
148 struct statfs64 tmp; 148 struct statfs64 tmp;
149 error = vfs_statfs64(nd.dentry, &tmp); 149 error = vfs_statfs64(nd.path.dentry, &tmp);
150 if (!error && copy_to_user(buf, &tmp, sizeof(tmp))) 150 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
151 error = -EFAULT; 151 error = -EFAULT;
152 path_release(&nd); 152 path_put(&nd.path);
153 } 153 }
154 return error; 154 return error;
155} 155}
@@ -233,7 +233,7 @@ static long do_sys_truncate(const char __user * path, loff_t length)
233 error = user_path_walk(path, &nd); 233 error = user_path_walk(path, &nd);
234 if (error) 234 if (error)
235 goto out; 235 goto out;
236 inode = nd.dentry->d_inode; 236 inode = nd.path.dentry->d_inode;
237 237
238 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */ 238 /* For directories it's -EISDIR, for other non-regulars - -EINVAL */
239 error = -EISDIR; 239 error = -EISDIR;
@@ -271,13 +271,13 @@ static long do_sys_truncate(const char __user * path, loff_t length)
271 error = locks_verify_truncate(inode, NULL, length); 271 error = locks_verify_truncate(inode, NULL, length);
272 if (!error) { 272 if (!error) {
273 DQUOT_INIT(inode); 273 DQUOT_INIT(inode);
274 error = do_truncate(nd.dentry, length, 0, NULL); 274 error = do_truncate(nd.path.dentry, length, 0, NULL);
275 } 275 }
276 276
277put_write_and_out: 277put_write_and_out:
278 put_write_access(inode); 278 put_write_access(inode);
279dput_and_out: 279dput_and_out:
280 path_release(&nd); 280 path_put(&nd.path);
281out: 281out:
282 return error; 282 return error;
283} 283}
@@ -455,14 +455,14 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)
455 res = vfs_permission(&nd, mode); 455 res = vfs_permission(&nd, mode);
456 /* SuS v2 requires we report a read only fs too */ 456 /* SuS v2 requires we report a read only fs too */
457 if(res || !(mode & S_IWOTH) || 457 if(res || !(mode & S_IWOTH) ||
458 special_file(nd.dentry->d_inode->i_mode)) 458 special_file(nd.path.dentry->d_inode->i_mode))
459 goto out_path_release; 459 goto out_path_release;
460 460
461 if(IS_RDONLY(nd.dentry->d_inode)) 461 if(IS_RDONLY(nd.path.dentry->d_inode))
462 res = -EROFS; 462 res = -EROFS;
463 463
464out_path_release: 464out_path_release:
465 path_release(&nd); 465 path_put(&nd.path);
466out: 466out:
467 current->fsuid = old_fsuid; 467 current->fsuid = old_fsuid;
468 current->fsgid = old_fsgid; 468 current->fsgid = old_fsgid;
@@ -490,10 +490,10 @@ asmlinkage long sys_chdir(const char __user * filename)
490 if (error) 490 if (error)
491 goto dput_and_out; 491 goto dput_and_out;
492 492
493 set_fs_pwd(current->fs, nd.mnt, nd.dentry); 493 set_fs_pwd(current->fs, &nd.path);
494 494
495dput_and_out: 495dput_and_out:
496 path_release(&nd); 496 path_put(&nd.path);
497out: 497out:
498 return error; 498 return error;
499} 499}
@@ -501,9 +501,7 @@ out:
501asmlinkage long sys_fchdir(unsigned int fd) 501asmlinkage long sys_fchdir(unsigned int fd)
502{ 502{
503 struct file *file; 503 struct file *file;
504 struct dentry *dentry;
505 struct inode *inode; 504 struct inode *inode;
506 struct vfsmount *mnt;
507 int error; 505 int error;
508 506
509 error = -EBADF; 507 error = -EBADF;
@@ -511,9 +509,7 @@ asmlinkage long sys_fchdir(unsigned int fd)
511 if (!file) 509 if (!file)
512 goto out; 510 goto out;
513 511
514 dentry = file->f_path.dentry; 512 inode = file->f_path.dentry->d_inode;
515 mnt = file->f_path.mnt;
516 inode = dentry->d_inode;
517 513
518 error = -ENOTDIR; 514 error = -ENOTDIR;
519 if (!S_ISDIR(inode->i_mode)) 515 if (!S_ISDIR(inode->i_mode))
@@ -521,7 +517,7 @@ asmlinkage long sys_fchdir(unsigned int fd)
521 517
522 error = file_permission(file, MAY_EXEC); 518 error = file_permission(file, MAY_EXEC);
523 if (!error) 519 if (!error)
524 set_fs_pwd(current->fs, mnt, dentry); 520 set_fs_pwd(current->fs, &file->f_path);
525out_putf: 521out_putf:
526 fput(file); 522 fput(file);
527out: 523out:
@@ -545,11 +541,11 @@ asmlinkage long sys_chroot(const char __user * filename)
545 if (!capable(CAP_SYS_CHROOT)) 541 if (!capable(CAP_SYS_CHROOT))
546 goto dput_and_out; 542 goto dput_and_out;
547 543
548 set_fs_root(current->fs, nd.mnt, nd.dentry); 544 set_fs_root(current->fs, &nd.path);
549 set_fs_altroot(); 545 set_fs_altroot();
550 error = 0; 546 error = 0;
551dput_and_out: 547dput_and_out:
552 path_release(&nd); 548 path_put(&nd.path);
553out: 549out:
554 return error; 550 return error;
555} 551}
@@ -602,7 +598,7 @@ asmlinkage long sys_fchmodat(int dfd, const char __user *filename,
602 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd); 598 error = __user_walk_fd(dfd, filename, LOOKUP_FOLLOW, &nd);
603 if (error) 599 if (error)
604 goto out; 600 goto out;
605 inode = nd.dentry->d_inode; 601 inode = nd.path.dentry->d_inode;
606 602
607 error = -EROFS; 603 error = -EROFS;
608 if (IS_RDONLY(inode)) 604 if (IS_RDONLY(inode))
@@ -617,11 +613,11 @@ asmlinkage long sys_fchmodat(int dfd, const char __user *filename,
617 mode = inode->i_mode; 613 mode = inode->i_mode;
618 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); 614 newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
619 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; 615 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
620 error = notify_change(nd.dentry, &newattrs); 616 error = notify_change(nd.path.dentry, &newattrs);
621 mutex_unlock(&inode->i_mutex); 617 mutex_unlock(&inode->i_mutex);
622 618
623dput_and_out: 619dput_and_out:
624 path_release(&nd); 620 path_put(&nd.path);
625out: 621out:
626 return error; 622 return error;
627} 623}
@@ -675,8 +671,8 @@ asmlinkage long sys_chown(const char __user * filename, uid_t user, gid_t group)
675 error = user_path_walk(filename, &nd); 671 error = user_path_walk(filename, &nd);
676 if (error) 672 if (error)
677 goto out; 673 goto out;
678 error = chown_common(nd.dentry, user, group); 674 error = chown_common(nd.path.dentry, user, group);
679 path_release(&nd); 675 path_put(&nd.path);
680out: 676out:
681 return error; 677 return error;
682} 678}
@@ -695,8 +691,8 @@ asmlinkage long sys_fchownat(int dfd, const char __user *filename, uid_t user,
695 error = __user_walk_fd(dfd, filename, follow, &nd); 691 error = __user_walk_fd(dfd, filename, follow, &nd);
696 if (error) 692 if (error)
697 goto out; 693 goto out;
698 error = chown_common(nd.dentry, user, group); 694 error = chown_common(nd.path.dentry, user, group);
699 path_release(&nd); 695 path_put(&nd.path);
700out: 696out:
701 return error; 697 return error;
702} 698}
@@ -709,8 +705,8 @@ asmlinkage long sys_lchown(const char __user * filename, uid_t user, gid_t group
709 error = user_path_walk_link(filename, &nd); 705 error = user_path_walk_link(filename, &nd);
710 if (error) 706 if (error)
711 goto out; 707 goto out;
712 error = chown_common(nd.dentry, user, group); 708 error = chown_common(nd.path.dentry, user, group);
713 path_release(&nd); 709 path_put(&nd.path);
714out: 710out:
715 return error; 711 return error;
716} 712}
@@ -863,7 +859,7 @@ struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry
863 goto out; 859 goto out;
864 if (IS_ERR(dentry)) 860 if (IS_ERR(dentry))
865 goto out_err; 861 goto out_err;
866 nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->mnt), 862 nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->path.mnt),
867 nd->intent.open.flags - 1, 863 nd->intent.open.flags - 1,
868 nd->intent.open.file, 864 nd->intent.open.file,
869 open); 865 open);
@@ -891,9 +887,10 @@ struct file *nameidata_to_filp(struct nameidata *nd, int flags)
891 filp = nd->intent.open.file; 887 filp = nd->intent.open.file;
892 /* Has the filesystem initialised the file for us? */ 888 /* Has the filesystem initialised the file for us? */
893 if (filp->f_path.dentry == NULL) 889 if (filp->f_path.dentry == NULL)
894 filp = __dentry_open(nd->dentry, nd->mnt, flags, filp, NULL); 890 filp = __dentry_open(nd->path.dentry, nd->path.mnt, flags, filp,
891 NULL);
895 else 892 else
896 path_release(nd); 893 path_put(&nd->path);
897 return filp; 894 return filp;
898} 895}
899 896
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 7c6b4ec83cb7..88f8edf18258 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -153,7 +153,7 @@ static int get_nr_threads(struct task_struct *tsk)
153 return count; 153 return count;
154} 154}
155 155
156static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) 156static int proc_cwd_link(struct inode *inode, struct path *path)
157{ 157{
158 struct task_struct *task = get_proc_task(inode); 158 struct task_struct *task = get_proc_task(inode);
159 struct fs_struct *fs = NULL; 159 struct fs_struct *fs = NULL;
@@ -165,8 +165,8 @@ static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfs
165 } 165 }
166 if (fs) { 166 if (fs) {
167 read_lock(&fs->lock); 167 read_lock(&fs->lock);
168 *mnt = mntget(fs->pwdmnt); 168 *path = fs->pwd;
169 *dentry = dget(fs->pwd); 169 path_get(&fs->pwd);
170 read_unlock(&fs->lock); 170 read_unlock(&fs->lock);
171 result = 0; 171 result = 0;
172 put_fs_struct(fs); 172 put_fs_struct(fs);
@@ -174,7 +174,7 @@ static int proc_cwd_link(struct inode *inode, struct dentry **dentry, struct vfs
174 return result; 174 return result;
175} 175}
176 176
177static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) 177static int proc_root_link(struct inode *inode, struct path *path)
178{ 178{
179 struct task_struct *task = get_proc_task(inode); 179 struct task_struct *task = get_proc_task(inode);
180 struct fs_struct *fs = NULL; 180 struct fs_struct *fs = NULL;
@@ -186,8 +186,8 @@ static int proc_root_link(struct inode *inode, struct dentry **dentry, struct vf
186 } 186 }
187 if (fs) { 187 if (fs) {
188 read_lock(&fs->lock); 188 read_lock(&fs->lock);
189 *mnt = mntget(fs->rootmnt); 189 *path = fs->root;
190 *dentry = dget(fs->root); 190 path_get(&fs->root);
191 read_unlock(&fs->lock); 191 read_unlock(&fs->lock);
192 result = 0; 192 result = 0;
193 put_fs_struct(fs); 193 put_fs_struct(fs);
@@ -1164,39 +1164,36 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
1164 int error = -EACCES; 1164 int error = -EACCES;
1165 1165
1166 /* We don't need a base pointer in the /proc filesystem */ 1166 /* We don't need a base pointer in the /proc filesystem */
1167 path_release(nd); 1167 path_put(&nd->path);
1168 1168
1169 /* Are we allowed to snoop on the tasks file descriptors? */ 1169 /* Are we allowed to snoop on the tasks file descriptors? */
1170 if (!proc_fd_access_allowed(inode)) 1170 if (!proc_fd_access_allowed(inode))
1171 goto out; 1171 goto out;
1172 1172
1173 error = PROC_I(inode)->op.proc_get_link(inode, &nd->dentry, &nd->mnt); 1173 error = PROC_I(inode)->op.proc_get_link(inode, &nd->path);
1174 nd->last_type = LAST_BIND; 1174 nd->last_type = LAST_BIND;
1175out: 1175out:
1176 return ERR_PTR(error); 1176 return ERR_PTR(error);
1177} 1177}
1178 1178
1179static int do_proc_readlink(struct dentry *dentry, struct vfsmount *mnt, 1179static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
1180 char __user *buffer, int buflen)
1181{ 1180{
1182 struct inode * inode;
1183 char *tmp = (char*)__get_free_page(GFP_TEMPORARY); 1181 char *tmp = (char*)__get_free_page(GFP_TEMPORARY);
1184 char *path; 1182 char *pathname;
1185 int len; 1183 int len;
1186 1184
1187 if (!tmp) 1185 if (!tmp)
1188 return -ENOMEM; 1186 return -ENOMEM;
1189 1187
1190 inode = dentry->d_inode; 1188 pathname = d_path(path, tmp, PAGE_SIZE);
1191 path = d_path(dentry, mnt, tmp, PAGE_SIZE); 1189 len = PTR_ERR(pathname);
1192 len = PTR_ERR(path); 1190 if (IS_ERR(pathname))
1193 if (IS_ERR(path))
1194 goto out; 1191 goto out;
1195 len = tmp + PAGE_SIZE - 1 - path; 1192 len = tmp + PAGE_SIZE - 1 - pathname;
1196 1193
1197 if (len > buflen) 1194 if (len > buflen)
1198 len = buflen; 1195 len = buflen;
1199 if (copy_to_user(buffer, path, len)) 1196 if (copy_to_user(buffer, pathname, len))
1200 len = -EFAULT; 1197 len = -EFAULT;
1201 out: 1198 out:
1202 free_page((unsigned long)tmp); 1199 free_page((unsigned long)tmp);
@@ -1207,20 +1204,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
1207{ 1204{
1208 int error = -EACCES; 1205 int error = -EACCES;
1209 struct inode *inode = dentry->d_inode; 1206 struct inode *inode = dentry->d_inode;
1210 struct dentry *de; 1207 struct path path;
1211 struct vfsmount *mnt = NULL;
1212 1208
1213 /* Are we allowed to snoop on the tasks file descriptors? */ 1209 /* Are we allowed to snoop on the tasks file descriptors? */
1214 if (!proc_fd_access_allowed(inode)) 1210 if (!proc_fd_access_allowed(inode))
1215 goto out; 1211 goto out;
1216 1212
1217 error = PROC_I(inode)->op.proc_get_link(inode, &de, &mnt); 1213 error = PROC_I(inode)->op.proc_get_link(inode, &path);
1218 if (error) 1214 if (error)
1219 goto out; 1215 goto out;
1220 1216
1221 error = do_proc_readlink(de, mnt, buffer, buflen); 1217 error = do_proc_readlink(&path, buffer, buflen);
1222 dput(de); 1218 path_put(&path);
1223 mntput(mnt);
1224out: 1219out:
1225 return error; 1220 return error;
1226} 1221}
@@ -1447,8 +1442,7 @@ out:
1447 1442
1448#define PROC_FDINFO_MAX 64 1443#define PROC_FDINFO_MAX 64
1449 1444
1450static int proc_fd_info(struct inode *inode, struct dentry **dentry, 1445static int proc_fd_info(struct inode *inode, struct path *path, char *info)
1451 struct vfsmount **mnt, char *info)
1452{ 1446{
1453 struct task_struct *task = get_proc_task(inode); 1447 struct task_struct *task = get_proc_task(inode);
1454 struct files_struct *files = NULL; 1448 struct files_struct *files = NULL;
@@ -1467,10 +1461,10 @@ static int proc_fd_info(struct inode *inode, struct dentry **dentry,
1467 spin_lock(&files->file_lock); 1461 spin_lock(&files->file_lock);
1468 file = fcheck_files(files, fd); 1462 file = fcheck_files(files, fd);
1469 if (file) { 1463 if (file) {
1470 if (mnt) 1464 if (path) {
1471 *mnt = mntget(file->f_path.mnt); 1465 *path = file->f_path;
1472 if (dentry) 1466 path_get(&file->f_path);
1473 *dentry = dget(file->f_path.dentry); 1467 }
1474 if (info) 1468 if (info)
1475 snprintf(info, PROC_FDINFO_MAX, 1469 snprintf(info, PROC_FDINFO_MAX,
1476 "pos:\t%lli\n" 1470 "pos:\t%lli\n"
@@ -1487,10 +1481,9 @@ static int proc_fd_info(struct inode *inode, struct dentry **dentry,
1487 return -ENOENT; 1481 return -ENOENT;
1488} 1482}
1489 1483
1490static int proc_fd_link(struct inode *inode, struct dentry **dentry, 1484static int proc_fd_link(struct inode *inode, struct path *path)
1491 struct vfsmount **mnt)
1492{ 1485{
1493 return proc_fd_info(inode, dentry, mnt, NULL); 1486 return proc_fd_info(inode, path, NULL);
1494} 1487}
1495 1488
1496static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd) 1489static int tid_fd_revalidate(struct dentry *dentry, struct nameidata *nd)
@@ -1684,7 +1677,7 @@ static ssize_t proc_fdinfo_read(struct file *file, char __user *buf,
1684 size_t len, loff_t *ppos) 1677 size_t len, loff_t *ppos)
1685{ 1678{
1686 char tmp[PROC_FDINFO_MAX]; 1679 char tmp[PROC_FDINFO_MAX];
1687 int err = proc_fd_info(file->f_path.dentry->d_inode, NULL, NULL, tmp); 1680 int err = proc_fd_info(file->f_path.dentry->d_inode, NULL, tmp);
1688 if (!err) 1681 if (!err)
1689 err = simple_read_from_buffer(buf, len, ppos, tmp, strlen(tmp)); 1682 err = simple_read_from_buffer(buf, len, ppos, tmp, strlen(tmp));
1690 return err; 1683 return err;
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index ea496ffeabe7..1c81c8f1aeed 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -48,7 +48,7 @@ extern int maps_protect;
48 48
49extern void create_seq_entry(char *name, mode_t mode, 49extern void create_seq_entry(char *name, mode_t mode,
50 const struct file_operations *f); 50 const struct file_operations *f);
51extern int proc_exe_link(struct inode *, struct dentry **, struct vfsmount **); 51extern int proc_exe_link(struct inode *, struct path *);
52extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns, 52extern int proc_tid_stat(struct seq_file *m, struct pid_namespace *ns,
53 struct pid *pid, struct task_struct *task); 53 struct pid *pid, struct task_struct *task);
54extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns, 54extern int proc_tgid_stat(struct seq_file *m, struct pid_namespace *ns,
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index 5d9147b9d738..941e95114b5a 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -67,7 +67,7 @@ int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)
67 if (len < 1) 67 if (len < 1)
68 len = 1; 68 len = 1;
69 seq_printf(m, "%*c", len, ' '); 69 seq_printf(m, "%*c", len, ' ');
70 seq_path(m, file->f_path.mnt, file->f_path.dentry, ""); 70 seq_path(m, &file->f_path, "");
71 } 71 }
72 72
73 seq_putc(m, '\n'); 73 seq_putc(m, '\n');
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index b9cb23c08f63..614c34b6d1c2 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -407,7 +407,7 @@ static int proc_sys_permission(struct inode *inode, int mask, struct nameidata *
407 if (!nd || !depth) 407 if (!nd || !depth)
408 goto out; 408 goto out;
409 409
410 dentry = nd->dentry; 410 dentry = nd->path.dentry;
411 table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head); 411 table = do_proc_sys_lookup(dentry->d_parent, &dentry->d_name, &head);
412 412
413 /* If the entry does not exist deny permission */ 413 /* If the entry does not exist deny permission */
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index ae4d3f2c8cb2..49958cffbd8d 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -75,7 +75,7 @@ int task_statm(struct mm_struct *mm, int *shared, int *text,
75 return mm->total_vm; 75 return mm->total_vm;
76} 76}
77 77
78int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) 78int proc_exe_link(struct inode *inode, struct path *path)
79{ 79{
80 struct vm_area_struct * vma; 80 struct vm_area_struct * vma;
81 int result = -ENOENT; 81 int result = -ENOENT;
@@ -98,8 +98,8 @@ int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount *
98 } 98 }
99 99
100 if (vma) { 100 if (vma) {
101 *mnt = mntget(vma->vm_file->f_path.mnt); 101 *path = vma->vm_file->f_path;
102 *dentry = dget(vma->vm_file->f_path.dentry); 102 path_get(&vma->vm_file->f_path);
103 result = 0; 103 result = 0;
104 } 104 }
105 105
@@ -271,7 +271,7 @@ static int show_map(struct seq_file *m, void *v)
271 */ 271 */
272 if (file) { 272 if (file) {
273 pad_len_spaces(m, len); 273 pad_len_spaces(m, len);
274 seq_path(m, file->f_path.mnt, file->f_path.dentry, "\n"); 274 seq_path(m, &file->f_path, "\n");
275 } else { 275 } else {
276 const char *name = arch_vma_name(vma); 276 const char *name = arch_vma_name(vma);
277 if (!name) { 277 if (!name) {
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index abfc6f5e56ca..8011528518bd 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -103,7 +103,7 @@ int task_statm(struct mm_struct *mm, int *shared, int *text,
103 return size; 103 return size;
104} 104}
105 105
106int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount **mnt) 106int proc_exe_link(struct inode *inode, struct path *path)
107{ 107{
108 struct vm_list_struct *vml; 108 struct vm_list_struct *vml;
109 struct vm_area_struct *vma; 109 struct vm_area_struct *vma;
@@ -126,8 +126,8 @@ int proc_exe_link(struct inode *inode, struct dentry **dentry, struct vfsmount *
126 } 126 }
127 127
128 if (vma) { 128 if (vma) {
129 *mnt = mntget(vma->vm_file->f_path.mnt); 129 *path = vma->vm_file->f_path;
130 *dentry = dget(vma->vm_file->f_path.dentry); 130 path_get(&vma->vm_file->f_path);
131 result = 0; 131 result = 0;
132 } 132 }
133 133
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 6033f0c3bd0b..6841452e0dea 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -2026,29 +2026,29 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2026 if (err) 2026 if (err)
2027 return err; 2027 return err;
2028 /* Quotafile not on the same filesystem? */ 2028 /* Quotafile not on the same filesystem? */
2029 if (nd.mnt->mnt_sb != sb) { 2029 if (nd.path.mnt->mnt_sb != sb) {
2030 path_release(&nd); 2030 path_put(&nd.path);
2031 return -EXDEV; 2031 return -EXDEV;
2032 } 2032 }
2033 /* We must not pack tails for quota files on reiserfs for quota IO to work */ 2033 /* We must not pack tails for quota files on reiserfs for quota IO to work */
2034 if (!REISERFS_I(nd.dentry->d_inode)->i_flags & i_nopack_mask) { 2034 if (!REISERFS_I(nd.path.dentry->d_inode)->i_flags & i_nopack_mask) {
2035 reiserfs_warning(sb, 2035 reiserfs_warning(sb,
2036 "reiserfs: Quota file must have tail packing disabled."); 2036 "reiserfs: Quota file must have tail packing disabled.");
2037 path_release(&nd); 2037 path_put(&nd.path);
2038 return -EINVAL; 2038 return -EINVAL;
2039 } 2039 }
2040 /* Not journalling quota? No more tests needed... */ 2040 /* Not journalling quota? No more tests needed... */
2041 if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] && 2041 if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] &&
2042 !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) { 2042 !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) {
2043 path_release(&nd); 2043 path_put(&nd.path);
2044 return vfs_quota_on(sb, type, format_id, path); 2044 return vfs_quota_on(sb, type, format_id, path);
2045 } 2045 }
2046 /* Quotafile not of fs root? */ 2046 /* Quotafile not of fs root? */
2047 if (nd.dentry->d_parent->d_inode != sb->s_root->d_inode) 2047 if (nd.path.dentry->d_parent->d_inode != sb->s_root->d_inode)
2048 reiserfs_warning(sb, 2048 reiserfs_warning(sb,
2049 "reiserfs: Quota file not on filesystem root. " 2049 "reiserfs: Quota file not on filesystem root. "
2050 "Journalled quota will not work."); 2050 "Journalled quota will not work.");
2051 path_release(&nd); 2051 path_put(&nd.path);
2052 return vfs_quota_on(sb, type, format_id, path); 2052 return vfs_quota_on(sb, type, format_id, path);
2053} 2053}
2054 2054
diff --git a/fs/seq_file.c b/fs/seq_file.c
index ca71c115bdaa..853770274f20 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -342,13 +342,11 @@ int seq_printf(struct seq_file *m, const char *f, ...)
342} 342}
343EXPORT_SYMBOL(seq_printf); 343EXPORT_SYMBOL(seq_printf);
344 344
345int seq_path(struct seq_file *m, 345int seq_path(struct seq_file *m, struct path *path, char *esc)
346 struct vfsmount *mnt, struct dentry *dentry,
347 char *esc)
348{ 346{
349 if (m->count < m->size) { 347 if (m->count < m->size) {
350 char *s = m->buf + m->count; 348 char *s = m->buf + m->count;
351 char *p = d_path(dentry, mnt, s, m->size - m->count); 349 char *p = d_path(path, s, m->size - m->count);
352 if (!IS_ERR(p)) { 350 if (!IS_ERR(p)) {
353 while (s <= p) { 351 while (s <= p) {
354 char c = *p++; 352 char c = *p++;
diff --git a/fs/stat.c b/fs/stat.c
index 68510068a641..9cf41f719d50 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -62,8 +62,8 @@ int vfs_stat_fd(int dfd, char __user *name, struct kstat *stat)
62 62
63 error = __user_walk_fd(dfd, name, LOOKUP_FOLLOW, &nd); 63 error = __user_walk_fd(dfd, name, LOOKUP_FOLLOW, &nd);
64 if (!error) { 64 if (!error) {
65 error = vfs_getattr(nd.mnt, nd.dentry, stat); 65 error = vfs_getattr(nd.path.mnt, nd.path.dentry, stat);
66 path_release(&nd); 66 path_put(&nd.path);
67 } 67 }
68 return error; 68 return error;
69} 69}
@@ -82,8 +82,8 @@ int vfs_lstat_fd(int dfd, char __user *name, struct kstat *stat)
82 82
83 error = __user_walk_fd(dfd, name, 0, &nd); 83 error = __user_walk_fd(dfd, name, 0, &nd);
84 if (!error) { 84 if (!error) {
85 error = vfs_getattr(nd.mnt, nd.dentry, stat); 85 error = vfs_getattr(nd.path.mnt, nd.path.dentry, stat);
86 path_release(&nd); 86 path_put(&nd.path);
87 } 87 }
88 return error; 88 return error;
89} 89}
@@ -302,17 +302,18 @@ asmlinkage long sys_readlinkat(int dfd, const char __user *path,
302 302
303 error = __user_walk_fd(dfd, path, 0, &nd); 303 error = __user_walk_fd(dfd, path, 0, &nd);
304 if (!error) { 304 if (!error) {
305 struct inode * inode = nd.dentry->d_inode; 305 struct inode *inode = nd.path.dentry->d_inode;
306 306
307 error = -EINVAL; 307 error = -EINVAL;
308 if (inode->i_op && inode->i_op->readlink) { 308 if (inode->i_op && inode->i_op->readlink) {
309 error = security_inode_readlink(nd.dentry); 309 error = security_inode_readlink(nd.path.dentry);
310 if (!error) { 310 if (!error) {
311 touch_atime(nd.mnt, nd.dentry); 311 touch_atime(nd.path.mnt, nd.path.dentry);
312 error = inode->i_op->readlink(nd.dentry, buf, bufsiz); 312 error = inode->i_op->readlink(nd.path.dentry,
313 buf, bufsiz);
313 } 314 }
314 } 315 }
315 path_release(&nd); 316 path_put(&nd.path);
316 } 317 }
317 return error; 318 return error;
318} 319}
diff --git a/fs/utimes.c b/fs/utimes.c
index e5588cd8530e..b18da9c0b97f 100644
--- a/fs/utimes.c
+++ b/fs/utimes.c
@@ -84,7 +84,7 @@ long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags
84 if (error) 84 if (error)
85 goto out; 85 goto out;
86 86
87 dentry = nd.dentry; 87 dentry = nd.path.dentry;
88 } 88 }
89 89
90 inode = dentry->d_inode; 90 inode = dentry->d_inode;
@@ -138,7 +138,7 @@ dput_and_out:
138 if (f) 138 if (f)
139 fput(f); 139 fput(f);
140 else 140 else
141 path_release(&nd); 141 path_put(&nd.path);
142out: 142out:
143 return error; 143 return error;
144} 144}
diff --git a/fs/xattr.c b/fs/xattr.c
index f7c8f87bb390..3acab1615460 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -262,8 +262,8 @@ sys_setxattr(char __user *path, char __user *name, void __user *value,
262 error = user_path_walk(path, &nd); 262 error = user_path_walk(path, &nd);
263 if (error) 263 if (error)
264 return error; 264 return error;
265 error = setxattr(nd.dentry, name, value, size, flags); 265 error = setxattr(nd.path.dentry, name, value, size, flags);
266 path_release(&nd); 266 path_put(&nd.path);
267 return error; 267 return error;
268} 268}
269 269
@@ -277,8 +277,8 @@ sys_lsetxattr(char __user *path, char __user *name, void __user *value,
277 error = user_path_walk_link(path, &nd); 277 error = user_path_walk_link(path, &nd);
278 if (error) 278 if (error)
279 return error; 279 return error;
280 error = setxattr(nd.dentry, name, value, size, flags); 280 error = setxattr(nd.path.dentry, name, value, size, flags);
281 path_release(&nd); 281 path_put(&nd.path);
282 return error; 282 return error;
283} 283}
284 284
@@ -347,8 +347,8 @@ sys_getxattr(char __user *path, char __user *name, void __user *value,
347 error = user_path_walk(path, &nd); 347 error = user_path_walk(path, &nd);
348 if (error) 348 if (error)
349 return error; 349 return error;
350 error = getxattr(nd.dentry, name, value, size); 350 error = getxattr(nd.path.dentry, name, value, size);
351 path_release(&nd); 351 path_put(&nd.path);
352 return error; 352 return error;
353} 353}
354 354
@@ -362,8 +362,8 @@ sys_lgetxattr(char __user *path, char __user *name, void __user *value,
362 error = user_path_walk_link(path, &nd); 362 error = user_path_walk_link(path, &nd);
363 if (error) 363 if (error)
364 return error; 364 return error;
365 error = getxattr(nd.dentry, name, value, size); 365 error = getxattr(nd.path.dentry, name, value, size);
366 path_release(&nd); 366 path_put(&nd.path);
367 return error; 367 return error;
368} 368}
369 369
@@ -421,8 +421,8 @@ sys_listxattr(char __user *path, char __user *list, size_t size)
421 error = user_path_walk(path, &nd); 421 error = user_path_walk(path, &nd);
422 if (error) 422 if (error)
423 return error; 423 return error;
424 error = listxattr(nd.dentry, list, size); 424 error = listxattr(nd.path.dentry, list, size);
425 path_release(&nd); 425 path_put(&nd.path);
426 return error; 426 return error;
427} 427}
428 428
@@ -435,8 +435,8 @@ sys_llistxattr(char __user *path, char __user *list, size_t size)
435 error = user_path_walk_link(path, &nd); 435 error = user_path_walk_link(path, &nd);
436 if (error) 436 if (error)
437 return error; 437 return error;
438 error = listxattr(nd.dentry, list, size); 438 error = listxattr(nd.path.dentry, list, size);
439 path_release(&nd); 439 path_put(&nd.path);
440 return error; 440 return error;
441} 441}
442 442
@@ -482,8 +482,8 @@ sys_removexattr(char __user *path, char __user *name)
482 error = user_path_walk(path, &nd); 482 error = user_path_walk(path, &nd);
483 if (error) 483 if (error)
484 return error; 484 return error;
485 error = removexattr(nd.dentry, name); 485 error = removexattr(nd.path.dentry, name);
486 path_release(&nd); 486 path_put(&nd.path);
487 return error; 487 return error;
488} 488}
489 489
@@ -496,8 +496,8 @@ sys_lremovexattr(char __user *path, char __user *name)
496 error = user_path_walk_link(path, &nd); 496 error = user_path_walk_link(path, &nd);
497 if (error) 497 if (error)
498 return error; 498 return error;
499 error = removexattr(nd.dentry, name); 499 error = removexattr(nd.path.dentry, name);
500 path_release(&nd); 500 path_put(&nd.path);
501 return error; 501 return error;
502} 502}
503 503
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index 4c82a050a3a8..a9952e490ac9 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -91,10 +91,10 @@ xfs_find_handle(
91 if (error) 91 if (error)
92 return error; 92 return error;
93 93
94 ASSERT(nd.dentry); 94 ASSERT(nd.path.dentry);
95 ASSERT(nd.dentry->d_inode); 95 ASSERT(nd.path.dentry->d_inode);
96 inode = igrab(nd.dentry->d_inode); 96 inode = igrab(nd.path.dentry->d_inode);
97 path_release(&nd); 97 path_put(&nd.path);
98 break; 98 break;
99 } 99 }
100 100
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index cdc8004cfd12..06480bcabfdc 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -32,9 +32,11 @@
32#define DOMAIN_COORD_TYPE_SW_ANY 0xfd 32#define DOMAIN_COORD_TYPE_SW_ANY 0xfd
33#define DOMAIN_COORD_TYPE_HW_ALL 0xfe 33#define DOMAIN_COORD_TYPE_HW_ALL 0xfe
34 34
35#define ACPI_CSTATE_SYSTEMIO (0) 35#define ACPI_CSTATE_SYSTEMIO 0
36#define ACPI_CSTATE_FFH (1) 36#define ACPI_CSTATE_FFH 1
37#define ACPI_CSTATE_HALT (2) 37#define ACPI_CSTATE_HALT 2
38
39#define ACPI_CX_DESC_LEN 32
38 40
39/* Power Management */ 41/* Power Management */
40 42
@@ -74,6 +76,7 @@ struct acpi_processor_cx {
74 u64 time; 76 u64 time;
75 struct acpi_processor_cx_policy promotion; 77 struct acpi_processor_cx_policy promotion;
76 struct acpi_processor_cx_policy demotion; 78 struct acpi_processor_cx_policy demotion;
79 char desc[ACPI_CX_DESC_LEN];
77}; 80};
78 81
79struct acpi_processor_power { 82struct acpi_processor_power {
diff --git a/include/asm-m68knommu/cacheflush.h b/include/asm-m68knommu/cacheflush.h
index 29bc0aad2ebc..87e5dc0413b4 100644
--- a/include/asm-m68knommu/cacheflush.h
+++ b/include/asm-m68knommu/cacheflush.h
@@ -54,28 +54,28 @@ static inline void __flush_cache_all(void)
54#if defined(CONFIG_M527x) || defined(CONFIG_M528x) 54#if defined(CONFIG_M527x) || defined(CONFIG_M528x)
55 __asm__ __volatile__ ( 55 __asm__ __volatile__ (
56 "movel #0x81000200, %%d0\n\t" 56 "movel #0x81000200, %%d0\n\t"
57 "movec %%d0, %%CACR\n\t" 57 "movec %%d0, %%CACR\n\t"
58 "nop\n\t" 58 "nop\n\t"
59 : : : "d0" ); 59 : : : "d0" );
60#endif /* CONFIG_M527x || CONFIG_M528x */ 60#endif /* CONFIG_M527x || CONFIG_M528x */
61#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || defined(CONFIG_M5272) 61#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || defined(CONFIG_M5272)
62 __asm__ __volatile__ ( 62 __asm__ __volatile__ (
63 "movel #0x81000100, %%d0\n\t" 63 "movel #0x81000100, %%d0\n\t"
64 "movec %%d0, %%CACR\n\t" 64 "movec %%d0, %%CACR\n\t"
65 "nop\n\t" 65 "nop\n\t"
66 : : : "d0" ); 66 : : : "d0" );
67#endif /* CONFIG_M5206 || CONFIG_M5206e || CONFIG_M5272 */ 67#endif /* CONFIG_M5206 || CONFIG_M5206e || CONFIG_M5272 */
68#ifdef CONFIG_M5249 68#ifdef CONFIG_M5249
69 __asm__ __volatile__ ( 69 __asm__ __volatile__ (
70 "movel #0xa1000200, %%d0\n\t" 70 "movel #0xa1000200, %%d0\n\t"
71 "movec %%d0, %%CACR\n\t" 71 "movec %%d0, %%CACR\n\t"
72 "nop\n\t" 72 "nop\n\t"
73 : : : "d0" ); 73 : : : "d0" );
74#endif /* CONFIG_M5249 */ 74#endif /* CONFIG_M5249 */
75#ifdef CONFIG_M532x 75#ifdef CONFIG_M532x
76 __asm__ __volatile__ ( 76 __asm__ __volatile__ (
77 "movel #0x81000200, %%d0\n\t" 77 "movel #0x81000200, %%d0\n\t"
78 "movec %%d0, %%CACR\n\t" 78 "movec %%d0, %%CACR\n\t"
79 "nop\n\t" 79 "nop\n\t"
80 : : : "d0" ); 80 : : : "d0" );
81#endif /* CONFIG_M532x */ 81#endif /* CONFIG_M532x */
diff --git a/include/asm-m68knommu/system.h b/include/asm-m68knommu/system.h
index 039ab3f81732..64c64432bbb8 100644
--- a/include/asm-m68knommu/system.h
+++ b/include/asm-m68knommu/system.h
@@ -104,7 +104,7 @@ asmlinkage void resume(void);
104#define mb() asm volatile ("" : : :"memory") 104#define mb() asm volatile ("" : : :"memory")
105#define rmb() asm volatile ("" : : :"memory") 105#define rmb() asm volatile ("" : : :"memory")
106#define wmb() asm volatile ("" : : :"memory") 106#define wmb() asm volatile ("" : : :"memory")
107#define set_mb(var, value) do { xchg(&var, value); } while (0) 107#define set_mb(var, value) ({ (var) = (value); wmb(); })
108 108
109#ifdef CONFIG_SMP 109#ifdef CONFIG_SMP
110#define smp_mb() mb() 110#define smp_mb() mb()
diff --git a/include/asm-powerpc/systbl.h b/include/asm-powerpc/systbl.h
index e996521fb3a6..ae7085c65692 100644
--- a/include/asm-powerpc/systbl.h
+++ b/include/asm-powerpc/systbl.h
@@ -309,8 +309,10 @@ SYSCALL_SPU(getcpu)
309COMPAT_SYS(epoll_pwait) 309COMPAT_SYS(epoll_pwait)
310COMPAT_SYS_SPU(utimensat) 310COMPAT_SYS_SPU(utimensat)
311COMPAT_SYS_SPU(signalfd) 311COMPAT_SYS_SPU(signalfd)
312SYSCALL(ni_syscall) 312SYSCALL_SPU(timerfd_create)
313SYSCALL_SPU(eventfd) 313SYSCALL_SPU(eventfd)
314COMPAT_SYS_SPU(sync_file_range2) 314COMPAT_SYS_SPU(sync_file_range2)
315COMPAT_SYS(fallocate) 315COMPAT_SYS(fallocate)
316SYSCALL(subpage_prot) 316SYSCALL(subpage_prot)
317COMPAT_SYS_SPU(timerfd_settime)
318COMPAT_SYS_SPU(timerfd_gettime)
diff --git a/include/asm-powerpc/unistd.h b/include/asm-powerpc/unistd.h
index fedc4b8e49e2..ce91bb662063 100644
--- a/include/asm-powerpc/unistd.h
+++ b/include/asm-powerpc/unistd.h
@@ -328,15 +328,17 @@
328#define __NR_epoll_pwait 303 328#define __NR_epoll_pwait 303
329#define __NR_utimensat 304 329#define __NR_utimensat 304
330#define __NR_signalfd 305 330#define __NR_signalfd 305
331#define __NR_timerfd 306 331#define __NR_timerfd_create 306
332#define __NR_eventfd 307 332#define __NR_eventfd 307
333#define __NR_sync_file_range2 308 333#define __NR_sync_file_range2 308
334#define __NR_fallocate 309 334#define __NR_fallocate 309
335#define __NR_subpage_prot 310 335#define __NR_subpage_prot 310
336#define __NR_timerfd_settime 311
337#define __NR_timerfd_gettime 312
336 338
337#ifdef __KERNEL__ 339#ifdef __KERNEL__
338 340
339#define __NR_syscalls 311 341#define __NR_syscalls 313
340 342
341#define __NR__exit __NR_exit 343#define __NR__exit __NR_exit
342#define NR_syscalls __NR_syscalls 344#define NR_syscalls __NR_syscalls
diff --git a/include/asm-ppc/page.h b/include/asm-ppc/page.h
index ad4c5a1bc9d6..37e4756b6b2d 100644
--- a/include/asm-ppc/page.h
+++ b/include/asm-ppc/page.h
@@ -125,6 +125,8 @@ extern __inline__ int get_order(unsigned long size)
125 return 32 - lz; 125 return 32 - lz;
126} 126}
127 127
128typedef struct page *pgtable_t;
129
128#endif /* __ASSEMBLY__ */ 130#endif /* __ASSEMBLY__ */
129 131
130#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ 132#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
diff --git a/include/asm-sh/bugs.h b/include/asm-sh/bugs.h
index def8128b8b78..cfda7d5bf026 100644
--- a/include/asm-sh/bugs.h
+++ b/include/asm-sh/bugs.h
@@ -39,7 +39,7 @@ static void __init check_bugs(void)
39 *p++ = '4'; 39 *p++ = '4';
40 *p++ = 'a'; 40 *p++ = 'a';
41 break; 41 break;
42 case CPU_SH7343 ... CPU_SH7722: 42 case CPU_SH7343 ... CPU_SH7366:
43 *p++ = '4'; 43 *p++ = '4';
44 *p++ = 'a'; 44 *p++ = 'a';
45 *p++ = 'l'; 45 *p++ = 'l';
diff --git a/include/asm-sh/cpu-sh4/freq.h b/include/asm-sh/cpu-sh4/freq.h
index 1ac10b9a078f..ec028c649215 100644
--- a/include/asm-sh/cpu-sh4/freq.h
+++ b/include/asm-sh/cpu-sh4/freq.h
@@ -10,12 +10,14 @@
10#ifndef __ASM_CPU_SH4_FREQ_H 10#ifndef __ASM_CPU_SH4_FREQ_H
11#define __ASM_CPU_SH4_FREQ_H 11#define __ASM_CPU_SH4_FREQ_H
12 12
13#if defined(CONFIG_CPU_SUBTYPE_SH7722) 13#if defined(CONFIG_CPU_SUBTYPE_SH7722) || defined(CONFIG_CPU_SUBTYPE_SH7366)
14#define FRQCR 0xa4150000 14#define FRQCR 0xa4150000
15#define VCLKCR 0xa4150004 15#define VCLKCR 0xa4150004
16#define SCLKACR 0xa4150008 16#define SCLKACR 0xa4150008
17#define SCLKBCR 0xa415000c 17#define SCLKBCR 0xa415000c
18#if defined(CONFIG_CPU_SUBTYPE_SH7722)
18#define IrDACLKCR 0xa4150010 19#define IrDACLKCR 0xa4150010
20#endif
19#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 21#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \
20 defined(CONFIG_CPU_SUBTYPE_SH7780) 22 defined(CONFIG_CPU_SUBTYPE_SH7780)
21#define FRQCR 0xffc80000 23#define FRQCR 0xffc80000
diff --git a/include/asm-sh/cpu-sh5/cacheflush.h b/include/asm-sh/cpu-sh5/cacheflush.h
index 98edb5b1da32..5a11f0b7e66a 100644
--- a/include/asm-sh/cpu-sh5/cacheflush.h
+++ b/include/asm-sh/cpu-sh5/cacheflush.h
@@ -3,15 +3,13 @@
3 3
4#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
5 5
6#include <asm/page.h>
7
8struct vm_area_struct; 6struct vm_area_struct;
9struct page; 7struct page;
10struct mm_struct; 8struct mm_struct;
11 9
12extern void flush_cache_all(void); 10extern void flush_cache_all(void);
13extern void flush_cache_mm(struct mm_struct *mm); 11extern void flush_cache_mm(struct mm_struct *mm);
14extern void flush_cache_sigtramp(unsigned long start, unsigned long end); 12extern void flush_cache_sigtramp(unsigned long vaddr);
15extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start, 13extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
16 unsigned long end); 14 unsigned long end);
17extern void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn); 15extern void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn);
@@ -27,7 +25,7 @@ extern void flush_icache_user_range(struct vm_area_struct *vma,
27#define flush_dcache_mmap_unlock(mapping) do { } while (0) 25#define flush_dcache_mmap_unlock(mapping) do { } while (0)
28 26
29#define flush_icache_page(vma, page) do { } while (0) 27#define flush_icache_page(vma, page) do { } while (0)
30#define p3_cache_init() do { } while (0) 28void p3_cache_init(void);
31 29
32#endif /* __ASSEMBLY__ */ 30#endif /* __ASSEMBLY__ */
33 31
diff --git a/include/asm-sh/cpu-sh5/mmu_context.h b/include/asm-sh/cpu-sh5/mmu_context.h
index df857fc09960..68a1d2cff457 100644
--- a/include/asm-sh/cpu-sh5/mmu_context.h
+++ b/include/asm-sh/cpu-sh5/mmu_context.h
@@ -16,12 +16,6 @@
16/* This has to be a common function because the next location to fill 16/* This has to be a common function because the next location to fill
17 * information is shared. */ 17 * information is shared. */
18extern void __do_tlb_refill(unsigned long address, unsigned long long is_text_not_data, pte_t *pte); 18extern void __do_tlb_refill(unsigned long address, unsigned long long is_text_not_data, pte_t *pte);
19
20/* Profiling counter. */
21#ifdef CONFIG_SH64_PROC_TLB
22extern unsigned long long calls_to_do_fast_page_fault;
23#endif
24
25#endif /* __ASSEMBLY__ */ 19#endif /* __ASSEMBLY__ */
26 20
27#endif /* __ASM_SH_CPU_SH5_MMU_CONTEXT_H */ 21#endif /* __ASM_SH_CPU_SH5_MMU_CONTEXT_H */
diff --git a/include/asm-sh/hp6xx.h b/include/asm-sh/hp6xx.h
index 53ca5643d9c7..0d4165a32dcd 100644
--- a/include/asm-sh/hp6xx.h
+++ b/include/asm-sh/hp6xx.h
@@ -10,9 +10,9 @@
10 * 10 *
11 */ 11 */
12 12
13#define HP680_BTN_IRQ 32 /* IRQ0_IRQ */ 13#define HP680_BTN_IRQ 32 /* IRQ0_IRQ */
14#define HP680_TS_IRQ 35 /* IRQ3_IRQ */ 14#define HP680_TS_IRQ 35 /* IRQ3_IRQ */
15#define HP680_HD64461_IRQ 36 /* IRQ4_IRQ */ 15#define HP680_HD64461_IRQ 36 /* IRQ4_IRQ */
16 16
17#define DAC_LCD_BRIGHTNESS 0 17#define DAC_LCD_BRIGHTNESS 0
18#define DAC_SPEAKER_VOLUME 1 18#define DAC_SPEAKER_VOLUME 1
@@ -55,26 +55,4 @@
55#define PJDR 0xa4000130 55#define PJDR 0xa4000130
56#define PKDR 0xa4000132 56#define PKDR 0xa4000132
57 57
58static inline void hp6xx_led_red(int on)
59{
60 u16 v16;
61 v16 = ctrl_inw(CONFIG_HD64461_IOBASE + HD64461_GPBDR - 0x10000);
62 if (on)
63 ctrl_outw(v16 & (~HD64461_GPBDR_LED_RED), CONFIG_HD64461_IOBASE + HD64461_GPBDR - 0x10000);
64 else
65 ctrl_outw(v16 | HD64461_GPBDR_LED_RED, CONFIG_HD64461_IOBASE + HD64461_GPBDR - 0x10000);
66}
67
68static inline void hp6xx_led_green(int on)
69{
70 u8 v8;
71
72 v8 = ctrl_inb(PKDR);
73 if (on)
74 ctrl_outb(v8 & (~PKDR_LED_GREEN), PKDR);
75 else
76 ctrl_outb(v8 | PKDR_LED_GREEN, PKDR);
77}
78
79
80#endif /* __ASM_SH_HP6XX_H */ 58#endif /* __ASM_SH_HP6XX_H */
diff --git a/include/asm-sh/io.h b/include/asm-sh/io.h
index 94900c089519..356e50d06745 100644
--- a/include/asm-sh/io.h
+++ b/include/asm-sh/io.h
@@ -38,6 +38,7 @@
38 */ 38 */
39#define __IO_PREFIX generic 39#define __IO_PREFIX generic
40#include <asm/io_generic.h> 40#include <asm/io_generic.h>
41#include <asm/io_trapped.h>
41 42
42#define maybebadio(port) \ 43#define maybebadio(port) \
43 printk(KERN_ERR "bad PC-like io %s:%u for port 0x%lx at 0x%08x\n", \ 44 printk(KERN_ERR "bad PC-like io %s:%u for port 0x%lx at 0x%08x\n", \
@@ -181,13 +182,13 @@ __BUILD_MEMORY_STRING(w, u16)
181#define iowrite32(v,a) writel((v),(a)) 182#define iowrite32(v,a) writel((v),(a))
182#define iowrite32be(v,a) __raw_writel(cpu_to_be32((v)),(a)) 183#define iowrite32be(v,a) __raw_writel(cpu_to_be32((v)),(a))
183 184
184#define ioread8_rep(a,d,c) insb((a),(d),(c)) 185#define ioread8_rep(a, d, c) readsb((a), (d), (c))
185#define ioread16_rep(a,d,c) insw((a),(d),(c)) 186#define ioread16_rep(a, d, c) readsw((a), (d), (c))
186#define ioread32_rep(a,d,c) insl((a),(d),(c)) 187#define ioread32_rep(a, d, c) readsl((a), (d), (c))
187 188
188#define iowrite8_rep(a,s,c) outsb((a),(s),(c)) 189#define iowrite8_rep(a, s, c) writesb((a), (s), (c))
189#define iowrite16_rep(a,s,c) outsw((a),(s),(c)) 190#define iowrite16_rep(a, s, c) writesw((a), (s), (c))
190#define iowrite32_rep(a,s,c) outsl((a),(s),(c)) 191#define iowrite32_rep(a, s, c) writesl((a), (s), (c))
191 192
192#define mmiowb() wmb() /* synco on SH-4A, otherwise a nop */ 193#define mmiowb() wmb() /* synco on SH-4A, otherwise a nop */
193 194
@@ -207,6 +208,8 @@ static inline void __set_io_port_base(unsigned long pbase)
207 generic_io_base = pbase; 208 generic_io_base = pbase;
208} 209}
209 210
211#define __ioport_map(p, n) sh_mv.mv_ioport_map((p), (n))
212
210/* We really want to try and get these to memcpy etc */ 213/* We really want to try and get these to memcpy etc */
211extern void memcpy_fromio(void *, volatile void __iomem *, unsigned long); 214extern void memcpy_fromio(void *, volatile void __iomem *, unsigned long);
212extern void memcpy_toio(volatile void __iomem *, const void *, unsigned long); 215extern void memcpy_toio(volatile void __iomem *, const void *, unsigned long);
@@ -309,7 +312,14 @@ __ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
309{ 312{
310#ifdef CONFIG_SUPERH32 313#ifdef CONFIG_SUPERH32
311 unsigned long last_addr = offset + size - 1; 314 unsigned long last_addr = offset + size - 1;
315#endif
316 void __iomem *ret;
312 317
318 ret = __ioremap_trapped(offset, size);
319 if (ret)
320 return ret;
321
322#ifdef CONFIG_SUPERH32
313 /* 323 /*
314 * For P1 and P2 space this is trivial, as everything is already 324 * For P1 and P2 space this is trivial, as everything is already
315 * mapped. Uncached access for P1 addresses are done through P2. 325 * mapped. Uncached access for P1 addresses are done through P2.
diff --git a/include/asm-sh/io_trapped.h b/include/asm-sh/io_trapped.h
new file mode 100644
index 000000000000..f1251d4f0ba9
--- /dev/null
+++ b/include/asm-sh/io_trapped.h
@@ -0,0 +1,58 @@
1#ifndef __ASM_SH_IO_TRAPPED_H
2#define __ASM_SH_IO_TRAPPED_H
3
4#include <linux/list.h>
5#include <linux/ioport.h>
6#include <asm/page.h>
7
8#define IO_TRAPPED_MAGIC 0xfeedbeef
9
10struct trapped_io {
11 unsigned int magic;
12 struct resource *resource;
13 unsigned int num_resources;
14 unsigned int minimum_bus_width;
15 struct list_head list;
16 void __iomem *virt_base;
17} __aligned(PAGE_SIZE);
18
19#ifdef CONFIG_IO_TRAPPED
20int register_trapped_io(struct trapped_io *tiop);
21int handle_trapped_io(struct pt_regs *regs, unsigned long address);
22
23void __iomem *match_trapped_io_handler(struct list_head *list,
24 unsigned long offset,
25 unsigned long size);
26
27#ifdef CONFIG_HAS_IOMEM
28extern struct list_head trapped_mem;
29
30static inline void __iomem *
31__ioremap_trapped(unsigned long offset, unsigned long size)
32{
33 return match_trapped_io_handler(&trapped_mem, offset, size);
34}
35#else
36#define __ioremap_trapped(offset, size) NULL
37#endif
38
39#ifdef CONFIG_HAS_IOPORT
40extern struct list_head trapped_io;
41
42static inline void __iomem *
43__ioport_map_trapped(unsigned long offset, unsigned long size)
44{
45 return match_trapped_io_handler(&trapped_io, offset, size);
46}
47#else
48#define __ioport_map_trapped(offset, size) NULL
49#endif
50
51#else
52#define register_trapped_io(tiop) (-1)
53#define handle_trapped_io(tiop, address) 0
54#define __ioremap_trapped(offset, size) NULL
55#define __ioport_map_trapped(offset, size) NULL
56#endif
57
58#endif /* __ASM_SH_IO_TRAPPED_H */
diff --git a/include/asm-sh/ioctls.h b/include/asm-sh/ioctls.h
index 35805df010a0..c212c371a4a5 100644
--- a/include/asm-sh/ioctls.h
+++ b/include/asm-sh/ioctls.h
@@ -78,6 +78,10 @@
78#define TIOCSBRK _IO('T', 39) /* 0x5427 */ /* BSD compatibility */ 78#define TIOCSBRK _IO('T', 39) /* 0x5427 */ /* BSD compatibility */
79#define TIOCCBRK _IO('T', 40) /* 0x5428 */ /* BSD compatibility */ 79#define TIOCCBRK _IO('T', 40) /* 0x5428 */ /* BSD compatibility */
80#define TIOCGSID _IOR('T', 41, pid_t) /* 0x5429 */ /* Return the session ID of FD */ 80#define TIOCGSID _IOR('T', 41, pid_t) /* 0x5429 */ /* Return the session ID of FD */
81#define TCGETS2 _IOR('T', 42, struct termios2)
82#define TCSETS2 _IOW('T', 43, struct termios2)
83#define TCSETSW2 _IOW('T', 44, struct termios2)
84#define TCSETSF2 _IOW('T', 45, struct termios2)
81#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 85#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
82#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 86#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
83 87
diff --git a/include/asm-sh/irq.h b/include/asm-sh/irq.h
index 11850f65c922..ca66e5df69dc 100644
--- a/include/asm-sh/irq.h
+++ b/include/asm-sh/irq.h
@@ -50,4 +50,8 @@ extern void irq_ctx_exit(int cpu);
50# define irq_ctx_exit(cpu) do { } while (0) 50# define irq_ctx_exit(cpu) do { } while (0)
51#endif 51#endif
52 52
53#ifdef CONFIG_CPU_SH5
54#include <asm/cpu/irq.h>
55#endif
56
53#endif /* __ASM_SH_IRQ_H */ 57#endif /* __ASM_SH_IRQ_H */
diff --git a/include/asm-sh/mmu_context_64.h b/include/asm-sh/mmu_context_64.h
index 020be744b088..9649f1c07caf 100644
--- a/include/asm-sh/mmu_context_64.h
+++ b/include/asm-sh/mmu_context_64.h
@@ -66,6 +66,9 @@ static inline void set_asid(unsigned long asid)
66 : "=r" (sr), "=r" (pc) : "0" (sr)); 66 : "=r" (sr), "=r" (pc) : "0" (sr));
67} 67}
68 68
69/* arch/sh/kernel/cpu/sh5/entry.S */
70extern unsigned long switch_and_save_asid(unsigned long new_asid);
71
69/* No spare register to twiddle, so use a software cache */ 72/* No spare register to twiddle, so use a software cache */
70extern pgd_t *mmu_pdtp_cache; 73extern pgd_t *mmu_pdtp_cache;
71 74
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h
index 134562dc8c45..304c30b5d947 100644
--- a/include/asm-sh/page.h
+++ b/include/asm-sh/page.h
@@ -55,11 +55,14 @@ extern void clear_page(void *to);
55extern void copy_page(void *to, void *from); 55extern void copy_page(void *to, void *from);
56 56
57#if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_MMU) && \ 57#if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_MMU) && \
58 (defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)) 58 (defined(CONFIG_CPU_SH5) || defined(CONFIG_CPU_SH4) || \
59 defined(CONFIG_SH7705_CACHE_32KB))
59struct page; 60struct page;
60struct vm_area_struct; 61struct vm_area_struct;
61extern void clear_user_page(void *to, unsigned long address, struct page *page); 62extern void clear_user_page(void *to, unsigned long address, struct page *page);
62#ifdef CONFIG_CPU_SH4 63extern void copy_user_page(void *to, void *from, unsigned long address,
64 struct page *page);
65#if defined(CONFIG_CPU_SH4)
63extern void copy_user_highpage(struct page *to, struct page *from, 66extern void copy_user_highpage(struct page *to, struct page *from,
64 unsigned long vaddr, struct vm_area_struct *vma); 67 unsigned long vaddr, struct vm_area_struct *vma);
65#define __HAVE_ARCH_COPY_USER_HIGHPAGE 68#define __HAVE_ARCH_COPY_USER_HIGHPAGE
diff --git a/include/asm-sh/pgtable_64.h b/include/asm-sh/pgtable_64.h
index 972211671c9a..f9dd9d311441 100644
--- a/include/asm-sh/pgtable_64.h
+++ b/include/asm-sh/pgtable_64.h
@@ -138,6 +138,14 @@ static __inline__ void pmd_set(pmd_t *pmdp,pte_t *ptep)
138#endif 138#endif
139 139
140/* 140/*
141 * Stub out _PAGE_SZHUGE if we don't have a good definition for it,
142 * to make pte_mkhuge() happy.
143 */
144#ifndef _PAGE_SZHUGE
145# define _PAGE_SZHUGE (0)
146#endif
147
148/*
141 * Default flags for a Kernel page. 149 * Default flags for a Kernel page.
142 * This is fundametally also SHARED because the main use of this define 150 * This is fundametally also SHARED because the main use of this define
143 * (other than for PGD/PMD entries) is for the VMALLOC pool which is 151 * (other than for PGD/PMD entries) is for the VMALLOC pool which is
@@ -179,6 +187,11 @@ static __inline__ void pmd_set(pmd_t *pmdp,pte_t *ptep)
179 _PAGE_WRITE | _PAGE_EXECUTE) 187 _PAGE_WRITE | _PAGE_EXECUTE)
180#define PAGE_KERNEL __pgprot(_KERNPG_TABLE) 188#define PAGE_KERNEL __pgprot(_KERNPG_TABLE)
181 189
190#define PAGE_KERNEL_NOCACHE \
191 __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \
192 _PAGE_EXECUTE | _PAGE_ACCESSED | \
193 _PAGE_DIRTY | _PAGE_SHARED)
194
182/* Make it a device mapping for maximum safety (e.g. for mapping device 195/* Make it a device mapping for maximum safety (e.g. for mapping device
183 registers into user-space via /dev/map). */ 196 registers into user-space via /dev/map). */
184#define pgprot_noncached(x) __pgprot(((x).pgprot & ~(_PAGE_CACHABLE)) | _PAGE_DEVICE) 197#define pgprot_noncached(x) __pgprot(((x).pgprot & ~(_PAGE_CACHABLE)) | _PAGE_DEVICE)
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index c9b14161f73d..19fe47c1ca17 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -33,7 +33,7 @@ enum cpu_type {
33 CPU_SH7763, CPU_SH7770, CPU_SH7780, CPU_SH7781, CPU_SH7785, CPU_SHX3, 33 CPU_SH7763, CPU_SH7770, CPU_SH7780, CPU_SH7781, CPU_SH7785, CPU_SHX3,
34 34
35 /* SH4AL-DSP types */ 35 /* SH4AL-DSP types */
36 CPU_SH7343, CPU_SH7722, 36 CPU_SH7343, CPU_SH7722, CPU_SH7366,
37 37
38 /* SH-5 types */ 38 /* SH-5 types */
39 CPU_SH5_101, CPU_SH5_103, 39 CPU_SH5_101, CPU_SH5_103,
diff --git a/include/asm-sh/r7780rp.h b/include/asm-sh/r7780rp.h
index bdecea0840a0..1770460a4616 100644
--- a/include/asm-sh/r7780rp.h
+++ b/include/asm-sh/r7780rp.h
@@ -195,7 +195,4 @@ unsigned char *highlander_init_irq_r7780mp(void);
195unsigned char *highlander_init_irq_r7780rp(void); 195unsigned char *highlander_init_irq_r7780rp(void);
196unsigned char *highlander_init_irq_r7785rp(void); 196unsigned char *highlander_init_irq_r7785rp(void);
197 197
198#define __IO_PREFIX r7780rp
199#include <asm/io_generic.h>
200
201#endif /* __ASM_SH_RENESAS_R7780RP */ 198#endif /* __ASM_SH_RENESAS_R7780RP */
diff --git a/include/asm-sh/rts7751r2d.h b/include/asm-sh/rts7751r2d.h
index 83b9c111f171..0a800157b826 100644
--- a/include/asm-sh/rts7751r2d.h
+++ b/include/asm-sh/rts7751r2d.h
@@ -67,7 +67,4 @@
67void init_rts7751r2d_IRQ(void); 67void init_rts7751r2d_IRQ(void);
68int rts7751r2d_irq_demux(int); 68int rts7751r2d_irq_demux(int);
69 69
70#define __IO_PREFIX rts7751r2d
71#include <asm/io_generic.h>
72
73#endif /* __ASM_SH_RENESAS_RTS7751R2D */ 70#endif /* __ASM_SH_RENESAS_RTS7751R2D */
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h
index 772cd1a0a674..5145aa2a0ce9 100644
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -182,6 +182,11 @@ BUILD_TRAP_HANDLER(fpu_state_restore);
182 182
183#define arch_align_stack(x) (x) 183#define arch_align_stack(x) (x)
184 184
185struct mem_access {
186 unsigned long (*from)(void *dst, const void *src, unsigned long cnt);
187 unsigned long (*to)(void *dst, const void *src, unsigned long cnt);
188};
189
185#ifdef CONFIG_SUPERH32 190#ifdef CONFIG_SUPERH32
186# include "system_32.h" 191# include "system_32.h"
187#else 192#else
diff --git a/include/asm-sh/system_32.h b/include/asm-sh/system_32.h
index 7ff08d956ba8..f11bcf0855ed 100644
--- a/include/asm-sh/system_32.h
+++ b/include/asm-sh/system_32.h
@@ -96,4 +96,7 @@ do { \
96 : "=&r" (__dummy)); \ 96 : "=&r" (__dummy)); \
97} while (0) 97} while (0)
98 98
99int handle_unaligned_access(opcode_t instruction, struct pt_regs *regs,
100 struct mem_access *ma);
101
99#endif /* __ASM_SH_SYSTEM_32_H */ 102#endif /* __ASM_SH_SYSTEM_32_H */
diff --git a/include/asm-sh/termbits.h b/include/asm-sh/termbits.h
index 7ee1b42eeab0..77db116948cf 100644
--- a/include/asm-sh/termbits.h
+++ b/include/asm-sh/termbits.h
@@ -140,6 +140,7 @@ struct ktermios {
140#define HUPCL 0002000 140#define HUPCL 0002000
141#define CLOCAL 0004000 141#define CLOCAL 0004000
142#define CBAUDEX 0010000 142#define CBAUDEX 0010000
143#define BOTHER 0010000
143#define B57600 0010001 144#define B57600 0010001
144#define B115200 0010002 145#define B115200 0010002
145#define B230400 0010003 146#define B230400 0010003
@@ -155,10 +156,12 @@ struct ktermios {
155#define B3000000 0010015 156#define B3000000 0010015
156#define B3500000 0010016 157#define B3500000 0010016
157#define B4000000 0010017 158#define B4000000 0010017
158#define CIBAUD 002003600000 /* input baud rate (not used) */ 159#define CIBAUD 002003600000 /* input baud rate */
159#define CMSPAR 010000000000 /* mark or space (stick) parity */ 160#define CMSPAR 010000000000 /* mark or space (stick) parity */
160#define CRTSCTS 020000000000 /* flow control */ 161#define CRTSCTS 020000000000 /* flow control */
161 162
163#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
164
162/* c_lflag bits */ 165/* c_lflag bits */
163#define ISIG 0000001 166#define ISIG 0000001
164#define ICANON 0000002 167#define ICANON 0000002
diff --git a/include/asm-sh/termios.h b/include/asm-sh/termios.h
index e7c8f86ef890..0a8c793c76f2 100644
--- a/include/asm-sh/termios.h
+++ b/include/asm-sh/termios.h
@@ -80,8 +80,10 @@ struct termio {
80 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ 80 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
81}) 81})
82 82
83#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios)) 83#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2))
84#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios)) 84#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2))
85#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
86#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
85 87
86#endif /* __KERNEL__ */ 88#endif /* __KERNEL__ */
87 89
diff --git a/include/asm-sh/tlb.h b/include/asm-sh/tlb.h
index 56ad1fb888a2..88ff1ae8a6b8 100644
--- a/include/asm-sh/tlb.h
+++ b/include/asm-sh/tlb.h
@@ -20,6 +20,7 @@
20 */ 20 */
21#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) 21#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
22 22
23#include <linux/pagemap.h>
23#include <asm-generic/tlb.h> 24#include <asm-generic/tlb.h>
24 25
25#endif /* __ASSEMBLY__ */ 26#endif /* __ASSEMBLY__ */
diff --git a/include/asm-sh/uaccess.h b/include/asm-sh/uaccess.h
index ff24ce95b238..b3440c305b5d 100644
--- a/include/asm-sh/uaccess.h
+++ b/include/asm-sh/uaccess.h
@@ -1,5 +1,34 @@
1#ifndef __ASM_SH_UACCESS_H
2#define __ASM_SH_UACCESS_H
3
1#ifdef CONFIG_SUPERH32 4#ifdef CONFIG_SUPERH32
2# include "uaccess_32.h" 5# include "uaccess_32.h"
3#else 6#else
4# include "uaccess_64.h" 7# include "uaccess_64.h"
5#endif 8#endif
9
10static inline unsigned long
11copy_from_user(void *to, const void __user *from, unsigned long n)
12{
13 unsigned long __copy_from = (unsigned long) from;
14 __kernel_size_t __copy_size = (__kernel_size_t) n;
15
16 if (__copy_size && __access_ok(__copy_from, __copy_size))
17 return __copy_user(to, from, __copy_size);
18
19 return __copy_size;
20}
21
22static inline unsigned long
23copy_to_user(void __user *to, const void *from, unsigned long n)
24{
25 unsigned long __copy_to = (unsigned long) to;
26 __kernel_size_t __copy_size = (__kernel_size_t) n;
27
28 if (__copy_size && __access_ok(__copy_to, __copy_size))
29 return __copy_user(to, from, __copy_size);
30
31 return __copy_size;
32}
33
34#endif /* __ASM_SH_UACCESS_H */
diff --git a/include/asm-sh/uaccess_32.h b/include/asm-sh/uaccess_32.h
index b6082f3c1dc4..c0318b608893 100644
--- a/include/asm-sh/uaccess_32.h
+++ b/include/asm-sh/uaccess_32.h
@@ -10,8 +10,8 @@
10 * Copyright (C) 1996, 1997, 1998 by Ralf Baechle 10 * Copyright (C) 1996, 1997, 1998 by Ralf Baechle
11 * and i386 version. 11 * and i386 version.
12 */ 12 */
13#ifndef __ASM_SH_UACCESS_H 13#ifndef __ASM_SH_UACCESS_32_H
14#define __ASM_SH_UACCESS_H 14#define __ASM_SH_UACCESS_32_H
15 15
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/sched.h> 17#include <linux/sched.h>
@@ -302,24 +302,6 @@ extern void __put_user_unknown(void);
302/* Return the number of bytes NOT copied */ 302/* Return the number of bytes NOT copied */
303__kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n); 303__kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
304 304
305#define copy_to_user(to,from,n) ({ \
306void *__copy_to = (void *) (to); \
307__kernel_size_t __copy_size = (__kernel_size_t) (n); \
308__kernel_size_t __copy_res; \
309if(__copy_size && __access_ok((unsigned long)__copy_to, __copy_size)) { \
310__copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \
311} else __copy_res = __copy_size; \
312__copy_res; })
313
314#define copy_from_user(to,from,n) ({ \
315void *__copy_to = (void *) (to); \
316void *__copy_from = (void *) (from); \
317__kernel_size_t __copy_size = (__kernel_size_t) (n); \
318__kernel_size_t __copy_res; \
319if(__copy_size && __access_ok((unsigned long)__copy_from, __copy_size)) { \
320__copy_res = __copy_user(__copy_to, __copy_from, __copy_size); \
321} else __copy_res = __copy_size; \
322__copy_res; })
323 305
324static __always_inline unsigned long 306static __always_inline unsigned long
325__copy_from_user(void *to, const void __user *from, unsigned long n) 307__copy_from_user(void *to, const void __user *from, unsigned long n)
@@ -507,4 +489,4 @@ struct exception_table_entry
507 489
508extern int fixup_exception(struct pt_regs *regs); 490extern int fixup_exception(struct pt_regs *regs);
509 491
510#endif /* __ASM_SH_UACCESS_H */ 492#endif /* __ASM_SH_UACCESS_32_H */
diff --git a/include/asm-sh/uaccess_64.h b/include/asm-sh/uaccess_64.h
index d54ec082d25a..f956b7b316c7 100644
--- a/include/asm-sh/uaccess_64.h
+++ b/include/asm-sh/uaccess_64.h
@@ -202,15 +202,6 @@ extern void __put_user_unknown(void);
202/* XXX: should be such that: 4byte and the rest. */ 202/* XXX: should be such that: 4byte and the rest. */
203extern __kernel_size_t __copy_user(void *__to, const void *__from, __kernel_size_t __n); 203extern __kernel_size_t __copy_user(void *__to, const void *__from, __kernel_size_t __n);
204 204
205#define copy_to_user(to,from,n) ({ \
206void *__copy_to = (void *) (to); \
207__kernel_size_t __copy_size = (__kernel_size_t) (n); \
208__kernel_size_t __copy_res; \
209if(__copy_size && __access_ok((unsigned long)__copy_to, __copy_size)) { \
210__copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \
211} else __copy_res = __copy_size; \
212__copy_res; })
213
214#define copy_to_user_ret(to,from,n,retval) ({ \ 205#define copy_to_user_ret(to,from,n,retval) ({ \
215if (copy_to_user(to,from,n)) \ 206if (copy_to_user(to,from,n)) \
216 return retval; \ 207 return retval; \
@@ -225,16 +216,6 @@ if (__copy_to_user(to,from,n)) \
225 return retval; \ 216 return retval; \
226}) 217})
227 218
228#define copy_from_user(to,from,n) ({ \
229void *__copy_to = (void *) (to); \
230void *__copy_from = (void *) (from); \
231__kernel_size_t __copy_size = (__kernel_size_t) (n); \
232__kernel_size_t __copy_res; \
233if(__copy_size && __access_ok((unsigned long)__copy_from, __copy_size)) { \
234__copy_res = __copy_user(__copy_to, __copy_from, __copy_size); \
235} else __copy_res = __copy_size; \
236__copy_res; })
237
238#define copy_from_user_ret(to,from,n,retval) ({ \ 219#define copy_from_user_ret(to,from,n,retval) ({ \
239if (copy_from_user(to,from,n)) \ 220if (copy_from_user(to,from,n)) \
240 return retval; \ 221 return retval; \
diff --git a/include/asm-sh/unistd_32.h b/include/asm-sh/unistd_32.h
index 433fd1b48fa2..0b07212ec659 100644
--- a/include/asm-sh/unistd_32.h
+++ b/include/asm-sh/unistd_32.h
@@ -330,11 +330,13 @@
330#define __NR_epoll_pwait 319 330#define __NR_epoll_pwait 319
331#define __NR_utimensat 320 331#define __NR_utimensat 320
332#define __NR_signalfd 321 332#define __NR_signalfd 321
333/* #define __NR_timerfd 322 removed */ 333#define __NR_timerfd_create 322
334#define __NR_eventfd 323 334#define __NR_eventfd 323
335#define __NR_fallocate 324 335#define __NR_fallocate 324
336#define __NR_timerfd_settime 325
337#define __NR_timerfd_gettime 326
336 338
337#define NR_syscalls 325 339#define NR_syscalls 327
338 340
339#ifdef __KERNEL__ 341#ifdef __KERNEL__
340 342
diff --git a/include/asm-sh/unistd_64.h b/include/asm-sh/unistd_64.h
index 108d2ba897fe..9d21eab52427 100644
--- a/include/asm-sh/unistd_64.h
+++ b/include/asm-sh/unistd_64.h
@@ -90,7 +90,7 @@
90#define __NR_sigpending 73 90#define __NR_sigpending 73
91#define __NR_sethostname 74 91#define __NR_sethostname 74
92#define __NR_setrlimit 75 92#define __NR_setrlimit 75
93#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ 93#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
94#define __NR_getrusage 77 94#define __NR_getrusage 77
95#define __NR_gettimeofday 78 95#define __NR_gettimeofday 78
96#define __NR_settimeofday 79 96#define __NR_settimeofday 79
@@ -370,9 +370,11 @@
370#define __NR_epoll_pwait 347 370#define __NR_epoll_pwait 347
371#define __NR_utimensat 348 371#define __NR_utimensat 348
372#define __NR_signalfd 349 372#define __NR_signalfd 349
373/* #define __NR_timerfd 350 removed */ 373#define __NR_timerfd_create 350
374#define __NR_eventfd 351 374#define __NR_eventfd 351
375#define __NR_fallocate 352 375#define __NR_fallocate 352
376#define __NR_timerfd_settime 353
377#define __NR_timerfd_gettime 354
376 378
377#ifdef __KERNEL__ 379#ifdef __KERNEL__
378 380
diff --git a/include/asm-x86/cacheflush.h b/include/asm-x86/cacheflush.h
index 6a22212b4b20..5396c212d8c0 100644
--- a/include/asm-x86/cacheflush.h
+++ b/include/asm-x86/cacheflush.h
@@ -48,12 +48,15 @@ void cpa_init(void);
48 48
49#ifdef CONFIG_DEBUG_RODATA 49#ifdef CONFIG_DEBUG_RODATA
50void mark_rodata_ro(void); 50void mark_rodata_ro(void);
51extern const int rodata_test_data;
51#endif 52#endif
53
52#ifdef CONFIG_DEBUG_RODATA_TEST 54#ifdef CONFIG_DEBUG_RODATA_TEST
53void rodata_test(void); 55int rodata_test(void);
54#else 56#else
55static inline void rodata_test(void) 57static inline int rodata_test(void)
56{ 58{
59 return 0;
57} 60}
58#endif 61#endif
59 62
diff --git a/include/asm-x86/kdebug.h b/include/asm-x86/kdebug.h
index dd442a1632c0..99dcbafa1511 100644
--- a/include/asm-x86/kdebug.h
+++ b/include/asm-x86/kdebug.h
@@ -31,7 +31,6 @@ extern void show_trace(struct task_struct *t, struct pt_regs *regs,
31 unsigned long *sp, unsigned long bp); 31 unsigned long *sp, unsigned long bp);
32extern void __show_regs(struct pt_regs *regs); 32extern void __show_regs(struct pt_regs *regs);
33extern void show_regs(struct pt_regs *regs); 33extern void show_regs(struct pt_regs *regs);
34extern void dump_pagetable(unsigned long);
35extern unsigned long oops_begin(void); 34extern unsigned long oops_begin(void);
36extern void oops_end(unsigned long, struct pt_regs *, int signr); 35extern void oops_end(unsigned long, struct pt_regs *, int signr);
37 36
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index ddbe7efe590e..2c7e003356ac 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -203,6 +203,7 @@ extern bool wmi_has_guid(const char *guid);
203extern int acpi_blacklisted(void); 203extern int acpi_blacklisted(void);
204#ifdef CONFIG_DMI 204#ifdef CONFIG_DMI
205extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d); 205extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d);
206extern int acpi_osi_setup(char *str);
206#endif 207#endif
207 208
208#ifdef CONFIG_ACPI_NUMA 209#ifdef CONFIG_ACPI_NUMA
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 97153027207a..2af9ec025015 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -534,8 +534,7 @@ extern void audit_log_n_untrustedstring(struct audit_buffer *ab,
534 const char *string); 534 const char *string);
535extern void audit_log_d_path(struct audit_buffer *ab, 535extern void audit_log_d_path(struct audit_buffer *ab,
536 const char *prefix, 536 const char *prefix,
537 struct dentry *dentry, 537 struct path *path);
538 struct vfsmount *vfsmnt);
539extern void audit_log_lost(const char *message); 538extern void audit_log_lost(const char *message);
540 /* Private API (for audit.c only) */ 539 /* Private API (for audit.c only) */
541extern int audit_filter_user(struct netlink_skb_parms *cb, int type); 540extern int audit_filter_user(struct netlink_skb_parms *cb, int type);
@@ -552,7 +551,7 @@ extern int audit_enabled;
552#define audit_log_hex(a,b,l) do { ; } while (0) 551#define audit_log_hex(a,b,l) do { ; } while (0)
553#define audit_log_untrustedstring(a,s) do { ; } while (0) 552#define audit_log_untrustedstring(a,s) do { ; } while (0)
554#define audit_log_n_untrustedstring(a,n,s) do { ; } while (0) 553#define audit_log_n_untrustedstring(a,n,s) do { ; } while (0)
555#define audit_log_d_path(b,p,d,v) do { ; } while (0) 554#define audit_log_d_path(b, p, d) do { ; } while (0)
556#define audit_enabled 0 555#define audit_enabled 0
557#endif 556#endif
558#endif 557#endif
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 8c6967f3fb11..4b287ad9371a 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -37,6 +37,7 @@
37 37
38#ifdef __KERNEL__ 38#ifdef __KERNEL__
39 39
40#include <linux/kernel.h>
40#include <linux/types.h> 41#include <linux/types.h>
41#include <linux/list.h> 42#include <linux/list.h>
42#include <linux/kref.h> 43#include <linux/kref.h>
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 385d45b616db..6b72a4584086 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -19,6 +19,7 @@
19 19
20#define CPUIDLE_STATE_MAX 8 20#define CPUIDLE_STATE_MAX 8
21#define CPUIDLE_NAME_LEN 16 21#define CPUIDLE_NAME_LEN 16
22#define CPUIDLE_DESC_LEN 32
22 23
23struct cpuidle_device; 24struct cpuidle_device;
24 25
@@ -29,6 +30,7 @@ struct cpuidle_device;
29 30
30struct cpuidle_state { 31struct cpuidle_state {
31 char name[CPUIDLE_NAME_LEN]; 32 char name[CPUIDLE_NAME_LEN];
33 char desc[CPUIDLE_DESC_LEN];
32 void *driver_data; 34 void *driver_data;
33 35
34 unsigned int flags; 36 unsigned int flags;
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index c2c153f97e8f..6bd646096fa6 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -10,6 +10,7 @@
10#include <linux/rcupdate.h> 10#include <linux/rcupdate.h>
11 11
12struct nameidata; 12struct nameidata;
13struct path;
13struct vfsmount; 14struct vfsmount;
14 15
15/* 16/*
@@ -300,8 +301,8 @@ extern int d_validate(struct dentry *, struct dentry *);
300 */ 301 */
301extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); 302extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
302 303
303extern char * d_path(struct dentry *, struct vfsmount *, char *, int); 304extern char *d_path(struct path *, char *, int);
304 305
305/* Allocation counts.. */ 306/* Allocation counts.. */
306 307
307/** 308/**
diff --git a/include/linux/dcookies.h b/include/linux/dcookies.h
index 98c69ab80c84..24c806f12a6c 100644
--- a/include/linux/dcookies.h
+++ b/include/linux/dcookies.h
@@ -13,6 +13,7 @@
13#ifdef CONFIG_PROFILING 13#ifdef CONFIG_PROFILING
14 14
15#include <linux/dcache.h> 15#include <linux/dcache.h>
16#include <linux/path.h>
16#include <linux/types.h> 17#include <linux/types.h>
17 18
18struct dcookie_user; 19struct dcookie_user;
@@ -43,8 +44,7 @@ void dcookie_unregister(struct dcookie_user * user);
43 * 44 *
44 * Returns 0 on success, with *cookie filled in 45 * Returns 0 on success, with *cookie filled in
45 */ 46 */
46int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt, 47int get_dcookie(struct path *path, unsigned long *cookie);
47 unsigned long * cookie);
48 48
49#else 49#else
50 50
@@ -57,13 +57,12 @@ static inline void dcookie_unregister(struct dcookie_user * user)
57{ 57{
58 return; 58 return;
59} 59}
60 60
61static inline int get_dcookie(struct dentry * dentry, 61static inline int get_dcookie(struct path *path, unsigned long *cookie)
62 struct vfsmount * vfsmnt, unsigned long * cookie)
63{ 62{
64 return -ENOSYS; 63 return -ENOSYS;
65} 64}
66 65
67#endif /* CONFIG_PROFILING */ 66#endif /* CONFIG_PROFILING */
68 67
69#endif /* DCOOKIES_H */ 68#endif /* DCOOKIES_H */
diff --git a/include/linux/dm9000.h b/include/linux/dm9000.h
index 0008e2ad0c9f..a3750462f9e3 100644
--- a/include/linux/dm9000.h
+++ b/include/linux/dm9000.h
@@ -19,6 +19,8 @@
19#define DM9000_PLATF_8BITONLY (0x0001) 19#define DM9000_PLATF_8BITONLY (0x0001)
20#define DM9000_PLATF_16BITONLY (0x0002) 20#define DM9000_PLATF_16BITONLY (0x0002)
21#define DM9000_PLATF_32BITONLY (0x0004) 21#define DM9000_PLATF_32BITONLY (0x0004)
22#define DM9000_PLATF_EXT_PHY (0x0008)
23#define DM9000_PLATF_NO_EEPROM (0x0010)
22 24
23/* platfrom data for platfrom device structure's platfrom_data field */ 25/* platfrom data for platfrom device structure's platfrom_data field */
24 26
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 18cfbf76ec5b..98ffb6ead434 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1284,8 +1284,10 @@ struct super_operations {
1284 * 1284 *
1285 * I_DIRTY_SYNC Inode is dirty, but doesn't have to be written on 1285 * I_DIRTY_SYNC Inode is dirty, but doesn't have to be written on
1286 * fdatasync(). i_atime is the usual cause. 1286 * fdatasync(). i_atime is the usual cause.
1287 * I_DIRTY_DATASYNC Inode is dirty and must be written on fdatasync(), f.e. 1287 * I_DIRTY_DATASYNC Data-related inode changes pending. We keep track of
1288 * because i_size changed. 1288 * these changes separately from I_DIRTY_SYNC so that we
1289 * don't have to write inode on fdatasync() when only
1290 * mtime has changed in it.
1289 * I_DIRTY_PAGES Inode has dirty pages. Inode itself may be clean. 1291 * I_DIRTY_PAGES Inode has dirty pages. Inode itself may be clean.
1290 * I_NEW get_new_inode() sets i_state to I_LOCK|I_NEW. Both 1292 * I_NEW get_new_inode() sets i_state to I_LOCK|I_NEW. Both
1291 * are cleared by unlock_new_inode(), called from iget(). 1293 * are cleared by unlock_new_inode(), called from iget().
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
index 11a36ceddf73..282f54219129 100644
--- a/include/linux/fs_struct.h
+++ b/include/linux/fs_struct.h
@@ -1,15 +1,13 @@
1#ifndef _LINUX_FS_STRUCT_H 1#ifndef _LINUX_FS_STRUCT_H
2#define _LINUX_FS_STRUCT_H 2#define _LINUX_FS_STRUCT_H
3 3
4struct dentry; 4#include <linux/path.h>
5struct vfsmount;
6 5
7struct fs_struct { 6struct fs_struct {
8 atomic_t count; 7 atomic_t count;
9 rwlock_t lock; 8 rwlock_t lock;
10 int umask; 9 int umask;
11 struct dentry * root, * pwd, * altroot; 10 struct path root, pwd, altroot;
12 struct vfsmount * rootmnt, * pwdmnt, * altrootmnt;
13}; 11};
14 12
15#define INIT_FS { \ 13#define INIT_FS { \
@@ -22,8 +20,8 @@ extern struct kmem_cache *fs_cachep;
22 20
23extern void exit_fs(struct task_struct *); 21extern void exit_fs(struct task_struct *);
24extern void set_fs_altroot(void); 22extern void set_fs_altroot(void);
25extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *); 23extern void set_fs_root(struct fs_struct *, struct path *);
26extern void set_fs_pwd(struct fs_struct *, struct vfsmount *, struct dentry *); 24extern void set_fs_pwd(struct fs_struct *, struct path *);
27extern struct fs_struct *copy_fs_struct(struct fs_struct *); 25extern struct fs_struct *copy_fs_struct(struct fs_struct *);
28extern void put_fs_struct(struct fs_struct *); 26extern void put_fs_struct(struct fs_struct *);
29 27
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 3902690647b0..74ff57596eb1 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -528,7 +528,7 @@ int hid_set_field(struct hid_field *, unsigned, __s32);
528int hid_input_report(struct hid_device *, int type, u8 *, int, int); 528int hid_input_report(struct hid_device *, int type, u8 *, int, int);
529int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); 529int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field);
530int hidinput_mapping_quirks(struct hid_usage *, struct input_dev *, unsigned long **, int *); 530int hidinput_mapping_quirks(struct hid_usage *, struct input_dev *, unsigned long **, int *);
531void hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32); 531int hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
532int hidinput_apple_event(struct hid_device *, struct input_dev *, struct hid_usage *, __s32); 532int hidinput_apple_event(struct hid_device *, struct input_dev *, struct hid_usage *, __s32);
533void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt); 533void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt);
534void hid_output_report(struct hid_report *report, __u8 *data); 534void hid_output_report(struct hid_report *report, __u8 *data);
diff --git a/include/linux/ktime.h b/include/linux/ktime.h
index 36c542b70c6d..2cd7fa73d1af 100644
--- a/include/linux/ktime.h
+++ b/include/linux/ktime.h
@@ -310,6 +310,8 @@ static inline ktime_t ktime_sub_us(const ktime_t kt, const u64 usec)
310 return ktime_sub_ns(kt, usec * 1000); 310 return ktime_sub_ns(kt, usec * 1000);
311} 311}
312 312
313extern ktime_t ktime_add_safe(const ktime_t lhs, const ktime_t rhs);
314
313/* 315/*
314 * The resolution of the clocks. The resolution value is returned in 316 * The resolution of the clocks. The resolution value is returned in
315 * the clock_getres() system call to give application programmers an 317 * the clock_getres() system call to give application programmers an
diff --git a/include/linux/maple.h b/include/linux/maple.h
index bad9a7b319de..3f01e2bae1a1 100644
--- a/include/linux/maple.h
+++ b/include/linux/maple.h
@@ -7,74 +7,74 @@ extern struct bus_type maple_bus_type;
7 7
8/* Maple Bus command and response codes */ 8/* Maple Bus command and response codes */
9enum maple_code { 9enum maple_code {
10 MAPLE_RESPONSE_FILEERR = -5, 10 MAPLE_RESPONSE_FILEERR = -5,
11 MAPLE_RESPONSE_AGAIN = -4, /* request should be retransmitted */ 11 MAPLE_RESPONSE_AGAIN = -4, /* request should be retransmitted */
12 MAPLE_RESPONSE_BADCMD = -3, 12 MAPLE_RESPONSE_BADCMD = -3,
13 MAPLE_RESPONSE_BADFUNC = -2, 13 MAPLE_RESPONSE_BADFUNC = -2,
14 MAPLE_RESPONSE_NONE = -1, /* unit didn't respond at all */ 14 MAPLE_RESPONSE_NONE = -1, /* unit didn't respond at all */
15 MAPLE_COMMAND_DEVINFO = 1, 15 MAPLE_COMMAND_DEVINFO = 1,
16 MAPLE_COMMAND_ALLINFO = 2, 16 MAPLE_COMMAND_ALLINFO = 2,
17 MAPLE_COMMAND_RESET = 3, 17 MAPLE_COMMAND_RESET = 3,
18 MAPLE_COMMAND_KILL = 4, 18 MAPLE_COMMAND_KILL = 4,
19 MAPLE_RESPONSE_DEVINFO = 5, 19 MAPLE_RESPONSE_DEVINFO = 5,
20 MAPLE_RESPONSE_ALLINFO = 6, 20 MAPLE_RESPONSE_ALLINFO = 6,
21 MAPLE_RESPONSE_OK = 7, 21 MAPLE_RESPONSE_OK = 7,
22 MAPLE_RESPONSE_DATATRF = 8, 22 MAPLE_RESPONSE_DATATRF = 8,
23 MAPLE_COMMAND_GETCOND = 9, 23 MAPLE_COMMAND_GETCOND = 9,
24 MAPLE_COMMAND_GETMINFO = 10, 24 MAPLE_COMMAND_GETMINFO = 10,
25 MAPLE_COMMAND_BREAD = 11, 25 MAPLE_COMMAND_BREAD = 11,
26 MAPLE_COMMAND_BWRITE = 12, 26 MAPLE_COMMAND_BWRITE = 12,
27 MAPLE_COMMAND_SETCOND = 14 27 MAPLE_COMMAND_SETCOND = 14
28}; 28};
29 29
30struct mapleq { 30struct mapleq {
31 struct list_head list; 31 struct list_head list;
32 struct maple_device *dev; 32 struct maple_device *dev;
33 void *sendbuf, *recvbuf, *recvbufdcsp; 33 void *sendbuf, *recvbuf, *recvbufdcsp;
34 unsigned char length; 34 unsigned char length;
35 enum maple_code command; 35 enum maple_code command;
36}; 36};
37 37
38struct maple_devinfo { 38struct maple_devinfo {
39 unsigned long function; 39 unsigned long function;
40 unsigned long function_data[3]; 40 unsigned long function_data[3];
41 unsigned char area_code; 41 unsigned char area_code;
42 unsigned char connector_directon; 42 unsigned char connector_direction;
43 char product_name[31]; 43 char product_name[31];
44 char product_licence[61]; 44 char product_licence[61];
45 unsigned short standby_power; 45 unsigned short standby_power;
46 unsigned short max_power; 46 unsigned short max_power;
47}; 47};
48 48
49struct maple_device { 49struct maple_device {
50 struct maple_driver *driver; 50 struct maple_driver *driver;
51 struct mapleq *mq; 51 struct mapleq *mq;
52 void *private_data; 52 void *private_data;
53 void (*callback) (struct mapleq * mq); 53 void (*callback) (struct mapleq * mq);
54 unsigned long when, interval, function; 54 unsigned long when, interval, function;
55 struct maple_devinfo devinfo; 55 struct maple_devinfo devinfo;
56 unsigned char port, unit; 56 unsigned char port, unit;
57 char product_name[32]; 57 char product_name[32];
58 char product_licence[64]; 58 char product_licence[64];
59 int registered; 59 struct device dev;
60 struct device dev;
61}; 60};
62 61
63struct maple_driver { 62struct maple_driver {
64 unsigned long function; 63 unsigned long function;
65 int (*connect) (struct maple_device * dev); 64 int (*connect) (struct maple_device * dev);
66 void (*disconnect) (struct maple_device * dev); 65 void (*disconnect) (struct maple_device * dev);
67 struct device_driver drv; 66 struct device_driver drv;
67 int registered;
68}; 68};
69 69
70void maple_getcond_callback(struct maple_device *dev, 70void maple_getcond_callback(struct maple_device *dev,
71 void (*callback) (struct mapleq * mq), 71 void (*callback) (struct mapleq * mq),
72 unsigned long interval, 72 unsigned long interval,
73 unsigned long function); 73 unsigned long function);
74int maple_driver_register(struct device_driver *drv); 74int maple_driver_register(struct device_driver *drv);
75void maple_add_packet(struct mapleq *mq); 75void maple_add_packet(struct mapleq *mq);
76 76
77#define to_maple_dev(n) container_of(n, struct maple_device, dev) 77#define to_maple_dev(n) container_of(n, struct maple_device, dev)
78#define to_maple_driver(n) container_of(n, struct maple_driver, drv) 78#define to_maple_driver(n) container_of(n, struct maple_driver, drv)
79 79
80#endif /* __LINUX_MAPLE_H */ 80#endif /* __LINUX_MAPLE_H */
diff --git a/include/linux/module.h b/include/linux/module.h
index 330bec08c2c4..819c4e889bf1 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -567,8 +567,7 @@ static inline void print_modules(void)
567{ 567{
568} 568}
569 569
570static inline void module_update_markers(struct module *probe_module, 570static inline void module_update_markers(void)
571 int *refcount)
572{ 571{
573} 572}
574 573
diff --git a/include/linux/namei.h b/include/linux/namei.h
index c13e411491f4..24d88e98a626 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/dcache.h> 4#include <linux/dcache.h>
5#include <linux/linkage.h> 5#include <linux/linkage.h>
6#include <linux/path.h>
6 7
7struct vfsmount; 8struct vfsmount;
8 9
@@ -15,8 +16,7 @@ struct open_intent {
15enum { MAX_NESTED_LINKS = 8 }; 16enum { MAX_NESTED_LINKS = 8 };
16 17
17struct nameidata { 18struct nameidata {
18 struct dentry *dentry; 19 struct path path;
19 struct vfsmount *mnt;
20 struct qstr last; 20 struct qstr last;
21 unsigned int flags; 21 unsigned int flags;
22 int last_type; 22 int last_type;
@@ -29,11 +29,6 @@ struct nameidata {
29 } intent; 29 } intent;
30}; 30};
31 31
32struct path {
33 struct vfsmount *mnt;
34 struct dentry *dentry;
35};
36
37/* 32/*
38 * Type of the last component on LOOKUP_PARENT 33 * Type of the last component on LOOKUP_PARENT
39 */ 34 */
@@ -71,8 +66,6 @@ extern int __user_walk_fd(int dfd, const char __user *, unsigned, struct nameida
71extern int path_lookup(const char *, unsigned, struct nameidata *); 66extern int path_lookup(const char *, unsigned, struct nameidata *);
72extern int vfs_path_lookup(struct dentry *, struct vfsmount *, 67extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
73 const char *, unsigned int, struct nameidata *); 68 const char *, unsigned int, struct nameidata *);
74extern void path_release(struct nameidata *);
75extern void path_release_on_umount(struct nameidata *);
76 69
77extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags); 70extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags);
78extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags); 71extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7128a02f1d37..a2f003239c85 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -604,6 +604,10 @@ struct net_device
604 604
605 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ 605 unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
606 606
607 /* ingress path synchronizer */
608 spinlock_t ingress_lock;
609 struct Qdisc *qdisc_ingress;
610
607/* 611/*
608 * Cache line mostly used on queue transmit path (qdisc) 612 * Cache line mostly used on queue transmit path (qdisc)
609 */ 613 */
@@ -617,10 +621,6 @@ struct net_device
617 /* Partially transmitted GSO packet. */ 621 /* Partially transmitted GSO packet. */
618 struct sk_buff *gso_skb; 622 struct sk_buff *gso_skb;
619 623
620 /* ingress path synchronizer */
621 spinlock_t ingress_lock;
622 struct Qdisc *qdisc_ingress;
623
624/* 624/*
625 * One part is mostly used on xmit path (device) 625 * One part is mostly used on xmit path (device)
626 */ 626 */
diff --git a/include/linux/nfsd/export.h b/include/linux/nfsd/export.h
index 3a1687251367..5431512b2757 100644
--- a/include/linux/nfsd/export.h
+++ b/include/linux/nfsd/export.h
@@ -84,9 +84,8 @@ struct svc_export {
84 struct cache_head h; 84 struct cache_head h;
85 struct auth_domain * ex_client; 85 struct auth_domain * ex_client;
86 int ex_flags; 86 int ex_flags;
87 struct vfsmount * ex_mnt; 87 struct path ex_path;
88 struct dentry * ex_dentry; 88 char *ex_pathname;
89 char * ex_path;
90 uid_t ex_anon_uid; 89 uid_t ex_anon_uid;
91 gid_t ex_anon_gid; 90 gid_t ex_anon_gid;
92 int ex_fsid; 91 int ex_fsid;
@@ -107,8 +106,7 @@ struct svc_expkey {
107 int ek_fsidtype; 106 int ek_fsidtype;
108 u32 ek_fsid[6]; 107 u32 ek_fsid[6];
109 108
110 struct vfsmount * ek_mnt; 109 struct path ek_path;
111 struct dentry * ek_dentry;
112}; 110};
113 111
114#define EX_SECURE(exp) (!((exp)->ex_flags & NFSEXP_INSECURE_PORT)) 112#define EX_SECURE(exp) (!((exp)->ex_flags & NFSEXP_INSECURE_PORT))
diff --git a/include/linux/path.h b/include/linux/path.h
new file mode 100644
index 000000000000..915e0c382a51
--- /dev/null
+++ b/include/linux/path.h
@@ -0,0 +1,15 @@
1#ifndef _LINUX_PATH_H
2#define _LINUX_PATH_H
3
4struct dentry;
5struct vfsmount;
6
7struct path {
8 struct vfsmount *mnt;
9 struct dentry *dentry;
10};
11
12extern void path_get(struct path *);
13extern void path_put(struct path *);
14
15#endif /* _LINUX_PATH_H */
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index d6a4f69bdc92..d9a9e718ad19 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -269,7 +269,7 @@ extern void kclist_add(struct kcore_list *, void *, size_t);
269#endif 269#endif
270 270
271union proc_op { 271union proc_op {
272 int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **); 272 int (*proc_get_link)(struct inode *, struct path *);
273 int (*proc_read)(struct task_struct *task, char *page); 273 int (*proc_read)(struct task_struct *task, char *page);
274 int (*proc_show)(struct seq_file *m, 274 int (*proc_show)(struct seq_file *m,
275 struct pid_namespace *ns, struct pid *pid, 275 struct pid_namespace *ns, struct pid *pid,
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 648dfeb444db..67c2563961f3 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -8,8 +8,7 @@
8 8
9struct seq_operations; 9struct seq_operations;
10struct file; 10struct file;
11struct vfsmount; 11struct path;
12struct dentry;
13struct inode; 12struct inode;
14 13
15struct seq_file { 14struct seq_file {
@@ -42,7 +41,7 @@ int seq_puts(struct seq_file *m, const char *s);
42int seq_printf(struct seq_file *, const char *, ...) 41int seq_printf(struct seq_file *, const char *, ...)
43 __attribute__ ((format (printf,2,3))); 42 __attribute__ ((format (printf,2,3)));
44 43
45int seq_path(struct seq_file *, struct vfsmount *, struct dentry *, char *); 44int seq_path(struct seq_file *, struct path *, char *);
46 45
47int single_open(struct file *, int (*)(struct seq_file *, void *), void *); 46int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
48int single_release(struct inode *, struct file *); 47int single_release(struct inode *, struct file *);
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 5e6d3d634d5b..57deecc79d52 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -71,6 +71,7 @@ struct kmem_cache {
71 71
72 /* Allocation and freeing of slabs */ 72 /* Allocation and freeing of slabs */
73 int objects; /* Number of objects in slab */ 73 int objects; /* Number of objects in slab */
74 gfp_t allocflags; /* gfp flags to use on each alloc */
74 int refcount; /* Refcount for slab cache destroy */ 75 int refcount; /* Refcount for slab cache destroy */
75 void (*ctor)(struct kmem_cache *, void *); 76 void (*ctor)(struct kmem_cache *, void *);
76 int inuse; /* Offset to metadata */ 77 int inuse; /* Offset to metadata */
@@ -110,7 +111,7 @@ struct kmem_cache {
110 * We keep the general caches in an array of slab caches that are used for 111 * We keep the general caches in an array of slab caches that are used for
111 * 2^x bytes of allocations. 112 * 2^x bytes of allocations.
112 */ 113 */
113extern struct kmem_cache kmalloc_caches[PAGE_SHIFT]; 114extern struct kmem_cache kmalloc_caches[PAGE_SHIFT + 1];
114 115
115/* 116/*
116 * Sorry that the following has to be that ugly but some versions of GCC 117 * Sorry that the following has to be that ugly but some versions of GCC
@@ -188,12 +189,16 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
188void *kmem_cache_alloc(struct kmem_cache *, gfp_t); 189void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
189void *__kmalloc(size_t size, gfp_t flags); 190void *__kmalloc(size_t size, gfp_t flags);
190 191
192static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
193{
194 return (void *)__get_free_pages(flags | __GFP_COMP, get_order(size));
195}
196
191static __always_inline void *kmalloc(size_t size, gfp_t flags) 197static __always_inline void *kmalloc(size_t size, gfp_t flags)
192{ 198{
193 if (__builtin_constant_p(size)) { 199 if (__builtin_constant_p(size)) {
194 if (size > PAGE_SIZE / 2) 200 if (size > PAGE_SIZE)
195 return (void *)__get_free_pages(flags | __GFP_COMP, 201 return kmalloc_large(size, flags);
196 get_order(size));
197 202
198 if (!(flags & SLUB_DMA)) { 203 if (!(flags & SLUB_DMA)) {
199 struct kmem_cache *s = kmalloc_slab(size); 204 struct kmem_cache *s = kmalloc_slab(size);
@@ -214,7 +219,7 @@ void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
214static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) 219static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
215{ 220{
216 if (__builtin_constant_p(size) && 221 if (__builtin_constant_p(size) &&
217 size <= PAGE_SIZE / 2 && !(flags & SLUB_DMA)) { 222 size <= PAGE_SIZE && !(flags & SLUB_DMA)) {
218 struct kmem_cache *s = kmalloc_slab(size); 223 struct kmem_cache *s = kmalloc_slab(size);
219 224
220 if (!s) 225 if (!s)
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 32a57e1dee3a..717e2192d521 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -324,6 +324,7 @@ extern void ax25_dama_on(ax25_cb *);
324extern void ax25_dama_off(ax25_cb *); 324extern void ax25_dama_off(ax25_cb *);
325 325
326/* ax25_ds_timer.c */ 326/* ax25_ds_timer.c */
327extern void ax25_ds_setup_timer(ax25_dev *);
327extern void ax25_ds_set_timer(ax25_dev *); 328extern void ax25_ds_set_timer(ax25_dev *);
328extern void ax25_ds_del_timer(ax25_dev *); 329extern void ax25_ds_del_timer(ax25_dev *);
329extern void ax25_ds_timer(ax25_cb *); 330extern void ax25_ds_timer(ax25_cb *);
@@ -416,6 +417,7 @@ extern void ax25_calculate_rtt(ax25_cb *);
416extern void ax25_disconnect(ax25_cb *, int); 417extern void ax25_disconnect(ax25_cb *, int);
417 418
418/* ax25_timer.c */ 419/* ax25_timer.c */
420extern void ax25_setup_timers(ax25_cb *);
419extern void ax25_start_heartbeat(ax25_cb *); 421extern void ax25_start_heartbeat(ax25_cb *);
420extern void ax25_start_t1timer(ax25_cb *); 422extern void ax25_start_t1timer(ax25_cb *);
421extern void ax25_start_t2timer(ax25_cb *); 423extern void ax25_start_t2timer(ax25_cb *);
diff --git a/include/net/ndisc.h b/include/net/ndisc.h
index 6684f7efbeeb..59b70624b056 100644
--- a/include/net/ndisc.h
+++ b/include/net/ndisc.h
@@ -103,7 +103,6 @@ extern void ndisc_send_redirect(struct sk_buff *skb,
103extern int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int dir); 103extern int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int dir);
104 104
105 105
106struct rt6_info * dflt_rt_lookup(void);
107 106
108/* 107/*
109 * IGMP 108 * IGMP
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index ac72116636ca..eea7785cc757 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -508,7 +508,10 @@ struct xfrm_skb_cb {
508 } header; 508 } header;
509 509
510 /* Sequence number for replay protection. */ 510 /* Sequence number for replay protection. */
511 u64 seq; 511 union {
512 u64 output;
513 __be32 input;
514 } seq;
512}; 515};
513 516
514#define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0])) 517#define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0]))
diff --git a/init/do_mounts.c b/init/do_mounts.c
index f86573126f83..3885e70e7759 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -193,10 +193,10 @@ static int __init do_mount_root(char *name, char *fs, int flags, void *data)
193 return err; 193 return err;
194 194
195 sys_chdir("/root"); 195 sys_chdir("/root");
196 ROOT_DEV = current->fs->pwdmnt->mnt_sb->s_dev; 196 ROOT_DEV = current->fs->pwd.mnt->mnt_sb->s_dev;
197 printk("VFS: Mounted root (%s filesystem)%s.\n", 197 printk("VFS: Mounted root (%s filesystem)%s.\n",
198 current->fs->pwdmnt->mnt_sb->s_type->name, 198 current->fs->pwd.mnt->mnt_sb->s_type->name,
199 current->fs->pwdmnt->mnt_sb->s_flags & MS_RDONLY ? 199 current->fs->pwd.mnt->mnt_sb->s_flags & MS_RDONLY ?
200 " readonly" : ""); 200 " readonly" : "");
201 return 0; 201 return 0;
202} 202}
diff --git a/kernel/audit.c b/kernel/audit.c
index c8555b180213..2eeea9a14240 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1312,26 +1312,26 @@ void audit_log_untrustedstring(struct audit_buffer *ab, const char *string)
1312 1312
1313/* This is a helper-function to print the escaped d_path */ 1313/* This is a helper-function to print the escaped d_path */
1314void audit_log_d_path(struct audit_buffer *ab, const char *prefix, 1314void audit_log_d_path(struct audit_buffer *ab, const char *prefix,
1315 struct dentry *dentry, struct vfsmount *vfsmnt) 1315 struct path *path)
1316{ 1316{
1317 char *p, *path; 1317 char *p, *pathname;
1318 1318
1319 if (prefix) 1319 if (prefix)
1320 audit_log_format(ab, " %s", prefix); 1320 audit_log_format(ab, " %s", prefix);
1321 1321
1322 /* We will allow 11 spaces for ' (deleted)' to be appended */ 1322 /* We will allow 11 spaces for ' (deleted)' to be appended */
1323 path = kmalloc(PATH_MAX+11, ab->gfp_mask); 1323 pathname = kmalloc(PATH_MAX+11, ab->gfp_mask);
1324 if (!path) { 1324 if (!pathname) {
1325 audit_log_format(ab, "<no memory>"); 1325 audit_log_format(ab, "<no memory>");
1326 return; 1326 return;
1327 } 1327 }
1328 p = d_path(dentry, vfsmnt, path, PATH_MAX+11); 1328 p = d_path(path, pathname, PATH_MAX+11);
1329 if (IS_ERR(p)) { /* Should never happen since we send PATH_MAX */ 1329 if (IS_ERR(p)) { /* Should never happen since we send PATH_MAX */
1330 /* FIXME: can we save some information here? */ 1330 /* FIXME: can we save some information here? */
1331 audit_log_format(ab, "<too long>"); 1331 audit_log_format(ab, "<too long>");
1332 } else 1332 } else
1333 audit_log_untrustedstring(ab, p); 1333 audit_log_untrustedstring(ab, p);
1334 kfree(path); 1334 kfree(pathname);
1335} 1335}
1336 1336
1337/** 1337/**
diff --git a/kernel/audit_tree.c b/kernel/audit_tree.c
index f4fcf58f20f8..9ef5e0aacc3c 100644
--- a/kernel/audit_tree.c
+++ b/kernel/audit_tree.c
@@ -549,8 +549,8 @@ void audit_trim_trees(void)
549 if (err) 549 if (err)
550 goto skip_it; 550 goto skip_it;
551 551
552 root_mnt = collect_mounts(nd.mnt, nd.dentry); 552 root_mnt = collect_mounts(nd.path.mnt, nd.path.dentry);
553 path_release(&nd); 553 path_put(&nd.path);
554 if (!root_mnt) 554 if (!root_mnt)
555 goto skip_it; 555 goto skip_it;
556 556
@@ -583,17 +583,17 @@ skip_it:
583static int is_under(struct vfsmount *mnt, struct dentry *dentry, 583static int is_under(struct vfsmount *mnt, struct dentry *dentry,
584 struct nameidata *nd) 584 struct nameidata *nd)
585{ 585{
586 if (mnt != nd->mnt) { 586 if (mnt != nd->path.mnt) {
587 for (;;) { 587 for (;;) {
588 if (mnt->mnt_parent == mnt) 588 if (mnt->mnt_parent == mnt)
589 return 0; 589 return 0;
590 if (mnt->mnt_parent == nd->mnt) 590 if (mnt->mnt_parent == nd->path.mnt)
591 break; 591 break;
592 mnt = mnt->mnt_parent; 592 mnt = mnt->mnt_parent;
593 } 593 }
594 dentry = mnt->mnt_mountpoint; 594 dentry = mnt->mnt_mountpoint;
595 } 595 }
596 return is_subdir(dentry, nd->dentry); 596 return is_subdir(dentry, nd->path.dentry);
597} 597}
598 598
599int audit_make_tree(struct audit_krule *rule, char *pathname, u32 op) 599int audit_make_tree(struct audit_krule *rule, char *pathname, u32 op)
@@ -641,8 +641,8 @@ int audit_add_tree_rule(struct audit_krule *rule)
641 err = path_lookup(tree->pathname, 0, &nd); 641 err = path_lookup(tree->pathname, 0, &nd);
642 if (err) 642 if (err)
643 goto Err; 643 goto Err;
644 mnt = collect_mounts(nd.mnt, nd.dentry); 644 mnt = collect_mounts(nd.path.mnt, nd.path.dentry);
645 path_release(&nd); 645 path_put(&nd.path);
646 if (!mnt) { 646 if (!mnt) {
647 err = -ENOMEM; 647 err = -ENOMEM;
648 goto Err; 648 goto Err;
@@ -701,8 +701,8 @@ int audit_tag_tree(char *old, char *new)
701 err = path_lookup(new, 0, &nd); 701 err = path_lookup(new, 0, &nd);
702 if (err) 702 if (err)
703 return err; 703 return err;
704 tagged = collect_mounts(nd.mnt, nd.dentry); 704 tagged = collect_mounts(nd.path.mnt, nd.path.dentry);
705 path_release(&nd); 705 path_put(&nd.path);
706 if (!tagged) 706 if (!tagged)
707 return -ENOMEM; 707 return -ENOMEM;
708 708
@@ -711,9 +711,9 @@ int audit_tag_tree(char *old, char *new)
711 drop_collected_mounts(tagged); 711 drop_collected_mounts(tagged);
712 return err; 712 return err;
713 } 713 }
714 mnt = mntget(nd.mnt); 714 mnt = mntget(nd.path.mnt);
715 dentry = dget(nd.dentry); 715 dentry = dget(nd.path.dentry);
716 path_release(&nd); 716 path_put(&nd.path);
717 717
718 if (dentry == tagged->mnt_root && dentry == mnt->mnt_root) 718 if (dentry == tagged->mnt_root && dentry == mnt->mnt_root)
719 follow_up(&mnt, &dentry); 719 follow_up(&mnt, &dentry);
@@ -744,13 +744,13 @@ int audit_tag_tree(char *old, char *new)
744 spin_lock(&vfsmount_lock); 744 spin_lock(&vfsmount_lock);
745 if (!is_under(mnt, dentry, &nd)) { 745 if (!is_under(mnt, dentry, &nd)) {
746 spin_unlock(&vfsmount_lock); 746 spin_unlock(&vfsmount_lock);
747 path_release(&nd); 747 path_put(&nd.path);
748 put_tree(tree); 748 put_tree(tree);
749 mutex_lock(&audit_filter_mutex); 749 mutex_lock(&audit_filter_mutex);
750 continue; 750 continue;
751 } 751 }
752 spin_unlock(&vfsmount_lock); 752 spin_unlock(&vfsmount_lock);
753 path_release(&nd); 753 path_put(&nd.path);
754 754
755 list_for_each_entry(p, &list, mnt_list) { 755 list_for_each_entry(p, &list, mnt_list) {
756 failed = tag_chunk(p->mnt_root->d_inode, tree); 756 failed = tag_chunk(p->mnt_root->d_inode, tree);
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 6f19fd477aac..2f2914b7cc30 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -169,8 +169,8 @@ static struct audit_parent *audit_init_parent(struct nameidata *ndp)
169 inotify_init_watch(&parent->wdata); 169 inotify_init_watch(&parent->wdata);
170 /* grab a ref so inotify watch hangs around until we take audit_filter_mutex */ 170 /* grab a ref so inotify watch hangs around until we take audit_filter_mutex */
171 get_inotify_watch(&parent->wdata); 171 get_inotify_watch(&parent->wdata);
172 wd = inotify_add_watch(audit_ih, &parent->wdata, ndp->dentry->d_inode, 172 wd = inotify_add_watch(audit_ih, &parent->wdata,
173 AUDIT_IN_WATCH); 173 ndp->path.dentry->d_inode, AUDIT_IN_WATCH);
174 if (wd < 0) { 174 if (wd < 0) {
175 audit_free_parent(&parent->wdata); 175 audit_free_parent(&parent->wdata);
176 return ERR_PTR(wd); 176 return ERR_PTR(wd);
@@ -1161,11 +1161,11 @@ static int audit_get_nd(char *path, struct nameidata **ndp,
1161static void audit_put_nd(struct nameidata *ndp, struct nameidata *ndw) 1161static void audit_put_nd(struct nameidata *ndp, struct nameidata *ndw)
1162{ 1162{
1163 if (ndp) { 1163 if (ndp) {
1164 path_release(ndp); 1164 path_put(&ndp->path);
1165 kfree(ndp); 1165 kfree(ndp);
1166 } 1166 }
1167 if (ndw) { 1167 if (ndw) {
1168 path_release(ndw); 1168 path_put(&ndw->path);
1169 kfree(ndw); 1169 kfree(ndw);
1170 } 1170 }
1171} 1171}
@@ -1214,8 +1214,8 @@ static int audit_add_watch(struct audit_krule *krule, struct nameidata *ndp,
1214 1214
1215 /* update watch filter fields */ 1215 /* update watch filter fields */
1216 if (ndw) { 1216 if (ndw) {
1217 watch->dev = ndw->dentry->d_inode->i_sb->s_dev; 1217 watch->dev = ndw->path.dentry->d_inode->i_sb->s_dev;
1218 watch->ino = ndw->dentry->d_inode->i_ino; 1218 watch->ino = ndw->path.dentry->d_inode->i_ino;
1219 } 1219 }
1220 1220
1221 /* The audit_filter_mutex must not be held during inotify calls because 1221 /* The audit_filter_mutex must not be held during inotify calls because
@@ -1225,7 +1225,8 @@ static int audit_add_watch(struct audit_krule *krule, struct nameidata *ndp,
1225 */ 1225 */
1226 mutex_unlock(&audit_filter_mutex); 1226 mutex_unlock(&audit_filter_mutex);
1227 1227
1228 if (inotify_find_watch(audit_ih, ndp->dentry->d_inode, &i_watch) < 0) { 1228 if (inotify_find_watch(audit_ih, ndp->path.dentry->d_inode,
1229 &i_watch) < 0) {
1229 parent = audit_init_parent(ndp); 1230 parent = audit_init_parent(ndp);
1230 if (IS_ERR(parent)) { 1231 if (IS_ERR(parent)) {
1231 /* caller expects mutex locked */ 1232 /* caller expects mutex locked */
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 1c06ecf38d7b..ac6d9b23b018 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -208,8 +208,7 @@ struct audit_context {
208 int name_count; 208 int name_count;
209 struct audit_names names[AUDIT_NAMES]; 209 struct audit_names names[AUDIT_NAMES];
210 char * filterkey; /* key for rule that triggered record */ 210 char * filterkey; /* key for rule that triggered record */
211 struct dentry * pwd; 211 struct path pwd;
212 struct vfsmount * pwdmnt;
213 struct audit_context *previous; /* For nested syscalls */ 212 struct audit_context *previous; /* For nested syscalls */
214 struct audit_aux_data *aux; 213 struct audit_aux_data *aux;
215 struct audit_aux_data *aux_pids; 214 struct audit_aux_data *aux_pids;
@@ -786,12 +785,9 @@ static inline void audit_free_names(struct audit_context *context)
786 __putname(context->names[i].name); 785 __putname(context->names[i].name);
787 } 786 }
788 context->name_count = 0; 787 context->name_count = 0;
789 if (context->pwd) 788 path_put(&context->pwd);
790 dput(context->pwd); 789 context->pwd.dentry = NULL;
791 if (context->pwdmnt) 790 context->pwd.mnt = NULL;
792 mntput(context->pwdmnt);
793 context->pwd = NULL;
794 context->pwdmnt = NULL;
795} 791}
796 792
797static inline void audit_free_aux(struct audit_context *context) 793static inline void audit_free_aux(struct audit_context *context)
@@ -930,8 +926,7 @@ static void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk
930 if ((vma->vm_flags & VM_EXECUTABLE) && 926 if ((vma->vm_flags & VM_EXECUTABLE) &&
931 vma->vm_file) { 927 vma->vm_file) {
932 audit_log_d_path(ab, "exe=", 928 audit_log_d_path(ab, "exe=",
933 vma->vm_file->f_path.dentry, 929 &vma->vm_file->f_path);
934 vma->vm_file->f_path.mnt);
935 break; 930 break;
936 } 931 }
937 vma = vma->vm_next; 932 vma = vma->vm_next;
@@ -1341,10 +1336,10 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
1341 context->target_sid, context->target_comm)) 1336 context->target_sid, context->target_comm))
1342 call_panic = 1; 1337 call_panic = 1;
1343 1338
1344 if (context->pwd && context->pwdmnt) { 1339 if (context->pwd.dentry && context->pwd.mnt) {
1345 ab = audit_log_start(context, GFP_KERNEL, AUDIT_CWD); 1340 ab = audit_log_start(context, GFP_KERNEL, AUDIT_CWD);
1346 if (ab) { 1341 if (ab) {
1347 audit_log_d_path(ab, "cwd=", context->pwd, context->pwdmnt); 1342 audit_log_d_path(ab, "cwd=", &context->pwd);
1348 audit_log_end(ab); 1343 audit_log_end(ab);
1349 } 1344 }
1350 } 1345 }
@@ -1367,8 +1362,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
1367 case 0: 1362 case 0:
1368 /* name was specified as a relative path and the 1363 /* name was specified as a relative path and the
1369 * directory component is the cwd */ 1364 * directory component is the cwd */
1370 audit_log_d_path(ab, " name=", context->pwd, 1365 audit_log_d_path(ab, " name=", &context->pwd);
1371 context->pwdmnt);
1372 break; 1366 break;
1373 default: 1367 default:
1374 /* log the name's directory component */ 1368 /* log the name's directory component */
@@ -1695,10 +1689,10 @@ void __audit_getname(const char *name)
1695 context->names[context->name_count].ino = (unsigned long)-1; 1689 context->names[context->name_count].ino = (unsigned long)-1;
1696 context->names[context->name_count].osid = 0; 1690 context->names[context->name_count].osid = 0;
1697 ++context->name_count; 1691 ++context->name_count;
1698 if (!context->pwd) { 1692 if (!context->pwd.dentry) {
1699 read_lock(&current->fs->lock); 1693 read_lock(&current->fs->lock);
1700 context->pwd = dget(current->fs->pwd); 1694 context->pwd = current->fs->pwd;
1701 context->pwdmnt = mntget(current->fs->pwdmnt); 1695 path_get(&current->fs->pwd);
1702 read_unlock(&current->fs->lock); 1696 read_unlock(&current->fs->lock);
1703 } 1697 }
1704 1698
diff --git a/kernel/exit.c b/kernel/exit.c
index 3b893e78ce61..506a957b665a 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -512,14 +512,10 @@ static void __put_fs_struct(struct fs_struct *fs)
512{ 512{
513 /* No need to hold fs->lock if we are killing it */ 513 /* No need to hold fs->lock if we are killing it */
514 if (atomic_dec_and_test(&fs->count)) { 514 if (atomic_dec_and_test(&fs->count)) {
515 dput(fs->root); 515 path_put(&fs->root);
516 mntput(fs->rootmnt); 516 path_put(&fs->pwd);
517 dput(fs->pwd); 517 if (fs->altroot.dentry)
518 mntput(fs->pwdmnt); 518 path_put(&fs->altroot);
519 if (fs->altroot) {
520 dput(fs->altroot);
521 mntput(fs->altrootmnt);
522 }
523 kmem_cache_free(fs_cachep, fs); 519 kmem_cache_free(fs_cachep, fs);
524 } 520 }
525} 521}
diff --git a/kernel/fork.c b/kernel/fork.c
index 4363a4eb84e3..dd249c37b3a3 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -600,16 +600,16 @@ static struct fs_struct *__copy_fs_struct(struct fs_struct *old)
600 rwlock_init(&fs->lock); 600 rwlock_init(&fs->lock);
601 fs->umask = old->umask; 601 fs->umask = old->umask;
602 read_lock(&old->lock); 602 read_lock(&old->lock);
603 fs->rootmnt = mntget(old->rootmnt); 603 fs->root = old->root;
604 fs->root = dget(old->root); 604 path_get(&old->root);
605 fs->pwdmnt = mntget(old->pwdmnt); 605 fs->pwd = old->pwd;
606 fs->pwd = dget(old->pwd); 606 path_get(&old->pwd);
607 if (old->altroot) { 607 if (old->altroot.dentry) {
608 fs->altrootmnt = mntget(old->altrootmnt); 608 fs->altroot = old->altroot;
609 fs->altroot = dget(old->altroot); 609 path_get(&old->altroot);
610 } else { 610 } else {
611 fs->altrootmnt = NULL; 611 fs->altroot.mnt = NULL;
612 fs->altroot = NULL; 612 fs->altroot.dentry = NULL;
613 } 613 }
614 read_unlock(&old->lock); 614 read_unlock(&old->lock);
615 } 615 }
diff --git a/kernel/futex.c b/kernel/futex.c
index a6baaec44b8f..221f2128a437 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -2116,7 +2116,7 @@ asmlinkage long sys_futex(u32 __user *uaddr, int op, u32 val,
2116 2116
2117 t = timespec_to_ktime(ts); 2117 t = timespec_to_ktime(ts);
2118 if (cmd == FUTEX_WAIT) 2118 if (cmd == FUTEX_WAIT)
2119 t = ktime_add(ktime_get(), t); 2119 t = ktime_add_safe(ktime_get(), t);
2120 tp = &t; 2120 tp = &t;
2121 } 2121 }
2122 /* 2122 /*
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index 133d558db452..7d5e4b016f39 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -176,7 +176,7 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
176 176
177 t = timespec_to_ktime(ts); 177 t = timespec_to_ktime(ts);
178 if (cmd == FUTEX_WAIT) 178 if (cmd == FUTEX_WAIT)
179 t = ktime_add(ktime_get(), t); 179 t = ktime_add_safe(ktime_get(), t);
180 tp = &t; 180 tp = &t;
181 } 181 }
182 if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE) 182 if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE)
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 3f4a57c7895d..98bee013f71f 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -326,6 +326,23 @@ u64 ktime_divns(const ktime_t kt, s64 div)
326#endif /* BITS_PER_LONG >= 64 */ 326#endif /* BITS_PER_LONG >= 64 */
327 327
328/* 328/*
329 * Add two ktime values and do a safety check for overflow:
330 */
331ktime_t ktime_add_safe(const ktime_t lhs, const ktime_t rhs)
332{
333 ktime_t res = ktime_add(lhs, rhs);
334
335 /*
336 * We use KTIME_SEC_MAX here, the maximum timeout which we can
337 * return to user space in a timespec:
338 */
339 if (res.tv64 < 0 || res.tv64 < lhs.tv64 || res.tv64 < rhs.tv64)
340 res = ktime_set(KTIME_SEC_MAX, 0);
341
342 return res;
343}
344
345/*
329 * Check, whether the timer is on the callback pending list 346 * Check, whether the timer is on the callback pending list
330 */ 347 */
331static inline int hrtimer_cb_pending(const struct hrtimer *timer) 348static inline int hrtimer_cb_pending(const struct hrtimer *timer)
@@ -425,6 +442,8 @@ static int hrtimer_reprogram(struct hrtimer *timer,
425 ktime_t expires = ktime_sub(timer->expires, base->offset); 442 ktime_t expires = ktime_sub(timer->expires, base->offset);
426 int res; 443 int res;
427 444
445 WARN_ON_ONCE(timer->expires.tv64 < 0);
446
428 /* 447 /*
429 * When the callback is running, we do not reprogram the clock event 448 * When the callback is running, we do not reprogram the clock event
430 * device. The timer callback is either running on a different CPU or 449 * device. The timer callback is either running on a different CPU or
@@ -435,6 +454,15 @@ static int hrtimer_reprogram(struct hrtimer *timer,
435 if (hrtimer_callback_running(timer)) 454 if (hrtimer_callback_running(timer))
436 return 0; 455 return 0;
437 456
457 /*
458 * CLOCK_REALTIME timer might be requested with an absolute
459 * expiry time which is less than base->offset. Nothing wrong
460 * about that, just avoid to call into the tick code, which
461 * has now objections against negative expiry values.
462 */
463 if (expires.tv64 < 0)
464 return -ETIME;
465
438 if (expires.tv64 >= expires_next->tv64) 466 if (expires.tv64 >= expires_next->tv64)
439 return 0; 467 return 0;
440 468
@@ -682,13 +710,7 @@ u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
682 */ 710 */
683 orun++; 711 orun++;
684 } 712 }
685 timer->expires = ktime_add(timer->expires, interval); 713 timer->expires = ktime_add_safe(timer->expires, interval);
686 /*
687 * Make sure, that the result did not wrap with a very large
688 * interval.
689 */
690 if (timer->expires.tv64 < 0)
691 timer->expires = ktime_set(KTIME_SEC_MAX, 0);
692 714
693 return orun; 715 return orun;
694} 716}
@@ -839,7 +861,7 @@ hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
839 new_base = switch_hrtimer_base(timer, base); 861 new_base = switch_hrtimer_base(timer, base);
840 862
841 if (mode == HRTIMER_MODE_REL) { 863 if (mode == HRTIMER_MODE_REL) {
842 tim = ktime_add(tim, new_base->get_time()); 864 tim = ktime_add_safe(tim, new_base->get_time());
843 /* 865 /*
844 * CONFIG_TIME_LOW_RES is a temporary way for architectures 866 * CONFIG_TIME_LOW_RES is a temporary way for architectures
845 * to signal that they simply return xtime in 867 * to signal that they simply return xtime in
@@ -848,16 +870,8 @@ hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
848 * timeouts. This will go away with the GTOD framework. 870 * timeouts. This will go away with the GTOD framework.
849 */ 871 */
850#ifdef CONFIG_TIME_LOW_RES 872#ifdef CONFIG_TIME_LOW_RES
851 tim = ktime_add(tim, base->resolution); 873 tim = ktime_add_safe(tim, base->resolution);
852#endif 874#endif
853 /*
854 * Careful here: User space might have asked for a
855 * very long sleep, so the add above might result in a
856 * negative number, which enqueues the timer in front
857 * of the queue.
858 */
859 if (tim.tv64 < 0)
860 tim.tv64 = KTIME_MAX;
861 } 875 }
862 timer->expires = tim; 876 timer->expires = tim;
863 877
diff --git a/kernel/kmod.c b/kernel/kmod.c
index bb7df2a28bd7..22be3ff3f363 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -173,10 +173,7 @@ static int ____call_usermodehelper(void *data)
173 */ 173 */
174 set_user_nice(current, 0); 174 set_user_nice(current, 0);
175 175
176 retval = -EPERM; 176 retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp);
177 if (current->fs->root)
178 retval = kernel_execve(sub_info->path,
179 sub_info->argv, sub_info->envp);
180 177
181 /* Exec failed? */ 178 /* Exec failed? */
182 sub_info->retval = retval; 179 sub_info->retval = retval;
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 022c9c3cee6f..a9b04203a66d 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -767,9 +767,11 @@ common_timer_set(struct k_itimer *timr, int flags,
767 /* SIGEV_NONE timers are not queued ! See common_timer_get */ 767 /* SIGEV_NONE timers are not queued ! See common_timer_get */
768 if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) { 768 if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) {
769 /* Setup correct expiry time for relative timers */ 769 /* Setup correct expiry time for relative timers */
770 if (mode == HRTIMER_MODE_REL) 770 if (mode == HRTIMER_MODE_REL) {
771 timer->expires = ktime_add(timer->expires, 771 timer->expires =
772 timer->base->get_time()); 772 ktime_add_safe(timer->expires,
773 timer->base->get_time());
774 }
773 return 0; 775 return 0;
774 } 776 }
775 777
diff --git a/mm/memory.c b/mm/memory.c
index 717aa0e3be2d..ce3c9e4492d8 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2711,6 +2711,13 @@ void print_vma_addr(char *prefix, unsigned long ip)
2711 struct mm_struct *mm = current->mm; 2711 struct mm_struct *mm = current->mm;
2712 struct vm_area_struct *vma; 2712 struct vm_area_struct *vma;
2713 2713
2714 /*
2715 * Do not print if we are in atomic
2716 * contexts (in exception stacks, etc.):
2717 */
2718 if (preempt_count())
2719 return;
2720
2714 down_read(&mm->mmap_sem); 2721 down_read(&mm->mmap_sem);
2715 vma = find_vma(mm, ip); 2722 vma = find_vma(mm, ip);
2716 if (vma && vma->vm_file) { 2723 if (vma && vma->vm_file) {
@@ -2719,7 +2726,7 @@ void print_vma_addr(char *prefix, unsigned long ip)
2719 if (buf) { 2726 if (buf) {
2720 char *p, *s; 2727 char *p, *s;
2721 2728
2722 p = d_path(f->f_dentry, f->f_vfsmnt, buf, PAGE_SIZE); 2729 p = d_path(&f->f_path, buf, PAGE_SIZE);
2723 if (IS_ERR(p)) 2730 if (IS_ERR(p))
2724 p = "?"; 2731 p = "?";
2725 s = strrchr(p, '/'); 2732 s = strrchr(p, '/');
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 8d246c3b340f..6c7ba1a63d23 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1996,7 +1996,7 @@ int show_numa_map(struct seq_file *m, void *v)
1996 1996
1997 if (file) { 1997 if (file) {
1998 seq_printf(m, " file="); 1998 seq_printf(m, " file=");
1999 seq_path(m, file->f_path.mnt, file->f_path.dentry, "\n\t= "); 1999 seq_path(m, &file->f_path, "\n\t= ");
2000 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { 2000 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
2001 seq_printf(m, " heap"); 2001 seq_printf(m, " heap");
2002 } else if (vma->vm_start <= mm->start_stack && 2002 } else if (vma->vm_start <= mm->start_stack &&
diff --git a/mm/slab.c b/mm/slab.c
index 40c00dacbe4b..473e6c2eaefb 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2630,6 +2630,7 @@ static struct slab *alloc_slabmgmt(struct kmem_cache *cachep, void *objp,
2630 slabp->colouroff = colour_off; 2630 slabp->colouroff = colour_off;
2631 slabp->s_mem = objp + colour_off; 2631 slabp->s_mem = objp + colour_off;
2632 slabp->nodeid = nodeid; 2632 slabp->nodeid = nodeid;
2633 slabp->free = 0;
2633 return slabp; 2634 return slabp;
2634} 2635}
2635 2636
@@ -2683,7 +2684,6 @@ static void cache_init_objs(struct kmem_cache *cachep,
2683 slab_bufctl(slabp)[i] = i + 1; 2684 slab_bufctl(slabp)[i] = i + 1;
2684 } 2685 }
2685 slab_bufctl(slabp)[i - 1] = BUFCTL_END; 2686 slab_bufctl(slabp)[i - 1] = BUFCTL_END;
2686 slabp->free = 0;
2687} 2687}
2688 2688
2689static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags) 2689static void kmem_flagcheck(struct kmem_cache *cachep, gfp_t flags)
@@ -2816,7 +2816,6 @@ static int cache_grow(struct kmem_cache *cachep,
2816 if (!slabp) 2816 if (!slabp)
2817 goto opps1; 2817 goto opps1;
2818 2818
2819 slabp->nodeid = nodeid;
2820 slab_map_pages(cachep, slabp, objp); 2819 slab_map_pages(cachep, slabp, objp);
2821 2820
2822 cache_init_objs(cachep, slabp); 2821 cache_init_objs(cachep, slabp);
diff --git a/mm/slub.c b/mm/slub.c
index e2989ae243b5..4b3895cb90ee 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -211,6 +211,8 @@ static inline void ClearSlabDebug(struct page *page)
211/* Internal SLUB flags */ 211/* Internal SLUB flags */
212#define __OBJECT_POISON 0x80000000 /* Poison object */ 212#define __OBJECT_POISON 0x80000000 /* Poison object */
213#define __SYSFS_ADD_DEFERRED 0x40000000 /* Not yet visible via sysfs */ 213#define __SYSFS_ADD_DEFERRED 0x40000000 /* Not yet visible via sysfs */
214#define __KMALLOC_CACHE 0x20000000 /* objects freed using kfree */
215#define __PAGE_ALLOC_FALLBACK 0x10000000 /* Allow fallback to page alloc */
214 216
215/* Not all arches define cache_line_size */ 217/* Not all arches define cache_line_size */
216#ifndef cache_line_size 218#ifndef cache_line_size
@@ -308,7 +310,7 @@ static inline int is_end(void *addr)
308 return (unsigned long)addr & PAGE_MAPPING_ANON; 310 return (unsigned long)addr & PAGE_MAPPING_ANON;
309} 311}
310 312
311void *slab_address(struct page *page) 313static void *slab_address(struct page *page)
312{ 314{
313 return page->end - PAGE_MAPPING_ANON; 315 return page->end - PAGE_MAPPING_ANON;
314} 316}
@@ -1078,14 +1080,7 @@ static struct page *allocate_slab(struct kmem_cache *s, gfp_t flags, int node)
1078 struct page *page; 1080 struct page *page;
1079 int pages = 1 << s->order; 1081 int pages = 1 << s->order;
1080 1082
1081 if (s->order) 1083 flags |= s->allocflags;
1082 flags |= __GFP_COMP;
1083
1084 if (s->flags & SLAB_CACHE_DMA)
1085 flags |= SLUB_DMA;
1086
1087 if (s->flags & SLAB_RECLAIM_ACCOUNT)
1088 flags |= __GFP_RECLAIMABLE;
1089 1084
1090 if (node == -1) 1085 if (node == -1)
1091 page = alloc_pages(flags, s->order); 1086 page = alloc_pages(flags, s->order);
@@ -1546,7 +1541,6 @@ load_freelist:
1546unlock_out: 1541unlock_out:
1547 slab_unlock(c->page); 1542 slab_unlock(c->page);
1548 stat(c, ALLOC_SLOWPATH); 1543 stat(c, ALLOC_SLOWPATH);
1549out:
1550#ifdef SLUB_FASTPATH 1544#ifdef SLUB_FASTPATH
1551 local_irq_restore(flags); 1545 local_irq_restore(flags);
1552#endif 1546#endif
@@ -1581,8 +1575,24 @@ new_slab:
1581 c->page = new; 1575 c->page = new;
1582 goto load_freelist; 1576 goto load_freelist;
1583 } 1577 }
1584 object = NULL; 1578#ifdef SLUB_FASTPATH
1585 goto out; 1579 local_irq_restore(flags);
1580#endif
1581 /*
1582 * No memory available.
1583 *
1584 * If the slab uses higher order allocs but the object is
1585 * smaller than a page size then we can fallback in emergencies
1586 * to the page allocator via kmalloc_large. The page allocator may
1587 * have failed to obtain a higher order page and we can try to
1588 * allocate a single page if the object fits into a single page.
1589 * That is only possible if certain conditions are met that are being
1590 * checked when a slab is created.
1591 */
1592 if (!(gfpflags & __GFP_NORETRY) && (s->flags & __PAGE_ALLOC_FALLBACK))
1593 return kmalloc_large(s->objsize, gfpflags);
1594
1595 return NULL;
1586debug: 1596debug:
1587 object = c->page->freelist; 1597 object = c->page->freelist;
1588 if (!alloc_debug_processing(s, c->page, object, addr)) 1598 if (!alloc_debug_processing(s, c->page, object, addr))
@@ -2329,10 +2339,33 @@ static int calculate_sizes(struct kmem_cache *s)
2329 size = ALIGN(size, align); 2339 size = ALIGN(size, align);
2330 s->size = size; 2340 s->size = size;
2331 2341
2332 s->order = calculate_order(size); 2342 if ((flags & __KMALLOC_CACHE) &&
2343 PAGE_SIZE / size < slub_min_objects) {
2344 /*
2345 * Kmalloc cache that would not have enough objects in
2346 * an order 0 page. Kmalloc slabs can fallback to
2347 * page allocator order 0 allocs so take a reasonably large
2348 * order that will allows us a good number of objects.
2349 */
2350 s->order = max(slub_max_order, PAGE_ALLOC_COSTLY_ORDER);
2351 s->flags |= __PAGE_ALLOC_FALLBACK;
2352 s->allocflags |= __GFP_NOWARN;
2353 } else
2354 s->order = calculate_order(size);
2355
2333 if (s->order < 0) 2356 if (s->order < 0)
2334 return 0; 2357 return 0;
2335 2358
2359 s->allocflags = 0;
2360 if (s->order)
2361 s->allocflags |= __GFP_COMP;
2362
2363 if (s->flags & SLAB_CACHE_DMA)
2364 s->allocflags |= SLUB_DMA;
2365
2366 if (s->flags & SLAB_RECLAIM_ACCOUNT)
2367 s->allocflags |= __GFP_RECLAIMABLE;
2368
2336 /* 2369 /*
2337 * Determine the number of objects per slab 2370 * Determine the number of objects per slab
2338 */ 2371 */
@@ -2484,11 +2517,11 @@ EXPORT_SYMBOL(kmem_cache_destroy);
2484 * Kmalloc subsystem 2517 * Kmalloc subsystem
2485 *******************************************************************/ 2518 *******************************************************************/
2486 2519
2487struct kmem_cache kmalloc_caches[PAGE_SHIFT] __cacheline_aligned; 2520struct kmem_cache kmalloc_caches[PAGE_SHIFT + 1] __cacheline_aligned;
2488EXPORT_SYMBOL(kmalloc_caches); 2521EXPORT_SYMBOL(kmalloc_caches);
2489 2522
2490#ifdef CONFIG_ZONE_DMA 2523#ifdef CONFIG_ZONE_DMA
2491static struct kmem_cache *kmalloc_caches_dma[PAGE_SHIFT]; 2524static struct kmem_cache *kmalloc_caches_dma[PAGE_SHIFT + 1];
2492#endif 2525#endif
2493 2526
2494static int __init setup_slub_min_order(char *str) 2527static int __init setup_slub_min_order(char *str)
@@ -2536,7 +2569,7 @@ static struct kmem_cache *create_kmalloc_cache(struct kmem_cache *s,
2536 2569
2537 down_write(&slub_lock); 2570 down_write(&slub_lock);
2538 if (!kmem_cache_open(s, gfp_flags, name, size, ARCH_KMALLOC_MINALIGN, 2571 if (!kmem_cache_open(s, gfp_flags, name, size, ARCH_KMALLOC_MINALIGN,
2539 flags, NULL)) 2572 flags | __KMALLOC_CACHE, NULL))
2540 goto panic; 2573 goto panic;
2541 2574
2542 list_add(&s->list, &slab_caches); 2575 list_add(&s->list, &slab_caches);
@@ -2670,9 +2703,8 @@ void *__kmalloc(size_t size, gfp_t flags)
2670{ 2703{
2671 struct kmem_cache *s; 2704 struct kmem_cache *s;
2672 2705
2673 if (unlikely(size > PAGE_SIZE / 2)) 2706 if (unlikely(size > PAGE_SIZE))
2674 return (void *)__get_free_pages(flags | __GFP_COMP, 2707 return kmalloc_large(size, flags);
2675 get_order(size));
2676 2708
2677 s = get_slab(size, flags); 2709 s = get_slab(size, flags);
2678 2710
@@ -2688,9 +2720,8 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
2688{ 2720{
2689 struct kmem_cache *s; 2721 struct kmem_cache *s;
2690 2722
2691 if (unlikely(size > PAGE_SIZE / 2)) 2723 if (unlikely(size > PAGE_SIZE))
2692 return (void *)__get_free_pages(flags | __GFP_COMP, 2724 return kmalloc_large(size, flags);
2693 get_order(size));
2694 2725
2695 s = get_slab(size, flags); 2726 s = get_slab(size, flags);
2696 2727
@@ -3001,7 +3032,7 @@ void __init kmem_cache_init(void)
3001 caches++; 3032 caches++;
3002 } 3033 }
3003 3034
3004 for (i = KMALLOC_SHIFT_LOW; i < PAGE_SHIFT; i++) { 3035 for (i = KMALLOC_SHIFT_LOW; i <= PAGE_SHIFT; i++) {
3005 create_kmalloc_cache(&kmalloc_caches[i], 3036 create_kmalloc_cache(&kmalloc_caches[i],
3006 "kmalloc", 1 << i, GFP_KERNEL); 3037 "kmalloc", 1 << i, GFP_KERNEL);
3007 caches++; 3038 caches++;
@@ -3028,7 +3059,7 @@ void __init kmem_cache_init(void)
3028 slab_state = UP; 3059 slab_state = UP;
3029 3060
3030 /* Provide the correct kmalloc names now that the caches are up */ 3061 /* Provide the correct kmalloc names now that the caches are up */
3031 for (i = KMALLOC_SHIFT_LOW; i < PAGE_SHIFT; i++) 3062 for (i = KMALLOC_SHIFT_LOW; i <= PAGE_SHIFT; i++)
3032 kmalloc_caches[i]. name = 3063 kmalloc_caches[i]. name =
3033 kasprintf(GFP_KERNEL, "kmalloc-%d", 1 << i); 3064 kasprintf(GFP_KERNEL, "kmalloc-%d", 1 << i);
3034 3065
@@ -3057,6 +3088,9 @@ static int slab_unmergeable(struct kmem_cache *s)
3057 if (slub_nomerge || (s->flags & SLUB_NEVER_MERGE)) 3088 if (slub_nomerge || (s->flags & SLUB_NEVER_MERGE))
3058 return 1; 3089 return 1;
3059 3090
3091 if ((s->flags & __PAGE_ALLOC_FALLBACK))
3092 return 1;
3093
3060 if (s->ctor) 3094 if (s->ctor)
3061 return 1; 3095 return 1;
3062 3096
@@ -3218,9 +3252,9 @@ void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, void *caller)
3218{ 3252{
3219 struct kmem_cache *s; 3253 struct kmem_cache *s;
3220 3254
3221 if (unlikely(size > PAGE_SIZE / 2)) 3255 if (unlikely(size > PAGE_SIZE))
3222 return (void *)__get_free_pages(gfpflags | __GFP_COMP, 3256 return kmalloc_large(size, gfpflags);
3223 get_order(size)); 3257
3224 s = get_slab(size, gfpflags); 3258 s = get_slab(size, gfpflags);
3225 3259
3226 if (unlikely(ZERO_OR_NULL_PTR(s))) 3260 if (unlikely(ZERO_OR_NULL_PTR(s)))
@@ -3234,9 +3268,9 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
3234{ 3268{
3235 struct kmem_cache *s; 3269 struct kmem_cache *s;
3236 3270
3237 if (unlikely(size > PAGE_SIZE / 2)) 3271 if (unlikely(size > PAGE_SIZE))
3238 return (void *)__get_free_pages(gfpflags | __GFP_COMP, 3272 return kmalloc_large(size, gfpflags);
3239 get_order(size)); 3273
3240 s = get_slab(size, gfpflags); 3274 s = get_slab(size, gfpflags);
3241 3275
3242 if (unlikely(ZERO_OR_NULL_PTR(s))) 3276 if (unlikely(ZERO_OR_NULL_PTR(s)))
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 02ccab5ad9d9..2da149cfc9ac 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1394,7 +1394,7 @@ static int swap_show(struct seq_file *swap, void *v)
1394 } 1394 }
1395 1395
1396 file = ptr->swap_file; 1396 file = ptr->swap_file;
1397 len = seq_path(swap, file->f_path.mnt, file->f_path.dentry, " \t\n\\"); 1397 len = seq_path(swap, &file->f_path, " \t\n\\");
1398 seq_printf(swap, "%*s%s\t%u\t%u\t%d\n", 1398 seq_printf(swap, "%*s%s\t%u\t%u\t%d\n",
1399 len < 40 ? 40 - len : 1, " ", 1399 len < 40 ? 40 - len : 1, " ",
1400 S_ISBLK(file->f_path.dentry->d_inode->i_mode) ? 1400 S_ISBLK(file->f_path.dentry->d_inode->i_mode) ?
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index 8fc64e3150a2..48bfcc741f25 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -510,11 +510,7 @@ ax25_cb *ax25_create_cb(void)
510 skb_queue_head_init(&ax25->ack_queue); 510 skb_queue_head_init(&ax25->ack_queue);
511 skb_queue_head_init(&ax25->reseq_queue); 511 skb_queue_head_init(&ax25->reseq_queue);
512 512
513 init_timer(&ax25->timer); 513 ax25_setup_timers(ax25);
514 init_timer(&ax25->t1timer);
515 init_timer(&ax25->t2timer);
516 init_timer(&ax25->t3timer);
517 init_timer(&ax25->idletimer);
518 514
519 ax25_fillin_cb(ax25, NULL); 515 ax25_fillin_cb(ax25, NULL);
520 516
@@ -1928,12 +1924,10 @@ static int ax25_info_show(struct seq_file *seq, void *v)
1928 ax25->paclen); 1924 ax25->paclen);
1929 1925
1930 if (ax25->sk != NULL) { 1926 if (ax25->sk != NULL) {
1931 bh_lock_sock(ax25->sk); 1927 seq_printf(seq, " %d %d %lu\n",
1932 seq_printf(seq," %d %d %ld\n",
1933 atomic_read(&ax25->sk->sk_wmem_alloc), 1928 atomic_read(&ax25->sk->sk_wmem_alloc),
1934 atomic_read(&ax25->sk->sk_rmem_alloc), 1929 atomic_read(&ax25->sk->sk_rmem_alloc),
1935 ax25->sk->sk_socket != NULL ? SOCK_INODE(ax25->sk->sk_socket)->i_ino : 0L); 1930 sock_i_ino(ax25->sk));
1936 bh_unlock_sock(ax25->sk);
1937 } else { 1931 } else {
1938 seq_puts(seq, " * * *\n"); 1932 seq_puts(seq, " * * *\n");
1939 } 1933 }
diff --git a/net/ax25/ax25_dev.c b/net/ax25/ax25_dev.c
index 528c874d9828..a7a0e0c9698b 100644
--- a/net/ax25/ax25_dev.c
+++ b/net/ax25/ax25_dev.c
@@ -82,7 +82,7 @@ void ax25_dev_device_up(struct net_device *dev)
82 ax25_dev->values[AX25_VALUES_DS_TIMEOUT]= AX25_DEF_DS_TIMEOUT; 82 ax25_dev->values[AX25_VALUES_DS_TIMEOUT]= AX25_DEF_DS_TIMEOUT;
83 83
84#if defined(CONFIG_AX25_DAMA_SLAVE) || defined(CONFIG_AX25_DAMA_MASTER) 84#if defined(CONFIG_AX25_DAMA_SLAVE) || defined(CONFIG_AX25_DAMA_MASTER)
85 init_timer(&ax25_dev->dama.slave_timer); 85 ax25_ds_setup_timer(ax25_dev);
86#endif 86#endif
87 87
88 spin_lock_bh(&ax25_dev_lock); 88 spin_lock_bh(&ax25_dev_lock);
diff --git a/net/ax25/ax25_ds_timer.c b/net/ax25/ax25_ds_timer.c
index c4e3b025d21c..2ce79df00680 100644
--- a/net/ax25/ax25_ds_timer.c
+++ b/net/ax25/ax25_ds_timer.c
@@ -40,13 +40,10 @@ static void ax25_ds_timeout(unsigned long);
40 * 1/10th of a second. 40 * 1/10th of a second.
41 */ 41 */
42 42
43static void ax25_ds_add_timer(ax25_dev *ax25_dev) 43void ax25_ds_setup_timer(ax25_dev *ax25_dev)
44{ 44{
45 struct timer_list *t = &ax25_dev->dama.slave_timer; 45 setup_timer(&ax25_dev->dama.slave_timer, ax25_ds_timeout,
46 t->data = (unsigned long) ax25_dev; 46 (unsigned long)ax25_dev);
47 t->function = &ax25_ds_timeout;
48 t->expires = jiffies + HZ;
49 add_timer(t);
50} 47}
51 48
52void ax25_ds_del_timer(ax25_dev *ax25_dev) 49void ax25_ds_del_timer(ax25_dev *ax25_dev)
@@ -60,10 +57,9 @@ void ax25_ds_set_timer(ax25_dev *ax25_dev)
60 if (ax25_dev == NULL) /* paranoia */ 57 if (ax25_dev == NULL) /* paranoia */
61 return; 58 return;
62 59
63 del_timer(&ax25_dev->dama.slave_timer);
64 ax25_dev->dama.slave_timeout = 60 ax25_dev->dama.slave_timeout =
65 msecs_to_jiffies(ax25_dev->values[AX25_VALUES_DS_TIMEOUT]) / 10; 61 msecs_to_jiffies(ax25_dev->values[AX25_VALUES_DS_TIMEOUT]) / 10;
66 ax25_ds_add_timer(ax25_dev); 62 mod_timer(&ax25_dev->dama.slave_timer, jiffies + HZ);
67} 63}
68 64
69/* 65/*
diff --git a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c
index 38c7f3087ec3..8672cd84fdf9 100644
--- a/net/ax25/ax25_route.c
+++ b/net/ax25/ax25_route.c
@@ -45,7 +45,7 @@ void ax25_rt_device_down(struct net_device *dev)
45{ 45{
46 ax25_route *s, *t, *ax25_rt; 46 ax25_route *s, *t, *ax25_rt;
47 47
48 write_lock(&ax25_route_lock); 48 write_lock_bh(&ax25_route_lock);
49 ax25_rt = ax25_route_list; 49 ax25_rt = ax25_route_list;
50 while (ax25_rt != NULL) { 50 while (ax25_rt != NULL) {
51 s = ax25_rt; 51 s = ax25_rt;
@@ -68,7 +68,7 @@ void ax25_rt_device_down(struct net_device *dev)
68 } 68 }
69 } 69 }
70 } 70 }
71 write_unlock(&ax25_route_lock); 71 write_unlock_bh(&ax25_route_lock);
72} 72}
73 73
74static int __must_check ax25_rt_add(struct ax25_routes_struct *route) 74static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
@@ -82,7 +82,7 @@ static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
82 if (route->digi_count > AX25_MAX_DIGIS) 82 if (route->digi_count > AX25_MAX_DIGIS)
83 return -EINVAL; 83 return -EINVAL;
84 84
85 write_lock(&ax25_route_lock); 85 write_lock_bh(&ax25_route_lock);
86 86
87 ax25_rt = ax25_route_list; 87 ax25_rt = ax25_route_list;
88 while (ax25_rt != NULL) { 88 while (ax25_rt != NULL) {
@@ -92,7 +92,7 @@ static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
92 ax25_rt->digipeat = NULL; 92 ax25_rt->digipeat = NULL;
93 if (route->digi_count != 0) { 93 if (route->digi_count != 0) {
94 if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) { 94 if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
95 write_unlock(&ax25_route_lock); 95 write_unlock_bh(&ax25_route_lock);
96 return -ENOMEM; 96 return -ENOMEM;
97 } 97 }
98 ax25_rt->digipeat->lastrepeat = -1; 98 ax25_rt->digipeat->lastrepeat = -1;
@@ -102,14 +102,14 @@ static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
102 ax25_rt->digipeat->calls[i] = route->digi_addr[i]; 102 ax25_rt->digipeat->calls[i] = route->digi_addr[i];
103 } 103 }
104 } 104 }
105 write_unlock(&ax25_route_lock); 105 write_unlock_bh(&ax25_route_lock);
106 return 0; 106 return 0;
107 } 107 }
108 ax25_rt = ax25_rt->next; 108 ax25_rt = ax25_rt->next;
109 } 109 }
110 110
111 if ((ax25_rt = kmalloc(sizeof(ax25_route), GFP_ATOMIC)) == NULL) { 111 if ((ax25_rt = kmalloc(sizeof(ax25_route), GFP_ATOMIC)) == NULL) {
112 write_unlock(&ax25_route_lock); 112 write_unlock_bh(&ax25_route_lock);
113 return -ENOMEM; 113 return -ENOMEM;
114 } 114 }
115 115
@@ -120,7 +120,7 @@ static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
120 ax25_rt->ip_mode = ' '; 120 ax25_rt->ip_mode = ' ';
121 if (route->digi_count != 0) { 121 if (route->digi_count != 0) {
122 if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) { 122 if ((ax25_rt->digipeat = kmalloc(sizeof(ax25_digi), GFP_ATOMIC)) == NULL) {
123 write_unlock(&ax25_route_lock); 123 write_unlock_bh(&ax25_route_lock);
124 kfree(ax25_rt); 124 kfree(ax25_rt);
125 return -ENOMEM; 125 return -ENOMEM;
126 } 126 }
@@ -133,7 +133,7 @@ static int __must_check ax25_rt_add(struct ax25_routes_struct *route)
133 } 133 }
134 ax25_rt->next = ax25_route_list; 134 ax25_rt->next = ax25_route_list;
135 ax25_route_list = ax25_rt; 135 ax25_route_list = ax25_rt;
136 write_unlock(&ax25_route_lock); 136 write_unlock_bh(&ax25_route_lock);
137 137
138 return 0; 138 return 0;
139} 139}
@@ -152,7 +152,7 @@ static int ax25_rt_del(struct ax25_routes_struct *route)
152 if ((ax25_dev = ax25_addr_ax25dev(&route->port_addr)) == NULL) 152 if ((ax25_dev = ax25_addr_ax25dev(&route->port_addr)) == NULL)
153 return -EINVAL; 153 return -EINVAL;
154 154
155 write_lock(&ax25_route_lock); 155 write_lock_bh(&ax25_route_lock);
156 156
157 ax25_rt = ax25_route_list; 157 ax25_rt = ax25_route_list;
158 while (ax25_rt != NULL) { 158 while (ax25_rt != NULL) {
@@ -174,7 +174,7 @@ static int ax25_rt_del(struct ax25_routes_struct *route)
174 } 174 }
175 } 175 }
176 } 176 }
177 write_unlock(&ax25_route_lock); 177 write_unlock_bh(&ax25_route_lock);
178 178
179 return 0; 179 return 0;
180} 180}
@@ -188,7 +188,7 @@ static int ax25_rt_opt(struct ax25_route_opt_struct *rt_option)
188 if ((ax25_dev = ax25_addr_ax25dev(&rt_option->port_addr)) == NULL) 188 if ((ax25_dev = ax25_addr_ax25dev(&rt_option->port_addr)) == NULL)
189 return -EINVAL; 189 return -EINVAL;
190 190
191 write_lock(&ax25_route_lock); 191 write_lock_bh(&ax25_route_lock);
192 192
193 ax25_rt = ax25_route_list; 193 ax25_rt = ax25_route_list;
194 while (ax25_rt != NULL) { 194 while (ax25_rt != NULL) {
@@ -216,7 +216,7 @@ static int ax25_rt_opt(struct ax25_route_opt_struct *rt_option)
216 } 216 }
217 217
218out: 218out:
219 write_unlock(&ax25_route_lock); 219 write_unlock_bh(&ax25_route_lock);
220 return err; 220 return err;
221} 221}
222 222
@@ -492,7 +492,7 @@ void __exit ax25_rt_free(void)
492{ 492{
493 ax25_route *s, *ax25_rt = ax25_route_list; 493 ax25_route *s, *ax25_rt = ax25_route_list;
494 494
495 write_lock(&ax25_route_lock); 495 write_lock_bh(&ax25_route_lock);
496 while (ax25_rt != NULL) { 496 while (ax25_rt != NULL) {
497 s = ax25_rt; 497 s = ax25_rt;
498 ax25_rt = ax25_rt->next; 498 ax25_rt = ax25_rt->next;
@@ -500,5 +500,5 @@ void __exit ax25_rt_free(void)
500 kfree(s->digipeat); 500 kfree(s->digipeat);
501 kfree(s); 501 kfree(s);
502 } 502 }
503 write_unlock(&ax25_route_lock); 503 write_unlock_bh(&ax25_route_lock);
504} 504}
diff --git a/net/ax25/ax25_timer.c b/net/ax25/ax25_timer.c
index 72594867fab6..db29ea71e80a 100644
--- a/net/ax25/ax25_timer.c
+++ b/net/ax25/ax25_timer.c
@@ -40,63 +40,45 @@ static void ax25_t2timer_expiry(unsigned long);
40static void ax25_t3timer_expiry(unsigned long); 40static void ax25_t3timer_expiry(unsigned long);
41static void ax25_idletimer_expiry(unsigned long); 41static void ax25_idletimer_expiry(unsigned long);
42 42
43void ax25_start_heartbeat(ax25_cb *ax25) 43void ax25_setup_timers(ax25_cb *ax25)
44{ 44{
45 del_timer(&ax25->timer); 45 setup_timer(&ax25->timer, ax25_heartbeat_expiry, (unsigned long)ax25);
46 46 setup_timer(&ax25->t1timer, ax25_t1timer_expiry, (unsigned long)ax25);
47 ax25->timer.data = (unsigned long)ax25; 47 setup_timer(&ax25->t2timer, ax25_t2timer_expiry, (unsigned long)ax25);
48 ax25->timer.function = &ax25_heartbeat_expiry; 48 setup_timer(&ax25->t3timer, ax25_t3timer_expiry, (unsigned long)ax25);
49 ax25->timer.expires = jiffies + 5 * HZ; 49 setup_timer(&ax25->idletimer, ax25_idletimer_expiry,
50 (unsigned long)ax25);
51}
50 52
51 add_timer(&ax25->timer); 53void ax25_start_heartbeat(ax25_cb *ax25)
54{
55 mod_timer(&ax25->timer, jiffies + 5 * HZ);
52} 56}
53 57
54void ax25_start_t1timer(ax25_cb *ax25) 58void ax25_start_t1timer(ax25_cb *ax25)
55{ 59{
56 del_timer(&ax25->t1timer); 60 mod_timer(&ax25->t1timer, jiffies + ax25->t1);
57
58 ax25->t1timer.data = (unsigned long)ax25;
59 ax25->t1timer.function = &ax25_t1timer_expiry;
60 ax25->t1timer.expires = jiffies + ax25->t1;
61
62 add_timer(&ax25->t1timer);
63} 61}
64 62
65void ax25_start_t2timer(ax25_cb *ax25) 63void ax25_start_t2timer(ax25_cb *ax25)
66{ 64{
67 del_timer(&ax25->t2timer); 65 mod_timer(&ax25->t2timer, jiffies + ax25->t2);
68
69 ax25->t2timer.data = (unsigned long)ax25;
70 ax25->t2timer.function = &ax25_t2timer_expiry;
71 ax25->t2timer.expires = jiffies + ax25->t2;
72
73 add_timer(&ax25->t2timer);
74} 66}
75 67
76void ax25_start_t3timer(ax25_cb *ax25) 68void ax25_start_t3timer(ax25_cb *ax25)
77{ 69{
78 del_timer(&ax25->t3timer); 70 if (ax25->t3 > 0)
79 71 mod_timer(&ax25->t3timer, jiffies + ax25->t3);
80 if (ax25->t3 > 0) { 72 else
81 ax25->t3timer.data = (unsigned long)ax25; 73 del_timer(&ax25->t3timer);
82 ax25->t3timer.function = &ax25_t3timer_expiry;
83 ax25->t3timer.expires = jiffies + ax25->t3;
84
85 add_timer(&ax25->t3timer);
86 }
87} 74}
88 75
89void ax25_start_idletimer(ax25_cb *ax25) 76void ax25_start_idletimer(ax25_cb *ax25)
90{ 77{
91 del_timer(&ax25->idletimer); 78 if (ax25->idle > 0)
92 79 mod_timer(&ax25->idletimer, jiffies + ax25->idle);
93 if (ax25->idle > 0) { 80 else
94 ax25->idletimer.data = (unsigned long)ax25; 81 del_timer(&ax25->idletimer);
95 ax25->idletimer.function = &ax25_idletimer_expiry;
96 ax25->idletimer.expires = jiffies + ax25->idle;
97
98 add_timer(&ax25->idletimer);
99 }
100} 82}
101 83
102void ax25_stop_heartbeat(ax25_cb *ax25) 84void ax25_stop_heartbeat(ax25_cb *ax25)
diff --git a/net/core/dev.c b/net/core/dev.c
index b3e19ae57f95..908f07c3bd7d 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1071,8 +1071,6 @@ int dev_close(struct net_device *dev)
1071 */ 1071 */
1072 call_netdevice_notifiers(NETDEV_GOING_DOWN, dev); 1072 call_netdevice_notifiers(NETDEV_GOING_DOWN, dev);
1073 1073
1074 dev_deactivate(dev);
1075
1076 clear_bit(__LINK_STATE_START, &dev->state); 1074 clear_bit(__LINK_STATE_START, &dev->state);
1077 1075
1078 /* Synchronize to scheduled poll. We cannot touch poll list, 1076 /* Synchronize to scheduled poll. We cannot touch poll list,
@@ -1083,6 +1081,8 @@ int dev_close(struct net_device *dev)
1083 */ 1081 */
1084 smp_mb__after_clear_bit(); /* Commit netif_running(). */ 1082 smp_mb__after_clear_bit(); /* Commit netif_running(). */
1085 1083
1084 dev_deactivate(dev);
1085
1086 /* 1086 /*
1087 * Call the device specific close. This cannot fail. 1087 * Call the device specific close. This cannot fail.
1088 * Only if device is UP 1088 * Only if device is UP
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index a16cf1ec5e5e..7bb6a9a1256d 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -834,18 +834,12 @@ static void neigh_timer_handler(unsigned long arg)
834 } 834 }
835 if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) { 835 if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) {
836 struct sk_buff *skb = skb_peek(&neigh->arp_queue); 836 struct sk_buff *skb = skb_peek(&neigh->arp_queue);
837 /* keep skb alive even if arp_queue overflows */ 837
838 if (skb)
839 skb_get(skb);
840 write_unlock(&neigh->lock);
841 neigh->ops->solicit(neigh, skb); 838 neigh->ops->solicit(neigh, skb);
842 atomic_inc(&neigh->probes); 839 atomic_inc(&neigh->probes);
843 if (skb)
844 kfree_skb(skb);
845 } else {
846out:
847 write_unlock(&neigh->lock);
848 } 840 }
841out:
842 write_unlock(&neigh->lock);
849 843
850 if (notify) 844 if (notify)
851 neigh_update_notify(neigh); 845 neigh_update_notify(neigh);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 61ac8d06292c..ecb02afd52dc 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -504,7 +504,7 @@ int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id,
504 504
505EXPORT_SYMBOL_GPL(rtnl_put_cacheinfo); 505EXPORT_SYMBOL_GPL(rtnl_put_cacheinfo);
506 506
507static void set_operstate(struct net_device *dev, unsigned char transition) 507static int set_operstate(struct net_device *dev, unsigned char transition, bool send_notification)
508{ 508{
509 unsigned char operstate = dev->operstate; 509 unsigned char operstate = dev->operstate;
510 510
@@ -527,8 +527,12 @@ static void set_operstate(struct net_device *dev, unsigned char transition)
527 write_lock_bh(&dev_base_lock); 527 write_lock_bh(&dev_base_lock);
528 dev->operstate = operstate; 528 dev->operstate = operstate;
529 write_unlock_bh(&dev_base_lock); 529 write_unlock_bh(&dev_base_lock);
530 netdev_state_change(dev); 530
531 } 531 if (send_notification)
532 netdev_state_change(dev);
533 return 1;
534 } else
535 return 0;
532} 536}
533 537
534static void copy_rtnl_link_stats(struct rtnl_link_stats *a, 538static void copy_rtnl_link_stats(struct rtnl_link_stats *a,
@@ -822,6 +826,7 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
822 if (tb[IFLA_BROADCAST]) { 826 if (tb[IFLA_BROADCAST]) {
823 nla_memcpy(dev->broadcast, tb[IFLA_BROADCAST], dev->addr_len); 827 nla_memcpy(dev->broadcast, tb[IFLA_BROADCAST], dev->addr_len);
824 send_addr_notify = 1; 828 send_addr_notify = 1;
829 modified = 1;
825 } 830 }
826 831
827 if (ifm->ifi_flags || ifm->ifi_change) { 832 if (ifm->ifi_flags || ifm->ifi_change) {
@@ -834,16 +839,23 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
834 dev_change_flags(dev, flags); 839 dev_change_flags(dev, flags);
835 } 840 }
836 841
837 if (tb[IFLA_TXQLEN]) 842 if (tb[IFLA_TXQLEN]) {
838 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]); 843 if (dev->tx_queue_len != nla_get_u32(tb[IFLA_TXQLEN])) {
844 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
845 modified = 1;
846 }
847 }
839 848
840 if (tb[IFLA_OPERSTATE]) 849 if (tb[IFLA_OPERSTATE])
841 set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE])); 850 modified |= set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE]), false);
842 851
843 if (tb[IFLA_LINKMODE]) { 852 if (tb[IFLA_LINKMODE]) {
844 write_lock_bh(&dev_base_lock); 853 if (dev->link_mode != nla_get_u8(tb[IFLA_LINKMODE])) {
845 dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]); 854 write_lock_bh(&dev_base_lock);
846 write_unlock_bh(&dev_base_lock); 855 dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
856 write_lock_bh(&dev_base_lock);
857 modified = 1;
858 }
847 } 859 }
848 860
849 err = 0; 861 err = 0;
@@ -857,6 +869,10 @@ errout:
857 869
858 if (send_addr_notify) 870 if (send_addr_notify)
859 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev); 871 call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
872
873 if (modified)
874 netdev_state_change(dev);
875
860 return err; 876 return err;
861} 877}
862 878
@@ -974,7 +990,7 @@ struct net_device *rtnl_create_link(struct net *net, char *ifname,
974 if (tb[IFLA_TXQLEN]) 990 if (tb[IFLA_TXQLEN])
975 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]); 991 dev->tx_queue_len = nla_get_u32(tb[IFLA_TXQLEN]);
976 if (tb[IFLA_OPERSTATE]) 992 if (tb[IFLA_OPERSTATE])
977 set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE])); 993 set_operstate(dev, nla_get_u8(tb[IFLA_OPERSTATE]), true);
978 if (tb[IFLA_LINKMODE]) 994 if (tb[IFLA_LINKMODE])
979 dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]); 995 dev->link_mode = nla_get_u8(tb[IFLA_LINKMODE]);
980 996
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index cfc07dac636c..0d0fd28a9041 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2106,11 +2106,10 @@ int skb_append_datato_frags(struct sock *sk, struct sk_buff *skb,
2106/** 2106/**
2107 * skb_pull_rcsum - pull skb and update receive checksum 2107 * skb_pull_rcsum - pull skb and update receive checksum
2108 * @skb: buffer to update 2108 * @skb: buffer to update
2109 * @start: start of data before pull
2110 * @len: length of data pulled 2109 * @len: length of data pulled
2111 * 2110 *
2112 * This function performs an skb_pull on the packet and updates 2111 * This function performs an skb_pull on the packet and updates
2113 * update the CHECKSUM_COMPLETE checksum. It should be used on 2112 * the CHECKSUM_COMPLETE checksum. It should be used on
2114 * receive path processing instead of skb_pull unless you know 2113 * receive path processing instead of skb_pull unless you know
2115 * that the checksum difference is zero (e.g., a valid IP header) 2114 * that the checksum difference is zero (e.g., a valid IP header)
2116 * or you are setting ip_summed to CHECKSUM_NONE. 2115 * or you are setting ip_summed to CHECKSUM_NONE.
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 9d4555ec0b59..8219b7e0968d 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -96,7 +96,7 @@ static int ah_output(struct xfrm_state *x, struct sk_buff *skb)
96 96
97 ah->reserved = 0; 97 ah->reserved = 0;
98 ah->spi = x->id.spi; 98 ah->spi = x->id.spi;
99 ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq); 99 ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
100 100
101 spin_lock_bh(&x->lock); 101 spin_lock_bh(&x->lock);
102 err = ah_mac_digest(ahp, skb, ah->auth_data); 102 err = ah_mac_digest(ahp, skb, ah->auth_data);
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 8e17f65f4002..c663fa5339ee 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -368,7 +368,6 @@ static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb)
368 if (!(neigh->nud_state&NUD_VALID)) 368 if (!(neigh->nud_state&NUD_VALID))
369 printk(KERN_DEBUG "trying to ucast probe in NUD_INVALID\n"); 369 printk(KERN_DEBUG "trying to ucast probe in NUD_INVALID\n");
370 dst_ha = neigh->ha; 370 dst_ha = neigh->ha;
371 read_lock_bh(&neigh->lock);
372 } else if ((probes -= neigh->parms->app_probes) < 0) { 371 } else if ((probes -= neigh->parms->app_probes) < 0) {
373#ifdef CONFIG_ARPD 372#ifdef CONFIG_ARPD
374 neigh_app_ns(neigh); 373 neigh_app_ns(neigh);
@@ -378,8 +377,6 @@ static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb)
378 377
379 arp_send(ARPOP_REQUEST, ETH_P_ARP, target, dev, saddr, 378 arp_send(ARPOP_REQUEST, ETH_P_ARP, target, dev, saddr,
380 dst_ha, dev->dev_addr, NULL); 379 dst_ha, dev->dev_addr, NULL);
381 if (dst_ha)
382 read_unlock_bh(&neigh->lock);
383} 380}
384 381
385static int arp_ignore(struct in_device *in_dev, __be32 sip, __be32 tip) 382static int arp_ignore(struct in_device *in_dev, __be32 sip, __be32 tip)
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index 258d17631b4b..091e6709f831 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -199,7 +199,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
199 } 199 }
200 200
201 esph->spi = x->id.spi; 201 esph->spi = x->id.spi;
202 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq); 202 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
203 203
204 sg_init_table(sg, nfrags); 204 sg_init_table(sg, nfrags);
205 skb_to_sgvec(skb, sg, 205 skb_to_sgvec(skb, sg,
@@ -210,7 +210,8 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
210 aead_givcrypt_set_callback(req, 0, esp_output_done, skb); 210 aead_givcrypt_set_callback(req, 0, esp_output_done, skb);
211 aead_givcrypt_set_crypt(req, sg, sg, clen, iv); 211 aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
212 aead_givcrypt_set_assoc(req, asg, sizeof(*esph)); 212 aead_givcrypt_set_assoc(req, asg, sizeof(*esph));
213 aead_givcrypt_set_giv(req, esph->enc_data, XFRM_SKB_CB(skb)->seq); 213 aead_givcrypt_set_giv(req, esph->enc_data,
214 XFRM_SKB_CB(skb)->seq.output);
214 215
215 ESP_SKB_CB(skb)->tmp = tmp; 216 ESP_SKB_CB(skb)->tmp = tmp;
216 err = crypto_aead_givencrypt(req); 217 err = crypto_aead_givencrypt(req);
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index f5fba3f71c06..1ff446d0fa8b 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1762,11 +1762,9 @@ static struct leaf *trie_leafindex(struct trie *t, int index)
1762{ 1762{
1763 struct leaf *l = trie_firstleaf(t); 1763 struct leaf *l = trie_firstleaf(t);
1764 1764
1765 while (index-- > 0) { 1765 while (l && index-- > 0)
1766 l = trie_nextleaf(l); 1766 l = trie_nextleaf(l);
1767 if (!l) 1767
1768 break;
1769 }
1770 return l; 1768 return l;
1771} 1769}
1772 1770
@@ -2461,6 +2459,84 @@ static const struct file_operations fib_trie_fops = {
2461 .release = seq_release_net, 2459 .release = seq_release_net,
2462}; 2460};
2463 2461
2462struct fib_route_iter {
2463 struct seq_net_private p;
2464 struct trie *main_trie;
2465 loff_t pos;
2466 t_key key;
2467};
2468
2469static struct leaf *fib_route_get_idx(struct fib_route_iter *iter, loff_t pos)
2470{
2471 struct leaf *l = NULL;
2472 struct trie *t = iter->main_trie;
2473
2474 /* use cache location of last found key */
2475 if (iter->pos > 0 && pos >= iter->pos && (l = fib_find_node(t, iter->key)))
2476 pos -= iter->pos;
2477 else {
2478 iter->pos = 0;
2479 l = trie_firstleaf(t);
2480 }
2481
2482 while (l && pos-- > 0) {
2483 iter->pos++;
2484 l = trie_nextleaf(l);
2485 }
2486
2487 if (l)
2488 iter->key = pos; /* remember it */
2489 else
2490 iter->pos = 0; /* forget it */
2491
2492 return l;
2493}
2494
2495static void *fib_route_seq_start(struct seq_file *seq, loff_t *pos)
2496 __acquires(RCU)
2497{
2498 struct fib_route_iter *iter = seq->private;
2499 struct fib_table *tb;
2500
2501 rcu_read_lock();
2502 tb = fib_get_table(iter->p.net, RT_TABLE_MAIN);
2503 if (!tb)
2504 return NULL;
2505
2506 iter->main_trie = (struct trie *) tb->tb_data;
2507 if (*pos == 0)
2508 return SEQ_START_TOKEN;
2509 else
2510 return fib_route_get_idx(iter, *pos - 1);
2511}
2512
2513static void *fib_route_seq_next(struct seq_file *seq, void *v, loff_t *pos)
2514{
2515 struct fib_route_iter *iter = seq->private;
2516 struct leaf *l = v;
2517
2518 ++*pos;
2519 if (v == SEQ_START_TOKEN) {
2520 iter->pos = 0;
2521 l = trie_firstleaf(iter->main_trie);
2522 } else {
2523 iter->pos++;
2524 l = trie_nextleaf(l);
2525 }
2526
2527 if (l)
2528 iter->key = l->key;
2529 else
2530 iter->pos = 0;
2531 return l;
2532}
2533
2534static void fib_route_seq_stop(struct seq_file *seq, void *v)
2535 __releases(RCU)
2536{
2537 rcu_read_unlock();
2538}
2539
2464static unsigned fib_flag_trans(int type, __be32 mask, const struct fib_info *fi) 2540static unsigned fib_flag_trans(int type, __be32 mask, const struct fib_info *fi)
2465{ 2541{
2466 static unsigned type2flags[RTN_MAX + 1] = { 2542 static unsigned type2flags[RTN_MAX + 1] = {
@@ -2484,7 +2560,6 @@ static unsigned fib_flag_trans(int type, __be32 mask, const struct fib_info *fi)
2484 */ 2560 */
2485static int fib_route_seq_show(struct seq_file *seq, void *v) 2561static int fib_route_seq_show(struct seq_file *seq, void *v)
2486{ 2562{
2487 const struct fib_trie_iter *iter = seq->private;
2488 struct leaf *l = v; 2563 struct leaf *l = v;
2489 struct leaf_info *li; 2564 struct leaf_info *li;
2490 struct hlist_node *node; 2565 struct hlist_node *node;
@@ -2496,12 +2571,6 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2496 return 0; 2571 return 0;
2497 } 2572 }
2498 2573
2499 if (iter->trie == iter->trie_local)
2500 return 0;
2501
2502 if (IS_TNODE(l))
2503 return 0;
2504
2505 hlist_for_each_entry_rcu(li, node, &l->list, hlist) { 2574 hlist_for_each_entry_rcu(li, node, &l->list, hlist) {
2506 struct fib_alias *fa; 2575 struct fib_alias *fa;
2507 __be32 mask, prefix; 2576 __be32 mask, prefix;
@@ -2544,16 +2613,16 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2544} 2613}
2545 2614
2546static const struct seq_operations fib_route_seq_ops = { 2615static const struct seq_operations fib_route_seq_ops = {
2547 .start = fib_trie_seq_start, 2616 .start = fib_route_seq_start,
2548 .next = fib_trie_seq_next, 2617 .next = fib_route_seq_next,
2549 .stop = fib_trie_seq_stop, 2618 .stop = fib_route_seq_stop,
2550 .show = fib_route_seq_show, 2619 .show = fib_route_seq_show,
2551}; 2620};
2552 2621
2553static int fib_route_seq_open(struct inode *inode, struct file *file) 2622static int fib_route_seq_open(struct inode *inode, struct file *file)
2554{ 2623{
2555 return seq_open_net(inode, file, &fib_route_seq_ops, 2624 return seq_open_net(inode, file, &fib_route_seq_ops,
2556 sizeof(struct fib_trie_iter)); 2625 sizeof(struct fib_route_iter));
2557} 2626}
2558 2627
2559static const struct file_operations fib_route_fops = { 2628static const struct file_operations fib_route_fops = {
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 9cac6c034abd..1aba606f6bbb 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -120,8 +120,6 @@ void inet_listen_wlock(struct inet_hashinfo *hashinfo)
120 } 120 }
121} 121}
122 122
123EXPORT_SYMBOL(inet_listen_wlock);
124
125/* 123/*
126 * Don't inline this cruft. Here are some nice properties to exploit here. The 124 * Don't inline this cruft. Here are some nice properties to exploit here. The
127 * BSD API does not allow a listening sock to specify the remote port nor the 125 * BSD API does not allow a listening sock to specify the remote port nor the
@@ -494,7 +492,6 @@ out:
494 return ret; 492 return ret;
495 } 493 }
496} 494}
497EXPORT_SYMBOL_GPL(__inet_hash_connect);
498 495
499/* 496/*
500 * Bind a port for a connect operation and hash it. 497 * Bind a port for a connect operation and hash it.
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 754b0a5bbfe9..de0572c88859 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -514,11 +514,6 @@ static int do_ip_setsockopt(struct sock *sk, int level,
514 val &= ~3; 514 val &= ~3;
515 val |= inet->tos & 3; 515 val |= inet->tos & 3;
516 } 516 }
517 if (IPTOS_PREC(val) >= IPTOS_PREC_CRITIC_ECP &&
518 !capable(CAP_NET_ADMIN)) {
519 err = -EPERM;
520 break;
521 }
522 if (inet->tos != val) { 517 if (inet->tos != val) {
523 inet->tos = val; 518 inet->tos = val;
524 sk->sk_priority = rt_tos2priority(val); 519 sk->sk_priority = rt_tos2priority(val);
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c
index 379c8e04c36c..2ff0c8233e47 100644
--- a/net/ipv6/ah6.c
+++ b/net/ipv6/ah6.c
@@ -283,7 +283,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
283 283
284 ah->reserved = 0; 284 ah->reserved = 0;
285 ah->spi = x->id.spi; 285 ah->spi = x->id.spi;
286 ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq); 286 ah->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
287 287
288 spin_lock_bh(&x->lock); 288 spin_lock_bh(&x->lock);
289 err = ah_mac_digest(ahp, skb, ah->auth_data); 289 err = ah_mac_digest(ahp, skb, ah->auth_data);
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
index 8e0f1428c716..0ec1402320ea 100644
--- a/net/ipv6/esp6.c
+++ b/net/ipv6/esp6.c
@@ -188,7 +188,7 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
188 *skb_mac_header(skb) = IPPROTO_ESP; 188 *skb_mac_header(skb) = IPPROTO_ESP;
189 189
190 esph->spi = x->id.spi; 190 esph->spi = x->id.spi;
191 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq); 191 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output);
192 192
193 sg_init_table(sg, nfrags); 193 sg_init_table(sg, nfrags);
194 skb_to_sgvec(skb, sg, 194 skb_to_sgvec(skb, sg,
@@ -199,7 +199,8 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb)
199 aead_givcrypt_set_callback(req, 0, esp_output_done, skb); 199 aead_givcrypt_set_callback(req, 0, esp_output_done, skb);
200 aead_givcrypt_set_crypt(req, sg, sg, clen, iv); 200 aead_givcrypt_set_crypt(req, sg, sg, clen, iv);
201 aead_givcrypt_set_assoc(req, asg, sizeof(*esph)); 201 aead_givcrypt_set_assoc(req, asg, sizeof(*esph));
202 aead_givcrypt_set_giv(req, esph->enc_data, XFRM_SKB_CB(skb)->seq); 202 aead_givcrypt_set_giv(req, esph->enc_data,
203 XFRM_SKB_CB(skb)->seq.output);
203 204
204 ESP_SKB_CB(skb)->tmp = tmp; 205 ESP_SKB_CB(skb)->tmp = tmp;
205 err = crypto_aead_givencrypt(req); 206 err = crypto_aead_givencrypt(req);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 9ac6ca2521c3..8b67ca07467d 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -621,7 +621,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
621 * or if the skb it not generated by a local socket. (This last 621 * or if the skb it not generated by a local socket. (This last
622 * check should be redundant, but it's free.) 622 * check should be redundant, but it's free.)
623 */ 623 */
624 if (!np || np->pmtudisc >= IPV6_PMTUDISC_DO) { 624 if (!skb->local_df) {
625 skb->dev = skb->dst->dev; 625 skb->dev = skb->dst->dev;
626 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev); 626 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev);
627 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGFAILS); 627 IP6_INC_STATS(ip6_dst_idev(skb->dst), IPSTATS_MIB_FRAGFAILS);
@@ -1420,6 +1420,10 @@ int ip6_push_pending_frames(struct sock *sk)
1420 tmp_skb->sk = NULL; 1420 tmp_skb->sk = NULL;
1421 } 1421 }
1422 1422
1423 /* Allow local fragmentation. */
1424 if (np->pmtudisc < IPV6_PMTUDISC_DO)
1425 skb->local_df = 1;
1426
1423 ipv6_addr_copy(final_dst, &fl->fl6_dst); 1427 ipv6_addr_copy(final_dst, &fl->fl6_dst);
1424 __skb_pull(skb, skb_network_header_len(skb)); 1428 __skb_pull(skb, skb_network_header_len(skb));
1425 if (opt && opt->opt_flen) 1429 if (opt && opt->opt_flen)
diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
index b34c58c65656..79ccfb080733 100644
--- a/net/ipv6/xfrm6_output.c
+++ b/net/ipv6/xfrm6_output.c
@@ -36,7 +36,7 @@ static int xfrm6_tunnel_check_size(struct sk_buff *skb)
36 if (mtu < IPV6_MIN_MTU) 36 if (mtu < IPV6_MIN_MTU)
37 mtu = IPV6_MIN_MTU; 37 mtu = IPV6_MIN_MTU;
38 38
39 if (skb->len > mtu) { 39 if (!skb->local_df && skb->len > mtu) {
40 skb->dev = dst->dev; 40 skb->dev = dst->dev;
41 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev); 41 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu, skb->dev);
42 ret = -EMSGSIZE; 42 ret = -EMSGSIZE;
diff --git a/net/key/af_key.c b/net/key/af_key.c
index b3ac85e808ac..1c853927810a 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2291,6 +2291,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
2291 return 0; 2291 return 0;
2292 2292
2293out: 2293out:
2294 xp->dead = 1;
2294 xfrm_policy_destroy(xp); 2295 xfrm_policy_destroy(xp);
2295 return err; 2296 return err;
2296} 2297}
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 202d7fa09483..62567959b66e 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -945,7 +945,7 @@ static int tcp_packet(struct nf_conn *ct,
945 945
946 ct->proto.tcp.state = new_state; 946 ct->proto.tcp.state = new_state;
947 if (old_state != new_state 947 if (old_state != new_state
948 && new_state == TCP_CONNTRACK_CLOSE) 948 && new_state == TCP_CONNTRACK_FIN_WAIT)
949 ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT; 949 ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT;
950 timeout = ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans 950 timeout = ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans
951 && tcp_timeouts[new_state] > nf_ct_tcp_timeout_max_retrans 951 && tcp_timeouts[new_state] > nf_ct_tcp_timeout_max_retrans
diff --git a/net/netfilter/xt_SECMARK.c b/net/netfilter/xt_SECMARK.c
index 7708e2084ce2..c0284856ccd4 100644
--- a/net/netfilter/xt_SECMARK.c
+++ b/net/netfilter/xt_SECMARK.c
@@ -111,7 +111,7 @@ secmark_tg_check(const char *tablename, const void *entry,
111 return true; 111 return true;
112} 112}
113 113
114void secmark_tg_destroy(const struct xt_target *target, void *targinfo) 114static void secmark_tg_destroy(const struct xt_target *target, void *targinfo)
115{ 115{
116 switch (mode) { 116 switch (mode) {
117 case SECMARK_MODE_SEL: 117 case SECMARK_MODE_SEL:
diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c
index 9a8ea0195c4f..fd462313471c 100644
--- a/net/netlabel/netlabel_domainhash.c
+++ b/net/netlabel/netlabel_domainhash.c
@@ -150,11 +150,11 @@ static struct netlbl_dom_map *netlbl_domhsh_search_def(const char *domain)
150 entry = netlbl_domhsh_search(domain); 150 entry = netlbl_domhsh_search(domain);
151 if (entry == NULL) { 151 if (entry == NULL) {
152 entry = rcu_dereference(netlbl_domhsh_def); 152 entry = rcu_dereference(netlbl_domhsh_def);
153 if (entry != NULL && entry->valid) 153 if (entry != NULL && !entry->valid)
154 return entry; 154 entry = NULL;
155 } 155 }
156 156
157 return NULL; 157 return entry;
158} 158}
159 159
160/* 160/*
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c
index 42e81fd8cc49..3e745b72fded 100644
--- a/net/netlabel/netlabel_unlabeled.c
+++ b/net/netlabel/netlabel_unlabeled.c
@@ -180,6 +180,7 @@ static void netlbl_unlabel_audit_addr4(struct audit_buffer *audit_buf,
180 } 180 }
181} 181}
182 182
183#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
183/** 184/**
184 * netlbl_unlabel_audit_addr6 - Audit an IPv6 address 185 * netlbl_unlabel_audit_addr6 - Audit an IPv6 address
185 * @audit_buf: audit buffer 186 * @audit_buf: audit buffer
@@ -213,6 +214,7 @@ static void netlbl_unlabel_audit_addr6(struct audit_buffer *audit_buf,
213 audit_log_format(audit_buf, " src_prefixlen=%d", mask_len); 214 audit_log_format(audit_buf, " src_prefixlen=%d", mask_len);
214 } 215 }
215} 216}
217#endif /* IPv6 */
216 218
217/* 219/*
218 * Unlabeled Connection Hash Table Functions 220 * Unlabeled Connection Hash Table Functions
@@ -617,8 +619,6 @@ static int netlbl_unlhsh_add(struct net *net,
617 int ifindex; 619 int ifindex;
618 struct net_device *dev; 620 struct net_device *dev;
619 struct netlbl_unlhsh_iface *iface; 621 struct netlbl_unlhsh_iface *iface;
620 struct in_addr *addr4, *mask4;
621 struct in6_addr *addr6, *mask6;
622 struct audit_buffer *audit_buf = NULL; 622 struct audit_buffer *audit_buf = NULL;
623 char *secctx = NULL; 623 char *secctx = NULL;
624 u32 secctx_len; 624 u32 secctx_len;
@@ -651,7 +651,9 @@ static int netlbl_unlhsh_add(struct net *net,
651 audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_STCADD, 651 audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_STCADD,
652 audit_info); 652 audit_info);
653 switch (addr_len) { 653 switch (addr_len) {
654 case sizeof(struct in_addr): 654 case sizeof(struct in_addr): {
655 struct in_addr *addr4, *mask4;
656
655 addr4 = (struct in_addr *)addr; 657 addr4 = (struct in_addr *)addr;
656 mask4 = (struct in_addr *)mask; 658 mask4 = (struct in_addr *)mask;
657 ret_val = netlbl_unlhsh_add_addr4(iface, addr4, mask4, secid); 659 ret_val = netlbl_unlhsh_add_addr4(iface, addr4, mask4, secid);
@@ -661,8 +663,11 @@ static int netlbl_unlhsh_add(struct net *net,
661 addr4->s_addr, 663 addr4->s_addr,
662 mask4->s_addr); 664 mask4->s_addr);
663 break; 665 break;
666 }
664#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 667#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
665 case sizeof(struct in6_addr): 668 case sizeof(struct in6_addr): {
669 struct in6_addr *addr6, *mask6;
670
666 addr6 = (struct in6_addr *)addr; 671 addr6 = (struct in6_addr *)addr;
667 mask6 = (struct in6_addr *)mask; 672 mask6 = (struct in6_addr *)mask;
668 ret_val = netlbl_unlhsh_add_addr6(iface, addr6, mask6, secid); 673 ret_val = netlbl_unlhsh_add_addr6(iface, addr6, mask6, secid);
@@ -671,6 +676,7 @@ static int netlbl_unlhsh_add(struct net *net,
671 dev_name, 676 dev_name,
672 addr6, mask6); 677 addr6, mask6);
673 break; 678 break;
679 }
674#endif /* IPv6 */ 680#endif /* IPv6 */
675 default: 681 default:
676 ret_val = -EINVAL; 682 ret_val = -EINVAL;
@@ -1741,10 +1747,6 @@ int netlbl_unlabel_getattr(const struct sk_buff *skb,
1741 u16 family, 1747 u16 family,
1742 struct netlbl_lsm_secattr *secattr) 1748 struct netlbl_lsm_secattr *secattr)
1743{ 1749{
1744 struct iphdr *hdr4;
1745 struct ipv6hdr *hdr6;
1746 struct netlbl_unlhsh_addr4 *addr4;
1747 struct netlbl_unlhsh_addr6 *addr6;
1748 struct netlbl_unlhsh_iface *iface; 1750 struct netlbl_unlhsh_iface *iface;
1749 1751
1750 rcu_read_lock(); 1752 rcu_read_lock();
@@ -1752,21 +1754,29 @@ int netlbl_unlabel_getattr(const struct sk_buff *skb,
1752 if (iface == NULL) 1754 if (iface == NULL)
1753 goto unlabel_getattr_nolabel; 1755 goto unlabel_getattr_nolabel;
1754 switch (family) { 1756 switch (family) {
1755 case PF_INET: 1757 case PF_INET: {
1758 struct iphdr *hdr4;
1759 struct netlbl_unlhsh_addr4 *addr4;
1760
1756 hdr4 = ip_hdr(skb); 1761 hdr4 = ip_hdr(skb);
1757 addr4 = netlbl_unlhsh_search_addr4(hdr4->saddr, iface); 1762 addr4 = netlbl_unlhsh_search_addr4(hdr4->saddr, iface);
1758 if (addr4 == NULL) 1763 if (addr4 == NULL)
1759 goto unlabel_getattr_nolabel; 1764 goto unlabel_getattr_nolabel;
1760 secattr->attr.secid = addr4->secid; 1765 secattr->attr.secid = addr4->secid;
1761 break; 1766 break;
1767 }
1762#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1768#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1763 case PF_INET6: 1769 case PF_INET6: {
1770 struct ipv6hdr *hdr6;
1771 struct netlbl_unlhsh_addr6 *addr6;
1772
1764 hdr6 = ipv6_hdr(skb); 1773 hdr6 = ipv6_hdr(skb);
1765 addr6 = netlbl_unlhsh_search_addr6(&hdr6->saddr, iface); 1774 addr6 = netlbl_unlhsh_search_addr6(&hdr6->saddr, iface);
1766 if (addr6 == NULL) 1775 if (addr6 == NULL)
1767 goto unlabel_getattr_nolabel; 1776 goto unlabel_getattr_nolabel;
1768 secattr->attr.secid = addr6->secid; 1777 secattr->attr.secid = addr6->secid;
1769 break; 1778 break;
1779 }
1770#endif /* IPv6 */ 1780#endif /* IPv6 */
1771 default: 1781 default:
1772 goto unlabel_getattr_nolabel; 1782 goto unlabel_getattr_nolabel;
diff --git a/net/netlabel/netlabel_user.c b/net/netlabel/netlabel_user.c
index 85a96a3fddaa..023fc8fe840d 100644
--- a/net/netlabel/netlabel_user.c
+++ b/net/netlabel/netlabel_user.c
@@ -96,7 +96,6 @@ int netlbl_netlink_init(void)
96struct audit_buffer *netlbl_audit_start_common(int type, 96struct audit_buffer *netlbl_audit_start_common(int type,
97 struct netlbl_audit *audit_info) 97 struct netlbl_audit *audit_info)
98{ 98{
99 struct audit_context *audit_ctx = current->audit_context;
100 struct audit_buffer *audit_buf; 99 struct audit_buffer *audit_buf;
101 char *secctx; 100 char *secctx;
102 u32 secctx_len; 101 u32 secctx_len;
@@ -104,7 +103,7 @@ struct audit_buffer *netlbl_audit_start_common(int type,
104 if (audit_enabled == 0) 103 if (audit_enabled == 0)
105 return NULL; 104 return NULL;
106 105
107 audit_buf = audit_log_start(audit_ctx, GFP_ATOMIC, type); 106 audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, type);
108 if (audit_buf == NULL) 107 if (audit_buf == NULL)
109 return NULL; 108 return NULL;
110 109
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 150579a21469..d16929c9b4bc 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -230,10 +230,8 @@ static void genl_unregister_mc_groups(struct genl_family *family)
230{ 230{
231 struct genl_multicast_group *grp, *tmp; 231 struct genl_multicast_group *grp, *tmp;
232 232
233 genl_lock();
234 list_for_each_entry_safe(grp, tmp, &family->mcast_groups, list) 233 list_for_each_entry_safe(grp, tmp, &family->mcast_groups, list)
235 __genl_unregister_mc_group(family, grp); 234 __genl_unregister_mc_group(family, grp);
236 genl_unlock();
237} 235}
238 236
239/** 237/**
@@ -396,10 +394,10 @@ int genl_unregister_family(struct genl_family *family)
396{ 394{
397 struct genl_family *rc; 395 struct genl_family *rc;
398 396
399 genl_unregister_mc_groups(family);
400
401 genl_lock(); 397 genl_lock();
402 398
399 genl_unregister_mc_groups(family);
400
403 list_for_each_entry(rc, genl_family_chain(family->id), family_list) { 401 list_for_each_entry(rc, genl_family_chain(family->id), family_list) {
404 if (family->id != rc->id || strcmp(rc->name, family->name)) 402 if (family->id != rc->id || strcmp(rc->name, family->name))
405 continue; 403 continue;
diff --git a/net/socket.c b/net/socket.c
index 7651de008502..b6d35cd72a50 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -701,6 +701,9 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
701{ 701{
702 struct socket *sock = file->private_data; 702 struct socket *sock = file->private_data;
703 703
704 if (unlikely(!sock->ops->splice_read))
705 return -EINVAL;
706
704 return sock->ops->splice_read(sock, ppos, pipe, len, flags); 707 return sock->ops->splice_read(sock, ppos, pipe, len, flags);
705} 708}
706 709
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 0e3ead7e11b9..1b395a41a8b2 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -495,7 +495,7 @@ rpc_lookup_parent(char *path, struct nameidata *nd)
495static void 495static void
496rpc_release_path(struct nameidata *nd) 496rpc_release_path(struct nameidata *nd)
497{ 497{
498 path_release(nd); 498 path_put(&nd->path);
499 rpc_put_mount(); 499 rpc_put_mount();
500} 500}
501 501
@@ -668,7 +668,8 @@ rpc_lookup_negative(char *path, struct nameidata *nd)
668 668
669 if ((error = rpc_lookup_parent(path, nd)) != 0) 669 if ((error = rpc_lookup_parent(path, nd)) != 0)
670 return ERR_PTR(error); 670 return ERR_PTR(error);
671 dentry = rpc_lookup_create(nd->dentry, nd->last.name, nd->last.len, 1); 671 dentry = rpc_lookup_create(nd->path.dentry, nd->last.name, nd->last.len,
672 1);
672 if (IS_ERR(dentry)) 673 if (IS_ERR(dentry))
673 rpc_release_path(nd); 674 rpc_release_path(nd);
674 return dentry; 675 return dentry;
@@ -695,7 +696,7 @@ rpc_mkdir(char *path, struct rpc_clnt *rpc_client)
695 dentry = rpc_lookup_negative(path, &nd); 696 dentry = rpc_lookup_negative(path, &nd);
696 if (IS_ERR(dentry)) 697 if (IS_ERR(dentry))
697 return dentry; 698 return dentry;
698 dir = nd.dentry->d_inode; 699 dir = nd.path.dentry->d_inode;
699 if ((error = __rpc_mkdir(dir, dentry)) != 0) 700 if ((error = __rpc_mkdir(dir, dentry)) != 0)
700 goto err_dput; 701 goto err_dput;
701 RPC_I(dentry->d_inode)->private = rpc_client; 702 RPC_I(dentry->d_inode)->private = rpc_client;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index eea75888805e..b8788fd5e3c6 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -718,16 +718,16 @@ static struct sock *unix_find_other(struct net *net,
718 goto put_fail; 718 goto put_fail;
719 719
720 err = -ECONNREFUSED; 720 err = -ECONNREFUSED;
721 if (!S_ISSOCK(nd.dentry->d_inode->i_mode)) 721 if (!S_ISSOCK(nd.path.dentry->d_inode->i_mode))
722 goto put_fail; 722 goto put_fail;
723 u=unix_find_socket_byinode(net, nd.dentry->d_inode); 723 u = unix_find_socket_byinode(net, nd.path.dentry->d_inode);
724 if (!u) 724 if (!u)
725 goto put_fail; 725 goto put_fail;
726 726
727 if (u->sk_type == type) 727 if (u->sk_type == type)
728 touch_atime(nd.mnt, nd.dentry); 728 touch_atime(nd.path.mnt, nd.path.dentry);
729 729
730 path_release(&nd); 730 path_put(&nd.path);
731 731
732 err=-EPROTOTYPE; 732 err=-EPROTOTYPE;
733 if (u->sk_type != type) { 733 if (u->sk_type != type) {
@@ -748,7 +748,7 @@ static struct sock *unix_find_other(struct net *net,
748 return u; 748 return u;
749 749
750put_fail: 750put_fail:
751 path_release(&nd); 751 path_put(&nd.path);
752fail: 752fail:
753 *error=err; 753 *error=err;
754 return NULL; 754 return NULL;
@@ -819,12 +819,12 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
819 */ 819 */
820 mode = S_IFSOCK | 820 mode = S_IFSOCK |
821 (SOCK_INODE(sock)->i_mode & ~current->fs->umask); 821 (SOCK_INODE(sock)->i_mode & ~current->fs->umask);
822 err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); 822 err = vfs_mknod(nd.path.dentry->d_inode, dentry, mode, 0);
823 if (err) 823 if (err)
824 goto out_mknod_dput; 824 goto out_mknod_dput;
825 mutex_unlock(&nd.dentry->d_inode->i_mutex); 825 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
826 dput(nd.dentry); 826 dput(nd.path.dentry);
827 nd.dentry = dentry; 827 nd.path.dentry = dentry;
828 828
829 addr->hash = UNIX_HASH_SIZE; 829 addr->hash = UNIX_HASH_SIZE;
830 } 830 }
@@ -842,8 +842,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
842 list = &unix_socket_table[addr->hash]; 842 list = &unix_socket_table[addr->hash];
843 } else { 843 } else {
844 list = &unix_socket_table[dentry->d_inode->i_ino & (UNIX_HASH_SIZE-1)]; 844 list = &unix_socket_table[dentry->d_inode->i_ino & (UNIX_HASH_SIZE-1)];
845 u->dentry = nd.dentry; 845 u->dentry = nd.path.dentry;
846 u->mnt = nd.mnt; 846 u->mnt = nd.path.mnt;
847 } 847 }
848 848
849 err = 0; 849 err = 0;
@@ -861,8 +861,8 @@ out:
861out_mknod_dput: 861out_mknod_dput:
862 dput(dentry); 862 dput(dentry);
863out_mknod_unlock: 863out_mknod_unlock:
864 mutex_unlock(&nd.dentry->d_inode->i_mutex); 864 mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
865 path_release(&nd); 865 path_put(&nd.path);
866out_mknod_parent: 866out_mknod_parent:
867 if (err==-EEXIST) 867 if (err==-EEXIST)
868 err=-EADDRINUSE; 868 err=-EADDRINUSE;
diff --git a/net/xfrm/Kconfig b/net/xfrm/Kconfig
index 8f9dbec319be..9201ef8ad90e 100644
--- a/net/xfrm/Kconfig
+++ b/net/xfrm/Kconfig
@@ -38,7 +38,7 @@ config XFRM_MIGRATE
38 38
39config XFRM_STATISTICS 39config XFRM_STATISTICS
40 bool "Transformation statistics (EXPERIMENTAL)" 40 bool "Transformation statistics (EXPERIMENTAL)"
41 depends on XFRM && PROC_FS && EXPERIMENTAL 41 depends on INET && XFRM && PROC_FS && EXPERIMENTAL
42 ---help--- 42 ---help---
43 This statistics is not a SNMP/MIB specification but shows 43 This statistics is not a SNMP/MIB specification but shows
44 statistics about transformation error (or almost error) factor 44 statistics about transformation error (or almost error) factor
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 4d6ebc633a94..62188c6a06dd 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -109,7 +109,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
109 if (encap_type < 0) { 109 if (encap_type < 0) {
110 async = 1; 110 async = 1;
111 x = xfrm_input_state(skb); 111 x = xfrm_input_state(skb);
112 seq = XFRM_SKB_CB(skb)->seq; 112 seq = XFRM_SKB_CB(skb)->seq.input;
113 goto resume; 113 goto resume;
114 } 114 }
115 115
@@ -175,7 +175,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
175 175
176 spin_unlock(&x->lock); 176 spin_unlock(&x->lock);
177 177
178 XFRM_SKB_CB(skb)->seq = seq; 178 XFRM_SKB_CB(skb)->seq.input = seq;
179 179
180 nexthdr = x->type->input(x, skb); 180 nexthdr = x->type->input(x, skb);
181 181
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index fc690368325f..569d377932c4 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -62,7 +62,7 @@ static int xfrm_output_one(struct sk_buff *skb, int err)
62 } 62 }
63 63
64 if (x->type->flags & XFRM_TYPE_REPLAY_PROT) { 64 if (x->type->flags & XFRM_TYPE_REPLAY_PROT) {
65 XFRM_SKB_CB(skb)->seq = ++x->replay.oseq; 65 XFRM_SKB_CB(skb)->seq.output = ++x->replay.oseq;
66 if (unlikely(x->replay.oseq == 0)) { 66 if (unlikely(x->replay.oseq == 0)) {
67 XFRM_INC_STATS(LINUX_MIB_XFRMOUTSTATESEQERROR); 67 XFRM_INC_STATS(LINUX_MIB_XFRMOUTSTATESEQERROR);
68 x->replay.oseq--; 68 x->replay.oseq--;
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 78338079b7f5..f971ca5645f8 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1105,6 +1105,7 @@ static struct xfrm_policy *xfrm_policy_construct(struct xfrm_userpolicy_info *p,
1105 return xp; 1105 return xp;
1106 error: 1106 error:
1107 *errp = err; 1107 *errp = err;
1108 xp->dead = 1;
1108 xfrm_policy_destroy(xp); 1109 xfrm_policy_destroy(xp);
1109 return NULL; 1110 return NULL;
1110} 1111}
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 6c18a14386a4..26146cbaa504 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1624,7 +1624,6 @@ sub dump_function($$) {
1624 1624
1625 $prototype =~ s/^static +//; 1625 $prototype =~ s/^static +//;
1626 $prototype =~ s/^extern +//; 1626 $prototype =~ s/^extern +//;
1627 $prototype =~ s/^fastcall +//;
1628 $prototype =~ s/^asmlinkage +//; 1627 $prototype =~ s/^asmlinkage +//;
1629 $prototype =~ s/^inline +//; 1628 $prototype =~ s/^inline +//;
1630 $prototype =~ s/^__inline__ +//; 1629 $prototype =~ s/^__inline__ +//;
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index e8529e2f51e5..187964e88af1 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -568,10 +568,11 @@ void avc_audit(u32 ssid, u32 tsid,
568 audit_log_format(ab, " capability=%d", a->u.cap); 568 audit_log_format(ab, " capability=%d", a->u.cap);
569 break; 569 break;
570 case AVC_AUDIT_DATA_FS: 570 case AVC_AUDIT_DATA_FS:
571 if (a->u.fs.dentry) { 571 if (a->u.fs.path.dentry) {
572 struct dentry *dentry = a->u.fs.dentry; 572 struct dentry *dentry = a->u.fs.path.dentry;
573 if (a->u.fs.mnt) { 573 if (a->u.fs.path.mnt) {
574 audit_log_d_path(ab, "path=", dentry, a->u.fs.mnt); 574 audit_log_d_path(ab, "path=",
575 &a->u.fs.path);
575 } else { 576 } else {
576 audit_log_format(ab, " name="); 577 audit_log_format(ab, " name=");
577 audit_log_untrustedstring(ab, dentry->d_name.name); 578 audit_log_untrustedstring(ab, dentry->d_name.name);
@@ -626,8 +627,12 @@ void avc_audit(u32 ssid, u32 tsid,
626 case AF_UNIX: 627 case AF_UNIX:
627 u = unix_sk(sk); 628 u = unix_sk(sk);
628 if (u->dentry) { 629 if (u->dentry) {
630 struct path path = {
631 .dentry = u->dentry,
632 .mnt = u->mnt
633 };
629 audit_log_d_path(ab, "path=", 634 audit_log_d_path(ab, "path=",
630 u->dentry, u->mnt); 635 &path);
631 break; 636 break;
632 } 637 }
633 if (!u->addr) 638 if (!u->addr)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 44f16d9041e3..75c2e99bfb81 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1356,8 +1356,8 @@ static inline int dentry_has_perm(struct task_struct *tsk,
1356 struct inode *inode = dentry->d_inode; 1356 struct inode *inode = dentry->d_inode;
1357 struct avc_audit_data ad; 1357 struct avc_audit_data ad;
1358 AVC_AUDIT_DATA_INIT(&ad,FS); 1358 AVC_AUDIT_DATA_INIT(&ad,FS);
1359 ad.u.fs.mnt = mnt; 1359 ad.u.fs.path.mnt = mnt;
1360 ad.u.fs.dentry = dentry; 1360 ad.u.fs.path.dentry = dentry;
1361 return inode_has_perm(tsk, inode, av, &ad); 1361 return inode_has_perm(tsk, inode, av, &ad);
1362} 1362}
1363 1363
@@ -1375,15 +1375,12 @@ static int file_has_perm(struct task_struct *tsk,
1375{ 1375{
1376 struct task_security_struct *tsec = tsk->security; 1376 struct task_security_struct *tsec = tsk->security;
1377 struct file_security_struct *fsec = file->f_security; 1377 struct file_security_struct *fsec = file->f_security;
1378 struct vfsmount *mnt = file->f_path.mnt; 1378 struct inode *inode = file->f_path.dentry->d_inode;
1379 struct dentry *dentry = file->f_path.dentry;
1380 struct inode *inode = dentry->d_inode;
1381 struct avc_audit_data ad; 1379 struct avc_audit_data ad;
1382 int rc; 1380 int rc;
1383 1381
1384 AVC_AUDIT_DATA_INIT(&ad, FS); 1382 AVC_AUDIT_DATA_INIT(&ad, FS);
1385 ad.u.fs.mnt = mnt; 1383 ad.u.fs.path = file->f_path;
1386 ad.u.fs.dentry = dentry;
1387 1384
1388 if (tsec->sid != fsec->sid) { 1385 if (tsec->sid != fsec->sid) {
1389 rc = avc_has_perm(tsec->sid, fsec->sid, 1386 rc = avc_has_perm(tsec->sid, fsec->sid,
@@ -1418,7 +1415,7 @@ static int may_create(struct inode *dir,
1418 sbsec = dir->i_sb->s_security; 1415 sbsec = dir->i_sb->s_security;
1419 1416
1420 AVC_AUDIT_DATA_INIT(&ad, FS); 1417 AVC_AUDIT_DATA_INIT(&ad, FS);
1421 ad.u.fs.dentry = dentry; 1418 ad.u.fs.path.dentry = dentry;
1422 1419
1423 rc = avc_has_perm(tsec->sid, dsec->sid, SECCLASS_DIR, 1420 rc = avc_has_perm(tsec->sid, dsec->sid, SECCLASS_DIR,
1424 DIR__ADD_NAME | DIR__SEARCH, 1421 DIR__ADD_NAME | DIR__SEARCH,
@@ -1476,7 +1473,7 @@ static int may_link(struct inode *dir,
1476 isec = dentry->d_inode->i_security; 1473 isec = dentry->d_inode->i_security;
1477 1474
1478 AVC_AUDIT_DATA_INIT(&ad, FS); 1475 AVC_AUDIT_DATA_INIT(&ad, FS);
1479 ad.u.fs.dentry = dentry; 1476 ad.u.fs.path.dentry = dentry;
1480 1477
1481 av = DIR__SEARCH; 1478 av = DIR__SEARCH;
1482 av |= (kind ? DIR__REMOVE_NAME : DIR__ADD_NAME); 1479 av |= (kind ? DIR__REMOVE_NAME : DIR__ADD_NAME);
@@ -1523,7 +1520,7 @@ static inline int may_rename(struct inode *old_dir,
1523 1520
1524 AVC_AUDIT_DATA_INIT(&ad, FS); 1521 AVC_AUDIT_DATA_INIT(&ad, FS);
1525 1522
1526 ad.u.fs.dentry = old_dentry; 1523 ad.u.fs.path.dentry = old_dentry;
1527 rc = avc_has_perm(tsec->sid, old_dsec->sid, SECCLASS_DIR, 1524 rc = avc_has_perm(tsec->sid, old_dsec->sid, SECCLASS_DIR,
1528 DIR__REMOVE_NAME | DIR__SEARCH, &ad); 1525 DIR__REMOVE_NAME | DIR__SEARCH, &ad);
1529 if (rc) 1526 if (rc)
@@ -1539,7 +1536,7 @@ static inline int may_rename(struct inode *old_dir,
1539 return rc; 1536 return rc;
1540 } 1537 }
1541 1538
1542 ad.u.fs.dentry = new_dentry; 1539 ad.u.fs.path.dentry = new_dentry;
1543 av = DIR__ADD_NAME | DIR__SEARCH; 1540 av = DIR__ADD_NAME | DIR__SEARCH;
1544 if (new_dentry->d_inode) 1541 if (new_dentry->d_inode)
1545 av |= DIR__REMOVE_NAME; 1542 av |= DIR__REMOVE_NAME;
@@ -1918,8 +1915,7 @@ static int selinux_bprm_set_security(struct linux_binprm *bprm)
1918 } 1915 }
1919 1916
1920 AVC_AUDIT_DATA_INIT(&ad, FS); 1917 AVC_AUDIT_DATA_INIT(&ad, FS);
1921 ad.u.fs.mnt = bprm->file->f_path.mnt; 1918 ad.u.fs.path = bprm->file->f_path;
1922 ad.u.fs.dentry = bprm->file->f_path.dentry;
1923 1919
1924 if (bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID) 1920 if (bprm->file->f_path.mnt->mnt_flags & MNT_NOSUID)
1925 newsid = tsec->sid; 1921 newsid = tsec->sid;
@@ -2315,7 +2311,7 @@ static int selinux_sb_kern_mount(struct super_block *sb, void *data)
2315 return rc; 2311 return rc;
2316 2312
2317 AVC_AUDIT_DATA_INIT(&ad,FS); 2313 AVC_AUDIT_DATA_INIT(&ad,FS);
2318 ad.u.fs.dentry = sb->s_root; 2314 ad.u.fs.path.dentry = sb->s_root;
2319 return superblock_has_perm(current, sb, FILESYSTEM__MOUNT, &ad); 2315 return superblock_has_perm(current, sb, FILESYSTEM__MOUNT, &ad);
2320} 2316}
2321 2317
@@ -2324,7 +2320,7 @@ static int selinux_sb_statfs(struct dentry *dentry)
2324 struct avc_audit_data ad; 2320 struct avc_audit_data ad;
2325 2321
2326 AVC_AUDIT_DATA_INIT(&ad,FS); 2322 AVC_AUDIT_DATA_INIT(&ad,FS);
2327 ad.u.fs.dentry = dentry->d_sb->s_root; 2323 ad.u.fs.path.dentry = dentry->d_sb->s_root;
2328 return superblock_has_perm(current, dentry->d_sb, FILESYSTEM__GETATTR, &ad); 2324 return superblock_has_perm(current, dentry->d_sb, FILESYSTEM__GETATTR, &ad);
2329} 2325}
2330 2326
@@ -2341,10 +2337,10 @@ static int selinux_mount(char * dev_name,
2341 return rc; 2337 return rc;
2342 2338
2343 if (flags & MS_REMOUNT) 2339 if (flags & MS_REMOUNT)
2344 return superblock_has_perm(current, nd->mnt->mnt_sb, 2340 return superblock_has_perm(current, nd->path.mnt->mnt_sb,
2345 FILESYSTEM__REMOUNT, NULL); 2341 FILESYSTEM__REMOUNT, NULL);
2346 else 2342 else
2347 return dentry_has_perm(current, nd->mnt, nd->dentry, 2343 return dentry_has_perm(current, nd->path.mnt, nd->path.dentry,
2348 FILE__MOUNTON); 2344 FILE__MOUNTON);
2349} 2345}
2350 2346
@@ -2587,7 +2583,7 @@ static int selinux_inode_setxattr(struct dentry *dentry, char *name, void *value
2587 return -EPERM; 2583 return -EPERM;
2588 2584
2589 AVC_AUDIT_DATA_INIT(&ad,FS); 2585 AVC_AUDIT_DATA_INIT(&ad,FS);
2590 ad.u.fs.dentry = dentry; 2586 ad.u.fs.path.dentry = dentry;
2591 2587
2592 rc = avc_has_perm(tsec->sid, isec->sid, isec->sclass, 2588 rc = avc_has_perm(tsec->sid, isec->sid, isec->sclass,
2593 FILE__RELABELFROM, &ad); 2589 FILE__RELABELFROM, &ad);
diff --git a/security/selinux/include/avc.h b/security/selinux/include/avc.h
index 80c28fa6621c..8e23d7a873a4 100644
--- a/security/selinux/include/avc.h
+++ b/security/selinux/include/avc.h
@@ -13,6 +13,7 @@
13#include <linux/spinlock.h> 13#include <linux/spinlock.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/in6.h> 15#include <linux/in6.h>
16#include <linux/path.h>
16#include <asm/system.h> 17#include <asm/system.h>
17#include "flask.h" 18#include "flask.h"
18#include "av_permissions.h" 19#include "av_permissions.h"
@@ -30,8 +31,6 @@ extern int selinux_enforcing;
30struct avc_entry; 31struct avc_entry;
31 32
32struct task_struct; 33struct task_struct;
33struct vfsmount;
34struct dentry;
35struct inode; 34struct inode;
36struct sock; 35struct sock;
37struct sk_buff; 36struct sk_buff;
@@ -46,8 +45,7 @@ struct avc_audit_data {
46 struct task_struct *tsk; 45 struct task_struct *tsk;
47 union { 46 union {
48 struct { 47 struct {
49 struct vfsmount *mnt; 48 struct path path;
50 struct dentry *dentry;
51 struct inode *inode; 49 struct inode *inode;
52 } fs; 50 } fs;
53 struct { 51 struct {
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 5b690482f8cb..2b5d6f72f678 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -325,7 +325,7 @@ static int smack_sb_statfs(struct dentry *dentry)
325static int smack_sb_mount(char *dev_name, struct nameidata *nd, 325static int smack_sb_mount(char *dev_name, struct nameidata *nd,
326 char *type, unsigned long flags, void *data) 326 char *type, unsigned long flags, void *data)
327{ 327{
328 struct superblock_smack *sbp = nd->mnt->mnt_sb->s_security; 328 struct superblock_smack *sbp = nd->path.mnt->mnt_sb->s_security;
329 329
330 return smk_curacc(sbp->smk_floor, MAY_WRITE); 330 return smk_curacc(sbp->smk_floor, MAY_WRITE);
331} 331}
diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index f97c1ba43a28..47cfa5186e34 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -149,13 +149,13 @@ struct snd_seq_client *snd_seq_client_use_ptr(int clientid)
149 } 149 }
150 spin_unlock_irqrestore(&clients_lock, flags); 150 spin_unlock_irqrestore(&clients_lock, flags);
151#ifdef CONFIG_KMOD 151#ifdef CONFIG_KMOD
152 if (!in_interrupt() && current->fs->root) { 152 if (!in_interrupt()) {
153 static char client_requested[SNDRV_SEQ_GLOBAL_CLIENTS]; 153 static char client_requested[SNDRV_SEQ_GLOBAL_CLIENTS];
154 static char card_requested[SNDRV_CARDS]; 154 static char card_requested[SNDRV_CARDS];
155 if (clientid < SNDRV_SEQ_GLOBAL_CLIENTS) { 155 if (clientid < SNDRV_SEQ_GLOBAL_CLIENTS) {
156 int idx; 156 int idx;
157 157
158 if (! client_requested[clientid] && current->fs->root) { 158 if (!client_requested[clientid]) {
159 client_requested[clientid] = 1; 159 client_requested[clientid] = 1;
160 for (idx = 0; idx < 15; idx++) { 160 for (idx = 0; idx < 15; idx++) {
161 if (seq_client_load[idx] < 0) 161 if (seq_client_load[idx] < 0)
diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
index 155dc7da4722..2f00ad28a2b7 100644
--- a/sound/core/seq/seq_device.c
+++ b/sound/core/seq/seq_device.c
@@ -149,9 +149,6 @@ void snd_seq_device_load_drivers(void)
149 if (snd_seq_in_init) 149 if (snd_seq_in_init)
150 return; 150 return;
151 151
152 if (! current->fs->root)
153 return;
154
155 mutex_lock(&ops_mutex); 152 mutex_lock(&ops_mutex);
156 list_for_each_entry(ops, &opslist, list) { 153 list_for_each_entry(ops, &opslist, list) {
157 if (! (ops->driver & DRIVER_LOADED) && 154 if (! (ops->driver & DRIVER_LOADED) &&
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 00cca4d6e562..812f91b3de5b 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -71,8 +71,6 @@ static DEFINE_MUTEX(sound_mutex);
71 */ 71 */
72void snd_request_card(int card) 72void snd_request_card(int card)
73{ 73{
74 if (! current->fs->root)
75 return;
76 if (snd_card_locked(card)) 74 if (snd_card_locked(card))
77 return; 75 return;
78 if (card < 0 || card >= cards_limit) 76 if (card < 0 || card >= cards_limit)
@@ -86,8 +84,6 @@ static void snd_request_other(int minor)
86{ 84{
87 char *str; 85 char *str;
88 86
89 if (! current->fs->root)
90 return;
91 switch (minor) { 87 switch (minor) {
92 case SNDRV_MINOR_SEQUENCER: str = "snd-seq"; break; 88 case SNDRV_MINOR_SEQUENCER: str = "snd-seq"; break;
93 case SNDRV_MINOR_TIMER: str = "snd-timer"; break; 89 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
diff --git a/sound/core/timer.c b/sound/core/timer.c
index aece465934b8..9d8184a2c2d0 100644
--- a/sound/core/timer.c
+++ b/sound/core/timer.c
@@ -150,8 +150,6 @@ static struct snd_timer *snd_timer_find(struct snd_timer_id *tid)
150 150
151static void snd_timer_request(struct snd_timer_id *tid) 151static void snd_timer_request(struct snd_timer_id *tid)
152{ 152{
153 if (! current->fs->root)
154 return;
155 switch (tid->dev_class) { 153 switch (tid->dev_class) {
156 case SNDRV_TIMER_CLASS_GLOBAL: 154 case SNDRV_TIMER_CLASS_GLOBAL:
157 if (tid->device < timer_limit) 155 if (tid->device < timer_limit)
diff --git a/sound/ppc/daca.c b/sound/ppc/daca.c
index 8432c16cd6ff..ca9452901a50 100644
--- a/sound/ppc/daca.c
+++ b/sound/ppc/daca.c
@@ -250,9 +250,8 @@ int __init snd_pmac_daca_init(struct snd_pmac *chip)
250 struct pmac_daca *mix; 250 struct pmac_daca *mix;
251 251
252#ifdef CONFIG_KMOD 252#ifdef CONFIG_KMOD
253 if (current->fs->root) 253 request_module("i2c-powermac");
254 request_module("i2c-powermac"); 254#endif /* CONFIG_KMOD */
255#endif /* CONFIG_KMOD */
256 255
257 mix = kzalloc(sizeof(*mix), GFP_KERNEL); 256 mix = kzalloc(sizeof(*mix), GFP_KERNEL);
258 if (! mix) 257 if (! mix)
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 71a7a9765429..3f8d7164cef9 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -1351,9 +1351,8 @@ int __init snd_pmac_tumbler_init(struct snd_pmac *chip)
1351 char *chipname; 1351 char *chipname;
1352 1352
1353#ifdef CONFIG_KMOD 1353#ifdef CONFIG_KMOD
1354 if (current->fs->root) 1354 request_module("i2c-powermac");
1355 request_module("i2c-powermac"); 1355#endif /* CONFIG_KMOD */
1356#endif /* CONFIG_KMOD */
1357 1356
1358 mix = kzalloc(sizeof(*mix), GFP_KERNEL); 1357 mix = kzalloc(sizeof(*mix), GFP_KERNEL);
1359 if (! mix) 1358 if (! mix)