aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/Makefile2
-rw-r--r--Documentation/DocBook/filesystems.tmpl101
-rw-r--r--Documentation/DocBook/kernel-api.tmpl60
-rw-r--r--Documentation/mips/time.README39
-rw-r--r--Makefile2
-rw-r--r--arch/cris/arch-v32/drivers/cryptocop.c1
-rw-r--r--arch/i386/kernel/apm.c2
-rw-r--r--arch/i386/kernel/io_apic.c66
-rw-r--r--arch/ia64/kernel/mca_drv.c95
-rw-r--r--arch/ia64/kernel/sal.c11
-rw-r--r--arch/ia64/kernel/setup.c2
-rw-r--r--arch/ia64/kernel/smp.c12
-rw-r--r--arch/mips/Kconfig3
-rw-r--r--arch/mips/au1000/common/prom.c2
-rw-r--r--arch/mips/au1000/common/setup.c2
-rw-r--r--arch/mips/au1000/common/time.c106
-rw-r--r--arch/mips/dec/time.c9
-rw-r--r--arch/mips/emma2rh/common/irq_emma2rh.c2
-rw-r--r--arch/mips/emma2rh/markeins/irq_markeins.c4
-rw-r--r--arch/mips/emma2rh/markeins/platform.c88
-rw-r--r--arch/mips/jmr3927/rbhma3100/irq.c3
-rw-r--r--arch/mips/jmr3927/rbhma3100/setup.c40
-rw-r--r--arch/mips/kernel/asm-offsets.c2
-rw-r--r--arch/mips/kernel/entry.S3
-rw-r--r--arch/mips/kernel/head.S3
-rw-r--r--arch/mips/kernel/r4k_switch.S5
-rw-r--r--arch/mips/kernel/scall32-o32.S2
-rw-r--r--arch/mips/kernel/scall64-64.S2
-rw-r--r--arch/mips/kernel/scall64-n32.S2
-rw-r--r--arch/mips/kernel/scall64-o32.S2
-rw-r--r--arch/mips/kernel/smp-mt.c154
-rw-r--r--arch/mips/kernel/smtc-asm.S7
-rw-r--r--arch/mips/kernel/smtc.c1
-rw-r--r--arch/mips/kernel/time.c319
-rw-r--r--arch/mips/kernel/traps.c2
-rw-r--r--arch/mips/kernel/vmlinux.lds.S10
-rw-r--r--arch/mips/lib-64/dump_tlb.c6
-rw-r--r--arch/mips/mips-boards/generic/memory.c2
-rw-r--r--arch/mips/mips-boards/generic/pci.c2
-rw-r--r--arch/mips/mips-boards/generic/time.c7
-rw-r--r--arch/mips/mm/c-sb1.c18
-rw-r--r--arch/mips/mm/pg-r4k.c30
-rw-r--r--arch/mips/mm/tlbex.c13
-rw-r--r--arch/mips/momentum/ocelot_g/ocelot_pld.h6
-rw-r--r--arch/mips/momentum/ocelot_g/setup.c5
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c12
-rw-r--r--arch/mips/philips/pnx8550/common/time.c4
-rw-r--r--arch/mips/pmc-sierra/yosemite/i2c-yosemite.c2
-rw-r--r--arch/mips/pmc-sierra/yosemite/smp.c6
-rw-r--r--arch/mips/sgi-ip27/ip27-timer.c16
-rw-r--r--arch/mips/sibyte/bcm1480/time.c33
-rw-r--r--arch/mips/sibyte/sb1250/time.c28
-rw-r--r--arch/mips/tx4927/common/smsc_fdc37m81x.c172
-rw-r--r--arch/mips/tx4927/common/tx4927_setup.c2
-rw-r--r--arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c8
-rw-r--r--arch/powerpc/kernel/Makefile1
-rw-r--r--arch/powerpc/kernel/btext.c2
-rw-r--r--arch/powerpc/kernel/head_64.S27
-rw-r--r--arch/powerpc/kernel/iommu.c77
-rw-r--r--arch/powerpc/kernel/perfmon_fsl_booke.c221
-rw-r--r--arch/powerpc/kernel/pmc.c2
-rw-r--r--arch/powerpc/kernel/traps.c18
-rw-r--r--arch/powerpc/kernel/vio.c4
-rw-r--r--arch/powerpc/lib/sstep.c5
-rw-r--r--arch/powerpc/mm/hugetlbpage.c3
-rw-r--r--arch/powerpc/oprofile/Makefile2
-rw-r--r--arch/powerpc/oprofile/common.c10
-rw-r--r--arch/powerpc/oprofile/op_model_7450.c2
-rw-r--r--arch/powerpc/oprofile/op_model_fsl_booke.c170
-rw-r--r--arch/powerpc/oprofile/op_model_power4.c2
-rw-r--r--arch/powerpc/oprofile/op_model_rs64.c2
-rw-r--r--arch/powerpc/platforms/iseries/iommu.c11
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c35
-rw-r--r--arch/powerpc/sysdev/dart.h1
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c8
-rw-r--r--arch/powerpc/sysdev/qe_lib/qe.c3
-rw-r--r--arch/ppc/kernel/traps.c18
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/setup.c12
-rw-r--r--arch/sh/boards/renesas/sh7710voipgw/setup.c105
-rw-r--r--arch/sh/boards/se/7300/irq.c20
-rw-r--r--arch/sh/boards/se/73180/irq.c47
-rw-r--r--arch/sh/boards/se/7343/irq.c90
-rw-r--r--arch/sh/boards/se/770x/irq.c80
-rw-r--r--arch/sh/boards/se/7751/irq.c85
-rw-r--r--arch/sh/boards/sh03/setup.c13
-rw-r--r--arch/sh/boards/snapgear/setup.c12
-rw-r--r--arch/sh/boards/titan/setup.c12
-rw-r--r--arch/sh/configs/r7780rp_defconfig174
-rw-r--r--arch/sh/configs/titan_defconfig101
-rw-r--r--arch/sh/drivers/dma/dma-sh.c42
-rw-r--r--arch/sh/kernel/cpu/irq/ipr.c106
-rw-r--r--arch/sh/kernel/cpu/irq/pint.c8
-rw-r--r--arch/sh/kernel/syscalls.S3
-rw-r--r--arch/sparc64/kernel/prom.c21
-rw-r--r--arch/sparc64/kernel/traps.c8
-rw-r--r--arch/um/Makefile21
-rw-r--r--arch/um/Makefile-i3864
-rw-r--r--arch/um/Makefile-x86_644
-rw-r--r--arch/um/drivers/ubd_kern.c319
-rw-r--r--arch/um/include/mconsole_kern.h1
-rw-r--r--arch/um/kernel/dyn.lds.S1
-rw-r--r--arch/um/kernel/tt/tracer.c1
-rw-r--r--arch/um/kernel/uml.lds.S1
-rw-r--r--arch/um/os-Linux/sys-i386/tls.c3
-rw-r--r--arch/um/os-Linux/tls.c1
-rw-r--r--arch/um/sys-i386/unmap.c11
-rw-r--r--arch/um/sys-x86_64/unmap.c11
-rw-r--r--arch/x86_64/ia32/ia32_signal.c5
-rw-r--r--block/cfq-iosched.c16
-rw-r--r--block/ll_rw_blk.c24
-rw-r--r--drivers/ata/ahci.c3
-rw-r--r--drivers/ata/ata_piix.c37
-rw-r--r--drivers/ata/libata-core.c1
-rw-r--r--drivers/ata/libata.h1
-rw-r--r--drivers/ata/sata_nv.c12
-rw-r--r--drivers/ata/sata_sis.c21
-rw-r--r--drivers/bluetooth/bluecard_cs.c2
-rw-r--r--drivers/ide/pci/generic.c2
-rw-r--r--drivers/ieee1394/eth1394.c20
-rw-r--r--drivers/isdn/gigaset/common.c2
-rw-r--r--drivers/md/dm-crypt.c11
-rw-r--r--drivers/message/i2o/exec-osm.c2
-rw-r--r--drivers/net/Kconfig6
-rw-r--r--drivers/net/arm/ep93xx_eth.c40
-rw-r--r--drivers/net/au1000_eth.c2
-rw-r--r--drivers/net/ehea/ehea_main.c11
-rw-r--r--drivers/net/irda/stir4200.c3
-rw-r--r--drivers/net/myri10ge/myri10ge.c1
-rw-r--r--drivers/net/s2io.c11
-rw-r--r--drivers/net/skge.c3
-rw-r--r--drivers/net/sky2.c9
-rw-r--r--drivers/net/tokenring/proteon.c9
-rw-r--r--drivers/net/tokenring/skisa.c9
-rw-r--r--drivers/net/wan/Kconfig2
-rw-r--r--drivers/net/wan/n2.c6
-rw-r--r--drivers/scsi/dpt/dpti_i2o.h2
-rw-r--r--drivers/scsi/imm.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c2
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c4
-rw-r--r--drivers/scsi/ppa.c2
-rw-r--r--drivers/scsi/qla4xxx/Kconfig2
-rw-r--r--drivers/serial/ioc4_serial.c4
-rw-r--r--drivers/usb/net/usbnet.c2
-rw-r--r--drivers/video/backlight/hp680_bl.c2
-rw-r--r--drivers/video/offb.c36
-rw-r--r--fs/block_dev.c56
-rw-r--r--fs/ecryptfs/crypto.c206
-rw-r--r--fs/ecryptfs/dentry.c8
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h22
-rw-r--r--fs/ecryptfs/file.c44
-rw-r--r--fs/ecryptfs/inode.c95
-rw-r--r--fs/ecryptfs/keystore.c114
-rw-r--r--fs/ecryptfs/main.c15
-rw-r--r--fs/ecryptfs/super.c18
-rw-r--r--include/asm-i386/io_apic.h29
-rw-r--r--include/asm-ia64/sal.h1
-rw-r--r--include/asm-ia64/uaccess.h2
-rw-r--r--include/asm-mips/asm.h2
-rw-r--r--include/asm-mips/div64.h21
-rw-r--r--include/asm-mips/mipsmtregs.h2
-rw-r--r--include/asm-mips/pgalloc.h2
-rw-r--r--include/asm-mips/pgtable-64.h2
-rw-r--r--include/asm-mips/sibyte/sb1250.h2
-rw-r--r--include/asm-mips/time.h10
-rw-r--r--include/asm-mips/unistd.h19
-rw-r--r--include/asm-powerpc/current.h12
-rw-r--r--include/asm-powerpc/io.h7
-rw-r--r--include/asm-powerpc/iommu.h22
-rw-r--r--include/asm-powerpc/oprofile_impl.h87
-rw-r--r--include/asm-powerpc/pmc.h13
-rw-r--r--include/asm-powerpc/system.h6
-rw-r--r--include/asm-powerpc/tce.h3
-rw-r--r--include/asm-sh/irq.h10
-rw-r--r--include/asm-sh/unistd.h5
-rw-r--r--include/asm-sparc64/futex.h18
-rw-r--r--include/asm-um/common.lds.S8
-rw-r--r--include/linux/libata.h1
-rw-r--r--include/linux/mtd/nand.h2
-rw-r--r--include/linux/wait.h9
-rw-r--r--kernel/module.c2
-rw-r--r--kernel/taskstats.c17
-rw-r--r--kernel/tsacct.c10
-rw-r--r--net/appletalk/ddp.c2
-rw-r--r--net/bridge/netfilter/ebtables.c2
-rw-r--r--net/core/skbuff.c9
-rw-r--r--net/dccp/ccids/ccid2.c18
-rw-r--r--net/ipv4/cipso_ipv4.c7
-rw-r--r--net/ipv4/ip_options.c2
-rw-r--r--net/ipv4/netfilter/arp_tables.c25
-rw-r--r--net/ipv4/netfilter/ip_tables.c67
-rw-r--r--net/ipv4/raw.c17
-rw-r--r--net/ipv4/sysctl_net_ipv4.c7
-rw-r--r--net/ipv4/tcp_cong.c8
-rw-r--r--net/ipv6/ip6_flowlabel.c24
-rw-r--r--net/ipv6/netfilter/Kconfig2
-rw-r--r--net/ipv6/netfilter/ip6_tables.c24
-rw-r--r--net/ipv6/raw.c17
-rw-r--r--net/ipv6/xfrm6_tunnel.c4
-rw-r--r--net/netfilter/nf_conntrack_core.c3
-rw-r--r--net/netlink/af_netlink.c5
-rw-r--r--net/sched/sch_netem.c2
-rw-r--r--net/sctp/associola.c15
-rw-r--r--net/sctp/endpointola.c7
-rw-r--r--net/sctp/input.c9
-rw-r--r--net/sctp/protocol.c2
-rw-r--r--net/sctp/socket.c9
-rw-r--r--net/sunrpc/svcauth.c4
-rw-r--r--net/sunrpc/svcsock.c31
-rw-r--r--net/tipc/port.c5
-rw-r--r--net/xfrm/xfrm_user.c4
-rw-r--r--security/selinux/hooks.c8
-rw-r--r--security/selinux/include/selinux_netlabel.h10
-rw-r--r--security/selinux/ss/services.c37
213 files changed, 2708 insertions, 2388 deletions
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 66e1cf733571..3bf5086574bc 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -9,7 +9,7 @@
9DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \ 9DOCBOOKS := wanbook.xml z8530book.xml mcabook.xml videobook.xml \
10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \ 10 kernel-hacking.xml kernel-locking.xml deviceiobook.xml \
11 procfs-guide.xml writing_usb_driver.xml \ 11 procfs-guide.xml writing_usb_driver.xml \
12 kernel-api.xml journal-api.xml lsm.xml usb.xml \ 12 kernel-api.xml filesystems.xml journal-api.xml lsm.xml usb.xml \
13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ 13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
14 genericirq.xml 14 genericirq.xml
15 15
diff --git a/Documentation/DocBook/filesystems.tmpl b/Documentation/DocBook/filesystems.tmpl
new file mode 100644
index 000000000000..4785032fb6ea
--- /dev/null
+++ b/Documentation/DocBook/filesystems.tmpl
@@ -0,0 +1,101 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="Linux-filesystems-API">
6 <bookinfo>
7 <title>Linux Filesystems API</title>
8
9 <legalnotice>
10 <para>
11 This documentation is free software; you can redistribute
12 it and/or modify it under the terms of the GNU General Public
13 License as published by the Free Software Foundation; either
14 version 2 of the License, or (at your option) any later
15 version.
16 </para>
17
18 <para>
19 This program is distributed in the hope that it will be
20 useful, but WITHOUT ANY WARRANTY; without even the implied
21 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License for more details.
23 </para>
24
25 <para>
26 You should have received a copy of the GNU General Public
27 License along with this program; if not, write to the Free
28 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
29 MA 02111-1307 USA
30 </para>
31
32 <para>
33 For more details see the file COPYING in the source
34 distribution of Linux.
35 </para>
36 </legalnotice>
37 </bookinfo>
38
39<toc></toc>
40
41 <chapter id="vfs">
42 <title>The Linux VFS</title>
43 <sect1><title>The Filesystem types</title>
44!Iinclude/linux/fs.h
45 </sect1>
46 <sect1><title>The Directory Cache</title>
47!Efs/dcache.c
48!Iinclude/linux/dcache.h
49 </sect1>
50 <sect1><title>Inode Handling</title>
51!Efs/inode.c
52!Efs/bad_inode.c
53 </sect1>
54 <sect1><title>Registration and Superblocks</title>
55!Efs/super.c
56 </sect1>
57 <sect1><title>File Locks</title>
58!Efs/locks.c
59!Ifs/locks.c
60 </sect1>
61 <sect1><title>Other Functions</title>
62!Efs/mpage.c
63!Efs/namei.c
64!Efs/buffer.c
65!Efs/bio.c
66!Efs/seq_file.c
67!Efs/filesystems.c
68!Efs/fs-writeback.c
69!Efs/block_dev.c
70 </sect1>
71 </chapter>
72
73 <chapter id="proc">
74 <title>The proc filesystem</title>
75
76 <sect1><title>sysctl interface</title>
77!Ekernel/sysctl.c
78 </sect1>
79
80 <sect1><title>proc filesystem interface</title>
81!Ifs/proc/base.c
82 </sect1>
83 </chapter>
84
85 <chapter id="sysfs">
86 <title>The Filesystem for Exporting Kernel Objects</title>
87!Efs/sysfs/file.c
88!Efs/sysfs/symlink.c
89!Efs/sysfs/bin.c
90 </chapter>
91
92 <chapter id="debugfs">
93 <title>The debugfs filesystem</title>
94
95 <sect1><title>debugfs interface</title>
96!Efs/debugfs/inode.c
97!Efs/debugfs/file.c
98 </sect1>
99 </chapter>
100
101</book>
diff --git a/Documentation/DocBook/kernel-api.tmpl b/Documentation/DocBook/kernel-api.tmpl
index 2b5ac604948c..a166675c4303 100644
--- a/Documentation/DocBook/kernel-api.tmpl
+++ b/Documentation/DocBook/kernel-api.tmpl
@@ -182,66 +182,6 @@ X!Ilib/string.c
182 </sect1> 182 </sect1>
183 </chapter> 183 </chapter>
184 184
185 <chapter id="vfs">
186 <title>The Linux VFS</title>
187 <sect1><title>The Filesystem types</title>
188!Iinclude/linux/fs.h
189 </sect1>
190 <sect1><title>The Directory Cache</title>
191!Efs/dcache.c
192!Iinclude/linux/dcache.h
193 </sect1>
194 <sect1><title>Inode Handling</title>
195!Efs/inode.c
196!Efs/bad_inode.c
197 </sect1>
198 <sect1><title>Registration and Superblocks</title>
199!Efs/super.c
200 </sect1>
201 <sect1><title>File Locks</title>
202!Efs/locks.c
203!Ifs/locks.c
204 </sect1>
205 <sect1><title>Other Functions</title>
206!Efs/mpage.c
207!Efs/namei.c
208!Efs/buffer.c
209!Efs/bio.c
210!Efs/seq_file.c
211!Efs/filesystems.c
212!Efs/fs-writeback.c
213!Efs/block_dev.c
214 </sect1>
215 </chapter>
216
217 <chapter id="proc">
218 <title>The proc filesystem</title>
219
220 <sect1><title>sysctl interface</title>
221!Ekernel/sysctl.c
222 </sect1>
223
224 <sect1><title>proc filesystem interface</title>
225!Ifs/proc/base.c
226 </sect1>
227 </chapter>
228
229 <chapter id="sysfs">
230 <title>The Filesystem for Exporting Kernel Objects</title>
231!Efs/sysfs/file.c
232!Efs/sysfs/symlink.c
233!Efs/sysfs/bin.c
234 </chapter>
235
236 <chapter id="debugfs">
237 <title>The debugfs filesystem</title>
238
239 <sect1><title>debugfs interface</title>
240!Efs/debugfs/inode.c
241!Efs/debugfs/file.c
242 </sect1>
243 </chapter>
244
245 <chapter id="relayfs"> 185 <chapter id="relayfs">
246 <title>relay interface support</title> 186 <title>relay interface support</title>
247 187
diff --git a/Documentation/mips/time.README b/Documentation/mips/time.README
index e1304b6bc483..a4ce603ed3b3 100644
--- a/Documentation/mips/time.README
+++ b/Documentation/mips/time.README
@@ -38,19 +38,14 @@ The new time code provide the following services:
38 38
39 a) Implements functions required by Linux common code: 39 a) Implements functions required by Linux common code:
40 time_init 40 time_init
41 do_gettimeofday
42 do_settimeofday
43 41
44 b) provides an abstraction of RTC and null RTC implementation as default. 42 b) provides an abstraction of RTC and null RTC implementation as default.
45 extern unsigned long (*rtc_get_time)(void); 43 extern unsigned long (*rtc_get_time)(void);
46 extern int (*rtc_set_time)(unsigned long); 44 extern int (*rtc_set_time)(unsigned long);
47 45
48 c) a set of gettimeoffset functions for different CPUs and different 46 c) high-level and low-level timer interrupt routines where the timer
49 needs. 47 interrupt source may or may not be the CPU timer. The high-level
50 48 routine is dispatched through do_IRQ() while the low-level is
51 d) high-level and low-level timer interrupt routines where the timer
52 interrupt source may or may not be the CPU timer. The high-level
53 routine is dispatched through do_IRQ() while the low-level is
54 dispatched in assemably code (usually int-handler.S) 49 dispatched in assemably code (usually int-handler.S)
55 50
56 51
@@ -73,8 +68,7 @@ the following functions or values:
73 c) (optional) board-specific RTC routines. 68 c) (optional) board-specific RTC routines.
74 69
75 d) (optional) mips_hpt_frequency - It must be definied if the board 70 d) (optional) mips_hpt_frequency - It must be definied if the board
76 is using CPU counter for timer interrupt or it is using fixed rate 71 is using CPU counter for timer interrupt.
77 gettimeoffset().
78 72
79 73
80PORTING GUIDE 74PORTING GUIDE
@@ -89,16 +83,6 @@ Step 1: decide how you like to implement the time services.
89 If the answer is no, you need a timer to provide the timer interrupt 83 If the answer is no, you need a timer to provide the timer interrupt
90 at 100 HZ speed. 84 at 100 HZ speed.
91 85
92 You cannot use the fast gettimeoffset functions, i.e.,
93
94 unsigned long fixed_rate_gettimeoffset(void);
95 unsigned long calibrate_div32_gettimeoffset(void);
96 unsigned long calibrate_div64_gettimeoffset(void);
97
98 You can use null_gettimeoffset() will gives the same time resolution as
99 jiffy. Or you can implement your own gettimeoffset (probably based on
100 some ad hoc hardware on your machine.)
101
102 c) The following sub steps assume your CPU has counter register. 86 c) The following sub steps assume your CPU has counter register.
103 Do you plan to use the CPU counter register as the timer interrupt 87 Do you plan to use the CPU counter register as the timer interrupt
104 or use an exnternal timer? 88 or use an exnternal timer?
@@ -123,8 +107,8 @@ Step 3: implement rtc routines, board_time_init() and plat_timer_setup()
123 board_time_init() - 107 board_time_init() -
124 a) (optional) set up RTC routines, 108 a) (optional) set up RTC routines,
125 b) (optional) calibrate and set the mips_hpt_frequency 109 b) (optional) calibrate and set the mips_hpt_frequency
126 (only needed if you intended to use fixed_rate_gettimeoffset 110 (only needed if you intended to use cpu counter as timer interrupt
127 or use cpu counter as timer interrupt source) 111 source)
128 112
129 plat_timer_setup() - 113 plat_timer_setup() -
130 a) (optional) over-write any choices made above by time_init(). 114 a) (optional) over-write any choices made above by time_init().
@@ -154,8 +138,8 @@ for some of the functions in time.c.
154For example, you may define your own timer interrupt routine, which does 138For example, you may define your own timer interrupt routine, which does
155some of its own processing and then calls timer_interrupt(). 139some of its own processing and then calls timer_interrupt().
156 140
157You can also over-ride any of the built-in functions (gettimeoffset, 141You can also over-ride any of the built-in functions (RTC routines
158RTC routines and/or timer interrupt routine). 142and/or timer interrupt routine).
159 143
160 144
161PORTING NOTES FOR SMP 145PORTING NOTES FOR SMP
@@ -187,10 +171,3 @@ You need to decide on your timer interrupt sources.
187 171
188 You can also do the low-level version of those interrupt routines, 172 You can also do the low-level version of those interrupt routines,
189 following similar dispatching routes described above. 173 following similar dispatching routes described above.
190
191Note about do_gettimeoffset():
192
193 It is very likely the CPU counter registers are not sync'ed up in a SMP box.
194 Therefore you cannot really use the many of the existing routines that
195 are based on CPU counter. You should wirte your own gettimeoffset rouinte
196 if you want intra-jiffy resolution.
diff --git a/Makefile b/Makefile
index 25b35992a02c..95576199f3ca 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 19 3SUBLEVEL = 19
4EXTRAVERSION =-rc3 4EXTRAVERSION =-rc4
5NAME=Avast! A bilge rat! 5NAME=Avast! A bilge rat!
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index ba096ebb0b15..2449637e6fc0 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2051,7 +2051,6 @@ static void cryptocop_job_queue_close(void)
2051 spin_lock_irqsave(&cryptocop_process_lock, process_flags); 2051 spin_lock_irqsave(&cryptocop_process_lock, process_flags);
2052 2052
2053 /* Empty the job queue. */ 2053 /* Empty the job queue. */
2054 spin_lock_irqsave(&cryptocop_process_lock, process_flags);
2055 for (i = 0; i < cryptocop_prio_no_prios; i++){ 2054 for (i = 0; i < cryptocop_prio_no_prios; i++){
2056 if (!list_empty(&(cryptocop_job_queues[i].jobs))){ 2055 if (!list_empty(&(cryptocop_job_queues[i].jobs))){
2057 list_for_each_safe(node, tmp, &(cryptocop_job_queues[i].jobs)) { 2056 list_for_each_safe(node, tmp, &(cryptocop_job_queues[i].jobs)) {
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index 2af65858d322..a60358fe9a49 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -198,7 +198,7 @@
198 * (APM) BIOS Interface Specification, Revision 1.2, February 1996. 198 * (APM) BIOS Interface Specification, Revision 1.2, February 1996.
199 * 199 *
200 * [This document is available from Microsoft at: 200 * [This document is available from Microsoft at:
201 * http://www.microsoft.com/hwdev/busbios/amp_12.htm] 201 * http://www.microsoft.com/whdc/archive/amp_12.mspx]
202 */ 202 */
203 203
204#include <linux/module.h> 204#include <linux/module.h>
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 350192d6ab98..507983c513c3 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -91,6 +91,46 @@ static struct irq_pin_list {
91 int apic, pin, next; 91 int apic, pin, next;
92} irq_2_pin[PIN_MAP_SIZE]; 92} irq_2_pin[PIN_MAP_SIZE];
93 93
94struct io_apic {
95 unsigned int index;
96 unsigned int unused[3];
97 unsigned int data;
98};
99
100static __attribute_const__ struct io_apic __iomem *io_apic_base(int idx)
101{
102 return (void __iomem *) __fix_to_virt(FIX_IO_APIC_BASE_0 + idx)
103 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK);
104}
105
106static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
107{
108 struct io_apic __iomem *io_apic = io_apic_base(apic);
109 writel(reg, &io_apic->index);
110 return readl(&io_apic->data);
111}
112
113static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
114{
115 struct io_apic __iomem *io_apic = io_apic_base(apic);
116 writel(reg, &io_apic->index);
117 writel(value, &io_apic->data);
118}
119
120/*
121 * Re-write a value: to be used for read-modify-write
122 * cycles where the read already set up the index register.
123 *
124 * Older SiS APIC requires we rewrite the index register
125 */
126static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
127{
128 volatile struct io_apic *io_apic = io_apic_base(apic);
129 if (sis_apic_bug)
130 writel(reg, &io_apic->index);
131 writel(value, &io_apic->data);
132}
133
94union entry_union { 134union entry_union {
95 struct { u32 w1, w2; }; 135 struct { u32 w1, w2; };
96 struct IO_APIC_route_entry entry; 136 struct IO_APIC_route_entry entry;
@@ -107,12 +147,34 @@ static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
107 return eu.entry; 147 return eu.entry;
108} 148}
109 149
150/*
151 * When we write a new IO APIC routing entry, we need to write the high
152 * word first! If the mask bit in the low word is clear, we will enable
153 * the interrupt, and we need to make sure the entry is fully populated
154 * before that happens.
155 */
110static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e) 156static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
111{ 157{
112 unsigned long flags; 158 unsigned long flags;
113 union entry_union eu; 159 union entry_union eu;
114 eu.entry = e; 160 eu.entry = e;
115 spin_lock_irqsave(&ioapic_lock, flags); 161 spin_lock_irqsave(&ioapic_lock, flags);
162 io_apic_write(apic, 0x11 + 2*pin, eu.w2);
163 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
164 spin_unlock_irqrestore(&ioapic_lock, flags);
165}
166
167/*
168 * When we mask an IO APIC routing entry, we need to write the low
169 * word first, in order to set the mask bit before we change the
170 * high bits!
171 */
172static void ioapic_mask_entry(int apic, int pin)
173{
174 unsigned long flags;
175 union entry_union eu = { .entry.mask = 1 };
176
177 spin_lock_irqsave(&ioapic_lock, flags);
116 io_apic_write(apic, 0x10 + 2*pin, eu.w1); 178 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
117 io_apic_write(apic, 0x11 + 2*pin, eu.w2); 179 io_apic_write(apic, 0x11 + 2*pin, eu.w2);
118 spin_unlock_irqrestore(&ioapic_lock, flags); 180 spin_unlock_irqrestore(&ioapic_lock, flags);
@@ -234,9 +296,7 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
234 /* 296 /*
235 * Disable it in the IO-APIC irq-routing table: 297 * Disable it in the IO-APIC irq-routing table:
236 */ 298 */
237 memset(&entry, 0, sizeof(entry)); 299 ioapic_mask_entry(apic, pin);
238 entry.mask = 1;
239 ioapic_write_entry(apic, pin, entry);
240} 300}
241 301
242static void clear_IO_APIC (void) 302static void clear_IO_APIC (void)
diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c
index a45009d2bc90..afc1403799c9 100644
--- a/arch/ia64/kernel/mca_drv.c
+++ b/arch/ia64/kernel/mca_drv.c
@@ -435,6 +435,50 @@ is_mca_global(peidx_table_t *peidx, pal_bus_check_info_t *pbci,
435} 435}
436 436
437/** 437/**
438 * get_target_identifier - Get the valid Cache or Bus check target identifier.
439 * @peidx: pointer of index of processor error section
440 *
441 * Return value:
442 * target address on Success / 0 on Failue
443 */
444static u64
445get_target_identifier(peidx_table_t *peidx)
446{
447 u64 target_address = 0;
448 sal_log_mod_error_info_t *smei;
449 pal_cache_check_info_t *pcci;
450 int i, level = 9;
451
452 /*
453 * Look through the cache checks for a valid target identifier
454 * If more than one valid target identifier, return the one
455 * with the lowest cache level.
456 */
457 for (i = 0; i < peidx_cache_check_num(peidx); i++) {
458 smei = (sal_log_mod_error_info_t *)peidx_cache_check(peidx, i);
459 if (smei->valid.target_identifier && smei->target_identifier) {
460 pcci = (pal_cache_check_info_t *)&(smei->check_info);
461 if (!target_address || (pcci->level < level)) {
462 target_address = smei->target_identifier;
463 level = pcci->level;
464 continue;
465 }
466 }
467 }
468 if (target_address)
469 return target_address;
470
471 /*
472 * Look at the bus check for a valid target identifier
473 */
474 smei = peidx_bus_check(peidx, 0);
475 if (smei && smei->valid.target_identifier)
476 return smei->target_identifier;
477
478 return 0;
479}
480
481/**
438 * recover_from_read_error - Try to recover the errors which type are "read"s. 482 * recover_from_read_error - Try to recover the errors which type are "read"s.
439 * @slidx: pointer of index of SAL error record 483 * @slidx: pointer of index of SAL error record
440 * @peidx: pointer of index of processor error section 484 * @peidx: pointer of index of processor error section
@@ -450,13 +494,14 @@ recover_from_read_error(slidx_table_t *slidx,
450 peidx_table_t *peidx, pal_bus_check_info_t *pbci, 494 peidx_table_t *peidx, pal_bus_check_info_t *pbci,
451 struct ia64_sal_os_state *sos) 495 struct ia64_sal_os_state *sos)
452{ 496{
453 sal_log_mod_error_info_t *smei; 497 u64 target_identifier;
454 pal_min_state_area_t *pmsa; 498 pal_min_state_area_t *pmsa;
455 struct ia64_psr *psr1, *psr2; 499 struct ia64_psr *psr1, *psr2;
456 ia64_fptr_t *mca_hdlr_bh = (ia64_fptr_t*)mca_handler_bhhook; 500 ia64_fptr_t *mca_hdlr_bh = (ia64_fptr_t*)mca_handler_bhhook;
457 501
458 /* Is target address valid? */ 502 /* Is target address valid? */
459 if (!pbci->tv) 503 target_identifier = get_target_identifier(peidx);
504 if (!target_identifier)
460 return fatal_mca("target address not valid"); 505 return fatal_mca("target address not valid");
461 506
462 /* 507 /*
@@ -487,32 +532,28 @@ recover_from_read_error(slidx_table_t *slidx,
487 pmsa = sos->pal_min_state; 532 pmsa = sos->pal_min_state;
488 if (psr1->cpl != 0 || 533 if (psr1->cpl != 0 ||
489 ((psr2->cpl != 0) && mca_recover_range(pmsa->pmsa_iip))) { 534 ((psr2->cpl != 0) && mca_recover_range(pmsa->pmsa_iip))) {
490 smei = peidx_bus_check(peidx, 0); 535 /*
491 if (smei->valid.target_identifier) { 536 * setup for resume to bottom half of MCA,
492 /* 537 * "mca_handler_bhhook"
493 * setup for resume to bottom half of MCA, 538 */
494 * "mca_handler_bhhook" 539 /* pass to bhhook as argument (gr8, ...) */
495 */ 540 pmsa->pmsa_gr[8-1] = target_identifier;
496 /* pass to bhhook as argument (gr8, ...) */ 541 pmsa->pmsa_gr[9-1] = pmsa->pmsa_iip;
497 pmsa->pmsa_gr[8-1] = smei->target_identifier; 542 pmsa->pmsa_gr[10-1] = pmsa->pmsa_ipsr;
498 pmsa->pmsa_gr[9-1] = pmsa->pmsa_iip; 543 /* set interrupted return address (but no use) */
499 pmsa->pmsa_gr[10-1] = pmsa->pmsa_ipsr; 544 pmsa->pmsa_br0 = pmsa->pmsa_iip;
500 /* set interrupted return address (but no use) */ 545 /* change resume address to bottom half */
501 pmsa->pmsa_br0 = pmsa->pmsa_iip; 546 pmsa->pmsa_iip = mca_hdlr_bh->fp;
502 /* change resume address to bottom half */ 547 pmsa->pmsa_gr[1-1] = mca_hdlr_bh->gp;
503 pmsa->pmsa_iip = mca_hdlr_bh->fp; 548 /* set cpl with kernel mode */
504 pmsa->pmsa_gr[1-1] = mca_hdlr_bh->gp; 549 psr2 = (struct ia64_psr *)&pmsa->pmsa_ipsr;
505 /* set cpl with kernel mode */ 550 psr2->cpl = 0;
506 psr2 = (struct ia64_psr *)&pmsa->pmsa_ipsr; 551 psr2->ri = 0;
507 psr2->cpl = 0; 552 psr2->bn = 1;
508 psr2->ri = 0; 553 psr2->i = 0;
509 psr2->bn = 1; 554
510 psr2->i = 0; 555 return mca_recovered("user memory corruption. "
511
512 return mca_recovered("user memory corruption. "
513 "kill affected process - recovered."); 556 "kill affected process - recovered.");
514 }
515
516 } 557 }
517 558
518 return fatal_mca("kernel context not recovered, iip 0x%lx\n", 559 return fatal_mca("kernel context not recovered, iip 0x%lx\n",
diff --git a/arch/ia64/kernel/sal.c b/arch/ia64/kernel/sal.c
index 642fdc7b969d..20bad78b5073 100644
--- a/arch/ia64/kernel/sal.c
+++ b/arch/ia64/kernel/sal.c
@@ -223,12 +223,13 @@ static void __init sal_desc_ap_wakeup(void *p) { }
223 */ 223 */
224static int sal_cache_flush_drops_interrupts; 224static int sal_cache_flush_drops_interrupts;
225 225
226static void __init 226void __init
227check_sal_cache_flush (void) 227check_sal_cache_flush (void)
228{ 228{
229 unsigned long flags; 229 unsigned long flags;
230 int cpu; 230 int cpu;
231 u64 vector; 231 u64 vector, cache_type = 3;
232 struct ia64_sal_retval isrv;
232 233
233 cpu = get_cpu(); 234 cpu = get_cpu();
234 local_irq_save(flags); 235 local_irq_save(flags);
@@ -243,7 +244,10 @@ check_sal_cache_flush (void)
243 while (!ia64_get_irr(IA64_TIMER_VECTOR)) 244 while (!ia64_get_irr(IA64_TIMER_VECTOR))
244 cpu_relax(); 245 cpu_relax();
245 246
246 ia64_sal_cache_flush(3); 247 SAL_CALL(isrv, SAL_CACHE_FLUSH, cache_type, 0, 0, 0, 0, 0, 0);
248
249 if (isrv.status)
250 printk(KERN_ERR "SAL_CAL_FLUSH failed with %ld\n", isrv.status);
247 251
248 if (ia64_get_irr(IA64_TIMER_VECTOR)) { 252 if (ia64_get_irr(IA64_TIMER_VECTOR)) {
249 vector = ia64_get_ivr(); 253 vector = ia64_get_ivr();
@@ -331,7 +335,6 @@ ia64_sal_init (struct ia64_sal_systab *systab)
331 p += SAL_DESC_SIZE(*p); 335 p += SAL_DESC_SIZE(*p);
332 } 336 }
333 337
334 check_sal_cache_flush();
335} 338}
336 339
337int 340int
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index c4caa8003492..d10404a41756 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -457,6 +457,8 @@ setup_arch (char **cmdline_p)
457 cpu_init(); /* initialize the bootstrap CPU */ 457 cpu_init(); /* initialize the bootstrap CPU */
458 mmu_context_init(); /* initialize context_id bitmap */ 458 mmu_context_init(); /* initialize context_id bitmap */
459 459
460 check_sal_cache_flush();
461
460#ifdef CONFIG_ACPI 462#ifdef CONFIG_ACPI
461 acpi_boot_init(); 463 acpi_boot_init();
462#endif 464#endif
diff --git a/arch/ia64/kernel/smp.c b/arch/ia64/kernel/smp.c
index 657ac99a451c..6ab95ceaf9d4 100644
--- a/arch/ia64/kernel/smp.c
+++ b/arch/ia64/kernel/smp.c
@@ -108,7 +108,7 @@ cpu_die(void)
108} 108}
109 109
110irqreturn_t 110irqreturn_t
111handle_IPI (int irq, void *dev_id, struct pt_regs *regs) 111handle_IPI (int irq, void *dev_id)
112{ 112{
113 int this_cpu = get_cpu(); 113 int this_cpu = get_cpu();
114 unsigned long *pending_ipis = &__ia64_per_cpu_var(ipi_operation); 114 unsigned long *pending_ipis = &__ia64_per_cpu_var(ipi_operation);
@@ -328,10 +328,14 @@ int
328smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wait) 328smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wait)
329{ 329{
330 struct call_data_struct data; 330 struct call_data_struct data;
331 int cpus = num_online_cpus()-1; 331 int cpus;
332 332
333 if (!cpus) 333 spin_lock(&call_lock);
334 cpus = num_online_cpus() - 1;
335 if (!cpus) {
336 spin_unlock(&call_lock);
334 return 0; 337 return 0;
338 }
335 339
336 /* Can deadlock when called with interrupts disabled */ 340 /* Can deadlock when called with interrupts disabled */
337 WARN_ON(irqs_disabled()); 341 WARN_ON(irqs_disabled());
@@ -343,8 +347,6 @@ smp_call_function (void (*func) (void *info), void *info, int nonatomic, int wai
343 if (wait) 347 if (wait)
344 atomic_set(&data.finished, 0); 348 atomic_set(&data.finished, 0);
345 349
346 spin_lock(&call_lock);
347
348 call_data = &data; 350 call_data = &data;
349 mb(); /* ensure store to call_data precedes setting of IPI_CALL_FUNC */ 351 mb(); /* ensure store to call_data precedes setting of IPI_CALL_FUNC */
350 send_IPI_allbutself(IPI_CALL_FUNC); 352 send_IPI_allbutself(IPI_CALL_FUNC);
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 14af6cce2fa2..74ba76378113 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -408,7 +408,7 @@ config MOMENCO_OCELOT_C
408 select SWAP_IO_SPACE 408 select SWAP_IO_SPACE
409 select SYS_HAS_CPU_RM7000 409 select SYS_HAS_CPU_RM7000
410 select SYS_SUPPORTS_32BIT_KERNEL 410 select SYS_SUPPORTS_32BIT_KERNEL
411 select SYS_SUPPORTS_64BIT_KERNEL 411 select SYS_SUPPORTS_64BIT_KERNEL if BROKEN
412 select SYS_SUPPORTS_BIG_ENDIAN 412 select SYS_SUPPORTS_BIG_ENDIAN
413 help 413 help
414 The Ocelot is a MIPS-based Single Board Computer (SBC) made by 414 The Ocelot is a MIPS-based Single Board Computer (SBC) made by
@@ -1690,6 +1690,7 @@ config NR_CPUS
1690 depends on SMP 1690 depends on SMP
1691 default "64" if SGI_IP27 1691 default "64" if SGI_IP27
1692 default "2" 1692 default "2"
1693 default "8" if MIPS_MT_SMTC
1693 help 1694 help
1694 This allows you to specify the maximum number of CPUs which this 1695 This allows you to specify the maximum number of CPUs which this
1695 kernel will support. The maximum supported value is 32 for 32-bit 1696 kernel will support. The maximum supported value is 32 for 32-bit
diff --git a/arch/mips/au1000/common/prom.c b/arch/mips/au1000/common/prom.c
index b4b010a2fe36..6fce60af005d 100644
--- a/arch/mips/au1000/common/prom.c
+++ b/arch/mips/au1000/common/prom.c
@@ -47,7 +47,7 @@ extern int prom_argc;
47extern char **prom_argv, **prom_envp; 47extern char **prom_argv, **prom_envp;
48 48
49 49
50char * prom_getcmdline(void) 50char * __init_or_module prom_getcmdline(void)
51{ 51{
52 return &(arcs_cmdline[0]); 52 return &(arcs_cmdline[0]);
53} 53}
diff --git a/arch/mips/au1000/common/setup.c b/arch/mips/au1000/common/setup.c
index 377ae0d8ff00..919172db560c 100644
--- a/arch/mips/au1000/common/setup.c
+++ b/arch/mips/au1000/common/setup.c
@@ -43,7 +43,7 @@
43#include <asm/mach-au1x00/au1000.h> 43#include <asm/mach-au1x00/au1000.h>
44#include <asm/time.h> 44#include <asm/time.h>
45 45
46extern char * __init prom_getcmdline(void); 46extern char * prom_getcmdline(void);
47extern void __init board_setup(void); 47extern void __init board_setup(void);
48extern void au1000_restart(char *); 48extern void au1000_restart(char *);
49extern void au1000_halt(void); 49extern void au1000_halt(void);
diff --git a/arch/mips/au1000/common/time.c b/arch/mips/au1000/common/time.c
index 94f09194d63d..fa1c62f05515 100644
--- a/arch/mips/au1000/common/time.c
+++ b/arch/mips/au1000/common/time.c
@@ -53,9 +53,6 @@ static unsigned long r4k_cur; /* What counter should be at next timer irq */
53int no_au1xxx_32khz; 53int no_au1xxx_32khz;
54extern int allow_au1k_wait; /* default off for CP0 Counter */ 54extern int allow_au1k_wait; /* default off for CP0 Counter */
55 55
56/* Cycle counter value at the previous timer interrupt.. */
57static unsigned int timerhi = 0, timerlo = 0;
58
59#ifdef CONFIG_PM 56#ifdef CONFIG_PM
60#if HZ < 100 || HZ > 1000 57#if HZ < 100 || HZ > 1000
61#error "unsupported HZ value! Must be in [100,1000]" 58#error "unsupported HZ value! Must be in [100,1000]"
@@ -82,7 +79,6 @@ unsigned long wtimer;
82void mips_timer_interrupt(void) 79void mips_timer_interrupt(void)
83{ 80{
84 int irq = 63; 81 int irq = 63;
85 unsigned long count;
86 82
87 irq_enter(); 83 irq_enter();
88 kstat_this_cpu.irqs[irq]++; 84 kstat_this_cpu.irqs[irq]++;
@@ -91,10 +87,6 @@ void mips_timer_interrupt(void)
91 goto null; 87 goto null;
92 88
93 do { 89 do {
94 count = read_c0_count();
95 timerhi += (count < timerlo); /* Wrap around */
96 timerlo = count;
97
98 kstat_this_cpu.irqs[irq]++; 90 kstat_this_cpu.irqs[irq]++;
99 do_timer(1); 91 do_timer(1);
100#ifndef CONFIG_SMP 92#ifndef CONFIG_SMP
@@ -231,7 +223,6 @@ wakeup_counter0_set(int ticks)
231 */ 223 */
232unsigned long cal_r4koff(void) 224unsigned long cal_r4koff(void)
233{ 225{
234 unsigned long count;
235 unsigned long cpu_speed; 226 unsigned long cpu_speed;
236 unsigned long flags; 227 unsigned long flags;
237 unsigned long counter; 228 unsigned long counter;
@@ -258,7 +249,7 @@ unsigned long cal_r4koff(void)
258 249
259#if defined(CONFIG_AU1000_USE32K) 250#if defined(CONFIG_AU1000_USE32K)
260 { 251 {
261 unsigned long start, end; 252 unsigned long start, end, count;
262 253
263 start = au_readl(SYS_RTCREAD); 254 start = au_readl(SYS_RTCREAD);
264 start += 2; 255 start += 2;
@@ -282,7 +273,6 @@ unsigned long cal_r4koff(void)
282#else 273#else
283 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * 274 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) *
284 AU1000_SRC_CLK; 275 AU1000_SRC_CLK;
285 count = cpu_speed / 2;
286#endif 276#endif
287 } 277 }
288 else { 278 else {
@@ -291,98 +281,15 @@ unsigned long cal_r4koff(void)
291 * NOTE: some old silicon doesn't allow reading the PLL. 281 * NOTE: some old silicon doesn't allow reading the PLL.
292 */ 282 */
293 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * AU1000_SRC_CLK; 283 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * AU1000_SRC_CLK;
294 count = cpu_speed / 2;
295 no_au1xxx_32khz = 1; 284 no_au1xxx_32khz = 1;
296 } 285 }
297 mips_hpt_frequency = count; 286 mips_hpt_frequency = cpu_speed;
298 // Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16) 287 // Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16)
299 set_au1x00_uart_baud_base(cpu_speed / (2 * ((int)(au_readl(SYS_POWERCTRL)&0x03) + 2) * 16)); 288 set_au1x00_uart_baud_base(cpu_speed / (2 * ((int)(au_readl(SYS_POWERCTRL)&0x03) + 2) * 16));
300 spin_unlock_irqrestore(&time_lock, flags); 289 spin_unlock_irqrestore(&time_lock, flags);
301 return (cpu_speed / HZ); 290 return (cpu_speed / HZ);
302} 291}
303 292
304/* This is for machines which generate the exact clock. */
305#define USECS_PER_JIFFY (1000000/HZ)
306#define USECS_PER_JIFFY_FRAC (0x100000000LL*1000000/HZ&0xffffffff)
307
308static unsigned long
309div64_32(unsigned long v1, unsigned long v2, unsigned long v3)
310{
311 unsigned long r0;
312 do_div64_32(r0, v1, v2, v3);
313 return r0;
314}
315
316static unsigned long do_fast_cp0_gettimeoffset(void)
317{
318 u32 count;
319 unsigned long res, tmp;
320 unsigned long r0;
321
322 /* Last jiffy when do_fast_gettimeoffset() was called. */
323 static unsigned long last_jiffies=0;
324 unsigned long quotient;
325
326 /*
327 * Cached "1/(clocks per usec)*2^32" value.
328 * It has to be recalculated once each jiffy.
329 */
330 static unsigned long cached_quotient=0;
331
332 tmp = jiffies;
333
334 quotient = cached_quotient;
335
336 if (tmp && last_jiffies != tmp) {
337 last_jiffies = tmp;
338 if (last_jiffies != 0) {
339 r0 = div64_32(timerhi, timerlo, tmp);
340 quotient = div64_32(USECS_PER_JIFFY, USECS_PER_JIFFY_FRAC, r0);
341 cached_quotient = quotient;
342 }
343 }
344
345 /* Get last timer tick in absolute kernel time */
346 count = read_c0_count();
347
348 /* .. relative to previous jiffy (32 bits is enough) */
349 count -= timerlo;
350
351 __asm__("multu\t%1,%2\n\t"
352 "mfhi\t%0"
353 : "=r" (res)
354 : "r" (count), "r" (quotient)
355 : "hi", "lo", GCC_REG_ACCUM);
356
357 /*
358 * Due to possible jiffies inconsistencies, we need to check
359 * the result so that we'll get a timer that is monotonic.
360 */
361 if (res >= USECS_PER_JIFFY)
362 res = USECS_PER_JIFFY-1;
363
364 return res;
365}
366
367#ifdef CONFIG_PM
368static unsigned long do_fast_pm_gettimeoffset(void)
369{
370 unsigned long pc0;
371 unsigned long offset;
372
373 pc0 = au_readl(SYS_TOYREAD);
374 au_sync();
375 offset = pc0 - last_pc0;
376 if (offset > 2*MATCH20_INC) {
377 printk("huge offset %x, last_pc0 %x last_match20 %x pc0 %x\n",
378 (unsigned)offset, (unsigned)last_pc0,
379 (unsigned)last_match20, (unsigned)pc0);
380 }
381 offset = (unsigned long)((offset * 305) / 10);
382 return offset;
383}
384#endif
385
386void __init plat_timer_setup(struct irqaction *irq) 293void __init plat_timer_setup(struct irqaction *irq)
387{ 294{
388 unsigned int est_freq; 295 unsigned int est_freq;
@@ -420,7 +327,6 @@ void __init plat_timer_setup(struct irqaction *irq)
420 unsigned int c0_status; 327 unsigned int c0_status;
421 328
422 printk("WARNING: no 32KHz clock found.\n"); 329 printk("WARNING: no 32KHz clock found.\n");
423 do_gettimeoffset = do_fast_cp0_gettimeoffset;
424 330
425 /* Ensure we get CPO_COUNTER interrupts. 331 /* Ensure we get CPO_COUNTER interrupts.
426 */ 332 */
@@ -445,19 +351,11 @@ void __init plat_timer_setup(struct irqaction *irq)
445 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); 351 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20);
446 startup_match20_interrupt(counter0_irq); 352 startup_match20_interrupt(counter0_irq);
447 353
448 do_gettimeoffset = do_fast_pm_gettimeoffset;
449
450 /* We can use the real 'wait' instruction. 354 /* We can use the real 'wait' instruction.
451 */ 355 */
452 allow_au1k_wait = 1; 356 allow_au1k_wait = 1;
453 } 357 }
454 358
455#else
456 /* We have to do this here instead of in timer_init because
457 * the generic code in arch/mips/kernel/time.c will write
458 * over our function pointer.
459 */
460 do_gettimeoffset = do_fast_cp0_gettimeoffset;
461#endif 359#endif
462} 360}
463 361
diff --git a/arch/mips/dec/time.c b/arch/mips/dec/time.c
index 4cf0c06e2414..69e424e9ab6f 100644
--- a/arch/mips/dec/time.c
+++ b/arch/mips/dec/time.c
@@ -160,11 +160,6 @@ static unsigned int dec_ioasic_hpt_read(void)
160 return ioasic_read(IO_REG_FCTR); 160 return ioasic_read(IO_REG_FCTR);
161} 161}
162 162
163static void dec_ioasic_hpt_init(unsigned int count)
164{
165 ioasic_write(IO_REG_FCTR, ioasic_read(IO_REG_FCTR) - count);
166}
167
168 163
169void __init dec_time_init(void) 164void __init dec_time_init(void)
170{ 165{
@@ -174,11 +169,9 @@ void __init dec_time_init(void)
174 mips_timer_state = dec_timer_state; 169 mips_timer_state = dec_timer_state;
175 mips_timer_ack = dec_timer_ack; 170 mips_timer_ack = dec_timer_ack;
176 171
177 if (!cpu_has_counter && IOASIC) { 172 if (!cpu_has_counter && IOASIC)
178 /* For pre-R4k systems we use the I/O ASIC's counter. */ 173 /* For pre-R4k systems we use the I/O ASIC's counter. */
179 mips_hpt_read = dec_ioasic_hpt_read; 174 mips_hpt_read = dec_ioasic_hpt_read;
180 mips_hpt_init = dec_ioasic_hpt_init;
181 }
182 175
183 /* Set up the rate of periodic DS1287 interrupts. */ 176 /* Set up the rate of periodic DS1287 interrupts. */
184 CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - __ffs(HZ)), RTC_REG_A); 177 CMOS_WRITE(RTC_REF_CLCK_32KHZ | (16 - __ffs(HZ)), RTC_REG_A);
diff --git a/arch/mips/emma2rh/common/irq_emma2rh.c b/arch/mips/emma2rh/common/irq_emma2rh.c
index 7c930860c921..197ed4c2ba04 100644
--- a/arch/mips/emma2rh/common/irq_emma2rh.c
+++ b/arch/mips/emma2rh/common/irq_emma2rh.c
@@ -97,7 +97,7 @@ void emma2rh_irq_init(u32 irq_base)
97 irq_desc[i].status = IRQ_DISABLED; 97 irq_desc[i].status = IRQ_DISABLED;
98 irq_desc[i].action = NULL; 98 irq_desc[i].action = NULL;
99 irq_desc[i].depth = 1; 99 irq_desc[i].depth = 1;
100 irq_desc[i].handler = &emma2rh_irq_controller; 100 irq_desc[i].chip = &emma2rh_irq_controller;
101 } 101 }
102 102
103 emma2rh_irq_base = irq_base; 103 emma2rh_irq_base = irq_base;
diff --git a/arch/mips/emma2rh/markeins/irq_markeins.c b/arch/mips/emma2rh/markeins/irq_markeins.c
index f23ae9fcffa0..0b36eb001e62 100644
--- a/arch/mips/emma2rh/markeins/irq_markeins.c
+++ b/arch/mips/emma2rh/markeins/irq_markeins.c
@@ -86,7 +86,7 @@ void emma2rh_sw_irq_init(u32 irq_base)
86 irq_desc[i].status = IRQ_DISABLED; 86 irq_desc[i].status = IRQ_DISABLED;
87 irq_desc[i].action = NULL; 87 irq_desc[i].action = NULL;
88 irq_desc[i].depth = 2; 88 irq_desc[i].depth = 2;
89 irq_desc[i].handler = &emma2rh_sw_irq_controller; 89 irq_desc[i].chip = &emma2rh_sw_irq_controller;
90 } 90 }
91 91
92 emma2rh_sw_irq_base = irq_base; 92 emma2rh_sw_irq_base = irq_base;
@@ -166,7 +166,7 @@ void emma2rh_gpio_irq_init(u32 irq_base)
166 irq_desc[i].status = IRQ_DISABLED; 166 irq_desc[i].status = IRQ_DISABLED;
167 irq_desc[i].action = NULL; 167 irq_desc[i].action = NULL;
168 irq_desc[i].depth = 2; 168 irq_desc[i].depth = 2;
169 irq_desc[i].handler = &emma2rh_gpio_irq_controller; 169 irq_desc[i].chip = &emma2rh_gpio_irq_controller;
170 } 170 }
171 171
172 emma2rh_gpio_irq_base = irq_base; 172 emma2rh_gpio_irq_base = irq_base;
diff --git a/arch/mips/emma2rh/markeins/platform.c b/arch/mips/emma2rh/markeins/platform.c
index 15cc61df3622..11567702b155 100644
--- a/arch/mips/emma2rh/markeins/platform.c
+++ b/arch/mips/emma2rh/markeins/platform.c
@@ -44,18 +44,45 @@
44#define I2C_EMMA2RH "emma2rh-iic" /* must be in sync with IIC driver */ 44#define I2C_EMMA2RH "emma2rh-iic" /* must be in sync with IIC driver */
45 45
46static struct resource i2c_emma_resources_0[] = { 46static struct resource i2c_emma_resources_0[] = {
47 { NULL, EMMA2RH_IRQ_PIIC0, EMMA2RH_IRQ_PIIC0, IORESOURCE_IRQ }, 47 {
48 { NULL, KSEG1ADDR(EMMA2RH_PIIC0_BASE), KSEG1ADDR(EMMA2RH_PIIC0_BASE + 0x1000), 0 }, 48 .name = NULL,
49 .start = EMMA2RH_IRQ_PIIC0,
50 .end = EMMA2RH_IRQ_PIIC0,
51 .flags = IORESOURCE_IRQ
52 }, {
53 .name = NULL,
54 .start = EMMA2RH_PIIC0_BASE,
55 .end = EMMA2RH_PIIC0_BASE + 0x1000,
56 .flags = 0
57 },
49}; 58};
50 59
51struct resource i2c_emma_resources_1[] = { 60struct resource i2c_emma_resources_1[] = {
52 { NULL, EMMA2RH_IRQ_PIIC1, EMMA2RH_IRQ_PIIC1, IORESOURCE_IRQ }, 61 {
53 { NULL, KSEG1ADDR(EMMA2RH_PIIC1_BASE), KSEG1ADDR(EMMA2RH_PIIC1_BASE + 0x1000), 0 }, 62 .name = NULL,
63 .start = EMMA2RH_IRQ_PIIC1,
64 .end = EMMA2RH_IRQ_PIIC1,
65 .flags = IORESOURCE_IRQ
66 }, {
67 .name = NULL,
68 .start = EMMA2RH_PIIC1_BASE,
69 .end = EMMA2RH_PIIC1_BASE + 0x1000,
70 .flags = 0
71 },
54}; 72};
55 73
56struct resource i2c_emma_resources_2[] = { 74struct resource i2c_emma_resources_2[] = {
57 { NULL, EMMA2RH_IRQ_PIIC2, EMMA2RH_IRQ_PIIC2, IORESOURCE_IRQ }, 75 {
58 { NULL, KSEG1ADDR(EMMA2RH_PIIC2_BASE), KSEG1ADDR(EMMA2RH_PIIC2_BASE + 0x1000), 0 }, 76 .name = NULL,
77 .start = EMMA2RH_IRQ_PIIC2,
78 .end = EMMA2RH_IRQ_PIIC2,
79 .flags = IORESOURCE_IRQ
80 }, {
81 .name = NULL,
82 .start = EMMA2RH_PIIC2_BASE,
83 .end = EMMA2RH_PIIC2_BASE + 0x1000,
84 .flags = 0
85 },
59}; 86};
60 87
61struct platform_device i2c_emma_devices[] = { 88struct platform_device i2c_emma_devices[] = {
@@ -83,32 +110,29 @@ struct platform_device i2c_emma_devices[] = {
83#define EMMA2RH_SERIAL_FLAGS UPF_BOOT_AUTOCONF | UPF_SKIP_TEST 110#define EMMA2RH_SERIAL_FLAGS UPF_BOOT_AUTOCONF | UPF_SKIP_TEST
84 111
85static struct plat_serial8250_port platform_serial_ports[] = { 112static struct plat_serial8250_port platform_serial_ports[] = {
86 [0] = { 113 [0] = {
87 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR0_BASE + 3), 114 .membase= (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR0_BASE + 3),
88 .irq = EMMA2RH_IRQ_PFUR0, 115 .irq = EMMA2RH_IRQ_PFUR0,
89 .uartclk = EMMA2RH_SERIAL_CLOCK, 116 .uartclk = EMMA2RH_SERIAL_CLOCK,
90 .regshift = 4, 117 .regshift = 4,
91 .iotype = UPIO_MEM, 118 .iotype = UPIO_MEM,
92 .flags = EMMA2RH_SERIAL_FLAGS, 119 .flags = EMMA2RH_SERIAL_FLAGS,
93 }, 120 }, [1] = {
94 [1] = { 121 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR1_BASE + 3),
95 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR1_BASE + 3), 122 .irq = EMMA2RH_IRQ_PFUR1,
96 .irq = EMMA2RH_IRQ_PFUR1, 123 .uartclk = EMMA2RH_SERIAL_CLOCK,
97 .uartclk = EMMA2RH_SERIAL_CLOCK, 124 .regshift = 4,
98 .regshift = 4, 125 .iotype = UPIO_MEM,
99 .iotype = UPIO_MEM, 126 .flags = EMMA2RH_SERIAL_FLAGS,
100 .flags = EMMA2RH_SERIAL_FLAGS, 127 }, [2] = {
101 }, 128 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR2_BASE + 3),
102 [2] = { 129 .irq = EMMA2RH_IRQ_PFUR2,
103 .membase = (void __iomem*)KSEG1ADDR(EMMA2RH_PFUR2_BASE + 3), 130 .uartclk = EMMA2RH_SERIAL_CLOCK,
104 .irq = EMMA2RH_IRQ_PFUR2, 131 .regshift = 4,
105 .uartclk = EMMA2RH_SERIAL_CLOCK, 132 .iotype = UPIO_MEM,
106 .regshift = 4, 133 .flags = EMMA2RH_SERIAL_FLAGS,
107 .iotype = UPIO_MEM, 134 }, [3] = {
108 .flags = EMMA2RH_SERIAL_FLAGS, 135 .flags = 0,
109 },
110 [3] = {
111 .flags = 0,
112 }, 136 },
113}; 137};
114 138
diff --git a/arch/mips/jmr3927/rbhma3100/irq.c b/arch/mips/jmr3927/rbhma3100/irq.c
index 39a0243bed9a..de4a238c28be 100644
--- a/arch/mips/jmr3927/rbhma3100/irq.c
+++ b/arch/mips/jmr3927/rbhma3100/irq.c
@@ -288,6 +288,8 @@ static void tx_branch_likely_bug_fixup(void)
288 288
289static void jmr3927_spurious(void) 289static void jmr3927_spurious(void)
290{ 290{
291 struct pt_regs * regs = get_irq_regs();
292
291#ifdef CONFIG_TX_BRANCH_LIKELY_BUG_WORKAROUND 293#ifdef CONFIG_TX_BRANCH_LIKELY_BUG_WORKAROUND
292 tx_branch_likely_bug_fixup(); 294 tx_branch_likely_bug_fixup();
293#endif 295#endif
@@ -297,6 +299,7 @@ static void jmr3927_spurious(void)
297 299
298asmlinkage void plat_irq_dispatch(void) 300asmlinkage void plat_irq_dispatch(void)
299{ 301{
302 struct pt_regs * regs = get_irq_regs();
300 int irq; 303 int irq;
301 304
302#ifdef CONFIG_TX_BRANCH_LIKELY_BUG_WORKAROUND 305#ifdef CONFIG_TX_BRANCH_LIKELY_BUG_WORKAROUND
diff --git a/arch/mips/jmr3927/rbhma3100/setup.c b/arch/mips/jmr3927/rbhma3100/setup.c
index 025434054ed0..16e5dfe7aa8a 100644
--- a/arch/mips/jmr3927/rbhma3100/setup.c
+++ b/arch/mips/jmr3927/rbhma3100/setup.c
@@ -170,12 +170,20 @@ static void jmr3927_machine_power_off(void)
170 while (1); 170 while (1);
171} 171}
172 172
173static unsigned int jmr3927_hpt_read(void)
174{
175 /* We assume this function is called xtime_lock held. */
176 return jiffies * (JMR3927_TIMER_CLK / HZ) + jmr3927_tmrptr->trr;
177}
178
173#define USE_RTC_DS1742 179#define USE_RTC_DS1742
174#ifdef USE_RTC_DS1742 180#ifdef USE_RTC_DS1742
175extern void rtc_ds1742_init(unsigned long base); 181extern void rtc_ds1742_init(unsigned long base);
176#endif 182#endif
177static void __init jmr3927_time_init(void) 183static void __init jmr3927_time_init(void)
178{ 184{
185 mips_hpt_read = jmr3927_hpt_read;
186 mips_hpt_frequency = JMR3927_TIMER_CLK;
179#ifdef USE_RTC_DS1742 187#ifdef USE_RTC_DS1742
180 if (jmr3927_have_nvram()) { 188 if (jmr3927_have_nvram()) {
181 rtc_ds1742_init(JMR3927_IOC_NVRAMB_ADDR); 189 rtc_ds1742_init(JMR3927_IOC_NVRAMB_ADDR);
@@ -183,12 +191,8 @@ static void __init jmr3927_time_init(void)
183#endif 191#endif
184} 192}
185 193
186unsigned long jmr3927_do_gettimeoffset(void);
187
188void __init plat_timer_setup(struct irqaction *irq) 194void __init plat_timer_setup(struct irqaction *irq)
189{ 195{
190 do_gettimeoffset = jmr3927_do_gettimeoffset;
191
192 jmr3927_tmrptr->cpra = JMR3927_TIMER_CLK / HZ; 196 jmr3927_tmrptr->cpra = JMR3927_TIMER_CLK / HZ;
193 jmr3927_tmrptr->itmr = TXx927_TMTITMR_TIIE | TXx927_TMTITMR_TZCE; 197 jmr3927_tmrptr->itmr = TXx927_TMTITMR_TIIE | TXx927_TMTITMR_TZCE;
194 jmr3927_tmrptr->ccdr = JMR3927_TIMER_CCD; 198 jmr3927_tmrptr->ccdr = JMR3927_TIMER_CCD;
@@ -200,34 +204,6 @@ void __init plat_timer_setup(struct irqaction *irq)
200 204
201#define USECS_PER_JIFFY (1000000/HZ) 205#define USECS_PER_JIFFY (1000000/HZ)
202 206
203unsigned long jmr3927_do_gettimeoffset(void)
204{
205 unsigned long count;
206 unsigned long res = 0;
207
208 /* MUST read TRR before TISR. */
209 count = jmr3927_tmrptr->trr;
210
211 if (jmr3927_tmrptr->tisr & TXx927_TMTISR_TIIS) {
212 /* timer interrupt is pending. use Max value. */
213 res = USECS_PER_JIFFY - 1;
214 } else {
215 /* convert to usec */
216 /* res = count / (JMR3927_TIMER_CLK / 1000000); */
217 res = (count << 7) / ((JMR3927_TIMER_CLK << 7) / 1000000);
218
219 /*
220 * Due to possible jiffies inconsistencies, we need to check
221 * the result so that we'll get a timer that is monotonic.
222 */
223 if (res >= USECS_PER_JIFFY)
224 res = USECS_PER_JIFFY-1;
225 }
226
227 return res;
228}
229
230
231//#undef DO_WRITE_THROUGH 207//#undef DO_WRITE_THROUGH
232#define DO_WRITE_THROUGH 208#define DO_WRITE_THROUGH
233#define DO_ENABLE_CACHE 209#define DO_ENABLE_CACHE
diff --git a/arch/mips/kernel/asm-offsets.c b/arch/mips/kernel/asm-offsets.c
index e9ce5b3721af..ff88b06f89df 100644
--- a/arch/mips/kernel/asm-offsets.c
+++ b/arch/mips/kernel/asm-offsets.c
@@ -22,7 +22,7 @@
22#define offset(string, ptr, member) \ 22#define offset(string, ptr, member) \
23 __asm__("\n@@@" string "%0" : : "i" (_offset(ptr, member))) 23 __asm__("\n@@@" string "%0" : : "i" (_offset(ptr, member)))
24#define constant(string, member) \ 24#define constant(string, member) \
25 __asm__("\n@@@" string "%x0" : : "ri" (member)) 25 __asm__("\n@@@" string "%X0" : : "ri" (member))
26#define size(string, size) \ 26#define size(string, size) \
27 __asm__("\n@@@" string "%0" : : "i" (sizeof(size))) 27 __asm__("\n@@@" string "%0" : : "i" (sizeof(size)))
28#define linefeed text("") 28#define linefeed text("")
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
index 417c08ac76eb..f10b6a19f8bf 100644
--- a/arch/mips/kernel/entry.S
+++ b/arch/mips/kernel/entry.S
@@ -83,7 +83,10 @@ FEXPORT(syscall_exit)
83FEXPORT(restore_all) # restore full frame 83FEXPORT(restore_all) # restore full frame
84#ifdef CONFIG_MIPS_MT_SMTC 84#ifdef CONFIG_MIPS_MT_SMTC
85/* Detect and execute deferred IPI "interrupts" */ 85/* Detect and execute deferred IPI "interrupts" */
86 LONG_L s0, TI_REGS($28)
87 LONG_S sp, TI_REGS($28)
86 jal deferred_smtc_ipi 88 jal deferred_smtc_ipi
89 LONG_S s0, TI_REGS($28)
87/* Re-arm any temporarily masked interrupts not explicitly "acked" */ 90/* Re-arm any temporarily masked interrupts not explicitly "acked" */
88 mfc0 v0, CP0_TCSTATUS 91 mfc0 v0, CP0_TCSTATUS
89 ori v1, v0, TCSTATUS_IXMT 92 ori v1, v0, TCSTATUS_IXMT
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 8c6db0fc72f0..ddc1b71c9378 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -189,7 +189,8 @@ NESTED(kernel_entry, 16, sp) # kernel entry point
189 189
190 MTC0 zero, CP0_CONTEXT # clear context register 190 MTC0 zero, CP0_CONTEXT # clear context register
191 PTR_LA $28, init_thread_union 191 PTR_LA $28, init_thread_union
192 PTR_ADDIU sp, $28, _THREAD_SIZE - 32 192 PTR_LI sp, _THREAD_SIZE - 32
193 PTR_ADDU sp, $28
193 set_saved_sp sp, t0, t1 194 set_saved_sp sp, t0, t1
194 PTR_SUBU sp, 4 * SZREG # init stack pointer 195 PTR_SUBU sp, 4 * SZREG # init stack pointer
195 196
diff --git a/arch/mips/kernel/r4k_switch.S b/arch/mips/kernel/r4k_switch.S
index d5c8b82fed72..cc566cf12246 100644
--- a/arch/mips/kernel/r4k_switch.S
+++ b/arch/mips/kernel/r4k_switch.S
@@ -85,7 +85,12 @@
85 move $28, a2 85 move $28, a2
86 cpu_restore_nonscratch a1 86 cpu_restore_nonscratch a1
87 87
88#if (_THREAD_SIZE - 32) < 0x10000
88 PTR_ADDIU t0, $28, _THREAD_SIZE - 32 89 PTR_ADDIU t0, $28, _THREAD_SIZE - 32
90#else
91 PTR_LI t0, _THREAD_SIZE - 32
92 PTR_ADDU t0, $28
93#endif
89 set_saved_sp t0, t1, t2 94 set_saved_sp t0, t1, t2
90#ifdef CONFIG_MIPS_MT_SMTC 95#ifdef CONFIG_MIPS_MT_SMTC
91 /* Read-modify-writes of Status must be atomic on a VPE */ 96 /* Read-modify-writes of Status must be atomic on a VPE */
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 720fac3435d5..a95f37de080e 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -654,6 +654,8 @@ einval: li v0, -EINVAL
654 sys sys_set_robust_list 2 654 sys sys_set_robust_list 2
655 sys sys_get_robust_list 3 /* 4310 */ 655 sys sys_get_robust_list 3 /* 4310 */
656 sys sys_ni_syscall 0 656 sys sys_ni_syscall 0
657 sys sys_getcpu 3
658 sys sys_epoll_pwait 6
657 .endm 659 .endm
658 660
659 /* We pre-compute the number of _instruction_ bytes needed to 661 /* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index 3a34f62c8b1b..8fb0f60f657b 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -469,3 +469,5 @@ sys_call_table:
469 PTR sys_set_robust_list 469 PTR sys_set_robust_list
470 PTR sys_get_robust_list 470 PTR sys_get_robust_list
471 PTR sys_ni_syscall /* 5270 */ 471 PTR sys_ni_syscall /* 5270 */
472 PTR sys_getcpu
473 PTR sys_epoll_pwait
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 67b92a1d6c72..0da5ca2040ff 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -395,3 +395,5 @@ EXPORT(sysn32_call_table)
395 PTR compat_sys_set_robust_list 395 PTR compat_sys_set_robust_list
396 PTR compat_sys_get_robust_list 396 PTR compat_sys_get_robust_list
397 PTR sys_ni_syscall 397 PTR sys_ni_syscall
398 PTR sys_getcpu
399 PTR sys_epoll_pwait
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 2875c4a3fa58..b9d00cae8b5f 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -517,4 +517,6 @@ sys_call_table:
517 PTR compat_sys_set_robust_list 517 PTR compat_sys_set_robust_list
518 PTR compat_sys_get_robust_list /* 4310 */ 518 PTR compat_sys_get_robust_list /* 4310 */
519 PTR sys_ni_syscall 519 PTR sys_ni_syscall
520 PTR sys_getcpu
521 PTR sys_epoll_pwait
520 .size sys_call_table,.-sys_call_table 522 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c
index 3b5f3b632622..2ac19a6cbf68 100644
--- a/arch/mips/kernel/smp-mt.c
+++ b/arch/mips/kernel/smp-mt.c
@@ -140,15 +140,90 @@ static struct irqaction irq_call = {
140 .name = "IPI_call" 140 .name = "IPI_call"
141}; 141};
142 142
143static void __init smp_copy_vpe_config(void)
144{
145 write_vpe_c0_status(
146 (read_c0_status() & ~(ST0_IM | ST0_IE | ST0_KSU)) | ST0_CU0);
147
148 /* set config to be the same as vpe0, particularly kseg0 coherency alg */
149 write_vpe_c0_config( read_c0_config());
150
151 /* make sure there are no software interrupts pending */
152 write_vpe_c0_cause(0);
153
154 /* Propagate Config7 */
155 write_vpe_c0_config7(read_c0_config7());
156
157 write_vpe_c0_count(read_c0_count());
158}
159
160static unsigned int __init smp_vpe_init(unsigned int tc, unsigned int mvpconf0,
161 unsigned int ncpu)
162{
163 if (tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT))
164 return ncpu;
165
166 /* Deactivate all but VPE 0 */
167 if (tc != 0) {
168 unsigned long tmp = read_vpe_c0_vpeconf0();
169
170 tmp &= ~VPECONF0_VPA;
171
172 /* master VPE */
173 tmp |= VPECONF0_MVP;
174 write_vpe_c0_vpeconf0(tmp);
175
176 /* Record this as available CPU */
177 cpu_set(tc, phys_cpu_present_map);
178 __cpu_number_map[tc] = ++ncpu;
179 __cpu_logical_map[ncpu] = tc;
180 }
181
182 /* Disable multi-threading with TC's */
183 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() & ~VPECONTROL_TE);
184
185 if (tc != 0)
186 smp_copy_vpe_config();
187
188 return ncpu;
189}
190
191static void __init smp_tc_init(unsigned int tc, unsigned int mvpconf0)
192{
193 unsigned long tmp;
194
195 if (!tc)
196 return;
197
198 /* bind a TC to each VPE, May as well put all excess TC's
199 on the last VPE */
200 if (tc >= (((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)+1))
201 write_tc_c0_tcbind(read_tc_c0_tcbind() | ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT));
202 else {
203 write_tc_c0_tcbind(read_tc_c0_tcbind() | tc);
204
205 /* and set XTC */
206 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | (tc << VPECONF0_XTC_SHIFT));
207 }
208
209 tmp = read_tc_c0_tcstatus();
210
211 /* mark not allocated and not dynamically allocatable */
212 tmp &= ~(TCSTATUS_A | TCSTATUS_DA);
213 tmp |= TCSTATUS_IXMT; /* interrupt exempt */
214 write_tc_c0_tcstatus(tmp);
215
216 write_tc_c0_tchalt(TCHALT_H);
217}
218
143/* 219/*
144 * Common setup before any secondaries are started 220 * Common setup before any secondaries are started
145 * Make sure all CPU's are in a sensible state before we boot any of the 221 * Make sure all CPU's are in a sensible state before we boot any of the
146 * secondarys 222 * secondarys
147 */ 223 */
148void plat_smp_setup(void) 224void __init plat_smp_setup(void)
149{ 225{
150 unsigned long val; 226 unsigned int mvpconf0, ntc, tc, ncpu = 0;
151 int i, num;
152 227
153#ifdef CONFIG_MIPS_MT_FPAFF 228#ifdef CONFIG_MIPS_MT_FPAFF
154 /* If we have an FPU, enroll ourselves in the FPU-full mask */ 229 /* If we have an FPU, enroll ourselves in the FPU-full mask */
@@ -167,75 +242,16 @@ void plat_smp_setup(void)
167 /* Put MVPE's into 'configuration state' */ 242 /* Put MVPE's into 'configuration state' */
168 set_c0_mvpcontrol(MVPCONTROL_VPC); 243 set_c0_mvpcontrol(MVPCONTROL_VPC);
169 244
170 val = read_c0_mvpconf0(); 245 mvpconf0 = read_c0_mvpconf0();
246 ntc = (mvpconf0 & MVPCONF0_PTC) >> MVPCONF0_PTC_SHIFT;
171 247
172 /* we'll always have more TC's than VPE's, so loop setting everything 248 /* we'll always have more TC's than VPE's, so loop setting everything
173 to a sensible state */ 249 to a sensible state */
174 for (i = 0, num = 0; i <= ((val & MVPCONF0_PTC) >> MVPCONF0_PTC_SHIFT); i++) { 250 for (tc = 0; tc <= ntc; tc++) {
175 settc(i); 251 settc(tc);
176
177 /* VPE's */
178 if (i <= ((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)) {
179
180 /* deactivate all but vpe0 */
181 if (i != 0) {
182 unsigned long tmp = read_vpe_c0_vpeconf0();
183
184 tmp &= ~VPECONF0_VPA;
185
186 /* master VPE */
187 tmp |= VPECONF0_MVP;
188 write_vpe_c0_vpeconf0(tmp);
189
190 /* Record this as available CPU */
191 cpu_set(i, phys_cpu_present_map);
192 __cpu_number_map[i] = ++num;
193 __cpu_logical_map[num] = i;
194 }
195
196 /* disable multi-threading with TC's */
197 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() & ~VPECONTROL_TE);
198
199 if (i != 0) {
200 write_vpe_c0_status((read_c0_status() & ~(ST0_IM | ST0_IE | ST0_KSU)) | ST0_CU0);
201 252
202 /* set config to be the same as vpe0, particularly kseg0 coherency alg */ 253 smp_tc_init(tc, mvpconf0);
203 write_vpe_c0_config( read_c0_config()); 254 ncpu = smp_vpe_init(tc, mvpconf0, ncpu);
204
205 /* make sure there are no software interrupts pending */
206 write_vpe_c0_cause(0);
207
208 /* Propagate Config7 */
209 write_vpe_c0_config7(read_c0_config7());
210 }
211
212 }
213
214 /* TC's */
215
216 if (i != 0) {
217 unsigned long tmp;
218
219 /* bind a TC to each VPE, May as well put all excess TC's
220 on the last VPE */
221 if ( i >= (((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)+1) )
222 write_tc_c0_tcbind(read_tc_c0_tcbind() | ((val & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT) );
223 else {
224 write_tc_c0_tcbind( read_tc_c0_tcbind() | i);
225
226 /* and set XTC */
227 write_vpe_c0_vpeconf0( read_vpe_c0_vpeconf0() | (i << VPECONF0_XTC_SHIFT));
228 }
229
230 tmp = read_tc_c0_tcstatus();
231
232 /* mark not allocated and not dynamically allocatable */
233 tmp &= ~(TCSTATUS_A | TCSTATUS_DA);
234 tmp |= TCSTATUS_IXMT; /* interrupt exempt */
235 write_tc_c0_tcstatus(tmp);
236
237 write_tc_c0_tchalt(TCHALT_H);
238 }
239 } 255 }
240 256
241 /* Release config state */ 257 /* Release config state */
@@ -243,7 +259,7 @@ void plat_smp_setup(void)
243 259
244 /* We'll wait until starting the secondaries before starting MVPE */ 260 /* We'll wait until starting the secondaries before starting MVPE */
245 261
246 printk(KERN_INFO "Detected %i available secondary CPU(s)\n", num); 262 printk(KERN_INFO "Detected %i available secondary CPU(s)\n", ncpu);
247} 263}
248 264
249void __init plat_prepare_cpus(unsigned int max_cpus) 265void __init plat_prepare_cpus(unsigned int max_cpus)
diff --git a/arch/mips/kernel/smtc-asm.S b/arch/mips/kernel/smtc-asm.S
index 1cb9441f1474..921207c4a83c 100644
--- a/arch/mips/kernel/smtc-asm.S
+++ b/arch/mips/kernel/smtc-asm.S
@@ -101,7 +101,9 @@ FEXPORT(__smtc_ipi_vector)
101 lw t0,PT_PADSLOT5(sp) 101 lw t0,PT_PADSLOT5(sp)
102 /* Argument from sender passed in stack pad slot 4 */ 102 /* Argument from sender passed in stack pad slot 4 */
103 lw a0,PT_PADSLOT4(sp) 103 lw a0,PT_PADSLOT4(sp)
104 PTR_LA ra, _ret_from_irq 104 LONG_L s0, TI_REGS($28)
105 LONG_S sp, TI_REGS($28)
106 PTR_LA ra, ret_from_irq
105 jr t0 107 jr t0
106 108
107/* 109/*
@@ -119,7 +121,10 @@ LEAF(self_ipi)
119 subu t1,sp,PT_SIZE 121 subu t1,sp,PT_SIZE
120 sw ra,PT_EPC(t1) 122 sw ra,PT_EPC(t1)
121 sw a0,PT_PADSLOT4(t1) 123 sw a0,PT_PADSLOT4(t1)
124 LONG_L s0, TI_REGS($28)
125 LONG_S sp, TI_REGS($28)
122 la t2,ipi_decode 126 la t2,ipi_decode
127 LONG_S s0, TI_REGS($28)
123 sw t2,PT_PADSLOT5(t1) 128 sw t2,PT_PADSLOT5(t1)
124 /* Save pre-disable value of TCStatus */ 129 /* Save pre-disable value of TCStatus */
125 sw t0,PT_TCSTATUS(t1) 130 sw t0,PT_TCSTATUS(t1)
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index cc1f7474f7d7..3b78caf112f5 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -476,6 +476,7 @@ void mipsmt_prepare_cpus(void)
476 write_vpe_c0_compare(0); 476 write_vpe_c0_compare(0);
477 /* Propagate Config7 */ 477 /* Propagate Config7 */
478 write_vpe_c0_config7(read_c0_config7()); 478 write_vpe_c0_config7(read_c0_config7());
479 write_vpe_c0_count(read_c0_count());
479 } 480 }
480 /* enable multi-threading within VPE */ 481 /* enable multi-threading within VPE */
481 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() | VPECONTROL_TE); 482 write_vpe_c0_vpecontrol(read_vpe_c0_vpecontrol() | VPECONTROL_TE);
diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
index debe86c2f691..e535f86efa2f 100644
--- a/arch/mips/kernel/time.c
+++ b/arch/mips/kernel/time.c
@@ -11,6 +11,7 @@
11 * Free Software Foundation; either version 2 of the License, or (at your 11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version. 12 * option) any later version.
13 */ 13 */
14#include <linux/clocksource.h>
14#include <linux/types.h> 15#include <linux/types.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/init.h> 17#include <linux/init.h>
@@ -67,15 +68,9 @@ int (*rtc_mips_set_time)(unsigned long) = null_rtc_set_time;
67int (*rtc_mips_set_mmss)(unsigned long); 68int (*rtc_mips_set_mmss)(unsigned long);
68 69
69 70
70/* usecs per counter cycle, shifted to left by 32 bits */
71static unsigned int sll32_usecs_per_cycle;
72
73/* how many counter cycles in a jiffy */ 71/* how many counter cycles in a jiffy */
74static unsigned long cycles_per_jiffy __read_mostly; 72static unsigned long cycles_per_jiffy __read_mostly;
75 73
76/* Cycle counter value at the previous timer interrupt.. */
77static unsigned int timerhi, timerlo;
78
79/* expirelo is the count value for next CPU timer interrupt */ 74/* expirelo is the count value for next CPU timer interrupt */
80static unsigned int expirelo; 75static unsigned int expirelo;
81 76
@@ -93,7 +88,7 @@ static unsigned int null_hpt_read(void)
93 return 0; 88 return 0;
94} 89}
95 90
96static void null_hpt_init(unsigned int count) 91static void __init null_hpt_init(void)
97{ 92{
98 /* nothing */ 93 /* nothing */
99} 94}
@@ -128,186 +123,18 @@ static unsigned int c0_hpt_read(void)
128 return read_c0_count(); 123 return read_c0_count();
129} 124}
130 125
131/* For use solely as a high precision timer. */
132static void c0_hpt_init(unsigned int count)
133{
134 write_c0_count(read_c0_count() - count);
135}
136
137/* For use both as a high precision timer and an interrupt source. */ 126/* For use both as a high precision timer and an interrupt source. */
138static void c0_hpt_timer_init(unsigned int count) 127static void __init c0_hpt_timer_init(void)
139{ 128{
140 count = read_c0_count() - count; 129 expirelo = read_c0_count() + cycles_per_jiffy;
141 expirelo = (count / cycles_per_jiffy + 1) * cycles_per_jiffy;
142 write_c0_count(expirelo - cycles_per_jiffy);
143 write_c0_compare(expirelo); 130 write_c0_compare(expirelo);
144 write_c0_count(count);
145} 131}
146 132
147int (*mips_timer_state)(void); 133int (*mips_timer_state)(void);
148void (*mips_timer_ack)(void); 134void (*mips_timer_ack)(void);
149unsigned int (*mips_hpt_read)(void); 135unsigned int (*mips_hpt_read)(void);
150void (*mips_hpt_init)(unsigned int); 136void (*mips_hpt_init)(void) __initdata = null_hpt_init;
151 137unsigned int mips_hpt_mask = 0xffffffff;
152/*
153 * Gettimeoffset routines. These routines returns the time duration
154 * since last timer interrupt in usecs.
155 *
156 * If the exact CPU counter frequency is known, use fixed_rate_gettimeoffset.
157 * Otherwise use calibrate_gettimeoffset()
158 *
159 * If the CPU does not have the counter register, you can either supply
160 * your own gettimeoffset() routine, or use null_gettimeoffset(), which
161 * gives the same resolution as HZ.
162 */
163
164static unsigned long null_gettimeoffset(void)
165{
166 return 0;
167}
168
169
170/* The function pointer to one of the gettimeoffset funcs. */
171unsigned long (*do_gettimeoffset)(void) = null_gettimeoffset;
172
173
174static unsigned long fixed_rate_gettimeoffset(void)
175{
176 u32 count;
177 unsigned long res;
178
179 /* Get last timer tick in absolute kernel time */
180 count = mips_hpt_read();
181
182 /* .. relative to previous jiffy (32 bits is enough) */
183 count -= timerlo;
184
185 __asm__("multu %1,%2"
186 : "=h" (res)
187 : "r" (count), "r" (sll32_usecs_per_cycle)
188 : "lo", GCC_REG_ACCUM);
189
190 /*
191 * Due to possible jiffies inconsistencies, we need to check
192 * the result so that we'll get a timer that is monotonic.
193 */
194 if (res >= USECS_PER_JIFFY)
195 res = USECS_PER_JIFFY - 1;
196
197 return res;
198}
199
200
201/*
202 * Cached "1/(clocks per usec) * 2^32" value.
203 * It has to be recalculated once each jiffy.
204 */
205static unsigned long cached_quotient;
206
207/* Last jiffy when calibrate_divXX_gettimeoffset() was called. */
208static unsigned long last_jiffies;
209
210/*
211 * This is moved from dec/time.c:do_ioasic_gettimeoffset() by Maciej.
212 */
213static unsigned long calibrate_div32_gettimeoffset(void)
214{
215 u32 count;
216 unsigned long res, tmp;
217 unsigned long quotient;
218
219 tmp = jiffies;
220
221 quotient = cached_quotient;
222
223 if (last_jiffies != tmp) {
224 last_jiffies = tmp;
225 if (last_jiffies != 0) {
226 unsigned long r0;
227 do_div64_32(r0, timerhi, timerlo, tmp);
228 do_div64_32(quotient, USECS_PER_JIFFY,
229 USECS_PER_JIFFY_FRAC, r0);
230 cached_quotient = quotient;
231 }
232 }
233
234 /* Get last timer tick in absolute kernel time */
235 count = mips_hpt_read();
236
237 /* .. relative to previous jiffy (32 bits is enough) */
238 count -= timerlo;
239
240 __asm__("multu %1,%2"
241 : "=h" (res)
242 : "r" (count), "r" (quotient)
243 : "lo", GCC_REG_ACCUM);
244
245 /*
246 * Due to possible jiffies inconsistencies, we need to check
247 * the result so that we'll get a timer that is monotonic.
248 */
249 if (res >= USECS_PER_JIFFY)
250 res = USECS_PER_JIFFY - 1;
251
252 return res;
253}
254
255static unsigned long calibrate_div64_gettimeoffset(void)
256{
257 u32 count;
258 unsigned long res, tmp;
259 unsigned long quotient;
260
261 tmp = jiffies;
262
263 quotient = cached_quotient;
264
265 if (last_jiffies != tmp) {
266 last_jiffies = tmp;
267 if (last_jiffies) {
268 unsigned long r0;
269 __asm__(".set push\n\t"
270 ".set mips3\n\t"
271 "lwu %0,%3\n\t"
272 "dsll32 %1,%2,0\n\t"
273 "or %1,%1,%0\n\t"
274 "ddivu $0,%1,%4\n\t"
275 "mflo %1\n\t"
276 "dsll32 %0,%5,0\n\t"
277 "or %0,%0,%6\n\t"
278 "ddivu $0,%0,%1\n\t"
279 "mflo %0\n\t"
280 ".set pop"
281 : "=&r" (quotient), "=&r" (r0)
282 : "r" (timerhi), "m" (timerlo),
283 "r" (tmp), "r" (USECS_PER_JIFFY),
284 "r" (USECS_PER_JIFFY_FRAC)
285 : "hi", "lo", GCC_REG_ACCUM);
286 cached_quotient = quotient;
287 }
288 }
289
290 /* Get last timer tick in absolute kernel time */
291 count = mips_hpt_read();
292
293 /* .. relative to previous jiffy (32 bits is enough) */
294 count -= timerlo;
295
296 __asm__("multu %1,%2"
297 : "=h" (res)
298 : "r" (count), "r" (quotient)
299 : "lo", GCC_REG_ACCUM);
300
301 /*
302 * Due to possible jiffies inconsistencies, we need to check
303 * the result so that we'll get a timer that is monotonic.
304 */
305 if (res >= USECS_PER_JIFFY)
306 res = USECS_PER_JIFFY - 1;
307
308 return res;
309}
310
311 138
312/* last time when xtime and rtc are sync'ed up */ 139/* last time when xtime and rtc are sync'ed up */
313static long last_rtc_update; 140static long last_rtc_update;
@@ -334,18 +161,10 @@ void local_timer_interrupt(int irq, void *dev_id)
334 */ 161 */
335irqreturn_t timer_interrupt(int irq, void *dev_id) 162irqreturn_t timer_interrupt(int irq, void *dev_id)
336{ 163{
337 unsigned long j;
338 unsigned int count;
339
340 write_seqlock(&xtime_lock); 164 write_seqlock(&xtime_lock);
341 165
342 count = mips_hpt_read();
343 mips_timer_ack(); 166 mips_timer_ack();
344 167
345 /* Update timerhi/timerlo for intra-jiffy calibration. */
346 timerhi += count < timerlo; /* Wrap around */
347 timerlo = count;
348
349 /* 168 /*
350 * call the generic timer interrupt handling 169 * call the generic timer interrupt handling
351 */ 170 */
@@ -368,47 +187,6 @@ irqreturn_t timer_interrupt(int irq, void *dev_id)
368 } 187 }
369 } 188 }
370 189
371 /*
372 * If jiffies has overflown in this timer_interrupt, we must
373 * update the timer[hi]/[lo] to make fast gettimeoffset funcs
374 * quotient calc still valid. -arca
375 *
376 * The first timer interrupt comes late as interrupts are
377 * enabled long after timers are initialized. Therefore the
378 * high precision timer is fast, leading to wrong gettimeoffset()
379 * calculations. We deal with it by setting it based on the
380 * number of its ticks between the second and the third interrupt.
381 * That is still somewhat imprecise, but it's a good estimate.
382 * --macro
383 */
384 j = jiffies;
385 if (j < 4) {
386 static unsigned int prev_count;
387 static int hpt_initialized;
388
389 switch (j) {
390 case 0:
391 timerhi = timerlo = 0;
392 mips_hpt_init(count);
393 break;
394 case 2:
395 prev_count = count;
396 break;
397 case 3:
398 if (!hpt_initialized) {
399 unsigned int c3 = 3 * (count - prev_count);
400
401 timerhi = 0;
402 timerlo = c3;
403 mips_hpt_init(count - c3);
404 hpt_initialized = 1;
405 }
406 break;
407 default:
408 break;
409 }
410 }
411
412 write_sequnlock(&xtime_lock); 190 write_sequnlock(&xtime_lock);
413 191
414 /* 192 /*
@@ -476,12 +254,11 @@ asmlinkage void ll_local_timer_interrupt(int irq)
476 * 1) board_time_init() - 254 * 1) board_time_init() -
477 * a) (optional) set up RTC routines, 255 * a) (optional) set up RTC routines,
478 * b) (optional) calibrate and set the mips_hpt_frequency 256 * b) (optional) calibrate and set the mips_hpt_frequency
479 * (only needed if you intended to use fixed_rate_gettimeoffset 257 * (only needed if you intended to use cpu counter as timer interrupt
480 * or use cpu counter as timer interrupt source) 258 * source)
481 * 2) setup xtime based on rtc_mips_get_time(). 259 * 2) setup xtime based on rtc_mips_get_time().
482 * 3) choose a appropriate gettimeoffset routine. 260 * 3) calculate a couple of cached variables for later usage
483 * 4) calculate a couple of cached variables for later usage 261 * 4) plat_timer_setup() -
484 * 5) plat_timer_setup() -
485 * a) (optional) over-write any choices made above by time_init(). 262 * a) (optional) over-write any choices made above by time_init().
486 * b) machine specific code should setup the timer irqaction. 263 * b) machine specific code should setup the timer irqaction.
487 * c) enable the timer interrupt 264 * c) enable the timer interrupt
@@ -533,13 +310,48 @@ static unsigned int __init calibrate_hpt(void)
533 } while (--i); 310 } while (--i);
534 hpt_end = mips_hpt_read(); 311 hpt_end = mips_hpt_read();
535 312
536 hpt_count = hpt_end - hpt_start; 313 hpt_count = (hpt_end - hpt_start) & mips_hpt_mask;
537 hz = HZ; 314 hz = HZ;
538 frequency = (u64)hpt_count * (u64)hz; 315 frequency = (u64)hpt_count * (u64)hz;
539 316
540 return frequency >> log_2_loops; 317 return frequency >> log_2_loops;
541} 318}
542 319
320static cycle_t read_mips_hpt(void)
321{
322 return (cycle_t)mips_hpt_read();
323}
324
325static struct clocksource clocksource_mips = {
326 .name = "MIPS",
327 .read = read_mips_hpt,
328 .is_continuous = 1,
329};
330
331static void __init init_mips_clocksource(void)
332{
333 u64 temp;
334 u32 shift;
335
336 if (!mips_hpt_frequency || mips_hpt_read == null_hpt_read)
337 return;
338
339 /* Calclate a somewhat reasonable rating value */
340 clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;
341 /* Find a shift value */
342 for (shift = 32; shift > 0; shift--) {
343 temp = (u64) NSEC_PER_SEC << shift;
344 do_div(temp, mips_hpt_frequency);
345 if ((temp >> 32) == 0)
346 break;
347 }
348 clocksource_mips.shift = shift;
349 clocksource_mips.mult = (u32)temp;
350 clocksource_mips.mask = mips_hpt_mask;
351
352 clocksource_register(&clocksource_mips);
353}
354
543void __init time_init(void) 355void __init time_init(void)
544{ 356{
545 if (board_time_init) 357 if (board_time_init)
@@ -555,41 +367,21 @@ void __init time_init(void)
555 -xtime.tv_sec, -xtime.tv_nsec); 367 -xtime.tv_sec, -xtime.tv_nsec);
556 368
557 /* Choose appropriate high precision timer routines. */ 369 /* Choose appropriate high precision timer routines. */
558 if (!cpu_has_counter && !mips_hpt_read) { 370 if (!cpu_has_counter && !mips_hpt_read)
559 /* No high precision timer -- sorry. */ 371 /* No high precision timer -- sorry. */
560 mips_hpt_read = null_hpt_read; 372 mips_hpt_read = null_hpt_read;
561 mips_hpt_init = null_hpt_init; 373 else if (!mips_hpt_frequency && !mips_timer_state) {
562 } else if (!mips_hpt_frequency && !mips_timer_state) {
563 /* A high precision timer of unknown frequency. */ 374 /* A high precision timer of unknown frequency. */
564 if (!mips_hpt_read) { 375 if (!mips_hpt_read)
565 /* No external high precision timer -- use R4k. */ 376 /* No external high precision timer -- use R4k. */
566 mips_hpt_read = c0_hpt_read; 377 mips_hpt_read = c0_hpt_read;
567 mips_hpt_init = c0_hpt_init;
568 }
569
570 if (cpu_has_mips32r1 || cpu_has_mips32r2 ||
571 (current_cpu_data.isa_level == MIPS_CPU_ISA_I) ||
572 (current_cpu_data.isa_level == MIPS_CPU_ISA_II))
573 /*
574 * We need to calibrate the counter but we don't have
575 * 64-bit division.
576 */
577 do_gettimeoffset = calibrate_div32_gettimeoffset;
578 else
579 /*
580 * We need to calibrate the counter but we *do* have
581 * 64-bit division.
582 */
583 do_gettimeoffset = calibrate_div64_gettimeoffset;
584 } else { 378 } else {
585 /* We know counter frequency. Or we can get it. */ 379 /* We know counter frequency. Or we can get it. */
586 if (!mips_hpt_read) { 380 if (!mips_hpt_read) {
587 /* No external high precision timer -- use R4k. */ 381 /* No external high precision timer -- use R4k. */
588 mips_hpt_read = c0_hpt_read; 382 mips_hpt_read = c0_hpt_read;
589 383
590 if (mips_timer_state) 384 if (!mips_timer_state) {
591 mips_hpt_init = c0_hpt_init;
592 else {
593 /* No external timer interrupt -- use R4k. */ 385 /* No external timer interrupt -- use R4k. */
594 mips_hpt_init = c0_hpt_timer_init; 386 mips_hpt_init = c0_hpt_timer_init;
595 mips_timer_ack = c0_timer_ack; 387 mips_timer_ack = c0_timer_ack;
@@ -598,16 +390,9 @@ void __init time_init(void)
598 if (!mips_hpt_frequency) 390 if (!mips_hpt_frequency)
599 mips_hpt_frequency = calibrate_hpt(); 391 mips_hpt_frequency = calibrate_hpt();
600 392
601 do_gettimeoffset = fixed_rate_gettimeoffset;
602
603 /* Calculate cache parameters. */ 393 /* Calculate cache parameters. */
604 cycles_per_jiffy = (mips_hpt_frequency + HZ / 2) / HZ; 394 cycles_per_jiffy = (mips_hpt_frequency + HZ / 2) / HZ;
605 395
606 /* sll32_usecs_per_cycle = 10^6 * 2^32 / mips_counter_freq */
607 do_div64_32(sll32_usecs_per_cycle,
608 1000000, mips_hpt_frequency / 2,
609 mips_hpt_frequency);
610
611 /* Report the high precision timer rate for a reference. */ 396 /* Report the high precision timer rate for a reference. */
612 printk("Using %u.%03u MHz high precision timer.\n", 397 printk("Using %u.%03u MHz high precision timer.\n",
613 ((mips_hpt_frequency + 500) / 1000) / 1000, 398 ((mips_hpt_frequency + 500) / 1000) / 1000,
@@ -619,7 +404,7 @@ void __init time_init(void)
619 mips_timer_ack = null_timer_ack; 404 mips_timer_ack = null_timer_ack;
620 405
621 /* This sets up the high precision timer for the first interrupt. */ 406 /* This sets up the high precision timer for the first interrupt. */
622 mips_hpt_init(mips_hpt_read()); 407 mips_hpt_init();
623 408
624 /* 409 /*
625 * Call board specific timer interrupt setup. 410 * Call board specific timer interrupt setup.
@@ -633,6 +418,8 @@ void __init time_init(void)
633 * is not invoked accidentally. 418 * is not invoked accidentally.
634 */ 419 */
635 plat_timer_setup(&timer_irqaction); 420 plat_timer_setup(&timer_irqaction);
421
422 init_mips_clocksource();
636} 423}
637 424
638#define FEBRUARY 2 425#define FEBRUARY 2
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index cce8313ec27d..9fda1b8be3a7 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1111,7 +1111,7 @@ static struct shadow_registers {
1111static void mips_srs_init(void) 1111static void mips_srs_init(void)
1112{ 1112{
1113 shadow_registers.sr_supported = ((read_c0_srsctl() >> 26) & 0x0f) + 1; 1113 shadow_registers.sr_supported = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1114 printk(KERN_INFO "%d MIPSR2 register sets available\n", 1114 printk(KERN_INFO "%ld MIPSR2 register sets available\n",
1115 shadow_registers.sr_supported); 1115 shadow_registers.sr_supported);
1116 shadow_registers.sr_allocated = 1; /* Set 0 used by kernel */ 1116 shadow_registers.sr_allocated = 1; /* Set 0 used by kernel */
1117} 1117}
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 25ed3337ce35..79f0317d84ac 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -50,6 +50,16 @@ SECTIONS
50 /* writeable */ 50 /* writeable */
51 .data : { /* Data */ 51 .data : { /* Data */
52 . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */ 52 . = . + DATAOFFSET; /* for CONFIG_MAPPED_KERNEL */
53 /*
54 * This ALIGN is needed as a workaround for a bug a gcc bug upto 4.1 which
55 * limits the maximum alignment to at most 32kB and results in the following
56 * warning:
57 *
58 * CC arch/mips/kernel/init_task.o
59 * arch/mips/kernel/init_task.c:30: warning: alignment of ‘init_thread_union’
60 * is greater than maximum object file alignment. Using 32768
61 */
62 . = ALIGN(_PAGE_SIZE);
53 *(.data.init_task) 63 *(.data.init_task)
54 64
55 *(.data) 65 *(.data)
diff --git a/arch/mips/lib-64/dump_tlb.c b/arch/mips/lib-64/dump_tlb.c
index be8261be679b..594df1a05ecc 100644
--- a/arch/mips/lib-64/dump_tlb.c
+++ b/arch/mips/lib-64/dump_tlb.c
@@ -149,7 +149,7 @@ void dump_list_process(struct task_struct *t, void *address)
149 printk("Addr == %08lx\n", addr); 149 printk("Addr == %08lx\n", addr);
150 printk("tasks->mm.pgd == %08lx\n", (unsigned long) t->mm->pgd); 150 printk("tasks->mm.pgd == %08lx\n", (unsigned long) t->mm->pgd);
151 151
152 page_dir = pgd_offset(t->mm, 0); 152 page_dir = pgd_offset(t->mm, 0UL);
153 printk("page_dir == %016lx\n", (unsigned long) page_dir); 153 printk("page_dir == %016lx\n", (unsigned long) page_dir);
154 154
155 pgd = pgd_offset(t->mm, addr); 155 pgd = pgd_offset(t->mm, addr);
@@ -184,13 +184,13 @@ void dump_list_current(void *address)
184 dump_list_process(current, address); 184 dump_list_process(current, address);
185} 185}
186 186
187unsigned int vtop(void *address) 187unsigned long vtop(void *address)
188{ 188{
189 pgd_t *pgd; 189 pgd_t *pgd;
190 pud_t *pud; 190 pud_t *pud;
191 pmd_t *pmd; 191 pmd_t *pmd;
192 pte_t *pte; 192 pte_t *pte;
193 unsigned int addr, paddr; 193 unsigned long addr, paddr;
194 194
195 addr = (unsigned long) address; 195 addr = (unsigned long) address;
196 pgd = pgd_offset(current->mm, addr); 196 pgd = pgd_offset(current->mm, addr);
diff --git a/arch/mips/mips-boards/generic/memory.c b/arch/mips/mips-boards/generic/memory.c
index be80c5dd4a0c..eeed944e0f83 100644
--- a/arch/mips/mips-boards/generic/memory.c
+++ b/arch/mips/mips-boards/generic/memory.c
@@ -176,7 +176,7 @@ unsigned long __init prom_free_prom_memory(void)
176 if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA) 176 if (boot_mem_map.map[i].type != BOOT_MEM_ROM_DATA)
177 continue; 177 continue;
178 178
179 addr = boot_mem_map.map[i].addr; 179 addr = PAGE_ALIGN(boot_mem_map.map[i].addr);
180 while (addr < boot_mem_map.map[i].addr 180 while (addr < boot_mem_map.map[i].addr
181 + boot_mem_map.map[i].size) { 181 + boot_mem_map.map[i].size) {
182 ClearPageReserved(virt_to_page(__va(addr))); 182 ClearPageReserved(virt_to_page(__va(addr)));
diff --git a/arch/mips/mips-boards/generic/pci.c b/arch/mips/mips-boards/generic/pci.c
index 9337f6c8873a..3192a14698c8 100644
--- a/arch/mips/mips-boards/generic/pci.c
+++ b/arch/mips/mips-boards/generic/pci.c
@@ -90,7 +90,7 @@ static struct pci_controller msc_controller = {
90void __init mips_pcibios_init(void) 90void __init mips_pcibios_init(void)
91{ 91{
92 struct pci_controller *controller; 92 struct pci_controller *controller;
93 unsigned long start, end, map, start1, end1, map1, map2, map3, mask; 93 resource_size_t start, end, map, start1, end1, map1, map2, map3, mask;
94 94
95 switch (mips_revision_corid) { 95 switch (mips_revision_corid) {
96 case MIPS_REVISION_CORID_QED_RM5261: 96 case MIPS_REVISION_CORID_QED_RM5261:
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index c079e2ae02a1..d817c60c5ca5 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -208,7 +208,8 @@ static unsigned int __init estimate_cpu_frequency(void)
208 count = 6000000; 208 count = 6000000;
209#endif 209#endif
210#if defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_MALTA) 210#if defined(CONFIG_MIPS_ATLAS) || defined(CONFIG_MIPS_MALTA)
211 unsigned int flags; 211 unsigned long flags;
212 unsigned int start;
212 213
213 local_irq_save(flags); 214 local_irq_save(flags);
214 215
@@ -217,13 +218,13 @@ static unsigned int __init estimate_cpu_frequency(void)
217 while (!(CMOS_READ(RTC_REG_A) & RTC_UIP)); 218 while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
218 219
219 /* Start r4k counter. */ 220 /* Start r4k counter. */
220 write_c0_count(0); 221 start = read_c0_count();
221 222
222 /* Read counter exactly on falling edge of update flag */ 223 /* Read counter exactly on falling edge of update flag */
223 while (CMOS_READ(RTC_REG_A) & RTC_UIP); 224 while (CMOS_READ(RTC_REG_A) & RTC_UIP);
224 while (!(CMOS_READ(RTC_REG_A) & RTC_UIP)); 225 while (!(CMOS_READ(RTC_REG_A) & RTC_UIP));
225 226
226 count = read_c0_count(); 227 count = read_c0_count() - start;
227 228
228 /* restore interrupts */ 229 /* restore interrupts */
229 local_irq_restore(flags); 230 local_irq_restore(flags);
diff --git a/arch/mips/mm/c-sb1.c b/arch/mips/mm/c-sb1.c
index 5537558f19f7..ea49a775bf28 100644
--- a/arch/mips/mm/c-sb1.c
+++ b/arch/mips/mm/c-sb1.c
@@ -49,6 +49,15 @@ static unsigned short dcache_sets;
49static unsigned int icache_range_cutoff; 49static unsigned int icache_range_cutoff;
50static unsigned int dcache_range_cutoff; 50static unsigned int dcache_range_cutoff;
51 51
52static inline void sb1_on_each_cpu(void (*func) (void *info), void *info,
53 int retry, int wait)
54{
55 preempt_disable();
56 smp_call_function(func, info, retry, wait);
57 func(info);
58 preempt_enable();
59}
60
52/* 61/*
53 * The dcache is fully coherent to the system, with one 62 * The dcache is fully coherent to the system, with one
54 * big caveat: the instruction stream. In other words, 63 * big caveat: the instruction stream. In other words,
@@ -226,7 +235,7 @@ static void sb1_flush_cache_page(struct vm_area_struct *vma, unsigned long addr,
226 args.vma = vma; 235 args.vma = vma;
227 args.addr = addr; 236 args.addr = addr;
228 args.pfn = pfn; 237 args.pfn = pfn;
229 on_each_cpu(sb1_flush_cache_page_ipi, (void *) &args, 1, 1); 238 sb1_on_each_cpu(sb1_flush_cache_page_ipi, (void *) &args, 1, 1);
230} 239}
231#else 240#else
232void sb1_flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn) 241void sb1_flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn)
@@ -249,7 +258,7 @@ void sb1___flush_cache_all_ipi(void *ignored)
249 258
250static void sb1___flush_cache_all(void) 259static void sb1___flush_cache_all(void)
251{ 260{
252 on_each_cpu(sb1___flush_cache_all_ipi, 0, 1, 1); 261 sb1_on_each_cpu(sb1___flush_cache_all_ipi, 0, 1, 1);
253} 262}
254#else 263#else
255void sb1___flush_cache_all(void) 264void sb1___flush_cache_all(void)
@@ -299,7 +308,7 @@ void sb1_flush_icache_range(unsigned long start, unsigned long end)
299 308
300 args.start = start; 309 args.start = start;
301 args.end = end; 310 args.end = end;
302 on_each_cpu(sb1_flush_icache_range_ipi, &args, 1, 1); 311 sb1_on_each_cpu(sb1_flush_icache_range_ipi, &args, 1, 1);
303} 312}
304#else 313#else
305void sb1_flush_icache_range(unsigned long start, unsigned long end) 314void sb1_flush_icache_range(unsigned long start, unsigned long end)
@@ -326,7 +335,7 @@ static void sb1_flush_cache_sigtramp_ipi(void *info)
326 335
327static void sb1_flush_cache_sigtramp(unsigned long addr) 336static void sb1_flush_cache_sigtramp(unsigned long addr)
328{ 337{
329 on_each_cpu(sb1_flush_cache_sigtramp_ipi, (void *) addr, 1, 1); 338 sb1_on_each_cpu(sb1_flush_cache_sigtramp_ipi, (void *) addr, 1, 1);
330} 339}
331#else 340#else
332void sb1_flush_cache_sigtramp(unsigned long addr) 341void sb1_flush_cache_sigtramp(unsigned long addr)
@@ -444,7 +453,6 @@ static __init void probe_cache_sizes(void)
444void sb1_cache_init(void) 453void sb1_cache_init(void)
445{ 454{
446 extern char except_vec2_sb1; 455 extern char except_vec2_sb1;
447 extern char handle_vec2_sb1;
448 456
449 /* Special cache error handler for SB1 */ 457 /* Special cache error handler for SB1 */
450 set_uncached_handler (0x100, &except_vec2_sb1, 0x80); 458 set_uncached_handler (0x100, &except_vec2_sb1, 0x80);
diff --git a/arch/mips/mm/pg-r4k.c b/arch/mips/mm/pg-r4k.c
index b7c749232ffe..d41fc5885e87 100644
--- a/arch/mips/mm/pg-r4k.c
+++ b/arch/mips/mm/pg-r4k.c
@@ -270,6 +270,20 @@ static inline void build_addiu_a2_a0(unsigned long offset)
270 emit_instruction(mi); 270 emit_instruction(mi);
271} 271}
272 272
273static inline void build_addiu_a2(unsigned long offset)
274{
275 union mips_instruction mi;
276
277 BUG_ON(offset > 0x7fff);
278
279 mi.i_format.opcode = cpu_has_64bit_gp_regs ? daddiu_op : addiu_op;
280 mi.i_format.rs = 6; /* $a2 */
281 mi.i_format.rt = 6; /* $a2 */
282 mi.i_format.simmediate = offset;
283
284 emit_instruction(mi);
285}
286
273static inline void build_addiu_a1(unsigned long offset) 287static inline void build_addiu_a1(unsigned long offset)
274{ 288{
275 union mips_instruction mi; 289 union mips_instruction mi;
@@ -333,6 +347,7 @@ static inline void build_jr_ra(void)
333void __init build_clear_page(void) 347void __init build_clear_page(void)
334{ 348{
335 unsigned int loop_start; 349 unsigned int loop_start;
350 unsigned long off;
336 351
337 epc = (unsigned int *) &clear_page_array; 352 epc = (unsigned int *) &clear_page_array;
338 instruction_pending = 0; 353 instruction_pending = 0;
@@ -369,7 +384,12 @@ void __init build_clear_page(void)
369 } 384 }
370 } 385 }
371 386
372 build_addiu_a2_a0(PAGE_SIZE - (cpu_has_prefetch ? pref_offset_clear : 0)); 387 off = PAGE_SIZE - (cpu_has_prefetch ? pref_offset_clear : 0);
388 if (off > 0x7fff) {
389 build_addiu_a2_a0(off >> 1);
390 build_addiu_a2(off >> 1);
391 } else
392 build_addiu_a2_a0(off);
373 393
374 if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) 394 if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
375 build_insn_word(0x3c01a000); /* lui $at, 0xa000 */ 395 build_insn_word(0x3c01a000); /* lui $at, 0xa000 */
@@ -420,12 +440,18 @@ dest = label();
420void __init build_copy_page(void) 440void __init build_copy_page(void)
421{ 441{
422 unsigned int loop_start; 442 unsigned int loop_start;
443 unsigned long off;
423 444
424 epc = (unsigned int *) &copy_page_array; 445 epc = (unsigned int *) &copy_page_array;
425 store_offset = load_offset = 0; 446 store_offset = load_offset = 0;
426 instruction_pending = 0; 447 instruction_pending = 0;
427 448
428 build_addiu_a2_a0(PAGE_SIZE - (cpu_has_prefetch ? pref_offset_copy : 0)); 449 off = PAGE_SIZE - (cpu_has_prefetch ? pref_offset_copy : 0);
450 if (off > 0x7fff) {
451 build_addiu_a2_a0(off >> 1);
452 build_addiu_a2(off >> 1);
453 } else
454 build_addiu_a2_a0(off);
429 455
430 if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x()) 456 if (R4600_V2_HIT_CACHEOP_WAR && cpu_is_r4600_v2_x())
431 build_insn_word(0x3c01a000); /* lui $at, 0xa000 */ 457 build_insn_word(0x3c01a000); /* lui $at, 0xa000 */
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 6f8b25cfa6f0..fec318a1c8c5 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -102,7 +102,7 @@ enum opcode {
102 insn_addu, insn_addiu, insn_and, insn_andi, insn_beq, 102 insn_addu, insn_addiu, insn_and, insn_andi, insn_beq,
103 insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl, 103 insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl,
104 insn_bne, insn_daddu, insn_daddiu, insn_dmfc0, insn_dmtc0, 104 insn_bne, insn_daddu, insn_daddiu, insn_dmfc0, insn_dmtc0,
105 insn_dsll, insn_dsll32, insn_dsra, insn_dsrl, 105 insn_dsll, insn_dsll32, insn_dsra, insn_dsrl, insn_dsrl32,
106 insn_dsubu, insn_eret, insn_j, insn_jal, insn_jr, insn_ld, 106 insn_dsubu, insn_eret, insn_j, insn_jal, insn_jr, insn_ld,
107 insn_ll, insn_lld, insn_lui, insn_lw, insn_mfc0, insn_mtc0, 107 insn_ll, insn_lld, insn_lui, insn_lw, insn_mfc0, insn_mtc0,
108 insn_ori, insn_rfe, insn_sc, insn_scd, insn_sd, insn_sll, 108 insn_ori, insn_rfe, insn_sc, insn_scd, insn_sd, insn_sll,
@@ -145,6 +145,7 @@ static __initdata struct insn insn_table[] = {
145 { insn_dsll32, M(spec_op,0,0,0,0,dsll32_op), RT | RD | RE }, 145 { insn_dsll32, M(spec_op,0,0,0,0,dsll32_op), RT | RD | RE },
146 { insn_dsra, M(spec_op,0,0,0,0,dsra_op), RT | RD | RE }, 146 { insn_dsra, M(spec_op,0,0,0,0,dsra_op), RT | RD | RE },
147 { insn_dsrl, M(spec_op,0,0,0,0,dsrl_op), RT | RD | RE }, 147 { insn_dsrl, M(spec_op,0,0,0,0,dsrl_op), RT | RD | RE },
148 { insn_dsrl32, M(spec_op,0,0,0,0,dsrl32_op), RT | RD | RE },
148 { insn_dsubu, M(spec_op,0,0,0,0,dsubu_op), RS | RT | RD }, 149 { insn_dsubu, M(spec_op,0,0,0,0,dsubu_op), RS | RT | RD },
149 { insn_eret, M(cop0_op,cop_op,0,0,0,eret_op), 0 }, 150 { insn_eret, M(cop0_op,cop_op,0,0,0,eret_op), 0 },
150 { insn_j, M(j_op,0,0,0,0,0), JIMM }, 151 { insn_j, M(j_op,0,0,0,0,0), JIMM },
@@ -385,6 +386,7 @@ I_u2u1u3(_dsll);
385I_u2u1u3(_dsll32); 386I_u2u1u3(_dsll32);
386I_u2u1u3(_dsra); 387I_u2u1u3(_dsra);
387I_u2u1u3(_dsrl); 388I_u2u1u3(_dsrl);
389I_u2u1u3(_dsrl32);
388I_u3u1u2(_dsubu); 390I_u3u1u2(_dsubu);
389I_0(_eret); 391I_0(_eret);
390I_u1(_j); 392I_u1(_j);
@@ -996,7 +998,12 @@ build_get_pmde64(u32 **p, struct label **l, struct reloc **r,
996#endif 998#endif
997 999
998 l_vmalloc_done(l, *p); 1000 l_vmalloc_done(l, *p);
999 i_dsrl(p, tmp, tmp, PGDIR_SHIFT-3); /* get pgd offset in bytes */ 1001
1002 if (PGDIR_SHIFT - 3 < 32) /* get pgd offset in bytes */
1003 i_dsrl(p, tmp, tmp, PGDIR_SHIFT-3);
1004 else
1005 i_dsrl32(p, tmp, tmp, PGDIR_SHIFT - 3 - 32);
1006
1000 i_andi(p, tmp, tmp, (PTRS_PER_PGD - 1)<<3); 1007 i_andi(p, tmp, tmp, (PTRS_PER_PGD - 1)<<3);
1001 i_daddu(p, ptr, ptr, tmp); /* add in pgd offset */ 1008 i_daddu(p, ptr, ptr, tmp); /* add in pgd offset */
1002 i_dmfc0(p, tmp, C0_BADVADDR); /* get faulting address */ 1009 i_dmfc0(p, tmp, C0_BADVADDR); /* get faulting address */
@@ -1073,7 +1080,7 @@ build_get_pgde32(u32 **p, unsigned int tmp, unsigned int ptr)
1073 1080
1074static __init void build_adjust_context(u32 **p, unsigned int ctx) 1081static __init void build_adjust_context(u32 **p, unsigned int ctx)
1075{ 1082{
1076 unsigned int shift = 4 - (PTE_T_LOG2 + 1); 1083 unsigned int shift = 4 - (PTE_T_LOG2 + 1) + PAGE_SHIFT - 12;
1077 unsigned int mask = (PTRS_PER_PTE / 2 - 1) << (PTE_T_LOG2 + 1); 1084 unsigned int mask = (PTRS_PER_PTE / 2 - 1) << (PTE_T_LOG2 + 1);
1078 1085
1079 switch (current_cpu_data.cputype) { 1086 switch (current_cpu_data.cputype) {
diff --git a/arch/mips/momentum/ocelot_g/ocelot_pld.h b/arch/mips/momentum/ocelot_g/ocelot_pld.h
index fcb8275e219d..95e0534026d0 100644
--- a/arch/mips/momentum/ocelot_g/ocelot_pld.h
+++ b/arch/mips/momentum/ocelot_g/ocelot_pld.h
@@ -23,8 +23,8 @@
23#define OCELOT_REG_INTSET (12) 23#define OCELOT_REG_INTSET (12)
24#define OCELOT_REG_INTCLR (13) 24#define OCELOT_REG_INTCLR (13)
25 25
26#define OCELOT_PLD_WRITE(x, y) writeb(x, OCELOT_CS0_ADDR + OCELOT_REG_##y) 26#define __PLD_REG_TO_ADDR(reg) ((void *) OCELOT_CS0_ADDR + OCELOT_REG_##reg)
27#define OCELOT_PLD_READ(x) readb(OCELOT_CS0_ADDR + OCELOT_REG_##x) 27#define OCELOT_PLD_WRITE(x, reg) writeb(x, __PLD_REG_TO_ADDR(reg))
28 28#define OCELOT_PLD_READ(reg) readb(__PLD_REG_TO_ADDR(reg))
29 29
30#endif /* __MOMENCO_OCELOT_PLD_H__ */ 30#endif /* __MOMENCO_OCELOT_PLD_H__ */
diff --git a/arch/mips/momentum/ocelot_g/setup.c b/arch/mips/momentum/ocelot_g/setup.c
index 56ec47039c16..d288f7b01842 100644
--- a/arch/mips/momentum/ocelot_g/setup.c
+++ b/arch/mips/momentum/ocelot_g/setup.c
@@ -57,6 +57,7 @@
57#include <asm/gt64240.h> 57#include <asm/gt64240.h>
58#include <asm/irq.h> 58#include <asm/irq.h>
59#include <asm/pci.h> 59#include <asm/pci.h>
60#include <asm/pgtable.h>
60#include <asm/processor.h> 61#include <asm/processor.h>
61#include <asm/reboot.h> 62#include <asm/reboot.h>
62#include <linux/bootmem.h> 63#include <linux/bootmem.h>
@@ -160,6 +161,10 @@ static void __init setup_l3cache(unsigned long size)
160 printk("Done\n"); 161 printk("Done\n");
161} 162}
162 163
164void __init plat_timer_setup(struct irqaction *irq)
165{
166}
167
163void __init plat_mem_setup(void) 168void __init plat_mem_setup(void)
164{ 169{
165 void (*l3func)(unsigned long) = (void *) KSEG1ADDR(setup_l3cache); 170 void (*l3func)(unsigned long) = (void *) KSEG1ADDR(setup_l3cache);
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index dd0aec9c3ce1..1fb240c57bac 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -31,16 +31,18 @@
31#define M_COUNTER_OVERFLOW (1UL << 31) 31#define M_COUNTER_OVERFLOW (1UL << 31)
32 32
33#ifdef CONFIG_MIPS_MT_SMP 33#ifdef CONFIG_MIPS_MT_SMP
34#define WHAT (M_TC_EN_VPE | M_PERFCTL_VPEID(smp_processor_id())) 34#define WHAT (M_TC_EN_VPE | M_PERFCTL_VPEID(smp_processor_id()))
35#define vpe_id() smp_processor_id()
35#else 36#else
36#define WHAT 0 37#define WHAT 0
38#define vpe_id() smp_processor_id()
37#endif 39#endif
38 40
39#define __define_perf_accessors(r, n, np) \ 41#define __define_perf_accessors(r, n, np) \
40 \ 42 \
41static inline unsigned int r_c0_ ## r ## n(void) \ 43static inline unsigned int r_c0_ ## r ## n(void) \
42{ \ 44{ \
43 unsigned int cpu = smp_processor_id(); \ 45 unsigned int cpu = vpe_id(); \
44 \ 46 \
45 switch (cpu) { \ 47 switch (cpu) { \
46 case 0: \ 48 case 0: \
@@ -55,7 +57,7 @@ static inline unsigned int r_c0_ ## r ## n(void) \
55 \ 57 \
56static inline void w_c0_ ## r ## n(unsigned int value) \ 58static inline void w_c0_ ## r ## n(unsigned int value) \
57{ \ 59{ \
58 unsigned int cpu = smp_processor_id(); \ 60 unsigned int cpu = vpe_id(); \
59 \ 61 \
60 switch (cpu) { \ 62 switch (cpu) { \
61 case 0: \ 63 case 0: \
@@ -218,7 +220,7 @@ static inline int n_counters(void)
218{ 220{
219 int counters = __n_counters(); 221 int counters = __n_counters();
220 222
221#ifndef CONFIG_SMP 223#ifdef CONFIG_MIPS_MT_SMP
222 if (current_cpu_data.cputype == CPU_34K) 224 if (current_cpu_data.cputype == CPU_34K)
223 return counters >> 1; 225 return counters >> 1;
224#endif 226#endif
diff --git a/arch/mips/philips/pnx8550/common/time.c b/arch/mips/philips/pnx8550/common/time.c
index 0af655b1f330..65c440e8480b 100644
--- a/arch/mips/philips/pnx8550/common/time.c
+++ b/arch/mips/philips/pnx8550/common/time.c
@@ -41,8 +41,8 @@ extern unsigned int mips_hpt_frequency;
41 * 1) board_time_init() - 41 * 1) board_time_init() -
42 * a) (optional) set up RTC routines, 42 * a) (optional) set up RTC routines,
43 * b) (optional) calibrate and set the mips_hpt_frequency 43 * b) (optional) calibrate and set the mips_hpt_frequency
44 * (only needed if you intended to use fixed_rate_gettimeoffset 44 * (only needed if you intended to use cpu counter as timer interrupt
45 * or use cpu counter as timer interrupt source) 45 * source)
46 */ 46 */
47 47
48void pnx8550_time_init(void) 48void pnx8550_time_init(void)
diff --git a/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c b/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c
index 416da22b3bf4..85b14c73c226 100644
--- a/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c
+++ b/arch/mips/pmc-sierra/yosemite/i2c-yosemite.c
@@ -74,7 +74,7 @@ static int titan_i2c_poll(void)
74int titan_i2c_xfer(unsigned int slave_addr, titan_i2c_command * cmd, 74int titan_i2c_xfer(unsigned int slave_addr, titan_i2c_command * cmd,
75 int size, unsigned int *addr) 75 int size, unsigned int *addr)
76{ 76{
77 int loop = 0, bytes, i; 77 int loop, bytes = 0, i;
78 unsigned int *write_data, data, *read_data; 78 unsigned int *write_data, data, *read_data;
79 unsigned long reg_val, val; 79 unsigned long reg_val, val;
80 80
diff --git a/arch/mips/pmc-sierra/yosemite/smp.c b/arch/mips/pmc-sierra/yosemite/smp.c
index 65fa3a23ea5e..3cc0436db6cf 100644
--- a/arch/mips/pmc-sierra/yosemite/smp.c
+++ b/arch/mips/pmc-sierra/yosemite/smp.c
@@ -3,9 +3,7 @@
3 3
4#include <asm/pmon.h> 4#include <asm/pmon.h>
5#include <asm/titan_dep.h> 5#include <asm/titan_dep.h>
6 6#include <asm/time.h>
7extern unsigned int (*mips_hpt_read)(void);
8extern void (*mips_hpt_init)(unsigned int);
9 7
10#define LAUNCHSTACK_SIZE 256 8#define LAUNCHSTACK_SIZE 256
11 9
@@ -101,7 +99,7 @@ void prom_cpus_done(void)
101 */ 99 */
102void prom_init_secondary(void) 100void prom_init_secondary(void)
103{ 101{
104 mips_hpt_init(mips_hpt_read()); 102 mips_hpt_init();
105 103
106 set_c0_status(ST0_CO | ST0_IE | ST0_IM); 104 set_c0_status(ST0_CO | ST0_IE | ST0_IM);
107} 105}
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 4e870fc4469b..c965705f3427 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -134,13 +134,6 @@ again:
134 irq_exit(); 134 irq_exit();
135} 135}
136 136
137unsigned long ip27_do_gettimeoffset(void)
138{
139 unsigned long ct_cur1;
140 ct_cur1 = REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT) + CYCLES_PER_JIFFY;
141 return (ct_cur1 - ct_cur[0]) * NSEC_PER_CYCLE / 1000;
142}
143
144/* Includes for ioc3_init(). */ 137/* Includes for ioc3_init(). */
145#include <asm/sn/types.h> 138#include <asm/sn/types.h>
146#include <asm/sn/sn0/addrs.h> 139#include <asm/sn/sn0/addrs.h>
@@ -248,12 +241,17 @@ void __init plat_timer_setup(struct irqaction *irq)
248 setup_irq(irqno, &rt_irqaction); 241 setup_irq(irqno, &rt_irqaction);
249} 242}
250 243
244static unsigned int ip27_hpt_read(void)
245{
246 return REMOTE_HUB_L(cputonasid(0), PI_RT_COUNT);
247}
248
251void __init ip27_time_init(void) 249void __init ip27_time_init(void)
252{ 250{
251 mips_hpt_read = ip27_hpt_read;
252 mips_hpt_frequency = CYCLES_PER_SEC;
253 xtime.tv_sec = get_m48t35_time(); 253 xtime.tv_sec = get_m48t35_time();
254 xtime.tv_nsec = 0; 254 xtime.tv_nsec = 0;
255
256 do_gettimeoffset = ip27_do_gettimeoffset;
257} 255}
258 256
259void __init cpu_time_init(void) 257void __init cpu_time_init(void)
diff --git a/arch/mips/sibyte/bcm1480/time.c b/arch/mips/sibyte/bcm1480/time.c
index bf12af46132e..e136bde5248e 100644
--- a/arch/mips/sibyte/bcm1480/time.c
+++ b/arch/mips/sibyte/bcm1480/time.c
@@ -47,6 +47,12 @@
47#define IMR_IP3_VAL K_BCM1480_INT_MAP_I1 47#define IMR_IP3_VAL K_BCM1480_INT_MAP_I1
48#define IMR_IP4_VAL K_BCM1480_INT_MAP_I2 48#define IMR_IP4_VAL K_BCM1480_INT_MAP_I2
49 49
50#ifdef CONFIG_SIMULATION
51#define BCM1480_HPT_VALUE 50000
52#else
53#define BCM1480_HPT_VALUE 1000000
54#endif
55
50extern int bcm1480_steal_irq(int irq); 56extern int bcm1480_steal_irq(int irq);
51 57
52void bcm1480_time_init(void) 58void bcm1480_time_init(void)
@@ -59,11 +65,6 @@ void bcm1480_time_init(void)
59 BUG(); 65 BUG();
60 } 66 }
61 67
62 if (!cpu) {
63 /* Use our own gettimeoffset() routine */
64 do_gettimeoffset = bcm1480_gettimeoffset;
65 }
66
67 bcm1480_mask_irq(cpu, irq); 68 bcm1480_mask_irq(cpu, irq);
68 69
69 /* Map the timer interrupt to ip[4] of this cpu */ 70 /* Map the timer interrupt to ip[4] of this cpu */
@@ -74,11 +75,7 @@ void bcm1480_time_init(void)
74 /* Disable the timer and set up the count */ 75 /* Disable the timer and set up the count */
75 __raw_writeq(0, IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG))); 76 __raw_writeq(0, IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG)));
76 __raw_writeq( 77 __raw_writeq(
77#ifndef CONFIG_SIMULATION 78 BCM1480_HPT_VALUE/HZ
78 1000000/HZ
79#else
80 50000/HZ
81#endif
82 , IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT))); 79 , IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_INIT)));
83 80
84 /* Set the timer running */ 81 /* Set the timer running */
@@ -122,16 +119,16 @@ void bcm1480_timer_interrupt(void)
122 } 119 }
123} 120}
124 121
125/* 122static unsigned int bcm1480_hpt_read(void)
126 * We use our own do_gettimeoffset() instead of the generic one,
127 * because the generic one does not work for SMP case.
128 * In addition, since we use general timer 0 for system time,
129 * we can get accurate intra-jiffy offset without calibration.
130 */
131unsigned long bcm1480_gettimeoffset(void)
132{ 123{
124 /* We assume this function is called xtime_lock held. */
133 unsigned long count = 125 unsigned long count =
134 __raw_readq(IOADDR(A_SCD_TIMER_REGISTER(0, R_SCD_TIMER_CNT))); 126 __raw_readq(IOADDR(A_SCD_TIMER_REGISTER(0, R_SCD_TIMER_CNT)));
127 return (jiffies + 1) * (BCM1480_HPT_VALUE / HZ) - count;
128}
135 129
136 return 1000000/HZ - count; 130void __init bcm1480_hpt_setup(void)
131{
132 mips_hpt_read = bcm1480_hpt_read;
133 mips_hpt_frequency = BCM1480_HPT_VALUE;
137} 134}
diff --git a/arch/mips/sibyte/sb1250/time.c b/arch/mips/sibyte/sb1250/time.c
index 0ccf1796dd78..bcb74f2c1948 100644
--- a/arch/mips/sibyte/sb1250/time.c
+++ b/arch/mips/sibyte/sb1250/time.c
@@ -47,15 +47,11 @@
47 47
48#define SB1250_HPT_NUM 3 48#define SB1250_HPT_NUM 3
49#define SB1250_HPT_VALUE M_SCD_TIMER_CNT /* max value */ 49#define SB1250_HPT_VALUE M_SCD_TIMER_CNT /* max value */
50#define SB1250_HPT_SHIFT ((sizeof(unsigned int)*8)-V_SCD_TIMER_WIDTH)
51 50
52 51
53extern int sb1250_steal_irq(int irq); 52extern int sb1250_steal_irq(int irq);
54 53
55static unsigned int sb1250_hpt_read(void); 54static unsigned int sb1250_hpt_read(void);
56static void sb1250_hpt_init(unsigned int);
57
58static unsigned int hpt_offset;
59 55
60void __init sb1250_hpt_setup(void) 56void __init sb1250_hpt_setup(void)
61{ 57{
@@ -69,13 +65,9 @@ void __init sb1250_hpt_setup(void)
69 __raw_writeq(M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS, 65 __raw_writeq(M_SCD_TIMER_ENABLE | M_SCD_TIMER_MODE_CONTINUOUS,
70 IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CFG))); 66 IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CFG)));
71 67
72 /* 68 mips_hpt_frequency = V_SCD_TIMER_FREQ;
73 * we need to fill 32 bits, so just use the upper 23 bits and pretend
74 * the timer is going 512Mhz instead of 1Mhz
75 */
76 mips_hpt_frequency = V_SCD_TIMER_FREQ << SB1250_HPT_SHIFT;
77 mips_hpt_init = sb1250_hpt_init;
78 mips_hpt_read = sb1250_hpt_read; 69 mips_hpt_read = sb1250_hpt_read;
70 mips_hpt_mask = M_SCD_TIMER_INIT;
79 } 71 }
80} 72}
81 73
@@ -149,11 +141,7 @@ void sb1250_timer_interrupt(void)
149 141
150/* 142/*
151 * The HPT is free running from SB1250_HPT_VALUE down to 0 then starts over 143 * The HPT is free running from SB1250_HPT_VALUE down to 0 then starts over
152 * again. There's no easy way to set to a specific value so store init value 144 * again.
153 * in hpt_offset and subtract each time.
154 *
155 * Note: Timer isn't full 32bits so shift it into the upper part making
156 * it appear to run at a higher frequency.
157 */ 145 */
158static unsigned int sb1250_hpt_read(void) 146static unsigned int sb1250_hpt_read(void)
159{ 147{
@@ -161,13 +149,5 @@ static unsigned int sb1250_hpt_read(void)
161 149
162 count = G_SCD_TIMER_CNT(__raw_readq(IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CNT)))); 150 count = G_SCD_TIMER_CNT(__raw_readq(IOADDR(A_SCD_TIMER_REGISTER(SB1250_HPT_NUM, R_SCD_TIMER_CNT))));
163 151
164 count = (SB1250_HPT_VALUE - count) << SB1250_HPT_SHIFT; 152 return SB1250_HPT_VALUE - count;
165
166 return count - hpt_offset;
167}
168
169static void sb1250_hpt_init(unsigned int count)
170{
171 hpt_offset = count;
172 return;
173} 153}
diff --git a/arch/mips/tx4927/common/smsc_fdc37m81x.c b/arch/mips/tx4927/common/smsc_fdc37m81x.c
new file mode 100644
index 000000000000..33f517bc9a08
--- /dev/null
+++ b/arch/mips/tx4927/common/smsc_fdc37m81x.c
@@ -0,0 +1,172 @@
1/*
2 * Interface for smsc fdc48m81x Super IO chip
3 *
4 * Author: MontaVista Software, Inc. source@mvista.com
5 *
6 * 2001-2003 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 *
11 * Copyright 2004 (c) MontaVista Software, Inc.
12 */
13#include <linux/init.h>
14#include <linux/types.h>
15#include <asm/io.h>
16#include <asm/tx4927/smsc_fdc37m81x.h>
17
18#define DEBUG
19
20/* Common Registers */
21#define SMSC_FDC37M81X_CONFIG_INDEX 0x00
22#define SMSC_FDC37M81X_CONFIG_DATA 0x01
23#define SMSC_FDC37M81X_CONF 0x02
24#define SMSC_FDC37M81X_INDEX 0x03
25#define SMSC_FDC37M81X_DNUM 0x07
26#define SMSC_FDC37M81X_DID 0x20
27#define SMSC_FDC37M81X_DREV 0x21
28#define SMSC_FDC37M81X_PCNT 0x22
29#define SMSC_FDC37M81X_PMGT 0x23
30#define SMSC_FDC37M81X_OSC 0x24
31#define SMSC_FDC37M81X_CONFPA0 0x26
32#define SMSC_FDC37M81X_CONFPA1 0x27
33#define SMSC_FDC37M81X_TEST4 0x2B
34#define SMSC_FDC37M81X_TEST5 0x2C
35#define SMSC_FDC37M81X_TEST1 0x2D
36#define SMSC_FDC37M81X_TEST2 0x2E
37#define SMSC_FDC37M81X_TEST3 0x2F
38
39/* Logical device numbers */
40#define SMSC_FDC37M81X_FDD 0x00
41#define SMSC_FDC37M81X_SERIAL1 0x04
42#define SMSC_FDC37M81X_SERIAL2 0x05
43#define SMSC_FDC37M81X_KBD 0x07
44
45/* Logical device Config Registers */
46#define SMSC_FDC37M81X_ACTIVE 0x30
47#define SMSC_FDC37M81X_BASEADDR0 0x60
48#define SMSC_FDC37M81X_BASEADDR1 0x61
49#define SMSC_FDC37M81X_INT 0x70
50#define SMSC_FDC37M81X_INT2 0x72
51#define SMSC_FDC37M81X_MODE 0xF0
52
53/* Chip Config Values */
54#define SMSC_FDC37M81X_CONFIG_ENTER 0x55
55#define SMSC_FDC37M81X_CONFIG_EXIT 0xaa
56#define SMSC_FDC37M81X_CHIP_ID 0x4d
57
58static unsigned long g_smsc_fdc37m81x_base = 0;
59
60static inline unsigned char smsc_fdc37m81x_rd(unsigned char index)
61{
62 outb(index, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX);
63
64 return inb(g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_DATA);
65}
66
67static inline void smsc_dc37m81x_wr(unsigned char index, unsigned char data)
68{
69 outb(index, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX);
70 outb(data, g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_DATA);
71}
72
73void smsc_fdc37m81x_config_beg(void)
74{
75 if (g_smsc_fdc37m81x_base) {
76 outb(SMSC_FDC37M81X_CONFIG_ENTER,
77 g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX);
78 }
79}
80
81void smsc_fdc37m81x_config_end(void)
82{
83 if (g_smsc_fdc37m81x_base)
84 outb(SMSC_FDC37M81X_CONFIG_EXIT,
85 g_smsc_fdc37m81x_base + SMSC_FDC37M81X_CONFIG_INDEX);
86}
87
88u8 smsc_fdc37m81x_config_get(u8 reg)
89{
90 u8 val = 0;
91
92 if (g_smsc_fdc37m81x_base)
93 val = smsc_fdc37m81x_rd(reg);
94
95 return val;
96}
97
98void smsc_fdc37m81x_config_set(u8 reg, u8 val)
99{
100 if (g_smsc_fdc37m81x_base)
101 smsc_dc37m81x_wr(reg, val);
102}
103
104unsigned long __init smsc_fdc37m81x_init(unsigned long port)
105{
106 const int field = sizeof(unsigned long) * 2;
107 u8 chip_id;
108
109 if (g_smsc_fdc37m81x_base)
110 printk("smsc_fdc37m81x_init() stepping on old base=0x%0*lx\n",
111 field, g_smsc_fdc37m81x_base);
112
113 g_smsc_fdc37m81x_base = port;
114
115 smsc_fdc37m81x_config_beg();
116
117 chip_id = smsc_fdc37m81x_rd(SMSC_FDC37M81X_DID);
118 if (chip_id == SMSC_FDC37M81X_CHIP_ID)
119 smsc_fdc37m81x_config_end();
120 else {
121 printk("smsc_fdc37m81x_init() unknow chip id 0x%02x\n",
122 chip_id);
123 g_smsc_fdc37m81x_base = 0;
124 }
125
126 return g_smsc_fdc37m81x_base;
127}
128
129#ifdef DEBUG
130void smsc_fdc37m81x_config_dump_one(char *key, u8 dev, u8 reg)
131{
132 printk("%s: dev=0x%02x reg=0x%02x val=0x%02x\n", key, dev, reg,
133 smsc_fdc37m81x_rd(reg));
134}
135
136void smsc_fdc37m81x_config_dump(void)
137{
138 u8 orig;
139 char *fname = "smsc_fdc37m81x_config_dump()";
140
141 smsc_fdc37m81x_config_beg();
142
143 orig = smsc_fdc37m81x_rd(SMSC_FDC37M81X_DNUM);
144
145 printk("%s: common\n", fname);
146 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE,
147 SMSC_FDC37M81X_DNUM);
148 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE,
149 SMSC_FDC37M81X_DID);
150 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE,
151 SMSC_FDC37M81X_DREV);
152 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE,
153 SMSC_FDC37M81X_PCNT);
154 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_NONE,
155 SMSC_FDC37M81X_PMGT);
156
157 printk("%s: keyboard\n", fname);
158 smsc_dc37m81x_wr(SMSC_FDC37M81X_DNUM, SMSC_FDC37M81X_KBD);
159 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD,
160 SMSC_FDC37M81X_ACTIVE);
161 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD,
162 SMSC_FDC37M81X_INT);
163 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD,
164 SMSC_FDC37M81X_INT2);
165 smsc_fdc37m81x_config_dump_one(fname, SMSC_FDC37M81X_KBD,
166 SMSC_FDC37M81X_LDCR_F0);
167
168 smsc_dc37m81x_wr(SMSC_FDC37M81X_DNUM, orig);
169
170 smsc_fdc37m81x_config_end();
171}
172#endif
diff --git a/arch/mips/tx4927/common/tx4927_setup.c b/arch/mips/tx4927/common/tx4927_setup.c
index 4658b2ae4833..941c441729b0 100644
--- a/arch/mips/tx4927/common/tx4927_setup.c
+++ b/arch/mips/tx4927/common/tx4927_setup.c
@@ -112,8 +112,6 @@ void print_cp0(char *key, int num, char *name, u32 val)
112 return; 112 return;
113} 113}
114 114
115indent: Standard input:25: Error:Unexpected end of file
116
117void 115void
118dump_cp0(char *key) 116dump_cp0(char *key)
119{ 117{
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c b/arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c
index b926e6a75c29..08b20cdfd7b3 100644
--- a/arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c
+++ b/arch/mips/tx4938/toshiba_rbtx4938/spi_txx9.c
@@ -36,14 +36,18 @@ void __init txx9_spi_init(unsigned long base, int (*cs_func)(int chipid, int on)
36 36
37static DECLARE_WAIT_QUEUE_HEAD(txx9_spi_wait); 37static DECLARE_WAIT_QUEUE_HEAD(txx9_spi_wait);
38 38
39static void txx9_spi_interrupt(int irq, void *dev_id) 39static irqreturn_t txx9_spi_interrupt(int irq, void *dev_id)
40{ 40{
41 /* disable rx intr */ 41 /* disable rx intr */
42 tx4938_spiptr->cr0 &= ~TXx9_SPCR0_RBSIE; 42 tx4938_spiptr->cr0 &= ~TXx9_SPCR0_RBSIE;
43 wake_up(&txx9_spi_wait); 43 wake_up(&txx9_spi_wait);
44
45 return IRQ_HANDLED;
44} 46}
47
45static struct irqaction txx9_spi_action = { 48static struct irqaction txx9_spi_action = {
46 txx9_spi_interrupt, 0, 0, "spi", NULL, NULL, 49 .handler = txx9_spi_interrupt,
50 .name = "spi",
47}; 51};
48 52
49void __init txx9_spi_irqinit(int irc_irq) 53void __init txx9_spi_irqinit(int irc_irq)
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 8b133afbdc20..7af23c43fd4b 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -38,7 +38,6 @@ obj-$(CONFIG_6xx) += idle_6xx.o l2cr_6xx.o cpu_setup_6xx.o
38obj-$(CONFIG_TAU) += tau_6xx.o 38obj-$(CONFIG_TAU) += tau_6xx.o
39obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o 39obj32-$(CONFIG_SOFTWARE_SUSPEND) += swsusp_32.o
40obj32-$(CONFIG_MODULES) += module_32.o 40obj32-$(CONFIG_MODULES) += module_32.o
41obj-$(CONFIG_E500) += perfmon_fsl_booke.o
42 41
43ifeq ($(CONFIG_PPC_MERGE),y) 42ifeq ($(CONFIG_PPC_MERGE),y)
44 43
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index 995fcef156fd..93f21aaf7c8e 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -182,7 +182,7 @@ int btext_initialize(struct device_node *np)
182 prop = get_property(np, "linux,bootx-linebytes", NULL); 182 prop = get_property(np, "linux,bootx-linebytes", NULL);
183 if (prop == NULL) 183 if (prop == NULL)
184 prop = get_property(np, "linebytes", NULL); 184 prop = get_property(np, "linebytes", NULL);
185 if (prop) 185 if (prop && *prop != 0xffffffffu)
186 pitch = *prop; 186 pitch = *prop;
187 if (pitch == 1) 187 if (pitch == 1)
188 pitch = 0x1000; 188 pitch = 0x1000;
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 291e3629b504..e720729f3e55 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -487,7 +487,7 @@ BEGIN_FTR_SECTION
487 rlwimi r13,r12,16,0x20 487 rlwimi r13,r12,16,0x20
488 mfcr r12 488 mfcr r12
489 cmpwi r13,0x2c 489 cmpwi r13,0x2c
490 beq .do_stab_bolted_pSeries 490 beq do_stab_bolted_pSeries
491 mtcrf 0x80,r12 491 mtcrf 0x80,r12
492 mfspr r12,SPRN_SPRG2 492 mfspr r12,SPRN_SPRG2
493END_FTR_SECTION_IFCLR(CPU_FTR_SLB) 493END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
@@ -600,7 +600,7 @@ system_call_pSeries:
600 STD_EXCEPTION_PSERIES(., performance_monitor) 600 STD_EXCEPTION_PSERIES(., performance_monitor)
601 601
602 .align 7 602 .align 7
603_GLOBAL(do_stab_bolted_pSeries) 603do_stab_bolted_pSeries:
604 mtcrf 0x80,r12 604 mtcrf 0x80,r12
605 mfspr r12,SPRN_SPRG2 605 mfspr r12,SPRN_SPRG2
606 EXCEPTION_PROLOG_PSERIES(PACA_EXSLB, .do_stab_bolted) 606 EXCEPTION_PROLOG_PSERIES(PACA_EXSLB, .do_stab_bolted)
@@ -1046,7 +1046,7 @@ slb_miss_fault:
1046 li r5,0 1046 li r5,0
1047 std r4,_DAR(r1) 1047 std r4,_DAR(r1)
1048 std r5,_DSISR(r1) 1048 std r5,_DSISR(r1)
1049 b .handle_page_fault 1049 b handle_page_fault
1050 1050
1051unrecov_user_slb: 1051unrecov_user_slb:
1052 EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN) 1052 EXCEPTION_PROLOG_COMMON(0x4200, PACA_EXGEN)
@@ -1174,12 +1174,13 @@ program_check_common:
1174 .globl fp_unavailable_common 1174 .globl fp_unavailable_common
1175fp_unavailable_common: 1175fp_unavailable_common:
1176 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN) 1176 EXCEPTION_PROLOG_COMMON(0x800, PACA_EXGEN)
1177 bne .load_up_fpu /* if from user, just load it up */ 1177 bne 1f /* if from user, just load it up */
1178 bl .save_nvgprs 1178 bl .save_nvgprs
1179 addi r3,r1,STACK_FRAME_OVERHEAD 1179 addi r3,r1,STACK_FRAME_OVERHEAD
1180 ENABLE_INTS 1180 ENABLE_INTS
1181 bl .kernel_fp_unavailable_exception 1181 bl .kernel_fp_unavailable_exception
1182 BUG_OPCODE 1182 BUG_OPCODE
11831: b .load_up_fpu
1183 1184
1184 .align 7 1185 .align 7
1185 .globl altivec_unavailable_common 1186 .globl altivec_unavailable_common
@@ -1279,10 +1280,10 @@ _GLOBAL(do_hash_page)
1279 std r4,_DSISR(r1) 1280 std r4,_DSISR(r1)
1280 1281
1281 andis. r0,r4,0xa450 /* weird error? */ 1282 andis. r0,r4,0xa450 /* weird error? */
1282 bne- .handle_page_fault /* if not, try to insert a HPTE */ 1283 bne- handle_page_fault /* if not, try to insert a HPTE */
1283BEGIN_FTR_SECTION 1284BEGIN_FTR_SECTION
1284 andis. r0,r4,0x0020 /* Is it a segment table fault? */ 1285 andis. r0,r4,0x0020 /* Is it a segment table fault? */
1285 bne- .do_ste_alloc /* If so handle it */ 1286 bne- do_ste_alloc /* If so handle it */
1286END_FTR_SECTION_IFCLR(CPU_FTR_SLB) 1287END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
1287 1288
1288 /* 1289 /*
@@ -1324,7 +1325,7 @@ BEGIN_FW_FTR_SECTION
1324 * because ret_from_except_lite will check for and handle pending 1325 * because ret_from_except_lite will check for and handle pending
1325 * interrupts if necessary. 1326 * interrupts if necessary.
1326 */ 1327 */
1327 beq .ret_from_except_lite 1328 beq 13f
1328 /* For a hash failure, we don't bother re-enabling interrupts */ 1329 /* For a hash failure, we don't bother re-enabling interrupts */
1329 ble- 12f 1330 ble- 12f
1330 1331
@@ -1346,14 +1347,14 @@ BEGIN_FW_FTR_SECTION
1346END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES) 1347END_FW_FTR_SECTION_IFCLR(FW_FEATURE_ISERIES)
1347 1348
1348/* Here we have a page fault that hash_page can't handle. */ 1349/* Here we have a page fault that hash_page can't handle. */
1349_GLOBAL(handle_page_fault) 1350handle_page_fault:
1350 ENABLE_INTS 1351 ENABLE_INTS
135111: ld r4,_DAR(r1) 135211: ld r4,_DAR(r1)
1352 ld r5,_DSISR(r1) 1353 ld r5,_DSISR(r1)
1353 addi r3,r1,STACK_FRAME_OVERHEAD 1354 addi r3,r1,STACK_FRAME_OVERHEAD
1354 bl .do_page_fault 1355 bl .do_page_fault
1355 cmpdi r3,0 1356 cmpdi r3,0
1356 beq+ .ret_from_except_lite 1357 beq+ 13f
1357 bl .save_nvgprs 1358 bl .save_nvgprs
1358 mr r5,r3 1359 mr r5,r3
1359 addi r3,r1,STACK_FRAME_OVERHEAD 1360 addi r3,r1,STACK_FRAME_OVERHEAD
@@ -1370,12 +1371,14 @@ _GLOBAL(handle_page_fault)
1370 bl .low_hash_fault 1371 bl .low_hash_fault
1371 b .ret_from_except 1372 b .ret_from_except
1372 1373
137413: b .ret_from_except_lite
1375
1373 /* here we have a segment miss */ 1376 /* here we have a segment miss */
1374_GLOBAL(do_ste_alloc) 1377do_ste_alloc:
1375 bl .ste_allocate /* try to insert stab entry */ 1378 bl .ste_allocate /* try to insert stab entry */
1376 cmpdi r3,0 1379 cmpdi r3,0
1377 beq+ fast_exception_return 1380 bne- handle_page_fault
1378 b .handle_page_fault 1381 b fast_exception_return
1379 1382
1380/* 1383/*
1381 * r13 points to the PACA, r9 contains the saved CR, 1384 * r13 points to the PACA, r9 contains the saved CR,
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index f88a2a675d90..ba6b7256084b 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -47,6 +47,17 @@ static int novmerge = 0;
47static int novmerge = 1; 47static int novmerge = 1;
48#endif 48#endif
49 49
50static inline unsigned long iommu_num_pages(unsigned long vaddr,
51 unsigned long slen)
52{
53 unsigned long npages;
54
55 npages = IOMMU_PAGE_ALIGN(vaddr + slen) - (vaddr & IOMMU_PAGE_MASK);
56 npages >>= IOMMU_PAGE_SHIFT;
57
58 return npages;
59}
60
50static int __init setup_iommu(char *str) 61static int __init setup_iommu(char *str)
51{ 62{
52 if (!strcmp(str, "novmerge")) 63 if (!strcmp(str, "novmerge"))
@@ -178,10 +189,10 @@ static dma_addr_t iommu_alloc(struct iommu_table *tbl, void *page,
178 } 189 }
179 190
180 entry += tbl->it_offset; /* Offset into real TCE table */ 191 entry += tbl->it_offset; /* Offset into real TCE table */
181 ret = entry << PAGE_SHIFT; /* Set the return dma address */ 192 ret = entry << IOMMU_PAGE_SHIFT; /* Set the return dma address */
182 193
183 /* Put the TCEs in the HW table */ 194 /* Put the TCEs in the HW table */
184 ppc_md.tce_build(tbl, entry, npages, (unsigned long)page & PAGE_MASK, 195 ppc_md.tce_build(tbl, entry, npages, (unsigned long)page & IOMMU_PAGE_MASK,
185 direction); 196 direction);
186 197
187 198
@@ -203,7 +214,7 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
203 unsigned long entry, free_entry; 214 unsigned long entry, free_entry;
204 unsigned long i; 215 unsigned long i;
205 216
206 entry = dma_addr >> PAGE_SHIFT; 217 entry = dma_addr >> IOMMU_PAGE_SHIFT;
207 free_entry = entry - tbl->it_offset; 218 free_entry = entry - tbl->it_offset;
208 219
209 if (((free_entry + npages) > tbl->it_size) || 220 if (((free_entry + npages) > tbl->it_size) ||
@@ -270,7 +281,7 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
270 /* Init first segment length for backout at failure */ 281 /* Init first segment length for backout at failure */
271 outs->dma_length = 0; 282 outs->dma_length = 0;
272 283
273 DBG("mapping %d elements:\n", nelems); 284 DBG("sg mapping %d elements:\n", nelems);
274 285
275 spin_lock_irqsave(&(tbl->it_lock), flags); 286 spin_lock_irqsave(&(tbl->it_lock), flags);
276 287
@@ -285,9 +296,8 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
285 } 296 }
286 /* Allocate iommu entries for that segment */ 297 /* Allocate iommu entries for that segment */
287 vaddr = (unsigned long)page_address(s->page) + s->offset; 298 vaddr = (unsigned long)page_address(s->page) + s->offset;
288 npages = PAGE_ALIGN(vaddr + slen) - (vaddr & PAGE_MASK); 299 npages = iommu_num_pages(vaddr, slen);
289 npages >>= PAGE_SHIFT; 300 entry = iommu_range_alloc(tbl, npages, &handle, mask >> IOMMU_PAGE_SHIFT, 0);
290 entry = iommu_range_alloc(tbl, npages, &handle, mask >> PAGE_SHIFT, 0);
291 301
292 DBG(" - vaddr: %lx, size: %lx\n", vaddr, slen); 302 DBG(" - vaddr: %lx, size: %lx\n", vaddr, slen);
293 303
@@ -301,14 +311,14 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
301 311
302 /* Convert entry to a dma_addr_t */ 312 /* Convert entry to a dma_addr_t */
303 entry += tbl->it_offset; 313 entry += tbl->it_offset;
304 dma_addr = entry << PAGE_SHIFT; 314 dma_addr = entry << IOMMU_PAGE_SHIFT;
305 dma_addr |= s->offset; 315 dma_addr |= (s->offset & ~IOMMU_PAGE_MASK);
306 316
307 DBG(" - %lx pages, entry: %lx, dma_addr: %lx\n", 317 DBG(" - %lu pages, entry: %lx, dma_addr: %lx\n",
308 npages, entry, dma_addr); 318 npages, entry, dma_addr);
309 319
310 /* Insert into HW table */ 320 /* Insert into HW table */
311 ppc_md.tce_build(tbl, entry, npages, vaddr & PAGE_MASK, direction); 321 ppc_md.tce_build(tbl, entry, npages, vaddr & IOMMU_PAGE_MASK, direction);
312 322
313 /* If we are in an open segment, try merging */ 323 /* If we are in an open segment, try merging */
314 if (segstart != s) { 324 if (segstart != s) {
@@ -323,7 +333,7 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
323 DBG(" can't merge, new segment.\n"); 333 DBG(" can't merge, new segment.\n");
324 } else { 334 } else {
325 outs->dma_length += s->length; 335 outs->dma_length += s->length;
326 DBG(" merged, new len: %lx\n", outs->dma_length); 336 DBG(" merged, new len: %ux\n", outs->dma_length);
327 } 337 }
328 } 338 }
329 339
@@ -367,9 +377,8 @@ int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
367 if (s->dma_length != 0) { 377 if (s->dma_length != 0) {
368 unsigned long vaddr, npages; 378 unsigned long vaddr, npages;
369 379
370 vaddr = s->dma_address & PAGE_MASK; 380 vaddr = s->dma_address & IOMMU_PAGE_MASK;
371 npages = (PAGE_ALIGN(s->dma_address + s->dma_length) - vaddr) 381 npages = iommu_num_pages(s->dma_address, s->dma_length);
372 >> PAGE_SHIFT;
373 __iommu_free(tbl, vaddr, npages); 382 __iommu_free(tbl, vaddr, npages);
374 s->dma_address = DMA_ERROR_CODE; 383 s->dma_address = DMA_ERROR_CODE;
375 s->dma_length = 0; 384 s->dma_length = 0;
@@ -398,8 +407,7 @@ void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
398 407
399 if (sglist->dma_length == 0) 408 if (sglist->dma_length == 0)
400 break; 409 break;
401 npages = (PAGE_ALIGN(dma_handle + sglist->dma_length) 410 npages = iommu_num_pages(dma_handle,sglist->dma_length);
402 - (dma_handle & PAGE_MASK)) >> PAGE_SHIFT;
403 __iommu_free(tbl, dma_handle, npages); 411 __iommu_free(tbl, dma_handle, npages);
404 sglist++; 412 sglist++;
405 } 413 }
@@ -532,12 +540,11 @@ dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
532 BUG_ON(direction == DMA_NONE); 540 BUG_ON(direction == DMA_NONE);
533 541
534 uaddr = (unsigned long)vaddr; 542 uaddr = (unsigned long)vaddr;
535 npages = PAGE_ALIGN(uaddr + size) - (uaddr & PAGE_MASK); 543 npages = iommu_num_pages(uaddr, size);
536 npages >>= PAGE_SHIFT;
537 544
538 if (tbl) { 545 if (tbl) {
539 dma_handle = iommu_alloc(tbl, vaddr, npages, direction, 546 dma_handle = iommu_alloc(tbl, vaddr, npages, direction,
540 mask >> PAGE_SHIFT, 0); 547 mask >> IOMMU_PAGE_SHIFT, 0);
541 if (dma_handle == DMA_ERROR_CODE) { 548 if (dma_handle == DMA_ERROR_CODE) {
542 if (printk_ratelimit()) { 549 if (printk_ratelimit()) {
543 printk(KERN_INFO "iommu_alloc failed, " 550 printk(KERN_INFO "iommu_alloc failed, "
@@ -545,7 +552,7 @@ dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
545 tbl, vaddr, npages); 552 tbl, vaddr, npages);
546 } 553 }
547 } else 554 } else
548 dma_handle |= (uaddr & ~PAGE_MASK); 555 dma_handle |= (uaddr & ~IOMMU_PAGE_MASK);
549 } 556 }
550 557
551 return dma_handle; 558 return dma_handle;
@@ -554,11 +561,14 @@ dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
554void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle, 561void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
555 size_t size, enum dma_data_direction direction) 562 size_t size, enum dma_data_direction direction)
556{ 563{
564 unsigned int npages;
565
557 BUG_ON(direction == DMA_NONE); 566 BUG_ON(direction == DMA_NONE);
558 567
559 if (tbl) 568 if (tbl) {
560 iommu_free(tbl, dma_handle, (PAGE_ALIGN(dma_handle + size) - 569 npages = iommu_num_pages(dma_handle, size);
561 (dma_handle & PAGE_MASK)) >> PAGE_SHIFT); 570 iommu_free(tbl, dma_handle, npages);
571 }
562} 572}
563 573
564/* Allocates a contiguous real buffer and creates mappings over it. 574/* Allocates a contiguous real buffer and creates mappings over it.
@@ -570,11 +580,11 @@ void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
570{ 580{
571 void *ret = NULL; 581 void *ret = NULL;
572 dma_addr_t mapping; 582 dma_addr_t mapping;
573 unsigned int npages, order; 583 unsigned int order;
584 unsigned int nio_pages, io_order;
574 struct page *page; 585 struct page *page;
575 586
576 size = PAGE_ALIGN(size); 587 size = PAGE_ALIGN(size);
577 npages = size >> PAGE_SHIFT;
578 order = get_order(size); 588 order = get_order(size);
579 589
580 /* 590 /*
@@ -598,8 +608,10 @@ void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
598 memset(ret, 0, size); 608 memset(ret, 0, size);
599 609
600 /* Set up tces to cover the allocated range */ 610 /* Set up tces to cover the allocated range */
601 mapping = iommu_alloc(tbl, ret, npages, DMA_BIDIRECTIONAL, 611 nio_pages = size >> IOMMU_PAGE_SHIFT;
602 mask >> PAGE_SHIFT, order); 612 io_order = get_iommu_order(size);
613 mapping = iommu_alloc(tbl, ret, nio_pages, DMA_BIDIRECTIONAL,
614 mask >> IOMMU_PAGE_SHIFT, io_order);
603 if (mapping == DMA_ERROR_CODE) { 615 if (mapping == DMA_ERROR_CODE) {
604 free_pages((unsigned long)ret, order); 616 free_pages((unsigned long)ret, order);
605 return NULL; 617 return NULL;
@@ -611,12 +623,13 @@ void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
611void iommu_free_coherent(struct iommu_table *tbl, size_t size, 623void iommu_free_coherent(struct iommu_table *tbl, size_t size,
612 void *vaddr, dma_addr_t dma_handle) 624 void *vaddr, dma_addr_t dma_handle)
613{ 625{
614 unsigned int npages;
615
616 if (tbl) { 626 if (tbl) {
627 unsigned int nio_pages;
628
629 size = PAGE_ALIGN(size);
630 nio_pages = size >> IOMMU_PAGE_SHIFT;
631 iommu_free(tbl, dma_handle, nio_pages);
617 size = PAGE_ALIGN(size); 632 size = PAGE_ALIGN(size);
618 npages = size >> PAGE_SHIFT;
619 iommu_free(tbl, dma_handle, npages);
620 free_pages((unsigned long)vaddr, get_order(size)); 633 free_pages((unsigned long)vaddr, get_order(size));
621 } 634 }
622} 635}
diff --git a/arch/powerpc/kernel/perfmon_fsl_booke.c b/arch/powerpc/kernel/perfmon_fsl_booke.c
deleted file mode 100644
index e0dcf2b41fbe..000000000000
--- a/arch/powerpc/kernel/perfmon_fsl_booke.c
+++ /dev/null
@@ -1,221 +0,0 @@
1/* arch/powerpc/kernel/perfmon_fsl_booke.c
2 * Freescale Book-E Performance Monitor code
3 *
4 * Author: Andy Fleming
5 * Copyright (c) 2004 Freescale Semiconductor, Inc
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/errno.h>
14#include <linux/sched.h>
15#include <linux/kernel.h>
16#include <linux/mm.h>
17#include <linux/stddef.h>
18#include <linux/unistd.h>
19#include <linux/ptrace.h>
20#include <linux/slab.h>
21#include <linux/user.h>
22#include <linux/a.out.h>
23#include <linux/interrupt.h>
24#include <linux/init.h>
25#include <linux/module.h>
26#include <linux/prctl.h>
27
28#include <asm/pgtable.h>
29#include <asm/uaccess.h>
30#include <asm/system.h>
31#include <asm/io.h>
32#include <asm/reg.h>
33#include <asm/xmon.h>
34#include <asm/pmc.h>
35
36static inline u32 get_pmlca(int ctr);
37static inline void set_pmlca(int ctr, u32 pmlca);
38
39static inline u32 get_pmlca(int ctr)
40{
41 u32 pmlca;
42
43 switch (ctr) {
44 case 0:
45 pmlca = mfpmr(PMRN_PMLCA0);
46 break;
47 case 1:
48 pmlca = mfpmr(PMRN_PMLCA1);
49 break;
50 case 2:
51 pmlca = mfpmr(PMRN_PMLCA2);
52 break;
53 case 3:
54 pmlca = mfpmr(PMRN_PMLCA3);
55 break;
56 default:
57 panic("Bad ctr number\n");
58 }
59
60 return pmlca;
61}
62
63static inline void set_pmlca(int ctr, u32 pmlca)
64{
65 switch (ctr) {
66 case 0:
67 mtpmr(PMRN_PMLCA0, pmlca);
68 break;
69 case 1:
70 mtpmr(PMRN_PMLCA1, pmlca);
71 break;
72 case 2:
73 mtpmr(PMRN_PMLCA2, pmlca);
74 break;
75 case 3:
76 mtpmr(PMRN_PMLCA3, pmlca);
77 break;
78 default:
79 panic("Bad ctr number\n");
80 }
81}
82
83void init_pmc_stop(int ctr)
84{
85 u32 pmlca = (PMLCA_FC | PMLCA_FCS | PMLCA_FCU |
86 PMLCA_FCM1 | PMLCA_FCM0);
87 u32 pmlcb = 0;
88
89 switch (ctr) {
90 case 0:
91 mtpmr(PMRN_PMLCA0, pmlca);
92 mtpmr(PMRN_PMLCB0, pmlcb);
93 break;
94 case 1:
95 mtpmr(PMRN_PMLCA1, pmlca);
96 mtpmr(PMRN_PMLCB1, pmlcb);
97 break;
98 case 2:
99 mtpmr(PMRN_PMLCA2, pmlca);
100 mtpmr(PMRN_PMLCB2, pmlcb);
101 break;
102 case 3:
103 mtpmr(PMRN_PMLCA3, pmlca);
104 mtpmr(PMRN_PMLCB3, pmlcb);
105 break;
106 default:
107 panic("Bad ctr number!\n");
108 }
109}
110
111void set_pmc_event(int ctr, int event)
112{
113 u32 pmlca;
114
115 pmlca = get_pmlca(ctr);
116
117 pmlca = (pmlca & ~PMLCA_EVENT_MASK) |
118 ((event << PMLCA_EVENT_SHIFT) &
119 PMLCA_EVENT_MASK);
120
121 set_pmlca(ctr, pmlca);
122}
123
124void set_pmc_user_kernel(int ctr, int user, int kernel)
125{
126 u32 pmlca;
127
128 pmlca = get_pmlca(ctr);
129
130 if(user)
131 pmlca &= ~PMLCA_FCU;
132 else
133 pmlca |= PMLCA_FCU;
134
135 if(kernel)
136 pmlca &= ~PMLCA_FCS;
137 else
138 pmlca |= PMLCA_FCS;
139
140 set_pmlca(ctr, pmlca);
141}
142
143void set_pmc_marked(int ctr, int mark0, int mark1)
144{
145 u32 pmlca = get_pmlca(ctr);
146
147 if(mark0)
148 pmlca &= ~PMLCA_FCM0;
149 else
150 pmlca |= PMLCA_FCM0;
151
152 if(mark1)
153 pmlca &= ~PMLCA_FCM1;
154 else
155 pmlca |= PMLCA_FCM1;
156
157 set_pmlca(ctr, pmlca);
158}
159
160void pmc_start_ctr(int ctr, int enable)
161{
162 u32 pmlca = get_pmlca(ctr);
163
164 pmlca &= ~PMLCA_FC;
165
166 if (enable)
167 pmlca |= PMLCA_CE;
168 else
169 pmlca &= ~PMLCA_CE;
170
171 set_pmlca(ctr, pmlca);
172}
173
174void pmc_start_ctrs(int enable)
175{
176 u32 pmgc0 = mfpmr(PMRN_PMGC0);
177
178 pmgc0 &= ~PMGC0_FAC;
179 pmgc0 |= PMGC0_FCECE;
180
181 if (enable)
182 pmgc0 |= PMGC0_PMIE;
183 else
184 pmgc0 &= ~PMGC0_PMIE;
185
186 mtpmr(PMRN_PMGC0, pmgc0);
187}
188
189void pmc_stop_ctrs(void)
190{
191 u32 pmgc0 = mfpmr(PMRN_PMGC0);
192
193 pmgc0 |= PMGC0_FAC;
194
195 pmgc0 &= ~(PMGC0_PMIE | PMGC0_FCECE);
196
197 mtpmr(PMRN_PMGC0, pmgc0);
198}
199
200void dump_pmcs(void)
201{
202 printk("pmgc0: %x\n", mfpmr(PMRN_PMGC0));
203 printk("pmc\t\tpmlca\t\tpmlcb\n");
204 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC0),
205 mfpmr(PMRN_PMLCA0), mfpmr(PMRN_PMLCB0));
206 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC1),
207 mfpmr(PMRN_PMLCA1), mfpmr(PMRN_PMLCB1));
208 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC2),
209 mfpmr(PMRN_PMLCA2), mfpmr(PMRN_PMLCB2));
210 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC3),
211 mfpmr(PMRN_PMLCA3), mfpmr(PMRN_PMLCB3));
212}
213
214EXPORT_SYMBOL(init_pmc_stop);
215EXPORT_SYMBOL(set_pmc_event);
216EXPORT_SYMBOL(set_pmc_user_kernel);
217EXPORT_SYMBOL(set_pmc_marked);
218EXPORT_SYMBOL(pmc_start_ctr);
219EXPORT_SYMBOL(pmc_start_ctrs);
220EXPORT_SYMBOL(pmc_stop_ctrs);
221EXPORT_SYMBOL(dump_pmcs);
diff --git a/arch/powerpc/kernel/pmc.c b/arch/powerpc/kernel/pmc.c
index a0a2efadeabf..3d8f6f44641e 100644
--- a/arch/powerpc/kernel/pmc.c
+++ b/arch/powerpc/kernel/pmc.c
@@ -71,7 +71,7 @@ int reserve_pmc_hardware(perf_irq_t new_perf_irq)
71 } 71 }
72 72
73 pmc_owner_caller = __builtin_return_address(0); 73 pmc_owner_caller = __builtin_return_address(0);
74 perf_irq = new_perf_irq ? : dummy_perf; 74 perf_irq = new_perf_irq ? new_perf_irq : dummy_perf;
75 75
76 out: 76 out:
77 spin_unlock(&pmc_owner_lock); 77 spin_unlock(&pmc_owner_lock);
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 5ed4c2ceb5ca..c66b4771ef44 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -843,7 +843,7 @@ void __kprobes program_check_exception(struct pt_regs *regs)
843 843
844void alignment_exception(struct pt_regs *regs) 844void alignment_exception(struct pt_regs *regs)
845{ 845{
846 int fixed = 0; 846 int sig, code, fixed = 0;
847 847
848 /* we don't implement logging of alignment exceptions */ 848 /* we don't implement logging of alignment exceptions */
849 if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS)) 849 if (!(current->thread.align_ctl & PR_UNALIGN_SIGBUS))
@@ -857,14 +857,16 @@ void alignment_exception(struct pt_regs *regs)
857 857
858 /* Operand address was bad */ 858 /* Operand address was bad */
859 if (fixed == -EFAULT) { 859 if (fixed == -EFAULT) {
860 if (user_mode(regs)) 860 sig = SIGSEGV;
861 _exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar); 861 code = SEGV_ACCERR;
862 else 862 } else {
863 /* Search exception table */ 863 sig = SIGBUS;
864 bad_page_fault(regs, regs->dar, SIGSEGV); 864 code = BUS_ADRALN;
865 return;
866 } 865 }
867 _exception(SIGBUS, regs, BUS_ADRALN, regs->dar); 866 if (user_mode(regs))
867 _exception(sig, regs, code, regs->dar);
868 else
869 bad_page_fault(regs, regs->dar, sig);
868} 870}
869 871
870void StackOverflow(struct pt_regs *regs) 872void StackOverflow(struct pt_regs *regs)
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index cb87e71eec66..ed007878d1bf 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -92,9 +92,9 @@ static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
92 &tbl->it_index, &offset, &size); 92 &tbl->it_index, &offset, &size);
93 93
94 /* TCE table size - measured in tce entries */ 94 /* TCE table size - measured in tce entries */
95 tbl->it_size = size >> PAGE_SHIFT; 95 tbl->it_size = size >> IOMMU_PAGE_SHIFT;
96 /* offset for VIO should always be 0 */ 96 /* offset for VIO should always be 0 */
97 tbl->it_offset = offset >> PAGE_SHIFT; 97 tbl->it_offset = offset >> IOMMU_PAGE_SHIFT;
98 tbl->it_busno = 0; 98 tbl->it_busno = 0;
99 tbl->it_type = TCE_VB; 99 tbl->it_type = TCE_VB;
100 100
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 9590ba780b98..7e8ded051b5b 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -9,6 +9,7 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/kprobes.h>
12#include <linux/ptrace.h> 13#include <linux/ptrace.h>
13#include <asm/sstep.h> 14#include <asm/sstep.h>
14#include <asm/processor.h> 15#include <asm/processor.h>
@@ -25,7 +26,7 @@ extern char system_call_common[];
25/* 26/*
26 * Determine whether a conditional branch instruction would branch. 27 * Determine whether a conditional branch instruction would branch.
27 */ 28 */
28static int branch_taken(unsigned int instr, struct pt_regs *regs) 29static int __kprobes branch_taken(unsigned int instr, struct pt_regs *regs)
29{ 30{
30 unsigned int bo = (instr >> 21) & 0x1f; 31 unsigned int bo = (instr >> 21) & 0x1f;
31 unsigned int bi; 32 unsigned int bi;
@@ -51,7 +52,7 @@ static int branch_taken(unsigned int instr, struct pt_regs *regs)
51 * or -1 if the instruction is one that should not be stepped, 52 * or -1 if the instruction is one that should not be stepped,
52 * such as an rfid, or a mtmsrd that would clear MSR_RI. 53 * such as an rfid, or a mtmsrd that would clear MSR_RI.
53 */ 54 */
54int emulate_step(struct pt_regs *regs, unsigned int instr) 55int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr)
55{ 56{
56 unsigned int opcode, rd; 57 unsigned int opcode, rd;
57 unsigned long int imm; 58 unsigned long int imm;
diff --git a/arch/powerpc/mm/hugetlbpage.c b/arch/powerpc/mm/hugetlbpage.c
index 5615acc29527..fd68b74c07c3 100644
--- a/arch/powerpc/mm/hugetlbpage.c
+++ b/arch/powerpc/mm/hugetlbpage.c
@@ -480,9 +480,6 @@ static int open_high_hpage_areas(struct mm_struct *mm, u16 newareas)
480 480
481 mm->context.high_htlb_areas |= newareas; 481 mm->context.high_htlb_areas |= newareas;
482 482
483 /* update the paca copy of the context struct */
484 get_paca()->context = mm->context;
485
486 /* the context change must make it to memory before the flush, 483 /* the context change must make it to memory before the flush,
487 * so that further SLB misses do the right thing. */ 484 * so that further SLB misses do the right thing. */
488 mb(); 485 mb();
diff --git a/arch/powerpc/oprofile/Makefile b/arch/powerpc/oprofile/Makefile
index 3145d610b5b0..0b5df9c96ae0 100644
--- a/arch/powerpc/oprofile/Makefile
+++ b/arch/powerpc/oprofile/Makefile
@@ -13,4 +13,4 @@ DRIVER_OBJS := $(addprefix ../../../drivers/oprofile/, \
13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o 13oprofile-y := $(DRIVER_OBJS) common.o backtrace.o
14oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o 14oprofile-$(CONFIG_PPC64) += op_model_rs64.o op_model_power4.o
15oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o 15oprofile-$(CONFIG_FSL_BOOKE) += op_model_fsl_booke.o
16oprofile-$(CONFIG_PPC32) += op_model_7450.o 16oprofile-$(CONFIG_6xx) += op_model_7450.o
diff --git a/arch/powerpc/oprofile/common.c b/arch/powerpc/oprofile/common.c
index fd0bbbe7a4de..63bbef3b63f1 100644
--- a/arch/powerpc/oprofile/common.c
+++ b/arch/powerpc/oprofile/common.c
@@ -34,6 +34,11 @@ static void op_handle_interrupt(struct pt_regs *regs)
34 model->handle_interrupt(regs, ctr); 34 model->handle_interrupt(regs, ctr);
35} 35}
36 36
37static void op_powerpc_cpu_setup(void *dummy)
38{
39 model->cpu_setup(ctr);
40}
41
37static int op_powerpc_setup(void) 42static int op_powerpc_setup(void)
38{ 43{
39 int err; 44 int err;
@@ -47,7 +52,7 @@ static int op_powerpc_setup(void)
47 model->reg_setup(ctr, &sys, model->num_counters); 52 model->reg_setup(ctr, &sys, model->num_counters);
48 53
49 /* Configure the registers on all cpus. */ 54 /* Configure the registers on all cpus. */
50 on_each_cpu(model->cpu_setup, NULL, 0, 1); 55 on_each_cpu(op_powerpc_cpu_setup, NULL, 0, 1);
51 56
52 return 0; 57 return 0;
53} 58}
@@ -142,7 +147,8 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
142 case PPC_OPROFILE_POWER4: 147 case PPC_OPROFILE_POWER4:
143 model = &op_model_power4; 148 model = &op_model_power4;
144 break; 149 break;
145#else 150#endif
151#ifdef CONFIG_6xx
146 case PPC_OPROFILE_G4: 152 case PPC_OPROFILE_G4:
147 model = &op_model_7450; 153 model = &op_model_7450;
148 break; 154 break;
diff --git a/arch/powerpc/oprofile/op_model_7450.c b/arch/powerpc/oprofile/op_model_7450.c
index d8ee3aea83f8..f481c0ed5e67 100644
--- a/arch/powerpc/oprofile/op_model_7450.c
+++ b/arch/powerpc/oprofile/op_model_7450.c
@@ -81,7 +81,7 @@ static void pmc_stop_ctrs(void)
81 81
82/* Configures the counters on this CPU based on the global 82/* Configures the counters on this CPU based on the global
83 * settings */ 83 * settings */
84static void fsl7450_cpu_setup(void *unused) 84static void fsl7450_cpu_setup(struct op_counter_config *ctr)
85{ 85{
86 /* freeze all counters */ 86 /* freeze all counters */
87 pmc_stop_ctrs(); 87 pmc_stop_ctrs();
diff --git a/arch/powerpc/oprofile/op_model_fsl_booke.c b/arch/powerpc/oprofile/op_model_fsl_booke.c
index e29dede31423..0b3c31f5209e 100644
--- a/arch/powerpc/oprofile/op_model_fsl_booke.c
+++ b/arch/powerpc/oprofile/op_model_fsl_booke.c
@@ -32,42 +32,152 @@ static unsigned long reset_value[OP_MAX_COUNTER];
32static int num_counters; 32static int num_counters;
33static int oprofile_running; 33static int oprofile_running;
34 34
35static inline unsigned int ctr_read(unsigned int i) 35static void init_pmc_stop(int ctr)
36{ 36{
37 switch(i) { 37 u32 pmlca = (PMLCA_FC | PMLCA_FCS | PMLCA_FCU |
38 case 0: 38 PMLCA_FCM1 | PMLCA_FCM0);
39 return mfpmr(PMRN_PMC0); 39 u32 pmlcb = 0;
40 case 1:
41 return mfpmr(PMRN_PMC1);
42 case 2:
43 return mfpmr(PMRN_PMC2);
44 case 3:
45 return mfpmr(PMRN_PMC3);
46 default:
47 return 0;
48 }
49}
50 40
51static inline void ctr_write(unsigned int i, unsigned int val) 41 switch (ctr) {
52{
53 switch(i) {
54 case 0: 42 case 0:
55 mtpmr(PMRN_PMC0, val); 43 mtpmr(PMRN_PMLCA0, pmlca);
44 mtpmr(PMRN_PMLCB0, pmlcb);
56 break; 45 break;
57 case 1: 46 case 1:
58 mtpmr(PMRN_PMC1, val); 47 mtpmr(PMRN_PMLCA1, pmlca);
48 mtpmr(PMRN_PMLCB1, pmlcb);
59 break; 49 break;
60 case 2: 50 case 2:
61 mtpmr(PMRN_PMC2, val); 51 mtpmr(PMRN_PMLCA2, pmlca);
52 mtpmr(PMRN_PMLCB2, pmlcb);
62 break; 53 break;
63 case 3: 54 case 3:
64 mtpmr(PMRN_PMC3, val); 55 mtpmr(PMRN_PMLCA3, pmlca);
56 mtpmr(PMRN_PMLCB3, pmlcb);
65 break; 57 break;
66 default: 58 default:
67 break; 59 panic("Bad ctr number!\n");
68 } 60 }
69} 61}
70 62
63static void set_pmc_event(int ctr, int event)
64{
65 u32 pmlca;
66
67 pmlca = get_pmlca(ctr);
68
69 pmlca = (pmlca & ~PMLCA_EVENT_MASK) |
70 ((event << PMLCA_EVENT_SHIFT) &
71 PMLCA_EVENT_MASK);
72
73 set_pmlca(ctr, pmlca);
74}
75
76static void set_pmc_user_kernel(int ctr, int user, int kernel)
77{
78 u32 pmlca;
79
80 pmlca = get_pmlca(ctr);
81
82 if(user)
83 pmlca &= ~PMLCA_FCU;
84 else
85 pmlca |= PMLCA_FCU;
86
87 if(kernel)
88 pmlca &= ~PMLCA_FCS;
89 else
90 pmlca |= PMLCA_FCS;
91
92 set_pmlca(ctr, pmlca);
93}
94
95static void set_pmc_marked(int ctr, int mark0, int mark1)
96{
97 u32 pmlca = get_pmlca(ctr);
98
99 if(mark0)
100 pmlca &= ~PMLCA_FCM0;
101 else
102 pmlca |= PMLCA_FCM0;
103
104 if(mark1)
105 pmlca &= ~PMLCA_FCM1;
106 else
107 pmlca |= PMLCA_FCM1;
108
109 set_pmlca(ctr, pmlca);
110}
111
112static void pmc_start_ctr(int ctr, int enable)
113{
114 u32 pmlca = get_pmlca(ctr);
115
116 pmlca &= ~PMLCA_FC;
117
118 if (enable)
119 pmlca |= PMLCA_CE;
120 else
121 pmlca &= ~PMLCA_CE;
122
123 set_pmlca(ctr, pmlca);
124}
125
126static void pmc_start_ctrs(int enable)
127{
128 u32 pmgc0 = mfpmr(PMRN_PMGC0);
129
130 pmgc0 &= ~PMGC0_FAC;
131 pmgc0 |= PMGC0_FCECE;
132
133 if (enable)
134 pmgc0 |= PMGC0_PMIE;
135 else
136 pmgc0 &= ~PMGC0_PMIE;
137
138 mtpmr(PMRN_PMGC0, pmgc0);
139}
140
141static void pmc_stop_ctrs(void)
142{
143 u32 pmgc0 = mfpmr(PMRN_PMGC0);
144
145 pmgc0 |= PMGC0_FAC;
146
147 pmgc0 &= ~(PMGC0_PMIE | PMGC0_FCECE);
148
149 mtpmr(PMRN_PMGC0, pmgc0);
150}
151
152static void dump_pmcs(void)
153{
154 printk("pmgc0: %x\n", mfpmr(PMRN_PMGC0));
155 printk("pmc\t\tpmlca\t\tpmlcb\n");
156 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC0),
157 mfpmr(PMRN_PMLCA0), mfpmr(PMRN_PMLCB0));
158 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC1),
159 mfpmr(PMRN_PMLCA1), mfpmr(PMRN_PMLCB1));
160 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC2),
161 mfpmr(PMRN_PMLCA2), mfpmr(PMRN_PMLCB2));
162 printk("%8x\t%8x\t%8x\n", mfpmr(PMRN_PMC3),
163 mfpmr(PMRN_PMLCA3), mfpmr(PMRN_PMLCB3));
164}
165
166static void fsl_booke_cpu_setup(struct op_counter_config *ctr)
167{
168 int i;
169
170 /* freeze all counters */
171 pmc_stop_ctrs();
172
173 for (i = 0;i < num_counters;i++) {
174 init_pmc_stop(i);
175
176 set_pmc_event(i, ctr[i].event);
177
178 set_pmc_user_kernel(i, ctr[i].user, ctr[i].kernel);
179 }
180}
71 181
72static void fsl_booke_reg_setup(struct op_counter_config *ctr, 182static void fsl_booke_reg_setup(struct op_counter_config *ctr,
73 struct op_system_config *sys, 183 struct op_system_config *sys,
@@ -77,23 +187,14 @@ static void fsl_booke_reg_setup(struct op_counter_config *ctr,
77 187
78 num_counters = num_ctrs; 188 num_counters = num_ctrs;
79 189
80 /* freeze all counters */
81 pmc_stop_ctrs();
82
83 /* Our counters count up, and "count" refers to 190 /* Our counters count up, and "count" refers to
84 * how much before the next interrupt, and we interrupt 191 * how much before the next interrupt, and we interrupt
85 * on overflow. So we calculate the starting value 192 * on overflow. So we calculate the starting value
86 * which will give us "count" until overflow. 193 * which will give us "count" until overflow.
87 * Then we set the events on the enabled counters */ 194 * Then we set the events on the enabled counters */
88 for (i = 0; i < num_counters; ++i) { 195 for (i = 0; i < num_counters; ++i)
89 reset_value[i] = 0x80000000UL - ctr[i].count; 196 reset_value[i] = 0x80000000UL - ctr[i].count;
90 197
91 init_pmc_stop(i);
92
93 set_pmc_event(i, ctr[i].event);
94
95 set_pmc_user_kernel(i, ctr[i].user, ctr[i].kernel);
96 }
97} 198}
98 199
99static void fsl_booke_start(struct op_counter_config *ctr) 200static void fsl_booke_start(struct op_counter_config *ctr)
@@ -105,8 +206,8 @@ static void fsl_booke_start(struct op_counter_config *ctr)
105 for (i = 0; i < num_counters; ++i) { 206 for (i = 0; i < num_counters; ++i) {
106 if (ctr[i].enabled) { 207 if (ctr[i].enabled) {
107 ctr_write(i, reset_value[i]); 208 ctr_write(i, reset_value[i]);
108 /* Set Each enabled counterd to only 209 /* Set each enabled counter to only
109 * count when the Mark bit is not set */ 210 * count when the Mark bit is *not* set */
110 set_pmc_marked(i, 1, 0); 211 set_pmc_marked(i, 1, 0);
111 pmc_start_ctr(i, 1); 212 pmc_start_ctr(i, 1);
112 } else { 213 } else {
@@ -177,6 +278,7 @@ static void fsl_booke_handle_interrupt(struct pt_regs *regs,
177 278
178struct op_powerpc_model op_model_fsl_booke = { 279struct op_powerpc_model op_model_fsl_booke = {
179 .reg_setup = fsl_booke_reg_setup, 280 .reg_setup = fsl_booke_reg_setup,
281 .cpu_setup = fsl_booke_cpu_setup,
180 .start = fsl_booke_start, 282 .start = fsl_booke_start,
181 .stop = fsl_booke_stop, 283 .stop = fsl_booke_stop,
182 .handle_interrupt = fsl_booke_handle_interrupt, 284 .handle_interrupt = fsl_booke_handle_interrupt,
diff --git a/arch/powerpc/oprofile/op_model_power4.c b/arch/powerpc/oprofile/op_model_power4.c
index 6a927effcc77..356709d515b9 100644
--- a/arch/powerpc/oprofile/op_model_power4.c
+++ b/arch/powerpc/oprofile/op_model_power4.c
@@ -82,7 +82,7 @@ static inline int mmcra_must_set_sample(void)
82 return 0; 82 return 0;
83} 83}
84 84
85static void power4_cpu_setup(void *unused) 85static void power4_cpu_setup(struct op_counter_config *ctr)
86{ 86{
87 unsigned int mmcr0 = mmcr0_val; 87 unsigned int mmcr0 = mmcr0_val;
88 unsigned long mmcra = mmcra_val; 88 unsigned long mmcra = mmcra_val;
diff --git a/arch/powerpc/oprofile/op_model_rs64.c b/arch/powerpc/oprofile/op_model_rs64.c
index 042f8f4867ad..19c5ee089bc9 100644
--- a/arch/powerpc/oprofile/op_model_rs64.c
+++ b/arch/powerpc/oprofile/op_model_rs64.c
@@ -102,7 +102,7 @@ static void rs64_reg_setup(struct op_counter_config *ctr,
102 /* XXX setup user and kernel profiling */ 102 /* XXX setup user and kernel profiling */
103} 103}
104 104
105static void rs64_cpu_setup(void *unused) 105static void rs64_cpu_setup(struct op_counter_config *ctr)
106{ 106{
107 unsigned int mmcr0; 107 unsigned int mmcr0;
108 108
diff --git a/arch/powerpc/platforms/iseries/iommu.c b/arch/powerpc/platforms/iseries/iommu.c
index f4cbbcf8773a..218817d13c5c 100644
--- a/arch/powerpc/platforms/iseries/iommu.c
+++ b/arch/powerpc/platforms/iseries/iommu.c
@@ -43,9 +43,6 @@ static void tce_build_iSeries(struct iommu_table *tbl, long index, long npages,
43 u64 rc; 43 u64 rc;
44 u64 tce, rpn; 44 u64 tce, rpn;
45 45
46 index <<= TCE_PAGE_FACTOR;
47 npages <<= TCE_PAGE_FACTOR;
48
49 while (npages--) { 46 while (npages--) {
50 rpn = virt_to_abs(uaddr) >> TCE_SHIFT; 47 rpn = virt_to_abs(uaddr) >> TCE_SHIFT;
51 tce = (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT; 48 tce = (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT;
@@ -75,9 +72,6 @@ static void tce_free_iSeries(struct iommu_table *tbl, long index, long npages)
75{ 72{
76 u64 rc; 73 u64 rc;
77 74
78 npages <<= TCE_PAGE_FACTOR;
79 index <<= TCE_PAGE_FACTOR;
80
81 while (npages--) { 75 while (npages--) {
82 rc = HvCallXm_setTce((u64)tbl->it_index, (u64)index, 0); 76 rc = HvCallXm_setTce((u64)tbl->it_index, (u64)index, 0);
83 if (rc) 77 if (rc)
@@ -136,10 +130,9 @@ void iommu_table_getparms_iSeries(unsigned long busno,
136 panic("PCI_DMA: parms->size is zero, parms is 0x%p", parms); 130 panic("PCI_DMA: parms->size is zero, parms is 0x%p", parms);
137 131
138 /* itc_size is in pages worth of table, it_size is in # of entries */ 132 /* itc_size is in pages worth of table, it_size is in # of entries */
139 tbl->it_size = ((parms->itc_size * TCE_PAGE_SIZE) / 133 tbl->it_size = (parms->itc_size * TCE_PAGE_SIZE) / TCE_ENTRY_SIZE;
140 TCE_ENTRY_SIZE) >> TCE_PAGE_FACTOR;
141 tbl->it_busno = parms->itc_busno; 134 tbl->it_busno = parms->itc_busno;
142 tbl->it_offset = parms->itc_offset >> TCE_PAGE_FACTOR; 135 tbl->it_offset = parms->itc_offset;
143 tbl->it_index = parms->itc_index; 136 tbl->it_index = parms->itc_index;
144 tbl->it_blocksize = 1; 137 tbl->it_blocksize = 1;
145 tbl->it_type = virtbus ? TCE_VB : TCE_PCI; 138 tbl->it_type = virtbus ? TCE_VB : TCE_PCI;
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index d24ba547e53f..556c279a789d 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -57,9 +57,6 @@ static void tce_build_pSeries(struct iommu_table *tbl, long index,
57 u64 *tcep; 57 u64 *tcep;
58 u64 rpn; 58 u64 rpn;
59 59
60 index <<= TCE_PAGE_FACTOR;
61 npages <<= TCE_PAGE_FACTOR;
62
63 proto_tce = TCE_PCI_READ; // Read allowed 60 proto_tce = TCE_PCI_READ; // Read allowed
64 61
65 if (direction != DMA_TO_DEVICE) 62 if (direction != DMA_TO_DEVICE)
@@ -82,9 +79,6 @@ static void tce_free_pSeries(struct iommu_table *tbl, long index, long npages)
82{ 79{
83 u64 *tcep; 80 u64 *tcep;
84 81
85 npages <<= TCE_PAGE_FACTOR;
86 index <<= TCE_PAGE_FACTOR;
87
88 tcep = ((u64 *)tbl->it_base) + index; 82 tcep = ((u64 *)tbl->it_base) + index;
89 83
90 while (npages--) 84 while (npages--)
@@ -95,7 +89,6 @@ static unsigned long tce_get_pseries(struct iommu_table *tbl, long index)
95{ 89{
96 u64 *tcep; 90 u64 *tcep;
97 91
98 index <<= TCE_PAGE_FACTOR;
99 tcep = ((u64 *)tbl->it_base) + index; 92 tcep = ((u64 *)tbl->it_base) + index;
100 93
101 return *tcep; 94 return *tcep;
@@ -109,9 +102,6 @@ static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
109 u64 proto_tce, tce; 102 u64 proto_tce, tce;
110 u64 rpn; 103 u64 rpn;
111 104
112 tcenum <<= TCE_PAGE_FACTOR;
113 npages <<= TCE_PAGE_FACTOR;
114
115 rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; 105 rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT;
116 proto_tce = TCE_PCI_READ; 106 proto_tce = TCE_PCI_READ;
117 if (direction != DMA_TO_DEVICE) 107 if (direction != DMA_TO_DEVICE)
@@ -146,7 +136,7 @@ static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
146 u64 rpn; 136 u64 rpn;
147 long l, limit; 137 long l, limit;
148 138
149 if (TCE_PAGE_FACTOR == 0 && npages == 1) 139 if (npages == 1)
150 return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr, 140 return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr,
151 direction); 141 direction);
152 142
@@ -164,9 +154,6 @@ static void tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
164 __get_cpu_var(tce_page) = tcep; 154 __get_cpu_var(tce_page) = tcep;
165 } 155 }
166 156
167 tcenum <<= TCE_PAGE_FACTOR;
168 npages <<= TCE_PAGE_FACTOR;
169
170 rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; 157 rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT;
171 proto_tce = TCE_PCI_READ; 158 proto_tce = TCE_PCI_READ;
172 if (direction != DMA_TO_DEVICE) 159 if (direction != DMA_TO_DEVICE)
@@ -207,9 +194,6 @@ static void tce_free_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages
207{ 194{
208 u64 rc; 195 u64 rc;
209 196
210 tcenum <<= TCE_PAGE_FACTOR;
211 npages <<= TCE_PAGE_FACTOR;
212
213 while (npages--) { 197 while (npages--) {
214 rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, 0); 198 rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, 0);
215 199
@@ -229,9 +213,6 @@ static void tce_freemulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long n
229{ 213{
230 u64 rc; 214 u64 rc;
231 215
232 tcenum <<= TCE_PAGE_FACTOR;
233 npages <<= TCE_PAGE_FACTOR;
234
235 rc = plpar_tce_stuff((u64)tbl->it_index, (u64)tcenum << 12, 0, npages); 216 rc = plpar_tce_stuff((u64)tbl->it_index, (u64)tcenum << 12, 0, npages);
236 217
237 if (rc && printk_ratelimit()) { 218 if (rc && printk_ratelimit()) {
@@ -248,7 +229,6 @@ static unsigned long tce_get_pSeriesLP(struct iommu_table *tbl, long tcenum)
248 u64 rc; 229 u64 rc;
249 unsigned long tce_ret; 230 unsigned long tce_ret;
250 231
251 tcenum <<= TCE_PAGE_FACTOR;
252 rc = plpar_tce_get((u64)tbl->it_index, (u64)tcenum << 12, &tce_ret); 232 rc = plpar_tce_get((u64)tbl->it_index, (u64)tcenum << 12, &tce_ret);
253 233
254 if (rc && printk_ratelimit()) { 234 if (rc && printk_ratelimit()) {
@@ -289,7 +269,7 @@ static void iommu_table_setparms(struct pci_controller *phb,
289 tbl->it_busno = phb->bus->number; 269 tbl->it_busno = phb->bus->number;
290 270
291 /* Units of tce entries */ 271 /* Units of tce entries */
292 tbl->it_offset = phb->dma_window_base_cur >> PAGE_SHIFT; 272 tbl->it_offset = phb->dma_window_base_cur >> IOMMU_PAGE_SHIFT;
293 273
294 /* Test if we are going over 2GB of DMA space */ 274 /* Test if we are going over 2GB of DMA space */
295 if (phb->dma_window_base_cur + phb->dma_window_size > 0x80000000ul) { 275 if (phb->dma_window_base_cur + phb->dma_window_size > 0x80000000ul) {
@@ -300,7 +280,7 @@ static void iommu_table_setparms(struct pci_controller *phb,
300 phb->dma_window_base_cur += phb->dma_window_size; 280 phb->dma_window_base_cur += phb->dma_window_size;
301 281
302 /* Set the tce table size - measured in entries */ 282 /* Set the tce table size - measured in entries */
303 tbl->it_size = phb->dma_window_size >> PAGE_SHIFT; 283 tbl->it_size = phb->dma_window_size >> IOMMU_PAGE_SHIFT;
304 284
305 tbl->it_index = 0; 285 tbl->it_index = 0;
306 tbl->it_blocksize = 16; 286 tbl->it_blocksize = 16;
@@ -325,8 +305,8 @@ static void iommu_table_setparms_lpar(struct pci_controller *phb,
325 tbl->it_base = 0; 305 tbl->it_base = 0;
326 tbl->it_blocksize = 16; 306 tbl->it_blocksize = 16;
327 tbl->it_type = TCE_PCI; 307 tbl->it_type = TCE_PCI;
328 tbl->it_offset = offset >> PAGE_SHIFT; 308 tbl->it_offset = offset >> IOMMU_PAGE_SHIFT;
329 tbl->it_size = size >> PAGE_SHIFT; 309 tbl->it_size = size >> IOMMU_PAGE_SHIFT;
330} 310}
331 311
332static void iommu_bus_setup_pSeries(struct pci_bus *bus) 312static void iommu_bus_setup_pSeries(struct pci_bus *bus)
@@ -522,8 +502,6 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
522 const void *dma_window = NULL; 502 const void *dma_window = NULL;
523 struct pci_dn *pci; 503 struct pci_dn *pci;
524 504
525 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s)\n", dev, pci_name(dev));
526
527 /* dev setup for LPAR is a little tricky, since the device tree might 505 /* dev setup for LPAR is a little tricky, since the device tree might
528 * contain the dma-window properties per-device and not neccesarily 506 * contain the dma-window properties per-device and not neccesarily
529 * for the bus. So we need to search upwards in the tree until we 507 * for the bus. So we need to search upwards in the tree until we
@@ -532,6 +510,9 @@ static void iommu_dev_setup_pSeriesLP(struct pci_dev *dev)
532 */ 510 */
533 dn = pci_device_to_OF_node(dev); 511 dn = pci_device_to_OF_node(dev);
534 512
513 DBG("iommu_dev_setup_pSeriesLP, dev %p (%s) %s\n",
514 dev, pci_name(dev), dn->full_name);
515
535 for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table; 516 for (pdn = dn; pdn && PCI_DN(pdn) && !PCI_DN(pdn)->iommu_table;
536 pdn = pdn->parent) { 517 pdn = pdn->parent) {
537 dma_window = get_property(pdn, "ibm,dma-window", NULL); 518 dma_window = get_property(pdn, "ibm,dma-window", NULL);
diff --git a/arch/powerpc/sysdev/dart.h b/arch/powerpc/sysdev/dart.h
index 1c8817c4835e..ff202edb0591 100644
--- a/arch/powerpc/sysdev/dart.h
+++ b/arch/powerpc/sysdev/dart.h
@@ -72,7 +72,6 @@
72 72
73#define DART_PAGE_SHIFT 12 73#define DART_PAGE_SHIFT 12
74#define DART_PAGE_SIZE (1 << DART_PAGE_SHIFT) 74#define DART_PAGE_SIZE (1 << DART_PAGE_SHIFT)
75#define DART_PAGE_FACTOR (PAGE_SHIFT - DART_PAGE_SHIFT)
76 75
77 76
78#endif /* _POWERPC_SYSDEV_DART_H */ 77#endif /* _POWERPC_SYSDEV_DART_H */
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index 03b4477dd7f0..572b7846cc77 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -156,9 +156,6 @@ static void dart_build(struct iommu_table *tbl, long index,
156 156
157 DBG("dart: build at: %lx, %lx, addr: %x\n", index, npages, uaddr); 157 DBG("dart: build at: %lx, %lx, addr: %x\n", index, npages, uaddr);
158 158
159 index <<= DART_PAGE_FACTOR;
160 npages <<= DART_PAGE_FACTOR;
161
162 dp = ((unsigned int*)tbl->it_base) + index; 159 dp = ((unsigned int*)tbl->it_base) + index;
163 160
164 /* On U3, all memory is contigous, so we can move this 161 /* On U3, all memory is contigous, so we can move this
@@ -199,9 +196,6 @@ static void dart_free(struct iommu_table *tbl, long index, long npages)
199 196
200 DBG("dart: free at: %lx, %lx\n", index, npages); 197 DBG("dart: free at: %lx, %lx\n", index, npages);
201 198
202 index <<= DART_PAGE_FACTOR;
203 npages <<= DART_PAGE_FACTOR;
204
205 dp = ((unsigned int *)tbl->it_base) + index; 199 dp = ((unsigned int *)tbl->it_base) + index;
206 200
207 while (npages--) 201 while (npages--)
@@ -281,7 +275,7 @@ static void iommu_table_dart_setup(void)
281 iommu_table_dart.it_busno = 0; 275 iommu_table_dart.it_busno = 0;
282 iommu_table_dart.it_offset = 0; 276 iommu_table_dart.it_offset = 0;
283 /* it_size is in number of entries */ 277 /* it_size is in number of entries */
284 iommu_table_dart.it_size = (dart_tablesize / sizeof(u32)) >> DART_PAGE_FACTOR; 278 iommu_table_dart.it_size = dart_tablesize / sizeof(u32);
285 279
286 /* Initialize the common IOMMU code */ 280 /* Initialize the common IOMMU code */
287 iommu_table_dart.it_base = (unsigned long)dart_vbase; 281 iommu_table_dart.it_base = (unsigned long)dart_vbase;
diff --git a/arch/powerpc/sysdev/qe_lib/qe.c b/arch/powerpc/sysdev/qe_lib/qe.c
index 2bae632d3ad7..e4223226a7a8 100644
--- a/arch/powerpc/sysdev/qe_lib/qe.c
+++ b/arch/powerpc/sysdev/qe_lib/qe.c
@@ -122,8 +122,7 @@ int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input)
122 mcn_shift = QE_CR_MCN_NORMAL_SHIFT; 122 mcn_shift = QE_CR_MCN_NORMAL_SHIFT;
123 } 123 }
124 124
125 out_be32(&qe_immr->cp.cecdr, 125 out_be32(&qe_immr->cp.cecdr, cmd_input);
126 immrbar_virt_to_phys((void *)cmd_input));
127 out_be32(&qe_immr->cp.cecr, 126 out_be32(&qe_immr->cp.cecr,
128 (cmd | QE_CR_FLG | ((u32) device << dev_shift) | (u32) 127 (cmd | QE_CR_FLG | ((u32) device << dev_shift) | (u32)
129 mcn_protocol << mcn_shift)); 128 mcn_protocol << mcn_shift));
diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
index aafc8e8893d1..9661a91183b3 100644
--- a/arch/ppc/kernel/traps.c
+++ b/arch/ppc/kernel/traps.c
@@ -708,7 +708,7 @@ void single_step_exception(struct pt_regs *regs)
708 708
709void alignment_exception(struct pt_regs *regs) 709void alignment_exception(struct pt_regs *regs)
710{ 710{
711 int fixed; 711 int sig, code, fixed = 0;
712 712
713 fixed = fix_alignment(regs); 713 fixed = fix_alignment(regs);
714 if (fixed == 1) { 714 if (fixed == 1) {
@@ -717,14 +717,16 @@ void alignment_exception(struct pt_regs *regs)
717 return; 717 return;
718 } 718 }
719 if (fixed == -EFAULT) { 719 if (fixed == -EFAULT) {
720 /* fixed == -EFAULT means the operand address was bad */ 720 sig = SIGSEGV;
721 if (user_mode(regs)) 721 code = SEGV_ACCERR;
722 _exception(SIGSEGV, regs, SEGV_ACCERR, regs->dar); 722 } else {
723 else 723 sig = SIGBUS;
724 bad_page_fault(regs, regs->dar, SIGSEGV); 724 code = BUS_ADRALN;
725 return;
726 } 725 }
727 _exception(SIGBUS, regs, BUS_ADRALN, regs->dar); 726 if (user_mode(regs))
727 _exception(sig, regs, code, regs->dar);
728 else
729 bad_page_fault(regs, regs->dar, sig);
728} 730}
729 731
730void StackOverflow(struct pt_regs *regs) 732void StackOverflow(struct pt_regs *regs)
diff --git a/arch/sh/boards/renesas/hs7751rvoip/setup.c b/arch/sh/boards/renesas/hs7751rvoip/setup.c
index 1d997ffd7931..f7d0e304d899 100644
--- a/arch/sh/boards/renesas/hs7751rvoip/setup.c
+++ b/arch/sh/boards/renesas/hs7751rvoip/setup.c
@@ -15,12 +15,16 @@
15#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/machvec.h> 16#include <asm/machvec.h>
17 17
18static void __init hs7751rvoip_init_irq(void) 18static struct ipr_data hs77501rvoip_ipr_map[] = {
19{
20#if defined(CONFIG_HS7751RVOIP_CODEC) 19#if defined(CONFIG_HS7751RVOIP_CODEC)
21 make_ipr_irq(DMTE0_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY); 20 { DMTE0_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
22 make_ipr_irq(DMTE1_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY); 21 { DMTE1_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
23#endif 22#endif
23};
24
25static void __init hs7751rvoip_init_irq(void)
26{
27 make_ipr_irq(hs77501rvoip_ipr_map, ARRAY_SIZE(hs77501rvoip_ipr_map));
24 28
25 init_hs7751rvoip_IRQ(); 29 init_hs7751rvoip_IRQ();
26} 30}
diff --git a/arch/sh/boards/renesas/sh7710voipgw/setup.c b/arch/sh/boards/renesas/sh7710voipgw/setup.c
index e57e7afab8c6..180810b12107 100644
--- a/arch/sh/boards/renesas/sh7710voipgw/setup.c
+++ b/arch/sh/boards/renesas/sh7710voipgw/setup.c
@@ -13,6 +13,51 @@
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/irq.h> 14#include <asm/irq.h>
15 15
16static struct ipr_data sh7710voipgw_ipr_map[] = {
17 { TIMER2_IRQ, TIMER2_IPR_ADDR, TIMER2_IPR_POS, TIMER2_PRIORITY },
18 { WDT_IRQ, WDT_IPR_ADDR, WDT_IPR_POS, WDT_PRIORITY },
19
20 /* SCIF0 */
21 { SCIF0_ERI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
22 { SCIF0_RXI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
23 { SCIF0_BRI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
24 { SCIF0_TXI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
25
26 /* DMAC-1 */
27 { DMTE0_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
28 { DMTE1_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
29 { DMTE2_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
30 { DMTE3_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
31
32 /* DMAC-2 */
33 { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
34 { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
35
36 /* IPSEC */
37 { IPSEC_IRQ, IPSEC_IPR_ADDR, IPSEC_IPR_POS, IPSEC_PRIORITY },
38
39 /* EDMAC */
40 { EDMAC0_IRQ, EDMAC0_IPR_ADDR, EDMAC0_IPR_POS, EDMAC0_PRIORITY },
41 { EDMAC1_IRQ, EDMAC1_IPR_ADDR, EDMAC1_IPR_POS, EDMAC1_PRIORITY },
42 { EDMAC2_IRQ, EDMAC2_IPR_ADDR, EDMAC2_IPR_POS, EDMAC2_PRIORITY },
43
44 /* SIOF0 */
45 { SIOF0_ERI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
46 { SIOF0_TXI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
47 { SIOF0_RXI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
48 { SIOF0_CCI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
49
50 /* SIOF1 */
51 { SIOF1_ERI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS, SIOF1_PRIORITY },
52 { SIOF1_TXI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS, SIOF1_PRIORITY },
53 { SIOF1_RXI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS, SIOF1_PRIORITY },
54 { SIOF1_CCI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS, SIOF1_PRIORITY },
55
56 /* SLIC IRQ's */
57 { IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY },
58 { IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY },
59};
60
16/* 61/*
17 * Initialize IRQ setting 62 * Initialize IRQ setting
18 */ 63 */
@@ -37,65 +82,7 @@ static void __init sh7710voipgw_init_irq(void)
37 */ 82 */
38 ctrl_outw(0x2aa, INTC_ICR1); 83 ctrl_outw(0x2aa, INTC_ICR1);
39 84
40 /* Now make IPR interrupts */ 85 make_ipr_irq(sh7710voipgw_ipr_map, ARRAY_SIZE(sh7710voipgw_ipr_map));
41 make_ipr_irq(TIMER2_IRQ, TIMER2_IPR_ADDR,
42 TIMER2_IPR_POS, TIMER2_PRIORITY);
43 make_ipr_irq(WDT_IRQ, WDT_IPR_ADDR, WDT_IPR_POS, WDT_PRIORITY);
44
45 /* SCIF0 */
46 make_ipr_irq(SCIF0_ERI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
47 SCIF0_PRIORITY);
48 make_ipr_irq(SCIF0_RXI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
49 SCIF0_PRIORITY);
50 make_ipr_irq(SCIF0_BRI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
51 SCIF0_PRIORITY);
52 make_ipr_irq(SCIF0_TXI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
53 SCIF0_PRIORITY);
54
55 /* DMAC-1 */
56 make_ipr_irq(DMTE0_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
57 make_ipr_irq(DMTE1_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
58 make_ipr_irq(DMTE2_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
59 make_ipr_irq(DMTE3_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
60
61 /* DMAC-2 */
62 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
63 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
64
65 /* IPSEC */
66 make_ipr_irq(IPSEC_IRQ, IPSEC_IPR_ADDR, IPSEC_IPR_POS, IPSEC_PRIORITY);
67
68 /* EDMAC */
69 make_ipr_irq(EDMAC0_IRQ, EDMAC0_IPR_ADDR, EDMAC0_IPR_POS,
70 EDMAC0_PRIORITY);
71 make_ipr_irq(EDMAC1_IRQ, EDMAC1_IPR_ADDR, EDMAC1_IPR_POS,
72 EDMAC1_PRIORITY);
73 make_ipr_irq(EDMAC2_IRQ, EDMAC2_IPR_ADDR, EDMAC2_IPR_POS,
74 EDMAC2_PRIORITY);
75
76 /* SIOF0 */
77 make_ipr_irq(SIOF0_ERI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
78 SIOF0_PRIORITY);
79 make_ipr_irq(SIOF0_TXI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
80 SIOF0_PRIORITY);
81 make_ipr_irq(SIOF0_RXI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
82 SIOF0_PRIORITY);
83 make_ipr_irq(SIOF0_CCI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
84 SIOF0_PRIORITY);
85
86 /* SIOF1 */
87 make_ipr_irq(SIOF1_ERI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
88 SIOF1_PRIORITY);
89 make_ipr_irq(SIOF1_TXI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
90 SIOF1_PRIORITY);
91 make_ipr_irq(SIOF1_RXI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
92 SIOF1_PRIORITY);
93 make_ipr_irq(SIOF1_CCI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
94 SIOF1_PRIORITY);
95
96 /* SLIC IRQ's */
97 make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY);
98 make_ipr_irq(IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY);
99} 86}
100 87
101/* 88/*
diff --git a/arch/sh/boards/se/7300/irq.c b/arch/sh/boards/se/7300/irq.c
index ad1034f98a29..1279d776d60f 100644
--- a/arch/sh/boards/se/7300/irq.c
+++ b/arch/sh/boards/se/7300/irq.c
@@ -13,6 +13,17 @@
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/se7300.h> 14#include <asm/se7300.h>
15 15
16static struct ipr_data se7300_ipr_map[] = {
17 /* PC_IRQ[0-3] -> IRQ0 (32) */
18 { IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, 0x0f - IRQ0_IRQ },
19 /* A_IRQ[0-3] -> IRQ1 (33) */
20 { IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, 0x0f - IRQ1_IRQ },
21 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
22 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
23 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
24 { VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
25};
26
16/* 27/*
17 * Initialize IRQ setting 28 * Initialize IRQ setting
18 */ 29 */
@@ -23,14 +34,7 @@ init_7300se_IRQ(void)
23 ctrl_outw(0xa000, INTC_ICR1); /* IRQ mode; IRQ0,1 enable. */ 34 ctrl_outw(0xa000, INTC_ICR1); /* IRQ mode; IRQ0,1 enable. */
24 ctrl_outw(0x0000, PORT_PFCR); /* use F for IRQ[3:0] and SIU. */ 35 ctrl_outw(0x0000, PORT_PFCR); /* use F for IRQ[3:0] and SIU. */
25 36
26 /* PC_IRQ[0-3] -> IRQ0 (32) */ 37 make_ipr_irq(se7300_ipr_map, ARRAY_SIZE(se7300_ipr_map));
27 make_ipr_irq(IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, 0x0f - IRQ0_IRQ);
28 /* A_IRQ[0-3] -> IRQ1 (33) */
29 make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, 0x0f - IRQ1_IRQ);
30 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY);
31 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
32 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
33 make_ipr_irq(VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
34 38
35 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */ 39 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */
36} 40}
diff --git a/arch/sh/boards/se/73180/irq.c b/arch/sh/boards/se/73180/irq.c
index 2c62b8ea350e..e7200c56bb45 100644
--- a/arch/sh/boards/se/73180/irq.c
+++ b/arch/sh/boards/se/73180/irq.c
@@ -87,13 +87,38 @@ shmse_irq_demux(int irq)
87 return irq; 87 return irq;
88} 88}
89 89
90static struct ipr_data se73180_siof0_ipr_map[] = {
91 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
92};
93static struct ipr_data se73180_vpu_ipr_map[] = {
94 { VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8 },
95};
96static struct ipr_data se73180_other_ipr_map[] = {
97 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
98 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
99 { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
100 { IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
101 { IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
102 { IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
103 { IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
104 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
105 { SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY },
106
107 /* VIO interrupt */
108 { CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
109 { BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
110 { VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
111
112 { LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY },
113};
114
90/* 115/*
91 * Initialize IRQ setting 116 * Initialize IRQ setting
92 */ 117 */
93void __init 118void __init
94init_73180se_IRQ(void) 119init_73180se_IRQ(void)
95{ 120{
96 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY); 121 make_ipr_irq(se73180_siof0_ipr_map, ARRAY_SIZE(se73180_siof0_ipr_map));
97 122
98 ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */ 123 ctrl_outw(0x2000, 0xb03fffec); /* mrshpc irq enable */
99 ctrl_outw(0x2000, 0xb07fffec); /* mrshpc irq enable */ 124 ctrl_outw(0x2000, 0xb07fffec); /* mrshpc irq enable */
@@ -101,27 +126,11 @@ init_73180se_IRQ(void)
101 ctrl_outw(2 << ((7 - 5) * 2), INTC_ICR1); /* low-level irq */ 126 ctrl_outw(2 << ((7 - 5) * 2), INTC_ICR1); /* low-level irq */
102 make_intreq_irq(10); 127 make_intreq_irq(10);
103 128
104 make_ipr_irq(VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8); 129 make_ipr_irq(se73180_vpu_ipr_map, ARRAY_SIZE(se73180_vpu_ipr_map));
105 130
106 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */ 131 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */
107 132
108 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY); 133 make_ipr_irq(se73180_other_ipr_map, ARRAY_SIZE(se73180_other_ipr_map));
109 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
110 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
111 make_ipr_irq(IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
112 make_ipr_irq(IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
113 IIC0_PRIORITY);
114 make_ipr_irq(IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
115 IIC0_PRIORITY);
116 make_ipr_irq(IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
117 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY);
118 make_ipr_irq(SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY);
119
120 /* VIO interrupt */
121 make_ipr_irq(CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
122 make_ipr_irq(BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
123 make_ipr_irq(VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
124 134
125 make_ipr_irq(LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY);
126 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */ 135 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */
127} 136}
diff --git a/arch/sh/boards/se/7343/irq.c b/arch/sh/boards/se/7343/irq.c
index 288b62f59419..360153ecc55b 100644
--- a/arch/sh/boards/se/7343/irq.c
+++ b/arch/sh/boards/se/7343/irq.c
@@ -102,6 +102,51 @@ shmse_irq_demux(int irq)
102static struct irqaction irq5 = { no_action, 0, CPU_MASK_NONE, "IRQ5-cascade", 102static struct irqaction irq5 = { no_action, 0, CPU_MASK_NONE, "IRQ5-cascade",
103 NULL, NULL}; 103 NULL, NULL};
104 104
105static struct ipr_data se7343_irq5_ipr_map[] = {
106 { IRQ5_IRQ, IRQ5_IPR_ADDR+2, IRQ5_IPR_POS, IRQ5_PRIORITY },
107};
108static struct ipr_data se7343_siof0_vpu_ipr_map[] = {
109 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
110 { VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8 },
111};
112static struct ipr_data se7343_other_ipr_map[] = {
113 { DMTE0_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
114 { DMTE1_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
115 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
116 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
117 { DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
118 { DMTE5_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY },
119
120 /* I2C block */
121 { IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
122 { IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
123 { IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
124 { IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY },
125
126 { IIC1_ALI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
127 { IIC1_TACKI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
128 { IIC1_WAITI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
129 { IIC1_DTEI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY },
130
131 /* SIOF */
132 { SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY },
133
134 /* SIU */
135 { SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY },
136
137 /* VIO interrupt */
138 { CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
139 { BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
140 { VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
141
142 /*MFI interrupt*/
143
144 { MFI_IRQ, MFI_IPR_ADDR, MFI_IPR_POS, MFI_PRIORITY },
145
146 /* LCD controller */
147 { LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY },
148};
149
105/* 150/*
106 * Initialize IRQ setting 151 * Initialize IRQ setting
107 */ 152 */
@@ -138,54 +183,17 @@ init_7343se_IRQ(void)
138 /* Setup all external interrupts to be active low */ 183 /* Setup all external interrupts to be active low */
139 ctrl_outw(0xaaaa, INTC_ICR1); 184 ctrl_outw(0xaaaa, INTC_ICR1);
140 185
141 make_ipr_irq(IRQ5_IRQ, IRQ5_IPR_ADDR+2, IRQ5_IPR_POS, IRQ5_PRIORITY); 186 make_ipr_irq(se7343_irq5_ipr_map, ARRAY_SIZE(se7343_irq5_ipr_map));
187
142 setup_irq(IRQ5_IRQ, &irq5); 188 setup_irq(IRQ5_IRQ, &irq5);
143 /* Set port control to use IRQ5 */ 189 /* Set port control to use IRQ5 */
144 *(u16 *)0xA4050108 &= ~0xc; 190 *(u16 *)0xA4050108 &= ~0xc;
145 191
146 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY); 192 make_ipr_irq(se7343_siof0_vpu_ipr_map, ARRAY_SIZE(se7343_siof0_vpu_ipr_map));
147 make_ipr_irq(VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8);
148 193
149 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */ 194 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */
150 195
151 make_ipr_irq(DMTE0_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY); 196 make_ipr_irq(se7343_other_ipr_map, ARRAY_SIZE(se7343_other_ipr_map));
152 make_ipr_irq(DMTE1_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
153 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
154 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
155 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
156 make_ipr_irq(DMTE5_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
157
158 /* I2C block */
159 make_ipr_irq(IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
160 make_ipr_irq(IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
161 IIC0_PRIORITY);
162 make_ipr_irq(IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
163 IIC0_PRIORITY);
164 make_ipr_irq(IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
165
166 make_ipr_irq(IIC1_ALI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY);
167 make_ipr_irq(IIC1_TACKI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS,
168 IIC1_PRIORITY);
169 make_ipr_irq(IIC1_WAITI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS,
170 IIC1_PRIORITY);
171 make_ipr_irq(IIC1_DTEI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY);
172
173 /* SIOF */
174 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY);
175 197
176 /* SIU */
177 make_ipr_irq(SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY);
178
179 /* VIO interrupt */
180 make_ipr_irq(CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
181 make_ipr_irq(BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
182 make_ipr_irq(VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
183
184 /*MFI interrupt*/
185
186 make_ipr_irq(MFI_IRQ, MFI_IPR_ADDR, MFI_IPR_POS, MFI_PRIORITY);
187
188 /* LCD controller */
189 make_ipr_irq(LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY);
190 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */ 198 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */
191} 199}
diff --git a/arch/sh/boards/se/770x/irq.c b/arch/sh/boards/se/770x/irq.c
index cff6700bbafd..fcd7cd7fa05f 100644
--- a/arch/sh/boards/se/770x/irq.c
+++ b/arch/sh/boards/se/770x/irq.c
@@ -13,6 +13,48 @@
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/se.h> 14#include <asm/se.h>
15 15
16static struct ipr_data se770x_ipr_map[] = {
17#if defined(CONFIG_CPU_SUBTYPE_SH7705)
18 /* This is default value */
19 { 0xf-0x2, BCR_ILCRA, 2, 0x2 },
20 { 0xf-0xa, BCR_ILCRA, 1, 0xa },
21 { 0xf-0x5, BCR_ILCRB, 0, 0x5 },
22 { 0xf-0x8, BCR_ILCRC, 1, 0x8 },
23 { 0xf-0xc, BCR_ILCRC, 0, 0xc },
24 { 0xf-0xe, BCR_ILCRD, 3, 0xe },
25 { 0xf-0x3, BCR_ILCRD, 1, 0x3 }, /* LAN */
26 { 0xf-0xd, BCR_ILCRE, 2, 0xd },
27 { 0xf-0x9, BCR_ILCRE, 1, 0x9 },
28 { 0xf-0x1, BCR_ILCRE, 0, 0x1 },
29 { 0xf-0xf, BCR_ILCRF, 3, 0xf },
30 { 0xf-0xb, BCR_ILCRF, 1, 0xb },
31 { 0xf-0x7, BCR_ILCRG, 3, 0x7 },
32 { 0xf-0x6, BCR_ILCRG, 2, 0x6 },
33 { 0xf-0x4, BCR_ILCRG, 1, 0x4 },
34#else
35 { 14, BCR_ILCRA, 2, 0x0f-14 },
36 { 12, BCR_ILCRA, 1, 0x0f-12 },
37 { 8, BCR_ILCRB, 1, 0x0f- 8 },
38 { 6, BCR_ILCRC, 3, 0x0f- 6 },
39 { 5, BCR_ILCRC, 2, 0x0f- 5 },
40 { 4, BCR_ILCRC, 1, 0x0f- 4 },
41 { 3, BCR_ILCRC, 0, 0x0f- 3 },
42 { 1, BCR_ILCRD, 3, 0x0f- 1 },
43
44 { 10, BCR_ILCRD, 1, 0x0f-10 }, /* LAN */
45
46 { 0, BCR_ILCRE, 3, 0x0f- 0 }, /* PCIRQ3 */
47 { 11, BCR_ILCRE, 2, 0x0f-11 }, /* PCIRQ2 */
48 { 9, BCR_ILCRE, 1, 0x0f- 9 }, /* PCIRQ1 */
49 { 7, BCR_ILCRE, 0, 0x0f- 7 }, /* PCIRQ0 */
50
51 /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */
52 /* NOTE: #2 and #13 are not used on PC */
53 { 13, BCR_ILCRG, 1, 0x0f-13 }, /* SLOTIRQ2 */
54 { 2, BCR_ILCRG, 0, 0x0f- 2 }, /* SLOTIRQ1 */
55#endif
56};
57
16/* 58/*
17 * Initialize IRQ setting 59 * Initialize IRQ setting
18 */ 60 */
@@ -38,42 +80,6 @@ void __init init_se_IRQ(void)
38 ctrl_outw(0, BCR_ILCRE); 80 ctrl_outw(0, BCR_ILCRE);
39 ctrl_outw(0, BCR_ILCRF); 81 ctrl_outw(0, BCR_ILCRF);
40 ctrl_outw(0, BCR_ILCRG); 82 ctrl_outw(0, BCR_ILCRG);
41 /* This is default value */
42 make_ipr_irq(0xf-0x2, BCR_ILCRA, 2, 0x2);
43 make_ipr_irq(0xf-0xa, BCR_ILCRA, 1, 0xa);
44 make_ipr_irq(0xf-0x5, BCR_ILCRB, 0, 0x5);
45 make_ipr_irq(0xf-0x8, BCR_ILCRC, 1, 0x8);
46 make_ipr_irq(0xf-0xc, BCR_ILCRC, 0, 0xc);
47 make_ipr_irq(0xf-0xe, BCR_ILCRD, 3, 0xe);
48 make_ipr_irq(0xf-0x3, BCR_ILCRD, 1, 0x3); /* LAN */
49 make_ipr_irq(0xf-0xd, BCR_ILCRE, 2, 0xd);
50 make_ipr_irq(0xf-0x9, BCR_ILCRE, 1, 0x9);
51 make_ipr_irq(0xf-0x1, BCR_ILCRE, 0, 0x1);
52 make_ipr_irq(0xf-0xf, BCR_ILCRF, 3, 0xf);
53 make_ipr_irq(0xf-0xb, BCR_ILCRF, 1, 0xb);
54 make_ipr_irq(0xf-0x7, BCR_ILCRG, 3, 0x7);
55 make_ipr_irq(0xf-0x6, BCR_ILCRG, 2, 0x6);
56 make_ipr_irq(0xf-0x4, BCR_ILCRG, 1, 0x4);
57#else
58 make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-14);
59 make_ipr_irq(12, BCR_ILCRA, 1, 0x0f-12);
60 make_ipr_irq( 8, BCR_ILCRB, 1, 0x0f- 8);
61 make_ipr_irq( 6, BCR_ILCRC, 3, 0x0f- 6);
62 make_ipr_irq( 5, BCR_ILCRC, 2, 0x0f- 5);
63 make_ipr_irq( 4, BCR_ILCRC, 1, 0x0f- 4);
64 make_ipr_irq( 3, BCR_ILCRC, 0, 0x0f- 3);
65 make_ipr_irq( 1, BCR_ILCRD, 3, 0x0f- 1);
66
67 make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); /* LAN */
68
69 make_ipr_irq( 0, BCR_ILCRE, 3, 0x0f- 0); /* PCIRQ3 */
70 make_ipr_irq(11, BCR_ILCRE, 2, 0x0f-11); /* PCIRQ2 */
71 make_ipr_irq( 9, BCR_ILCRE, 1, 0x0f- 9); /* PCIRQ1 */
72 make_ipr_irq( 7, BCR_ILCRE, 0, 0x0f- 7); /* PCIRQ0 */
73
74 /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */
75 /* NOTE: #2 and #13 are not used on PC */
76 make_ipr_irq(13, BCR_ILCRG, 1, 0x0f-13); /* SLOTIRQ2 */
77 make_ipr_irq( 2, BCR_ILCRG, 0, 0x0f- 2); /* SLOTIRQ1 */
78#endif 83#endif
84 make_ipr_irq(se770x_ipr_map, ARRAY_SIZE(se770x_ipr_map));
79} 85}
diff --git a/arch/sh/boards/se/7751/irq.c b/arch/sh/boards/se/7751/irq.c
index c607b0a48479..e4c63a48296c 100644
--- a/arch/sh/boards/se/7751/irq.c
+++ b/arch/sh/boards/se/7751/irq.c
@@ -14,53 +14,50 @@
14#include <asm/irq.h> 14#include <asm/irq.h>
15#include <asm/se7751.h> 15#include <asm/se7751.h>
16 16
17/* 17static struct ipr_data se7751_ipr_map[] = {
18 * Initialize IRQ setting
19 */
20void __init init_7751se_IRQ(void)
21{
22
23 /* Leave old Solution Engine code in for reference. */ 18 /* Leave old Solution Engine code in for reference. */
24#if defined(CONFIG_SH_SOLUTION_ENGINE) 19#if defined(CONFIG_SH_SOLUTION_ENGINE)
25 /* 20 /*
26 * Super I/O (Just mimic PC): 21 * Super I/O (Just mimic PC):
27 * 1: keyboard 22 * 1: keyboard
28 * 3: serial 0 23 * 3: serial 0
29 * 4: serial 1 24 * 4: serial 1
30 * 5: printer 25 * 5: printer
31 * 6: floppy 26 * 6: floppy
32 * 8: rtc 27 * 8: rtc
33 * 12: mouse 28 * 12: mouse
34 * 14: ide0 29 * 14: ide0
35 */ 30 */
36 make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-14); 31 { 14, BCR_ILCRA, 2, 0x0f-14 },
37 make_ipr_irq(12, BCR_ILCRA, 1, 0x0f-12); 32 { 12, BCR_ILCRA, 1, 0x0f-12 },
38 make_ipr_irq( 8, BCR_ILCRB, 1, 0x0f- 8); 33 { 8, BCR_ILCRB, 1, 0x0f- 8 },
39 make_ipr_irq( 6, BCR_ILCRC, 3, 0x0f- 6); 34 { 6, BCR_ILCRC, 3, 0x0f- 6 },
40 make_ipr_irq( 5, BCR_ILCRC, 2, 0x0f- 5); 35 { 5, BCR_ILCRC, 2, 0x0f- 5 },
41 make_ipr_irq( 4, BCR_ILCRC, 1, 0x0f- 4); 36 { 4, BCR_ILCRC, 1, 0x0f- 4 },
42 make_ipr_irq( 3, BCR_ILCRC, 0, 0x0f- 3); 37 { 3, BCR_ILCRC, 0, 0x0f- 3 },
43 make_ipr_irq( 1, BCR_ILCRD, 3, 0x0f- 1); 38 { 1, BCR_ILCRD, 3, 0x0f- 1 },
44 39
45 make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); /* LAN */ 40 { 10, BCR_ILCRD, 1, 0x0f-10 }, /* LAN */
46 41
47 make_ipr_irq( 0, BCR_ILCRE, 3, 0x0f- 0); /* PCIRQ3 */ 42 { 0, BCR_ILCRE, 3, 0x0f- 0 }, /* PCIRQ3 */
48 make_ipr_irq(11, BCR_ILCRE, 2, 0x0f-11); /* PCIRQ2 */ 43 { 11, BCR_ILCRE, 2, 0x0f-11 }, /* PCIRQ2 */
49 make_ipr_irq( 9, BCR_ILCRE, 1, 0x0f- 9); /* PCIRQ1 */ 44 { 9, BCR_ILCRE, 1, 0x0f- 9 }, /* PCIRQ1 */
50 make_ipr_irq( 7, BCR_ILCRE, 0, 0x0f- 7); /* PCIRQ0 */ 45 { 7, BCR_ILCRE, 0, 0x0f- 7 }, /* PCIRQ0 */
51 46
52 /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */ 47 /* #2, #13 are allocated for SLOT IRQ #1 and #2 (for now) */
53 /* NOTE: #2 and #13 are not used on PC */ 48 /* NOTE: #2 and #13 are not used on PC */
54 make_ipr_irq(13, BCR_ILCRG, 1, 0x0f-13); /* SLOTIRQ2 */ 49 { 13, BCR_ILCRG, 1, 0x0f-13 }, /* SLOTIRQ2 */
55 make_ipr_irq( 2, BCR_ILCRG, 0, 0x0f- 2); /* SLOTIRQ1 */ 50 { 2, BCR_ILCRG, 0, 0x0f- 2 }, /* SLOTIRQ1 */
56
57#elif defined(CONFIG_SH_7751_SOLUTION_ENGINE) 51#elif defined(CONFIG_SH_7751_SOLUTION_ENGINE)
58 52 { 13, BCR_ILCRD, 3, 2 },
59 make_ipr_irq(13, BCR_ILCRD, 3, 2); 53 /* Add additional entries here as drivers are added and tested. */
60
61 /* Add additional calls to make_ipr_irq() as drivers are added
62 * and tested.
63 */
64#endif 54#endif
55};
65 56
57/*
58 * Initialize IRQ setting
59 */
60void __init init_7751se_IRQ(void)
61{
62 make_ipr_irq(se7751_ipr_map, ARRAY_SIZE(se7751_ipr_map));
66} 63}
diff --git a/arch/sh/boards/sh03/setup.c b/arch/sh/boards/sh03/setup.c
index 137e2ba9243e..5ad1e19771be 100644
--- a/arch/sh/boards/sh03/setup.c
+++ b/arch/sh/boards/sh03/setup.c
@@ -14,14 +14,17 @@
14#include <asm/sh03/sh03.h> 14#include <asm/sh03/sh03.h>
15#include <asm/addrspace.h> 15#include <asm/addrspace.h>
16 16
17static struct ipr_data sh03_ipr_map[] = {
18 { IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY },
19 { IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY },
20 { IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY },
21 { IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY },
22};
23
17static void __init init_sh03_IRQ(void) 24static void __init init_sh03_IRQ(void)
18{ 25{
19 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR); 26 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
20 27 make_ipr_irq(sh03_ipr_map, ARRAY_SIZE(sh03_ipr_map));
21 make_ipr_irq(IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY);
22 make_ipr_irq(IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY);
23 make_ipr_irq(IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY);
24 make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY);
25} 28}
26 29
27extern void *cf_io_base; 30extern void *cf_io_base;
diff --git a/arch/sh/boards/snapgear/setup.c b/arch/sh/boards/snapgear/setup.c
index 540d0bf16446..650fb3645947 100644
--- a/arch/sh/boards/snapgear/setup.c
+++ b/arch/sh/boards/snapgear/setup.c
@@ -68,6 +68,13 @@ module_init(eraseconfig_init);
68 * IRL3 = crypto 68 * IRL3 = crypto
69 */ 69 */
70 70
71static struct ipr_data snapgear_ipr_map[] = {
72 make_ipr_irq(IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY);
73 make_ipr_irq(IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY);
74 make_ipr_irq(IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY);
75 make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY);
76};
77
71static void __init init_snapgear_IRQ(void) 78static void __init init_snapgear_IRQ(void)
72{ 79{
73 /* enable individual interrupt mode for externals */ 80 /* enable individual interrupt mode for externals */
@@ -75,10 +82,7 @@ static void __init init_snapgear_IRQ(void)
75 82
76 printk("Setup SnapGear IRQ/IPR ...\n"); 83 printk("Setup SnapGear IRQ/IPR ...\n");
77 84
78 make_ipr_irq(IRL0_IRQ, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY); 85 make_ipr_irq(snapgear_ipr_map, ARRAY_SIZE(snapgear_ipr_map));
79 make_ipr_irq(IRL1_IRQ, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY);
80 make_ipr_irq(IRL2_IRQ, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY);
81 make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY);
82} 86}
83 87
84/* 88/*
diff --git a/arch/sh/boards/titan/setup.c b/arch/sh/boards/titan/setup.c
index 52b66d8b8d2a..a6046d93758b 100644
--- a/arch/sh/boards/titan/setup.c
+++ b/arch/sh/boards/titan/setup.c
@@ -9,15 +9,19 @@
9 9
10extern void __init pcibios_init_platform(void); 10extern void __init pcibios_init_platform(void);
11 11
12static struct ipr_data titan_ipr_map[] = {
13 { TITAN_IRQ_WAN, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY },
14 { TITAN_IRQ_LAN, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY },
15 { TITAN_IRQ_MPCIA, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY },
16 { TITAN_IRQ_USB, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY },
17};
18
12static void __init init_titan_irq(void) 19static void __init init_titan_irq(void)
13{ 20{
14 /* enable individual interrupt mode for externals */ 21 /* enable individual interrupt mode for externals */
15 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR); 22 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
16 23
17 make_ipr_irq( TITAN_IRQ_WAN, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY); /* PCIRQ0 */ 24 make_ipr_irq(titan_ipr_map, ARRAY_SIZE(titan_ipr_map));
18 make_ipr_irq( TITAN_IRQ_LAN, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY); /* PCIRQ1 */
19 make_ipr_irq( TITAN_IRQ_MPCIA, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY); /* PCIRQ2 */
20 make_ipr_irq( TITAN_IRQ_USB, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY); /* PCIRQ3 */
21} 25}
22 26
23struct sh_machine_vector mv_titan __initmv = { 27struct sh_machine_vector mv_titan __initmv = {
diff --git a/arch/sh/configs/r7780rp_defconfig b/arch/sh/configs/r7780rp_defconfig
index 2470364948e7..34e2046c3213 100644
--- a/arch/sh/configs/r7780rp_defconfig
+++ b/arch/sh/configs/r7780rp_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18 3# Linux kernel version: 2.6.19-rc3
4# Tue Oct 3 11:32:47 2006 4# Tue Oct 31 12:32:06 2006
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 7CONFIG_RWSEM_GENERIC_SPINLOCK=y
@@ -10,6 +10,7 @@ CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y 10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y 11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 12CONFIG_GENERIC_CALIBRATE_DELAY=y
13# CONFIG_GENERIC_TIME is not set
13CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 14CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
14 15
15# 16#
@@ -178,7 +179,7 @@ CONFIG_MMU=y
178CONFIG_PAGE_OFFSET=0x80000000 179CONFIG_PAGE_OFFSET=0x80000000
179CONFIG_MEMORY_START=0x08000000 180CONFIG_MEMORY_START=0x08000000
180CONFIG_MEMORY_SIZE=0x08000000 181CONFIG_MEMORY_SIZE=0x08000000
181CONFIG_32BIT=y 182# CONFIG_32BIT is not set
182CONFIG_VSYSCALL=y 183CONFIG_VSYSCALL=y
183CONFIG_HUGETLB_PAGE_SIZE_64K=y 184CONFIG_HUGETLB_PAGE_SIZE_64K=y
184# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set 185# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
@@ -229,9 +230,7 @@ CONFIG_SH_PCLK_FREQ=32000000
229# 230#
230# DMA support 231# DMA support
231# 232#
232CONFIG_SH_DMA=y 233# CONFIG_SH_DMA is not set
233CONFIG_NR_ONCHIP_DMA_CHANNELS=6
234# CONFIG_NR_DMA_CHANNELS_BOOL is not set
235 234
236# 235#
237# Companion Chips 236# Companion Chips
@@ -259,7 +258,7 @@ CONFIG_ZERO_PAGE_OFFSET=0x00001000
259CONFIG_BOOT_LINK_OFFSET=0x00800000 258CONFIG_BOOT_LINK_OFFSET=0x00800000
260# CONFIG_UBC_WAKEUP is not set 259# CONFIG_UBC_WAKEUP is not set
261CONFIG_CMDLINE_BOOL=y 260CONFIG_CMDLINE_BOOL=y
262CONFIG_CMDLINE="mem=128M console=ttySC0,115200 root=/dev/hda1" 261CONFIG_CMDLINE="mem=128M console=ttySC0,115200 root=/dev/sda1"
263 262
264# 263#
265# Bus options 264# Bus options
@@ -336,6 +335,7 @@ CONFIG_IP_PNP_DHCP=y
336# CONFIG_INET_TUNNEL is not set 335# CONFIG_INET_TUNNEL is not set
337CONFIG_INET_XFRM_MODE_TRANSPORT=y 336CONFIG_INET_XFRM_MODE_TRANSPORT=y
338CONFIG_INET_XFRM_MODE_TUNNEL=y 337CONFIG_INET_XFRM_MODE_TUNNEL=y
338CONFIG_INET_XFRM_MODE_BEET=y
339CONFIG_INET_DIAG=y 339CONFIG_INET_DIAG=y
340CONFIG_INET_TCP_DIAG=y 340CONFIG_INET_TCP_DIAG=y
341# CONFIG_TCP_CONG_ADVANCED is not set 341# CONFIG_TCP_CONG_ADVANCED is not set
@@ -441,76 +441,28 @@ CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
441# CONFIG_ATA_OVER_ETH is not set 441# CONFIG_ATA_OVER_ETH is not set
442 442
443# 443#
444# Misc devices
445#
446# CONFIG_SGI_IOC4 is not set
447# CONFIG_TIFM_CORE is not set
448
449#
444# ATA/ATAPI/MFM/RLL support 450# ATA/ATAPI/MFM/RLL support
445# 451#
446CONFIG_IDE=m 452# CONFIG_IDE is not set
447CONFIG_IDE_MAX_HWIFS=4
448CONFIG_BLK_DEV_IDE=m
449
450#
451# Please see Documentation/ide.txt for help/info on IDE drives
452#
453CONFIG_BLK_DEV_IDE_SATA=y
454CONFIG_BLK_DEV_IDEDISK=m
455CONFIG_IDEDISK_MULTI_MODE=y
456# CONFIG_BLK_DEV_IDECD is not set
457# CONFIG_BLK_DEV_IDETAPE is not set
458# CONFIG_BLK_DEV_IDEFLOPPY is not set
459CONFIG_BLK_DEV_IDESCSI=m
460# CONFIG_IDE_TASK_IOCTL is not set
461
462#
463# IDE chipset support/bugfixes
464#
465CONFIG_IDE_GENERIC=m
466CONFIG_BLK_DEV_IDEPCI=y
467CONFIG_IDEPCI_SHARE_IRQ=y
468# CONFIG_BLK_DEV_OFFBOARD is not set
469CONFIG_BLK_DEV_GENERIC=m
470# CONFIG_BLK_DEV_OPTI621 is not set
471CONFIG_BLK_DEV_IDEDMA_PCI=y
472# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
473CONFIG_IDEDMA_PCI_AUTO=y
474# CONFIG_IDEDMA_ONLYDISK is not set
475CONFIG_BLK_DEV_AEC62XX=m
476# CONFIG_BLK_DEV_ALI15X3 is not set
477# CONFIG_BLK_DEV_AMD74XX is not set
478# CONFIG_BLK_DEV_CMD64X is not set
479# CONFIG_BLK_DEV_TRIFLEX is not set
480# CONFIG_BLK_DEV_CY82C693 is not set
481# CONFIG_BLK_DEV_CS5520 is not set
482# CONFIG_BLK_DEV_CS5530 is not set
483# CONFIG_BLK_DEV_HPT34X is not set
484# CONFIG_BLK_DEV_HPT366 is not set
485# CONFIG_BLK_DEV_SC1200 is not set
486# CONFIG_BLK_DEV_PIIX is not set
487# CONFIG_BLK_DEV_IT821X is not set
488# CONFIG_BLK_DEV_NS87415 is not set
489# CONFIG_BLK_DEV_PDC202XX_OLD is not set
490CONFIG_BLK_DEV_PDC202XX_NEW=m
491# CONFIG_BLK_DEV_SVWKS is not set
492CONFIG_BLK_DEV_SIIMAGE=m
493# CONFIG_BLK_DEV_SLC90E66 is not set
494# CONFIG_BLK_DEV_TRM290 is not set
495# CONFIG_BLK_DEV_VIA82CXXX is not set
496# CONFIG_IDE_ARM is not set
497CONFIG_BLK_DEV_IDEDMA=y
498# CONFIG_IDEDMA_IVB is not set
499CONFIG_IDEDMA_AUTO=y
500# CONFIG_BLK_DEV_HD is not set
501 453
502# 454#
503# SCSI device support 455# SCSI device support
504# 456#
505# CONFIG_RAID_ATTRS is not set 457# CONFIG_RAID_ATTRS is not set
506CONFIG_SCSI=m 458CONFIG_SCSI=y
507# CONFIG_SCSI_NETLINK is not set 459# CONFIG_SCSI_NETLINK is not set
508CONFIG_SCSI_PROC_FS=y 460CONFIG_SCSI_PROC_FS=y
509 461
510# 462#
511# SCSI support type (disk, tape, CD-ROM) 463# SCSI support type (disk, tape, CD-ROM)
512# 464#
513CONFIG_BLK_DEV_SD=m 465CONFIG_BLK_DEV_SD=y
514# CONFIG_CHR_DEV_ST is not set 466# CONFIG_CHR_DEV_ST is not set
515# CONFIG_CHR_DEV_OSST is not set 467# CONFIG_CHR_DEV_OSST is not set
516# CONFIG_BLK_DEV_SR is not set 468# CONFIG_BLK_DEV_SR is not set
@@ -561,6 +513,7 @@ CONFIG_CHR_DEV_SG=m
561# CONFIG_SCSI_IPR is not set 513# CONFIG_SCSI_IPR is not set
562# CONFIG_SCSI_QLOGIC_1280 is not set 514# CONFIG_SCSI_QLOGIC_1280 is not set
563# CONFIG_SCSI_QLA_FC is not set 515# CONFIG_SCSI_QLA_FC is not set
516# CONFIG_SCSI_QLA_ISCSI is not set
564# CONFIG_SCSI_LPFC is not set 517# CONFIG_SCSI_LPFC is not set
565# CONFIG_SCSI_DC395x is not set 518# CONFIG_SCSI_DC395x is not set
566# CONFIG_SCSI_DC390T is not set 519# CONFIG_SCSI_DC390T is not set
@@ -570,7 +523,55 @@ CONFIG_CHR_DEV_SG=m
570# 523#
571# Serial ATA (prod) and Parallel ATA (experimental) drivers 524# Serial ATA (prod) and Parallel ATA (experimental) drivers
572# 525#
573# CONFIG_ATA is not set 526CONFIG_ATA=y
527# CONFIG_SATA_AHCI is not set
528# CONFIG_SATA_SVW is not set
529# CONFIG_ATA_PIIX is not set
530# CONFIG_SATA_MV is not set
531# CONFIG_SATA_NV is not set
532# CONFIG_PDC_ADMA is not set
533# CONFIG_SATA_QSTOR is not set
534# CONFIG_SATA_PROMISE is not set
535# CONFIG_SATA_SX4 is not set
536CONFIG_SATA_SIL=y
537# CONFIG_SATA_SIL24 is not set
538# CONFIG_SATA_SIS is not set
539# CONFIG_SATA_ULI is not set
540# CONFIG_SATA_VIA is not set
541# CONFIG_SATA_VITESSE is not set
542# CONFIG_PATA_ALI is not set
543# CONFIG_PATA_AMD is not set
544# CONFIG_PATA_ARTOP is not set
545# CONFIG_PATA_ATIIXP is not set
546# CONFIG_PATA_CMD64X is not set
547# CONFIG_PATA_CS5520 is not set
548# CONFIG_PATA_CS5530 is not set
549# CONFIG_PATA_CYPRESS is not set
550# CONFIG_PATA_EFAR is not set
551# CONFIG_ATA_GENERIC is not set
552# CONFIG_PATA_HPT366 is not set
553# CONFIG_PATA_HPT37X is not set
554# CONFIG_PATA_HPT3X2N is not set
555# CONFIG_PATA_HPT3X3 is not set
556# CONFIG_PATA_IT821X is not set
557# CONFIG_PATA_JMICRON is not set
558# CONFIG_PATA_TRIFLEX is not set
559# CONFIG_PATA_MPIIX is not set
560# CONFIG_PATA_OLDPIIX is not set
561# CONFIG_PATA_NETCELL is not set
562# CONFIG_PATA_NS87410 is not set
563# CONFIG_PATA_OPTI is not set
564# CONFIG_PATA_OPTIDMA is not set
565# CONFIG_PATA_PDC_OLD is not set
566# CONFIG_PATA_RADISYS is not set
567# CONFIG_PATA_RZ1000 is not set
568# CONFIG_PATA_SC1200 is not set
569# CONFIG_PATA_SERVERWORKS is not set
570# CONFIG_PATA_PDC2027X is not set
571# CONFIG_PATA_SIL680 is not set
572# CONFIG_PATA_SIS is not set
573# CONFIG_PATA_VIA is not set
574# CONFIG_PATA_WINBOND is not set
574 575
575# 576#
576# Multi-device support (RAID and LVM) 577# Multi-device support (RAID and LVM)
@@ -840,7 +841,6 @@ CONFIG_HW_RANDOM=y
840# TPM devices 841# TPM devices
841# 842#
842# CONFIG_TCG_TPM is not set 843# CONFIG_TCG_TPM is not set
843# CONFIG_TELCLOCK is not set
844 844
845# 845#
846# I2C support 846# I2C support
@@ -856,6 +856,7 @@ CONFIG_HW_RANDOM=y
856# 856#
857# Dallas's 1-wire bus 857# Dallas's 1-wire bus
858# 858#
859# CONFIG_W1 is not set
859 860
860# 861#
861# Hardware Monitoring support 862# Hardware Monitoring support
@@ -868,14 +869,9 @@ CONFIG_HWMON=y
868# CONFIG_HWMON_DEBUG_CHIP is not set 869# CONFIG_HWMON_DEBUG_CHIP is not set
869 870
870# 871#
871# Misc devices
872#
873
874#
875# Multimedia devices 872# Multimedia devices
876# 873#
877# CONFIG_VIDEO_DEV is not set 874# CONFIG_VIDEO_DEV is not set
878CONFIG_VIDEO_V4L2=y
879 875
880# 876#
881# Digital Video Broadcasting Devices 877# Digital Video Broadcasting Devices
@@ -959,7 +955,29 @@ CONFIG_USB_ARCH_HAS_EHCI=y
959# 955#
960# Real Time Clock 956# Real Time Clock
961# 957#
962# CONFIG_RTC_CLASS is not set 958CONFIG_RTC_LIB=y
959CONFIG_RTC_CLASS=y
960CONFIG_RTC_HCTOSYS=y
961CONFIG_RTC_HCTOSYS_DEVICE="rtc0"
962# CONFIG_RTC_DEBUG is not set
963
964#
965# RTC interfaces
966#
967CONFIG_RTC_INTF_SYSFS=y
968CONFIG_RTC_INTF_PROC=y
969CONFIG_RTC_INTF_DEV=y
970# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
971
972#
973# RTC drivers
974#
975# CONFIG_RTC_DRV_DS1553 is not set
976# CONFIG_RTC_DRV_DS1742 is not set
977# CONFIG_RTC_DRV_M48T86 is not set
978CONFIG_RTC_DRV_SH=y
979# CONFIG_RTC_DRV_TEST is not set
980# CONFIG_RTC_DRV_V3020 is not set
963 981
964# 982#
965# DMA Engine support 983# DMA Engine support
@@ -984,6 +1002,7 @@ CONFIG_EXT3_FS=y
984CONFIG_EXT3_FS_XATTR=y 1002CONFIG_EXT3_FS_XATTR=y
985# CONFIG_EXT3_FS_POSIX_ACL is not set 1003# CONFIG_EXT3_FS_POSIX_ACL is not set
986# CONFIG_EXT3_FS_SECURITY is not set 1004# CONFIG_EXT3_FS_SECURITY is not set
1005# CONFIG_EXT4DEV_FS is not set
987CONFIG_JBD=y 1006CONFIG_JBD=y
988# CONFIG_JBD_DEBUG is not set 1007# CONFIG_JBD_DEBUG is not set
989CONFIG_FS_MBCACHE=y 1008CONFIG_FS_MBCACHE=y
@@ -991,6 +1010,7 @@ CONFIG_FS_MBCACHE=y
991# CONFIG_JFS_FS is not set 1010# CONFIG_JFS_FS is not set
992CONFIG_FS_POSIX_ACL=y 1011CONFIG_FS_POSIX_ACL=y
993# CONFIG_XFS_FS is not set 1012# CONFIG_XFS_FS is not set
1013# CONFIG_GFS2_FS is not set
994# CONFIG_OCFS2_FS is not set 1014# CONFIG_OCFS2_FS is not set
995CONFIG_MINIX_FS=y 1015CONFIG_MINIX_FS=y
996# CONFIG_ROMFS_FS is not set 1016# CONFIG_ROMFS_FS is not set
@@ -1027,7 +1047,8 @@ CONFIG_PROC_FS=y
1027CONFIG_PROC_KCORE=y 1047CONFIG_PROC_KCORE=y
1028CONFIG_PROC_SYSCTL=y 1048CONFIG_PROC_SYSCTL=y
1029CONFIG_SYSFS=y 1049CONFIG_SYSFS=y
1030# CONFIG_TMPFS is not set 1050CONFIG_TMPFS=y
1051# CONFIG_TMPFS_POSIX_ACL is not set
1031CONFIG_HUGETLBFS=y 1052CONFIG_HUGETLBFS=y
1032CONFIG_HUGETLB_PAGE=y 1053CONFIG_HUGETLB_PAGE=y
1033CONFIG_RAMFS=y 1054CONFIG_RAMFS=y
@@ -1159,6 +1180,7 @@ CONFIG_DEBUG_FS=y
1159# CONFIG_DEBUG_LIST is not set 1180# CONFIG_DEBUG_LIST is not set
1160CONFIG_FRAME_POINTER=y 1181CONFIG_FRAME_POINTER=y
1161CONFIG_FORCED_INLINING=y 1182CONFIG_FORCED_INLINING=y
1183# CONFIG_HEADERS_CHECK is not set
1162# CONFIG_RCU_TORTURE_TEST is not set 1184# CONFIG_RCU_TORTURE_TEST is not set
1163# CONFIG_SH_STANDARD_BIOS is not set 1185# CONFIG_SH_STANDARD_BIOS is not set
1164# CONFIG_EARLY_SCIF_CONSOLE is not set 1186# CONFIG_EARLY_SCIF_CONSOLE is not set
@@ -1178,9 +1200,9 @@ CONFIG_FORCED_INLINING=y
1178# 1200#
1179CONFIG_CRYPTO=y 1201CONFIG_CRYPTO=y
1180CONFIG_CRYPTO_ALGAPI=y 1202CONFIG_CRYPTO_ALGAPI=y
1181CONFIG_CRYPTO_BLKCIPHER=m 1203CONFIG_CRYPTO_BLKCIPHER=y
1182CONFIG_CRYPTO_HASH=y 1204CONFIG_CRYPTO_HASH=y
1183CONFIG_CRYPTO_MANAGER=m 1205CONFIG_CRYPTO_MANAGER=y
1184CONFIG_CRYPTO_HMAC=y 1206CONFIG_CRYPTO_HMAC=y
1185# CONFIG_CRYPTO_NULL is not set 1207# CONFIG_CRYPTO_NULL is not set
1186# CONFIG_CRYPTO_MD4 is not set 1208# CONFIG_CRYPTO_MD4 is not set
@@ -1191,7 +1213,7 @@ CONFIG_CRYPTO_MD5=y
1191# CONFIG_CRYPTO_WP512 is not set 1213# CONFIG_CRYPTO_WP512 is not set
1192# CONFIG_CRYPTO_TGR192 is not set 1214# CONFIG_CRYPTO_TGR192 is not set
1193CONFIG_CRYPTO_ECB=m 1215CONFIG_CRYPTO_ECB=m
1194CONFIG_CRYPTO_CBC=m 1216CONFIG_CRYPTO_CBC=y
1195CONFIG_CRYPTO_DES=y 1217CONFIG_CRYPTO_DES=y
1196# CONFIG_CRYPTO_BLOWFISH is not set 1218# CONFIG_CRYPTO_BLOWFISH is not set
1197# CONFIG_CRYPTO_TWOFISH is not set 1219# CONFIG_CRYPTO_TWOFISH is not set
diff --git a/arch/sh/configs/titan_defconfig b/arch/sh/configs/titan_defconfig
index 5e8175461138..41049cf14b79 100644
--- a/arch/sh/configs/titan_defconfig
+++ b/arch/sh/configs/titan_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18 3# Linux kernel version: 2.6.19-rc3
4# Tue Oct 3 12:59:14 2006 4# Mon Oct 30 18:04:49 2006
5# 5#
6CONFIG_SUPERH=y 6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y 7CONFIG_RWSEM_GENERIC_SPINLOCK=y
@@ -10,6 +10,7 @@ CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y 10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y 11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 12CONFIG_GENERIC_CALIBRATE_DELAY=y
13# CONFIG_GENERIC_TIME is not set
13CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 14CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
14 15
15# 16#
@@ -23,7 +24,7 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
23# General setup 24# General setup
24# 25#
25CONFIG_LOCALVERSION="" 26CONFIG_LOCALVERSION=""
26CONFIG_LOCALVERSION_AUTO=y 27# CONFIG_LOCALVERSION_AUTO is not set
27CONFIG_SWAP=y 28CONFIG_SWAP=y
28CONFIG_SYSVIPC=y 29CONFIG_SYSVIPC=y
29# CONFIG_IPC_NS is not set 30# CONFIG_IPC_NS is not set
@@ -236,8 +237,8 @@ CONFIG_HZ_250=y
236CONFIG_HZ=250 237CONFIG_HZ=250
237# CONFIG_KEXEC is not set 238# CONFIG_KEXEC is not set
238# CONFIG_SMP is not set 239# CONFIG_SMP is not set
239CONFIG_PREEMPT_NONE=y 240# CONFIG_PREEMPT_NONE is not set
240# CONFIG_PREEMPT_VOLUNTARY is not set 241CONFIG_PREEMPT_VOLUNTARY=y
241# CONFIG_PREEMPT is not set 242# CONFIG_PREEMPT is not set
242 243
243# 244#
@@ -247,7 +248,7 @@ CONFIG_ZERO_PAGE_OFFSET=0x00001000
247CONFIG_BOOT_LINK_OFFSET=0x009e0000 248CONFIG_BOOT_LINK_OFFSET=0x009e0000
248# CONFIG_UBC_WAKEUP is not set 249# CONFIG_UBC_WAKEUP is not set
249CONFIG_CMDLINE_BOOL=y 250CONFIG_CMDLINE_BOOL=y
250CONFIG_CMDLINE="console=ttySC1,38400N81 root=/dev/nfs ip=:::::eth1:autoconf" 251CONFIG_CMDLINE="console=ttySC1,38400N81 root=/dev/nfs ip=:::::eth1:autoconf rw"
251 252
252# 253#
253# Bus options 254# Bus options
@@ -334,6 +335,7 @@ CONFIG_INET_XFRM_TUNNEL=y
334CONFIG_INET_TUNNEL=y 335CONFIG_INET_TUNNEL=y
335CONFIG_INET_XFRM_MODE_TRANSPORT=y 336CONFIG_INET_XFRM_MODE_TRANSPORT=y
336CONFIG_INET_XFRM_MODE_TUNNEL=y 337CONFIG_INET_XFRM_MODE_TUNNEL=y
338CONFIG_INET_XFRM_MODE_BEET=y
337CONFIG_INET_DIAG=m 339CONFIG_INET_DIAG=m
338CONFIG_INET_TCP_DIAG=m 340CONFIG_INET_TCP_DIAG=m
339# CONFIG_TCP_CONG_ADVANCED is not set 341# CONFIG_TCP_CONG_ADVANCED is not set
@@ -355,9 +357,10 @@ CONFIG_INET6_XFRM_TUNNEL=y
355CONFIG_INET6_TUNNEL=y 357CONFIG_INET6_TUNNEL=y
356CONFIG_INET6_XFRM_MODE_TRANSPORT=y 358CONFIG_INET6_XFRM_MODE_TRANSPORT=y
357CONFIG_INET6_XFRM_MODE_TUNNEL=y 359CONFIG_INET6_XFRM_MODE_TUNNEL=y
360CONFIG_INET6_XFRM_MODE_BEET=y
358# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 361# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
362CONFIG_IPV6_SIT=m
359CONFIG_IPV6_TUNNEL=y 363CONFIG_IPV6_TUNNEL=y
360# CONFIG_IPV6_SUBTREES is not set
361# CONFIG_IPV6_MULTIPLE_TABLES is not set 364# CONFIG_IPV6_MULTIPLE_TABLES is not set
362# CONFIG_NETWORK_SECMARK is not set 365# CONFIG_NETWORK_SECMARK is not set
363CONFIG_NETFILTER=y 366CONFIG_NETFILTER=y
@@ -714,6 +717,12 @@ CONFIG_BLK_DEV_INITRD=y
714CONFIG_ATA_OVER_ETH=m 717CONFIG_ATA_OVER_ETH=m
715 718
716# 719#
720# Misc devices
721#
722# CONFIG_SGI_IOC4 is not set
723# CONFIG_TIFM_CORE is not set
724
725#
717# ATA/ATAPI/MFM/RLL support 726# ATA/ATAPI/MFM/RLL support
718# 727#
719# CONFIG_IDE is not set 728# CONFIG_IDE is not set
@@ -778,9 +787,9 @@ CONFIG_CHR_DEV_SG=m
778# CONFIG_SCSI_INIA100 is not set 787# CONFIG_SCSI_INIA100 is not set
779# CONFIG_SCSI_STEX is not set 788# CONFIG_SCSI_STEX is not set
780# CONFIG_SCSI_SYM53C8XX_2 is not set 789# CONFIG_SCSI_SYM53C8XX_2 is not set
781# CONFIG_SCSI_IPR is not set
782# CONFIG_SCSI_QLOGIC_1280 is not set 790# CONFIG_SCSI_QLOGIC_1280 is not set
783# CONFIG_SCSI_QLA_FC is not set 791# CONFIG_SCSI_QLA_FC is not set
792# CONFIG_SCSI_QLA_ISCSI is not set
784# CONFIG_SCSI_LPFC is not set 793# CONFIG_SCSI_LPFC is not set
785# CONFIG_SCSI_DC395x is not set 794# CONFIG_SCSI_DC395x is not set
786# CONFIG_SCSI_DC390T is not set 795# CONFIG_SCSI_DC390T is not set
@@ -1095,7 +1104,6 @@ CONFIG_HW_RANDOM=y
1095# TPM devices 1104# TPM devices
1096# 1105#
1097# CONFIG_TCG_TPM is not set 1106# CONFIG_TCG_TPM is not set
1098# CONFIG_TELCLOCK is not set
1099 1107
1100# 1108#
1101# I2C support 1109# I2C support
@@ -1124,14 +1132,9 @@ CONFIG_HWMON=y
1124# CONFIG_HWMON_DEBUG_CHIP is not set 1132# CONFIG_HWMON_DEBUG_CHIP is not set
1125 1133
1126# 1134#
1127# Misc devices
1128#
1129
1130#
1131# Multimedia devices 1135# Multimedia devices
1132# 1136#
1133# CONFIG_VIDEO_DEV is not set 1137# CONFIG_VIDEO_DEV is not set
1134CONFIG_VIDEO_V4L2=y
1135 1138
1136# 1139#
1137# Digital Video Broadcasting Devices 1140# Digital Video Broadcasting Devices
@@ -1177,9 +1180,9 @@ CONFIG_USB_DEVICEFS=y
1177# USB Host Controller Drivers 1180# USB Host Controller Drivers
1178# 1181#
1179CONFIG_USB_EHCI_HCD=y 1182CONFIG_USB_EHCI_HCD=y
1180# CONFIG_USB_EHCI_SPLIT_ISO is not set 1183CONFIG_USB_EHCI_SPLIT_ISO=y
1181# CONFIG_USB_EHCI_ROOT_HUB_TT is not set 1184CONFIG_USB_EHCI_ROOT_HUB_TT=y
1182# CONFIG_USB_EHCI_TT_NEWSCHED is not set 1185CONFIG_USB_EHCI_TT_NEWSCHED=y
1183# CONFIG_USB_ISP116X_HCD is not set 1186# CONFIG_USB_ISP116X_HCD is not set
1184CONFIG_USB_OHCI_HCD=y 1187CONFIG_USB_OHCI_HCD=y
1185# CONFIG_USB_OHCI_BIG_ENDIAN is not set 1188# CONFIG_USB_OHCI_BIG_ENDIAN is not set
@@ -1235,7 +1238,6 @@ CONFIG_USB_STORAGE=y
1235# CONFIG_USB_ATI_REMOTE2 is not set 1238# CONFIG_USB_ATI_REMOTE2 is not set
1236# CONFIG_USB_KEYSPAN_REMOTE is not set 1239# CONFIG_USB_KEYSPAN_REMOTE is not set
1237# CONFIG_USB_APPLETOUCH is not set 1240# CONFIG_USB_APPLETOUCH is not set
1238# CONFIG_USB_TRANCEVIBRATOR is not set
1239 1241
1240# 1242#
1241# USB Imaging devices 1243# USB Imaging devices
@@ -1246,11 +1248,20 @@ CONFIG_USB_STORAGE=y
1246# 1248#
1247# USB Network Adapters 1249# USB Network Adapters
1248# 1250#
1249# CONFIG_USB_CATC is not set 1251CONFIG_USB_CATC=m
1250# CONFIG_USB_KAWETH is not set 1252CONFIG_USB_KAWETH=m
1251# CONFIG_USB_PEGASUS is not set 1253CONFIG_USB_PEGASUS=m
1252# CONFIG_USB_RTL8150 is not set 1254CONFIG_USB_RTL8150=m
1253# CONFIG_USB_USBNET is not set 1255CONFIG_USB_USBNET=m
1256CONFIG_USB_NET_AX8817X=m
1257CONFIG_USB_NET_CDCETHER=m
1258# CONFIG_USB_NET_GL620A is not set
1259CONFIG_USB_NET_NET1080=m
1260CONFIG_USB_NET_PLUSB=m
1261# CONFIG_USB_NET_MCS7830 is not set
1262# CONFIG_USB_NET_RNDIS_HOST is not set
1263# CONFIG_USB_NET_CDC_SUBSET is not set
1264CONFIG_USB_NET_ZAURUS=m
1254CONFIG_USB_MON=y 1265CONFIG_USB_MON=y
1255 1266
1256# 1267#
@@ -1285,6 +1296,7 @@ CONFIG_USB_SERIAL_ARK3116=m
1285# CONFIG_USB_SERIAL_KLSI is not set 1296# CONFIG_USB_SERIAL_KLSI is not set
1286# CONFIG_USB_SERIAL_KOBIL_SCT is not set 1297# CONFIG_USB_SERIAL_KOBIL_SCT is not set
1287# CONFIG_USB_SERIAL_MCT_U232 is not set 1298# CONFIG_USB_SERIAL_MCT_U232 is not set
1299# CONFIG_USB_SERIAL_MOS7720 is not set
1288# CONFIG_USB_SERIAL_MOS7840 is not set 1300# CONFIG_USB_SERIAL_MOS7840 is not set
1289# CONFIG_USB_SERIAL_NAVMAN is not set 1301# CONFIG_USB_SERIAL_NAVMAN is not set
1290CONFIG_USB_SERIAL_PL2303=m 1302CONFIG_USB_SERIAL_PL2303=m
@@ -1316,6 +1328,7 @@ CONFIG_USB_SERIAL_PL2303=m
1316# CONFIG_USB_APPLEDISPLAY is not set 1328# CONFIG_USB_APPLEDISPLAY is not set
1317# CONFIG_USB_SISUSBVGA is not set 1329# CONFIG_USB_SISUSBVGA is not set
1318# CONFIG_USB_LD is not set 1330# CONFIG_USB_LD is not set
1331# CONFIG_USB_TRANCEVIBRATOR is not set
1319# CONFIG_USB_TEST is not set 1332# CONFIG_USB_TEST is not set
1320 1333
1321# 1334#
@@ -1357,7 +1370,26 @@ CONFIG_USB_SERIAL_PL2303=m
1357# 1370#
1358# Real Time Clock 1371# Real Time Clock
1359# 1372#
1360# CONFIG_RTC_CLASS is not set 1373CONFIG_RTC_LIB=m
1374CONFIG_RTC_CLASS=m
1375
1376#
1377# RTC interfaces
1378#
1379CONFIG_RTC_INTF_SYSFS=m
1380CONFIG_RTC_INTF_PROC=m
1381CONFIG_RTC_INTF_DEV=m
1382# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
1383
1384#
1385# RTC drivers
1386#
1387# CONFIG_RTC_DRV_DS1553 is not set
1388# CONFIG_RTC_DRV_DS1742 is not set
1389# CONFIG_RTC_DRV_M48T86 is not set
1390CONFIG_RTC_DRV_SH=m
1391# CONFIG_RTC_DRV_TEST is not set
1392# CONFIG_RTC_DRV_V3020 is not set
1361 1393
1362# 1394#
1363# DMA Engine support 1395# DMA Engine support
@@ -1380,8 +1412,12 @@ CONFIG_EXT2_FS=y
1380# CONFIG_EXT2_FS_XIP is not set 1412# CONFIG_EXT2_FS_XIP is not set
1381CONFIG_EXT3_FS=y 1413CONFIG_EXT3_FS=y
1382# CONFIG_EXT3_FS_XATTR is not set 1414# CONFIG_EXT3_FS_XATTR is not set
1415CONFIG_EXT4DEV_FS=m
1416# CONFIG_EXT4DEV_FS_XATTR is not set
1383CONFIG_JBD=y 1417CONFIG_JBD=y
1384# CONFIG_JBD_DEBUG is not set 1418# CONFIG_JBD_DEBUG is not set
1419CONFIG_JBD2=m
1420# CONFIG_JBD2_DEBUG is not set
1385CONFIG_REISERFS_FS=m 1421CONFIG_REISERFS_FS=m
1386# CONFIG_REISERFS_CHECK is not set 1422# CONFIG_REISERFS_CHECK is not set
1387# CONFIG_REISERFS_PROC_INFO is not set 1423# CONFIG_REISERFS_PROC_INFO is not set
@@ -1393,9 +1429,10 @@ CONFIG_XFS_FS=m
1393# CONFIG_XFS_SECURITY is not set 1429# CONFIG_XFS_SECURITY is not set
1394# CONFIG_XFS_POSIX_ACL is not set 1430# CONFIG_XFS_POSIX_ACL is not set
1395# CONFIG_XFS_RT is not set 1431# CONFIG_XFS_RT is not set
1432# CONFIG_GFS2_FS is not set
1396# CONFIG_OCFS2_FS is not set 1433# CONFIG_OCFS2_FS is not set
1397# CONFIG_MINIX_FS is not set 1434# CONFIG_MINIX_FS is not set
1398# CONFIG_ROMFS_FS is not set 1435CONFIG_ROMFS_FS=y
1399CONFIG_INOTIFY=y 1436CONFIG_INOTIFY=y
1400CONFIG_INOTIFY_USER=y 1437CONFIG_INOTIFY_USER=y
1401# CONFIG_QUOTA is not set 1438# CONFIG_QUOTA is not set
@@ -1480,7 +1517,12 @@ CONFIG_SUNRPC=y
1480# CONFIG_RPCSEC_GSS_SPKM3 is not set 1517# CONFIG_RPCSEC_GSS_SPKM3 is not set
1481CONFIG_SMB_FS=m 1518CONFIG_SMB_FS=m
1482# CONFIG_SMB_NLS_DEFAULT is not set 1519# CONFIG_SMB_NLS_DEFAULT is not set
1483# CONFIG_CIFS is not set 1520CONFIG_CIFS=m
1521# CONFIG_CIFS_STATS is not set
1522CONFIG_CIFS_WEAK_PW_HASH=y
1523# CONFIG_CIFS_XATTR is not set
1524# CONFIG_CIFS_DEBUG2 is not set
1525# CONFIG_CIFS_EXPERIMENTAL is not set
1484# CONFIG_NCP_FS is not set 1526# CONFIG_NCP_FS is not set
1485# CONFIG_CODA_FS is not set 1527# CONFIG_CODA_FS is not set
1486# CONFIG_AFS_FS is not set 1528# CONFIG_AFS_FS is not set
@@ -1583,9 +1625,10 @@ CONFIG_LOG_BUF_SHIFT=16
1583# CONFIG_DEBUG_LIST is not set 1625# CONFIG_DEBUG_LIST is not set
1584# CONFIG_FRAME_POINTER is not set 1626# CONFIG_FRAME_POINTER is not set
1585# CONFIG_FORCED_INLINING is not set 1627# CONFIG_FORCED_INLINING is not set
1628# CONFIG_HEADERS_CHECK is not set
1586# CONFIG_RCU_TORTURE_TEST is not set 1629# CONFIG_RCU_TORTURE_TEST is not set
1587# CONFIG_SH_STANDARD_BIOS is not set 1630# CONFIG_SH_STANDARD_BIOS is not set
1588CONFIG_EARLY_SCIF_CONSOLE=y 1631# CONFIG_EARLY_SCIF_CONSOLE is not set
1589# CONFIG_EARLY_PRINTK is not set 1632# CONFIG_EARLY_PRINTK is not set
1590# CONFIG_DEBUG_STACKOVERFLOW is not set 1633# CONFIG_DEBUG_STACKOVERFLOW is not set
1591# CONFIG_DEBUG_STACK_USAGE is not set 1634# CONFIG_DEBUG_STACK_USAGE is not set
@@ -1605,7 +1648,7 @@ CONFIG_CRYPTO=y
1605CONFIG_CRYPTO_ALGAPI=y 1648CONFIG_CRYPTO_ALGAPI=y
1606CONFIG_CRYPTO_BLKCIPHER=y 1649CONFIG_CRYPTO_BLKCIPHER=y
1607CONFIG_CRYPTO_HASH=y 1650CONFIG_CRYPTO_HASH=y
1608CONFIG_CRYPTO_MANAGER=m 1651CONFIG_CRYPTO_MANAGER=y
1609CONFIG_CRYPTO_HMAC=y 1652CONFIG_CRYPTO_HMAC=y
1610CONFIG_CRYPTO_NULL=m 1653CONFIG_CRYPTO_NULL=m
1611CONFIG_CRYPTO_MD4=m 1654CONFIG_CRYPTO_MD4=m
@@ -1615,7 +1658,7 @@ CONFIG_CRYPTO_SHA256=m
1615CONFIG_CRYPTO_SHA512=m 1658CONFIG_CRYPTO_SHA512=m
1616CONFIG_CRYPTO_WP512=m 1659CONFIG_CRYPTO_WP512=m
1617CONFIG_CRYPTO_TGR192=m 1660CONFIG_CRYPTO_TGR192=m
1618CONFIG_CRYPTO_ECB=m 1661CONFIG_CRYPTO_ECB=y
1619CONFIG_CRYPTO_CBC=y 1662CONFIG_CRYPTO_CBC=y
1620CONFIG_CRYPTO_DES=y 1663CONFIG_CRYPTO_DES=y
1621CONFIG_CRYPTO_BLOWFISH=m 1664CONFIG_CRYPTO_BLOWFISH=m
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index d8ece20bb2cf..660786013350 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -19,23 +19,34 @@
19#include <asm/io.h> 19#include <asm/io.h>
20#include "dma-sh.h" 20#include "dma-sh.h"
21 21
22static inline unsigned int get_dmte_irq(unsigned int chan)
23{
24 unsigned int irq = 0;
25 22
23
24#ifdef CONFIG_CPU_SH4
25static struct ipr_data dmae_ipr_map[] = {
26 { DMAE_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
27};
28#endif
29static struct ipr_data dmte_ipr_map[] = {
26 /* 30 /*
27 * Normally we could just do DMTE0_IRQ + chan outright, though in the 31 * Normally we could just do DMTE0_IRQ + chan outright, though in the
28 * case of the 7751R, the DMTE IRQs for channels > 4 start right above 32 * case of the 7751R, the DMTE IRQs for channels > 4 start right above
29 * the SCIF 33 * the SCIF
30 */ 34 */
31 if (chan < 4) { 35 { DMTE0_IRQ + 0, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
32 irq = DMTE0_IRQ + chan; 36 { DMTE0_IRQ + 1, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
33 } else { 37 { DMTE0_IRQ + 2, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
34#ifdef DMTE4_IRQ 38 { DMTE0_IRQ + 3, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
35 irq = DMTE4_IRQ + chan - 4; 39 { DMTE4_IRQ + 0, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
36#endif 40 { DMTE4_IRQ + 1, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
37 } 41 { DMTE4_IRQ + 2, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
42 { DMTE4_IRQ + 3, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY },
43};
38 44
45static inline unsigned int get_dmte_irq(unsigned int chan)
46{
47 unsigned int irq = 0;
48 if (chan < ARRAY_SIZE(dmte_ipr_map))
49 irq = dmte_ipr_map[chan].irq;
39 return irq; 50 return irq;
40} 51}
41 52
@@ -258,17 +269,16 @@ static int __init sh_dmac_init(void)
258 int i; 269 int i;
259 270
260#ifdef CONFIG_CPU_SH4 271#ifdef CONFIG_CPU_SH4
261 make_ipr_irq(DMAE_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY); 272 make_ipr_irq(dmae_ipr_map, ARRAY_SIZE(dmae_ipr_map));
262 i = request_irq(DMAE_IRQ, dma_err, IRQF_DISABLED, "DMAC Address Error", 0); 273 i = request_irq(DMAE_IRQ, dma_err, IRQF_DISABLED, "DMAC Address Error", 0);
263 if (unlikely(i < 0)) 274 if (unlikely(i < 0))
264 return i; 275 return i;
265#endif 276#endif
266 277
267 for (i = 0; i < info->nr_channels; i++) { 278 i = info->nr_channels;
268 int irq = get_dmte_irq(i); 279 if (i > ARRAY_SIZE(dmte_ipr_map))
269 280 i = ARRAY_SIZE(dmte_ipr_map);
270 make_ipr_irq(irq, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY); 281 make_ipr_irq(dmte_ipr_map, i);
271 }
272 282
273 /* 283 /*
274 * Initialize DMAOR, and clean up any error flags that may have 284 * Initialize DMAOR, and clean up any error flags that may have
diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c
index f7997312ef98..a0089563cbfc 100644
--- a/arch/sh/kernel/cpu/irq/ipr.c
+++ b/arch/sh/kernel/cpu/irq/ipr.c
@@ -23,24 +23,21 @@
23#include <asm/io.h> 23#include <asm/io.h>
24#include <asm/machvec.h> 24#include <asm/machvec.h>
25 25
26struct ipr_data {
27 unsigned int addr; /* Address of Interrupt Priority Register */
28 int shift; /* Shifts of the 16-bit data */
29 int priority; /* The priority */
30};
31 26
32static void disable_ipr_irq(unsigned int irq) 27static void disable_ipr_irq(unsigned int irq)
33{ 28{
34 struct ipr_data *p = get_irq_chip_data(irq); 29 struct ipr_data *p = get_irq_chip_data(irq);
30 int shift = p->shift*4;
35 /* Set the priority in IPR to 0 */ 31 /* Set the priority in IPR to 0 */
36 ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << p->shift)), p->addr); 32 ctrl_outw(ctrl_inw(p->addr) & (0xffff ^ (0xf << shift)), p->addr);
37} 33}
38 34
39static void enable_ipr_irq(unsigned int irq) 35static void enable_ipr_irq(unsigned int irq)
40{ 36{
41 struct ipr_data *p = get_irq_chip_data(irq); 37 struct ipr_data *p = get_irq_chip_data(irq);
38 int shift = p->shift*4;
42 /* Set priority in IPR back to original value */ 39 /* Set priority in IPR back to original value */
43 ctrl_outw(ctrl_inw(p->addr) | (p->priority << p->shift), p->addr); 40 ctrl_outw(ctrl_inw(p->addr) | (p->priority << shift), p->addr);
44} 41}
45 42
46static struct irq_chip ipr_irq_chip = { 43static struct irq_chip ipr_irq_chip = {
@@ -50,67 +47,57 @@ static struct irq_chip ipr_irq_chip = {
50 .mask_ack = disable_ipr_irq, 47 .mask_ack = disable_ipr_irq,
51}; 48};
52 49
53void make_ipr_irq(unsigned int irq, unsigned int addr, int pos, int priority) 50void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs)
54{ 51{
55 struct ipr_data ipr_data; 52 int i;
56
57 disable_irq_nosync(irq);
58
59 ipr_data.addr = addr;
60 ipr_data.shift = pos*4; /* POSition (0-3) x 4 means shift */
61 ipr_data.priority = priority;
62 53
63 set_irq_chip_and_handler_name(irq, &ipr_irq_chip, 54 for (i = 0; i < nr_irqs; i++) {
55 unsigned int irq = table[i].irq;
56 disable_irq_nosync(irq);
57 set_irq_chip_and_handler_name(irq, &ipr_irq_chip,
64 handle_level_irq, "level"); 58 handle_level_irq, "level");
65 set_irq_chip_data(irq, &ipr_data); 59 set_irq_chip_data(irq, &table[i]);
66 60 enable_ipr_irq(irq);
67 enable_ipr_irq(irq); 61 }
68} 62}
63EXPORT_SYMBOL(make_ipr_irq);
69 64
70/* XXX: This needs to die a horrible death.. */ 65static struct ipr_data sys_ipr_map[] = {
71void __init init_IRQ(void)
72{
73#ifndef CONFIG_CPU_SUBTYPE_SH7780 66#ifndef CONFIG_CPU_SUBTYPE_SH7780
74 make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY); 67 { TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY },
75 make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY); 68 { TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY },
76#ifdef RTC_IRQ 69#ifdef RTC_IRQ
77 make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY); 70 { RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY },
78#endif 71#endif
79
80#ifdef SCI_ERI_IRQ 72#ifdef SCI_ERI_IRQ
81 make_ipr_irq(SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY); 73 { SCI_ERI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
82 make_ipr_irq(SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY); 74 { SCI_RXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
83 make_ipr_irq(SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY); 75 { SCI_TXI_IRQ, SCI_IPR_ADDR, SCI_IPR_POS, SCI_PRIORITY },
84#endif 76#endif
85
86#ifdef SCIF1_ERI_IRQ 77#ifdef SCIF1_ERI_IRQ
87 make_ipr_irq(SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); 78 { SCIF1_ERI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
88 make_ipr_irq(SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); 79 { SCIF1_RXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
89 make_ipr_irq(SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); 80 { SCIF1_BRI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
90 make_ipr_irq(SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY); 81 { SCIF1_TXI_IRQ, SCIF1_IPR_ADDR, SCIF1_IPR_POS, SCIF1_PRIORITY },
91#endif 82#endif
92
93#if defined(CONFIG_CPU_SUBTYPE_SH7300) 83#if defined(CONFIG_CPU_SUBTYPE_SH7300)
94 make_ipr_irq(SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY); 84 { SCIF0_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS, SCIF0_PRIORITY },
95 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY); 85 { DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
96 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY); 86 { DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY },
97 make_ipr_irq(VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY); 87 { VIO_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY },
98#endif 88#endif
99
100#ifdef SCIF_ERI_IRQ 89#ifdef SCIF_ERI_IRQ
101 make_ipr_irq(SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); 90 { SCIF_ERI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
102 make_ipr_irq(SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); 91 { SCIF_RXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
103 make_ipr_irq(SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); 92 { SCIF_BRI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
104 make_ipr_irq(SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY); 93 { SCIF_TXI_IRQ, SCIF_IPR_ADDR, SCIF_IPR_POS, SCIF_PRIORITY },
105#endif 94#endif
106
107#ifdef IRDA_ERI_IRQ 95#ifdef IRDA_ERI_IRQ
108 make_ipr_irq(IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); 96 { IRDA_ERI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
109 make_ipr_irq(IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); 97 { IRDA_RXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
110 make_ipr_irq(IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); 98 { IRDA_BRI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
111 make_ipr_irq(IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY); 99 { IRDA_TXI_IRQ, IRDA_IPR_ADDR, IRDA_IPR_POS, IRDA_PRIORITY },
112#endif 100#endif
113
114#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 101#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
115 defined(CONFIG_CPU_SUBTYPE_SH7706) || \ 102 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
116 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 103 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
@@ -124,14 +111,19 @@ void __init init_IRQ(void)
124 * You should set corresponding bits of PFC to "00" 111 * You should set corresponding bits of PFC to "00"
125 * to enable these interrupts. 112 * to enable these interrupts.
126 */ 113 */
127 make_ipr_irq(IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY); 114 { IRQ0_IRQ, IRQ0_IPR_ADDR, IRQ0_IPR_POS, IRQ0_PRIORITY },
128 make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY); 115 { IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY },
129 make_ipr_irq(IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY); 116 { IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY },
130 make_ipr_irq(IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY); 117 { IRQ3_IRQ, IRQ3_IPR_ADDR, IRQ3_IPR_POS, IRQ3_PRIORITY },
131 make_ipr_irq(IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY); 118 { IRQ4_IRQ, IRQ4_IPR_ADDR, IRQ4_IPR_POS, IRQ4_PRIORITY },
132 make_ipr_irq(IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY); 119 { IRQ5_IRQ, IRQ5_IPR_ADDR, IRQ5_IPR_POS, IRQ5_PRIORITY },
133#endif 120#endif
134#endif 121#endif
122};
123
124void __init init_IRQ(void)
125{
126 make_ipr_irq(sys_ipr_map, ARRAY_SIZE(sys_ipr_map));
135 127
136#ifdef CONFIG_CPU_HAS_PINT_IRQ 128#ifdef CONFIG_CPU_HAS_PINT_IRQ
137 init_IRQ_pint(); 129 init_IRQ_pint();
@@ -153,5 +145,3 @@ int ipr_irq_demux(int irq)
153 return irq; 145 return irq;
154} 146}
155#endif 147#endif
156
157EXPORT_SYMBOL(make_ipr_irq);
diff --git a/arch/sh/kernel/cpu/irq/pint.c b/arch/sh/kernel/cpu/irq/pint.c
index 17f47b373d6e..f60007783a21 100644
--- a/arch/sh/kernel/cpu/irq/pint.c
+++ b/arch/sh/kernel/cpu/irq/pint.c
@@ -84,12 +84,16 @@ void make_pint_irq(unsigned int irq)
84 disable_pint_irq(irq); 84 disable_pint_irq(irq);
85} 85}
86 86
87static struct ipr_data pint_ipr_map[] = {
88 { PINT0_IRQ, PINT0_IPR_ADDR, PINT0_IPR_POS, PINT0_PRIORITY },
89 { PINT8_IRQ, PINT8_IPR_ADDR, PINT8_IPR_POS, PINT8_PRIORITY },
90};
91
87void __init init_IRQ_pint(void) 92void __init init_IRQ_pint(void)
88{ 93{
89 int i; 94 int i;
90 95
91 make_ipr_irq(PINT0_IRQ, PINT0_IPR_ADDR, PINT0_IPR_POS, PINT0_PRIORITY); 96 make_ipr_irq(pint_ipr_map, ARRAY_SIZE(pint_ipr_map));
92 make_ipr_irq(PINT8_IRQ, PINT8_IPR_ADDR, PINT8_IPR_POS, PINT8_PRIORITY);
93 97
94 enable_irq(PINT0_IRQ); 98 enable_irq(PINT0_IRQ);
95 enable_irq(PINT8_IRQ); 99 enable_irq(PINT8_IRQ);
diff --git a/arch/sh/kernel/syscalls.S b/arch/sh/kernel/syscalls.S
index 768334e95075..ca81976e9e34 100644
--- a/arch/sh/kernel/syscalls.S
+++ b/arch/sh/kernel/syscalls.S
@@ -351,3 +351,6 @@ ENTRY(sys_call_table)
351 .long sys_sync_file_range 351 .long sys_sync_file_range
352 .long sys_tee /* 315 */ 352 .long sys_tee /* 315 */
353 .long sys_vmsplice 353 .long sys_vmsplice
354 .long sys_move_pages
355 .long sys_getcpu
356 .long sys_epoll_pwait
diff --git a/arch/sparc64/kernel/prom.c b/arch/sparc64/kernel/prom.c
index c60efb3cb22e..0917c24c4f08 100644
--- a/arch/sparc64/kernel/prom.c
+++ b/arch/sparc64/kernel/prom.c
@@ -793,7 +793,7 @@ static unsigned int schizo_irq_build(struct device_node *dp,
793 return virt_irq; 793 return virt_irq;
794} 794}
795 795
796static void schizo_irq_trans_init(struct device_node *dp) 796static void __schizo_irq_trans_init(struct device_node *dp, int is_tomatillo)
797{ 797{
798 struct linux_prom64_registers *regs; 798 struct linux_prom64_registers *regs;
799 struct schizo_irq_data *irq_data; 799 struct schizo_irq_data *irq_data;
@@ -807,11 +807,24 @@ static void schizo_irq_trans_init(struct device_node *dp)
807 dp->irq_trans->data = irq_data; 807 dp->irq_trans->data = irq_data;
808 808
809 irq_data->pbm_regs = regs[0].phys_addr; 809 irq_data->pbm_regs = regs[0].phys_addr;
810 irq_data->sync_reg = regs[3].phys_addr + 0x1a18UL; 810 if (is_tomatillo)
811 irq_data->sync_reg = regs[3].phys_addr + 0x1a18UL;
812 else
813 irq_data->sync_reg = 0UL;
811 irq_data->portid = of_getintprop_default(dp, "portid", 0); 814 irq_data->portid = of_getintprop_default(dp, "portid", 0);
812 irq_data->chip_version = of_getintprop_default(dp, "version#", 0); 815 irq_data->chip_version = of_getintprop_default(dp, "version#", 0);
813} 816}
814 817
818static void schizo_irq_trans_init(struct device_node *dp)
819{
820 __schizo_irq_trans_init(dp, 0);
821}
822
823static void tomatillo_irq_trans_init(struct device_node *dp)
824{
825 __schizo_irq_trans_init(dp, 1);
826}
827
815static unsigned int pci_sun4v_irq_build(struct device_node *dp, 828static unsigned int pci_sun4v_irq_build(struct device_node *dp,
816 unsigned int devino, 829 unsigned int devino,
817 void *_data) 830 void *_data)
@@ -1050,8 +1063,8 @@ static struct irq_trans pci_irq_trans_table[] = {
1050 { "pci108e,8001", schizo_irq_trans_init }, 1063 { "pci108e,8001", schizo_irq_trans_init },
1051 { "SUNW,schizo+", schizo_irq_trans_init }, 1064 { "SUNW,schizo+", schizo_irq_trans_init },
1052 { "pci108e,8002", schizo_irq_trans_init }, 1065 { "pci108e,8002", schizo_irq_trans_init },
1053 { "SUNW,tomatillo", schizo_irq_trans_init }, 1066 { "SUNW,tomatillo", tomatillo_irq_trans_init },
1054 { "pci108e,a801", schizo_irq_trans_init }, 1067 { "pci108e,a801", tomatillo_irq_trans_init },
1055 { "SUNW,sun4v-pci", pci_sun4v_irq_trans_init }, 1068 { "SUNW,sun4v-pci", pci_sun4v_irq_trans_init },
1056}; 1069};
1057#endif 1070#endif
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c
index 68420e2dad0e..fe1796c939c3 100644
--- a/arch/sparc64/kernel/traps.c
+++ b/arch/sparc64/kernel/traps.c
@@ -87,6 +87,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
87 i + 1, 87 i + 1,
88 p->trapstack[i].tstate, p->trapstack[i].tpc, 88 p->trapstack[i].tstate, p->trapstack[i].tpc,
89 p->trapstack[i].tnpc, p->trapstack[i].tt); 89 p->trapstack[i].tnpc, p->trapstack[i].tt);
90 print_symbol("TRAPLOG: TPC<%s>\n", p->trapstack[i].tpc);
90 } 91 }
91} 92}
92 93
@@ -1134,6 +1135,9 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
1134 printk("%s" "ERROR(%d): TPC[%lx] TNPC[%lx] O7[%lx] TSTATE[%lx]\n", 1135 printk("%s" "ERROR(%d): TPC[%lx] TNPC[%lx] O7[%lx] TSTATE[%lx]\n",
1135 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(), 1136 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
1136 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate); 1137 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
1138 printk("%s" "ERROR(%d): ",
1139 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
1140 print_symbol("TPC<%s>\n", regs->tpc);
1137 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n", 1141 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
1138 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(), 1142 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
1139 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT, 1143 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
@@ -1741,6 +1745,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
1741 smp_processor_id(), 1745 smp_processor_id(),
1742 (type & 0x1) ? 'I' : 'D', 1746 (type & 0x1) ? 'I' : 'D',
1743 regs->tpc); 1747 regs->tpc);
1748 print_symbol(KERN_EMERG "TPC<%s>\n", regs->tpc);
1744 panic("Irrecoverable Cheetah+ parity error."); 1749 panic("Irrecoverable Cheetah+ parity error.");
1745 } 1750 }
1746 1751
@@ -1748,6 +1753,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
1748 smp_processor_id(), 1753 smp_processor_id(),
1749 (type & 0x1) ? 'I' : 'D', 1754 (type & 0x1) ? 'I' : 'D',
1750 regs->tpc); 1755 regs->tpc);
1756 print_symbol(KERN_WARNING "TPC<%s>\n", regs->tpc);
1751} 1757}
1752 1758
1753struct sun4v_error_entry { 1759struct sun4v_error_entry {
@@ -1946,6 +1952,7 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
1946 1952
1947 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n", 1953 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
1948 regs->tpc, tl); 1954 regs->tpc, tl);
1955 print_symbol(KERN_EMERG "SUN4V-ITLB: TPC<%s>\n", regs->tpc);
1949 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] " 1956 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
1950 "pte[%lx] error[%lx]\n", 1957 "pte[%lx] error[%lx]\n",
1951 sun4v_err_itlb_vaddr, sun4v_err_itlb_ctx, 1958 sun4v_err_itlb_vaddr, sun4v_err_itlb_ctx,
@@ -1966,6 +1973,7 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
1966 1973
1967 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n", 1974 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
1968 regs->tpc, tl); 1975 regs->tpc, tl);
1976 print_symbol(KERN_EMERG "SUN4V-DTLB: TPC<%s>\n", regs->tpc);
1969 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] " 1977 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
1970 "pte[%lx] error[%lx]\n", 1978 "pte[%lx] error[%lx]\n",
1971 sun4v_err_dtlb_vaddr, sun4v_err_dtlb_ctx, 1979 sun4v_err_dtlb_vaddr, sun4v_err_dtlb_ctx,
diff --git a/arch/um/Makefile b/arch/um/Makefile
index c8016a98483b..5d5ed726faa0 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -64,9 +64,14 @@ CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
64 64
65AFLAGS += $(ARCH_INCLUDE) 65AFLAGS += $(ARCH_INCLUDE)
66 66
67USER_CFLAGS := $(patsubst -I%,,$(CFLAGS)) 67USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
68USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \ 68 $(patsubst -I%,,$(CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
69 $(MODE_INCLUDE) -D_FILE_OFFSET_BITS=64 69 -D_FILE_OFFSET_BITS=64
70
71include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
72
73#This will adjust *FLAGS accordingly to the platform.
74include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
70 75
71# -Derrno=kernel_errno - This turns all kernel references to errno into 76# -Derrno=kernel_errno - This turns all kernel references to errno into
72# kernel_errno to separate them from the libc errno. This allows -fno-common 77# kernel_errno to separate them from the libc errno. This allows -fno-common
@@ -74,15 +79,11 @@ USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
74# errnos. 79# errnos.
75# These apply to kernelspace only. 80# These apply to kernelspace only.
76 81
77CFLAGS += -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 82KERNEL_DEFINES = -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
78 -Dmktime=kernel_mktime 83 -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)
84CFLAGS += $(KERNEL_DEFINES)
79CFLAGS += $(call cc-option,-fno-unit-at-a-time,) 85CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
80 86
81include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
82
83#This will adjust *FLAGS accordingly to the platform.
84include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
85
86# These are needed for clean and mrproper, since in that case .config is not 87# These are needed for clean and mrproper, since in that case .config is not
87# included; the values here are meaningless 88# included; the values here are meaningless
88 89
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
index b65ca115ef77..c9f1c5b24c9a 100644
--- a/arch/um/Makefile-i386
+++ b/arch/um/Makefile-i386
@@ -16,7 +16,6 @@ OBJCOPYFLAGS := -O binary -R .note -R .comment -S
16ifeq ("$(origin SUBARCH)", "command line") 16ifeq ("$(origin SUBARCH)", "command line")
17ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)") 17ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
18CFLAGS += $(call cc-option,-m32) 18CFLAGS += $(call cc-option,-m32)
19USER_CFLAGS += $(call cc-option,-m32)
20AFLAGS += $(call cc-option,-m32) 19AFLAGS += $(call cc-option,-m32)
21LINK-y += $(call cc-option,-m32) 20LINK-y += $(call cc-option,-m32)
22UML_OBJCOPYFLAGS += -F $(ELF_FORMAT) 21UML_OBJCOPYFLAGS += -F $(ELF_FORMAT)
@@ -25,7 +24,7 @@ export LDFLAGS HOSTCFLAGS HOSTLDFLAGS UML_OBJCOPYFLAGS
25endif 24endif
26endif 25endif
27 26
28CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH) 27ARCH_KERNEL_DEFINES += -U__$(SUBARCH)__ -U$(SUBARCH)
29 28
30# First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y. 29# First of all, tune CFLAGS for the specific CPU. This actually sets cflags-y.
31include $(srctree)/arch/i386/Makefile.cpu 30include $(srctree)/arch/i386/Makefile.cpu
@@ -38,4 +37,3 @@ cflags-y += $(call cc-option,-mpreferred-stack-boundary=2)
38cflags-y += -ffreestanding 37cflags-y += -ffreestanding
39 38
40CFLAGS += $(cflags-y) 39CFLAGS += $(cflags-y)
41USER_CFLAGS += $(cflags-y)
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index d278682dd799..69ecea63fdae 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -8,8 +8,8 @@ _extra_flags_ = -fno-builtin -m64
8 8
9#We #undef __x86_64__ for kernelspace, not for userspace where 9#We #undef __x86_64__ for kernelspace, not for userspace where
10#it's needed for headers to work! 10#it's needed for headers to work!
11CFLAGS += -U__$(SUBARCH)__ $(_extra_flags_) 11ARCH_KERNEL_DEFINES = -U__$(SUBARCH)__
12USER_CFLAGS += $(_extra_flags_) 12CFLAGS += $(_extra_flags_)
13 13
14CHECKFLAGS += -m64 14CHECKFLAGS += -m64
15AFLAGS += -m64 15AFLAGS += -m64
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index bc458f57921b..49c047b75cc5 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -106,10 +106,15 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
106 106
107#define DRIVER_NAME "uml-blkdev" 107#define DRIVER_NAME "uml-blkdev"
108 108
109/* Can be taken in interrupt context, and is passed to the block layer to lock
110 * the request queue. Kernel side code knows that. */
109static DEFINE_SPINLOCK(ubd_io_lock); 111static DEFINE_SPINLOCK(ubd_io_lock);
110static DEFINE_SPINLOCK(ubd_lock);
111 112
112static void (*do_ubd)(void); 113static DEFINE_MUTEX(ubd_lock);
114
115/* XXX - this made sense in 2.4 days, now it's only used as a boolean, and
116 * probably it doesn't make sense even for that. */
117static int do_ubd;
113 118
114static int ubd_open(struct inode * inode, struct file * filp); 119static int ubd_open(struct inode * inode, struct file * filp);
115static int ubd_release(struct inode * inode, struct file * file); 120static int ubd_release(struct inode * inode, struct file * file);
@@ -117,7 +122,7 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
117 unsigned int cmd, unsigned long arg); 122 unsigned int cmd, unsigned long arg);
118static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo); 123static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo);
119 124
120#define MAX_DEV (8) 125#define MAX_DEV (16)
121 126
122static struct block_device_operations ubd_blops = { 127static struct block_device_operations ubd_blops = {
123 .owner = THIS_MODULE, 128 .owner = THIS_MODULE,
@@ -150,8 +155,9 @@ static struct gendisk *fake_gendisk[MAX_DEV];
150static struct openflags global_openflags = OPEN_FLAGS; 155static struct openflags global_openflags = OPEN_FLAGS;
151 156
152struct cow { 157struct cow {
153 /* This is the backing file, actually */ 158 /* backing file name */
154 char *file; 159 char *file;
160 /* backing file fd */
155 int fd; 161 int fd;
156 unsigned long *bitmap; 162 unsigned long *bitmap;
157 unsigned long bitmap_len; 163 unsigned long bitmap_len;
@@ -160,14 +166,16 @@ struct cow {
160}; 166};
161 167
162struct ubd { 168struct ubd {
169 /* name (and fd, below) of the file opened for writing, either the
170 * backing or the cow file. */
163 char *file; 171 char *file;
164 int count; 172 int count;
165 int fd; 173 int fd;
166 __u64 size; 174 __u64 size;
167 struct openflags boot_openflags; 175 struct openflags boot_openflags;
168 struct openflags openflags; 176 struct openflags openflags;
169 int shared; 177 unsigned shared:1;
170 int no_cow; 178 unsigned no_cow:1;
171 struct cow cow; 179 struct cow cow;
172 struct platform_device pdev; 180 struct platform_device pdev;
173}; 181};
@@ -192,18 +200,7 @@ struct ubd {
192 .cow = DEFAULT_COW, \ 200 .cow = DEFAULT_COW, \
193} 201}
194 202
195struct ubd ubd_dev[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD }; 203struct ubd ubd_devs[MAX_DEV] = { [ 0 ... MAX_DEV - 1 ] = DEFAULT_UBD };
196
197static int ubd0_init(void)
198{
199 struct ubd *dev = &ubd_dev[0];
200
201 if(dev->file == NULL)
202 dev->file = "root_fs";
203 return(0);
204}
205
206__initcall(ubd0_init);
207 204
208/* Only changed by fake_ide_setup which is a setup */ 205/* Only changed by fake_ide_setup which is a setup */
209static int fake_ide = 0; 206static int fake_ide = 0;
@@ -277,7 +274,7 @@ static int parse_unit(char **ptr)
277 return(-1); 274 return(-1);
278 *ptr = end; 275 *ptr = end;
279 } 276 }
280 else if (('a' <= *str) && (*str <= 'h')) { 277 else if (('a' <= *str) && (*str <= 'z')) {
281 n = *str - 'a'; 278 n = *str - 'a';
282 str++; 279 str++;
283 *ptr = str; 280 *ptr = str;
@@ -285,9 +282,13 @@ static int parse_unit(char **ptr)
285 return(n); 282 return(n);
286} 283}
287 284
285/* If *index_out == -1 at exit, the passed option was a general one;
286 * otherwise, the str pointer is used (and owned) inside ubd_devs array, so it
287 * should not be freed on exit.
288 */
288static int ubd_setup_common(char *str, int *index_out) 289static int ubd_setup_common(char *str, int *index_out)
289{ 290{
290 struct ubd *dev; 291 struct ubd *ubd_dev;
291 struct openflags flags = global_openflags; 292 struct openflags flags = global_openflags;
292 char *backing_file; 293 char *backing_file;
293 int n, err, i; 294 int n, err, i;
@@ -311,7 +312,7 @@ static int ubd_setup_common(char *str, int *index_out)
311 } 312 }
312 313
313 err = 1; 314 err = 1;
314 spin_lock(&ubd_lock); 315 mutex_lock(&ubd_lock);
315 if(fake_major != MAJOR_NR){ 316 if(fake_major != MAJOR_NR){
316 printk(KERN_ERR "Can't assign a fake major twice\n"); 317 printk(KERN_ERR "Can't assign a fake major twice\n");
317 goto out1; 318 goto out1;
@@ -323,7 +324,7 @@ static int ubd_setup_common(char *str, int *index_out)
323 major); 324 major);
324 err = 0; 325 err = 0;
325 out1: 326 out1:
326 spin_unlock(&ubd_lock); 327 mutex_unlock(&ubd_lock);
327 return(err); 328 return(err);
328 } 329 }
329 330
@@ -340,10 +341,10 @@ static int ubd_setup_common(char *str, int *index_out)
340 } 341 }
341 342
342 err = 1; 343 err = 1;
343 spin_lock(&ubd_lock); 344 mutex_lock(&ubd_lock);
344 345
345 dev = &ubd_dev[n]; 346 ubd_dev = &ubd_devs[n];
346 if(dev->file != NULL){ 347 if(ubd_dev->file != NULL){
347 printk(KERN_ERR "ubd_setup : device already configured\n"); 348 printk(KERN_ERR "ubd_setup : device already configured\n");
348 goto out; 349 goto out;
349 } 350 }
@@ -360,10 +361,10 @@ static int ubd_setup_common(char *str, int *index_out)
360 flags.s = 1; 361 flags.s = 1;
361 break; 362 break;
362 case 'd': 363 case 'd':
363 dev->no_cow = 1; 364 ubd_dev->no_cow = 1;
364 break; 365 break;
365 case 'c': 366 case 'c':
366 dev->shared = 1; 367 ubd_dev->shared = 1;
367 break; 368 break;
368 case '=': 369 case '=':
369 str++; 370 str++;
@@ -390,7 +391,7 @@ break_loop:
390 } 391 }
391 392
392 if(backing_file){ 393 if(backing_file){
393 if(dev->no_cow) 394 if(ubd_dev->no_cow)
394 printk(KERN_ERR "Can't specify both 'd' and a " 395 printk(KERN_ERR "Can't specify both 'd' and a "
395 "cow file\n"); 396 "cow file\n");
396 else { 397 else {
@@ -398,11 +399,11 @@ break_loop:
398 backing_file++; 399 backing_file++;
399 } 400 }
400 } 401 }
401 dev->file = str; 402 ubd_dev->file = str;
402 dev->cow.file = backing_file; 403 ubd_dev->cow.file = backing_file;
403 dev->boot_openflags = flags; 404 ubd_dev->boot_openflags = flags;
404out: 405out:
405 spin_unlock(&ubd_lock); 406 mutex_unlock(&ubd_lock);
406 return(err); 407 return(err);
407} 408}
408 409
@@ -472,8 +473,9 @@ int thread_fd = -1;
472 473
473/* Changed by ubd_handler, which is serialized because interrupts only 474/* Changed by ubd_handler, which is serialized because interrupts only
474 * happen on CPU 0. 475 * happen on CPU 0.
476 * XXX: currently unused.
475 */ 477 */
476int intr_count = 0; 478static int intr_count = 0;
477 479
478/* call ubd_finish if you need to serialize */ 480/* call ubd_finish if you need to serialize */
479static void __ubd_finish(struct request *req, int error) 481static void __ubd_finish(struct request *req, int error)
@@ -493,6 +495,8 @@ static void __ubd_finish(struct request *req, int error)
493 end_request(req, 1); 495 end_request(req, 1);
494} 496}
495 497
498/* Callable only from interrupt context - otherwise you need to do
499 * spin_lock_irq()/spin_lock_irqsave() */
496static inline void ubd_finish(struct request *req, int error) 500static inline void ubd_finish(struct request *req, int error)
497{ 501{
498 spin_lock(&ubd_io_lock); 502 spin_lock(&ubd_io_lock);
@@ -500,14 +504,15 @@ static inline void ubd_finish(struct request *req, int error)
500 spin_unlock(&ubd_io_lock); 504 spin_unlock(&ubd_io_lock);
501} 505}
502 506
503/* Called without ubd_io_lock held */ 507/* XXX - move this inside ubd_intr. */
508/* Called without ubd_io_lock held, and only in interrupt context. */
504static void ubd_handler(void) 509static void ubd_handler(void)
505{ 510{
506 struct io_thread_req req; 511 struct io_thread_req req;
507 struct request *rq = elv_next_request(ubd_queue); 512 struct request *rq = elv_next_request(ubd_queue);
508 int n; 513 int n;
509 514
510 do_ubd = NULL; 515 do_ubd = 0;
511 intr_count++; 516 intr_count++;
512 n = os_read_file(thread_fd, &req, sizeof(req)); 517 n = os_read_file(thread_fd, &req, sizeof(req));
513 if(n != sizeof(req)){ 518 if(n != sizeof(req)){
@@ -521,7 +526,9 @@ static void ubd_handler(void)
521 526
522 ubd_finish(rq, req.error); 527 ubd_finish(rq, req.error);
523 reactivate_fd(thread_fd, UBD_IRQ); 528 reactivate_fd(thread_fd, UBD_IRQ);
529 spin_lock(&ubd_io_lock);
524 do_ubd_request(ubd_queue); 530 do_ubd_request(ubd_queue);
531 spin_unlock(&ubd_io_lock);
525} 532}
526 533
527static irqreturn_t ubd_intr(int irq, void *dev) 534static irqreturn_t ubd_intr(int irq, void *dev)
@@ -541,87 +548,90 @@ void kill_io_thread(void)
541 548
542__uml_exitcall(kill_io_thread); 549__uml_exitcall(kill_io_thread);
543 550
544static int ubd_file_size(struct ubd *dev, __u64 *size_out) 551static inline int ubd_file_size(struct ubd *ubd_dev, __u64 *size_out)
545{ 552{
546 char *file; 553 char *file;
547 554
548 file = dev->cow.file ? dev->cow.file : dev->file; 555 file = ubd_dev->cow.file ? ubd_dev->cow.file : ubd_dev->file;
549 return(os_file_size(file, size_out)); 556 return(os_file_size(file, size_out));
550} 557}
551 558
552static void ubd_close(struct ubd *dev) 559static void ubd_close_dev(struct ubd *ubd_dev)
553{ 560{
554 os_close_file(dev->fd); 561 os_close_file(ubd_dev->fd);
555 if(dev->cow.file == NULL) 562 if(ubd_dev->cow.file == NULL)
556 return; 563 return;
557 564
558 os_close_file(dev->cow.fd); 565 os_close_file(ubd_dev->cow.fd);
559 vfree(dev->cow.bitmap); 566 vfree(ubd_dev->cow.bitmap);
560 dev->cow.bitmap = NULL; 567 ubd_dev->cow.bitmap = NULL;
561} 568}
562 569
563static int ubd_open_dev(struct ubd *dev) 570static int ubd_open_dev(struct ubd *ubd_dev)
564{ 571{
565 struct openflags flags; 572 struct openflags flags;
566 char **back_ptr; 573 char **back_ptr;
567 int err, create_cow, *create_ptr; 574 int err, create_cow, *create_ptr;
575 int fd;
568 576
569 dev->openflags = dev->boot_openflags; 577 ubd_dev->openflags = ubd_dev->boot_openflags;
570 create_cow = 0; 578 create_cow = 0;
571 create_ptr = (dev->cow.file != NULL) ? &create_cow : NULL; 579 create_ptr = (ubd_dev->cow.file != NULL) ? &create_cow : NULL;
572 back_ptr = dev->no_cow ? NULL : &dev->cow.file; 580 back_ptr = ubd_dev->no_cow ? NULL : &ubd_dev->cow.file;
573 dev->fd = open_ubd_file(dev->file, &dev->openflags, dev->shared, 581
574 back_ptr, &dev->cow.bitmap_offset, 582 fd = open_ubd_file(ubd_dev->file, &ubd_dev->openflags, ubd_dev->shared,
575 &dev->cow.bitmap_len, &dev->cow.data_offset, 583 back_ptr, &ubd_dev->cow.bitmap_offset,
584 &ubd_dev->cow.bitmap_len, &ubd_dev->cow.data_offset,
576 create_ptr); 585 create_ptr);
577 586
578 if((dev->fd == -ENOENT) && create_cow){ 587 if((fd == -ENOENT) && create_cow){
579 dev->fd = create_cow_file(dev->file, dev->cow.file, 588 fd = create_cow_file(ubd_dev->file, ubd_dev->cow.file,
580 dev->openflags, 1 << 9, PAGE_SIZE, 589 ubd_dev->openflags, 1 << 9, PAGE_SIZE,
581 &dev->cow.bitmap_offset, 590 &ubd_dev->cow.bitmap_offset,
582 &dev->cow.bitmap_len, 591 &ubd_dev->cow.bitmap_len,
583 &dev->cow.data_offset); 592 &ubd_dev->cow.data_offset);
584 if(dev->fd >= 0){ 593 if(fd >= 0){
585 printk(KERN_INFO "Creating \"%s\" as COW file for " 594 printk(KERN_INFO "Creating \"%s\" as COW file for "
586 "\"%s\"\n", dev->file, dev->cow.file); 595 "\"%s\"\n", ubd_dev->file, ubd_dev->cow.file);
587 } 596 }
588 } 597 }
589 598
590 if(dev->fd < 0){ 599 if(fd < 0){
591 printk("Failed to open '%s', errno = %d\n", dev->file, 600 printk("Failed to open '%s', errno = %d\n", ubd_dev->file,
592 -dev->fd); 601 -fd);
593 return(dev->fd); 602 return fd;
594 } 603 }
604 ubd_dev->fd = fd;
595 605
596 if(dev->cow.file != NULL){ 606 if(ubd_dev->cow.file != NULL){
597 err = -ENOMEM; 607 err = -ENOMEM;
598 dev->cow.bitmap = (void *) vmalloc(dev->cow.bitmap_len); 608 ubd_dev->cow.bitmap = (void *) vmalloc(ubd_dev->cow.bitmap_len);
599 if(dev->cow.bitmap == NULL){ 609 if(ubd_dev->cow.bitmap == NULL){
600 printk(KERN_ERR "Failed to vmalloc COW bitmap\n"); 610 printk(KERN_ERR "Failed to vmalloc COW bitmap\n");
601 goto error; 611 goto error;
602 } 612 }
603 flush_tlb_kernel_vm(); 613 flush_tlb_kernel_vm();
604 614
605 err = read_cow_bitmap(dev->fd, dev->cow.bitmap, 615 err = read_cow_bitmap(ubd_dev->fd, ubd_dev->cow.bitmap,
606 dev->cow.bitmap_offset, 616 ubd_dev->cow.bitmap_offset,
607 dev->cow.bitmap_len); 617 ubd_dev->cow.bitmap_len);
608 if(err < 0) 618 if(err < 0)
609 goto error; 619 goto error;
610 620
611 flags = dev->openflags; 621 flags = ubd_dev->openflags;
612 flags.w = 0; 622 flags.w = 0;
613 err = open_ubd_file(dev->cow.file, &flags, dev->shared, NULL, 623 err = open_ubd_file(ubd_dev->cow.file, &flags, ubd_dev->shared, NULL,
614 NULL, NULL, NULL, NULL); 624 NULL, NULL, NULL, NULL);
615 if(err < 0) goto error; 625 if(err < 0) goto error;
616 dev->cow.fd = err; 626 ubd_dev->cow.fd = err;
617 } 627 }
618 return(0); 628 return(0);
619 error: 629 error:
620 os_close_file(dev->fd); 630 os_close_file(ubd_dev->fd);
621 return(err); 631 return(err);
622} 632}
623 633
624static int ubd_new_disk(int major, u64 size, int unit, 634static int ubd_disk_register(int major, u64 size, int unit,
625 struct gendisk **disk_out) 635 struct gendisk **disk_out)
626 636
627{ 637{
@@ -642,13 +652,13 @@ static int ubd_new_disk(int major, u64 size, int unit,
642 652
643 /* sysfs register (not for ide fake devices) */ 653 /* sysfs register (not for ide fake devices) */
644 if (major == MAJOR_NR) { 654 if (major == MAJOR_NR) {
645 ubd_dev[unit].pdev.id = unit; 655 ubd_devs[unit].pdev.id = unit;
646 ubd_dev[unit].pdev.name = DRIVER_NAME; 656 ubd_devs[unit].pdev.name = DRIVER_NAME;
647 platform_device_register(&ubd_dev[unit].pdev); 657 platform_device_register(&ubd_devs[unit].pdev);
648 disk->driverfs_dev = &ubd_dev[unit].pdev.dev; 658 disk->driverfs_dev = &ubd_devs[unit].pdev.dev;
649 } 659 }
650 660
651 disk->private_data = &ubd_dev[unit]; 661 disk->private_data = &ubd_devs[unit];
652 disk->queue = ubd_queue; 662 disk->queue = ubd_queue;
653 add_disk(disk); 663 add_disk(disk);
654 664
@@ -660,25 +670,25 @@ static int ubd_new_disk(int major, u64 size, int unit,
660 670
661static int ubd_add(int n) 671static int ubd_add(int n)
662{ 672{
663 struct ubd *dev = &ubd_dev[n]; 673 struct ubd *ubd_dev = &ubd_devs[n];
664 int err; 674 int err;
665 675
666 err = -ENODEV; 676 err = -ENODEV;
667 if(dev->file == NULL) 677 if(ubd_dev->file == NULL)
668 goto out; 678 goto out;
669 679
670 err = ubd_file_size(dev, &dev->size); 680 err = ubd_file_size(ubd_dev, &ubd_dev->size);
671 if(err < 0) 681 if(err < 0)
672 goto out; 682 goto out;
673 683
674 dev->size = ROUND_BLOCK(dev->size); 684 ubd_dev->size = ROUND_BLOCK(ubd_dev->size);
675 685
676 err = ubd_new_disk(MAJOR_NR, dev->size, n, &ubd_gendisk[n]); 686 err = ubd_disk_register(MAJOR_NR, ubd_dev->size, n, &ubd_gendisk[n]);
677 if(err) 687 if(err)
678 goto out; 688 goto out;
679 689
680 if(fake_major != MAJOR_NR) 690 if(fake_major != MAJOR_NR)
681 ubd_new_disk(fake_major, dev->size, n, 691 ubd_disk_register(fake_major, ubd_dev->size, n,
682 &fake_gendisk[n]); 692 &fake_gendisk[n]);
683 693
684 /* perhaps this should also be under the "if (fake_major)" above */ 694 /* perhaps this should also be under the "if (fake_major)" above */
@@ -693,32 +703,41 @@ out:
693 703
694static int ubd_config(char *str) 704static int ubd_config(char *str)
695{ 705{
696 int n, err; 706 int n, ret;
697 707
698 str = kstrdup(str, GFP_KERNEL); 708 str = kstrdup(str, GFP_KERNEL);
699 if(str == NULL){ 709 if (str == NULL) {
700 printk(KERN_ERR "ubd_config failed to strdup string\n"); 710 printk(KERN_ERR "ubd_config failed to strdup string\n");
701 return(1); 711 ret = 1;
712 goto out;
702 } 713 }
703 err = ubd_setup_common(str, &n); 714 ret = ubd_setup_common(str, &n);
704 if(err){ 715 if (ret) {
705 kfree(str); 716 ret = -1;
706 return(-1); 717 goto err_free;
718 }
719 if (n == -1) {
720 ret = 0;
721 goto err_free;
707 } 722 }
708 if(n == -1) return(0);
709 723
710 spin_lock(&ubd_lock); 724 mutex_lock(&ubd_lock);
711 err = ubd_add(n); 725 ret = ubd_add(n);
712 if(err) 726 if (ret)
713 ubd_dev[n].file = NULL; 727 ubd_devs[n].file = NULL;
714 spin_unlock(&ubd_lock); 728 mutex_unlock(&ubd_lock);
715 729
716 return(err); 730out:
731 return ret;
732
733err_free:
734 kfree(str);
735 goto out;
717} 736}
718 737
719static int ubd_get_config(char *name, char *str, int size, char **error_out) 738static int ubd_get_config(char *name, char *str, int size, char **error_out)
720{ 739{
721 struct ubd *dev; 740 struct ubd *ubd_dev;
722 int n, len = 0; 741 int n, len = 0;
723 742
724 n = parse_unit(&name); 743 n = parse_unit(&name);
@@ -727,24 +746,24 @@ static int ubd_get_config(char *name, char *str, int size, char **error_out)
727 return(-1); 746 return(-1);
728 } 747 }
729 748
730 dev = &ubd_dev[n]; 749 ubd_dev = &ubd_devs[n];
731 spin_lock(&ubd_lock); 750 mutex_lock(&ubd_lock);
732 751
733 if(dev->file == NULL){ 752 if(ubd_dev->file == NULL){
734 CONFIG_CHUNK(str, size, len, "", 1); 753 CONFIG_CHUNK(str, size, len, "", 1);
735 goto out; 754 goto out;
736 } 755 }
737 756
738 CONFIG_CHUNK(str, size, len, dev->file, 0); 757 CONFIG_CHUNK(str, size, len, ubd_dev->file, 0);
739 758
740 if(dev->cow.file != NULL){ 759 if(ubd_dev->cow.file != NULL){
741 CONFIG_CHUNK(str, size, len, ",", 0); 760 CONFIG_CHUNK(str, size, len, ",", 0);
742 CONFIG_CHUNK(str, size, len, dev->cow.file, 1); 761 CONFIG_CHUNK(str, size, len, ubd_dev->cow.file, 1);
743 } 762 }
744 else CONFIG_CHUNK(str, size, len, "", 1); 763 else CONFIG_CHUNK(str, size, len, "", 1);
745 764
746 out: 765 out:
747 spin_unlock(&ubd_lock); 766 mutex_unlock(&ubd_lock);
748 return(len); 767 return(len);
749} 768}
750 769
@@ -760,22 +779,22 @@ static int ubd_id(char **str, int *start_out, int *end_out)
760 779
761static int ubd_remove(int n) 780static int ubd_remove(int n)
762{ 781{
763 struct ubd *dev; 782 struct ubd *ubd_dev;
764 int err = -ENODEV; 783 int err = -ENODEV;
765 784
766 spin_lock(&ubd_lock); 785 mutex_lock(&ubd_lock);
767 786
768 if(ubd_gendisk[n] == NULL) 787 if(ubd_gendisk[n] == NULL)
769 goto out; 788 goto out;
770 789
771 dev = &ubd_dev[n]; 790 ubd_dev = &ubd_devs[n];
772 791
773 if(dev->file == NULL) 792 if(ubd_dev->file == NULL)
774 goto out; 793 goto out;
775 794
776 /* you cannot remove a open disk */ 795 /* you cannot remove a open disk */
777 err = -EBUSY; 796 err = -EBUSY;
778 if(dev->count > 0) 797 if(ubd_dev->count > 0)
779 goto out; 798 goto out;
780 799
781 del_gendisk(ubd_gendisk[n]); 800 del_gendisk(ubd_gendisk[n]);
@@ -788,14 +807,15 @@ static int ubd_remove(int n)
788 fake_gendisk[n] = NULL; 807 fake_gendisk[n] = NULL;
789 } 808 }
790 809
791 platform_device_unregister(&dev->pdev); 810 platform_device_unregister(&ubd_dev->pdev);
792 *dev = ((struct ubd) DEFAULT_UBD); 811 *ubd_dev = ((struct ubd) DEFAULT_UBD);
793 err = 0; 812 err = 0;
794out: 813out:
795 spin_unlock(&ubd_lock); 814 mutex_unlock(&ubd_lock);
796 return err; 815 return err;
797} 816}
798 817
818/* All these are called by mconsole in process context and without ubd-specific locks. */
799static struct mc_device ubd_mc = { 819static struct mc_device ubd_mc = {
800 .name = "ubd", 820 .name = "ubd",
801 .config = ubd_config, 821 .config = ubd_config,
@@ -804,7 +824,7 @@ static struct mc_device ubd_mc = {
804 .remove = ubd_remove, 824 .remove = ubd_remove,
805}; 825};
806 826
807static int ubd_mc_init(void) 827static int __init ubd_mc_init(void)
808{ 828{
809 mconsole_register_dev(&ubd_mc); 829 mconsole_register_dev(&ubd_mc);
810 return 0; 830 return 0;
@@ -812,13 +832,24 @@ static int ubd_mc_init(void)
812 832
813__initcall(ubd_mc_init); 833__initcall(ubd_mc_init);
814 834
835static int __init ubd0_init(void)
836{
837 struct ubd *ubd_dev = &ubd_devs[0];
838
839 if(ubd_dev->file == NULL)
840 ubd_dev->file = "root_fs";
841 return(0);
842}
843
844__initcall(ubd0_init);
845
815static struct platform_driver ubd_driver = { 846static struct platform_driver ubd_driver = {
816 .driver = { 847 .driver = {
817 .name = DRIVER_NAME, 848 .name = DRIVER_NAME,
818 }, 849 },
819}; 850};
820 851
821int ubd_init(void) 852static int __init ubd_init(void)
822{ 853{
823 int i; 854 int i;
824 855
@@ -846,7 +877,7 @@ int ubd_init(void)
846 877
847late_initcall(ubd_init); 878late_initcall(ubd_init);
848 879
849int ubd_driver_init(void){ 880static int __init ubd_driver_init(void){
850 unsigned long stack; 881 unsigned long stack;
851 int err; 882 int err;
852 883
@@ -867,7 +898,7 @@ int ubd_driver_init(void){
867 return(0); 898 return(0);
868 } 899 }
869 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr, 900 err = um_request_irq(UBD_IRQ, thread_fd, IRQ_READ, ubd_intr,
870 IRQF_DISABLED, "ubd", ubd_dev); 901 IRQF_DISABLED, "ubd", ubd_devs);
871 if(err != 0) 902 if(err != 0)
872 printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err); 903 printk(KERN_ERR "um_request_irq failed - errno = %d\n", -err);
873 return 0; 904 return 0;
@@ -878,24 +909,24 @@ device_initcall(ubd_driver_init);
878static int ubd_open(struct inode *inode, struct file *filp) 909static int ubd_open(struct inode *inode, struct file *filp)
879{ 910{
880 struct gendisk *disk = inode->i_bdev->bd_disk; 911 struct gendisk *disk = inode->i_bdev->bd_disk;
881 struct ubd *dev = disk->private_data; 912 struct ubd *ubd_dev = disk->private_data;
882 int err = 0; 913 int err = 0;
883 914
884 if(dev->count == 0){ 915 if(ubd_dev->count == 0){
885 err = ubd_open_dev(dev); 916 err = ubd_open_dev(ubd_dev);
886 if(err){ 917 if(err){
887 printk(KERN_ERR "%s: Can't open \"%s\": errno = %d\n", 918 printk(KERN_ERR "%s: Can't open \"%s\": errno = %d\n",
888 disk->disk_name, dev->file, -err); 919 disk->disk_name, ubd_dev->file, -err);
889 goto out; 920 goto out;
890 } 921 }
891 } 922 }
892 dev->count++; 923 ubd_dev->count++;
893 set_disk_ro(disk, !dev->openflags.w); 924 set_disk_ro(disk, !ubd_dev->openflags.w);
894 925
895 /* This should no more be needed. And it didn't work anyway to exclude 926 /* This should no more be needed. And it didn't work anyway to exclude
896 * read-write remounting of filesystems.*/ 927 * read-write remounting of filesystems.*/
897 /*if((filp->f_mode & FMODE_WRITE) && !dev->openflags.w){ 928 /*if((filp->f_mode & FMODE_WRITE) && !ubd_dev->openflags.w){
898 if(--dev->count == 0) ubd_close(dev); 929 if(--ubd_dev->count == 0) ubd_close_dev(ubd_dev);
899 err = -EROFS; 930 err = -EROFS;
900 }*/ 931 }*/
901 out: 932 out:
@@ -905,10 +936,10 @@ static int ubd_open(struct inode *inode, struct file *filp)
905static int ubd_release(struct inode * inode, struct file * file) 936static int ubd_release(struct inode * inode, struct file * file)
906{ 937{
907 struct gendisk *disk = inode->i_bdev->bd_disk; 938 struct gendisk *disk = inode->i_bdev->bd_disk;
908 struct ubd *dev = disk->private_data; 939 struct ubd *ubd_dev = disk->private_data;
909 940
910 if(--dev->count == 0) 941 if(--ubd_dev->count == 0)
911 ubd_close(dev); 942 ubd_close_dev(ubd_dev);
912 return(0); 943 return(0);
913} 944}
914 945
@@ -976,12 +1007,12 @@ static void cowify_req(struct io_thread_req *req, unsigned long *bitmap,
976static int prepare_request(struct request *req, struct io_thread_req *io_req) 1007static int prepare_request(struct request *req, struct io_thread_req *io_req)
977{ 1008{
978 struct gendisk *disk = req->rq_disk; 1009 struct gendisk *disk = req->rq_disk;
979 struct ubd *dev = disk->private_data; 1010 struct ubd *ubd_dev = disk->private_data;
980 __u64 offset; 1011 __u64 offset;
981 int len; 1012 int len;
982 1013
983 /* This should be impossible now */ 1014 /* This should be impossible now */
984 if((rq_data_dir(req) == WRITE) && !dev->openflags.w){ 1015 if((rq_data_dir(req) == WRITE) && !ubd_dev->openflags.w){
985 printk("Write attempted on readonly ubd device %s\n", 1016 printk("Write attempted on readonly ubd device %s\n",
986 disk->disk_name); 1017 disk->disk_name);
987 end_request(req, 0); 1018 end_request(req, 0);
@@ -991,8 +1022,8 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req)
991 offset = ((__u64) req->sector) << 9; 1022 offset = ((__u64) req->sector) << 9;
992 len = req->current_nr_sectors << 9; 1023 len = req->current_nr_sectors << 9;
993 1024
994 io_req->fds[0] = (dev->cow.file != NULL) ? dev->cow.fd : dev->fd; 1025 io_req->fds[0] = (ubd_dev->cow.file != NULL) ? ubd_dev->cow.fd : ubd_dev->fd;
995 io_req->fds[1] = dev->fd; 1026 io_req->fds[1] = ubd_dev->fd;
996 io_req->cow_offset = -1; 1027 io_req->cow_offset = -1;
997 io_req->offset = offset; 1028 io_req->offset = offset;
998 io_req->length = len; 1029 io_req->length = len;
@@ -1001,13 +1032,13 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req)
1001 1032
1002 io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE; 1033 io_req->op = (rq_data_dir(req) == READ) ? UBD_READ : UBD_WRITE;
1003 io_req->offsets[0] = 0; 1034 io_req->offsets[0] = 0;
1004 io_req->offsets[1] = dev->cow.data_offset; 1035 io_req->offsets[1] = ubd_dev->cow.data_offset;
1005 io_req->buffer = req->buffer; 1036 io_req->buffer = req->buffer;
1006 io_req->sectorsize = 1 << 9; 1037 io_req->sectorsize = 1 << 9;
1007 1038
1008 if(dev->cow.file != NULL) 1039 if(ubd_dev->cow.file != NULL)
1009 cowify_req(io_req, dev->cow.bitmap, dev->cow.bitmap_offset, 1040 cowify_req(io_req, ubd_dev->cow.bitmap, ubd_dev->cow.bitmap_offset,
1010 dev->cow.bitmap_len); 1041 ubd_dev->cow.bitmap_len);
1011 1042
1012 return(0); 1043 return(0);
1013} 1044}
@@ -1033,7 +1064,7 @@ static void do_ubd_request(request_queue_t *q)
1033 return; 1064 return;
1034 err = prepare_request(req, &io_req); 1065 err = prepare_request(req, &io_req);
1035 if(!err){ 1066 if(!err){
1036 do_ubd = ubd_handler; 1067 do_ubd = 1;
1037 n = os_write_file(thread_fd, (char *) &io_req, 1068 n = os_write_file(thread_fd, (char *) &io_req,
1038 sizeof(io_req)); 1069 sizeof(io_req));
1039 if(n != sizeof(io_req)) 1070 if(n != sizeof(io_req))
@@ -1045,18 +1076,18 @@ static void do_ubd_request(request_queue_t *q)
1045 1076
1046static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo) 1077static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
1047{ 1078{
1048 struct ubd *dev = bdev->bd_disk->private_data; 1079 struct ubd *ubd_dev = bdev->bd_disk->private_data;
1049 1080
1050 geo->heads = 128; 1081 geo->heads = 128;
1051 geo->sectors = 32; 1082 geo->sectors = 32;
1052 geo->cylinders = dev->size / (128 * 32 * 512); 1083 geo->cylinders = ubd_dev->size / (128 * 32 * 512);
1053 return 0; 1084 return 0;
1054} 1085}
1055 1086
1056static int ubd_ioctl(struct inode * inode, struct file * file, 1087static int ubd_ioctl(struct inode * inode, struct file * file,
1057 unsigned int cmd, unsigned long arg) 1088 unsigned int cmd, unsigned long arg)
1058{ 1089{
1059 struct ubd *dev = inode->i_bdev->bd_disk->private_data; 1090 struct ubd *ubd_dev = inode->i_bdev->bd_disk->private_data;
1060 struct hd_driveid ubd_id = { 1091 struct hd_driveid ubd_id = {
1061 .cyls = 0, 1092 .cyls = 0,
1062 .heads = 128, 1093 .heads = 128,
@@ -1066,7 +1097,7 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
1066 switch (cmd) { 1097 switch (cmd) {
1067 struct cdrom_volctrl volume; 1098 struct cdrom_volctrl volume;
1068 case HDIO_GET_IDENTITY: 1099 case HDIO_GET_IDENTITY:
1069 ubd_id.cyls = dev->size / (128 * 32 * 512); 1100 ubd_id.cyls = ubd_dev->size / (128 * 32 * 512);
1070 if(copy_to_user((char __user *) arg, (char *) &ubd_id, 1101 if(copy_to_user((char __user *) arg, (char *) &ubd_id,
1071 sizeof(ubd_id))) 1102 sizeof(ubd_id)))
1072 return(-EFAULT); 1103 return(-EFAULT);
@@ -1353,8 +1384,8 @@ void do_io(struct io_thread_req *req)
1353 */ 1384 */
1354int kernel_fd = -1; 1385int kernel_fd = -1;
1355 1386
1356/* Only changed by the io thread */ 1387/* Only changed by the io thread. XXX: currently unused. */
1357int io_count = 0; 1388static int io_count = 0;
1358 1389
1359int io_thread(void *arg) 1390int io_thread(void *arg)
1360{ 1391{
diff --git a/arch/um/include/mconsole_kern.h b/arch/um/include/mconsole_kern.h
index d0b690197fd7..1ea6d928e1cd 100644
--- a/arch/um/include/mconsole_kern.h
+++ b/arch/um/include/mconsole_kern.h
@@ -14,6 +14,7 @@ struct mconsole_entry {
14 struct mc_request request; 14 struct mc_request request;
15}; 15};
16 16
17/* All these methods are called in process context. */
17struct mc_device { 18struct mc_device {
18 struct list_head list; 19 struct list_head list;
19 char *name; 20 char *name;
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index 68ed24df5c8f..e36f92b463ce 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -14,6 +14,7 @@ SECTIONS
14 * is remapped.*/ 14 * is remapped.*/
15 __binary_start = .; 15 __binary_start = .;
16 . = ALIGN(4096); /* Init code and data */ 16 . = ALIGN(4096); /* Init code and data */
17 _text = .;
17 _stext = .; 18 _stext = .;
18 __init_begin = .; 19 __init_begin = .;
19 .init.text : { 20 .init.text : {
diff --git a/arch/um/kernel/tt/tracer.c b/arch/um/kernel/tt/tracer.c
index 9882342206ec..b9195355075a 100644
--- a/arch/um/kernel/tt/tracer.c
+++ b/arch/um/kernel/tt/tracer.c
@@ -176,7 +176,6 @@ struct {
176int signal_index[32]; 176int signal_index[32];
177int nsignals = 0; 177int nsignals = 0;
178int debug_trace = 0; 178int debug_trace = 0;
179extern int io_nsignals, io_count, intr_count;
180 179
181extern void signal_usr1(int sig); 180extern void signal_usr1(int sig);
182 181
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index 8eca47a6ff08..f6301274cf3c 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -25,6 +25,7 @@ SECTIONS
25 . = ALIGN(4096); /* Init code and data */ 25 . = ALIGN(4096); /* Init code and data */
26#endif 26#endif
27 27
28 _text = .;
28 _stext = .; 29 _stext = .;
29 __init_begin = .; 30 __init_begin = .;
30 .init.text : { 31 .init.text : {
diff --git a/arch/um/os-Linux/sys-i386/tls.c b/arch/um/os-Linux/sys-i386/tls.c
index 6e945ab45843..256532034c62 100644
--- a/arch/um/os-Linux/sys-i386/tls.c
+++ b/arch/um/os-Linux/sys-i386/tls.c
@@ -1,6 +1,9 @@
1#include <errno.h> 1#include <errno.h>
2#include <linux/unistd.h> 2#include <linux/unistd.h>
3
3#include <sys/syscall.h> 4#include <sys/syscall.h>
5#include <unistd.h>
6
4#include "sysdep/tls.h" 7#include "sysdep/tls.h"
5#include "user_util.h" 8#include "user_util.h"
6 9
diff --git a/arch/um/os-Linux/tls.c b/arch/um/os-Linux/tls.c
index a2de2580b8af..9f7999f27c77 100644
--- a/arch/um/os-Linux/tls.c
+++ b/arch/um/os-Linux/tls.c
@@ -1,6 +1,7 @@
1#include <errno.h> 1#include <errno.h>
2#include <sys/ptrace.h> 2#include <sys/ptrace.h>
3#include <sys/syscall.h> 3#include <sys/syscall.h>
4#include <unistd.h>
4#include <asm/ldt.h> 5#include <asm/ldt.h>
5#include "sysdep/tls.h" 6#include "sysdep/tls.h"
6#include "uml-config.h" 7#include "uml-config.h"
diff --git a/arch/um/sys-i386/unmap.c b/arch/um/sys-i386/unmap.c
index 8e55cd5d3d07..1b0ad0e4adcd 100644
--- a/arch/um/sys-i386/unmap.c
+++ b/arch/um/sys-i386/unmap.c
@@ -5,17 +5,20 @@
5 5
6#include <linux/mman.h> 6#include <linux/mman.h>
7#include <asm/unistd.h> 7#include <asm/unistd.h>
8#include <sys/syscall.h>
9 8
9static int errno;
10
11static inline _syscall2(int,munmap,void *,start,size_t,len)
12static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
10int switcheroo(int fd, int prot, void *from, void *to, int size) 13int switcheroo(int fd, int prot, void *from, void *to, int size)
11{ 14{
12 if (syscall(__NR_munmap, to, size) < 0){ 15 if(munmap(to, size) < 0){
13 return(-1); 16 return(-1);
14 } 17 }
15 if (syscall(__NR_mmap2, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){ 18 if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
16 return(-1); 19 return(-1);
17 } 20 }
18 if (syscall(__NR_munmap, from, size) < 0){ 21 if(munmap(from, size) < 0){
19 return(-1); 22 return(-1);
20 } 23 }
21 return(0); 24 return(0);
diff --git a/arch/um/sys-x86_64/unmap.c b/arch/um/sys-x86_64/unmap.c
index 57c9286a701b..f4a4bffd8a18 100644
--- a/arch/um/sys-x86_64/unmap.c
+++ b/arch/um/sys-x86_64/unmap.c
@@ -5,17 +5,20 @@
5 5
6#include <linux/mman.h> 6#include <linux/mman.h>
7#include <asm/unistd.h> 7#include <asm/unistd.h>
8#include <sys/syscall.h>
9 8
9static int errno;
10
11static inline _syscall2(int,munmap,void *,start,size_t,len)
12static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
10int switcheroo(int fd, int prot, void *from, void *to, int size) 13int switcheroo(int fd, int prot, void *from, void *to, int size)
11{ 14{
12 if (syscall(__NR_munmap, to, size) < 0){ 15 if(munmap(to, size) < 0){
13 return(-1); 16 return(-1);
14 } 17 }
15 if (syscall(__NR_mmap, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){ 18 if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
16 return(-1); 19 return(-1);
17 } 20 }
18 if (syscall(__NR_munmap, from, size) < 0){ 21 if(munmap(from, size) < 0){
19 return(-1); 22 return(-1);
20 } 23 }
21 return(0); 24 return(0);
diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c
index a6ba9951e86c..0e0a266d976f 100644
--- a/arch/x86_64/ia32/ia32_signal.c
+++ b/arch/x86_64/ia32/ia32_signal.c
@@ -579,6 +579,11 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
579 regs->rsp = (unsigned long) frame; 579 regs->rsp = (unsigned long) frame;
580 regs->rip = (unsigned long) ka->sa.sa_handler; 580 regs->rip = (unsigned long) ka->sa.sa_handler;
581 581
582 /* Make -mregparm=3 work */
583 regs->rax = sig;
584 regs->rdx = (unsigned long) &frame->info;
585 regs->rcx = (unsigned long) &frame->uc;
586
582 asm volatile("movl %0,%%ds" :: "r" (__USER32_DS)); 587 asm volatile("movl %0,%%ds" :: "r" (__USER32_DS));
583 asm volatile("movl %0,%%es" :: "r" (__USER32_DS)); 588 asm volatile("movl %0,%%es" :: "r" (__USER32_DS));
584 589
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index d3d76136f53a..1d9c3c70a9a0 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -456,6 +456,9 @@ static void cfq_add_rq_rb(struct request *rq)
456 */ 456 */
457 while ((__alias = elv_rb_add(&cfqq->sort_list, rq)) != NULL) 457 while ((__alias = elv_rb_add(&cfqq->sort_list, rq)) != NULL)
458 cfq_dispatch_insert(cfqd->queue, __alias); 458 cfq_dispatch_insert(cfqd->queue, __alias);
459
460 if (!cfq_cfqq_on_rr(cfqq))
461 cfq_add_cfqq_rr(cfqd, cfqq);
459} 462}
460 463
461static inline void 464static inline void
@@ -1215,11 +1218,12 @@ static inline void changed_ioprio(struct cfq_io_context *cic)
1215{ 1218{
1216 struct cfq_data *cfqd = cic->key; 1219 struct cfq_data *cfqd = cic->key;
1217 struct cfq_queue *cfqq; 1220 struct cfq_queue *cfqq;
1221 unsigned long flags;
1218 1222
1219 if (unlikely(!cfqd)) 1223 if (unlikely(!cfqd))
1220 return; 1224 return;
1221 1225
1222 spin_lock(cfqd->queue->queue_lock); 1226 spin_lock_irqsave(cfqd->queue->queue_lock, flags);
1223 1227
1224 cfqq = cic->cfqq[ASYNC]; 1228 cfqq = cic->cfqq[ASYNC];
1225 if (cfqq) { 1229 if (cfqq) {
@@ -1236,7 +1240,7 @@ static inline void changed_ioprio(struct cfq_io_context *cic)
1236 if (cfqq) 1240 if (cfqq)
1237 cfq_mark_cfqq_prio_changed(cfqq); 1241 cfq_mark_cfqq_prio_changed(cfqq);
1238 1242
1239 spin_unlock(cfqd->queue->queue_lock); 1243 spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
1240} 1244}
1241 1245
1242static void cfq_ioc_set_ioprio(struct io_context *ioc) 1246static void cfq_ioc_set_ioprio(struct io_context *ioc)
@@ -1362,6 +1366,7 @@ cfq_cic_link(struct cfq_data *cfqd, struct io_context *ioc,
1362 struct rb_node **p; 1366 struct rb_node **p;
1363 struct rb_node *parent; 1367 struct rb_node *parent;
1364 struct cfq_io_context *__cic; 1368 struct cfq_io_context *__cic;
1369 unsigned long flags;
1365 void *k; 1370 void *k;
1366 1371
1367 cic->ioc = ioc; 1372 cic->ioc = ioc;
@@ -1391,9 +1396,9 @@ restart:
1391 rb_link_node(&cic->rb_node, parent, p); 1396 rb_link_node(&cic->rb_node, parent, p);
1392 rb_insert_color(&cic->rb_node, &ioc->cic_root); 1397 rb_insert_color(&cic->rb_node, &ioc->cic_root);
1393 1398
1394 spin_lock_irq(cfqd->queue->queue_lock); 1399 spin_lock_irqsave(cfqd->queue->queue_lock, flags);
1395 list_add(&cic->queue_list, &cfqd->cic_list); 1400 list_add(&cic->queue_list, &cfqd->cic_list);
1396 spin_unlock_irq(cfqd->queue->queue_lock); 1401 spin_unlock_irqrestore(cfqd->queue->queue_lock, flags);
1397} 1402}
1398 1403
1399/* 1404/*
@@ -1650,9 +1655,6 @@ static void cfq_insert_request(request_queue_t *q, struct request *rq)
1650 1655
1651 cfq_add_rq_rb(rq); 1656 cfq_add_rq_rb(rq);
1652 1657
1653 if (!cfq_cfqq_on_rr(cfqq))
1654 cfq_add_cfqq_rr(cfqd, cfqq);
1655
1656 list_add_tail(&rq->queuelist, &cfqq->fifo); 1658 list_add_tail(&rq->queuelist, &cfqq->fifo);
1657 1659
1658 cfq_rq_enqueued(cfqd, cfqq, rq); 1660 cfq_rq_enqueued(cfqd, cfqq, rq);
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 136066583c68..c7b1dac8bee9 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -2999,6 +2999,7 @@ void generic_make_request(struct bio *bio)
2999{ 2999{
3000 request_queue_t *q; 3000 request_queue_t *q;
3001 sector_t maxsector; 3001 sector_t maxsector;
3002 sector_t old_sector;
3002 int ret, nr_sectors = bio_sectors(bio); 3003 int ret, nr_sectors = bio_sectors(bio);
3003 dev_t old_dev; 3004 dev_t old_dev;
3004 3005
@@ -3027,7 +3028,7 @@ void generic_make_request(struct bio *bio)
3027 * NOTE: we don't repeat the blk_size check for each new device. 3028 * NOTE: we don't repeat the blk_size check for each new device.
3028 * Stacking drivers are expected to know what they are doing. 3029 * Stacking drivers are expected to know what they are doing.
3029 */ 3030 */
3030 maxsector = -1; 3031 old_sector = -1;
3031 old_dev = 0; 3032 old_dev = 0;
3032 do { 3033 do {
3033 char b[BDEVNAME_SIZE]; 3034 char b[BDEVNAME_SIZE];
@@ -3061,15 +3062,30 @@ end_io:
3061 */ 3062 */
3062 blk_partition_remap(bio); 3063 blk_partition_remap(bio);
3063 3064
3064 if (maxsector != -1) 3065 if (old_sector != -1)
3065 blk_add_trace_remap(q, bio, old_dev, bio->bi_sector, 3066 blk_add_trace_remap(q, bio, old_dev, bio->bi_sector,
3066 maxsector); 3067 old_sector);
3067 3068
3068 blk_add_trace_bio(q, bio, BLK_TA_QUEUE); 3069 blk_add_trace_bio(q, bio, BLK_TA_QUEUE);
3069 3070
3070 maxsector = bio->bi_sector; 3071 old_sector = bio->bi_sector;
3071 old_dev = bio->bi_bdev->bd_dev; 3072 old_dev = bio->bi_bdev->bd_dev;
3072 3073
3074 maxsector = bio->bi_bdev->bd_inode->i_size >> 9;
3075 if (maxsector) {
3076 sector_t sector = bio->bi_sector;
3077
3078 if (maxsector < nr_sectors || maxsector - nr_sectors < sector) {
3079 /*
3080 * This may well happen - partitions are not checked
3081 * to make sure they are within the size of the
3082 * whole device.
3083 */
3084 handle_bad_sector(bio);
3085 goto end_io;
3086 }
3087 }
3088
3073 ret = q->make_request_fn(q, bio); 3089 ret = q->make_request_fn(q, bio);
3074 } while (ret); 3090 } while (ret);
3075} 3091}
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index cef2e70d64f8..988f8bbd14ff 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -736,8 +736,7 @@ static int ahci_softreset(struct ata_port *ap, unsigned int *class)
736 } 736 }
737 737
738 /* check BUSY/DRQ, perform Command List Override if necessary */ 738 /* check BUSY/DRQ, perform Command List Override if necessary */
739 ahci_tf_read(ap, &tf); 739 if (ahci_check_status(ap) & (ATA_BUSY | ATA_DRQ)) {
740 if (tf.command & (ATA_BUSY | ATA_DRQ)) {
741 rc = ahci_clo(ap); 740 rc = ahci_clo(ap);
742 741
743 if (rc == -EOPNOTSUPP) { 742 if (rc == -EOPNOTSUPP) {
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 5250187ffce2..720174d628fa 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -126,8 +126,7 @@ enum {
126 ich6_sata = 7, 126 ich6_sata = 7,
127 ich6_sata_ahci = 8, 127 ich6_sata_ahci = 8,
128 ich6m_sata_ahci = 9, 128 ich6m_sata_ahci = 9,
129 ich7m_sata_ahci = 10, 129 ich8_sata_ahci = 10,
130 ich8_sata_ahci = 11,
131 130
132 /* constants for mapping table */ 131 /* constants for mapping table */
133 P0 = 0, /* port 0 */ 132 P0 = 0, /* port 0 */
@@ -227,7 +226,7 @@ static const struct pci_device_id piix_pci_tbl[] = {
227 /* 82801GB/GR/GH (ICH7, identical to ICH6) */ 226 /* 82801GB/GR/GH (ICH7, identical to ICH6) */
228 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 227 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
229 /* 2801GBM/GHM (ICH7M, identical to ICH6M) */ 228 /* 2801GBM/GHM (ICH7M, identical to ICH6M) */
230 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich7m_sata_ahci }, 229 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6m_sata_ahci },
231 /* Enterprise Southbridge 2 (where's the datasheet?) */ 230 /* Enterprise Southbridge 2 (where's the datasheet?) */
232 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci }, 231 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
233 /* SATA Controller 1 IDE (ICH8, no datasheet yet) */ 232 /* SATA Controller 1 IDE (ICH8, no datasheet yet) */
@@ -399,23 +398,10 @@ static const struct piix_map_db ich6m_map_db = {
399 .mask = 0x3, 398 .mask = 0x3,
400 .port_enable = 0x5, 399 .port_enable = 0x5,
401 .present_shift = 4, 400 .present_shift = 4,
402 .map = {
403 /* PM PS SM SS MAP */
404 { P0, P2, RV, RV }, /* 00b */
405 { RV, RV, RV, RV },
406 { P0, P2, IDE, IDE }, /* 10b */
407 { RV, RV, RV, RV },
408 },
409};
410
411static const struct piix_map_db ich7m_map_db = {
412 .mask = 0x3,
413 .port_enable = 0x5,
414 .present_shift = 4,
415 401
416 /* Map 01b isn't specified in the doc but some notebooks use 402 /* Map 01b isn't specified in the doc but some notebooks use
417 * it anyway. ATM, the only case spotted carries subsystem ID 403 * it anyway. MAP 01b have been spotted on both ICH6M and
418 * 1025:0107. This is the only difference from ich6m. 404 * ICH7M.
419 */ 405 */
420 .map = { 406 .map = {
421 /* PM PS SM SS MAP */ 407 /* PM PS SM SS MAP */
@@ -445,7 +431,6 @@ static const struct piix_map_db *piix_map_db_table[] = {
445 [ich6_sata] = &ich6_map_db, 431 [ich6_sata] = &ich6_map_db,
446 [ich6_sata_ahci] = &ich6_map_db, 432 [ich6_sata_ahci] = &ich6_map_db,
447 [ich6m_sata_ahci] = &ich6m_map_db, 433 [ich6m_sata_ahci] = &ich6m_map_db,
448 [ich7m_sata_ahci] = &ich7m_map_db,
449 [ich8_sata_ahci] = &ich8_map_db, 434 [ich8_sata_ahci] = &ich8_map_db,
450}; 435};
451 436
@@ -556,19 +541,7 @@ static struct ata_port_info piix_port_info[] = {
556 .port_ops = &piix_sata_ops, 541 .port_ops = &piix_sata_ops,
557 }, 542 },
558 543
559 /* ich7m_sata_ahci: 10 */ 544 /* ich8_sata_ahci: 10 */
560 {
561 .sht = &piix_sht,
562 .flags = ATA_FLAG_SATA |
563 PIIX_FLAG_CHECKINTR | PIIX_FLAG_SCR |
564 PIIX_FLAG_AHCI,
565 .pio_mask = 0x1f, /* pio0-4 */
566 .mwdma_mask = 0x07, /* mwdma0-2 */
567 .udma_mask = 0x7f, /* udma0-6 */
568 .port_ops = &piix_sata_ops,
569 },
570
571 /* ich8_sata_ahci: 11 */
572 { 545 {
573 .sht = &piix_sht, 546 .sht = &piix_sht,
574 .flags = ATA_FLAG_SATA | 547 .flags = ATA_FLAG_SATA |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 83728a9457ad..a8fd0c3e59b3 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -6122,7 +6122,6 @@ EXPORT_SYMBOL_GPL(ata_std_prereset);
6122EXPORT_SYMBOL_GPL(ata_std_softreset); 6122EXPORT_SYMBOL_GPL(ata_std_softreset);
6123EXPORT_SYMBOL_GPL(sata_std_hardreset); 6123EXPORT_SYMBOL_GPL(sata_std_hardreset);
6124EXPORT_SYMBOL_GPL(ata_std_postreset); 6124EXPORT_SYMBOL_GPL(ata_std_postreset);
6125EXPORT_SYMBOL_GPL(ata_dev_revalidate);
6126EXPORT_SYMBOL_GPL(ata_dev_classify); 6125EXPORT_SYMBOL_GPL(ata_dev_classify);
6127EXPORT_SYMBOL_GPL(ata_dev_pair); 6126EXPORT_SYMBOL_GPL(ata_dev_pair);
6128EXPORT_SYMBOL_GPL(ata_port_disable); 6127EXPORT_SYMBOL_GPL(ata_port_disable);
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index a5ecb71390a9..0ed263be652a 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -53,6 +53,7 @@ extern unsigned ata_exec_internal(struct ata_device *dev,
53extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd); 53extern unsigned int ata_do_simple_cmd(struct ata_device *dev, u8 cmd);
54extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class, 54extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
55 int post_reset, u16 *id); 55 int post_reset, u16 *id);
56extern int ata_dev_revalidate(struct ata_device *dev, int post_reset);
56extern int ata_dev_configure(struct ata_device *dev, int print_info); 57extern int ata_dev_configure(struct ata_device *dev, int print_info);
57extern int sata_down_spd_limit(struct ata_port *ap); 58extern int sata_down_spd_limit(struct ata_port *ap);
58extern int sata_set_spd_needed(struct ata_port *ap); 59extern int sata_set_spd_needed(struct ata_port *ap);
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index 323b60710806..d65ebfd7c7b2 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -117,10 +117,14 @@ static const struct pci_device_id nv_pci_tbl[] = {
117 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC }, 117 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA), GENERIC },
118 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC }, 118 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA2), GENERIC },
119 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC }, 119 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_SATA3), GENERIC },
120 { PCI_VDEVICE(NVIDIA, 0x045c), GENERIC }, 120 { PCI_VDEVICE(NVIDIA, 0x045c), GENERIC }, /* MCP65 */
121 { PCI_VDEVICE(NVIDIA, 0x045d), GENERIC }, 121 { PCI_VDEVICE(NVIDIA, 0x045d), GENERIC }, /* MCP65 */
122 { PCI_VDEVICE(NVIDIA, 0x045e), GENERIC }, 122 { PCI_VDEVICE(NVIDIA, 0x045e), GENERIC }, /* MCP65 */
123 { PCI_VDEVICE(NVIDIA, 0x045f), GENERIC }, 123 { PCI_VDEVICE(NVIDIA, 0x045f), GENERIC }, /* MCP65 */
124 { PCI_VDEVICE(NVIDIA, 0x0550), GENERIC }, /* MCP67 */
125 { PCI_VDEVICE(NVIDIA, 0x0551), GENERIC }, /* MCP67 */
126 { PCI_VDEVICE(NVIDIA, 0x0552), GENERIC }, /* MCP67 */
127 { PCI_VDEVICE(NVIDIA, 0x0553), GENERIC }, /* MCP67 */
124 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, 128 { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID,
125 PCI_ANY_ID, PCI_ANY_ID, 129 PCI_ANY_ID, PCI_ANY_ID,
126 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC }, 130 PCI_CLASS_STORAGE_IDE<<8, 0xffff00, GENERIC },
diff --git a/drivers/ata/sata_sis.c b/drivers/ata/sata_sis.c
index 0738f52463a9..9d1235ba06b1 100644
--- a/drivers/ata/sata_sis.c
+++ b/drivers/ata/sata_sis.c
@@ -240,7 +240,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
240 struct ata_probe_ent *probe_ent = NULL; 240 struct ata_probe_ent *probe_ent = NULL;
241 int rc; 241 int rc;
242 u32 genctl; 242 u32 genctl;
243 struct ata_port_info *ppi[2]; 243 struct ata_port_info pi = sis_port_info, *ppi[2] = { &pi, &pi };
244 int pci_dev_busy = 0; 244 int pci_dev_busy = 0;
245 u8 pmr; 245 u8 pmr;
246 u8 port2_start; 246 u8 port2_start;
@@ -265,27 +265,20 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
265 if (rc) 265 if (rc)
266 goto err_out_regions; 266 goto err_out_regions;
267 267
268 ppi[0] = ppi[1] = &sis_port_info;
269 probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
270 if (!probe_ent) {
271 rc = -ENOMEM;
272 goto err_out_regions;
273 }
274
275 /* check and see if the SCRs are in IO space or PCI cfg space */ 268 /* check and see if the SCRs are in IO space or PCI cfg space */
276 pci_read_config_dword(pdev, SIS_GENCTL, &genctl); 269 pci_read_config_dword(pdev, SIS_GENCTL, &genctl);
277 if ((genctl & GENCTL_IOMAPPED_SCR) == 0) 270 if ((genctl & GENCTL_IOMAPPED_SCR) == 0)
278 probe_ent->port_flags |= SIS_FLAG_CFGSCR; 271 pi.flags |= SIS_FLAG_CFGSCR;
279 272
280 /* if hardware thinks SCRs are in IO space, but there are 273 /* if hardware thinks SCRs are in IO space, but there are
281 * no IO resources assigned, change to PCI cfg space. 274 * no IO resources assigned, change to PCI cfg space.
282 */ 275 */
283 if ((!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) && 276 if ((!(pi.flags & SIS_FLAG_CFGSCR)) &&
284 ((pci_resource_start(pdev, SIS_SCR_PCI_BAR) == 0) || 277 ((pci_resource_start(pdev, SIS_SCR_PCI_BAR) == 0) ||
285 (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) { 278 (pci_resource_len(pdev, SIS_SCR_PCI_BAR) < 128))) {
286 genctl &= ~GENCTL_IOMAPPED_SCR; 279 genctl &= ~GENCTL_IOMAPPED_SCR;
287 pci_write_config_dword(pdev, SIS_GENCTL, genctl); 280 pci_write_config_dword(pdev, SIS_GENCTL, genctl);
288 probe_ent->port_flags |= SIS_FLAG_CFGSCR; 281 pi.flags |= SIS_FLAG_CFGSCR;
289 } 282 }
290 283
291 pci_read_config_byte(pdev, SIS_PMR, &pmr); 284 pci_read_config_byte(pdev, SIS_PMR, &pmr);
@@ -306,6 +299,12 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
306 port2_start = 0x20; 299 port2_start = 0x20;
307 } 300 }
308 301
302 probe_ent = ata_pci_init_native_mode(pdev, ppi, ATA_PORT_PRIMARY | ATA_PORT_SECONDARY);
303 if (!probe_ent) {
304 rc = -ENOMEM;
305 goto err_out_regions;
306 }
307
309 if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) { 308 if (!(probe_ent->port_flags & SIS_FLAG_CFGSCR)) {
310 probe_ent->port[0].scr_addr = 309 probe_ent->port[0].scr_addr =
311 pci_resource_start(pdev, SIS_SCR_PCI_BAR); 310 pci_resource_start(pdev, SIS_SCR_PCI_BAR);
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index 845b8680032a..cbc07250b898 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -282,7 +282,7 @@ static void bluecard_write_wakeup(bluecard_info_t *info)
282 clear_bit(ready_bit, &(info->tx_state)); 282 clear_bit(ready_bit, &(info->tx_state));
283 283
284 if (bt_cb(skb)->pkt_type & 0x80) { 284 if (bt_cb(skb)->pkt_type & 0x80) {
285 DECLARE_WAIT_QUEUE_HEAD(wq); 285 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
286 DEFINE_WAIT(wait); 286 DEFINE_WAIT(wait);
287 287
288 unsigned char baud_reg; 288 unsigned char baud_reg;
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index e72ab36a5494..9f306880491a 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -48,7 +48,7 @@ static int ide_generic_all; /* Set to claim all devices */
48static int __init ide_generic_all_on(char *unused) 48static int __init ide_generic_all_on(char *unused)
49{ 49{
50 ide_generic_all = 1; 50 ide_generic_all = 1;
51 printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers."); 51 printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n");
52 return 1; 52 return 1;
53} 53}
54__setup("all-generic-ide", ide_generic_all_on); 54__setup("all-generic-ide", ide_generic_all_on);
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index 8a7b8fab6238..31e5cc49d61a 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -64,6 +64,7 @@
64#include <linux/ethtool.h> 64#include <linux/ethtool.h>
65#include <asm/uaccess.h> 65#include <asm/uaccess.h>
66#include <asm/delay.h> 66#include <asm/delay.h>
67#include <asm/unaligned.h>
67#include <net/arp.h> 68#include <net/arp.h>
68 69
69#include "config_roms.h" 70#include "config_roms.h"
@@ -491,7 +492,7 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
491 int i; 492 int i;
492 struct eth1394_priv *priv = netdev_priv(dev); 493 struct eth1394_priv *priv = netdev_priv(dev);
493 struct hpsb_host *host = priv->host; 494 struct hpsb_host *host = priv->host;
494 u64 guid = *((u64*)&(host->csr.rom->bus_info_data[3])); 495 u64 guid = get_unaligned((u64*)&(host->csr.rom->bus_info_data[3]));
495 u16 maxpayload = 1 << (host->csr.max_rec + 1); 496 u16 maxpayload = 1 << (host->csr.max_rec + 1);
496 int max_speed = IEEE1394_SPEED_MAX; 497 int max_speed = IEEE1394_SPEED_MAX;
497 498
@@ -514,8 +515,8 @@ static void ether1394_reset_priv (struct net_device *dev, int set_mtu)
514 ETHER1394_GASP_OVERHEAD))); 515 ETHER1394_GASP_OVERHEAD)));
515 516
516 /* Set our hardware address while we're at it */ 517 /* Set our hardware address while we're at it */
517 *(u64*)dev->dev_addr = guid; 518 memcpy(dev->dev_addr, &guid, sizeof(u64));
518 *(u64*)dev->broadcast = ~0x0ULL; 519 memset(dev->broadcast, 0xff, sizeof(u64));
519 } 520 }
520 521
521 spin_unlock_irqrestore (&priv->lock, flags); 522 spin_unlock_irqrestore (&priv->lock, flags);
@@ -894,6 +895,7 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
894 u16 maxpayload; 895 u16 maxpayload;
895 struct eth1394_node_ref *node; 896 struct eth1394_node_ref *node;
896 struct eth1394_node_info *node_info; 897 struct eth1394_node_info *node_info;
898 __be64 guid;
897 899
898 /* Sanity check. MacOSX seems to be sending us 131 in this 900 /* Sanity check. MacOSX seems to be sending us 131 in this
899 * field (atleast on my Panther G5). Not sure why. */ 901 * field (atleast on my Panther G5). Not sure why. */
@@ -902,8 +904,9 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
902 904
903 maxpayload = min(eth1394_speedto_maxpayload[sspd], (u16)(1 << (max_rec + 1))); 905 maxpayload = min(eth1394_speedto_maxpayload[sspd], (u16)(1 << (max_rec + 1)));
904 906
907 guid = get_unaligned(&arp1394->s_uniq_id);
905 node = eth1394_find_node_guid(&priv->ip_node_list, 908 node = eth1394_find_node_guid(&priv->ip_node_list,
906 be64_to_cpu(arp1394->s_uniq_id)); 909 be64_to_cpu(guid));
907 if (!node) { 910 if (!node) {
908 return 0; 911 return 0;
909 } 912 }
@@ -931,10 +934,9 @@ static inline u16 ether1394_parse_encap(struct sk_buff *skb,
931 arp_ptr += arp->ar_pln; /* skip over sender IP addr */ 934 arp_ptr += arp->ar_pln; /* skip over sender IP addr */
932 935
933 if (arp->ar_op == htons(ARPOP_REQUEST)) 936 if (arp->ar_op == htons(ARPOP_REQUEST))
934 /* just set ARP req target unique ID to 0 */ 937 memset(arp_ptr, 0, sizeof(u64));
935 *((u64*)arp_ptr) = 0;
936 else 938 else
937 *((u64*)arp_ptr) = *((u64*)dev->dev_addr); 939 memcpy(arp_ptr, dev->dev_addr, sizeof(u64));
938 } 940 }
939 941
940 /* Now add the ethernet header. */ 942 /* Now add the ethernet header. */
@@ -1675,8 +1677,10 @@ static int ether1394_tx (struct sk_buff *skb, struct net_device *dev)
1675 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF]) 1677 if (max_payload < dg_size + hdr_type_len[ETH1394_HDR_LF_UF])
1676 priv->bc_dgl++; 1678 priv->bc_dgl++;
1677 } else { 1679 } else {
1680 __be64 guid = get_unaligned((u64 *)eth->h_dest);
1681
1678 node = eth1394_find_node_guid(&priv->ip_node_list, 1682 node = eth1394_find_node_guid(&priv->ip_node_list,
1679 be64_to_cpu(*(u64*)eth->h_dest)); 1683 be64_to_cpu(guid));
1680 if (!node) { 1684 if (!node) {
1681 ret = -EAGAIN; 1685 ret = -EAGAIN;
1682 goto fail; 1686 goto fail;
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c
index aca165d43aa0..d8d256dadddf 100644
--- a/drivers/isdn/gigaset/common.c
+++ b/drivers/isdn/gigaset/common.c
@@ -616,7 +616,7 @@ static struct bc_state *gigaset_initbcs(struct bc_state *bcs,
616 } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL) 616 } else if ((bcs->skb = dev_alloc_skb(SBUFSIZE + HW_HDR_LEN)) != NULL)
617 skb_reserve(bcs->skb, HW_HDR_LEN); 617 skb_reserve(bcs->skb, HW_HDR_LEN);
618 else { 618 else {
619 dev_warn(cs->dev, "could not allocate skb\n"); 619 gig_dbg(DEBUG_INIT, "could not allocate skb\n");
620 bcs->inputstate |= INS_skip_frame; 620 bcs->inputstate |= INS_skip_frame;
621 } 621 }
622 622
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index a625576fdeeb..08a40f4e4f60 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -915,8 +915,6 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
915 char *result, unsigned int maxlen) 915 char *result, unsigned int maxlen)
916{ 916{
917 struct crypt_config *cc = (struct crypt_config *) ti->private; 917 struct crypt_config *cc = (struct crypt_config *) ti->private;
918 const char *cipher;
919 const char *chainmode = NULL;
920 unsigned int sz = 0; 918 unsigned int sz = 0;
921 919
922 switch (type) { 920 switch (type) {
@@ -925,14 +923,11 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
925 break; 923 break;
926 924
927 case STATUSTYPE_TABLE: 925 case STATUSTYPE_TABLE:
928 cipher = crypto_blkcipher_name(cc->tfm);
929
930 chainmode = cc->chainmode;
931
932 if (cc->iv_mode) 926 if (cc->iv_mode)
933 DMEMIT("%s-%s-%s ", cipher, chainmode, cc->iv_mode); 927 DMEMIT("%s-%s-%s ", cc->cipher, cc->chainmode,
928 cc->iv_mode);
934 else 929 else
935 DMEMIT("%s-%s ", cipher, chainmode); 930 DMEMIT("%s-%s ", cc->cipher, cc->chainmode);
936 931
937 if (cc->key_size > 0) { 932 if (cc->key_size > 0) {
938 if ((maxlen - sz) < ((cc->key_size << 1) + 1)) 933 if ((maxlen - sz) < ((cc->key_size << 1) + 1))
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 01a5a702b037..a2350640384b 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -124,7 +124,7 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
124int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg, 124int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
125 unsigned long timeout, struct i2o_dma *dma) 125 unsigned long timeout, struct i2o_dma *dma)
126{ 126{
127 DECLARE_WAIT_QUEUE_HEAD(wq); 127 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
128 struct i2o_exec_wait *wait; 128 struct i2o_exec_wait *wait;
129 static u32 tcntxt = 0x80000000; 129 static u32 tcntxt = 0x80000000;
130 unsigned long flags; 130 unsigned long flags;
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index e38846eb51fa..28c17d1ca5cb 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2112,7 +2112,7 @@ config SKGE
2112 2112
2113config SKY2 2113config SKY2
2114 tristate "SysKonnect Yukon2 support (EXPERIMENTAL)" 2114 tristate "SysKonnect Yukon2 support (EXPERIMENTAL)"
2115 depends on PCI && EXPERIMENTAL 2115 depends on PCI
2116 select CRC32 2116 select CRC32
2117 ---help--- 2117 ---help---
2118 This driver supports Gigabit Ethernet adapters based on the 2118 This driver supports Gigabit Ethernet adapters based on the
@@ -2120,8 +2120,8 @@ config SKY2
2120 Marvell 88E8021/88E8022/88E8035/88E8036/88E8038/88E8050/88E8052/ 2120 Marvell 88E8021/88E8022/88E8035/88E8036/88E8038/88E8050/88E8052/
2121 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21 2121 88E8053/88E8055/88E8061/88E8062, SysKonnect SK-9E21D/SK-9S21
2122 2122
2123 This driver does not support the original Yukon chipset: a seperate 2123 There is companion driver for the older Marvell Yukon and
2124 driver, skge, is provided for Yukon-based adapters. 2124 Genesis based adapters: skge.
2125 2125
2126 To compile this driver as a module, choose M here: the module 2126 To compile this driver as a module, choose M here: the module
2127 will be called sky2. This is recommended. 2127 will be called sky2. This is recommended.
diff --git a/drivers/net/arm/ep93xx_eth.c b/drivers/net/arm/ep93xx_eth.c
index 127561c782fd..8ebd68e2af98 100644
--- a/drivers/net/arm/ep93xx_eth.c
+++ b/drivers/net/arm/ep93xx_eth.c
@@ -193,12 +193,9 @@ static struct net_device_stats *ep93xx_get_stats(struct net_device *dev)
193static int ep93xx_rx(struct net_device *dev, int *budget) 193static int ep93xx_rx(struct net_device *dev, int *budget)
194{ 194{
195 struct ep93xx_priv *ep = netdev_priv(dev); 195 struct ep93xx_priv *ep = netdev_priv(dev);
196 int tail_offset;
197 int rx_done; 196 int rx_done;
198 int processed; 197 int processed;
199 198
200 tail_offset = rdl(ep, REG_RXSTSQCURADD) - ep->descs_dma_addr;
201
202 rx_done = 0; 199 rx_done = 0;
203 processed = 0; 200 processed = 0;
204 while (*budget > 0) { 201 while (*budget > 0) {
@@ -211,36 +208,28 @@ static int ep93xx_rx(struct net_device *dev, int *budget)
211 208
212 entry = ep->rx_pointer; 209 entry = ep->rx_pointer;
213 rstat = ep->descs->rstat + entry; 210 rstat = ep->descs->rstat + entry;
214 if ((void *)rstat - (void *)ep->descs == tail_offset) { 211
212 rstat0 = rstat->rstat0;
213 rstat1 = rstat->rstat1;
214 if (!(rstat0 & RSTAT0_RFP) || !(rstat1 & RSTAT1_RFP)) {
215 rx_done = 1; 215 rx_done = 1;
216 break; 216 break;
217 } 217 }
218 218
219 rstat0 = rstat->rstat0;
220 rstat1 = rstat->rstat1;
221 rstat->rstat0 = 0; 219 rstat->rstat0 = 0;
222 rstat->rstat1 = 0; 220 rstat->rstat1 = 0;
223 221
224 if (!(rstat0 & RSTAT0_RFP))
225 printk(KERN_CRIT "ep93xx_rx: buffer not done "
226 " %.8x %.8x\n", rstat0, rstat1);
227 if (!(rstat0 & RSTAT0_EOF)) 222 if (!(rstat0 & RSTAT0_EOF))
228 printk(KERN_CRIT "ep93xx_rx: not end-of-frame " 223 printk(KERN_CRIT "ep93xx_rx: not end-of-frame "
229 " %.8x %.8x\n", rstat0, rstat1); 224 " %.8x %.8x\n", rstat0, rstat1);
230 if (!(rstat0 & RSTAT0_EOB)) 225 if (!(rstat0 & RSTAT0_EOB))
231 printk(KERN_CRIT "ep93xx_rx: not end-of-buffer " 226 printk(KERN_CRIT "ep93xx_rx: not end-of-buffer "
232 " %.8x %.8x\n", rstat0, rstat1); 227 " %.8x %.8x\n", rstat0, rstat1);
233 if (!(rstat1 & RSTAT1_RFP))
234 printk(KERN_CRIT "ep93xx_rx: buffer1 not done "
235 " %.8x %.8x\n", rstat0, rstat1);
236 if ((rstat1 & RSTAT1_BUFFER_INDEX) >> 16 != entry) 228 if ((rstat1 & RSTAT1_BUFFER_INDEX) >> 16 != entry)
237 printk(KERN_CRIT "ep93xx_rx: entry mismatch " 229 printk(KERN_CRIT "ep93xx_rx: entry mismatch "
238 " %.8x %.8x\n", rstat0, rstat1); 230 " %.8x %.8x\n", rstat0, rstat1);
239 231
240 if (!(rstat0 & RSTAT0_RWE)) { 232 if (!(rstat0 & RSTAT0_RWE)) {
241 printk(KERN_NOTICE "ep93xx_rx: receive error "
242 " %.8x %.8x\n", rstat0, rstat1);
243
244 ep->stats.rx_errors++; 233 ep->stats.rx_errors++;
245 if (rstat0 & RSTAT0_OE) 234 if (rstat0 & RSTAT0_OE)
246 ep->stats.rx_fifo_errors++; 235 ep->stats.rx_fifo_errors++;
@@ -301,13 +290,8 @@ err:
301 290
302static int ep93xx_have_more_rx(struct ep93xx_priv *ep) 291static int ep93xx_have_more_rx(struct ep93xx_priv *ep)
303{ 292{
304 struct ep93xx_rstat *rstat; 293 struct ep93xx_rstat *rstat = ep->descs->rstat + ep->rx_pointer;
305 int tail_offset; 294 return !!((rstat->rstat0 & RSTAT0_RFP) && (rstat->rstat1 & RSTAT1_RFP));
306
307 rstat = ep->descs->rstat + ep->rx_pointer;
308 tail_offset = rdl(ep, REG_RXSTSQCURADD) - ep->descs_dma_addr;
309
310 return !((void *)rstat - (void *)ep->descs == tail_offset);
311} 295}
312 296
313static int ep93xx_poll(struct net_device *dev, int *budget) 297static int ep93xx_poll(struct net_device *dev, int *budget)
@@ -347,7 +331,7 @@ static int ep93xx_xmit(struct sk_buff *skb, struct net_device *dev)
347 struct ep93xx_priv *ep = netdev_priv(dev); 331 struct ep93xx_priv *ep = netdev_priv(dev);
348 int entry; 332 int entry;
349 333
350 if (unlikely(skb->len) > MAX_PKT_SIZE) { 334 if (unlikely(skb->len > MAX_PKT_SIZE)) {
351 ep->stats.tx_dropped++; 335 ep->stats.tx_dropped++;
352 dev_kfree_skb(skb); 336 dev_kfree_skb(skb);
353 return NETDEV_TX_OK; 337 return NETDEV_TX_OK;
@@ -379,10 +363,8 @@ static int ep93xx_xmit(struct sk_buff *skb, struct net_device *dev)
379static void ep93xx_tx_complete(struct net_device *dev) 363static void ep93xx_tx_complete(struct net_device *dev)
380{ 364{
381 struct ep93xx_priv *ep = netdev_priv(dev); 365 struct ep93xx_priv *ep = netdev_priv(dev);
382 int tail_offset;
383 int wake; 366 int wake;
384 367
385 tail_offset = rdl(ep, REG_TXSTSQCURADD) - ep->descs_dma_addr;
386 wake = 0; 368 wake = 0;
387 369
388 spin_lock(&ep->tx_pending_lock); 370 spin_lock(&ep->tx_pending_lock);
@@ -393,15 +375,13 @@ static void ep93xx_tx_complete(struct net_device *dev)
393 375
394 entry = ep->tx_clean_pointer; 376 entry = ep->tx_clean_pointer;
395 tstat = ep->descs->tstat + entry; 377 tstat = ep->descs->tstat + entry;
396 if ((void *)tstat - (void *)ep->descs == tail_offset)
397 break;
398 378
399 tstat0 = tstat->tstat0; 379 tstat0 = tstat->tstat0;
380 if (!(tstat0 & TSTAT0_TXFP))
381 break;
382
400 tstat->tstat0 = 0; 383 tstat->tstat0 = 0;
401 384
402 if (!(tstat0 & TSTAT0_TXFP))
403 printk(KERN_CRIT "ep93xx_tx_complete: buffer not done "
404 " %.8x\n", tstat0);
405 if (tstat0 & TSTAT0_FA) 385 if (tstat0 & TSTAT0_FA)
406 printk(KERN_CRIT "ep93xx_tx_complete: frame aborted " 386 printk(KERN_CRIT "ep93xx_tx_complete: frame aborted "
407 " %.8x\n", tstat0); 387 " %.8x\n", tstat0);
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 4873dc610d22..7db3c8af0894 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -102,7 +102,7 @@ static void enable_mac(struct net_device *, int);
102// externs 102// externs
103extern int get_ethernet_addr(char *ethernet_addr); 103extern int get_ethernet_addr(char *ethernet_addr);
104extern void str2eaddr(unsigned char *ea, unsigned char *str); 104extern void str2eaddr(unsigned char *ea, unsigned char *str);
105extern char * __init prom_getcmdline(void); 105extern char * prom_getcmdline(void);
106 106
107/* 107/*
108 * Theory of operation 108 * Theory of operation
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index eb7d44de59ff..4538c99733fd 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -586,8 +586,8 @@ int ehea_sense_port_attr(struct ehea_port *port)
586 u64 hret; 586 u64 hret;
587 struct hcp_ehea_port_cb0 *cb0; 587 struct hcp_ehea_port_cb0 *cb0;
588 588
589 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 589 cb0 = kzalloc(H_CB_ALIGNMENT, GFP_ATOMIC); /* May be called via */
590 if (!cb0) { 590 if (!cb0) { /* ehea_neq_tasklet() */
591 ehea_error("no mem for cb0"); 591 ehea_error("no mem for cb0");
592 ret = -ENOMEM; 592 ret = -ENOMEM;
593 goto out; 593 goto out;
@@ -765,8 +765,7 @@ static void ehea_parse_eqe(struct ehea_adapter *adapter, u64 eqe)
765 765
766 if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) { 766 if (EHEA_BMASK_GET(NEQE_PORT_UP, eqe)) {
767 if (!netif_carrier_ok(port->netdev)) { 767 if (!netif_carrier_ok(port->netdev)) {
768 ret = ehea_sense_port_attr( 768 ret = ehea_sense_port_attr(port);
769 port);
770 if (ret) { 769 if (ret) {
771 ehea_error("failed resensing port " 770 ehea_error("failed resensing port "
772 "attributes"); 771 "attributes");
@@ -1502,7 +1501,7 @@ static void ehea_promiscuous(struct net_device *dev, int enable)
1502 if ((enable && port->promisc) || (!enable && !port->promisc)) 1501 if ((enable && port->promisc) || (!enable && !port->promisc))
1503 return; 1502 return;
1504 1503
1505 cb7 = kzalloc(H_CB_ALIGNMENT, GFP_KERNEL); 1504 cb7 = kzalloc(H_CB_ALIGNMENT, GFP_ATOMIC);
1506 if (!cb7) { 1505 if (!cb7) {
1507 ehea_error("no mem for cb7"); 1506 ehea_error("no mem for cb7");
1508 goto out; 1507 goto out;
@@ -1606,7 +1605,7 @@ static void ehea_add_multicast_entry(struct ehea_port* port, u8* mc_mac_addr)
1606 struct ehea_mc_list *ehea_mcl_entry; 1605 struct ehea_mc_list *ehea_mcl_entry;
1607 u64 hret; 1606 u64 hret;
1608 1607
1609 ehea_mcl_entry = kzalloc(sizeof(*ehea_mcl_entry), GFP_KERNEL); 1608 ehea_mcl_entry = kzalloc(sizeof(*ehea_mcl_entry), GFP_ATOMIC);
1610 if (!ehea_mcl_entry) { 1609 if (!ehea_mcl_entry) {
1611 ehea_error("no mem for mcl_entry"); 1610 ehea_error("no mem for mcl_entry");
1612 return; 1611 return;
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index be8a66e702b0..3b4c47875935 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -15,8 +15,7 @@
15* 15*
16* This program is free software; you can redistribute it and/or modify 16* This program is free software; you can redistribute it and/or modify
17* it under the terms of the GNU General Public License as published by 17* it under the terms of the GNU General Public License as published by
18* the Free Software Foundation; either version 2 of the License, or 18* the Free Software Foundation; either version 2 of the License.
19* (at your option) any later version.
20* 19*
21* This program is distributed in the hope that it will be useful, 20* This program is distributed in the hope that it will be useful,
22* but WITHOUT ANY WARRANTY; without even the implied warranty of 21* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index fdbb0d7213b0..806081b59733 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -2416,7 +2416,6 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2416 * firmware image, and set tx.boundary to 4KB. 2416 * firmware image, and set tx.boundary to 4KB.
2417 */ 2417 */
2418 2418
2419#define PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE 0x0132
2420#define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7 2419#define PCI_DEVICE_ID_INTEL_E5000_PCIE23 0x25f7
2421#define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa 2420#define PCI_DEVICE_ID_INTEL_E5000_PCIE47 0x25fa
2422 2421
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index a231ab7d28dd..33569ec9dbfc 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -5985,6 +5985,11 @@ static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba,
5985 ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1; 5985 ((RxD3_t*)rxdp)->Buffer1_ptr = *temp1;
5986 } else { 5986 } else {
5987 *skb = dev_alloc_skb(size); 5987 *skb = dev_alloc_skb(size);
5988 if (!(*skb)) {
5989 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb failed\n",
5990 dev->name);
5991 return -ENOMEM;
5992 }
5988 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2 = 5993 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2 =
5989 pci_map_single(sp->pdev, (*skb)->data, 5994 pci_map_single(sp->pdev, (*skb)->data,
5990 dev->mtu + 4, 5995 dev->mtu + 4,
@@ -6007,7 +6012,11 @@ static int set_rxd_buffer_pointer(nic_t *sp, RxD_t *rxdp, buffAdd_t *ba,
6007 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2; 6012 ((RxD3_t*)rxdp)->Buffer2_ptr = *temp2;
6008 } else { 6013 } else {
6009 *skb = dev_alloc_skb(size); 6014 *skb = dev_alloc_skb(size);
6010 6015 if (!(*skb)) {
6016 DBG_PRINT(ERR_DBG, "%s: dev_alloc_skb failed\n",
6017 dev->name);
6018 return -ENOMEM;
6019 }
6011 ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0 = 6020 ((RxD3_t*)rxdp)->Buffer0_ptr = *temp0 =
6012 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN, 6021 pci_map_single(sp->pdev, ba->ba_0, BUF0_LEN,
6013 PCI_DMA_FROMDEVICE); 6022 PCI_DMA_FROMDEVICE);
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index e7e414928f89..b2949035f66a 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -11,8 +11,7 @@
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by 13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or 14 * the Free Software Foundation; either version 2 of the License.
15 * (at your option) any later version.
16 * 15 *
17 * This program is distributed in the hope that it will be useful, 16 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 95efdb5bbbe1..16616f5440d0 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -10,8 +10,7 @@
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by 12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or 13 * the Free Software Foundation; either version 2 of the License.
14 * (at your option) any later version.
15 * 14 *
16 * This program is distributed in the hope that it will be useful, 15 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -3239,7 +3238,11 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
3239 dev->poll = sky2_poll; 3238 dev->poll = sky2_poll;
3240 dev->weight = NAPI_WEIGHT; 3239 dev->weight = NAPI_WEIGHT;
3241#ifdef CONFIG_NET_POLL_CONTROLLER 3240#ifdef CONFIG_NET_POLL_CONTROLLER
3242 dev->poll_controller = sky2_netpoll; 3241 /* Network console (only works on port 0)
3242 * because netpoll makes assumptions about NAPI
3243 */
3244 if (port == 0)
3245 dev->poll_controller = sky2_netpoll;
3243#endif 3246#endif
3244 3247
3245 sky2 = netdev_priv(dev); 3248 sky2 = netdev_priv(dev);
diff --git a/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
index 4f756960db2a..cb7dbb63c9d9 100644
--- a/drivers/net/tokenring/proteon.c
+++ b/drivers/net/tokenring/proteon.c
@@ -370,6 +370,10 @@ static int __init proteon_init(void)
370 dev->dma = dma[i]; 370 dev->dma = dma[i];
371 pdev = platform_device_register_simple("proteon", 371 pdev = platform_device_register_simple("proteon",
372 i, NULL, 0); 372 i, NULL, 0);
373 if (IS_ERR(pdev)) {
374 free_netdev(dev);
375 continue;
376 }
373 err = setup_card(dev, &pdev->dev); 377 err = setup_card(dev, &pdev->dev);
374 if (!err) { 378 if (!err) {
375 proteon_dev[i] = pdev; 379 proteon_dev[i] = pdev;
@@ -385,9 +389,10 @@ static int __init proteon_init(void)
385 /* Probe for cards. */ 389 /* Probe for cards. */
386 if (num == 0) { 390 if (num == 0) {
387 printk(KERN_NOTICE "proteon.c: No cards found.\n"); 391 printk(KERN_NOTICE "proteon.c: No cards found.\n");
388 return (-ENODEV); 392 platform_driver_unregister(&proteon_driver);
393 return -ENODEV;
389 } 394 }
390 return (0); 395 return 0;
391} 396}
392 397
393static void __exit proteon_cleanup(void) 398static void __exit proteon_cleanup(void)
diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
index d6ba41cf3110..33afea31d87b 100644
--- a/drivers/net/tokenring/skisa.c
+++ b/drivers/net/tokenring/skisa.c
@@ -380,6 +380,10 @@ static int __init sk_isa_init(void)
380 dev->dma = dma[i]; 380 dev->dma = dma[i];
381 pdev = platform_device_register_simple("skisa", 381 pdev = platform_device_register_simple("skisa",
382 i, NULL, 0); 382 i, NULL, 0);
383 if (IS_ERR(pdev)) {
384 free_netdev(dev);
385 continue;
386 }
383 err = setup_card(dev, &pdev->dev); 387 err = setup_card(dev, &pdev->dev);
384 if (!err) { 388 if (!err) {
385 sk_isa_dev[i] = pdev; 389 sk_isa_dev[i] = pdev;
@@ -395,9 +399,10 @@ static int __init sk_isa_init(void)
395 /* Probe for cards. */ 399 /* Probe for cards. */
396 if (num == 0) { 400 if (num == 0) {
397 printk(KERN_NOTICE "skisa.c: No cards found.\n"); 401 printk(KERN_NOTICE "skisa.c: No cards found.\n");
398 return (-ENODEV); 402 platform_driver_unregister(&sk_isa_driver);
403 return -ENODEV;
399 } 404 }
400 return (0); 405 return 0;
401} 406}
402 407
403static void __exit sk_isa_cleanup(void) 408static void __exit sk_isa_cleanup(void)
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 58b7efbb0750..b5d0d7fb647a 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -127,7 +127,7 @@ config LANMEDIA
127# There is no way to detect a Sealevel board. Force it modular 127# There is no way to detect a Sealevel board. Force it modular
128config SEALEVEL_4021 128config SEALEVEL_4021
129 tristate "Sealevel Systems 4021 support" 129 tristate "Sealevel Systems 4021 support"
130 depends on WAN && ISA && m && ISA_DMA_API 130 depends on WAN && ISA && m && ISA_DMA_API && INET
131 help 131 help
132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter. 132 This is a driver for the Sealevel Systems ACB 56 serial I/O adapter.
133 133
diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c
index dcf46add3adf..5c322dfb79f6 100644
--- a/drivers/net/wan/n2.c
+++ b/drivers/net/wan/n2.c
@@ -500,7 +500,7 @@ static int __init n2_init(void)
500#ifdef MODULE 500#ifdef MODULE
501 printk(KERN_INFO "n2: no card initialized\n"); 501 printk(KERN_INFO "n2: no card initialized\n");
502#endif 502#endif
503 return -ENOSYS; /* no parameters specified, abort */ 503 return -EINVAL; /* no parameters specified, abort */
504 } 504 }
505 505
506 printk(KERN_INFO "%s\n", version); 506 printk(KERN_INFO "%s\n", version);
@@ -538,11 +538,11 @@ static int __init n2_init(void)
538 n2_run(io, irq, ram, valid[0], valid[1]); 538 n2_run(io, irq, ram, valid[0], valid[1]);
539 539
540 if (*hw == '\x0') 540 if (*hw == '\x0')
541 return first_card ? 0 : -ENOSYS; 541 return first_card ? 0 : -EINVAL;
542 }while(*hw++ == ':'); 542 }while(*hw++ == ':');
543 543
544 printk(KERN_ERR "n2: invalid hardware parameters\n"); 544 printk(KERN_ERR "n2: invalid hardware parameters\n");
545 return first_card ? 0 : -ENOSYS; 545 return first_card ? 0 : -EINVAL;
546} 546}
547 547
548 548
diff --git a/drivers/scsi/dpt/dpti_i2o.h b/drivers/scsi/dpt/dpti_i2o.h
index b3fa7ed71faf..5a49216fe4cf 100644
--- a/drivers/scsi/dpt/dpti_i2o.h
+++ b/drivers/scsi/dpt/dpti_i2o.h
@@ -49,7 +49,7 @@
49 49
50#include <linux/wait.h> 50#include <linux/wait.h>
51typedef wait_queue_head_t adpt_wait_queue_head_t; 51typedef wait_queue_head_t adpt_wait_queue_head_t;
52#define ADPT_DECLARE_WAIT_QUEUE_HEAD(wait) DECLARE_WAIT_QUEUE_HEAD(wait) 52#define ADPT_DECLARE_WAIT_QUEUE_HEAD(wait) DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wait)
53typedef wait_queue_t adpt_wait_queue_t; 53typedef wait_queue_t adpt_wait_queue_t;
54 54
55/* 55/*
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 2d95ac9c32c1..e31f6122106f 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -1153,7 +1153,7 @@ static int __imm_attach(struct parport *pb)
1153{ 1153{
1154 struct Scsi_Host *host; 1154 struct Scsi_Host *host;
1155 imm_struct *dev; 1155 imm_struct *dev;
1156 DECLARE_WAIT_QUEUE_HEAD(waiting); 1156 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
1157 DEFINE_WAIT(wait); 1157 DEFINE_WAIT(wait);
1158 int ports; 1158 int ports;
1159 int modes, ppb; 1159 int modes, ppb;
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index d586c3d3b0d0..19c79a0549a7 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -305,7 +305,7 @@ lpfc_do_work(void *p)
305{ 305{
306 struct lpfc_hba *phba = p; 306 struct lpfc_hba *phba = p;
307 int rc; 307 int rc;
308 DECLARE_WAIT_QUEUE_HEAD(work_waitq); 308 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(work_waitq);
309 309
310 set_user_nice(current, -20); 310 set_user_nice(current, -20);
311 phba->work_wait = &work_waitq; 311 phba->work_wait = &work_waitq;
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index 24a1779b9af4..582f5ea4e84e 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -2983,7 +2983,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba,
2983 struct lpfc_iocbq * prspiocbq, 2983 struct lpfc_iocbq * prspiocbq,
2984 uint32_t timeout) 2984 uint32_t timeout)
2985{ 2985{
2986 DECLARE_WAIT_QUEUE_HEAD(done_q); 2986 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q);
2987 long timeleft, timeout_req = 0; 2987 long timeleft, timeout_req = 0;
2988 int retval = IOCB_SUCCESS; 2988 int retval = IOCB_SUCCESS;
2989 uint32_t creg_val; 2989 uint32_t creg_val;
@@ -3061,7 +3061,7 @@ int
3061lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq, 3061lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
3062 uint32_t timeout) 3062 uint32_t timeout)
3063{ 3063{
3064 DECLARE_WAIT_QUEUE_HEAD(done_q); 3064 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(done_q);
3065 DECLARE_WAITQUEUE(wq_entry, current); 3065 DECLARE_WAITQUEUE(wq_entry, current);
3066 uint32_t timeleft = 0; 3066 uint32_t timeleft = 0;
3067 int retval; 3067 int retval;
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index b0eba39f208a..89a2a9f11e41 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -1012,7 +1012,7 @@ static LIST_HEAD(ppa_hosts);
1012static int __ppa_attach(struct parport *pb) 1012static int __ppa_attach(struct parport *pb)
1013{ 1013{
1014 struct Scsi_Host *host; 1014 struct Scsi_Host *host;
1015 DECLARE_WAIT_QUEUE_HEAD(waiting); 1015 DECLARE_WAIT_QUEUE_HEAD_ONSTACK(waiting);
1016 DEFINE_WAIT(wait); 1016 DEFINE_WAIT(wait);
1017 ppa_struct *dev; 1017 ppa_struct *dev;
1018 int ports; 1018 int ports;
diff --git a/drivers/scsi/qla4xxx/Kconfig b/drivers/scsi/qla4xxx/Kconfig
index 08a07f0b8d94..69cbff3f57cf 100644
--- a/drivers/scsi/qla4xxx/Kconfig
+++ b/drivers/scsi/qla4xxx/Kconfig
@@ -1,6 +1,6 @@
1config SCSI_QLA_ISCSI 1config SCSI_QLA_ISCSI
2 tristate "QLogic ISP4XXX host adapter family support" 2 tristate "QLogic ISP4XXX host adapter family support"
3 depends on PCI && SCSI 3 depends on PCI && SCSI && NET
4 select SCSI_ISCSI_ATTRS 4 select SCSI_ISCSI_ATTRS
5 ---help--- 5 ---help---
6 This driver supports the QLogic 40xx (ISP4XXX) iSCSI host 6 This driver supports the QLogic 40xx (ISP4XXX) iSCSI host
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index ff4fa25f9fd1..711bd1511439 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -921,7 +921,7 @@ static void handle_dma_error_intr(void *arg, uint32_t other_ir)
921{ 921{
922 struct ioc4_port *port = (struct ioc4_port *)arg; 922 struct ioc4_port *port = (struct ioc4_port *)arg;
923 struct hooks *hooks = port->ip_hooks; 923 struct hooks *hooks = port->ip_hooks;
924 unsigned int flags; 924 unsigned long flags;
925 925
926 spin_lock_irqsave(&port->ip_lock, flags); 926 spin_lock_irqsave(&port->ip_lock, flags);
927 927
@@ -1834,7 +1834,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
1834 struct ioc4_port *port = (struct ioc4_port *)arg; 1834 struct ioc4_port *port = (struct ioc4_port *)arg;
1835 struct hooks *hooks = port->ip_hooks; 1835 struct hooks *hooks = port->ip_hooks;
1836 unsigned int rx_high_rd_aborted = 0; 1836 unsigned int rx_high_rd_aborted = 0;
1837 unsigned int flags; 1837 unsigned long flags;
1838 struct uart_port *the_port; 1838 struct uart_port *the_port;
1839 int loop_counter; 1839 int loop_counter;
1840 1840
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index cf3d20eb781c..40873635d80e 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -554,7 +554,7 @@ static int usbnet_stop (struct net_device *net)
554{ 554{
555 struct usbnet *dev = netdev_priv(net); 555 struct usbnet *dev = netdev_priv(net);
556 int temp; 556 int temp;
557 DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup); 557 DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup);
558 DECLARE_WAITQUEUE (wait, current); 558 DECLARE_WAITQUEUE (wait, current);
559 559
560 netif_stop_queue (net); 560 netif_stop_queue (net);
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index fe1488374f62..e3993213d10e 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -19,7 +19,7 @@
19#include <linux/backlight.h> 19#include <linux/backlight.h>
20 20
21#include <asm/cpu/dac.h> 21#include <asm/cpu/dac.h>
22#include <asm/hp6xx/hp6xx.h> 22#include <asm/hp6xx.h>
23#include <asm/hd64461.h> 23#include <asm/hd64461.h>
24 24
25#define HP680_MAX_INTENSITY 255 25#define HP680_MAX_INTENSITY 255
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index bad0e98fb3b6..9a40bbecf76b 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -157,7 +157,7 @@ static int offb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
157 out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue)); 157 out_le32(par->cmap_adr + 0xb4, (red << 16 | green << 8 | blue));
158 break; 158 break;
159 case cmap_gxt2000: 159 case cmap_gxt2000:
160 out_le32((unsigned __iomem *) par->cmap_adr + regno, 160 out_le32(((unsigned __iomem *) par->cmap_adr) + regno,
161 (red << 16 | green << 8 | blue)); 161 (red << 16 | green << 8 | blue));
162 break; 162 break;
163 } 163 }
@@ -213,7 +213,7 @@ static int offb_blank(int blank, struct fb_info *info)
213 out_le32(par->cmap_adr + 0xb4, 0); 213 out_le32(par->cmap_adr + 0xb4, 0);
214 break; 214 break;
215 case cmap_gxt2000: 215 case cmap_gxt2000:
216 out_le32((unsigned __iomem *) par->cmap_adr + i, 216 out_le32(((unsigned __iomem *) par->cmap_adr) + i,
217 0); 217 0);
218 break; 218 break;
219 } 219 }
@@ -226,13 +226,23 @@ static int offb_blank(int blank, struct fb_info *info)
226static void __iomem *offb_map_reg(struct device_node *np, int index, 226static void __iomem *offb_map_reg(struct device_node *np, int index,
227 unsigned long offset, unsigned long size) 227 unsigned long offset, unsigned long size)
228{ 228{
229 struct resource r; 229 const u32 *addrp;
230 230 u64 asize, taddr;
231 if (of_address_to_resource(np, index, &r)) 231 unsigned int flags;
232 return 0; 232
233 if ((r.start + offset + size) > r.end) 233 addrp = of_get_pci_address(np, index, &asize, &flags);
234 return 0; 234 if (addrp == NULL)
235 return ioremap(r.start + offset, size); 235 addrp = of_get_address(np, index, &asize, &flags);
236 if (addrp == NULL)
237 return NULL;
238 if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0)
239 return NULL;
240 if ((offset + size) > asize)
241 return NULL;
242 taddr = of_translate_address(np, addrp);
243 if (taddr == OF_BAD_ADDR)
244 return NULL;
245 return ioremap(taddr + offset, size);
236} 246}
237 247
238static void __init offb_init_fb(const char *name, const char *full_name, 248static void __init offb_init_fb(const char *name, const char *full_name,
@@ -289,7 +299,6 @@ static void __init offb_init_fb(const char *name, const char *full_name,
289 299
290 par->cmap_type = cmap_unknown; 300 par->cmap_type = cmap_unknown;
291 if (depth == 8) { 301 if (depth == 8) {
292 /* Palette hacks disabled for now */
293 if (dp && !strncmp(name, "ATY,Rage128", 11)) { 302 if (dp && !strncmp(name, "ATY,Rage128", 11)) {
294 par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff); 303 par->cmap_adr = offb_map_reg(dp, 2, 0, 0x1fff);
295 if (par->cmap_adr) 304 if (par->cmap_adr)
@@ -313,7 +322,8 @@ static void __init offb_init_fb(const char *name, const char *full_name,
313 ioremap(base + 0x7ff000, 0x1000) + 0xcc0; 322 ioremap(base + 0x7ff000, 0x1000) + 0xcc0;
314 par->cmap_data = par->cmap_adr + 1; 323 par->cmap_data = par->cmap_adr + 1;
315 par->cmap_type = cmap_m64; 324 par->cmap_type = cmap_m64;
316 } else if (dp && device_is_compatible(dp, "pci1014,b7")) { 325 } else if (dp && (device_is_compatible(dp, "pci1014,b7") ||
326 device_is_compatible(dp, "pci1014,21c"))) {
317 par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000); 327 par->cmap_adr = offb_map_reg(dp, 0, 0x6000, 0x1000);
318 if (par->cmap_adr) 328 if (par->cmap_adr)
319 par->cmap_type = cmap_gxt2000; 329 par->cmap_type = cmap_gxt2000;
@@ -433,7 +443,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
433 pp = get_property(dp, "linux,bootx-linebytes", &len); 443 pp = get_property(dp, "linux,bootx-linebytes", &len);
434 if (pp == NULL) 444 if (pp == NULL)
435 pp = get_property(dp, "linebytes", &len); 445 pp = get_property(dp, "linebytes", &len);
436 if (pp && len == sizeof(u32)) 446 if (pp && len == sizeof(u32) && (*pp != 0xffffffffu))
437 pitch = *pp; 447 pitch = *pp;
438 else 448 else
439 pitch = width * ((depth + 7) / 8); 449 pitch = width * ((depth + 7) / 8);
@@ -496,7 +506,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
496 offb_init_fb(no_real_node ? "bootx" : dp->name, 506 offb_init_fb(no_real_node ? "bootx" : dp->name,
497 no_real_node ? "display" : dp->full_name, 507 no_real_node ? "display" : dp->full_name,
498 width, height, depth, pitch, address, 508 width, height, depth, pitch, address,
499 no_real_node ? dp : NULL); 509 no_real_node ? NULL : dp);
500 } 510 }
501} 511}
502 512
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 702b88cbd91d..36c0e7af9d0f 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -642,34 +642,47 @@ static void free_bd_holder(struct bd_holder *bo)
642} 642}
643 643
644/** 644/**
645 * find_bd_holder - find matching struct bd_holder from the block device
646 *
647 * @bdev: struct block device to be searched
648 * @bo: target struct bd_holder
649 *
650 * Returns matching entry with @bo in @bdev->bd_holder_list.
651 * If found, increment the reference count and return the pointer.
652 * If not found, returns NULL.
653 */
654static struct bd_holder *find_bd_holder(struct block_device *bdev,
655 struct bd_holder *bo)
656{
657 struct bd_holder *tmp;
658
659 list_for_each_entry(tmp, &bdev->bd_holder_list, list)
660 if (tmp->sdir == bo->sdir) {
661 tmp->count++;
662 return tmp;
663 }
664
665 return NULL;
666}
667
668/**
645 * add_bd_holder - create sysfs symlinks for bd_claim() relationship 669 * add_bd_holder - create sysfs symlinks for bd_claim() relationship
646 * 670 *
647 * @bdev: block device to be bd_claimed 671 * @bdev: block device to be bd_claimed
648 * @bo: preallocated and initialized by alloc_bd_holder() 672 * @bo: preallocated and initialized by alloc_bd_holder()
649 * 673 *
650 * If there is no matching entry with @bo in @bdev->bd_holder_list, 674 * Add @bo to @bdev->bd_holder_list, create symlinks.
651 * add @bo to the list, create symlinks.
652 * 675 *
653 * Returns 0 if symlinks are created or already there. 676 * Returns 0 if symlinks are created.
654 * Returns -ve if something fails and @bo can be freed. 677 * Returns -ve if something fails.
655 */ 678 */
656static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo) 679static int add_bd_holder(struct block_device *bdev, struct bd_holder *bo)
657{ 680{
658 struct bd_holder *tmp;
659 int ret; 681 int ret;
660 682
661 if (!bo) 683 if (!bo)
662 return -EINVAL; 684 return -EINVAL;
663 685
664 list_for_each_entry(tmp, &bdev->bd_holder_list, list) {
665 if (tmp->sdir == bo->sdir) {
666 tmp->count++;
667 /* We've already done what we need to do here. */
668 free_bd_holder(bo);
669 return 0;
670 }
671 }
672
673 if (!bd_holder_grab_dirs(bdev, bo)) 686 if (!bd_holder_grab_dirs(bdev, bo))
674 return -EBUSY; 687 return -EBUSY;
675 688
@@ -740,7 +753,7 @@ static int bd_claim_by_kobject(struct block_device *bdev, void *holder,
740 struct kobject *kobj) 753 struct kobject *kobj)
741{ 754{
742 int res; 755 int res;
743 struct bd_holder *bo; 756 struct bd_holder *bo, *found;
744 757
745 if (!kobj) 758 if (!kobj)
746 return -EINVAL; 759 return -EINVAL;
@@ -751,9 +764,16 @@ static int bd_claim_by_kobject(struct block_device *bdev, void *holder,
751 764
752 mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_PARTITION); 765 mutex_lock_nested(&bdev->bd_mutex, BD_MUTEX_PARTITION);
753 res = bd_claim(bdev, holder); 766 res = bd_claim(bdev, holder);
754 if (res == 0) 767 if (res == 0) {
755 res = add_bd_holder(bdev, bo); 768 found = find_bd_holder(bdev, bo);
756 if (res) 769 if (found == NULL) {
770 res = add_bd_holder(bdev, bo);
771 if (res)
772 bd_release(bdev);
773 }
774 }
775
776 if (res || found)
757 free_bd_holder(bo); 777 free_bd_holder(bo);
758 mutex_unlock(&bdev->bd_mutex); 778 mutex_unlock(&bdev->bd_mutex);
759 779
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index ed35a9712fa1..f49f105394b7 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -94,25 +94,53 @@ static int ecryptfs_calculate_md5(char *dst,
94 struct ecryptfs_crypt_stat *crypt_stat, 94 struct ecryptfs_crypt_stat *crypt_stat,
95 char *src, int len) 95 char *src, int len)
96{ 96{
97 int rc = 0;
98 struct scatterlist sg; 97 struct scatterlist sg;
98 struct hash_desc desc = {
99 .tfm = crypt_stat->hash_tfm,
100 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
101 };
102 int rc = 0;
99 103
100 mutex_lock(&crypt_stat->cs_md5_tfm_mutex); 104 mutex_lock(&crypt_stat->cs_hash_tfm_mutex);
101 sg_init_one(&sg, (u8 *)src, len); 105 sg_init_one(&sg, (u8 *)src, len);
102 if (!crypt_stat->md5_tfm) { 106 if (!desc.tfm) {
103 crypt_stat->md5_tfm = 107 desc.tfm = crypto_alloc_hash(ECRYPTFS_DEFAULT_HASH, 0,
104 crypto_alloc_tfm("md5", CRYPTO_TFM_REQ_MAY_SLEEP); 108 CRYPTO_ALG_ASYNC);
105 if (!crypt_stat->md5_tfm) { 109 if (IS_ERR(desc.tfm)) {
106 rc = -ENOMEM; 110 rc = PTR_ERR(desc.tfm);
107 ecryptfs_printk(KERN_ERR, "Error attempting to " 111 ecryptfs_printk(KERN_ERR, "Error attempting to "
108 "allocate crypto context\n"); 112 "allocate crypto context; rc = [%d]\n",
113 rc);
109 goto out; 114 goto out;
110 } 115 }
116 crypt_stat->hash_tfm = desc.tfm;
111 } 117 }
112 crypto_digest_init(crypt_stat->md5_tfm); 118 crypto_hash_init(&desc);
113 crypto_digest_update(crypt_stat->md5_tfm, &sg, 1); 119 crypto_hash_update(&desc, &sg, len);
114 crypto_digest_final(crypt_stat->md5_tfm, dst); 120 crypto_hash_final(&desc, dst);
115 mutex_unlock(&crypt_stat->cs_md5_tfm_mutex); 121 mutex_unlock(&crypt_stat->cs_hash_tfm_mutex);
122out:
123 return rc;
124}
125
126int ecryptfs_crypto_api_algify_cipher_name(char **algified_name,
127 char *cipher_name,
128 char *chaining_modifier)
129{
130 int cipher_name_len = strlen(cipher_name);
131 int chaining_modifier_len = strlen(chaining_modifier);
132 int algified_name_len;
133 int rc;
134
135 algified_name_len = (chaining_modifier_len + cipher_name_len + 3);
136 (*algified_name) = kmalloc(algified_name_len, GFP_KERNEL);
137 if (!(algified_name)) {
138 rc = -ENOMEM;
139 goto out;
140 }
141 snprintf((*algified_name), algified_name_len, "%s(%s)",
142 chaining_modifier, cipher_name);
143 rc = 0;
116out: 144out:
117 return rc; 145 return rc;
118} 146}
@@ -178,7 +206,7 @@ ecryptfs_init_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat)
178 memset((void *)crypt_stat, 0, sizeof(struct ecryptfs_crypt_stat)); 206 memset((void *)crypt_stat, 0, sizeof(struct ecryptfs_crypt_stat));
179 mutex_init(&crypt_stat->cs_mutex); 207 mutex_init(&crypt_stat->cs_mutex);
180 mutex_init(&crypt_stat->cs_tfm_mutex); 208 mutex_init(&crypt_stat->cs_tfm_mutex);
181 mutex_init(&crypt_stat->cs_md5_tfm_mutex); 209 mutex_init(&crypt_stat->cs_hash_tfm_mutex);
182 ECRYPTFS_SET_FLAG(crypt_stat->flags, ECRYPTFS_STRUCT_INITIALIZED); 210 ECRYPTFS_SET_FLAG(crypt_stat->flags, ECRYPTFS_STRUCT_INITIALIZED);
183} 211}
184 212
@@ -191,9 +219,9 @@ ecryptfs_init_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat)
191void ecryptfs_destruct_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat) 219void ecryptfs_destruct_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat)
192{ 220{
193 if (crypt_stat->tfm) 221 if (crypt_stat->tfm)
194 crypto_free_tfm(crypt_stat->tfm); 222 crypto_free_blkcipher(crypt_stat->tfm);
195 if (crypt_stat->md5_tfm) 223 if (crypt_stat->hash_tfm)
196 crypto_free_tfm(crypt_stat->md5_tfm); 224 crypto_free_hash(crypt_stat->hash_tfm);
197 memset(crypt_stat, 0, sizeof(struct ecryptfs_crypt_stat)); 225 memset(crypt_stat, 0, sizeof(struct ecryptfs_crypt_stat));
198} 226}
199 227
@@ -203,7 +231,7 @@ void ecryptfs_destruct_mount_crypt_stat(
203 if (mount_crypt_stat->global_auth_tok_key) 231 if (mount_crypt_stat->global_auth_tok_key)
204 key_put(mount_crypt_stat->global_auth_tok_key); 232 key_put(mount_crypt_stat->global_auth_tok_key);
205 if (mount_crypt_stat->global_key_tfm) 233 if (mount_crypt_stat->global_key_tfm)
206 crypto_free_tfm(mount_crypt_stat->global_key_tfm); 234 crypto_free_blkcipher(mount_crypt_stat->global_key_tfm);
207 memset(mount_crypt_stat, 0, sizeof(struct ecryptfs_mount_crypt_stat)); 235 memset(mount_crypt_stat, 0, sizeof(struct ecryptfs_mount_crypt_stat));
208} 236}
209 237
@@ -269,6 +297,11 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
269 struct scatterlist *src_sg, int size, 297 struct scatterlist *src_sg, int size,
270 unsigned char *iv) 298 unsigned char *iv)
271{ 299{
300 struct blkcipher_desc desc = {
301 .tfm = crypt_stat->tfm,
302 .info = iv,
303 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
304 };
272 int rc = 0; 305 int rc = 0;
273 306
274 BUG_ON(!crypt_stat || !crypt_stat->tfm 307 BUG_ON(!crypt_stat || !crypt_stat->tfm
@@ -282,8 +315,8 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
282 } 315 }
283 /* Consider doing this once, when the file is opened */ 316 /* Consider doing this once, when the file is opened */
284 mutex_lock(&crypt_stat->cs_tfm_mutex); 317 mutex_lock(&crypt_stat->cs_tfm_mutex);
285 rc = crypto_cipher_setkey(crypt_stat->tfm, crypt_stat->key, 318 rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key,
286 crypt_stat->key_size); 319 crypt_stat->key_size);
287 if (rc) { 320 if (rc) {
288 ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n", 321 ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n",
289 rc); 322 rc);
@@ -292,7 +325,7 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
292 goto out; 325 goto out;
293 } 326 }
294 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes.\n", size); 327 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes.\n", size);
295 crypto_cipher_encrypt_iv(crypt_stat->tfm, dest_sg, src_sg, size, iv); 328 crypto_blkcipher_encrypt_iv(&desc, dest_sg, src_sg, size);
296 mutex_unlock(&crypt_stat->cs_tfm_mutex); 329 mutex_unlock(&crypt_stat->cs_tfm_mutex);
297out: 330out:
298 return rc; 331 return rc;
@@ -675,12 +708,17 @@ static int decrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
675 struct scatterlist *src_sg, int size, 708 struct scatterlist *src_sg, int size,
676 unsigned char *iv) 709 unsigned char *iv)
677{ 710{
711 struct blkcipher_desc desc = {
712 .tfm = crypt_stat->tfm,
713 .info = iv,
714 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
715 };
678 int rc = 0; 716 int rc = 0;
679 717
680 /* Consider doing this once, when the file is opened */ 718 /* Consider doing this once, when the file is opened */
681 mutex_lock(&crypt_stat->cs_tfm_mutex); 719 mutex_lock(&crypt_stat->cs_tfm_mutex);
682 rc = crypto_cipher_setkey(crypt_stat->tfm, crypt_stat->key, 720 rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key,
683 crypt_stat->key_size); 721 crypt_stat->key_size);
684 if (rc) { 722 if (rc) {
685 ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n", 723 ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n",
686 rc); 724 rc);
@@ -689,8 +727,7 @@ static int decrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
689 goto out; 727 goto out;
690 } 728 }
691 ecryptfs_printk(KERN_DEBUG, "Decrypting [%d] bytes.\n", size); 729 ecryptfs_printk(KERN_DEBUG, "Decrypting [%d] bytes.\n", size);
692 rc = crypto_cipher_decrypt_iv(crypt_stat->tfm, dest_sg, src_sg, size, 730 rc = crypto_blkcipher_decrypt_iv(&desc, dest_sg, src_sg, size);
693 iv);
694 mutex_unlock(&crypt_stat->cs_tfm_mutex); 731 mutex_unlock(&crypt_stat->cs_tfm_mutex);
695 if (rc) { 732 if (rc) {
696 ecryptfs_printk(KERN_ERR, "Error decrypting; rc = [%d]\n", 733 ecryptfs_printk(KERN_ERR, "Error decrypting; rc = [%d]\n",
@@ -759,6 +796,7 @@ ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
759 */ 796 */
760int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat) 797int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
761{ 798{
799 char *full_alg_name;
762 int rc = -EINVAL; 800 int rc = -EINVAL;
763 801
764 if (!crypt_stat->cipher) { 802 if (!crypt_stat->cipher) {
@@ -775,16 +813,24 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
775 goto out; 813 goto out;
776 } 814 }
777 mutex_lock(&crypt_stat->cs_tfm_mutex); 815 mutex_lock(&crypt_stat->cs_tfm_mutex);
778 crypt_stat->tfm = crypto_alloc_tfm(crypt_stat->cipher, 816 rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name,
779 ECRYPTFS_DEFAULT_CHAINING_MODE 817 crypt_stat->cipher, "cbc");
780 | CRYPTO_TFM_REQ_WEAK_KEY); 818 if (rc)
781 mutex_unlock(&crypt_stat->cs_tfm_mutex); 819 goto out;
820 crypt_stat->tfm = crypto_alloc_blkcipher(full_alg_name, 0,
821 CRYPTO_ALG_ASYNC);
822 kfree(full_alg_name);
782 if (!crypt_stat->tfm) { 823 if (!crypt_stat->tfm) {
783 ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): " 824 ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): "
784 "Error initializing cipher [%s]\n", 825 "Error initializing cipher [%s]\n",
785 crypt_stat->cipher); 826 crypt_stat->cipher);
827 mutex_unlock(&crypt_stat->cs_tfm_mutex);
786 goto out; 828 goto out;
787 } 829 }
830 crypto_blkcipher_set_flags(crypt_stat->tfm,
831 (ECRYPTFS_DEFAULT_CHAINING_MODE
832 | CRYPTO_TFM_REQ_WEAK_KEY));
833 mutex_unlock(&crypt_stat->cs_tfm_mutex);
788 rc = 0; 834 rc = 0;
789out: 835out:
790 return rc; 836 return rc;
@@ -1145,28 +1191,28 @@ int ecryptfs_cipher_code_to_string(char *str, u16 cipher_code)
1145int ecryptfs_read_header_region(char *data, struct dentry *dentry, 1191int ecryptfs_read_header_region(char *data, struct dentry *dentry,
1146 struct vfsmount *mnt) 1192 struct vfsmount *mnt)
1147{ 1193{
1148 struct file *file; 1194 struct file *lower_file;
1149 mm_segment_t oldfs; 1195 mm_segment_t oldfs;
1150 int rc; 1196 int rc;
1151 1197
1152 mnt = mntget(mnt); 1198 if ((rc = ecryptfs_open_lower_file(&lower_file, dentry, mnt,
1153 file = dentry_open(dentry, mnt, O_RDONLY); 1199 O_RDONLY))) {
1154 if (IS_ERR(file)) { 1200 printk(KERN_ERR
1155 ecryptfs_printk(KERN_DEBUG, "Error opening file to " 1201 "Error opening lower_file to read header region\n");
1156 "read header region\n");
1157 mntput(mnt);
1158 rc = PTR_ERR(file);
1159 goto out; 1202 goto out;
1160 } 1203 }
1161 file->f_pos = 0; 1204 lower_file->f_pos = 0;
1162 oldfs = get_fs(); 1205 oldfs = get_fs();
1163 set_fs(get_ds()); 1206 set_fs(get_ds());
1164 /* For releases 0.1 and 0.2, all of the header information 1207 /* For releases 0.1 and 0.2, all of the header information
1165 * fits in the first data extent-sized region. */ 1208 * fits in the first data extent-sized region. */
1166 rc = file->f_op->read(file, (char __user *)data, 1209 rc = lower_file->f_op->read(lower_file, (char __user *)data,
1167 ECRYPTFS_DEFAULT_EXTENT_SIZE, &file->f_pos); 1210 ECRYPTFS_DEFAULT_EXTENT_SIZE, &lower_file->f_pos);
1168 set_fs(oldfs); 1211 set_fs(oldfs);
1169 fput(file); 1212 if ((rc = ecryptfs_close_lower_file(lower_file))) {
1213 printk(KERN_ERR "Error closing lower_file\n");
1214 goto out;
1215 }
1170 rc = 0; 1216 rc = 0;
1171out: 1217out:
1172 return rc; 1218 return rc;
@@ -1573,84 +1619,52 @@ out:
1573 1619
1574/** 1620/**
1575 * ecryptfs_process_cipher - Perform cipher initialization. 1621 * ecryptfs_process_cipher - Perform cipher initialization.
1576 * @tfm: Crypto context set by this function
1577 * @key_tfm: Crypto context for key material, set by this function 1622 * @key_tfm: Crypto context for key material, set by this function
1578 * @cipher_name: Name of the cipher. 1623 * @cipher_name: Name of the cipher
1579 * @key_size: Size of the key in bytes. 1624 * @key_size: Size of the key in bytes
1580 * 1625 *
1581 * Returns zero on success. Any crypto_tfm structs allocated here 1626 * Returns zero on success. Any crypto_tfm structs allocated here
1582 * should be released by other functions, such as on a superblock put 1627 * should be released by other functions, such as on a superblock put
1583 * event, regardless of whether this function succeeds for fails. 1628 * event, regardless of whether this function succeeds for fails.
1584 */ 1629 */
1585int 1630int
1586ecryptfs_process_cipher(struct crypto_tfm **tfm, struct crypto_tfm **key_tfm, 1631ecryptfs_process_cipher(struct crypto_blkcipher **key_tfm, char *cipher_name,
1587 char *cipher_name, size_t key_size) 1632 size_t *key_size)
1588{ 1633{
1589 char dummy_key[ECRYPTFS_MAX_KEY_BYTES]; 1634 char dummy_key[ECRYPTFS_MAX_KEY_BYTES];
1635 char *full_alg_name;
1590 int rc; 1636 int rc;
1591 1637
1592 *tfm = *key_tfm = NULL; 1638 *key_tfm = NULL;
1593 if (key_size > ECRYPTFS_MAX_KEY_BYTES) { 1639 if (*key_size > ECRYPTFS_MAX_KEY_BYTES) {
1594 rc = -EINVAL; 1640 rc = -EINVAL;
1595 printk(KERN_ERR "Requested key size is [%Zd] bytes; maximum " 1641 printk(KERN_ERR "Requested key size is [%Zd] bytes; maximum "
1596 "allowable is [%d]\n", key_size, ECRYPTFS_MAX_KEY_BYTES); 1642 "allowable is [%d]\n", *key_size, ECRYPTFS_MAX_KEY_BYTES);
1597 goto out; 1643 goto out;
1598 } 1644 }
1599 *tfm = crypto_alloc_tfm(cipher_name, (ECRYPTFS_DEFAULT_CHAINING_MODE 1645 rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name, cipher_name,
1600 | CRYPTO_TFM_REQ_WEAK_KEY)); 1646 "ecb");
1601 if (!(*tfm)) { 1647 if (rc)
1602 rc = -EINVAL;
1603 printk(KERN_ERR "Unable to allocate crypto cipher with name "
1604 "[%s]\n", cipher_name);
1605 goto out; 1648 goto out;
1606 } 1649 *key_tfm = crypto_alloc_blkcipher(full_alg_name, 0, CRYPTO_ALG_ASYNC);
1607 *key_tfm = crypto_alloc_tfm(cipher_name, CRYPTO_TFM_REQ_WEAK_KEY); 1650 kfree(full_alg_name);
1608 if (!(*key_tfm)) { 1651 if (IS_ERR(*key_tfm)) {
1609 rc = -EINVAL; 1652 rc = PTR_ERR(*key_tfm);
1610 printk(KERN_ERR "Unable to allocate crypto cipher with name " 1653 printk(KERN_ERR "Unable to allocate crypto cipher with name "
1611 "[%s]\n", cipher_name); 1654 "[%s]; rc = [%d]\n", cipher_name, rc);
1612 goto out;
1613 }
1614 if (key_size < crypto_tfm_alg_min_keysize(*tfm)) {
1615 rc = -EINVAL;
1616 printk(KERN_ERR "Request key size is [%Zd]; minimum key size "
1617 "supported by cipher [%s] is [%d]\n", key_size,
1618 cipher_name, crypto_tfm_alg_min_keysize(*tfm));
1619 goto out;
1620 }
1621 if (key_size < crypto_tfm_alg_min_keysize(*key_tfm)) {
1622 rc = -EINVAL;
1623 printk(KERN_ERR "Request key size is [%Zd]; minimum key size "
1624 "supported by cipher [%s] is [%d]\n", key_size,
1625 cipher_name, crypto_tfm_alg_min_keysize(*key_tfm));
1626 goto out; 1655 goto out;
1627 } 1656 }
1628 if (key_size > crypto_tfm_alg_max_keysize(*tfm)) { 1657 crypto_blkcipher_set_flags(*key_tfm, CRYPTO_TFM_REQ_WEAK_KEY);
1629 rc = -EINVAL; 1658 if (*key_size == 0) {
1630 printk(KERN_ERR "Request key size is [%Zd]; maximum key size " 1659 struct blkcipher_alg *alg = crypto_blkcipher_alg(*key_tfm);
1631 "supported by cipher [%s] is [%d]\n", key_size, 1660
1632 cipher_name, crypto_tfm_alg_min_keysize(*tfm)); 1661 *key_size = alg->max_keysize;
1633 goto out;
1634 }
1635 if (key_size > crypto_tfm_alg_max_keysize(*key_tfm)) {
1636 rc = -EINVAL;
1637 printk(KERN_ERR "Request key size is [%Zd]; maximum key size "
1638 "supported by cipher [%s] is [%d]\n", key_size,
1639 cipher_name, crypto_tfm_alg_min_keysize(*key_tfm));
1640 goto out;
1641 }
1642 get_random_bytes(dummy_key, key_size);
1643 rc = crypto_cipher_setkey(*tfm, dummy_key, key_size);
1644 if (rc) {
1645 printk(KERN_ERR "Error attempting to set key of size [%Zd] for "
1646 "cipher [%s]; rc = [%d]\n", key_size, cipher_name, rc);
1647 rc = -EINVAL;
1648 goto out;
1649 } 1662 }
1650 rc = crypto_cipher_setkey(*key_tfm, dummy_key, key_size); 1663 get_random_bytes(dummy_key, *key_size);
1664 rc = crypto_blkcipher_setkey(*key_tfm, dummy_key, *key_size);
1651 if (rc) { 1665 if (rc) {
1652 printk(KERN_ERR "Error attempting to set key of size [%Zd] for " 1666 printk(KERN_ERR "Error attempting to set key of size [%Zd] for "
1653 "cipher [%s]; rc = [%d]\n", key_size, cipher_name, rc); 1667 "cipher [%s]; rc = [%d]\n", *key_size, cipher_name, rc);
1654 rc = -EINVAL; 1668 rc = -EINVAL;
1655 goto out; 1669 goto out;
1656 } 1670 }
diff --git a/fs/ecryptfs/dentry.c b/fs/ecryptfs/dentry.c
index f0d2a433242b..0b9992ab990f 100644
--- a/fs/ecryptfs/dentry.c
+++ b/fs/ecryptfs/dentry.c
@@ -24,6 +24,7 @@
24 24
25#include <linux/dcache.h> 25#include <linux/dcache.h>
26#include <linux/namei.h> 26#include <linux/namei.h>
27#include <linux/mount.h>
27#include "ecryptfs_kernel.h" 28#include "ecryptfs_kernel.h"
28 29
29/** 30/**
@@ -76,8 +77,13 @@ static void ecryptfs_d_release(struct dentry *dentry)
76 if (ecryptfs_dentry_to_private(dentry)) 77 if (ecryptfs_dentry_to_private(dentry))
77 kmem_cache_free(ecryptfs_dentry_info_cache, 78 kmem_cache_free(ecryptfs_dentry_info_cache,
78 ecryptfs_dentry_to_private(dentry)); 79 ecryptfs_dentry_to_private(dentry));
79 if (lower_dentry) 80 if (lower_dentry) {
81 struct vfsmount *lower_mnt =
82 ecryptfs_dentry_to_lower_mnt(dentry);
83
84 mntput(lower_mnt);
80 dput(lower_dentry); 85 dput(lower_dentry);
86 }
81 return; 87 return;
82} 88}
83 89
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 872c9958531a..f992533d1692 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -175,6 +175,7 @@ ecryptfs_get_key_payload_data(struct key *key)
175#define ECRYPTFS_DEFAULT_CIPHER "aes" 175#define ECRYPTFS_DEFAULT_CIPHER "aes"
176#define ECRYPTFS_DEFAULT_KEY_BYTES 16 176#define ECRYPTFS_DEFAULT_KEY_BYTES 16
177#define ECRYPTFS_DEFAULT_CHAINING_MODE CRYPTO_TFM_MODE_CBC 177#define ECRYPTFS_DEFAULT_CHAINING_MODE CRYPTO_TFM_MODE_CBC
178#define ECRYPTFS_DEFAULT_HASH "md5"
178#define ECRYPTFS_TAG_3_PACKET_TYPE 0x8C 179#define ECRYPTFS_TAG_3_PACKET_TYPE 0x8C
179#define ECRYPTFS_TAG_11_PACKET_TYPE 0xED 180#define ECRYPTFS_TAG_11_PACKET_TYPE 0xED
180#define MD5_DIGEST_SIZE 16 181#define MD5_DIGEST_SIZE 16
@@ -204,15 +205,15 @@ struct ecryptfs_crypt_stat {
204 size_t extent_shift; 205 size_t extent_shift;
205 unsigned int extent_mask; 206 unsigned int extent_mask;
206 struct ecryptfs_mount_crypt_stat *mount_crypt_stat; 207 struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
207 struct crypto_tfm *tfm; 208 struct crypto_blkcipher *tfm;
208 struct crypto_tfm *md5_tfm; /* Crypto context for generating 209 struct crypto_hash *hash_tfm; /* Crypto context for generating
209 * the initialization vectors */ 210 * the initialization vectors */
210 unsigned char cipher[ECRYPTFS_MAX_CIPHER_NAME_SIZE]; 211 unsigned char cipher[ECRYPTFS_MAX_CIPHER_NAME_SIZE];
211 unsigned char key[ECRYPTFS_MAX_KEY_BYTES]; 212 unsigned char key[ECRYPTFS_MAX_KEY_BYTES];
212 unsigned char root_iv[ECRYPTFS_MAX_IV_BYTES]; 213 unsigned char root_iv[ECRYPTFS_MAX_IV_BYTES];
213 unsigned char keysigs[ECRYPTFS_MAX_NUM_KEYSIGS][ECRYPTFS_SIG_SIZE_HEX]; 214 unsigned char keysigs[ECRYPTFS_MAX_NUM_KEYSIGS][ECRYPTFS_SIG_SIZE_HEX];
214 struct mutex cs_tfm_mutex; 215 struct mutex cs_tfm_mutex;
215 struct mutex cs_md5_tfm_mutex; 216 struct mutex cs_hash_tfm_mutex;
216 struct mutex cs_mutex; 217 struct mutex cs_mutex;
217}; 218};
218 219
@@ -244,7 +245,7 @@ struct ecryptfs_mount_crypt_stat {
244 struct ecryptfs_auth_tok *global_auth_tok; 245 struct ecryptfs_auth_tok *global_auth_tok;
245 struct key *global_auth_tok_key; 246 struct key *global_auth_tok_key;
246 size_t global_default_cipher_key_size; 247 size_t global_default_cipher_key_size;
247 struct crypto_tfm *global_key_tfm; 248 struct crypto_blkcipher *global_key_tfm;
248 struct mutex global_key_tfm_mutex; 249 struct mutex global_key_tfm_mutex;
249 unsigned char global_default_cipher_name[ECRYPTFS_MAX_CIPHER_NAME_SIZE 250 unsigned char global_default_cipher_name[ECRYPTFS_MAX_CIPHER_NAME_SIZE
250 + 1]; 251 + 1];
@@ -425,6 +426,9 @@ void ecryptfs_destruct_crypt_stat(struct ecryptfs_crypt_stat *crypt_stat);
425void ecryptfs_destruct_mount_crypt_stat( 426void ecryptfs_destruct_mount_crypt_stat(
426 struct ecryptfs_mount_crypt_stat *mount_crypt_stat); 427 struct ecryptfs_mount_crypt_stat *mount_crypt_stat);
427int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat); 428int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat);
429int ecryptfs_crypto_api_algify_cipher_name(char **algified_name,
430 char *cipher_name,
431 char *chaining_modifier);
428int ecryptfs_write_inode_size_to_header(struct file *lower_file, 432int ecryptfs_write_inode_size_to_header(struct file *lower_file,
429 struct inode *lower_inode, 433 struct inode *lower_inode,
430 struct inode *inode); 434 struct inode *inode);
@@ -473,10 +477,14 @@ ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat,
473 unsigned char *src, struct dentry *ecryptfs_dentry); 477 unsigned char *src, struct dentry *ecryptfs_dentry);
474int ecryptfs_truncate(struct dentry *dentry, loff_t new_length); 478int ecryptfs_truncate(struct dentry *dentry, loff_t new_length);
475int 479int
476ecryptfs_process_cipher(struct crypto_tfm **tfm, struct crypto_tfm **key_tfm, 480ecryptfs_process_cipher(struct crypto_blkcipher **key_tfm, char *cipher_name,
477 char *cipher_name, size_t key_size); 481 size_t *key_size);
478int ecryptfs_inode_test(struct inode *inode, void *candidate_lower_inode); 482int ecryptfs_inode_test(struct inode *inode, void *candidate_lower_inode);
479int ecryptfs_inode_set(struct inode *inode, void *lower_inode); 483int ecryptfs_inode_set(struct inode *inode, void *lower_inode);
480void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode); 484void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode);
485int ecryptfs_open_lower_file(struct file **lower_file,
486 struct dentry *lower_dentry,
487 struct vfsmount *lower_mnt, int flags);
488int ecryptfs_close_lower_file(struct file *lower_file);
481 489
482#endif /* #ifndef ECRYPTFS_KERNEL_H */ 490#endif /* #ifndef ECRYPTFS_KERNEL_H */
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c
index c8550c9f9cd2..a92ef05eff8f 100644
--- a/fs/ecryptfs/file.c
+++ b/fs/ecryptfs/file.c
@@ -198,6 +198,33 @@ retry:
198 198
199struct kmem_cache *ecryptfs_file_info_cache; 199struct kmem_cache *ecryptfs_file_info_cache;
200 200
201int ecryptfs_open_lower_file(struct file **lower_file,
202 struct dentry *lower_dentry,
203 struct vfsmount *lower_mnt, int flags)
204{
205 int rc = 0;
206
207 dget(lower_dentry);
208 mntget(lower_mnt);
209 *lower_file = dentry_open(lower_dentry, lower_mnt, flags);
210 if (IS_ERR(*lower_file)) {
211 printk(KERN_ERR "Error opening lower file for lower_dentry "
212 "[0x%p], lower_mnt [0x%p], and flags [0x%x]\n",
213 lower_dentry, lower_mnt, flags);
214 rc = PTR_ERR(*lower_file);
215 *lower_file = NULL;
216 goto out;
217 }
218out:
219 return rc;
220}
221
222int ecryptfs_close_lower_file(struct file *lower_file)
223{
224 fput(lower_file);
225 return 0;
226}
227
201/** 228/**
202 * ecryptfs_open 229 * ecryptfs_open
203 * @inode: inode speciying file to open 230 * @inode: inode speciying file to open
@@ -244,19 +271,15 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
244 ECRYPTFS_SET_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED); 271 ECRYPTFS_SET_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED);
245 } 272 }
246 mutex_unlock(&crypt_stat->cs_mutex); 273 mutex_unlock(&crypt_stat->cs_mutex);
247 /* This mntget & dget is undone via fput when the file is released */
248 dget(lower_dentry);
249 lower_flags = file->f_flags; 274 lower_flags = file->f_flags;
250 if ((lower_flags & O_ACCMODE) == O_WRONLY) 275 if ((lower_flags & O_ACCMODE) == O_WRONLY)
251 lower_flags = (lower_flags & O_ACCMODE) | O_RDWR; 276 lower_flags = (lower_flags & O_ACCMODE) | O_RDWR;
252 if (file->f_flags & O_APPEND) 277 if (file->f_flags & O_APPEND)
253 lower_flags &= ~O_APPEND; 278 lower_flags &= ~O_APPEND;
254 lower_mnt = ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry); 279 lower_mnt = ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry);
255 mntget(lower_mnt);
256 /* Corresponding fput() in ecryptfs_release() */ 280 /* Corresponding fput() in ecryptfs_release() */
257 lower_file = dentry_open(lower_dentry, lower_mnt, lower_flags); 281 if ((rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
258 if (IS_ERR(lower_file)) { 282 lower_flags))) {
259 rc = PTR_ERR(lower_file);
260 ecryptfs_printk(KERN_ERR, "Error opening lower file\n"); 283 ecryptfs_printk(KERN_ERR, "Error opening lower file\n");
261 goto out_puts; 284 goto out_puts;
262 } 285 }
@@ -341,11 +364,16 @@ static int ecryptfs_release(struct inode *inode, struct file *file)
341 struct file *lower_file = ecryptfs_file_to_lower(file); 364 struct file *lower_file = ecryptfs_file_to_lower(file);
342 struct ecryptfs_file_info *file_info = ecryptfs_file_to_private(file); 365 struct ecryptfs_file_info *file_info = ecryptfs_file_to_private(file);
343 struct inode *lower_inode = ecryptfs_inode_to_lower(inode); 366 struct inode *lower_inode = ecryptfs_inode_to_lower(inode);
367 int rc;
344 368
345 fput(lower_file); 369 if ((rc = ecryptfs_close_lower_file(lower_file))) {
370 printk(KERN_ERR "Error closing lower_file\n");
371 goto out;
372 }
346 inode->i_blocks = lower_inode->i_blocks; 373 inode->i_blocks = lower_inode->i_blocks;
347 kmem_cache_free(ecryptfs_file_info_cache, file_info); 374 kmem_cache_free(ecryptfs_file_info_cache, file_info);
348 return 0; 375out:
376 return rc;
349} 377}
350 378
351static int 379static int
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index efdd2b7b62d7..ff4865d24f0f 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -231,7 +231,6 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
231 int lower_flags; 231 int lower_flags;
232 struct ecryptfs_crypt_stat *crypt_stat; 232 struct ecryptfs_crypt_stat *crypt_stat;
233 struct dentry *lower_dentry; 233 struct dentry *lower_dentry;
234 struct dentry *tlower_dentry = NULL;
235 struct file *lower_file; 234 struct file *lower_file;
236 struct inode *inode, *lower_inode; 235 struct inode *inode, *lower_inode;
237 struct vfsmount *lower_mnt; 236 struct vfsmount *lower_mnt;
@@ -241,30 +240,19 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
241 lower_dentry->d_name.name); 240 lower_dentry->d_name.name);
242 inode = ecryptfs_dentry->d_inode; 241 inode = ecryptfs_dentry->d_inode;
243 crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat; 242 crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
244 tlower_dentry = dget(lower_dentry);
245 if (!tlower_dentry) {
246 rc = -ENOMEM;
247 ecryptfs_printk(KERN_ERR, "Error dget'ing lower_dentry\n");
248 goto out;
249 }
250 lower_flags = ((O_CREAT | O_WRONLY | O_TRUNC) & O_ACCMODE) | O_RDWR; 243 lower_flags = ((O_CREAT | O_WRONLY | O_TRUNC) & O_ACCMODE) | O_RDWR;
251#if BITS_PER_LONG != 32 244#if BITS_PER_LONG != 32
252 lower_flags |= O_LARGEFILE; 245 lower_flags |= O_LARGEFILE;
253#endif 246#endif
254 lower_mnt = ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry); 247 lower_mnt = ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry);
255 mntget(lower_mnt);
256 /* Corresponding fput() at end of this function */ 248 /* Corresponding fput() at end of this function */
257 lower_file = dentry_open(tlower_dentry, lower_mnt, lower_flags); 249 if ((rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
258 if (IS_ERR(lower_file)) { 250 lower_flags))) {
259 rc = PTR_ERR(lower_file);
260 ecryptfs_printk(KERN_ERR, 251 ecryptfs_printk(KERN_ERR,
261 "Error opening dentry; rc = [%i]\n", rc); 252 "Error opening dentry; rc = [%i]\n", rc);
262 goto out; 253 goto out;
263 } 254 }
264 /* fput(lower_file) should handle the puts if we do this */ 255 lower_inode = lower_dentry->d_inode;
265 lower_file->f_dentry = tlower_dentry;
266 lower_file->f_vfsmnt = lower_mnt;
267 lower_inode = tlower_dentry->d_inode;
268 if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) { 256 if (S_ISDIR(ecryptfs_dentry->d_inode->i_mode)) {
269 ecryptfs_printk(KERN_DEBUG, "This is a directory\n"); 257 ecryptfs_printk(KERN_DEBUG, "This is a directory\n");
270 ECRYPTFS_CLEAR_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED); 258 ECRYPTFS_CLEAR_FLAG(crypt_stat->flags, ECRYPTFS_ENCRYPTED);
@@ -285,7 +273,8 @@ static int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry)
285 } 273 }
286 rc = grow_file(ecryptfs_dentry, lower_file, inode, lower_inode); 274 rc = grow_file(ecryptfs_dentry, lower_file, inode, lower_inode);
287out_fput: 275out_fput:
288 fput(lower_file); 276 if ((rc = ecryptfs_close_lower_file(lower_file)))
277 printk(KERN_ERR "Error closing lower_file\n");
289out: 278out:
290 return rc; 279 return rc;
291} 280}
@@ -336,7 +325,6 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
336 struct dentry *lower_dir_dentry; 325 struct dentry *lower_dir_dentry;
337 struct dentry *lower_dentry; 326 struct dentry *lower_dentry;
338 struct vfsmount *lower_mnt; 327 struct vfsmount *lower_mnt;
339 struct dentry *tlower_dentry = NULL;
340 char *encoded_name; 328 char *encoded_name;
341 unsigned int encoded_namelen; 329 unsigned int encoded_namelen;
342 struct ecryptfs_crypt_stat *crypt_stat = NULL; 330 struct ecryptfs_crypt_stat *crypt_stat = NULL;
@@ -347,27 +335,32 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
347 lower_dir_dentry = ecryptfs_dentry_to_lower(dentry->d_parent); 335 lower_dir_dentry = ecryptfs_dentry_to_lower(dentry->d_parent);
348 dentry->d_op = &ecryptfs_dops; 336 dentry->d_op = &ecryptfs_dops;
349 if ((dentry->d_name.len == 1 && !strcmp(dentry->d_name.name, ".")) 337 if ((dentry->d_name.len == 1 && !strcmp(dentry->d_name.name, "."))
350 || (dentry->d_name.len == 2 && !strcmp(dentry->d_name.name, ".."))) 338 || (dentry->d_name.len == 2
351 goto out_drop; 339 && !strcmp(dentry->d_name.name, ".."))) {
340 d_drop(dentry);
341 goto out;
342 }
352 encoded_namelen = ecryptfs_encode_filename(crypt_stat, 343 encoded_namelen = ecryptfs_encode_filename(crypt_stat,
353 dentry->d_name.name, 344 dentry->d_name.name,
354 dentry->d_name.len, 345 dentry->d_name.len,
355 &encoded_name); 346 &encoded_name);
356 if (encoded_namelen < 0) { 347 if (encoded_namelen < 0) {
357 rc = encoded_namelen; 348 rc = encoded_namelen;
358 goto out_drop; 349 d_drop(dentry);
350 goto out;
359 } 351 }
360 ecryptfs_printk(KERN_DEBUG, "encoded_name = [%s]; encoded_namelen " 352 ecryptfs_printk(KERN_DEBUG, "encoded_name = [%s]; encoded_namelen "
361 "= [%d]\n", encoded_name, encoded_namelen); 353 "= [%d]\n", encoded_name, encoded_namelen);
362 lower_dentry = lookup_one_len(encoded_name, lower_dir_dentry, 354 lower_dentry = lookup_one_len(encoded_name, lower_dir_dentry,
363 encoded_namelen - 1); 355 encoded_namelen - 1);
364 kfree(encoded_name); 356 kfree(encoded_name);
365 lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent));
366 if (IS_ERR(lower_dentry)) { 357 if (IS_ERR(lower_dentry)) {
367 ecryptfs_printk(KERN_ERR, "ERR from lower_dentry\n"); 358 ecryptfs_printk(KERN_ERR, "ERR from lower_dentry\n");
368 rc = PTR_ERR(lower_dentry); 359 rc = PTR_ERR(lower_dentry);
369 goto out_drop; 360 d_drop(dentry);
361 goto out;
370 } 362 }
363 lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt(dentry->d_parent));
371 ecryptfs_printk(KERN_DEBUG, "lower_dentry = [%p]; lower_dentry->" 364 ecryptfs_printk(KERN_DEBUG, "lower_dentry = [%p]; lower_dentry->"
372 "d_name.name = [%s]\n", lower_dentry, 365 "d_name.name = [%s]\n", lower_dentry,
373 lower_dentry->d_name.name); 366 lower_dentry->d_name.name);
@@ -408,12 +401,6 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
408 "as we *think* we are about to unlink\n"); 401 "as we *think* we are about to unlink\n");
409 goto out; 402 goto out;
410 } 403 }
411 tlower_dentry = dget(lower_dentry);
412 if (!tlower_dentry || IS_ERR(tlower_dentry)) {
413 rc = -ENOMEM;
414 ecryptfs_printk(KERN_ERR, "Cannot dget lower_dentry\n");
415 goto out_dput;
416 }
417 /* Released in this function */ 404 /* Released in this function */
418 page_virt = 405 page_virt =
419 (char *)kmem_cache_alloc(ecryptfs_header_cache_2, 406 (char *)kmem_cache_alloc(ecryptfs_header_cache_2,
@@ -425,7 +412,7 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
425 goto out_dput; 412 goto out_dput;
426 } 413 }
427 memset(page_virt, 0, PAGE_CACHE_SIZE); 414 memset(page_virt, 0, PAGE_CACHE_SIZE);
428 rc = ecryptfs_read_header_region(page_virt, tlower_dentry, nd->mnt); 415 rc = ecryptfs_read_header_region(page_virt, lower_dentry, nd->mnt);
429 crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat; 416 crypt_stat = &ecryptfs_inode_to_private(dentry->d_inode)->crypt_stat;
430 if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_POLICY_APPLIED)) 417 if (!ECRYPTFS_CHECK_FLAG(crypt_stat->flags, ECRYPTFS_POLICY_APPLIED))
431 ecryptfs_set_default_sizes(crypt_stat); 418 ecryptfs_set_default_sizes(crypt_stat);
@@ -448,9 +435,6 @@ static struct dentry *ecryptfs_lookup(struct inode *dir, struct dentry *dentry,
448 435
449out_dput: 436out_dput:
450 dput(lower_dentry); 437 dput(lower_dentry);
451 if (tlower_dentry)
452 dput(tlower_dentry);
453out_drop:
454 d_drop(dentry); 438 d_drop(dentry);
455out: 439out:
456 return ERR_PTR(rc); 440 return ERR_PTR(rc);
@@ -486,8 +470,8 @@ out_lock:
486 unlock_dir(lower_dir_dentry); 470 unlock_dir(lower_dir_dentry);
487 dput(lower_new_dentry); 471 dput(lower_new_dentry);
488 dput(lower_old_dentry); 472 dput(lower_old_dentry);
489 if (!new_dentry->d_inode) 473 d_drop(new_dentry);
490 d_drop(new_dentry); 474 d_drop(old_dentry);
491 return rc; 475 return rc;
492} 476}
493 477
@@ -576,41 +560,24 @@ out:
576 560
577static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry) 561static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
578{ 562{
579 int rc = 0;
580 struct dentry *tdentry = NULL;
581 struct dentry *lower_dentry; 563 struct dentry *lower_dentry;
582 struct dentry *tlower_dentry = NULL;
583 struct dentry *lower_dir_dentry; 564 struct dentry *lower_dir_dentry;
565 int rc;
584 566
585 lower_dentry = ecryptfs_dentry_to_lower(dentry); 567 lower_dentry = ecryptfs_dentry_to_lower(dentry);
586 if (!(tdentry = dget(dentry))) { 568 dget(dentry);
587 rc = -EINVAL;
588 ecryptfs_printk(KERN_ERR, "Error dget'ing dentry [%p]\n",
589 dentry);
590 goto out;
591 }
592 lower_dir_dentry = lock_parent(lower_dentry); 569 lower_dir_dentry = lock_parent(lower_dentry);
593 if (!(tlower_dentry = dget(lower_dentry))) { 570 dget(lower_dentry);
594 rc = -EINVAL;
595 ecryptfs_printk(KERN_ERR, "Error dget'ing lower_dentry "
596 "[%p]\n", lower_dentry);
597 goto out;
598 }
599 rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry); 571 rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry);
600 if (!rc) { 572 dput(lower_dentry);
601 d_delete(tlower_dentry); 573 if (!rc)
602 tlower_dentry = NULL; 574 d_delete(lower_dentry);
603 }
604 ecryptfs_copy_attr_times(dir, lower_dir_dentry->d_inode); 575 ecryptfs_copy_attr_times(dir, lower_dir_dentry->d_inode);
605 dir->i_nlink = lower_dir_dentry->d_inode->i_nlink; 576 dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
606 unlock_dir(lower_dir_dentry); 577 unlock_dir(lower_dir_dentry);
607 if (!rc) 578 if (!rc)
608 d_drop(dentry); 579 d_drop(dentry);
609out: 580 dput(dentry);
610 if (tdentry)
611 dput(tdentry);
612 if (tlower_dentry)
613 dput(tlower_dentry);
614 return rc; 581 return rc;
615} 582}
616 583
@@ -832,12 +799,11 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
832 } 799 }
833 lower_dentry = ecryptfs_dentry_to_lower(dentry); 800 lower_dentry = ecryptfs_dentry_to_lower(dentry);
834 /* This dget & mntget is released through fput at out_fput: */ 801 /* This dget & mntget is released through fput at out_fput: */
835 dget(lower_dentry);
836 lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry); 802 lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry);
837 mntget(lower_mnt); 803 if ((rc = ecryptfs_open_lower_file(&lower_file, lower_dentry, lower_mnt,
838 lower_file = dentry_open(lower_dentry, lower_mnt, O_RDWR); 804 O_RDWR))) {
839 if (unlikely(IS_ERR(lower_file))) { 805 ecryptfs_printk(KERN_ERR,
840 rc = PTR_ERR(lower_file); 806 "Error opening dentry; rc = [%i]\n", rc);
841 goto out_free; 807 goto out_free;
842 } 808 }
843 ecryptfs_set_file_lower(&fake_ecryptfs_file, lower_file); 809 ecryptfs_set_file_lower(&fake_ecryptfs_file, lower_file);
@@ -879,7 +845,8 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
879 = CURRENT_TIME; 845 = CURRENT_TIME;
880 mark_inode_dirty_sync(inode); 846 mark_inode_dirty_sync(inode);
881out_fput: 847out_fput:
882 fput(lower_file); 848 if ((rc = ecryptfs_close_lower_file(lower_file)))
849 printk(KERN_ERR "Error closing lower_file\n");
883out_free: 850out_free:
884 if (ecryptfs_file_to_private(&fake_ecryptfs_file)) 851 if (ecryptfs_file_to_private(&fake_ecryptfs_file))
885 kmem_cache_free(ecryptfs_file_info_cache, 852 kmem_cache_free(ecryptfs_file_info_cache,
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c
index ba454785a0c5..c3746f56d162 100644
--- a/fs/ecryptfs/keystore.c
+++ b/fs/ecryptfs/keystore.c
@@ -458,14 +458,16 @@ out:
458static int decrypt_session_key(struct ecryptfs_auth_tok *auth_tok, 458static int decrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
459 struct ecryptfs_crypt_stat *crypt_stat) 459 struct ecryptfs_crypt_stat *crypt_stat)
460{ 460{
461 int rc = 0;
462 struct ecryptfs_password *password_s_ptr; 461 struct ecryptfs_password *password_s_ptr;
463 struct crypto_tfm *tfm = NULL;
464 struct scatterlist src_sg[2], dst_sg[2]; 462 struct scatterlist src_sg[2], dst_sg[2];
465 struct mutex *tfm_mutex = NULL; 463 struct mutex *tfm_mutex = NULL;
466 /* TODO: Use virt_to_scatterlist for these */ 464 /* TODO: Use virt_to_scatterlist for these */
467 char *encrypted_session_key; 465 char *encrypted_session_key;
468 char *session_key; 466 char *session_key;
467 struct blkcipher_desc desc = {
468 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
469 };
470 int rc = 0;
469 471
470 password_s_ptr = &auth_tok->token.password; 472 password_s_ptr = &auth_tok->token.password;
471 if (ECRYPTFS_CHECK_FLAG(password_s_ptr->flags, 473 if (ECRYPTFS_CHECK_FLAG(password_s_ptr->flags,
@@ -482,30 +484,37 @@ static int decrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
482 if (!strcmp(crypt_stat->cipher, 484 if (!strcmp(crypt_stat->cipher,
483 crypt_stat->mount_crypt_stat->global_default_cipher_name) 485 crypt_stat->mount_crypt_stat->global_default_cipher_name)
484 && crypt_stat->mount_crypt_stat->global_key_tfm) { 486 && crypt_stat->mount_crypt_stat->global_key_tfm) {
485 tfm = crypt_stat->mount_crypt_stat->global_key_tfm; 487 desc.tfm = crypt_stat->mount_crypt_stat->global_key_tfm;
486 tfm_mutex = &crypt_stat->mount_crypt_stat->global_key_tfm_mutex; 488 tfm_mutex = &crypt_stat->mount_crypt_stat->global_key_tfm_mutex;
487 } else { 489 } else {
488 tfm = crypto_alloc_tfm(crypt_stat->cipher, 490 char *full_alg_name;
489 CRYPTO_TFM_REQ_WEAK_KEY); 491
490 if (!tfm) { 492 rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name,
491 printk(KERN_ERR "Error allocating crypto context\n"); 493 crypt_stat->cipher,
492 rc = -ENOMEM; 494 "ecb");
495 if (rc)
496 goto out;
497 desc.tfm = crypto_alloc_blkcipher(full_alg_name, 0,
498 CRYPTO_ALG_ASYNC);
499 kfree(full_alg_name);
500 if (IS_ERR(desc.tfm)) {
501 rc = PTR_ERR(desc.tfm);
502 printk(KERN_ERR "Error allocating crypto context; "
503 "rc = [%d]\n", rc);
493 goto out; 504 goto out;
494 } 505 }
495 } 506 crypto_blkcipher_set_flags(desc.tfm, CRYPTO_TFM_REQ_WEAK_KEY);
496 if (password_s_ptr->session_key_encryption_key_bytes
497 < crypto_tfm_alg_min_keysize(tfm)) {
498 printk(KERN_WARNING "Session key encryption key is [%d] bytes; "
499 "minimum keysize for selected cipher is [%d] bytes.\n",
500 password_s_ptr->session_key_encryption_key_bytes,
501 crypto_tfm_alg_min_keysize(tfm));
502 rc = -EINVAL;
503 goto out;
504 } 507 }
505 if (tfm_mutex) 508 if (tfm_mutex)
506 mutex_lock(tfm_mutex); 509 mutex_lock(tfm_mutex);
507 crypto_cipher_setkey(tfm, password_s_ptr->session_key_encryption_key, 510 rc = crypto_blkcipher_setkey(desc.tfm,
508 crypt_stat->key_size); 511 password_s_ptr->session_key_encryption_key,
512 crypt_stat->key_size);
513 if (rc < 0) {
514 printk(KERN_ERR "Error setting key for crypto context\n");
515 rc = -EINVAL;
516 goto out_free_tfm;
517 }
509 /* TODO: virt_to_scatterlist */ 518 /* TODO: virt_to_scatterlist */
510 encrypted_session_key = (char *)__get_free_page(GFP_KERNEL); 519 encrypted_session_key = (char *)__get_free_page(GFP_KERNEL);
511 if (!encrypted_session_key) { 520 if (!encrypted_session_key) {
@@ -531,9 +540,12 @@ static int decrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
531 auth_tok->session_key.decrypted_key_size = 540 auth_tok->session_key.decrypted_key_size =
532 auth_tok->session_key.encrypted_key_size; 541 auth_tok->session_key.encrypted_key_size;
533 dst_sg[0].length = auth_tok->session_key.encrypted_key_size; 542 dst_sg[0].length = auth_tok->session_key.encrypted_key_size;
534 /* TODO: Handle error condition */ 543 rc = crypto_blkcipher_decrypt(&desc, dst_sg, src_sg,
535 crypto_cipher_decrypt(tfm, dst_sg, src_sg, 544 auth_tok->session_key.encrypted_key_size);
536 auth_tok->session_key.encrypted_key_size); 545 if (rc) {
546 printk(KERN_ERR "Error decrypting; rc = [%d]\n", rc);
547 goto out_free_memory;
548 }
537 auth_tok->session_key.decrypted_key_size = 549 auth_tok->session_key.decrypted_key_size =
538 auth_tok->session_key.encrypted_key_size; 550 auth_tok->session_key.encrypted_key_size;
539 memcpy(auth_tok->session_key.decrypted_key, session_key, 551 memcpy(auth_tok->session_key.decrypted_key, session_key,
@@ -546,6 +558,7 @@ static int decrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
546 if (ecryptfs_verbosity > 0) 558 if (ecryptfs_verbosity > 0)
547 ecryptfs_dump_hex(crypt_stat->key, 559 ecryptfs_dump_hex(crypt_stat->key,
548 crypt_stat->key_size); 560 crypt_stat->key_size);
561out_free_memory:
549 memset(encrypted_session_key, 0, PAGE_CACHE_SIZE); 562 memset(encrypted_session_key, 0, PAGE_CACHE_SIZE);
550 free_page((unsigned long)encrypted_session_key); 563 free_page((unsigned long)encrypted_session_key);
551 memset(session_key, 0, PAGE_CACHE_SIZE); 564 memset(session_key, 0, PAGE_CACHE_SIZE);
@@ -554,7 +567,7 @@ out_free_tfm:
554 if (tfm_mutex) 567 if (tfm_mutex)
555 mutex_unlock(tfm_mutex); 568 mutex_unlock(tfm_mutex);
556 else 569 else
557 crypto_free_tfm(tfm); 570 crypto_free_blkcipher(desc.tfm);
558out: 571out:
559 return rc; 572 return rc;
560} 573}
@@ -803,19 +816,21 @@ write_tag_3_packet(char *dest, size_t max, struct ecryptfs_auth_tok *auth_tok,
803 struct ecryptfs_crypt_stat *crypt_stat, 816 struct ecryptfs_crypt_stat *crypt_stat,
804 struct ecryptfs_key_record *key_rec, size_t *packet_size) 817 struct ecryptfs_key_record *key_rec, size_t *packet_size)
805{ 818{
806 int rc = 0;
807
808 size_t i; 819 size_t i;
809 size_t signature_is_valid = 0; 820 size_t signature_is_valid = 0;
810 size_t encrypted_session_key_valid = 0; 821 size_t encrypted_session_key_valid = 0;
811 char session_key_encryption_key[ECRYPTFS_MAX_KEY_BYTES]; 822 char session_key_encryption_key[ECRYPTFS_MAX_KEY_BYTES];
812 struct scatterlist dest_sg[2]; 823 struct scatterlist dest_sg[2];
813 struct scatterlist src_sg[2]; 824 struct scatterlist src_sg[2];
814 struct crypto_tfm *tfm = NULL;
815 struct mutex *tfm_mutex = NULL; 825 struct mutex *tfm_mutex = NULL;
816 size_t key_rec_size; 826 size_t key_rec_size;
817 size_t packet_size_length; 827 size_t packet_size_length;
818 size_t cipher_code; 828 size_t cipher_code;
829 struct blkcipher_desc desc = {
830 .tfm = NULL,
831 .flags = CRYPTO_TFM_REQ_MAY_SLEEP
832 };
833 int rc = 0;
819 834
820 (*packet_size) = 0; 835 (*packet_size) = 0;
821 /* Check for a valid signature on the auth_tok */ 836 /* Check for a valid signature on the auth_tok */
@@ -882,33 +897,48 @@ write_tag_3_packet(char *dest, size_t max, struct ecryptfs_auth_tok *auth_tok,
882 if (!strcmp(crypt_stat->cipher, 897 if (!strcmp(crypt_stat->cipher,
883 crypt_stat->mount_crypt_stat->global_default_cipher_name) 898 crypt_stat->mount_crypt_stat->global_default_cipher_name)
884 && crypt_stat->mount_crypt_stat->global_key_tfm) { 899 && crypt_stat->mount_crypt_stat->global_key_tfm) {
885 tfm = crypt_stat->mount_crypt_stat->global_key_tfm; 900 desc.tfm = crypt_stat->mount_crypt_stat->global_key_tfm;
886 tfm_mutex = &crypt_stat->mount_crypt_stat->global_key_tfm_mutex; 901 tfm_mutex = &crypt_stat->mount_crypt_stat->global_key_tfm_mutex;
887 } else 902 } else {
888 tfm = crypto_alloc_tfm(crypt_stat->cipher, 0); 903 char *full_alg_name;
889 if (!tfm) { 904
890 ecryptfs_printk(KERN_ERR, "Could not initialize crypto " 905 rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name,
891 "context for cipher [%s]\n", 906 crypt_stat->cipher,
892 crypt_stat->cipher); 907 "ecb");
893 rc = -EINVAL; 908 if (rc)
894 goto out; 909 goto out;
910 desc.tfm = crypto_alloc_blkcipher(full_alg_name, 0,
911 CRYPTO_ALG_ASYNC);
912 kfree(full_alg_name);
913 if (IS_ERR(desc.tfm)) {
914 rc = PTR_ERR(desc.tfm);
915 ecryptfs_printk(KERN_ERR, "Could not initialize crypto "
916 "context for cipher [%s]; rc = [%d]\n",
917 crypt_stat->cipher, rc);
918 goto out;
919 }
920 crypto_blkcipher_set_flags(desc.tfm, CRYPTO_TFM_REQ_WEAK_KEY);
895 } 921 }
896 if (tfm_mutex) 922 if (tfm_mutex)
897 mutex_lock(tfm_mutex); 923 mutex_lock(tfm_mutex);
898 rc = crypto_cipher_setkey(tfm, session_key_encryption_key, 924 rc = crypto_blkcipher_setkey(desc.tfm, session_key_encryption_key,
899 crypt_stat->key_size); 925 crypt_stat->key_size);
900 if (rc < 0) { 926 if (rc < 0) {
901 if (tfm_mutex) 927 if (tfm_mutex)
902 mutex_unlock(tfm_mutex); 928 mutex_unlock(tfm_mutex);
903 ecryptfs_printk(KERN_ERR, "Error setting key for crypto " 929 ecryptfs_printk(KERN_ERR, "Error setting key for crypto "
904 "context\n"); 930 "context; rc = [%d]\n", rc);
905 goto out; 931 goto out;
906 } 932 }
907 rc = 0; 933 rc = 0;
908 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes of the key\n", 934 ecryptfs_printk(KERN_DEBUG, "Encrypting [%d] bytes of the key\n",
909 crypt_stat->key_size); 935 crypt_stat->key_size);
910 crypto_cipher_encrypt(tfm, dest_sg, src_sg, 936 rc = crypto_blkcipher_encrypt(&desc, dest_sg, src_sg,
911 (*key_rec).enc_key_size); 937 (*key_rec).enc_key_size);
938 if (rc) {
939 printk(KERN_ERR "Error encrypting; rc = [%d]\n", rc);
940 goto out;
941 }
912 if (tfm_mutex) 942 if (tfm_mutex)
913 mutex_unlock(tfm_mutex); 943 mutex_unlock(tfm_mutex);
914 ecryptfs_printk(KERN_DEBUG, "This should be the encrypted key:\n"); 944 ecryptfs_printk(KERN_DEBUG, "This should be the encrypted key:\n");
@@ -971,8 +1001,8 @@ encrypted_session_key_set:
971 (*key_rec).enc_key_size); 1001 (*key_rec).enc_key_size);
972 (*packet_size) += (*key_rec).enc_key_size; 1002 (*packet_size) += (*key_rec).enc_key_size;
973out: 1003out:
974 if (tfm && !tfm_mutex) 1004 if (desc.tfm && !tfm_mutex)
975 crypto_free_tfm(tfm); 1005 crypto_free_blkcipher(desc.tfm);
976 if (rc) 1006 if (rc)
977 (*packet_size) = 0; 1007 (*packet_size) = 0;
978 return rc; 1008 return rc;
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 5938a232d11b..a78d87d14baf 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -208,7 +208,6 @@ static int ecryptfs_parse_options(struct super_block *sb, char *options)
208 char *cipher_name_dst; 208 char *cipher_name_dst;
209 char *cipher_name_src; 209 char *cipher_name_src;
210 char *cipher_key_bytes_src; 210 char *cipher_key_bytes_src;
211 struct crypto_tfm *tmp_tfm;
212 int cipher_name_len; 211 int cipher_name_len;
213 212
214 if (!options) { 213 if (!options) {
@@ -305,25 +304,19 @@ static int ecryptfs_parse_options(struct super_block *sb, char *options)
305 = '\0'; 304 = '\0';
306 } 305 }
307 if (!cipher_key_bytes_set) { 306 if (!cipher_key_bytes_set) {
308 mount_crypt_stat->global_default_cipher_key_size = 307 mount_crypt_stat->global_default_cipher_key_size = 0;
309 ECRYPTFS_DEFAULT_KEY_BYTES;
310 ecryptfs_printk(KERN_DEBUG, "Cipher key size was not "
311 "specified. Defaulting to [%d]\n",
312 mount_crypt_stat->
313 global_default_cipher_key_size);
314 } 308 }
315 rc = ecryptfs_process_cipher( 309 rc = ecryptfs_process_cipher(
316 &tmp_tfm,
317 &mount_crypt_stat->global_key_tfm, 310 &mount_crypt_stat->global_key_tfm,
318 mount_crypt_stat->global_default_cipher_name, 311 mount_crypt_stat->global_default_cipher_name,
319 mount_crypt_stat->global_default_cipher_key_size); 312 &mount_crypt_stat->global_default_cipher_key_size);
320 if (tmp_tfm)
321 crypto_free_tfm(tmp_tfm);
322 if (rc) { 313 if (rc) {
323 printk(KERN_ERR "Error attempting to initialize cipher [%s] " 314 printk(KERN_ERR "Error attempting to initialize cipher [%s] "
324 "with key size [%Zd] bytes; rc = [%d]\n", 315 "with key size [%Zd] bytes; rc = [%d]\n",
325 mount_crypt_stat->global_default_cipher_name, 316 mount_crypt_stat->global_default_cipher_name,
326 mount_crypt_stat->global_default_cipher_key_size, rc); 317 mount_crypt_stat->global_default_cipher_key_size, rc);
318 mount_crypt_stat->global_key_tfm = NULL;
319 mount_crypt_stat->global_auth_tok_key = NULL;
327 rc = -EINVAL; 320 rc = -EINVAL;
328 goto out; 321 goto out;
329 } 322 }
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c
index c337c0410fb1..825757ae4867 100644
--- a/fs/ecryptfs/super.c
+++ b/fs/ecryptfs/super.c
@@ -138,23 +138,6 @@ static void ecryptfs_clear_inode(struct inode *inode)
138} 138}
139 139
140/** 140/**
141 * ecryptfs_umount_begin
142 *
143 * Called in do_umount().
144 */
145static void ecryptfs_umount_begin(struct vfsmount *vfsmnt, int flags)
146{
147 struct vfsmount *lower_mnt =
148 ecryptfs_dentry_to_lower_mnt(vfsmnt->mnt_sb->s_root);
149 struct super_block *lower_sb;
150
151 mntput(lower_mnt);
152 lower_sb = lower_mnt->mnt_sb;
153 if (lower_sb->s_op->umount_begin)
154 lower_sb->s_op->umount_begin(lower_mnt, flags);
155}
156
157/**
158 * ecryptfs_show_options 141 * ecryptfs_show_options
159 * 142 *
160 * Prints the directory we are currently mounted over. 143 * Prints the directory we are currently mounted over.
@@ -193,6 +176,5 @@ struct super_operations ecryptfs_sops = {
193 .statfs = ecryptfs_statfs, 176 .statfs = ecryptfs_statfs,
194 .remount_fs = NULL, 177 .remount_fs = NULL,
195 .clear_inode = ecryptfs_clear_inode, 178 .clear_inode = ecryptfs_clear_inode,
196 .umount_begin = ecryptfs_umount_begin,
197 .show_options = ecryptfs_show_options 179 .show_options = ecryptfs_show_options
198}; 180};
diff --git a/include/asm-i386/io_apic.h b/include/asm-i386/io_apic.h
index 276ea7e8144a..059a9ff28b4d 100644
--- a/include/asm-i386/io_apic.h
+++ b/include/asm-i386/io_apic.h
@@ -12,10 +12,6 @@
12 12
13#ifdef CONFIG_X86_IO_APIC 13#ifdef CONFIG_X86_IO_APIC
14 14
15#define IO_APIC_BASE(idx) \
16 ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx) \
17 + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
18
19/* 15/*
20 * The structure of the IO-APIC: 16 * The structure of the IO-APIC:
21 */ 17 */
@@ -119,31 +115,8 @@ extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
119/* non-0 if default (table-less) MP configuration */ 115/* non-0 if default (table-less) MP configuration */
120extern int mpc_default_type; 116extern int mpc_default_type;
121 117
122static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg) 118/* Older SiS APIC requires we rewrite the index register */
123{
124 *IO_APIC_BASE(apic) = reg;
125 return *(IO_APIC_BASE(apic)+4);
126}
127
128static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned int value)
129{
130 *IO_APIC_BASE(apic) = reg;
131 *(IO_APIC_BASE(apic)+4) = value;
132}
133
134/*
135 * Re-write a value: to be used for read-modify-write
136 * cycles where the read already set up the index register.
137 *
138 * Older SiS APIC requires we rewrite the index regiser
139 */
140extern int sis_apic_bug; 119extern int sis_apic_bug;
141static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned int value)
142{
143 if (sis_apic_bug)
144 *IO_APIC_BASE(apic) = reg;
145 *(IO_APIC_BASE(apic)+4) = value;
146}
147 120
148/* 1 if "noapic" boot option passed */ 121/* 1 if "noapic" boot option passed */
149extern int skip_ioapic_setup; 122extern int skip_ioapic_setup;
diff --git a/include/asm-ia64/sal.h b/include/asm-ia64/sal.h
index 0b210abbe003..d000689d9142 100644
--- a/include/asm-ia64/sal.h
+++ b/include/asm-ia64/sal.h
@@ -659,6 +659,7 @@ ia64_sal_freq_base (unsigned long which, unsigned long *ticks_per_second,
659} 659}
660 660
661extern s64 ia64_sal_cache_flush (u64 cache_type); 661extern s64 ia64_sal_cache_flush (u64 cache_type);
662extern void __init check_sal_cache_flush (void);
662 663
663/* Initialize all the processor and platform level instruction and data caches */ 664/* Initialize all the processor and platform level instruction and data caches */
664static inline s64 665static inline s64
diff --git a/include/asm-ia64/uaccess.h b/include/asm-ia64/uaccess.h
index 9adb51211c22..449c8c0fa2bd 100644
--- a/include/asm-ia64/uaccess.h
+++ b/include/asm-ia64/uaccess.h
@@ -389,7 +389,7 @@ xlate_dev_kmem_ptr (char * p)
389 struct page *page; 389 struct page *page;
390 char * ptr; 390 char * ptr;
391 391
392 page = virt_to_page((unsigned long)p >> PAGE_SHIFT); 392 page = virt_to_page((unsigned long)p);
393 if (PageUncached(page)) 393 if (PageUncached(page))
394 ptr = (char *)__pa(p) + __IA64_UNCACHED_OFFSET; 394 ptr = (char *)__pa(p) + __IA64_UNCACHED_OFFSET;
395 else 395 else
diff --git a/include/asm-mips/asm.h b/include/asm-mips/asm.h
index e3038a4599ee..838eb3144d81 100644
--- a/include/asm-mips/asm.h
+++ b/include/asm-mips/asm.h
@@ -344,6 +344,7 @@ symbol = value
344#define PTR_L lw 344#define PTR_L lw
345#define PTR_S sw 345#define PTR_S sw
346#define PTR_LA la 346#define PTR_LA la
347#define PTR_LI li
347#define PTR_SLL sll 348#define PTR_SLL sll
348#define PTR_SLLV sllv 349#define PTR_SLLV sllv
349#define PTR_SRL srl 350#define PTR_SRL srl
@@ -368,6 +369,7 @@ symbol = value
368#define PTR_L ld 369#define PTR_L ld
369#define PTR_S sd 370#define PTR_S sd
370#define PTR_LA dla 371#define PTR_LA dla
372#define PTR_LI dli
371#define PTR_SLL dsll 373#define PTR_SLL dsll
372#define PTR_SLLV dsllv 374#define PTR_SLLV dsllv
373#define PTR_SRL dsrl 375#define PTR_SRL dsrl
diff --git a/include/asm-mips/div64.h b/include/asm-mips/div64.h
index 5f7dcf5452e7..d107832de1b6 100644
--- a/include/asm-mips/div64.h
+++ b/include/asm-mips/div64.h
@@ -83,27 +83,6 @@
83#if (_MIPS_SZLONG == 64) 83#if (_MIPS_SZLONG == 64)
84 84
85/* 85/*
86 * Don't use this one in new code
87 */
88#define do_div64_32(res, high, low, base) ({ \
89 unsigned int __quot, __mod; \
90 unsigned long __div; \
91 unsigned int __low, __high, __base; \
92 \
93 __high = (high); \
94 __low = (low); \
95 __div = __high; \
96 __div = __div << 32 | __low; \
97 __base = (base); \
98 \
99 __mod = __div % __base; \
100 __div = __div / __base; \
101 \
102 __quot = __div; \
103 (res) = __quot; \
104 __mod; })
105
106/*
107 * Hey, we're already 64-bit, no 86 * Hey, we're already 64-bit, no
108 * need to play games.. 87 * need to play games..
109 */ 88 */
diff --git a/include/asm-mips/mipsmtregs.h b/include/asm-mips/mipsmtregs.h
index f637ce70758f..3e9468f424f4 100644
--- a/include/asm-mips/mipsmtregs.h
+++ b/include/asm-mips/mipsmtregs.h
@@ -352,6 +352,8 @@ do { \
352#define write_vpe_c0_vpecontrol(val) mttc0(1, 1, val) 352#define write_vpe_c0_vpecontrol(val) mttc0(1, 1, val)
353#define read_vpe_c0_vpeconf0() mftc0(1, 2) 353#define read_vpe_c0_vpeconf0() mftc0(1, 2)
354#define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val) 354#define write_vpe_c0_vpeconf0(val) mttc0(1, 2, val)
355#define read_vpe_c0_count() mftc0(9, 0)
356#define write_vpe_c0_count(val) mttc0(9, 0, val)
355#define read_vpe_c0_status() mftc0(12, 0) 357#define read_vpe_c0_status() mftc0(12, 0)
356#define write_vpe_c0_status(val) mttc0(12, 0, val) 358#define write_vpe_c0_status(val) mttc0(12, 0, val)
357#define read_vpe_c0_cause() mftc0(13, 0) 359#define read_vpe_c0_cause() mftc0(13, 0)
diff --git a/include/asm-mips/pgalloc.h b/include/asm-mips/pgalloc.h
index 582c1fe6cc4a..af121c67dc71 100644
--- a/include/asm-mips/pgalloc.h
+++ b/include/asm-mips/pgalloc.h
@@ -48,7 +48,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
48 48
49 ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER); 49 ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_ORDER);
50 if (ret) { 50 if (ret) {
51 init = pgd_offset(&init_mm, 0); 51 init = pgd_offset(&init_mm, 0UL);
52 pgd_init((unsigned long)ret); 52 pgd_init((unsigned long)ret);
53 memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD, 53 memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
54 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); 54 (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
diff --git a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h
index d05fb6f38aa7..7e7320300aa3 100644
--- a/include/asm-mips/pgtable-64.h
+++ b/include/asm-mips/pgtable-64.h
@@ -174,7 +174,7 @@ static inline void pud_clear(pud_t *pudp)
174#define __pmd_offset(address) pmd_index(address) 174#define __pmd_offset(address) pmd_index(address)
175 175
176/* to find an entry in a kernel page-table-directory */ 176/* to find an entry in a kernel page-table-directory */
177#define pgd_offset_k(address) pgd_offset(&init_mm, 0) 177#define pgd_offset_k(address) pgd_offset(&init_mm, 0UL)
178 178
179#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 179#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
180#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)) 180#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
diff --git a/include/asm-mips/sibyte/sb1250.h b/include/asm-mips/sibyte/sb1250.h
index b09e16c93ca0..2ba6988ddc8e 100644
--- a/include/asm-mips/sibyte/sb1250.h
+++ b/include/asm-mips/sibyte/sb1250.h
@@ -51,8 +51,8 @@ extern void sb1250_mask_irq(int cpu, int irq);
51extern void sb1250_unmask_irq(int cpu, int irq); 51extern void sb1250_unmask_irq(int cpu, int irq);
52extern void sb1250_smp_finish(void); 52extern void sb1250_smp_finish(void);
53 53
54extern void bcm1480_hpt_setup(void);
54extern void bcm1480_time_init(void); 55extern void bcm1480_time_init(void);
55extern unsigned long bcm1480_gettimeoffset(void);
56extern void bcm1480_mask_irq(int cpu, int irq); 56extern void bcm1480_mask_irq(int cpu, int irq);
57extern void bcm1480_unmask_irq(int cpu, int irq); 57extern void bcm1480_unmask_irq(int cpu, int irq);
58extern void bcm1480_smp_finish(void); 58extern void bcm1480_smp_finish(void);
diff --git a/include/asm-mips/time.h b/include/asm-mips/time.h
index 28512ba2266e..625acd337bc3 100644
--- a/include/asm-mips/time.h
+++ b/include/asm-mips/time.h
@@ -48,7 +48,8 @@ extern void (*mips_timer_ack)(void);
48 * If mips_hpt_read is NULL, an R4k-compatible timer setup is attempted. 48 * If mips_hpt_read is NULL, an R4k-compatible timer setup is attempted.
49 */ 49 */
50extern unsigned int (*mips_hpt_read)(void); 50extern unsigned int (*mips_hpt_read)(void);
51extern void (*mips_hpt_init)(unsigned int); 51extern void (*mips_hpt_init)(void);
52extern unsigned int mips_hpt_mask;
52 53
53/* 54/*
54 * to_tm() converts system time back to (year, mon, day, hour, min, sec). 55 * to_tm() converts system time back to (year, mon, day, hour, min, sec).
@@ -58,13 +59,6 @@ extern void (*mips_hpt_init)(unsigned int);
58extern void to_tm(unsigned long tim, struct rtc_time *tm); 59extern void to_tm(unsigned long tim, struct rtc_time *tm);
59 60
60/* 61/*
61 * do_gettimeoffset(). By default, this func pointer points to
62 * do_null_gettimeoffset(), which leads to the same resolution as HZ.
63 * Higher resolution versions are available, which give ~1us resolution.
64 */
65extern unsigned long (*do_gettimeoffset)(void);
66
67/*
68 * high-level timer interrupt routines. 62 * high-level timer interrupt routines.
69 */ 63 */
70extern irqreturn_t timer_interrupt(int irq, void *dev_id); 64extern irqreturn_t timer_interrupt(int irq, void *dev_id);
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index 30240a445dbb..ec56aa52f669 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -332,16 +332,18 @@
332#define __NR_set_robust_list (__NR_Linux + 309) 332#define __NR_set_robust_list (__NR_Linux + 309)
333#define __NR_get_robust_list (__NR_Linux + 310) 333#define __NR_get_robust_list (__NR_Linux + 310)
334#define __NR_kexec_load (__NR_Linux + 311) 334#define __NR_kexec_load (__NR_Linux + 311)
335#define __NR_getcpu (__NR_Linux + 312)
336#define __NR_epoll_pwait (__NR_Linux + 313)
335 337
336/* 338/*
337 * Offset of the last Linux o32 flavoured syscall 339 * Offset of the last Linux o32 flavoured syscall
338 */ 340 */
339#define __NR_Linux_syscalls 311 341#define __NR_Linux_syscalls 313
340 342
341#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 343#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
342 344
343#define __NR_O32_Linux 4000 345#define __NR_O32_Linux 4000
344#define __NR_O32_Linux_syscalls 311 346#define __NR_O32_Linux_syscalls 313
345 347
346#if _MIPS_SIM == _MIPS_SIM_ABI64 348#if _MIPS_SIM == _MIPS_SIM_ABI64
347 349
@@ -620,16 +622,18 @@
620#define __NR_set_robust_list (__NR_Linux + 268) 622#define __NR_set_robust_list (__NR_Linux + 268)
621#define __NR_get_robust_list (__NR_Linux + 269) 623#define __NR_get_robust_list (__NR_Linux + 269)
622#define __NR_kexec_load (__NR_Linux + 270) 624#define __NR_kexec_load (__NR_Linux + 270)
625#define __NR_getcpu (__NR_Linux + 271)
626#define __NR_epoll_pwait (__NR_Linux + 272)
623 627
624/* 628/*
625 * Offset of the last Linux 64-bit flavoured syscall 629 * Offset of the last Linux 64-bit flavoured syscall
626 */ 630 */
627#define __NR_Linux_syscalls 270 631#define __NR_Linux_syscalls 272
628 632
629#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 633#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
630 634
631#define __NR_64_Linux 5000 635#define __NR_64_Linux 5000
632#define __NR_64_Linux_syscalls 270 636#define __NR_64_Linux_syscalls 272
633 637
634#if _MIPS_SIM == _MIPS_SIM_NABI32 638#if _MIPS_SIM == _MIPS_SIM_NABI32
635 639
@@ -912,16 +916,18 @@
912#define __NR_set_robust_list (__NR_Linux + 272) 916#define __NR_set_robust_list (__NR_Linux + 272)
913#define __NR_get_robust_list (__NR_Linux + 273) 917#define __NR_get_robust_list (__NR_Linux + 273)
914#define __NR_kexec_load (__NR_Linux + 274) 918#define __NR_kexec_load (__NR_Linux + 274)
919#define __NR_getcpu (__NR_Linux + 275)
920#define __NR_epoll_pwait (__NR_Linux + 276)
915 921
916/* 922/*
917 * Offset of the last N32 flavoured syscall 923 * Offset of the last N32 flavoured syscall
918 */ 924 */
919#define __NR_Linux_syscalls 274 925#define __NR_Linux_syscalls 276
920 926
921#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 927#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
922 928
923#define __NR_N32_Linux 6000 929#define __NR_N32_Linux 6000
924#define __NR_N32_Linux_syscalls 274 930#define __NR_N32_Linux_syscalls 276
925 931
926#ifdef __KERNEL__ 932#ifdef __KERNEL__
927 933
@@ -1189,6 +1195,7 @@ type name (atype a,btype b,ctype c,dtype d,etype e,ftype f) \
1189#endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */ 1195#endif /* (_MIPS_SIM == _MIPS_SIM_NABI32) || (_MIPS_SIM == _MIPS_SIM_ABI64) */
1190 1196
1191 1197
1198#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
1192#define __ARCH_WANT_IPC_PARSE_VERSION 1199#define __ARCH_WANT_IPC_PARSE_VERSION
1193#define __ARCH_WANT_OLD_READDIR 1200#define __ARCH_WANT_OLD_READDIR
1194#define __ARCH_WANT_SYS_ALARM 1201#define __ARCH_WANT_SYS_ALARM
diff --git a/include/asm-powerpc/current.h b/include/asm-powerpc/current.h
index 1938d6abd255..b8708aedf925 100644
--- a/include/asm-powerpc/current.h
+++ b/include/asm-powerpc/current.h
@@ -14,7 +14,17 @@ struct task_struct;
14#ifdef __powerpc64__ 14#ifdef __powerpc64__
15#include <asm/paca.h> 15#include <asm/paca.h>
16 16
17#define current (get_paca()->__current) 17static inline struct task_struct *get_current(void)
18{
19 struct task_struct *task;
20
21 __asm__ __volatile__("ld %0,%1(13)"
22 : "=r" (task)
23 : "i" (offsetof(struct paca_struct, __current)));
24
25 return task;
26}
27#define current get_current()
18 28
19#else 29#else
20 30
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index 3baff8b0fd5a..c2c5f14b5f5f 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -163,8 +163,11 @@ extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, long count);
163 163
164static inline void mmiowb(void) 164static inline void mmiowb(void)
165{ 165{
166 __asm__ __volatile__ ("sync" : : : "memory"); 166 unsigned long tmp;
167 get_paca()->io_sync = 0; 167
168 __asm__ __volatile__("sync; li %0,0; stb %0,%1(13)"
169 : "=&r" (tmp) : "i" (offsetof(struct paca_struct, io_sync))
170 : "memory");
168} 171}
169 172
170/* 173/*
diff --git a/include/asm-powerpc/iommu.h b/include/asm-powerpc/iommu.h
index a5e98641a2ae..39fad685ffab 100644
--- a/include/asm-powerpc/iommu.h
+++ b/include/asm-powerpc/iommu.h
@@ -22,17 +22,35 @@
22#define _ASM_IOMMU_H 22#define _ASM_IOMMU_H
23#ifdef __KERNEL__ 23#ifdef __KERNEL__
24 24
25#include <asm/types.h> 25#include <linux/compiler.h>
26#include <linux/spinlock.h> 26#include <linux/spinlock.h>
27#include <linux/device.h> 27#include <linux/device.h>
28#include <linux/dma-mapping.h> 28#include <linux/dma-mapping.h>
29#include <asm/types.h>
30#include <asm/bitops.h>
31
32#define IOMMU_PAGE_SHIFT 12
33#define IOMMU_PAGE_SIZE (ASM_CONST(1) << IOMMU_PAGE_SHIFT)
34#define IOMMU_PAGE_MASK (~((1 << IOMMU_PAGE_SHIFT) - 1))
35#define IOMMU_PAGE_ALIGN(addr) _ALIGN_UP(addr, IOMMU_PAGE_SIZE)
36
37#ifndef __ASSEMBLY__
38
39/* Pure 2^n version of get_order */
40static __inline__ __attribute_const__ int get_iommu_order(unsigned long size)
41{
42 return __ilog2((size - 1) >> IOMMU_PAGE_SHIFT) + 1;
43}
44
45#endif /* __ASSEMBLY__ */
46
29 47
30/* 48/*
31 * IOMAP_MAX_ORDER defines the largest contiguous block 49 * IOMAP_MAX_ORDER defines the largest contiguous block
32 * of dma space we can get. IOMAP_MAX_ORDER = 13 50 * of dma space we can get. IOMAP_MAX_ORDER = 13
33 * allows up to 2**12 pages (4096 * 4096) = 16 MB 51 * allows up to 2**12 pages (4096 * 4096) = 16 MB
34 */ 52 */
35#define IOMAP_MAX_ORDER 13 53#define IOMAP_MAX_ORDER 13
36 54
37struct iommu_table { 55struct iommu_table {
38 unsigned long it_busno; /* Bus number this table belongs to */ 56 unsigned long it_busno; /* Bus number this table belongs to */
diff --git a/include/asm-powerpc/oprofile_impl.h b/include/asm-powerpc/oprofile_impl.h
index 5b33994cd488..07a10e590c1d 100644
--- a/include/asm-powerpc/oprofile_impl.h
+++ b/include/asm-powerpc/oprofile_impl.h
@@ -42,7 +42,7 @@ struct op_powerpc_model {
42 void (*reg_setup) (struct op_counter_config *, 42 void (*reg_setup) (struct op_counter_config *,
43 struct op_system_config *, 43 struct op_system_config *,
44 int num_counters); 44 int num_counters);
45 void (*cpu_setup) (void *); 45 void (*cpu_setup) (struct op_counter_config *);
46 void (*start) (struct op_counter_config *); 46 void (*start) (struct op_counter_config *);
47 void (*stop) (void); 47 void (*stop) (void);
48 void (*handle_interrupt) (struct pt_regs *, 48 void (*handle_interrupt) (struct pt_regs *,
@@ -121,7 +121,90 @@ static inline void ctr_write(unsigned int i, unsigned int val)
121 break; 121 break;
122 } 122 }
123} 123}
124#endif /* !CONFIG_FSL_BOOKE */ 124#else /* CONFIG_FSL_BOOKE */
125static inline u32 get_pmlca(int ctr)
126{
127 u32 pmlca;
128
129 switch (ctr) {
130 case 0:
131 pmlca = mfpmr(PMRN_PMLCA0);
132 break;
133 case 1:
134 pmlca = mfpmr(PMRN_PMLCA1);
135 break;
136 case 2:
137 pmlca = mfpmr(PMRN_PMLCA2);
138 break;
139 case 3:
140 pmlca = mfpmr(PMRN_PMLCA3);
141 break;
142 default:
143 panic("Bad ctr number\n");
144 }
145
146 return pmlca;
147}
148
149static inline void set_pmlca(int ctr, u32 pmlca)
150{
151 switch (ctr) {
152 case 0:
153 mtpmr(PMRN_PMLCA0, pmlca);
154 break;
155 case 1:
156 mtpmr(PMRN_PMLCA1, pmlca);
157 break;
158 case 2:
159 mtpmr(PMRN_PMLCA2, pmlca);
160 break;
161 case 3:
162 mtpmr(PMRN_PMLCA3, pmlca);
163 break;
164 default:
165 panic("Bad ctr number\n");
166 }
167}
168
169static inline unsigned int ctr_read(unsigned int i)
170{
171 switch(i) {
172 case 0:
173 return mfpmr(PMRN_PMC0);
174 case 1:
175 return mfpmr(PMRN_PMC1);
176 case 2:
177 return mfpmr(PMRN_PMC2);
178 case 3:
179 return mfpmr(PMRN_PMC3);
180 default:
181 return 0;
182 }
183}
184
185static inline void ctr_write(unsigned int i, unsigned int val)
186{
187 switch(i) {
188 case 0:
189 mtpmr(PMRN_PMC0, val);
190 break;
191 case 1:
192 mtpmr(PMRN_PMC1, val);
193 break;
194 case 2:
195 mtpmr(PMRN_PMC2, val);
196 break;
197 case 3:
198 mtpmr(PMRN_PMC3, val);
199 break;
200 default:
201 break;
202 }
203}
204
205
206#endif /* CONFIG_FSL_BOOKE */
207
125 208
126extern void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth); 209extern void op_powerpc_backtrace(struct pt_regs * const regs, unsigned int depth);
127 210
diff --git a/include/asm-powerpc/pmc.h b/include/asm-powerpc/pmc.h
index 07d6a4279319..8588be68e0ad 100644
--- a/include/asm-powerpc/pmc.h
+++ b/include/asm-powerpc/pmc.h
@@ -32,18 +32,5 @@ void release_pmc_hardware(void);
32void power4_enable_pmcs(void); 32void power4_enable_pmcs(void);
33#endif 33#endif
34 34
35#ifdef CONFIG_FSL_BOOKE
36void init_pmc_stop(int ctr);
37void set_pmc_event(int ctr, int event);
38void set_pmc_user_kernel(int ctr, int user, int kernel);
39void set_pmc_marked(int ctr, int mark0, int mark1);
40void pmc_start_ctr(int ctr, int enable);
41void pmc_start_ctrs(int enable);
42void pmc_stop_ctrs(void);
43void dump_pmcs(void);
44
45extern struct op_powerpc_model op_model_fsl_booke;
46#endif
47
48#endif /* __KERNEL__ */ 35#endif /* __KERNEL__ */
49#endif /* _POWERPC_PMC_H */ 36#endif /* _POWERPC_PMC_H */
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index 43627596003b..f7b1227d6454 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -25,8 +25,8 @@
25 * 25 *
26 * We have to use the sync instructions for mb(), since lwsync doesn't 26 * We have to use the sync instructions for mb(), since lwsync doesn't
27 * order loads with respect to previous stores. Lwsync is fine for 27 * order loads with respect to previous stores. Lwsync is fine for
28 * rmb(), though. Note that lwsync is interpreted as sync by 28 * rmb(), though. Note that rmb() actually uses a sync on 32-bit
29 * 32-bit and older 64-bit CPUs. 29 * architectures.
30 * 30 *
31 * For wmb(), we use sync since wmb is used in drivers to order 31 * For wmb(), we use sync since wmb is used in drivers to order
32 * stores to system memory with respect to writes to the device. 32 * stores to system memory with respect to writes to the device.
@@ -34,7 +34,7 @@
34 * SMP since it is only used to order updates to system memory. 34 * SMP since it is only used to order updates to system memory.
35 */ 35 */
36#define mb() __asm__ __volatile__ ("sync" : : : "memory") 36#define mb() __asm__ __volatile__ ("sync" : : : "memory")
37#define rmb() __asm__ __volatile__ ("lwsync" : : : "memory") 37#define rmb() __asm__ __volatile__ (__stringify(LWSYNC) : : : "memory")
38#define wmb() __asm__ __volatile__ ("sync" : : : "memory") 38#define wmb() __asm__ __volatile__ ("sync" : : : "memory")
39#define read_barrier_depends() do { } while(0) 39#define read_barrier_depends() do { } while(0)
40 40
diff --git a/include/asm-powerpc/tce.h b/include/asm-powerpc/tce.h
index c9483adbf599..f663634cccc9 100644
--- a/include/asm-powerpc/tce.h
+++ b/include/asm-powerpc/tce.h
@@ -22,6 +22,8 @@
22#define _ASM_POWERPC_TCE_H 22#define _ASM_POWERPC_TCE_H
23#ifdef __KERNEL__ 23#ifdef __KERNEL__
24 24
25#include <asm/iommu.h>
26
25/* 27/*
26 * Tces come in two formats, one for the virtual bus and a different 28 * Tces come in two formats, one for the virtual bus and a different
27 * format for PCI 29 * format for PCI
@@ -33,7 +35,6 @@
33 35
34#define TCE_SHIFT 12 36#define TCE_SHIFT 12
35#define TCE_PAGE_SIZE (1 << TCE_SHIFT) 37#define TCE_PAGE_SIZE (1 << TCE_SHIFT)
36#define TCE_PAGE_FACTOR (PAGE_SHIFT - TCE_SHIFT)
37 38
38#define TCE_ENTRY_SIZE 8 /* each TCE is 64 bits */ 39#define TCE_ENTRY_SIZE 8 /* each TCE is 64 bits */
39 40
diff --git a/include/asm-sh/irq.h b/include/asm-sh/irq.h
index 7596ab83e0d4..6cd3e9e2a76a 100644
--- a/include/asm-sh/irq.h
+++ b/include/asm-sh/irq.h
@@ -327,11 +327,17 @@ extern unsigned short *irq_mask_register;
327 */ 327 */
328void init_IRQ_pint(void); 328void init_IRQ_pint(void);
329 329
330struct ipr_data {
331 unsigned int irq;
332 unsigned int addr; /* Address of Interrupt Priority Register */
333 int shift; /* Shifts of the 16-bit data */
334 int priority; /* The priority */
335};
336
330/* 337/*
331 * Function for "on chip support modules". 338 * Function for "on chip support modules".
332 */ 339 */
333extern void make_ipr_irq(unsigned int irq, unsigned int addr, 340extern void make_ipr_irq(struct ipr_data *table, unsigned int nr_irqs);
334 int pos, int priority);
335extern void make_imask_irq(unsigned int irq); 341extern void make_imask_irq(unsigned int irq);
336 342
337#if defined(CONFIG_CPU_SUBTYPE_SH7300) 343#if defined(CONFIG_CPU_SUBTYPE_SH7300)
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
index f1a0cbc966be..1c2abde122cd 100644
--- a/include/asm-sh/unistd.h
+++ b/include/asm-sh/unistd.h
@@ -324,8 +324,11 @@
324#define __NR_sync_file_range 314 324#define __NR_sync_file_range 314
325#define __NR_tee 315 325#define __NR_tee 315
326#define __NR_vmsplice 316 326#define __NR_vmsplice 316
327#define __NR_move_pages 317
328#define __NR_getcpu 318
329#define __NR_epoll_pwait 319
327 330
328#define NR_syscalls 317 331#define NR_syscalls 320
329 332
330#ifdef __KERNEL__ 333#ifdef __KERNEL__
331 334
diff --git a/include/asm-sparc64/futex.h b/include/asm-sparc64/futex.h
index dee40206b221..7392fc4a954e 100644
--- a/include/asm-sparc64/futex.h
+++ b/include/asm-sparc64/futex.h
@@ -87,24 +87,22 @@ static inline int
87futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) 87futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
88{ 88{
89 __asm__ __volatile__( 89 __asm__ __volatile__(
90 "\n1: lduwa [%2] %%asi, %0\n" 90 "\n1: casa [%3] %%asi, %2, %0\n"
91 "2: casa [%2] %%asi, %0, %1\n" 91 "2:\n"
92 "3:\n"
93 " .section .fixup,#alloc,#execinstr\n" 92 " .section .fixup,#alloc,#execinstr\n"
94 " .align 4\n" 93 " .align 4\n"
95 "4: ba 3b\n" 94 "3: ba 2b\n"
96 " mov %3, %0\n" 95 " mov %4, %0\n"
97 " .previous\n" 96 " .previous\n"
98 " .section __ex_table,\"a\"\n" 97 " .section __ex_table,\"a\"\n"
99 " .align 4\n" 98 " .align 4\n"
100 " .word 1b, 4b\n" 99 " .word 1b, 3b\n"
101 " .word 2b, 4b\n"
102 " .previous\n" 100 " .previous\n"
103 : "=&r" (oldval) 101 : "=r" (newval)
104 : "r" (newval), "r" (uaddr), "i" (-EFAULT) 102 : "0" (newval), "r" (oldval), "r" (uaddr), "i" (-EFAULT)
105 : "memory"); 103 : "memory");
106 104
107 return oldval; 105 return newval;
108} 106}
109 107
110#endif /* !(_SPARC64_FUTEX_H) */ 108#endif /* !(_SPARC64_FUTEX_H) */
diff --git a/include/asm-um/common.lds.S b/include/asm-um/common.lds.S
index 1010153faaf9..f0454516dd31 100644
--- a/include/asm-um/common.lds.S
+++ b/include/asm-um/common.lds.S
@@ -42,13 +42,7 @@
42 42
43 __initcall_start = .; 43 __initcall_start = .;
44 .initcall.init : { 44 .initcall.init : {
45 *(.initcall1.init) 45 INITCALLS
46 *(.initcall2.init)
47 *(.initcall3.init)
48 *(.initcall4.init)
49 *(.initcall5.init)
50 *(.initcall6.init)
51 *(.initcall7.init)
52 } 46 }
53 __initcall_end = .; 47 __initcall_end = .;
54 48
diff --git a/include/linux/libata.h b/include/linux/libata.h
index b03d5a340dc8..abd2debebca2 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -702,7 +702,6 @@ extern int ata_std_prereset(struct ata_port *ap);
702extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes); 702extern int ata_std_softreset(struct ata_port *ap, unsigned int *classes);
703extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class); 703extern int sata_std_hardreset(struct ata_port *ap, unsigned int *class);
704extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes); 704extern void ata_std_postreset(struct ata_port *ap, unsigned int *classes);
705extern int ata_dev_revalidate(struct ata_device *dev, int post_reset);
706extern void ata_port_disable(struct ata_port *); 705extern void ata_port_disable(struct ata_port *);
707extern void ata_std_ports(struct ata_ioports *ioaddr); 706extern void ata_std_ports(struct ata_ioports *ioaddr);
708#ifdef CONFIG_PCI 707#ifdef CONFIG_PCI
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 70420bbae82b..8b3ef4187219 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -355,7 +355,7 @@ struct nand_buffers {
355 * @priv: [OPTIONAL] pointer to private chip date 355 * @priv: [OPTIONAL] pointer to private chip date
356 * @errstat: [OPTIONAL] hardware specific function to perform additional error status checks 356 * @errstat: [OPTIONAL] hardware specific function to perform additional error status checks
357 * (determine if errors are correctable) 357 * (determine if errors are correctable)
358 * @write_page [REPLACEABLE] High-level page write function 358 * @write_page: [REPLACEABLE] High-level page write function
359 */ 359 */
360 360
361struct nand_chip { 361struct nand_chip {
diff --git a/include/linux/wait.h b/include/linux/wait.h
index b3b9048421d8..e820d00e1383 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -79,6 +79,15 @@ struct task_struct;
79 79
80extern void init_waitqueue_head(wait_queue_head_t *q); 80extern void init_waitqueue_head(wait_queue_head_t *q);
81 81
82#ifdef CONFIG_LOCKDEP
83# define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) \
84 ({ init_waitqueue_head(&name); name; })
85# define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) \
86 wait_queue_head_t name = __WAIT_QUEUE_HEAD_INIT_ONSTACK(name)
87#else
88# define DECLARE_WAIT_QUEUE_HEAD_ONSTACK(name) DECLARE_WAIT_QUEUE_HEAD(name)
89#endif
90
82static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p) 91static inline void init_waitqueue_entry(wait_queue_t *q, struct task_struct *p)
83{ 92{
84 q->flags = 0; 93 q->flags = 0;
diff --git a/kernel/module.c b/kernel/module.c
index 5072a943fe35..f0166563c602 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1718,7 +1718,7 @@ static struct module *load_module(void __user *umod,
1718 set_license(mod, get_modinfo(sechdrs, infoindex, "license")); 1718 set_license(mod, get_modinfo(sechdrs, infoindex, "license"));
1719 1719
1720 if (strcmp(mod->name, "ndiswrapper") == 0) 1720 if (strcmp(mod->name, "ndiswrapper") == 0)
1721 add_taint_module(mod, TAINT_PROPRIETARY_MODULE); 1721 add_taint(TAINT_PROPRIETARY_MODULE);
1722 if (strcmp(mod->name, "driverloader") == 0) 1722 if (strcmp(mod->name, "driverloader") == 0)
1723 add_taint_module(mod, TAINT_PROPRIETARY_MODULE); 1723 add_taint_module(mod, TAINT_PROPRIETARY_MODULE);
1724 1724
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 2039585ec5e1..f45c5e70773c 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -455,10 +455,9 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
455 int is_thread_group; 455 int is_thread_group;
456 struct nlattr *na; 456 struct nlattr *na;
457 457
458 if (!family_registered || !tidstats) 458 if (!family_registered)
459 return; 459 return;
460 460
461 rc = 0;
462 /* 461 /*
463 * Size includes space for nested attributes 462 * Size includes space for nested attributes
464 */ 463 */
@@ -466,8 +465,15 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
466 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0); 465 nla_total_size(sizeof(struct taskstats)) + nla_total_size(0);
467 466
468 is_thread_group = (tsk->signal->stats != NULL); 467 is_thread_group = (tsk->signal->stats != NULL);
469 if (is_thread_group) 468 if (is_thread_group) {
470 size = 2 * size; /* PID + STATS + TGID + STATS */ 469 /* PID + STATS + TGID + STATS */
470 size = 2 * size;
471 /* fill the tsk->signal->stats structure */
472 fill_tgid_exit(tsk);
473 }
474
475 if (!tidstats)
476 return;
471 477
472 rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, &reply, size); 478 rc = prepare_reply(NULL, TASKSTATS_CMD_NEW, &rep_skb, &reply, size);
473 if (rc < 0) 479 if (rc < 0)
@@ -487,11 +493,8 @@ void taskstats_exit_send(struct task_struct *tsk, struct taskstats *tidstats,
487 goto send; 493 goto send;
488 494
489 /* 495 /*
490 * tsk has/had a thread group so fill the tsk->signal->stats structure
491 * Doesn't matter if tsk is the leader or the last group member leaving 496 * Doesn't matter if tsk is the leader or the last group member leaving
492 */ 497 */
493
494 fill_tgid_exit(tsk);
495 if (!group_dead) 498 if (!group_dead)
496 goto send; 499 goto send;
497 500
diff --git a/kernel/tsacct.c b/kernel/tsacct.c
index 65a5036a3d95..96f77013d3f0 100644
--- a/kernel/tsacct.c
+++ b/kernel/tsacct.c
@@ -80,13 +80,17 @@ void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk)
80 */ 80 */
81void xacct_add_tsk(struct taskstats *stats, struct task_struct *p) 81void xacct_add_tsk(struct taskstats *stats, struct task_struct *p)
82{ 82{
83 struct mm_struct *mm;
84
83 /* convert pages-jiffies to Mbyte-usec */ 85 /* convert pages-jiffies to Mbyte-usec */
84 stats->coremem = jiffies_to_usecs(p->acct_rss_mem1) * PAGE_SIZE / MB; 86 stats->coremem = jiffies_to_usecs(p->acct_rss_mem1) * PAGE_SIZE / MB;
85 stats->virtmem = jiffies_to_usecs(p->acct_vm_mem1) * PAGE_SIZE / MB; 87 stats->virtmem = jiffies_to_usecs(p->acct_vm_mem1) * PAGE_SIZE / MB;
86 if (p->mm) { 88 mm = get_task_mm(p);
89 if (mm) {
87 /* adjust to KB unit */ 90 /* adjust to KB unit */
88 stats->hiwater_rss = p->mm->hiwater_rss * PAGE_SIZE / KB; 91 stats->hiwater_rss = mm->hiwater_rss * PAGE_SIZE / KB;
89 stats->hiwater_vm = p->mm->hiwater_vm * PAGE_SIZE / KB; 92 stats->hiwater_vm = mm->hiwater_vm * PAGE_SIZE / KB;
93 mmput(mm);
90 } 94 }
91 stats->read_char = p->rchar; 95 stats->read_char = p->rchar;
92 stats->write_char = p->wchar; 96 stats->write_char = p->wchar;
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index 708e2e0371af..485e35c3b28b 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1584,7 +1584,6 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1584 1584
1585 if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) { 1585 if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) {
1586 rt = atrtr_find(&usat->sat_addr); 1586 rt = atrtr_find(&usat->sat_addr);
1587 dev = rt->dev;
1588 } else { 1587 } else {
1589 struct atalk_addr at_hint; 1588 struct atalk_addr at_hint;
1590 1589
@@ -1592,7 +1591,6 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr
1592 at_hint.s_net = at->src_net; 1591 at_hint.s_net = at->src_net;
1593 1592
1594 rt = atrtr_find(&at_hint); 1593 rt = atrtr_find(&at_hint);
1595 dev = rt->dev;
1596 } 1594 }
1597 if (!rt) 1595 if (!rt)
1598 return -ENETUNREACH; 1596 return -ENETUNREACH;
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 3df55b2bd91d..9f85666f29f7 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -86,7 +86,7 @@ static inline int ebt_do_match (struct ebt_entry_match *m,
86static inline int ebt_dev_check(char *entry, const struct net_device *device) 86static inline int ebt_dev_check(char *entry, const struct net_device *device)
87{ 87{
88 int i = 0; 88 int i = 0;
89 char *devname = device->name; 89 const char *devname = device->name;
90 90
91 if (*entry == '\0') 91 if (*entry == '\0')
92 return 0; 92 return 0;
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 3c23760c5827..f735455dc5d1 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -1946,7 +1946,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
1946 do { 1946 do {
1947 struct sk_buff *nskb; 1947 struct sk_buff *nskb;
1948 skb_frag_t *frag; 1948 skb_frag_t *frag;
1949 int hsize, nsize; 1949 int hsize;
1950 int k; 1950 int k;
1951 int size; 1951 int size;
1952 1952
@@ -1957,11 +1957,10 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features)
1957 hsize = skb_headlen(skb) - offset; 1957 hsize = skb_headlen(skb) - offset;
1958 if (hsize < 0) 1958 if (hsize < 0)
1959 hsize = 0; 1959 hsize = 0;
1960 nsize = hsize + doffset; 1960 if (hsize > len || !sg)
1961 if (nsize > len + doffset || !sg) 1961 hsize = len;
1962 nsize = len + doffset;
1963 1962
1964 nskb = alloc_skb(nsize + headroom, GFP_ATOMIC); 1963 nskb = alloc_skb(hsize + doffset + headroom, GFP_ATOMIC);
1965 if (unlikely(!nskb)) 1964 if (unlikely(!nskb))
1966 goto err; 1965 goto err;
1967 1966
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c
index 2fbb84bf4e26..162032baeac0 100644
--- a/net/dccp/ccids/ccid2.c
+++ b/net/dccp/ccids/ccid2.c
@@ -352,14 +352,14 @@ static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, int len)
352 352
353#ifdef CONFIG_IP_DCCP_CCID2_DEBUG 353#ifdef CONFIG_IP_DCCP_CCID2_DEBUG
354 ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe); 354 ccid2_pr_debug("pipe=%d\n", hctx->ccid2hctx_pipe);
355 ccid2_pr_debug("Sent: seq=%llu\n", seq); 355 ccid2_pr_debug("Sent: seq=%llu\n", (unsigned long long)seq);
356 do { 356 do {
357 struct ccid2_seq *seqp = hctx->ccid2hctx_seqt; 357 struct ccid2_seq *seqp = hctx->ccid2hctx_seqt;
358 358
359 while (seqp != hctx->ccid2hctx_seqh) { 359 while (seqp != hctx->ccid2hctx_seqh) {
360 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n", 360 ccid2_pr_debug("out seq=%llu acked=%d time=%lu\n",
361 seqp->ccid2s_seq, seqp->ccid2s_acked, 361 (unsigned long long)seqp->ccid2s_seq,
362 seqp->ccid2s_sent); 362 seqp->ccid2s_acked, seqp->ccid2s_sent);
363 seqp = seqp->ccid2s_next; 363 seqp = seqp->ccid2s_next;
364 } 364 }
365 } while (0); 365 } while (0);
@@ -480,7 +480,8 @@ static inline void ccid2_new_ack(struct sock *sk,
480 /* first measurement */ 480 /* first measurement */
481 if (hctx->ccid2hctx_srtt == -1) { 481 if (hctx->ccid2hctx_srtt == -1) {
482 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n", 482 ccid2_pr_debug("R: %lu Time=%lu seq=%llu\n",
483 r, jiffies, seqp->ccid2s_seq); 483 r, jiffies,
484 (unsigned long long)seqp->ccid2s_seq);
484 ccid2_change_srtt(hctx, r); 485 ccid2_change_srtt(hctx, r);
485 hctx->ccid2hctx_rttvar = r >> 1; 486 hctx->ccid2hctx_rttvar = r >> 1;
486 } else { 487 } else {
@@ -636,8 +637,9 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
636 u64 ackno_end_rl; 637 u64 ackno_end_rl;
637 638
638 dccp_set_seqno(&ackno_end_rl, ackno - rl); 639 dccp_set_seqno(&ackno_end_rl, ackno - rl);
639 ccid2_pr_debug("ackvec start:%llu end:%llu\n", ackno, 640 ccid2_pr_debug("ackvec start:%llu end:%llu\n",
640 ackno_end_rl); 641 (unsigned long long)ackno,
642 (unsigned long long)ackno_end_rl);
641 /* if the seqno we are analyzing is larger than the 643 /* if the seqno we are analyzing is larger than the
642 * current ackno, then move towards the tail of our 644 * current ackno, then move towards the tail of our
643 * seqnos. 645 * seqnos.
@@ -672,7 +674,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
672 674
673 seqp->ccid2s_acked = 1; 675 seqp->ccid2s_acked = 1;
674 ccid2_pr_debug("Got ack for %llu\n", 676 ccid2_pr_debug("Got ack for %llu\n",
675 seqp->ccid2s_seq); 677 (unsigned long long)seqp->ccid2s_seq);
676 ccid2_hc_tx_dec_pipe(sk); 678 ccid2_hc_tx_dec_pipe(sk);
677 } 679 }
678 if (seqp == hctx->ccid2hctx_seqt) { 680 if (seqp == hctx->ccid2hctx_seqt) {
@@ -718,7 +720,7 @@ static void ccid2_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb)
718 while (1) { 720 while (1) {
719 if (!seqp->ccid2s_acked) { 721 if (!seqp->ccid2s_acked) {
720 ccid2_pr_debug("Packet lost: %llu\n", 722 ccid2_pr_debug("Packet lost: %llu\n",
721 seqp->ccid2s_seq); 723 (unsigned long long)seqp->ccid2s_seq);
722 /* XXX need to traverse from tail -> head in 724 /* XXX need to traverse from tail -> head in
723 * order to detect multiple congestion events in 725 * order to detect multiple congestion events in
724 * one ack vector. 726 * one ack vector.
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index e2077a3aa8c0..6460233407c7 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -1307,7 +1307,8 @@ int cipso_v4_socket_setattr(const struct socket *sock,
1307 1307
1308 /* We can't use ip_options_get() directly because it makes a call to 1308 /* We can't use ip_options_get() directly because it makes a call to
1309 * ip_options_get_alloc() which allocates memory with GFP_KERNEL and 1309 * ip_options_get_alloc() which allocates memory with GFP_KERNEL and
1310 * we can't block here. */ 1310 * we won't always have CAP_NET_RAW even though we _always_ want to
1311 * set the IPOPT_CIPSO option. */
1311 opt_len = (buf_len + 3) & ~3; 1312 opt_len = (buf_len + 3) & ~3;
1312 opt = kzalloc(sizeof(*opt) + opt_len, GFP_ATOMIC); 1313 opt = kzalloc(sizeof(*opt) + opt_len, GFP_ATOMIC);
1313 if (opt == NULL) { 1314 if (opt == NULL) {
@@ -1317,11 +1318,9 @@ int cipso_v4_socket_setattr(const struct socket *sock,
1317 memcpy(opt->__data, buf, buf_len); 1318 memcpy(opt->__data, buf, buf_len);
1318 opt->optlen = opt_len; 1319 opt->optlen = opt_len;
1319 opt->is_data = 1; 1320 opt->is_data = 1;
1321 opt->cipso = sizeof(struct iphdr);
1320 kfree(buf); 1322 kfree(buf);
1321 buf = NULL; 1323 buf = NULL;
1322 ret_val = ip_options_compile(opt, NULL);
1323 if (ret_val != 0)
1324 goto socket_setattr_failure;
1325 1324
1326 sk_inet = inet_sk(sk); 1325 sk_inet = inet_sk(sk);
1327 if (sk_inet->is_icsk) { 1326 if (sk_inet->is_icsk) {
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index 8dabbfc31267..9f02917d6f45 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -443,7 +443,7 @@ int ip_options_compile(struct ip_options * opt, struct sk_buff * skb)
443 opt->router_alert = optptr - iph; 443 opt->router_alert = optptr - iph;
444 break; 444 break;
445 case IPOPT_CIPSO: 445 case IPOPT_CIPSO:
446 if (opt->cipso) { 446 if ((!skb && !capable(CAP_NET_RAW)) || opt->cipso) {
447 pp_ptr = optptr; 447 pp_ptr = optptr;
448 goto error; 448 goto error;
449 } 449 }
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 0849f1cced13..413c2d0a1f3d 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -466,7 +466,13 @@ static inline int check_entry(struct arpt_entry *e, const char *name, unsigned i
466 return -EINVAL; 466 return -EINVAL;
467 } 467 }
468 468
469 if (e->target_offset + sizeof(struct arpt_entry_target) > e->next_offset)
470 return -EINVAL;
471
469 t = arpt_get_target(e); 472 t = arpt_get_target(e);
473 if (e->target_offset + t->u.target_size > e->next_offset)
474 return -EINVAL;
475
470 target = try_then_request_module(xt_find_target(NF_ARP, t->u.user.name, 476 target = try_then_request_module(xt_find_target(NF_ARP, t->u.user.name,
471 t->u.user.revision), 477 t->u.user.revision),
472 "arpt_%s", t->u.user.name); 478 "arpt_%s", t->u.user.name);
@@ -621,20 +627,18 @@ static int translate_table(const char *name,
621 } 627 }
622 } 628 }
623 629
624 if (!mark_source_chains(newinfo, valid_hooks, entry0)) {
625 duprintf("Looping hook\n");
626 return -ELOOP;
627 }
628
629 /* Finally, each sanity check must pass */ 630 /* Finally, each sanity check must pass */
630 i = 0; 631 i = 0;
631 ret = ARPT_ENTRY_ITERATE(entry0, newinfo->size, 632 ret = ARPT_ENTRY_ITERATE(entry0, newinfo->size,
632 check_entry, name, size, &i); 633 check_entry, name, size, &i);
633 634
634 if (ret != 0) { 635 if (ret != 0)
635 ARPT_ENTRY_ITERATE(entry0, newinfo->size, 636 goto cleanup;
636 cleanup_entry, &i); 637
637 return ret; 638 ret = -ELOOP;
639 if (!mark_source_chains(newinfo, valid_hooks, entry0)) {
640 duprintf("Looping hook\n");
641 goto cleanup;
638 } 642 }
639 643
640 /* And one copy for every other CPU */ 644 /* And one copy for every other CPU */
@@ -643,6 +647,9 @@ static int translate_table(const char *name,
643 memcpy(newinfo->entries[i], entry0, newinfo->size); 647 memcpy(newinfo->entries[i], entry0, newinfo->size);
644 } 648 }
645 649
650 return 0;
651cleanup:
652 ARPT_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
646 return ret; 653 return ret;
647} 654}
648 655
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 4b90927619b8..8a455439b128 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -547,12 +547,18 @@ check_entry(struct ipt_entry *e, const char *name, unsigned int size,
547 return -EINVAL; 547 return -EINVAL;
548 } 548 }
549 549
550 if (e->target_offset + sizeof(struct ipt_entry_target) > e->next_offset)
551 return -EINVAL;
552
550 j = 0; 553 j = 0;
551 ret = IPT_MATCH_ITERATE(e, check_match, name, &e->ip, e->comefrom, &j); 554 ret = IPT_MATCH_ITERATE(e, check_match, name, &e->ip, e->comefrom, &j);
552 if (ret != 0) 555 if (ret != 0)
553 goto cleanup_matches; 556 goto cleanup_matches;
554 557
555 t = ipt_get_target(e); 558 t = ipt_get_target(e);
559 ret = -EINVAL;
560 if (e->target_offset + t->u.target_size > e->next_offset)
561 goto cleanup_matches;
556 target = try_then_request_module(xt_find_target(AF_INET, 562 target = try_then_request_module(xt_find_target(AF_INET,
557 t->u.user.name, 563 t->u.user.name,
558 t->u.user.revision), 564 t->u.user.revision),
@@ -712,19 +718,17 @@ translate_table(const char *name,
712 } 718 }
713 } 719 }
714 720
715 if (!mark_source_chains(newinfo, valid_hooks, entry0))
716 return -ELOOP;
717
718 /* Finally, each sanity check must pass */ 721 /* Finally, each sanity check must pass */
719 i = 0; 722 i = 0;
720 ret = IPT_ENTRY_ITERATE(entry0, newinfo->size, 723 ret = IPT_ENTRY_ITERATE(entry0, newinfo->size,
721 check_entry, name, size, &i); 724 check_entry, name, size, &i);
722 725
723 if (ret != 0) { 726 if (ret != 0)
724 IPT_ENTRY_ITERATE(entry0, newinfo->size, 727 goto cleanup;
725 cleanup_entry, &i); 728
726 return ret; 729 ret = -ELOOP;
727 } 730 if (!mark_source_chains(newinfo, valid_hooks, entry0))
731 goto cleanup;
728 732
729 /* And one copy for every other CPU */ 733 /* And one copy for every other CPU */
730 for_each_possible_cpu(i) { 734 for_each_possible_cpu(i) {
@@ -732,6 +736,9 @@ translate_table(const char *name,
732 memcpy(newinfo->entries[i], entry0, newinfo->size); 736 memcpy(newinfo->entries[i], entry0, newinfo->size);
733 } 737 }
734 738
739 return 0;
740cleanup:
741 IPT_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
735 return ret; 742 return ret;
736} 743}
737 744
@@ -1463,6 +1470,10 @@ check_compat_entry_size_and_hooks(struct ipt_entry *e,
1463 return -EINVAL; 1470 return -EINVAL;
1464 } 1471 }
1465 1472
1473 if (e->target_offset + sizeof(struct compat_xt_entry_target) >
1474 e->next_offset)
1475 return -EINVAL;
1476
1466 off = 0; 1477 off = 0;
1467 entry_offset = (void *)e - (void *)base; 1478 entry_offset = (void *)e - (void *)base;
1468 j = 0; 1479 j = 0;
@@ -1472,6 +1483,9 @@ check_compat_entry_size_and_hooks(struct ipt_entry *e,
1472 goto cleanup_matches; 1483 goto cleanup_matches;
1473 1484
1474 t = ipt_get_target(e); 1485 t = ipt_get_target(e);
1486 ret = -EINVAL;
1487 if (e->target_offset + t->u.target_size > e->next_offset)
1488 goto cleanup_matches;
1475 target = try_then_request_module(xt_find_target(AF_INET, 1489 target = try_then_request_module(xt_find_target(AF_INET,
1476 t->u.user.name, 1490 t->u.user.name,
1477 t->u.user.revision), 1491 t->u.user.revision),
@@ -1513,7 +1527,7 @@ cleanup_matches:
1513 1527
1514static inline int compat_copy_match_from_user(struct ipt_entry_match *m, 1528static inline int compat_copy_match_from_user(struct ipt_entry_match *m,
1515 void **dstptr, compat_uint_t *size, const char *name, 1529 void **dstptr, compat_uint_t *size, const char *name,
1516 const struct ipt_ip *ip, unsigned int hookmask, int *i) 1530 const struct ipt_ip *ip, unsigned int hookmask)
1517{ 1531{
1518 struct ipt_entry_match *dm; 1532 struct ipt_entry_match *dm;
1519 struct ipt_match *match; 1533 struct ipt_match *match;
@@ -1526,22 +1540,13 @@ static inline int compat_copy_match_from_user(struct ipt_entry_match *m,
1526 ret = xt_check_match(match, AF_INET, dm->u.match_size - sizeof(*dm), 1540 ret = xt_check_match(match, AF_INET, dm->u.match_size - sizeof(*dm),
1527 name, hookmask, ip->proto, 1541 name, hookmask, ip->proto,
1528 ip->invflags & IPT_INV_PROTO); 1542 ip->invflags & IPT_INV_PROTO);
1529 if (ret) 1543 if (!ret && m->u.kernel.match->checkentry
1530 goto err;
1531
1532 if (m->u.kernel.match->checkentry
1533 && !m->u.kernel.match->checkentry(name, ip, match, dm->data, 1544 && !m->u.kernel.match->checkentry(name, ip, match, dm->data,
1534 hookmask)) { 1545 hookmask)) {
1535 duprintf("ip_tables: check failed for `%s'.\n", 1546 duprintf("ip_tables: check failed for `%s'.\n",
1536 m->u.kernel.match->name); 1547 m->u.kernel.match->name);
1537 ret = -EINVAL; 1548 ret = -EINVAL;
1538 goto err;
1539 } 1549 }
1540 (*i)++;
1541 return 0;
1542
1543err:
1544 module_put(m->u.kernel.match->me);
1545 return ret; 1550 return ret;
1546} 1551}
1547 1552
@@ -1553,19 +1558,18 @@ static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
1553 struct ipt_target *target; 1558 struct ipt_target *target;
1554 struct ipt_entry *de; 1559 struct ipt_entry *de;
1555 unsigned int origsize; 1560 unsigned int origsize;
1556 int ret, h, j; 1561 int ret, h;
1557 1562
1558 ret = 0; 1563 ret = 0;
1559 origsize = *size; 1564 origsize = *size;
1560 de = (struct ipt_entry *)*dstptr; 1565 de = (struct ipt_entry *)*dstptr;
1561 memcpy(de, e, sizeof(struct ipt_entry)); 1566 memcpy(de, e, sizeof(struct ipt_entry));
1562 1567
1563 j = 0;
1564 *dstptr += sizeof(struct compat_ipt_entry); 1568 *dstptr += sizeof(struct compat_ipt_entry);
1565 ret = IPT_MATCH_ITERATE(e, compat_copy_match_from_user, dstptr, size, 1569 ret = IPT_MATCH_ITERATE(e, compat_copy_match_from_user, dstptr, size,
1566 name, &de->ip, de->comefrom, &j); 1570 name, &de->ip, de->comefrom);
1567 if (ret) 1571 if (ret)
1568 goto cleanup_matches; 1572 goto err;
1569 de->target_offset = e->target_offset - (origsize - *size); 1573 de->target_offset = e->target_offset - (origsize - *size);
1570 t = ipt_get_target(e); 1574 t = ipt_get_target(e);
1571 target = t->u.kernel.target; 1575 target = t->u.kernel.target;
@@ -1599,12 +1603,7 @@ static int compat_copy_entry_from_user(struct ipt_entry *e, void **dstptr,
1599 goto err; 1603 goto err;
1600 } 1604 }
1601 ret = 0; 1605 ret = 0;
1602 return ret;
1603
1604err: 1606err:
1605 module_put(t->u.kernel.target->me);
1606cleanup_matches:
1607 IPT_MATCH_ITERATE(e, cleanup_match, &j);
1608 return ret; 1607 return ret;
1609} 1608}
1610 1609
@@ -1618,7 +1617,7 @@ translate_compat_table(const char *name,
1618 unsigned int *hook_entries, 1617 unsigned int *hook_entries,
1619 unsigned int *underflows) 1618 unsigned int *underflows)
1620{ 1619{
1621 unsigned int i; 1620 unsigned int i, j;
1622 struct xt_table_info *newinfo, *info; 1621 struct xt_table_info *newinfo, *info;
1623 void *pos, *entry0, *entry1; 1622 void *pos, *entry0, *entry1;
1624 unsigned int size; 1623 unsigned int size;
@@ -1636,21 +1635,21 @@ translate_compat_table(const char *name,
1636 } 1635 }
1637 1636
1638 duprintf("translate_compat_table: size %u\n", info->size); 1637 duprintf("translate_compat_table: size %u\n", info->size);
1639 i = 0; 1638 j = 0;
1640 xt_compat_lock(AF_INET); 1639 xt_compat_lock(AF_INET);
1641 /* Walk through entries, checking offsets. */ 1640 /* Walk through entries, checking offsets. */
1642 ret = IPT_ENTRY_ITERATE(entry0, total_size, 1641 ret = IPT_ENTRY_ITERATE(entry0, total_size,
1643 check_compat_entry_size_and_hooks, 1642 check_compat_entry_size_and_hooks,
1644 info, &size, entry0, 1643 info, &size, entry0,
1645 entry0 + total_size, 1644 entry0 + total_size,
1646 hook_entries, underflows, &i, name); 1645 hook_entries, underflows, &j, name);
1647 if (ret != 0) 1646 if (ret != 0)
1648 goto out_unlock; 1647 goto out_unlock;
1649 1648
1650 ret = -EINVAL; 1649 ret = -EINVAL;
1651 if (i != number) { 1650 if (j != number) {
1652 duprintf("translate_compat_table: %u not %u entries\n", 1651 duprintf("translate_compat_table: %u not %u entries\n",
1653 i, number); 1652 j, number);
1654 goto out_unlock; 1653 goto out_unlock;
1655 } 1654 }
1656 1655
@@ -1709,8 +1708,10 @@ translate_compat_table(const char *name,
1709free_newinfo: 1708free_newinfo:
1710 xt_free_table_info(newinfo); 1709 xt_free_table_info(newinfo);
1711out: 1710out:
1711 IPT_ENTRY_ITERATE(entry0, total_size, cleanup_entry, &j);
1712 return ret; 1712 return ret;
1713out_unlock: 1713out_unlock:
1714 compat_flush_offsets();
1714 xt_compat_unlock(AF_INET); 1715 xt_compat_unlock(AF_INET);
1715 goto out; 1716 goto out;
1716} 1717}
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index b430cf2a4f66..5c31dead2bdc 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -329,7 +329,7 @@ error:
329 return err; 329 return err;
330} 330}
331 331
332static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg) 332static int raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
333{ 333{
334 struct iovec *iov; 334 struct iovec *iov;
335 u8 __user *type = NULL; 335 u8 __user *type = NULL;
@@ -338,7 +338,7 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
338 unsigned int i; 338 unsigned int i;
339 339
340 if (!msg->msg_iov) 340 if (!msg->msg_iov)
341 return; 341 return 0;
342 342
343 for (i = 0; i < msg->msg_iovlen; i++) { 343 for (i = 0; i < msg->msg_iovlen; i++) {
344 iov = &msg->msg_iov[i]; 344 iov = &msg->msg_iov[i];
@@ -360,8 +360,9 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
360 code = iov->iov_base; 360 code = iov->iov_base;
361 361
362 if (type && code) { 362 if (type && code) {
363 get_user(fl->fl_icmp_type, type); 363 if (get_user(fl->fl_icmp_type, type) ||
364 get_user(fl->fl_icmp_code, code); 364 get_user(fl->fl_icmp_code, code))
365 return -EFAULT;
365 probed = 1; 366 probed = 1;
366 } 367 }
367 break; 368 break;
@@ -372,6 +373,7 @@ static void raw_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
372 if (probed) 373 if (probed)
373 break; 374 break;
374 } 375 }
376 return 0;
375} 377}
376 378
377static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, 379static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
@@ -480,8 +482,11 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
480 .proto = inet->hdrincl ? IPPROTO_RAW : 482 .proto = inet->hdrincl ? IPPROTO_RAW :
481 sk->sk_protocol, 483 sk->sk_protocol,
482 }; 484 };
483 if (!inet->hdrincl) 485 if (!inet->hdrincl) {
484 raw_probe_proto_opt(&fl, msg); 486 err = raw_probe_proto_opt(&fl, msg);
487 if (err)
488 goto done;
489 }
485 490
486 security_sk_classify_flow(sk, &fl); 491 security_sk_classify_flow(sk, &fl);
487 err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT)); 492 err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index e82a5be894b5..15061b314411 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -129,13 +129,6 @@ static int sysctl_tcp_congestion_control(ctl_table *table, int __user *name,
129 return ret; 129 return ret;
130} 130}
131 131
132static int __init tcp_congestion_default(void)
133{
134 return tcp_set_default_congestion_control(CONFIG_DEFAULT_TCP_CONG);
135}
136
137late_initcall(tcp_congestion_default);
138
139ctl_table ipv4_table[] = { 132ctl_table ipv4_table[] = {
140 { 133 {
141 .ctl_name = NET_IPV4_TCP_TIMESTAMPS, 134 .ctl_name = NET_IPV4_TCP_TIMESTAMPS,
diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index af0aca1e6be6..1e2982f4acd4 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -131,6 +131,14 @@ int tcp_set_default_congestion_control(const char *name)
131 return ret; 131 return ret;
132} 132}
133 133
134/* Set default value from kernel configuration at bootup */
135static int __init tcp_congestion_default(void)
136{
137 return tcp_set_default_congestion_control(CONFIG_DEFAULT_TCP_CONG);
138}
139late_initcall(tcp_congestion_default);
140
141
134/* Get current default congestion control */ 142/* Get current default congestion control */
135void tcp_get_default_congestion_control(char *name) 143void tcp_get_default_congestion_control(char *name)
136{ 144{
diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c
index 1d672b0547f2..6d4533b58dca 100644
--- a/net/ipv6/ip6_flowlabel.c
+++ b/net/ipv6/ip6_flowlabel.c
@@ -330,8 +330,10 @@ fl_create(struct in6_flowlabel_req *freq, char __user *optval, int optlen, int *
330 fl->share = freq->flr_share; 330 fl->share = freq->flr_share;
331 addr_type = ipv6_addr_type(&freq->flr_dst); 331 addr_type = ipv6_addr_type(&freq->flr_dst);
332 if ((addr_type&IPV6_ADDR_MAPPED) 332 if ((addr_type&IPV6_ADDR_MAPPED)
333 || addr_type == IPV6_ADDR_ANY) 333 || addr_type == IPV6_ADDR_ANY) {
334 err = -EINVAL;
334 goto done; 335 goto done;
336 }
335 ipv6_addr_copy(&fl->dst, &freq->flr_dst); 337 ipv6_addr_copy(&fl->dst, &freq->flr_dst);
336 atomic_set(&fl->users, 1); 338 atomic_set(&fl->users, 1);
337 switch (fl->share) { 339 switch (fl->share) {
@@ -587,6 +589,8 @@ static struct ip6_flowlabel *ip6fl_get_next(struct seq_file *seq, struct ip6_flo
587 while (!fl) { 589 while (!fl) {
588 if (++state->bucket <= FL_HASH_MASK) 590 if (++state->bucket <= FL_HASH_MASK)
589 fl = fl_ht[state->bucket]; 591 fl = fl_ht[state->bucket];
592 else
593 break;
590 } 594 }
591 return fl; 595 return fl;
592} 596}
@@ -623,9 +627,13 @@ static void ip6fl_seq_stop(struct seq_file *seq, void *v)
623 read_unlock_bh(&ip6_fl_lock); 627 read_unlock_bh(&ip6_fl_lock);
624} 628}
625 629
626static void ip6fl_fl_seq_show(struct seq_file *seq, struct ip6_flowlabel *fl) 630static int ip6fl_seq_show(struct seq_file *seq, void *v)
627{ 631{
628 while(fl) { 632 if (v == SEQ_START_TOKEN)
633 seq_printf(seq, "%-5s %-1s %-6s %-6s %-6s %-8s %-32s %s\n",
634 "Label", "S", "Owner", "Users", "Linger", "Expires", "Dst", "Opt");
635 else {
636 struct ip6_flowlabel *fl = v;
629 seq_printf(seq, 637 seq_printf(seq,
630 "%05X %-1d %-6d %-6d %-6ld %-8ld " NIP6_SEQFMT " %-4d\n", 638 "%05X %-1d %-6d %-6d %-6ld %-8ld " NIP6_SEQFMT " %-4d\n",
631 (unsigned)ntohl(fl->label), 639 (unsigned)ntohl(fl->label),
@@ -636,17 +644,7 @@ static void ip6fl_fl_seq_show(struct seq_file *seq, struct ip6_flowlabel *fl)
636 (long)(fl->expires - jiffies)/HZ, 644 (long)(fl->expires - jiffies)/HZ,
637 NIP6(fl->dst), 645 NIP6(fl->dst),
638 fl->opt ? fl->opt->opt_nflen : 0); 646 fl->opt ? fl->opt->opt_nflen : 0);
639 fl = fl->next;
640 } 647 }
641}
642
643static int ip6fl_seq_show(struct seq_file *seq, void *v)
644{
645 if (v == SEQ_START_TOKEN)
646 seq_printf(seq, "%-5s %-1s %-6s %-6s %-6s %-8s %-32s %s\n",
647 "Label", "S", "Owner", "Users", "Linger", "Expires", "Dst", "Opt");
648 else
649 ip6fl_fl_seq_show(seq, v);
650 return 0; 648 return 0;
651} 649}
652 650
diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig
index 4bc4e5b33794..d7c45a9c15fe 100644
--- a/net/ipv6/netfilter/Kconfig
+++ b/net/ipv6/netfilter/Kconfig
@@ -40,7 +40,7 @@ config IP6_NF_QUEUE
40 To compile it as a module, choose M here. If unsure, say N. 40 To compile it as a module, choose M here. If unsure, say N.
41 41
42config IP6_NF_IPTABLES 42config IP6_NF_IPTABLES
43 tristate "IP6 tables support (required for filtering/masq/NAT)" 43 tristate "IP6 tables support (required for filtering)"
44 depends on NETFILTER_XTABLES 44 depends on NETFILTER_XTABLES
45 help 45 help
46 ip6tables is a general, extensible packet identification framework. 46 ip6tables is a general, extensible packet identification framework.
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 53bf977cca63..167c2ea88f6b 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -586,12 +586,19 @@ check_entry(struct ip6t_entry *e, const char *name, unsigned int size,
586 return -EINVAL; 586 return -EINVAL;
587 } 587 }
588 588
589 if (e->target_offset + sizeof(struct ip6t_entry_target) >
590 e->next_offset)
591 return -EINVAL;
592
589 j = 0; 593 j = 0;
590 ret = IP6T_MATCH_ITERATE(e, check_match, name, &e->ipv6, e->comefrom, &j); 594 ret = IP6T_MATCH_ITERATE(e, check_match, name, &e->ipv6, e->comefrom, &j);
591 if (ret != 0) 595 if (ret != 0)
592 goto cleanup_matches; 596 goto cleanup_matches;
593 597
594 t = ip6t_get_target(e); 598 t = ip6t_get_target(e);
599 ret = -EINVAL;
600 if (e->target_offset + t->u.target_size > e->next_offset)
601 goto cleanup_matches;
595 target = try_then_request_module(xt_find_target(AF_INET6, 602 target = try_then_request_module(xt_find_target(AF_INET6,
596 t->u.user.name, 603 t->u.user.name,
597 t->u.user.revision), 604 t->u.user.revision),
@@ -751,19 +758,17 @@ translate_table(const char *name,
751 } 758 }
752 } 759 }
753 760
754 if (!mark_source_chains(newinfo, valid_hooks, entry0))
755 return -ELOOP;
756
757 /* Finally, each sanity check must pass */ 761 /* Finally, each sanity check must pass */
758 i = 0; 762 i = 0;
759 ret = IP6T_ENTRY_ITERATE(entry0, newinfo->size, 763 ret = IP6T_ENTRY_ITERATE(entry0, newinfo->size,
760 check_entry, name, size, &i); 764 check_entry, name, size, &i);
761 765
762 if (ret != 0) { 766 if (ret != 0)
763 IP6T_ENTRY_ITERATE(entry0, newinfo->size, 767 goto cleanup;
764 cleanup_entry, &i); 768
765 return ret; 769 ret = -ELOOP;
766 } 770 if (!mark_source_chains(newinfo, valid_hooks, entry0))
771 goto cleanup;
767 772
768 /* And one copy for every other CPU */ 773 /* And one copy for every other CPU */
769 for_each_possible_cpu(i) { 774 for_each_possible_cpu(i) {
@@ -771,6 +776,9 @@ translate_table(const char *name,
771 memcpy(newinfo->entries[i], entry0, newinfo->size); 776 memcpy(newinfo->entries[i], entry0, newinfo->size);
772 } 777 }
773 778
779 return 0;
780cleanup:
781 IP6T_ENTRY_ITERATE(entry0, newinfo->size, cleanup_entry, &i);
774 return ret; 782 return ret;
775} 783}
776 784
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index d09329ca3267..d6dedc4aec77 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -604,7 +604,7 @@ error:
604 return err; 604 return err;
605} 605}
606 606
607static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg) 607static int rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
608{ 608{
609 struct iovec *iov; 609 struct iovec *iov;
610 u8 __user *type = NULL; 610 u8 __user *type = NULL;
@@ -616,7 +616,7 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
616 int i; 616 int i;
617 617
618 if (!msg->msg_iov) 618 if (!msg->msg_iov)
619 return; 619 return 0;
620 620
621 for (i = 0; i < msg->msg_iovlen; i++) { 621 for (i = 0; i < msg->msg_iovlen; i++) {
622 iov = &msg->msg_iov[i]; 622 iov = &msg->msg_iov[i];
@@ -638,8 +638,9 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
638 code = iov->iov_base; 638 code = iov->iov_base;
639 639
640 if (type && code) { 640 if (type && code) {
641 get_user(fl->fl_icmp_type, type); 641 if (get_user(fl->fl_icmp_type, type) ||
642 get_user(fl->fl_icmp_code, code); 642 get_user(fl->fl_icmp_code, code))
643 return -EFAULT;
643 probed = 1; 644 probed = 1;
644 } 645 }
645 break; 646 break;
@@ -650,7 +651,8 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
650 /* check if type field is readable or not. */ 651 /* check if type field is readable or not. */
651 if (iov->iov_len > 2 - len) { 652 if (iov->iov_len > 2 - len) {
652 u8 __user *p = iov->iov_base; 653 u8 __user *p = iov->iov_base;
653 get_user(fl->fl_mh_type, &p[2 - len]); 654 if (get_user(fl->fl_mh_type, &p[2 - len]))
655 return -EFAULT;
654 probed = 1; 656 probed = 1;
655 } else 657 } else
656 len += iov->iov_len; 658 len += iov->iov_len;
@@ -664,6 +666,7 @@ static void rawv6_probe_proto_opt(struct flowi *fl, struct msghdr *msg)
664 if (probed) 666 if (probed)
665 break; 667 break;
666 } 668 }
669 return 0;
667} 670}
668 671
669static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, 672static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
@@ -787,7 +790,9 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
787 opt = ipv6_fixup_options(&opt_space, opt); 790 opt = ipv6_fixup_options(&opt_space, opt);
788 791
789 fl.proto = proto; 792 fl.proto = proto;
790 rawv6_probe_proto_opt(&fl, msg); 793 err = rawv6_probe_proto_opt(&fl, msg);
794 if (err)
795 goto out;
791 796
792 ipv6_addr_copy(&fl.fl6_dst, daddr); 797 ipv6_addr_copy(&fl.fl6_dst, daddr);
793 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr)) 798 if (ipv6_addr_any(&fl.fl6_src) && !ipv6_addr_any(&np->saddr))
diff --git a/net/ipv6/xfrm6_tunnel.c b/net/ipv6/xfrm6_tunnel.c
index 7af227bb1551..7931e4f898d4 100644
--- a/net/ipv6/xfrm6_tunnel.c
+++ b/net/ipv6/xfrm6_tunnel.c
@@ -135,7 +135,7 @@ u32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr)
135 x6spi = __xfrm6_tunnel_spi_lookup(saddr); 135 x6spi = __xfrm6_tunnel_spi_lookup(saddr);
136 spi = x6spi ? x6spi->spi : 0; 136 spi = x6spi ? x6spi->spi : 0;
137 read_unlock_bh(&xfrm6_tunnel_spi_lock); 137 read_unlock_bh(&xfrm6_tunnel_spi_lock);
138 return spi; 138 return htonl(spi);
139} 139}
140 140
141EXPORT_SYMBOL(xfrm6_tunnel_spi_lookup); 141EXPORT_SYMBOL(xfrm6_tunnel_spi_lookup);
@@ -210,7 +210,7 @@ u32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr)
210 spi = __xfrm6_tunnel_alloc_spi(saddr); 210 spi = __xfrm6_tunnel_alloc_spi(saddr);
211 write_unlock_bh(&xfrm6_tunnel_spi_lock); 211 write_unlock_bh(&xfrm6_tunnel_spi_lock);
212 212
213 return spi; 213 return htonl(spi);
214} 214}
215 215
216EXPORT_SYMBOL(xfrm6_tunnel_alloc_spi); 216EXPORT_SYMBOL(xfrm6_tunnel_alloc_spi);
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 093b3ddc513c..836541e509fe 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1520,9 +1520,10 @@ get_next_corpse(int (*iter)(struct nf_conn *i, void *data),
1520 if (iter(ct, data)) 1520 if (iter(ct, data))
1521 goto found; 1521 goto found;
1522 } 1522 }
1523 write_unlock_bh(&nf_conntrack_lock);
1523 return NULL; 1524 return NULL;
1524found: 1525found:
1525 atomic_inc(&nf_ct_tuplehash_to_ctrack(h)->ct_general.use); 1526 atomic_inc(&ct->ct_general.use);
1526 write_unlock_bh(&nf_conntrack_lock); 1527 write_unlock_bh(&nf_conntrack_lock);
1527 return ct; 1528 return ct;
1528} 1529}
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index d56e0d21f919..d527c8977b1f 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1075,8 +1075,9 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,
1075 return -EINVAL; 1075 return -EINVAL;
1076 len = sizeof(int); 1076 len = sizeof(int);
1077 val = nlk->flags & NETLINK_RECV_PKTINFO ? 1 : 0; 1077 val = nlk->flags & NETLINK_RECV_PKTINFO ? 1 : 0;
1078 put_user(len, optlen); 1078 if (put_user(len, optlen) ||
1079 put_user(val, optval); 1079 put_user(val, optval))
1080 return -EFAULT;
1080 err = 0; 1081 err = 0;
1081 break; 1082 break;
1082 default: 1083 default:
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index ef8874babf6a..0441876aa1e7 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -4,7 +4,7 @@
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License 5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License.
8 * 8 *
9 * Many of the algorithms and ideas for this came from 9 * Many of the algorithms and ideas for this came from
10 * NIST Net which is not copyrighted. 10 * NIST Net which is not copyrighted.
diff --git a/net/sctp/associola.c b/net/sctp/associola.c
index 27329ce9c311..ed0445fe85e7 100644
--- a/net/sctp/associola.c
+++ b/net/sctp/associola.c
@@ -346,11 +346,18 @@ void sctp_association_free(struct sctp_association *asoc)
346 struct list_head *pos, *temp; 346 struct list_head *pos, *temp;
347 int i; 347 int i;
348 348
349 list_del(&asoc->asocs); 349 /* Only real associations count against the endpoint, so
350 * don't bother for if this is a temporary association.
351 */
352 if (!asoc->temp) {
353 list_del(&asoc->asocs);
350 354
351 /* Decrement the backlog value for a TCP-style listening socket. */ 355 /* Decrement the backlog value for a TCP-style listening
352 if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING)) 356 * socket.
353 sk->sk_ack_backlog--; 357 */
358 if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))
359 sk->sk_ack_backlog--;
360 }
354 361
355 /* Mark as dead, so other users can know this structure is 362 /* Mark as dead, so other users can know this structure is
356 * going away. 363 * going away.
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
index 35c49ff2d062..9b6b394b66f6 100644
--- a/net/sctp/endpointola.c
+++ b/net/sctp/endpointola.c
@@ -144,6 +144,13 @@ void sctp_endpoint_add_asoc(struct sctp_endpoint *ep,
144{ 144{
145 struct sock *sk = ep->base.sk; 145 struct sock *sk = ep->base.sk;
146 146
147 /* If this is a temporary association, don't bother
148 * since we'll be removing it shortly and don't
149 * want anyone to find it anyway.
150 */
151 if (asoc->temp)
152 return;
153
147 /* Now just add it to our list of asocs */ 154 /* Now just add it to our list of asocs */
148 list_add_tail(&asoc->asocs, &ep->asocs); 155 list_add_tail(&asoc->asocs, &ep->asocs);
149 156
diff --git a/net/sctp/input.c b/net/sctp/input.c
index 64f630102532..6d82f400d13c 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -135,6 +135,9 @@ int sctp_rcv(struct sk_buff *skb)
135 135
136 SCTP_INC_STATS_BH(SCTP_MIB_INSCTPPACKS); 136 SCTP_INC_STATS_BH(SCTP_MIB_INSCTPPACKS);
137 137
138 if (skb_linearize(skb))
139 goto discard_it;
140
138 sh = (struct sctphdr *) skb->h.raw; 141 sh = (struct sctphdr *) skb->h.raw;
139 142
140 /* Pull up the IP and SCTP headers. */ 143 /* Pull up the IP and SCTP headers. */
@@ -768,6 +771,9 @@ static void __sctp_hash_established(struct sctp_association *asoc)
768/* Add an association to the hash. Local BH-safe. */ 771/* Add an association to the hash. Local BH-safe. */
769void sctp_hash_established(struct sctp_association *asoc) 772void sctp_hash_established(struct sctp_association *asoc)
770{ 773{
774 if (asoc->temp)
775 return;
776
771 sctp_local_bh_disable(); 777 sctp_local_bh_disable();
772 __sctp_hash_established(asoc); 778 __sctp_hash_established(asoc);
773 sctp_local_bh_enable(); 779 sctp_local_bh_enable();
@@ -801,6 +807,9 @@ static void __sctp_unhash_established(struct sctp_association *asoc)
801/* Remove association from the hash table. Local BH-safe. */ 807/* Remove association from the hash table. Local BH-safe. */
802void sctp_unhash_established(struct sctp_association *asoc) 808void sctp_unhash_established(struct sctp_association *asoc)
803{ 809{
810 if (asoc->temp)
811 return;
812
804 sctp_local_bh_disable(); 813 sctp_local_bh_disable();
805 __sctp_unhash_established(asoc); 814 __sctp_unhash_established(asoc);
806 sctp_local_bh_enable(); 815 sctp_local_bh_enable();
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index fac7674438a4..5b4f82fd98f8 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -591,7 +591,7 @@ static struct sock *sctp_v4_create_accept_sk(struct sock *sk,
591 newinet->dport = htons(asoc->peer.port); 591 newinet->dport = htons(asoc->peer.port);
592 newinet->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr; 592 newinet->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr;
593 newinet->pmtudisc = inet->pmtudisc; 593 newinet->pmtudisc = inet->pmtudisc;
594 newinet->id = 0; 594 newinet->id = asoc->next_tsn ^ jiffies;
595 595
596 newinet->uc_ttl = -1; 596 newinet->uc_ttl = -1;
597 newinet->mc_loop = 1; 597 newinet->mc_loop = 1;
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 9f34dec6ff8e..935bc9187fd8 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -3372,6 +3372,7 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,
3372{ 3372{
3373 struct sock *sk = asoc->base.sk; 3373 struct sock *sk = asoc->base.sk;
3374 struct socket *sock; 3374 struct socket *sock;
3375 struct inet_sock *inetsk;
3375 int err = 0; 3376 int err = 0;
3376 3377
3377 /* An association cannot be branched off from an already peeled-off 3378 /* An association cannot be branched off from an already peeled-off
@@ -3389,6 +3390,14 @@ SCTP_STATIC int sctp_do_peeloff(struct sctp_association *asoc,
3389 * asoc to the newsk. 3390 * asoc to the newsk.
3390 */ 3391 */
3391 sctp_sock_migrate(sk, sock->sk, asoc, SCTP_SOCKET_UDP_HIGH_BANDWIDTH); 3392 sctp_sock_migrate(sk, sock->sk, asoc, SCTP_SOCKET_UDP_HIGH_BANDWIDTH);
3393
3394 /* Make peeled-off sockets more like 1-1 accepted sockets.
3395 * Set the daddr and initialize id to something more random
3396 */
3397 inetsk = inet_sk(sock->sk);
3398 inetsk->daddr = asoc->peer.primary_addr.v4.sin_addr.s_addr;
3399 inetsk->id = asoc->next_tsn ^ jiffies;
3400
3392 *sockp = sock; 3401 *sockp = sock;
3393 3402
3394 return err; 3403 return err;
diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c
index 8f2320aded5c..0004c1f0ef04 100644
--- a/net/sunrpc/svcauth.c
+++ b/net/sunrpc/svcauth.c
@@ -147,10 +147,8 @@ auth_domain_lookup(char *name, struct auth_domain *new)
147 return hp; 147 return hp;
148 } 148 }
149 } 149 }
150 if (new) { 150 if (new)
151 hlist_add_head(&new->hash, head); 151 hlist_add_head(&new->hash, head);
152 kref_get(&new->ref);
153 }
154 spin_unlock(&auth_domain_lock); 152 spin_unlock(&auth_domain_lock);
155 return new; 153 return new;
156} 154}
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 96521f16342b..64ca1f61dd94 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -299,9 +299,15 @@ void svc_reserve(struct svc_rqst *rqstp, int space)
299static inline void 299static inline void
300svc_sock_put(struct svc_sock *svsk) 300svc_sock_put(struct svc_sock *svsk)
301{ 301{
302 if (atomic_dec_and_test(&svsk->sk_inuse) && test_bit(SK_DEAD, &svsk->sk_flags)) { 302 if (atomic_dec_and_test(&svsk->sk_inuse) &&
303 test_bit(SK_DEAD, &svsk->sk_flags)) {
303 dprintk("svc: releasing dead socket\n"); 304 dprintk("svc: releasing dead socket\n");
304 sock_release(svsk->sk_sock); 305 if (svsk->sk_sock->file)
306 sockfd_put(svsk->sk_sock);
307 else
308 sock_release(svsk->sk_sock);
309 if (svsk->sk_info_authunix != NULL)
310 svcauth_unix_info_release(svsk->sk_info_authunix);
305 kfree(svsk); 311 kfree(svsk);
306 } 312 }
307} 313}
@@ -1604,20 +1610,13 @@ svc_delete_socket(struct svc_sock *svsk)
1604 if (test_bit(SK_TEMP, &svsk->sk_flags)) 1610 if (test_bit(SK_TEMP, &svsk->sk_flags))
1605 serv->sv_tmpcnt--; 1611 serv->sv_tmpcnt--;
1606 1612
1607 if (!atomic_read(&svsk->sk_inuse)) { 1613 /* This atomic_inc should be needed - svc_delete_socket
1608 spin_unlock_bh(&serv->sv_lock); 1614 * should have the semantic of dropping a reference.
1609 if (svsk->sk_sock->file) 1615 * But it doesn't yet....
1610 sockfd_put(svsk->sk_sock); 1616 */
1611 else 1617 atomic_inc(&svsk->sk_inuse);
1612 sock_release(svsk->sk_sock); 1618 spin_unlock_bh(&serv->sv_lock);
1613 if (svsk->sk_info_authunix != NULL) 1619 svc_sock_put(svsk);
1614 svcauth_unix_info_release(svsk->sk_info_authunix);
1615 kfree(svsk);
1616 } else {
1617 spin_unlock_bh(&serv->sv_lock);
1618 dprintk(KERN_NOTICE "svc: server socket destroy delayed\n");
1619 /* svsk->sk_server = NULL; */
1620 }
1621} 1620}
1622 1621
1623/* 1622/*
diff --git a/net/tipc/port.c b/net/tipc/port.c
index c1a1a76759b5..b7f3199523ca 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -1136,11 +1136,12 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
1136 int res = -EINVAL; 1136 int res = -EINVAL;
1137 1137
1138 p_ptr = tipc_port_lock(ref); 1138 p_ptr = tipc_port_lock(ref);
1139 if (!p_ptr)
1140 return -EINVAL;
1141
1139 dbg("tipc_publ %u, p_ptr = %x, conn = %x, scope = %x, " 1142 dbg("tipc_publ %u, p_ptr = %x, conn = %x, scope = %x, "
1140 "lower = %u, upper = %u\n", 1143 "lower = %u, upper = %u\n",
1141 ref, p_ptr, p_ptr->publ.connected, scope, seq->lower, seq->upper); 1144 ref, p_ptr, p_ptr->publ.connected, scope, seq->lower, seq->upper);
1142 if (!p_ptr)
1143 return -EINVAL;
1144 if (p_ptr->publ.connected) 1145 if (p_ptr->publ.connected)
1145 goto exit; 1146 goto exit;
1146 if (seq->lower > seq->upper) 1147 if (seq->lower > seq->upper)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 2b2e59d8ffbc..b43e7647e125 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -323,7 +323,7 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info *
323 x->props.replay_window = p->replay_window; 323 x->props.replay_window = p->replay_window;
324 x->props.reqid = p->reqid; 324 x->props.reqid = p->reqid;
325 x->props.family = p->family; 325 x->props.family = p->family;
326 x->props.saddr = p->saddr; 326 memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr));
327 x->props.flags = p->flags; 327 x->props.flags = p->flags;
328} 328}
329 329
@@ -545,7 +545,7 @@ static void copy_to_user_state(struct xfrm_state *x, struct xfrm_usersa_info *p)
545 memcpy(&p->lft, &x->lft, sizeof(p->lft)); 545 memcpy(&p->lft, &x->lft, sizeof(p->lft));
546 memcpy(&p->curlft, &x->curlft, sizeof(p->curlft)); 546 memcpy(&p->curlft, &x->curlft, sizeof(p->curlft));
547 memcpy(&p->stats, &x->stats, sizeof(p->stats)); 547 memcpy(&p->stats, &x->stats, sizeof(p->stats));
548 p->saddr = x->props.saddr; 548 memcpy(&p->saddr, &x->props.saddr, sizeof(p->saddr));
549 p->mode = x->props.mode; 549 p->mode = x->props.mode;
550 p->replay_window = x->props.replay_window; 550 p->replay_window = x->props.replay_window;
551 p->reqid = x->props.reqid; 551 p->reqid = x->props.reqid;
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e9969a2fc846..8ab5679a37a3 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3313,7 +3313,13 @@ static int selinux_socket_getpeername(struct socket *sock)
3313 3313
3314static int selinux_socket_setsockopt(struct socket *sock,int level,int optname) 3314static int selinux_socket_setsockopt(struct socket *sock,int level,int optname)
3315{ 3315{
3316 return socket_has_perm(current, sock, SOCKET__SETOPT); 3316 int err;
3317
3318 err = socket_has_perm(current, sock, SOCKET__SETOPT);
3319 if (err)
3320 return err;
3321
3322 return selinux_netlbl_socket_setsockopt(sock, level, optname);
3317} 3323}
3318 3324
3319static int selinux_socket_getsockopt(struct socket *sock, int level, 3325static int selinux_socket_getsockopt(struct socket *sock, int level,
diff --git a/security/selinux/include/selinux_netlabel.h b/security/selinux/include/selinux_netlabel.h
index ecab4bddaaf4..9de10cc2cef2 100644
--- a/security/selinux/include/selinux_netlabel.h
+++ b/security/selinux/include/selinux_netlabel.h
@@ -53,6 +53,9 @@ void selinux_netlbl_sk_security_init(struct sk_security_struct *ssec,
53void selinux_netlbl_sk_clone_security(struct sk_security_struct *ssec, 53void selinux_netlbl_sk_clone_security(struct sk_security_struct *ssec,
54 struct sk_security_struct *newssec); 54 struct sk_security_struct *newssec);
55int selinux_netlbl_inode_permission(struct inode *inode, int mask); 55int selinux_netlbl_inode_permission(struct inode *inode, int mask);
56int selinux_netlbl_socket_setsockopt(struct socket *sock,
57 int level,
58 int optname);
56#else 59#else
57static inline void selinux_netlbl_cache_invalidate(void) 60static inline void selinux_netlbl_cache_invalidate(void)
58{ 61{
@@ -114,6 +117,13 @@ static inline int selinux_netlbl_inode_permission(struct inode *inode,
114{ 117{
115 return 0; 118 return 0;
116} 119}
120
121static inline int selinux_netlbl_socket_setsockopt(struct socket *sock,
122 int level,
123 int optname)
124{
125 return 0;
126}
117#endif /* CONFIG_NETLABEL */ 127#endif /* CONFIG_NETLABEL */
118 128
119#endif 129#endif
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index b1f6fb36c699..bfe122764c98 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2682,4 +2682,41 @@ u32 selinux_netlbl_socket_getpeersec_dgram(struct sk_buff *skb)
2682 2682
2683 return peer_sid; 2683 return peer_sid;
2684} 2684}
2685
2686/**
2687 * selinux_netlbl_socket_setsockopt - Do not allow users to remove a NetLabel
2688 * @sock: the socket
2689 * @level: the socket level or protocol
2690 * @optname: the socket option name
2691 *
2692 * Description:
2693 * Check the setsockopt() call and if the user is trying to replace the IP
2694 * options on a socket and a NetLabel is in place for the socket deny the
2695 * access; otherwise allow the access. Returns zero when the access is
2696 * allowed, -EACCES when denied, and other negative values on error.
2697 *
2698 */
2699int selinux_netlbl_socket_setsockopt(struct socket *sock,
2700 int level,
2701 int optname)
2702{
2703 int rc = 0;
2704 struct inode *inode = SOCK_INODE(sock);
2705 struct sk_security_struct *sksec = sock->sk->sk_security;
2706 struct inode_security_struct *isec = inode->i_security;
2707 struct netlbl_lsm_secattr secattr;
2708
2709 mutex_lock(&isec->lock);
2710 if (level == IPPROTO_IP && optname == IP_OPTIONS &&
2711 sksec->nlbl_state == NLBL_LABELED) {
2712 netlbl_secattr_init(&secattr);
2713 rc = netlbl_socket_getattr(sock, &secattr);
2714 if (rc == 0 && (secattr.cache || secattr.mls_lvl_vld))
2715 rc = -EACCES;
2716 netlbl_secattr_destroy(&secattr);
2717 }
2718 mutex_unlock(&isec->lock);
2719
2720 return rc;
2721}
2685#endif /* CONFIG_NETLABEL */ 2722#endif /* CONFIG_NETLABEL */