aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/filesystems/inotify.txt77
-rw-r--r--MAINTAINERS12
-rw-r--r--arch/arm/kernel/smp.c7
-rw-r--r--arch/arm/mach-integrator/platsmp.c8
-rw-r--r--arch/arm/mach-omap1/leds-h2p2-debug.c1
-rw-r--r--arch/arm/nwfpe/fpmodule.c1
-rw-r--r--arch/arm/plat-omap/ocpi.c1
-rw-r--r--arch/i386/mach-visws/reboot.c1
-rw-r--r--arch/i386/mach-voyager/voyager_basic.c1
-rw-r--r--arch/i386/mach-voyager/voyager_smp.c6
-rw-r--r--arch/ia64/Kconfig7
-rw-r--r--arch/ia64/configs/sn2_defconfig1
-rw-r--r--arch/ia64/kernel/setup.c37
-rw-r--r--arch/ia64/lib/flush.S46
-rw-r--r--arch/ia64/pci/pci.c12
-rw-r--r--arch/ia64/sn/kernel/io_init.c20
-rw-r--r--arch/ia64/sn/kernel/xpc_channel.c8
-rw-r--r--arch/ia64/sn/pci/pci_dma.c16
-rw-r--r--arch/ia64/sn/pci/pcibr/pcibr_provider.c10
-rw-r--r--arch/ia64/sn/pci/tioca_provider.c4
-rw-r--r--arch/ppc/boot/images/Makefile7
-rw-r--r--arch/ppc64/kernel/cpu_setup_power4.S38
-rw-r--r--arch/ppc64/kernel/cputable.c15
-rw-r--r--arch/ppc64/kernel/iSeries_htab.c51
-rw-r--r--arch/ppc64/kernel/iSeries_setup.c18
-rw-r--r--arch/ppc64/kernel/pSeries_lpar.c47
-rw-r--r--arch/ppc64/mm/hash_low.S8
-rw-r--r--arch/ppc64/mm/hash_native.c129
-rw-r--r--arch/ppc64/mm/hash_utils.c16
-rw-r--r--arch/ppc64/mm/hugetlbpage.c16
-rw-r--r--arch/ppc64/mm/init.c7
-rw-r--r--arch/s390/kernel/compat_linux.c38
-rw-r--r--arch/s390/kernel/compat_wrapper.S4
-rw-r--r--arch/um/Kconfig_net2
-rw-r--r--arch/um/Makefile30
-rw-r--r--arch/um/Makefile-i38631
-rw-r--r--arch/um/Makefile-x86_646
-rw-r--r--arch/um/drivers/Makefile17
-rw-r--r--arch/um/kernel/uml.lds.S4
-rw-r--r--arch/um/scripts/Makefile.unmap4
-rw-r--r--arch/um/sys-i386/ldt.c114
-rw-r--r--arch/um/sys-i386/unmap.c2
-rw-r--r--arch/um/sys-x86_64/signal.c2
-rw-r--r--arch/um/sys-x86_64/unmap.c2
-rw-r--r--arch/v850/kernel/vmlinux.lds.S5
-rw-r--r--drivers/char/rocket.c3
-rw-r--r--drivers/char/vt.c2
-rw-r--r--drivers/firmware/pcdp.h2
-rw-r--r--drivers/ieee1394/ohci1394.c3
-rw-r--r--drivers/input/joystick/amijoy.c2
-rw-r--r--drivers/md/bitmap.c9
-rw-r--r--drivers/md/raid0.c8
-rw-r--r--drivers/md/raid1.c37
-rw-r--r--drivers/media/dvb/frontends/lgdt3302.c16
-rw-r--r--drivers/media/video/cx88/cx88-cards.c8
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c4
-rw-r--r--drivers/media/video/cx88/cx88-video.c7
-rw-r--r--drivers/media/video/cx88/cx88.h6
-rw-r--r--drivers/media/video/tea5767.c34
-rw-r--r--drivers/media/video/tuner-core.c33
-rw-r--r--drivers/mtd/chips/Kconfig2
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c5
-rw-r--r--drivers/usb/serial/option.c228
-rw-r--r--fs/ext2/xip.c81
-rw-r--r--fs/hostfs/hostfs_kern.c9
-rw-r--r--fs/hppfs/hppfs_kern.c6
-rw-r--r--fs/inode.c45
-rw-r--r--fs/inotify.c58
-rw-r--r--fs/jffs2/build.c9
-rw-r--r--fs/jffs2/nodelist.c14
-rw-r--r--fs/jffs2/os-linux.h4
-rw-r--r--fs/jffs2/readinode.c11
-rw-r--r--fs/jffs2/super.c11
-rw-r--r--fs/jfs/jfs_dmap.c298
-rw-r--r--fs/jfs/jfs_dtree.c199
-rw-r--r--fs/jfs/jfs_dtree.h7
-rw-r--r--fs/jfs/jfs_imap.c105
-rw-r--r--fs/jfs/jfs_unicode.c7
-rw-r--r--fs/jfs/jfs_xtree.c340
-rw-r--r--fs/jfs/jfs_xtree.h6
-rw-r--r--fs/jfs/xattr.c6
-rw-r--r--fs/lockd/svc.c4
-rw-r--r--include/asm-arm/smp.h3
-rw-r--r--include/asm-ia64/pci.h1
-rw-r--r--include/asm-ia64/sn/pcibr_provider.h2
-rw-r--r--include/asm-ia64/sn/pcibus_provider_defs.h3
-rw-r--r--include/asm-ia64/sn/simulator.h9
-rw-r--r--include/asm-ia64/topology.h5
-rw-r--r--include/asm-ppc/mmu_context.h2
-rw-r--r--include/asm-ppc64/iSeries/HvCallHpt.h11
-rw-r--r--include/asm-ppc64/machdep.h6
-rw-r--r--include/asm-ppc64/mmu.h83
-rw-r--r--include/asm-um/ldt.h5
-rw-r--r--include/linux/fadvise.h10
-rw-r--r--include/linux/fs.h3
-rw-r--r--include/linux/fsnotify.h2
-rw-r--r--include/linux/raid/bitmap.h2
-rw-r--r--include/linux/sysctl.h12
-rw-r--r--init/do_mounts.c2
-rw-r--r--kernel/sysctl.c51
-rw-r--r--mm/filemap_xip.c23
-rwxr-xr-xscripts/Lindent2
102 files changed, 1023 insertions, 1732 deletions
diff --git a/Documentation/filesystems/inotify.txt b/Documentation/filesystems/inotify.txt
index 2c716041f578..6d501903f68e 100644
--- a/Documentation/filesystems/inotify.txt
+++ b/Documentation/filesystems/inotify.txt
@@ -1,18 +1,22 @@
1 inotify 1 inotify
2 a powerful yet simple file change notification system 2 a powerful yet simple file change notification system
3 3
4 4
5 5
6Document started 15 Mar 2005 by Robert Love <rml@novell.com> 6Document started 15 Mar 2005 by Robert Love <rml@novell.com>
7 7
8
8(i) User Interface 9(i) User Interface
9 10
10Inotify is controlled by a set of three sys calls 11Inotify is controlled by a set of three system calls and normal file I/O on a
12returned file descriptor.
11 13
12First step in using inotify is to initialise an inotify instance 14First step in using inotify is to initialise an inotify instance:
13 15
14 int fd = inotify_init (); 16 int fd = inotify_init ();
15 17
18Each instance is associated with a unique, ordered queue.
19
16Change events are managed by "watches". A watch is an (object,mask) pair where 20Change events are managed by "watches". A watch is an (object,mask) pair where
17the object is a file or directory and the mask is a bit mask of one or more 21the object is a file or directory and the mask is a bit mask of one or more
18inotify events that the application wishes to receive. See <linux/inotify.h> 22inotify events that the application wishes to receive. See <linux/inotify.h>
@@ -22,43 +26,52 @@ Watches are added via a path to the file.
22 26
23Watches on a directory will return events on any files inside of the directory. 27Watches on a directory will return events on any files inside of the directory.
24 28
25Adding a watch is simple, 29Adding a watch is simple:
26 30
27 int wd = inotify_add_watch (fd, path, mask); 31 int wd = inotify_add_watch (fd, path, mask);
28 32
29You can add a large number of files via something like 33Where "fd" is the return value from inotify_init(), path is the path to the
30 34object to watch, and mask is the watch mask (see <linux/inotify.h>).
31 for each file to watch {
32 int wd = inotify_add_watch (fd, file, mask);
33 }
34 35
35You can update an existing watch in the same manner, by passing in a new mask. 36You can update an existing watch in the same manner, by passing in a new mask.
36 37
37An existing watch is removed via the INOTIFY_IGNORE ioctl, for example 38An existing watch is removed via
38 39
39 inotify_rm_watch (fd, wd); 40 int ret = inotify_rm_watch (fd, wd);
40 41
41Events are provided in the form of an inotify_event structure that is read(2) 42Events are provided in the form of an inotify_event structure that is read(2)
42from a inotify instance fd. The filename is of dynamic length and follows the 43from a given inotify instance. The filename is of dynamic length and follows
43struct. It is of size len. The filename is padded with null bytes to ensure 44the struct. It is of size len. The filename is padded with null bytes to
44proper alignment. This padding is reflected in len. 45ensure proper alignment. This padding is reflected in len.
45 46
46You can slurp multiple events by passing a large buffer, for example 47You can slurp multiple events by passing a large buffer, for example
47 48
48 size_t len = read (fd, buf, BUF_LEN); 49 size_t len = read (fd, buf, BUF_LEN);
49 50
50Will return as many events as are available and fit in BUF_LEN. 51Where "buf" is a pointer to an array of "inotify_event" structures at least
52BUF_LEN bytes in size. The above example will return as many events as are
53available and fit in BUF_LEN.
51 54
52each inotify instance fd is also select()- and poll()-able. 55Each inotify instance fd is also select()- and poll()-able.
53 56
54You can find the size of the current event queue via the FIONREAD ioctl. 57You can find the size of the current event queue via the standard FIONREAD
58ioctl on the fd returned by inotify_init().
55 59
56All watches are destroyed and cleaned up on close. 60All watches are destroyed and cleaned up on close.
57 61
58 62
59(ii) Internal Kernel Implementation 63(ii)
64
65Prototypes:
66
67 int inotify_init (void);
68 int inotify_add_watch (int fd, const char *path, __u32 mask);
69 int inotify_rm_watch (int fd, __u32 mask);
70
60 71
61Each open inotify instance is associated with an inotify_device structure. 72(iii) Internal Kernel Implementation
73
74Each inotify instance is associated with an inotify_device structure.
62 75
63Each watch is associated with an inotify_watch structure. Watches are chained 76Each watch is associated with an inotify_watch structure. Watches are chained
64off of each associated device and each associated inode. 77off of each associated device and each associated inode.
@@ -66,7 +79,7 @@ off of each associated device and each associated inode.
66See fs/inotify.c for the locking and lifetime rules. 79See fs/inotify.c for the locking and lifetime rules.
67 80
68 81
69(iii) Rationale 82(iv) Rationale
70 83
71Q: What is the design decision behind not tying the watch to the open fd of 84Q: What is the design decision behind not tying the watch to the open fd of
72 the watched object? 85 the watched object?
@@ -75,9 +88,9 @@ A: Watches are associated with an open inotify device, not an open file.
75 This solves the primary problem with dnotify: keeping the file open pins 88 This solves the primary problem with dnotify: keeping the file open pins
76 the file and thus, worse, pins the mount. Dnotify is therefore infeasible 89 the file and thus, worse, pins the mount. Dnotify is therefore infeasible
77 for use on a desktop system with removable media as the media cannot be 90 for use on a desktop system with removable media as the media cannot be
78 unmounted. 91 unmounted. Watching a file should not require that it be open.
79 92
80Q: What is the design decision behind using an-fd-per-device as opposed to 93Q: What is the design decision behind using an-fd-per-instance as opposed to
81 an fd-per-watch? 94 an fd-per-watch?
82 95
83A: An fd-per-watch quickly consumes more file descriptors than are allowed, 96A: An fd-per-watch quickly consumes more file descriptors than are allowed,
@@ -86,8 +99,8 @@ A: An fd-per-watch quickly consumes more file descriptors than are allowed,
86 can use epoll, but requiring both is a silly and extraneous requirement. 99 can use epoll, but requiring both is a silly and extraneous requirement.
87 A watch consumes less memory than an open file, separating the number 100 A watch consumes less memory than an open file, separating the number
88 spaces is thus sensible. The current design is what user-space developers 101 spaces is thus sensible. The current design is what user-space developers
89 want: Users initialize inotify, once, and add n watches, requiring but one fd 102 want: Users initialize inotify, once, and add n watches, requiring but one
90 and no twiddling with fd limits. Initializing an inotify instance two 103 fd and no twiddling with fd limits. Initializing an inotify instance two
91 thousand times is silly. If we can implement user-space's preferences 104 thousand times is silly. If we can implement user-space's preferences
92 cleanly--and we can, the idr layer makes stuff like this trivial--then we 105 cleanly--and we can, the idr layer makes stuff like this trivial--then we
93 should. 106 should.
@@ -111,9 +124,6 @@ A: An fd-per-watch quickly consumes more file descriptors than are allowed,
111 example, love it. Trust me, I asked. It is not a surprise: Who'd want 124 example, love it. Trust me, I asked. It is not a surprise: Who'd want
112 to manage and block on 1000 fd's via select? 125 to manage and block on 1000 fd's via select?
113 126
114 - You'd have to manage the fd's, as an example: Call close() when you
115 received a delete event.
116
117 - No way to get out of band data. 127 - No way to get out of band data.
118 128
119 - 1024 is still too low. ;-) 129 - 1024 is still too low. ;-)
@@ -122,6 +132,11 @@ A: An fd-per-watch quickly consumes more file descriptors than are allowed,
122 scales to 1000s of directories, juggling 1000s of fd's just does not seem 132 scales to 1000s of directories, juggling 1000s of fd's just does not seem
123 the right interface. It is too heavy. 133 the right interface. It is too heavy.
124 134
135 Additionally, it _is_ possible to more than one instance and
136 juggle more than one queue and thus more than one associated fd. There
137 need not be a one-fd-per-process mapping; it is one-fd-per-queue and a
138 process can easily want more than one queue.
139
125Q: Why the system call approach? 140Q: Why the system call approach?
126 141
127A: The poor user-space interface is the second biggest problem with dnotify. 142A: The poor user-space interface is the second biggest problem with dnotify.
@@ -131,8 +146,6 @@ A: The poor user-space interface is the second biggest problem with dnotify.
131 Obtaining the fd and managing the watches could have been done either via a 146 Obtaining the fd and managing the watches could have been done either via a
132 device file or a family of new system calls. We decided to implement a 147 device file or a family of new system calls. We decided to implement a
133 family of system calls because that is the preffered approach for new kernel 148 family of system calls because that is the preffered approach for new kernel
134 features and it means our user interface requirements. 149 interfaces. The only real difference was whether we wanted to use open(2)
135 150 and ioctl(2) or a couple of new system calls. System calls beat ioctls.
136 Additionally, it _is_ possible to more than one instance and
137 juggle more than one queue and thus more than one associated fd.
138 151
diff --git a/MAINTAINERS b/MAINTAINERS
index 5d014725901c..48aa6d3d3ce9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1169,6 +1169,12 @@ L: linux-input@atrey.karlin.mff.cuni.cz
1169L: linux-joystick@atrey.karlin.mff.cuni.cz 1169L: linux-joystick@atrey.karlin.mff.cuni.cz
1170S: Maintained 1170S: Maintained
1171 1171
1172INOTIFY
1173P: John McCutchan and Robert Love
1174M: ttb@tentacle.dhs.org and rml@novell.com
1175L: linux-kernel@vger.kernel.org
1176S: Maintained
1177
1172INTEL 810/815 FRAMEBUFFER DRIVER 1178INTEL 810/815 FRAMEBUFFER DRIVER
1173P: Antonino Daplas 1179P: Antonino Daplas
1174M: adaplas@pol.net 1180M: adaplas@pol.net
@@ -2420,6 +2426,12 @@ L: linux-usb-users@lists.sourceforge.net
2420L: linux-usb-devel@lists.sourceforge.net 2426L: linux-usb-devel@lists.sourceforge.net
2421S: Maintained 2427S: Maintained
2422 2428
2429USB OPTION-CARD DRIVER
2430P: Matthias Urlichs
2431M: smurf@smurf.noris.de
2432L: linux-usb-devel@lists.sourceforge.net
2433S: Maintained
2434
2423USB OV511 DRIVER 2435USB OV511 DRIVER
2424P: Mark McClelland 2436P: Mark McClelland
2425M: mmcclell@bigfoot.com 2437M: mmcclell@bigfoot.com
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index a931409c8fe4..7ae45c3fc834 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -36,7 +36,7 @@
36 * The present bitmask indicates that the CPU is physically present. 36 * The present bitmask indicates that the CPU is physically present.
37 * The online bitmask indicates that the CPU is up and running. 37 * The online bitmask indicates that the CPU is up and running.
38 */ 38 */
39cpumask_t cpu_present_mask; 39cpumask_t cpu_possible_map;
40cpumask_t cpu_online_map; 40cpumask_t cpu_online_map;
41 41
42/* 42/*
@@ -235,7 +235,8 @@ void __init smp_prepare_boot_cpu(void)
235{ 235{
236 unsigned int cpu = smp_processor_id(); 236 unsigned int cpu = smp_processor_id();
237 237
238 cpu_set(cpu, cpu_present_mask); 238 cpu_set(cpu, cpu_possible_map);
239 cpu_set(cpu, cpu_present_map);
239 cpu_set(cpu, cpu_online_map); 240 cpu_set(cpu, cpu_online_map);
240} 241}
241 242
@@ -355,7 +356,7 @@ void show_ipi_list(struct seq_file *p)
355 356
356 seq_puts(p, "IPI:"); 357 seq_puts(p, "IPI:");
357 358
358 for_each_online_cpu(cpu) 359 for_each_present_cpu(cpu)
359 seq_printf(p, " %10lu", per_cpu(ipi_data, cpu).ipi_count); 360 seq_printf(p, " %10lu", per_cpu(ipi_data, cpu).ipi_count);
360 361
361 seq_putc(p, '\n'); 362 seq_putc(p, '\n');
diff --git a/arch/arm/mach-integrator/platsmp.c b/arch/arm/mach-integrator/platsmp.c
index ead15dfcb53d..2ba025777098 100644
--- a/arch/arm/mach-integrator/platsmp.c
+++ b/arch/arm/mach-integrator/platsmp.c
@@ -174,11 +174,13 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
174 max_cpus = ncores; 174 max_cpus = ncores;
175 175
176 /* 176 /*
177 * Initialise the present mask - this tells us which CPUs should 177 * Initialise the possible/present maps.
178 * be present. 178 * cpu_possible_map describes the set of CPUs which may be present
179 * cpu_present_map describes the set of CPUs populated
179 */ 180 */
180 for (i = 0; i < max_cpus; i++) { 181 for (i = 0; i < max_cpus; i++) {
181 cpu_set(i, cpu_present_mask); 182 cpu_set(i, cpu_possible_map);
183 cpu_set(i, cpu_present_map);
182 } 184 }
183 185
184 /* 186 /*
diff --git a/arch/arm/mach-omap1/leds-h2p2-debug.c b/arch/arm/mach-omap1/leds-h2p2-debug.c
index 6e98290cca5c..ec0d8285f243 100644
--- a/arch/arm/mach-omap1/leds-h2p2-debug.c
+++ b/arch/arm/mach-omap1/leds-h2p2-debug.c
@@ -13,7 +13,6 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/kernel_stat.h> 14#include <linux/kernel_stat.h>
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/version.h>
17 16
18#include <asm/io.h> 17#include <asm/io.h>
19#include <asm/hardware.h> 18#include <asm/hardware.h>
diff --git a/arch/arm/nwfpe/fpmodule.c b/arch/arm/nwfpe/fpmodule.c
index a806fea5c3ed..a8efcf34888e 100644
--- a/arch/arm/nwfpe/fpmodule.c
+++ b/arch/arm/nwfpe/fpmodule.c
@@ -24,7 +24,6 @@
24#include "fpa11.h" 24#include "fpa11.h"
25 25
26#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/version.h>
28#include <linux/config.h> 27#include <linux/config.h>
29 28
30/* XXX */ 29/* XXX */
diff --git a/arch/arm/plat-omap/ocpi.c b/arch/arm/plat-omap/ocpi.c
index 1fb16f9edfd5..2ede2ee8cae4 100644
--- a/arch/arm/plat-omap/ocpi.c
+++ b/arch/arm/plat-omap/ocpi.c
@@ -25,7 +25,6 @@
25 25
26#include <linux/config.h> 26#include <linux/config.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/version.h>
29#include <linux/types.h> 28#include <linux/types.h>
30#include <linux/errno.h> 29#include <linux/errno.h>
31#include <linux/kernel.h> 30#include <linux/kernel.h>
diff --git a/arch/i386/mach-visws/reboot.c b/arch/i386/mach-visws/reboot.c
index 3a81e904a7b8..95e4676594e1 100644
--- a/arch/i386/mach-visws/reboot.c
+++ b/arch/i386/mach-visws/reboot.c
@@ -7,6 +7,7 @@
7#include "piix4.h" 7#include "piix4.h"
8 8
9void (*pm_power_off)(void); 9void (*pm_power_off)(void);
10EXPORT_SYMBOL(pm_power_off);
10 11
11void machine_restart(char * __unused) 12void machine_restart(char * __unused)
12{ 13{
diff --git a/arch/i386/mach-voyager/voyager_basic.c b/arch/i386/mach-voyager/voyager_basic.c
index 3e439ce5e1b2..8680080a6a89 100644
--- a/arch/i386/mach-voyager/voyager_basic.c
+++ b/arch/i386/mach-voyager/voyager_basic.c
@@ -36,6 +36,7 @@
36 * Power off function, if any 36 * Power off function, if any
37 */ 37 */
38void (*pm_power_off)(void); 38void (*pm_power_off)(void);
39EXPORT_SYMBOL(pm_power_off);
39 40
40int voyager_level = 0; 41int voyager_level = 0;
41 42
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
index 8c8527593da0..0e1f4208b07c 100644
--- a/arch/i386/mach-voyager/voyager_smp.c
+++ b/arch/i386/mach-voyager/voyager_smp.c
@@ -10,6 +10,7 @@
10 * the voyager hal to provide the functionality 10 * the voyager hal to provide the functionality
11 */ 11 */
12#include <linux/config.h> 12#include <linux/config.h>
13#include <linux/module.h>
13#include <linux/mm.h> 14#include <linux/mm.h>
14#include <linux/kernel_stat.h> 15#include <linux/kernel_stat.h>
15#include <linux/delay.h> 16#include <linux/delay.h>
@@ -40,6 +41,7 @@ static unsigned long cpu_irq_affinity[NR_CPUS] __cacheline_aligned = { [0 ... NR
40/* per CPU data structure (for /proc/cpuinfo et al), visible externally 41/* per CPU data structure (for /proc/cpuinfo et al), visible externally
41 * indexed physically */ 42 * indexed physically */
42struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned; 43struct cpuinfo_x86 cpu_data[NR_CPUS] __cacheline_aligned;
44EXPORT_SYMBOL(cpu_data);
43 45
44/* physical ID of the CPU used to boot the system */ 46/* physical ID of the CPU used to boot the system */
45unsigned char boot_cpu_id; 47unsigned char boot_cpu_id;
@@ -72,6 +74,7 @@ static volatile unsigned long smp_invalidate_needed;
72/* Bitmask of currently online CPUs - used by setup.c for 74/* Bitmask of currently online CPUs - used by setup.c for
73 /proc/cpuinfo, visible externally but still physical */ 75 /proc/cpuinfo, visible externally but still physical */
74cpumask_t cpu_online_map = CPU_MASK_NONE; 76cpumask_t cpu_online_map = CPU_MASK_NONE;
77EXPORT_SYMBOL(cpu_online_map);
75 78
76/* Bitmask of CPUs present in the system - exported by i386_syms.c, used 79/* Bitmask of CPUs present in the system - exported by i386_syms.c, used
77 * by scheduler but indexed physically */ 80 * by scheduler but indexed physically */
@@ -238,6 +241,7 @@ static cpumask_t smp_commenced_mask = CPU_MASK_NONE;
238/* This is for the new dynamic CPU boot code */ 241/* This is for the new dynamic CPU boot code */
239cpumask_t cpu_callin_map = CPU_MASK_NONE; 242cpumask_t cpu_callin_map = CPU_MASK_NONE;
240cpumask_t cpu_callout_map = CPU_MASK_NONE; 243cpumask_t cpu_callout_map = CPU_MASK_NONE;
244EXPORT_SYMBOL(cpu_callout_map);
241 245
242/* The per processor IRQ masks (these are usually kept in sync) */ 246/* The per processor IRQ masks (these are usually kept in sync) */
243static __u16 vic_irq_mask[NR_CPUS] __cacheline_aligned; 247static __u16 vic_irq_mask[NR_CPUS] __cacheline_aligned;
@@ -978,6 +982,7 @@ void flush_tlb_page(struct vm_area_struct * vma, unsigned long va)
978 982
979 preempt_enable(); 983 preempt_enable();
980} 984}
985EXPORT_SYMBOL(flush_tlb_page);
981 986
982/* enable the requested IRQs */ 987/* enable the requested IRQs */
983static void 988static void
@@ -1109,6 +1114,7 @@ smp_call_function (void (*func) (void *info), void *info, int retry,
1109 1114
1110 return 0; 1115 return 0;
1111} 1116}
1117EXPORT_SYMBOL(smp_call_function);
1112 1118
1113/* Sorry about the name. In an APIC based system, the APICs 1119/* Sorry about the name. In an APIC based system, the APICs
1114 * themselves are programmed to send a timer interrupt. This is used 1120 * themselves are programmed to send a timer interrupt. This is used
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 2e08942339ad..cbb3e0cef93a 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -220,13 +220,6 @@ config IOSAPIC
220 depends on !IA64_HP_SIM 220 depends on !IA64_HP_SIM
221 default y 221 default y
222 222
223config IA64_SGI_SN_SIM
224 bool "SGI Medusa Simulator Support"
225 depends on IA64_SGI_SN2 || IA64_GENERIC
226 help
227 If you are compiling a kernel that will run under SGI's IA-64
228 simulator (Medusa) then say Y, otherwise say N.
229
230config IA64_SGI_SN_XP 223config IA64_SGI_SN_XP
231 tristate "Support communication between SGI SSIs" 224 tristate "Support communication between SGI SSIs"
232 select IA64_UNCACHED_ALLOCATOR 225 select IA64_UNCACHED_ALLOCATOR
diff --git a/arch/ia64/configs/sn2_defconfig b/arch/ia64/configs/sn2_defconfig
index c05613980300..04d0b00a2b8c 100644
--- a/arch/ia64/configs/sn2_defconfig
+++ b/arch/ia64/configs/sn2_defconfig
@@ -81,7 +81,6 @@ CONFIG_HOLES_IN_ZONE=y
81CONFIG_ARCH_DISCONTIGMEM_ENABLE=y 81CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
82# CONFIG_IA64_CYCLONE is not set 82# CONFIG_IA64_CYCLONE is not set
83CONFIG_IOSAPIC=y 83CONFIG_IOSAPIC=y
84CONFIG_IA64_SGI_SN_SIM=y
85CONFIG_FORCE_MAX_ZONEORDER=18 84CONFIG_FORCE_MAX_ZONEORDER=18
86CONFIG_SMP=y 85CONFIG_SMP=y
87CONFIG_NR_CPUS=512 86CONFIG_NR_CPUS=512
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 5c7c95737bbf..84f89da7c640 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -20,6 +20,7 @@
20 * 02/01/00 R.Seth fixed get_cpuinfo for SMP 20 * 02/01/00 R.Seth fixed get_cpuinfo for SMP
21 * 01/07/99 S.Eranian added the support for command line argument 21 * 01/07/99 S.Eranian added the support for command line argument
22 * 06/24/99 W.Drummond added boot_cpu_data. 22 * 06/24/99 W.Drummond added boot_cpu_data.
23 * 05/28/05 Z. Menyhart Dynamic stride size for "flush_icache_range()"
23 */ 24 */
24#include <linux/config.h> 25#include <linux/config.h>
25#include <linux/module.h> 26#include <linux/module.h>
@@ -85,6 +86,13 @@ EXPORT_SYMBOL(io_space);
85unsigned int num_io_spaces; 86unsigned int num_io_spaces;
86 87
87/* 88/*
89 * "flush_icache_range()" needs to know what processor dependent stride size to use
90 * when it makes i-cache(s) coherent with d-caches.
91 */
92#define I_CACHE_STRIDE_SHIFT 5 /* Safest way to go: 32 bytes by 32 bytes */
93unsigned long ia64_i_cache_stride_shift = ~0;
94
95/*
88 * The merge_mask variable needs to be set to (max(iommu_page_size(iommu)) - 1). This 96 * The merge_mask variable needs to be set to (max(iommu_page_size(iommu)) - 1). This
89 * mask specifies a mask of address bits that must be 0 in order for two buffers to be 97 * mask specifies a mask of address bits that must be 0 in order for two buffers to be
90 * mergeable by the I/O MMU (i.e., the end address of the first buffer and the start 98 * mergeable by the I/O MMU (i.e., the end address of the first buffer and the start
@@ -628,6 +636,12 @@ setup_per_cpu_areas (void)
628 /* start_kernel() requires this... */ 636 /* start_kernel() requires this... */
629} 637}
630 638
639/*
640 * Calculate the max. cache line size.
641 *
642 * In addition, the minimum of the i-cache stride sizes is calculated for
643 * "flush_icache_range()".
644 */
631static void 645static void
632get_max_cacheline_size (void) 646get_max_cacheline_size (void)
633{ 647{
@@ -641,6 +655,8 @@ get_max_cacheline_size (void)
641 printk(KERN_ERR "%s: ia64_pal_cache_summary() failed (status=%ld)\n", 655 printk(KERN_ERR "%s: ia64_pal_cache_summary() failed (status=%ld)\n",
642 __FUNCTION__, status); 656 __FUNCTION__, status);
643 max = SMP_CACHE_BYTES; 657 max = SMP_CACHE_BYTES;
658 /* Safest setup for "flush_icache_range()" */
659 ia64_i_cache_stride_shift = I_CACHE_STRIDE_SHIFT;
644 goto out; 660 goto out;
645 } 661 }
646 662
@@ -649,14 +665,31 @@ get_max_cacheline_size (void)
649 &cci); 665 &cci);
650 if (status != 0) { 666 if (status != 0) {
651 printk(KERN_ERR 667 printk(KERN_ERR
652 "%s: ia64_pal_cache_config_info(l=%lu) failed (status=%ld)\n", 668 "%s: ia64_pal_cache_config_info(l=%lu, 2) failed (status=%ld)\n",
653 __FUNCTION__, l, status); 669 __FUNCTION__, l, status);
654 max = SMP_CACHE_BYTES; 670 max = SMP_CACHE_BYTES;
671 /* The safest setup for "flush_icache_range()" */
672 cci.pcci_stride = I_CACHE_STRIDE_SHIFT;
673 cci.pcci_unified = 1;
655 } 674 }
656 line_size = 1 << cci.pcci_line_size; 675 line_size = 1 << cci.pcci_line_size;
657 if (line_size > max) 676 if (line_size > max)
658 max = line_size; 677 max = line_size;
659 } 678 if (!cci.pcci_unified) {
679 status = ia64_pal_cache_config_info(l,
680 /* cache_type (instruction)= */ 1,
681 &cci);
682 if (status != 0) {
683 printk(KERN_ERR
684 "%s: ia64_pal_cache_config_info(l=%lu, 1) failed (status=%ld)\n",
685 __FUNCTION__, l, status);
686 /* The safest setup for "flush_icache_range()" */
687 cci.pcci_stride = I_CACHE_STRIDE_SHIFT;
688 }
689 }
690 if (cci.pcci_stride < ia64_i_cache_stride_shift)
691 ia64_i_cache_stride_shift = cci.pcci_stride;
692 }
660 out: 693 out:
661 if (max > ia64_max_cacheline_size) 694 if (max > ia64_max_cacheline_size)
662 ia64_max_cacheline_size = max; 695 ia64_max_cacheline_size = max;
diff --git a/arch/ia64/lib/flush.S b/arch/ia64/lib/flush.S
index a1af9146cfdb..3e2cfa2c6d39 100644
--- a/arch/ia64/lib/flush.S
+++ b/arch/ia64/lib/flush.S
@@ -3,37 +3,59 @@
3 * 3 *
4 * Copyright (C) 1999-2001, 2005 Hewlett-Packard Co 4 * Copyright (C) 1999-2001, 2005 Hewlett-Packard Co
5 * David Mosberger-Tang <davidm@hpl.hp.com> 5 * David Mosberger-Tang <davidm@hpl.hp.com>
6 *
7 * 05/28/05 Zoltan Menyhart Dynamic stride size
6 */ 8 */
9
7#include <asm/asmmacro.h> 10#include <asm/asmmacro.h>
8#include <asm/page.h> 11
9 12
10 /* 13 /*
11 * flush_icache_range(start,end) 14 * flush_icache_range(start,end)
12 * Must flush range from start to end-1 but nothing else (need to 15 *
16 * Make i-cache(s) coherent with d-caches.
17 *
18 * Must deal with range from start to end-1 but nothing else (need to
13 * be careful not to touch addresses that may be unmapped). 19 * be careful not to touch addresses that may be unmapped).
20 *
21 * Note: "in0" and "in1" are preserved for debugging purposes.
14 */ 22 */
15GLOBAL_ENTRY(flush_icache_range) 23GLOBAL_ENTRY(flush_icache_range)
24
16 .prologue 25 .prologue
17 alloc r2=ar.pfs,2,0,0,0 26 alloc r2=ar.pfs,2,0,0,0
18 sub r8=in1,in0,1 27 movl r3=ia64_i_cache_stride_shift
28 mov r21=1
29 ;;
30 ld8 r20=[r3] // r20: stride shift
31 sub r22=in1,r0,1 // last byte address
19 ;; 32 ;;
20 shr.u r8=r8,5 // we flush 32 bytes per iteration 33 shr.u r23=in0,r20 // start / (stride size)
21 .save ar.lc, r3 34 shr.u r22=r22,r20 // (last byte address) / (stride size)
22 mov r3=ar.lc // save ar.lc 35 shl r21=r21,r20 // r21: stride size of the i-cache(s)
36 ;;
37 sub r8=r22,r23 // number of strides - 1
38 shl r24=r23,r20 // r24: addresses for "fc.i" =
39 // "start" rounded down to stride boundary
40 .save ar.lc,r3
41 mov r3=ar.lc // save ar.lc
23 ;; 42 ;;
24 43
25 .body 44 .body
26 45 mov ar.lc=r8
27 mov ar.lc=r8
28 ;; 46 ;;
29.Loop: fc.i in0 // issuable on M2 only 47 /*
30 add in0=32,in0 48 * 32 byte aligned loop, even number of (actually 2) bundles
49 */
50.Loop: fc.i r24 // issuable on M0 only
51 add r24=r21,r24 // we flush "stride size" bytes per iteration
52 nop.i 0
31 br.cloop.sptk.few .Loop 53 br.cloop.sptk.few .Loop
32 ;; 54 ;;
33 sync.i 55 sync.i
34 ;; 56 ;;
35 srlz.i 57 srlz.i
36 ;; 58 ;;
37 mov ar.lc=r3 // restore ar.lc 59 mov ar.lc=r3 // restore ar.lc
38 br.ret.sptk.many rp 60 br.ret.sptk.many rp
39END(flush_icache_range) 61END(flush_icache_range)
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 720a861f88be..54d9ed444e4a 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -157,6 +157,7 @@ alloc_pci_controller (int seg)
157 157
158 memset(controller, 0, sizeof(*controller)); 158 memset(controller, 0, sizeof(*controller));
159 controller->segment = seg; 159 controller->segment = seg;
160 controller->node = -1;
160 return controller; 161 return controller;
161} 162}
162 163
@@ -288,6 +289,7 @@ pci_acpi_scan_root(struct acpi_device *device, int domain, int bus)
288 unsigned int windows = 0; 289 unsigned int windows = 0;
289 struct pci_bus *pbus; 290 struct pci_bus *pbus;
290 char *name; 291 char *name;
292 int pxm;
291 293
292 controller = alloc_pci_controller(domain); 294 controller = alloc_pci_controller(domain);
293 if (!controller) 295 if (!controller)
@@ -295,10 +297,16 @@ pci_acpi_scan_root(struct acpi_device *device, int domain, int bus)
295 297
296 controller->acpi_handle = device->handle; 298 controller->acpi_handle = device->handle;
297 299
300 pxm = acpi_get_pxm(controller->acpi_handle);
301#ifdef CONFIG_NUMA
302 if (pxm >= 0)
303 controller->node = pxm_to_nid_map[pxm];
304#endif
305
298 acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window, 306 acpi_walk_resources(device->handle, METHOD_NAME__CRS, count_window,
299 &windows); 307 &windows);
300 controller->window = kmalloc(sizeof(*controller->window) * windows, 308 controller->window = kmalloc_node(sizeof(*controller->window) * windows,
301 GFP_KERNEL); 309 GFP_KERNEL, controller->node);
302 if (!controller->window) 310 if (!controller->window)
303 goto out2; 311 goto out2;
304 312
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c
index a67f39e448cb..a6649baf629a 100644
--- a/arch/ia64/sn/kernel/io_init.c
+++ b/arch/ia64/sn/kernel/io_init.c
@@ -61,7 +61,7 @@ sn_default_pci_unmap(struct pci_dev *pdev, dma_addr_t addr, int direction)
61} 61}
62 62
63static void * 63static void *
64sn_default_pci_bus_fixup(struct pcibus_bussoft *soft) 64sn_default_pci_bus_fixup(struct pcibus_bussoft *soft, struct pci_controller *controller)
65{ 65{
66 return NULL; 66 return NULL;
67} 67}
@@ -362,7 +362,7 @@ void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
362 362
363 provider_soft = NULL; 363 provider_soft = NULL;
364 if (provider->bus_fixup) 364 if (provider->bus_fixup)
365 provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr); 365 provider_soft = (*provider->bus_fixup) (prom_bussoft_ptr, controller);
366 366
367 if (provider_soft == NULL) 367 if (provider_soft == NULL)
368 return; /* fixup failed or not applicable */ 368 return; /* fixup failed or not applicable */
@@ -380,6 +380,22 @@ void sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus)
380 SN_PCIBUS_BUSSOFT(bus)->bs_xwidget_info = 380 SN_PCIBUS_BUSSOFT(bus)->bs_xwidget_info =
381 &(hubdev_info->hdi_xwidget_info[SN_PCIBUS_BUSSOFT(bus)->bs_xid]); 381 &(hubdev_info->hdi_xwidget_info[SN_PCIBUS_BUSSOFT(bus)->bs_xid]);
382 382
383 /*
384 * If the node information we obtained during the fixup phase is invalid
385 * then set controller->node to -1 (undetermined)
386 */
387 if (controller->node >= num_online_nodes()) {
388 struct pcibus_bussoft *b = SN_PCIBUS_BUSSOFT(bus);
389
390 printk(KERN_WARNING "Device ASIC=%u XID=%u PBUSNUM=%lu"
391 "L_IO=%lx L_MEM=%lx BASE=%lx\n",
392 b->bs_asic_type, b->bs_xid, b->bs_persist_busnum,
393 b->bs_legacy_io, b->bs_legacy_mem, b->bs_base);
394 printk(KERN_WARNING "on node %d but only %d nodes online."
395 "Association set to undetermined.\n",
396 controller->node, num_online_nodes());
397 controller->node = -1;
398 }
383 return; 399 return;
384 400
385error_return: 401error_return:
diff --git a/arch/ia64/sn/kernel/xpc_channel.c b/arch/ia64/sn/kernel/xpc_channel.c
index 6d02dac8056f..94698bea7be0 100644
--- a/arch/ia64/sn/kernel/xpc_channel.c
+++ b/arch/ia64/sn/kernel/xpc_channel.c
@@ -72,7 +72,7 @@ xpc_initialize_channels(struct xpc_partition *part, partid_t partid)
72enum xpc_retval 72enum xpc_retval
73xpc_setup_infrastructure(struct xpc_partition *part) 73xpc_setup_infrastructure(struct xpc_partition *part)
74{ 74{
75 int ret; 75 int ret, cpuid;
76 struct timer_list *timer; 76 struct timer_list *timer;
77 partid_t partid = XPC_PARTID(part); 77 partid_t partid = XPC_PARTID(part);
78 78
@@ -223,9 +223,9 @@ xpc_setup_infrastructure(struct xpc_partition *part)
223 xpc_vars_part[partid].openclose_args_pa = 223 xpc_vars_part[partid].openclose_args_pa =
224 __pa(part->local_openclose_args); 224 __pa(part->local_openclose_args);
225 xpc_vars_part[partid].IPI_amo_pa = __pa(part->local_IPI_amo_va); 225 xpc_vars_part[partid].IPI_amo_pa = __pa(part->local_IPI_amo_va);
226 xpc_vars_part[partid].IPI_nasid = cpuid_to_nasid(smp_processor_id()); 226 cpuid = raw_smp_processor_id(); /* any CPU in this partition will do */
227 xpc_vars_part[partid].IPI_phys_cpuid = 227 xpc_vars_part[partid].IPI_nasid = cpuid_to_nasid(cpuid);
228 cpu_physical_id(smp_processor_id()); 228 xpc_vars_part[partid].IPI_phys_cpuid = cpu_physical_id(cpuid);
229 xpc_vars_part[partid].nchannels = part->nchannels; 229 xpc_vars_part[partid].nchannels = part->nchannels;
230 xpc_vars_part[partid].magic = XPC_VP_MAGIC1; 230 xpc_vars_part[partid].magic = XPC_VP_MAGIC1;
231 231
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index a2f7a88aefbb..0e4b9ad9ef02 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -79,6 +79,7 @@ void *sn_dma_alloc_coherent(struct device *dev, size_t size,
79{ 79{
80 void *cpuaddr; 80 void *cpuaddr;
81 unsigned long phys_addr; 81 unsigned long phys_addr;
82 int node;
82 struct pci_dev *pdev = to_pci_dev(dev); 83 struct pci_dev *pdev = to_pci_dev(dev);
83 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev); 84 struct sn_pcibus_provider *provider = SN_PCIDEV_BUSPROVIDER(pdev);
84 85
@@ -86,10 +87,19 @@ void *sn_dma_alloc_coherent(struct device *dev, size_t size,
86 87
87 /* 88 /*
88 * Allocate the memory. 89 * Allocate the memory.
89 * FIXME: We should be doing alloc_pages_node for the node closest
90 * to the PCI device.
91 */ 90 */
92 if (!(cpuaddr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size)))) 91 node = pcibus_to_node(pdev->bus);
92 if (likely(node >=0)) {
93 struct page *p = alloc_pages_node(node, GFP_ATOMIC, get_order(size));
94
95 if (likely(p))
96 cpuaddr = page_address(p);
97 else
98 return NULL;
99 } else
100 cpuaddr = (void *)__get_free_pages(GFP_ATOMIC, get_order(size));
101
102 if (unlikely(!cpuaddr))
93 return NULL; 103 return NULL;
94 104
95 memset(cpuaddr, 0x0, size); 105 memset(cpuaddr, 0x0, size);
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_provider.c b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
index 9813da56d311..b95e928636a1 100644
--- a/arch/ia64/sn/pci/pcibr/pcibr_provider.c
+++ b/arch/ia64/sn/pci/pcibr/pcibr_provider.c
@@ -85,7 +85,7 @@ pcibr_error_intr_handler(int irq, void *arg, struct pt_regs *regs)
85} 85}
86 86
87void * 87void *
88pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft) 88pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *controller)
89{ 89{
90 int nasid, cnode, j; 90 int nasid, cnode, j;
91 struct hubdev_info *hubdev_info; 91 struct hubdev_info *hubdev_info;
@@ -158,6 +158,14 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft)
158 memset(soft->pbi_int_ate_resource.ate, 0, 158 memset(soft->pbi_int_ate_resource.ate, 0,
159 (soft->pbi_int_ate_size * sizeof(uint64_t))); 159 (soft->pbi_int_ate_size * sizeof(uint64_t)));
160 160
161 if (prom_bussoft->bs_asic_type == PCIIO_ASIC_TYPE_TIOCP)
162 /*
163 * TIO PCI Bridge with no closest node information.
164 * FIXME: Find another way to determine the closest node
165 */
166 controller->node = -1;
167 else
168 controller->node = cnode;
161 return soft; 169 return soft;
162} 170}
163 171
diff --git a/arch/ia64/sn/pci/tioca_provider.c b/arch/ia64/sn/pci/tioca_provider.c
index 51cc4e63092c..5d76a7581465 100644
--- a/arch/ia64/sn/pci/tioca_provider.c
+++ b/arch/ia64/sn/pci/tioca_provider.c
@@ -581,7 +581,7 @@ tioca_error_intr_handler(int irq, void *arg, struct pt_regs *pt)
581 * the caller. 581 * the caller.
582 */ 582 */
583static void * 583static void *
584tioca_bus_fixup(struct pcibus_bussoft *prom_bussoft) 584tioca_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *controller)
585{ 585{
586 struct tioca_common *tioca_common; 586 struct tioca_common *tioca_common;
587 struct tioca_kernel *tioca_kern; 587 struct tioca_kernel *tioca_kern;
@@ -646,6 +646,8 @@ tioca_bus_fixup(struct pcibus_bussoft *prom_bussoft)
646 __FUNCTION__, SGI_TIOCA_ERROR, 646 __FUNCTION__, SGI_TIOCA_ERROR,
647 (int)tioca_common->ca_common.bs_persist_busnum); 647 (int)tioca_common->ca_common.bs_persist_busnum);
648 648
649 /* Setup locality information */
650 controller->node = tioca_kern->ca_closest_node;
649 return tioca_common; 651 return tioca_common;
650} 652}
651 653
diff --git a/arch/ppc/boot/images/Makefile b/arch/ppc/boot/images/Makefile
index c9ac5f5fa9e4..532e7ef1edb6 100644
--- a/arch/ppc/boot/images/Makefile
+++ b/arch/ppc/boot/images/Makefile
@@ -6,12 +6,17 @@ MKIMAGE := $(srctree)/scripts/mkuboot.sh
6 6
7extra-y := vmlinux.bin vmlinux.gz 7extra-y := vmlinux.bin vmlinux.gz
8 8
9# two make processes may write to vmlinux.gz at the same time with make -j
10quiet_cmd_mygzip = GZIP $@
11cmd_mygzip = gzip -f -9 < $< > $@.$$$$ && mv $@.$$$$ $@
12
13
9OBJCOPYFLAGS_vmlinux.bin := -O binary 14OBJCOPYFLAGS_vmlinux.bin := -O binary
10$(obj)/vmlinux.bin: vmlinux FORCE 15$(obj)/vmlinux.bin: vmlinux FORCE
11 $(call if_changed,objcopy) 16 $(call if_changed,objcopy)
12 17
13$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE 18$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
14 $(call if_changed,gzip) 19 $(call if_changed,mygzip)
15 20
16quiet_cmd_uimage = UIMAGE $@ 21quiet_cmd_uimage = UIMAGE $@
17 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A ppc -O linux -T kernel \ 22 cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A ppc -O linux -T kernel \
diff --git a/arch/ppc64/kernel/cpu_setup_power4.S b/arch/ppc64/kernel/cpu_setup_power4.S
index 42fc08cf87a0..0482c063c26e 100644
--- a/arch/ppc64/kernel/cpu_setup_power4.S
+++ b/arch/ppc64/kernel/cpu_setup_power4.S
@@ -31,10 +31,13 @@ _GLOBAL(__970_cpu_preinit)
31 */ 31 */
32 mfspr r0,SPRN_PVR 32 mfspr r0,SPRN_PVR
33 srwi r0,r0,16 33 srwi r0,r0,16
34 cmpwi cr0,r0,0x39 34 cmpwi r0,0x39
35 cmpwi cr1,r0,0x3c 35 beq 1f
36 cror 4*cr0+eq,4*cr0+eq,4*cr1+eq 36 cmpwi r0,0x3c
37 beq 1f
38 cmpwi r0,0x44
37 bnelr 39 bnelr
401:
38 41
39 /* Make sure HID4:rm_ci is off before MMU is turned off, that large 42 /* Make sure HID4:rm_ci is off before MMU is turned off, that large
40 * pages are enabled with HID4:61 and clear HID5:DCBZ_size and 43 * pages are enabled with HID4:61 and clear HID5:DCBZ_size and
@@ -133,12 +136,14 @@ _GLOBAL(__save_cpu_setup)
133 /* We only deal with 970 for now */ 136 /* We only deal with 970 for now */
134 mfspr r0,SPRN_PVR 137 mfspr r0,SPRN_PVR
135 srwi r0,r0,16 138 srwi r0,r0,16
136 cmpwi cr0,r0,0x39 139 cmpwi r0,0x39
137 cmpwi cr1,r0,0x3c 140 beq 1f
138 cror 4*cr0+eq,4*cr0+eq,4*cr1+eq 141 cmpwi r0,0x3c
139 bne 1f 142 beq 1f
140 143 cmpwi r0,0x44
141 /* Save HID0,1,4 and 5 */ 144 bne 2f
145
1461: /* Save HID0,1,4 and 5 */
142 mfspr r3,SPRN_HID0 147 mfspr r3,SPRN_HID0
143 std r3,CS_HID0(r5) 148 std r3,CS_HID0(r5)
144 mfspr r3,SPRN_HID1 149 mfspr r3,SPRN_HID1
@@ -148,7 +153,7 @@ _GLOBAL(__save_cpu_setup)
148 mfspr r3,SPRN_HID5 153 mfspr r3,SPRN_HID5
149 std r3,CS_HID5(r5) 154 std r3,CS_HID5(r5)
150 155
1511: 1562:
152 mtcr r7 157 mtcr r7
153 blr 158 blr
154 159
@@ -165,12 +170,14 @@ _GLOBAL(__restore_cpu_setup)
165 /* We only deal with 970 for now */ 170 /* We only deal with 970 for now */
166 mfspr r0,SPRN_PVR 171 mfspr r0,SPRN_PVR
167 srwi r0,r0,16 172 srwi r0,r0,16
168 cmpwi cr0,r0,0x39 173 cmpwi r0,0x39
169 cmpwi cr1,r0,0x3c 174 beq 1f
170 cror 4*cr0+eq,4*cr0+eq,4*cr1+eq 175 cmpwi r0,0x3c
171 bne 1f 176 beq 1f
177 cmpwi r0,0x44
178 bnelr
172 179
173 /* Before accessing memory, we make sure rm_ci is clear */ 1801: /* Before accessing memory, we make sure rm_ci is clear */
174 li r0,0 181 li r0,0
175 mfspr r3,SPRN_HID4 182 mfspr r3,SPRN_HID4
176 rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */ 183 rldimi r3,r0,40,23 /* clear bit 23 (rm_ci) */
@@ -223,6 +230,5 @@ _GLOBAL(__restore_cpu_setup)
223 mtspr SPRN_HID5,r3 230 mtspr SPRN_HID5,r3
224 sync 231 sync
225 isync 232 isync
2261:
227 blr 233 blr
228 234
diff --git a/arch/ppc64/kernel/cputable.c b/arch/ppc64/kernel/cputable.c
index 8d4c46f6f0b6..77cec42f9525 100644
--- a/arch/ppc64/kernel/cputable.c
+++ b/arch/ppc64/kernel/cputable.c
@@ -183,6 +183,21 @@ struct cpu_spec cpu_specs[] = {
183 .cpu_setup = __setup_cpu_ppc970, 183 .cpu_setup = __setup_cpu_ppc970,
184 .firmware_features = COMMON_PPC64_FW, 184 .firmware_features = COMMON_PPC64_FW,
185 }, 185 },
186 { /* PPC970MP */
187 .pvr_mask = 0xffff0000,
188 .pvr_value = 0x00440000,
189 .cpu_name = "PPC970MP",
190 .cpu_features = CPU_FTR_SPLIT_ID_CACHE |
191 CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE |
192 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_ALTIVEC_COMP |
193 CPU_FTR_CAN_NAP | CPU_FTR_PMC8 | CPU_FTR_MMCRA,
194 .cpu_user_features = COMMON_USER_PPC64 |
195 PPC_FEATURE_HAS_ALTIVEC_COMP,
196 .icache_bsize = 128,
197 .dcache_bsize = 128,
198 .cpu_setup = __setup_cpu_ppc970,
199 .firmware_features = COMMON_PPC64_FW,
200 },
186 { /* Power5 */ 201 { /* Power5 */
187 .pvr_mask = 0xffff0000, 202 .pvr_mask = 0xffff0000,
188 .pvr_value = 0x003a0000, 203 .pvr_value = 0x003a0000,
diff --git a/arch/ppc64/kernel/iSeries_htab.c b/arch/ppc64/kernel/iSeries_htab.c
index aa9e8fdd1a4f..b0250ae4a72a 100644
--- a/arch/ppc64/kernel/iSeries_htab.c
+++ b/arch/ppc64/kernel/iSeries_htab.c
@@ -38,11 +38,12 @@ static inline void iSeries_hunlock(unsigned long slot)
38} 38}
39 39
40static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va, 40static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va,
41 unsigned long prpn, int secondary, 41 unsigned long prpn, unsigned long vflags,
42 unsigned long hpteflags, int bolted, int large) 42 unsigned long rflags)
43{ 43{
44 long slot; 44 long slot;
45 HPTE lhpte; 45 hpte_t lhpte;
46 int secondary = 0;
46 47
47 /* 48 /*
48 * The hypervisor tries both primary and secondary. 49 * The hypervisor tries both primary and secondary.
@@ -50,13 +51,13 @@ static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va,
50 * it means we have already tried both primary and secondary, 51 * it means we have already tried both primary and secondary,
51 * so we return failure immediately. 52 * so we return failure immediately.
52 */ 53 */
53 if (secondary) 54 if (vflags & HPTE_V_SECONDARY)
54 return -1; 55 return -1;
55 56
56 iSeries_hlock(hpte_group); 57 iSeries_hlock(hpte_group);
57 58
58 slot = HvCallHpt_findValid(&lhpte, va >> PAGE_SHIFT); 59 slot = HvCallHpt_findValid(&lhpte, va >> PAGE_SHIFT);
59 BUG_ON(lhpte.dw0.dw0.v); 60 BUG_ON(lhpte.v & HPTE_V_VALID);
60 61
61 if (slot == -1) { /* No available entry found in either group */ 62 if (slot == -1) { /* No available entry found in either group */
62 iSeries_hunlock(hpte_group); 63 iSeries_hunlock(hpte_group);
@@ -64,19 +65,13 @@ static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va,
64 } 65 }
65 66
66 if (slot < 0) { /* MSB set means secondary group */ 67 if (slot < 0) { /* MSB set means secondary group */
68 vflags |= HPTE_V_VALID;
67 secondary = 1; 69 secondary = 1;
68 slot &= 0x7fffffffffffffff; 70 slot &= 0x7fffffffffffffff;
69 } 71 }
70 72
71 lhpte.dw1.dword1 = 0; 73 lhpte.v = (va >> 23) << HPTE_V_AVPN_SHIFT | vflags | HPTE_V_VALID;
72 lhpte.dw1.dw1.rpn = physRpn_to_absRpn(prpn); 74 lhpte.r = (physRpn_to_absRpn(prpn) << HPTE_R_RPN_SHIFT) | rflags;
73 lhpte.dw1.flags.flags = hpteflags;
74
75 lhpte.dw0.dword0 = 0;
76 lhpte.dw0.dw0.avpn = va >> 23;
77 lhpte.dw0.dw0.h = secondary;
78 lhpte.dw0.dw0.bolted = bolted;
79 lhpte.dw0.dw0.v = 1;
80 75
81 /* Now fill in the actual HPTE */ 76 /* Now fill in the actual HPTE */
82 HvCallHpt_addValidate(slot, secondary, &lhpte); 77 HvCallHpt_addValidate(slot, secondary, &lhpte);
@@ -88,20 +83,17 @@ static long iSeries_hpte_insert(unsigned long hpte_group, unsigned long va,
88 83
89static unsigned long iSeries_hpte_getword0(unsigned long slot) 84static unsigned long iSeries_hpte_getword0(unsigned long slot)
90{ 85{
91 unsigned long dword0; 86 hpte_t hpte;
92 HPTE hpte;
93 87
94 HvCallHpt_get(&hpte, slot); 88 HvCallHpt_get(&hpte, slot);
95 dword0 = hpte.dw0.dword0; 89 return hpte.v;
96
97 return dword0;
98} 90}
99 91
100static long iSeries_hpte_remove(unsigned long hpte_group) 92static long iSeries_hpte_remove(unsigned long hpte_group)
101{ 93{
102 unsigned long slot_offset; 94 unsigned long slot_offset;
103 int i; 95 int i;
104 HPTE lhpte; 96 unsigned long hpte_v;
105 97
106 /* Pick a random slot to start at */ 98 /* Pick a random slot to start at */
107 slot_offset = mftb() & 0x7; 99 slot_offset = mftb() & 0x7;
@@ -109,10 +101,9 @@ static long iSeries_hpte_remove(unsigned long hpte_group)
109 iSeries_hlock(hpte_group); 101 iSeries_hlock(hpte_group);
110 102
111 for (i = 0; i < HPTES_PER_GROUP; i++) { 103 for (i = 0; i < HPTES_PER_GROUP; i++) {
112 lhpte.dw0.dword0 = 104 hpte_v = iSeries_hpte_getword0(hpte_group + slot_offset);
113 iSeries_hpte_getword0(hpte_group + slot_offset);
114 105
115 if (!lhpte.dw0.dw0.bolted) { 106 if (! (hpte_v & HPTE_V_BOLTED)) {
116 HvCallHpt_invalidateSetSwBitsGet(hpte_group + 107 HvCallHpt_invalidateSetSwBitsGet(hpte_group +
117 slot_offset, 0, 0); 108 slot_offset, 0, 0);
118 iSeries_hunlock(hpte_group); 109 iSeries_hunlock(hpte_group);
@@ -137,13 +128,13 @@ static long iSeries_hpte_remove(unsigned long hpte_group)
137static long iSeries_hpte_updatepp(unsigned long slot, unsigned long newpp, 128static long iSeries_hpte_updatepp(unsigned long slot, unsigned long newpp,
138 unsigned long va, int large, int local) 129 unsigned long va, int large, int local)
139{ 130{
140 HPTE hpte; 131 hpte_t hpte;
141 unsigned long avpn = va >> 23; 132 unsigned long avpn = va >> 23;
142 133
143 iSeries_hlock(slot); 134 iSeries_hlock(slot);
144 135
145 HvCallHpt_get(&hpte, slot); 136 HvCallHpt_get(&hpte, slot);
146 if ((hpte.dw0.dw0.avpn == avpn) && (hpte.dw0.dw0.v)) { 137 if ((HPTE_V_AVPN_VAL(hpte.v) == avpn) && (hpte.v & HPTE_V_VALID)) {
147 /* 138 /*
148 * Hypervisor expects bits as NPPP, which is 139 * Hypervisor expects bits as NPPP, which is
149 * different from how they are mapped in our PP. 140 * different from how they are mapped in our PP.
@@ -167,7 +158,7 @@ static long iSeries_hpte_updatepp(unsigned long slot, unsigned long newpp,
167 */ 158 */
168static long iSeries_hpte_find(unsigned long vpn) 159static long iSeries_hpte_find(unsigned long vpn)
169{ 160{
170 HPTE hpte; 161 hpte_t hpte;
171 long slot; 162 long slot;
172 163
173 /* 164 /*
@@ -177,7 +168,7 @@ static long iSeries_hpte_find(unsigned long vpn)
177 * 0x80000000xxxxxxxx : Entry found in secondary group, slot x 168 * 0x80000000xxxxxxxx : Entry found in secondary group, slot x
178 */ 169 */
179 slot = HvCallHpt_findValid(&hpte, vpn); 170 slot = HvCallHpt_findValid(&hpte, vpn);
180 if (hpte.dw0.dw0.v) { 171 if (hpte.v & HPTE_V_VALID) {
181 if (slot < 0) { 172 if (slot < 0) {
182 slot &= 0x7fffffffffffffff; 173 slot &= 0x7fffffffffffffff;
183 slot = -slot; 174 slot = -slot;
@@ -212,7 +203,7 @@ static void iSeries_hpte_updateboltedpp(unsigned long newpp, unsigned long ea)
212static void iSeries_hpte_invalidate(unsigned long slot, unsigned long va, 203static void iSeries_hpte_invalidate(unsigned long slot, unsigned long va,
213 int large, int local) 204 int large, int local)
214{ 205{
215 HPTE lhpte; 206 unsigned long hpte_v;
216 unsigned long avpn = va >> 23; 207 unsigned long avpn = va >> 23;
217 unsigned long flags; 208 unsigned long flags;
218 209
@@ -220,9 +211,9 @@ static void iSeries_hpte_invalidate(unsigned long slot, unsigned long va,
220 211
221 iSeries_hlock(slot); 212 iSeries_hlock(slot);
222 213
223 lhpte.dw0.dword0 = iSeries_hpte_getword0(slot); 214 hpte_v = iSeries_hpte_getword0(slot);
224 215
225 if ((lhpte.dw0.dw0.avpn == avpn) && lhpte.dw0.dw0.v) 216 if ((HPTE_V_AVPN_VAL(hpte_v) == avpn) && (hpte_v & HPTE_V_VALID))
226 HvCallHpt_invalidateSetSwBitsGet(slot, 0, 0); 217 HvCallHpt_invalidateSetSwBitsGet(slot, 0, 0);
227 218
228 iSeries_hunlock(slot); 219 iSeries_hunlock(slot);
diff --git a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c
index 077c82fc9f3a..a649edbb23b6 100644
--- a/arch/ppc64/kernel/iSeries_setup.c
+++ b/arch/ppc64/kernel/iSeries_setup.c
@@ -503,7 +503,7 @@ static void __init build_iSeries_Memory_Map(void)
503 503
504 /* Fill in the hashed page table hash mask */ 504 /* Fill in the hashed page table hash mask */
505 num_ptegs = hptSizePages * 505 num_ptegs = hptSizePages *
506 (PAGE_SIZE / (sizeof(HPTE) * HPTES_PER_GROUP)); 506 (PAGE_SIZE / (sizeof(hpte_t) * HPTES_PER_GROUP));
507 htab_hash_mask = num_ptegs - 1; 507 htab_hash_mask = num_ptegs - 1;
508 508
509 /* 509 /*
@@ -618,25 +618,23 @@ static void __init setup_iSeries_cache_sizes(void)
618static void iSeries_make_pte(unsigned long va, unsigned long pa, 618static void iSeries_make_pte(unsigned long va, unsigned long pa,
619 int mode) 619 int mode)
620{ 620{
621 HPTE local_hpte, rhpte; 621 hpte_t local_hpte, rhpte;
622 unsigned long hash, vpn; 622 unsigned long hash, vpn;
623 long slot; 623 long slot;
624 624
625 vpn = va >> PAGE_SHIFT; 625 vpn = va >> PAGE_SHIFT;
626 hash = hpt_hash(vpn, 0); 626 hash = hpt_hash(vpn, 0);
627 627
628 local_hpte.dw1.dword1 = pa | mode; 628 local_hpte.r = pa | mode;
629 local_hpte.dw0.dword0 = 0; 629 local_hpte.v = ((va >> 23) << HPTE_V_AVPN_SHIFT)
630 local_hpte.dw0.dw0.avpn = va >> 23; 630 | HPTE_V_BOLTED | HPTE_V_VALID;
631 local_hpte.dw0.dw0.bolted = 1; /* bolted */
632 local_hpte.dw0.dw0.v = 1;
633 631
634 slot = HvCallHpt_findValid(&rhpte, vpn); 632 slot = HvCallHpt_findValid(&rhpte, vpn);
635 if (slot < 0) { 633 if (slot < 0) {
636 /* Must find space in primary group */ 634 /* Must find space in primary group */
637 panic("hash_page: hpte already exists\n"); 635 panic("hash_page: hpte already exists\n");
638 } 636 }
639 HvCallHpt_addValidate(slot, 0, (HPTE *)&local_hpte ); 637 HvCallHpt_addValidate(slot, 0, &local_hpte);
640} 638}
641 639
642/* 640/*
@@ -646,7 +644,7 @@ static void __init iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr)
646{ 644{
647 unsigned long pa; 645 unsigned long pa;
648 unsigned long mode_rw = _PAGE_ACCESSED | _PAGE_COHERENT | PP_RWXX; 646 unsigned long mode_rw = _PAGE_ACCESSED | _PAGE_COHERENT | PP_RWXX;
649 HPTE hpte; 647 hpte_t hpte;
650 648
651 for (pa = saddr; pa < eaddr ;pa += PAGE_SIZE) { 649 for (pa = saddr; pa < eaddr ;pa += PAGE_SIZE) {
652 unsigned long ea = (unsigned long)__va(pa); 650 unsigned long ea = (unsigned long)__va(pa);
@@ -659,7 +657,7 @@ static void __init iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr)
659 if (!in_kernel_text(ea)) 657 if (!in_kernel_text(ea))
660 mode_rw |= HW_NO_EXEC; 658 mode_rw |= HW_NO_EXEC;
661 659
662 if (hpte.dw0.dw0.v) { 660 if (hpte.v & HPTE_V_VALID) {
663 /* HPTE exists, so just bolt it */ 661 /* HPTE exists, so just bolt it */
664 HvCallHpt_setSwBits(slot, 0x10, 0); 662 HvCallHpt_setSwBits(slot, 0x10, 0);
665 /* And make sure the pp bits are correct */ 663 /* And make sure the pp bits are correct */
diff --git a/arch/ppc64/kernel/pSeries_lpar.c b/arch/ppc64/kernel/pSeries_lpar.c
index 6534812db437..74dd144dcce8 100644
--- a/arch/ppc64/kernel/pSeries_lpar.c
+++ b/arch/ppc64/kernel/pSeries_lpar.c
@@ -277,31 +277,20 @@ void vpa_init(int cpu)
277 277
278long pSeries_lpar_hpte_insert(unsigned long hpte_group, 278long pSeries_lpar_hpte_insert(unsigned long hpte_group,
279 unsigned long va, unsigned long prpn, 279 unsigned long va, unsigned long prpn,
280 int secondary, unsigned long hpteflags, 280 unsigned long vflags, unsigned long rflags)
281 int bolted, int large)
282{ 281{
283 unsigned long arpn = physRpn_to_absRpn(prpn); 282 unsigned long arpn = physRpn_to_absRpn(prpn);
284 unsigned long lpar_rc; 283 unsigned long lpar_rc;
285 unsigned long flags; 284 unsigned long flags;
286 unsigned long slot; 285 unsigned long slot;
287 HPTE lhpte; 286 unsigned long hpte_v, hpte_r;
288 unsigned long dummy0, dummy1; 287 unsigned long dummy0, dummy1;
289 288
290 /* Fill in the local HPTE with absolute rpn, avpn and flags */ 289 hpte_v = ((va >> 23) << HPTE_V_AVPN_SHIFT) | vflags | HPTE_V_VALID;
291 lhpte.dw1.dword1 = 0; 290 if (vflags & HPTE_V_LARGE)
292 lhpte.dw1.dw1.rpn = arpn; 291 hpte_v &= ~(1UL << HPTE_V_AVPN_SHIFT);
293 lhpte.dw1.flags.flags = hpteflags;
294 292
295 lhpte.dw0.dword0 = 0; 293 hpte_r = (arpn << HPTE_R_RPN_SHIFT) | rflags;
296 lhpte.dw0.dw0.avpn = va >> 23;
297 lhpte.dw0.dw0.h = secondary;
298 lhpte.dw0.dw0.bolted = bolted;
299 lhpte.dw0.dw0.v = 1;
300
301 if (large) {
302 lhpte.dw0.dw0.l = 1;
303 lhpte.dw0.dw0.avpn &= ~0x1UL;
304 }
305 294
306 /* Now fill in the actual HPTE */ 295 /* Now fill in the actual HPTE */
307 /* Set CEC cookie to 0 */ 296 /* Set CEC cookie to 0 */
@@ -312,11 +301,11 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group,
312 flags = 0; 301 flags = 0;
313 302
314 /* XXX why is this here? - Anton */ 303 /* XXX why is this here? - Anton */
315 if (hpteflags & (_PAGE_GUARDED|_PAGE_NO_CACHE)) 304 if (rflags & (_PAGE_GUARDED|_PAGE_NO_CACHE))
316 lhpte.dw1.flags.flags &= ~_PAGE_COHERENT; 305 hpte_r &= ~_PAGE_COHERENT;
317 306
318 lpar_rc = plpar_hcall(H_ENTER, flags, hpte_group, lhpte.dw0.dword0, 307 lpar_rc = plpar_hcall(H_ENTER, flags, hpte_group, hpte_v,
319 lhpte.dw1.dword1, &slot, &dummy0, &dummy1); 308 hpte_r, &slot, &dummy0, &dummy1);
320 309
321 if (unlikely(lpar_rc == H_PTEG_Full)) 310 if (unlikely(lpar_rc == H_PTEG_Full))
322 return -1; 311 return -1;
@@ -332,7 +321,7 @@ long pSeries_lpar_hpte_insert(unsigned long hpte_group,
332 /* Because of iSeries, we have to pass down the secondary 321 /* Because of iSeries, we have to pass down the secondary
333 * bucket bit here as well 322 * bucket bit here as well
334 */ 323 */
335 return (slot & 7) | (secondary << 3); 324 return (slot & 7) | (!!(vflags & HPTE_V_SECONDARY) << 3);
336} 325}
337 326
338static DEFINE_SPINLOCK(pSeries_lpar_tlbie_lock); 327static DEFINE_SPINLOCK(pSeries_lpar_tlbie_lock);
@@ -427,22 +416,18 @@ static long pSeries_lpar_hpte_find(unsigned long vpn)
427 unsigned long hash; 416 unsigned long hash;
428 unsigned long i, j; 417 unsigned long i, j;
429 long slot; 418 long slot;
430 union { 419 unsigned long hpte_v;
431 unsigned long dword0;
432 Hpte_dword0 dw0;
433 } hpte_dw0;
434 Hpte_dword0 dw0;
435 420
436 hash = hpt_hash(vpn, 0); 421 hash = hpt_hash(vpn, 0);
437 422
438 for (j = 0; j < 2; j++) { 423 for (j = 0; j < 2; j++) {
439 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; 424 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
440 for (i = 0; i < HPTES_PER_GROUP; i++) { 425 for (i = 0; i < HPTES_PER_GROUP; i++) {
441 hpte_dw0.dword0 = pSeries_lpar_hpte_getword0(slot); 426 hpte_v = pSeries_lpar_hpte_getword0(slot);
442 dw0 = hpte_dw0.dw0;
443 427
444 if ((dw0.avpn == (vpn >> 11)) && dw0.v && 428 if ((HPTE_V_AVPN_VAL(hpte_v) == (vpn >> 11))
445 (dw0.h == j)) { 429 && (hpte_v & HPTE_V_VALID)
430 && (!!(hpte_v & HPTE_V_SECONDARY) == j)) {
446 /* HPTE matches */ 431 /* HPTE matches */
447 if (j) 432 if (j)
448 slot = -slot; 433 slot = -slot;
diff --git a/arch/ppc64/mm/hash_low.S b/arch/ppc64/mm/hash_low.S
index c23d46956dd9..fbff24827ae7 100644
--- a/arch/ppc64/mm/hash_low.S
+++ b/arch/ppc64/mm/hash_low.S
@@ -170,9 +170,7 @@ htab_insert_pte:
170 /* Call ppc_md.hpte_insert */ 170 /* Call ppc_md.hpte_insert */
171 ld r7,STK_PARM(r4)(r1) /* Retreive new pp bits */ 171 ld r7,STK_PARM(r4)(r1) /* Retreive new pp bits */
172 mr r4,r29 /* Retreive va */ 172 mr r4,r29 /* Retreive va */
173 li r6,0 /* primary slot */ 173 li r6,0 /* no vflags */
174 li r8,0 /* not bolted and not large */
175 li r9,0
176_GLOBAL(htab_call_hpte_insert1) 174_GLOBAL(htab_call_hpte_insert1)
177 bl . /* Will be patched by htab_finish_init() */ 175 bl . /* Will be patched by htab_finish_init() */
178 cmpdi 0,r3,0 176 cmpdi 0,r3,0
@@ -192,9 +190,7 @@ _GLOBAL(htab_call_hpte_insert1)
192 /* Call ppc_md.hpte_insert */ 190 /* Call ppc_md.hpte_insert */
193 ld r7,STK_PARM(r4)(r1) /* Retreive new pp bits */ 191 ld r7,STK_PARM(r4)(r1) /* Retreive new pp bits */
194 mr r4,r29 /* Retreive va */ 192 mr r4,r29 /* Retreive va */
195 li r6,1 /* secondary slot */ 193 li r6,HPTE_V_SECONDARY@l /* secondary slot */
196 li r8,0 /* not bolted and not large */
197 li r9,0
198_GLOBAL(htab_call_hpte_insert2) 194_GLOBAL(htab_call_hpte_insert2)
199 bl . /* Will be patched by htab_finish_init() */ 195 bl . /* Will be patched by htab_finish_init() */
200 cmpdi 0,r3,0 196 cmpdi 0,r3,0
diff --git a/arch/ppc64/mm/hash_native.c b/arch/ppc64/mm/hash_native.c
index 4fec05817d66..a6abd3a979bf 100644
--- a/arch/ppc64/mm/hash_native.c
+++ b/arch/ppc64/mm/hash_native.c
@@ -27,9 +27,9 @@
27 27
28static DEFINE_SPINLOCK(native_tlbie_lock); 28static DEFINE_SPINLOCK(native_tlbie_lock);
29 29
30static inline void native_lock_hpte(HPTE *hptep) 30static inline void native_lock_hpte(hpte_t *hptep)
31{ 31{
32 unsigned long *word = &hptep->dw0.dword0; 32 unsigned long *word = &hptep->v;
33 33
34 while (1) { 34 while (1) {
35 if (!test_and_set_bit(HPTE_LOCK_BIT, word)) 35 if (!test_and_set_bit(HPTE_LOCK_BIT, word))
@@ -39,32 +39,28 @@ static inline void native_lock_hpte(HPTE *hptep)
39 } 39 }
40} 40}
41 41
42static inline void native_unlock_hpte(HPTE *hptep) 42static inline void native_unlock_hpte(hpte_t *hptep)
43{ 43{
44 unsigned long *word = &hptep->dw0.dword0; 44 unsigned long *word = &hptep->v;
45 45
46 asm volatile("lwsync":::"memory"); 46 asm volatile("lwsync":::"memory");
47 clear_bit(HPTE_LOCK_BIT, word); 47 clear_bit(HPTE_LOCK_BIT, word);
48} 48}
49 49
50long native_hpte_insert(unsigned long hpte_group, unsigned long va, 50long native_hpte_insert(unsigned long hpte_group, unsigned long va,
51 unsigned long prpn, int secondary, 51 unsigned long prpn, unsigned long vflags,
52 unsigned long hpteflags, int bolted, int large) 52 unsigned long rflags)
53{ 53{
54 unsigned long arpn = physRpn_to_absRpn(prpn); 54 unsigned long arpn = physRpn_to_absRpn(prpn);
55 HPTE *hptep = htab_address + hpte_group; 55 hpte_t *hptep = htab_address + hpte_group;
56 Hpte_dword0 dw0; 56 unsigned long hpte_v, hpte_r;
57 HPTE lhpte;
58 int i; 57 int i;
59 58
60 for (i = 0; i < HPTES_PER_GROUP; i++) { 59 for (i = 0; i < HPTES_PER_GROUP; i++) {
61 dw0 = hptep->dw0.dw0; 60 if (! (hptep->v & HPTE_V_VALID)) {
62
63 if (!dw0.v) {
64 /* retry with lock held */ 61 /* retry with lock held */
65 native_lock_hpte(hptep); 62 native_lock_hpte(hptep);
66 dw0 = hptep->dw0.dw0; 63 if (! (hptep->v & HPTE_V_VALID))
67 if (!dw0.v)
68 break; 64 break;
69 native_unlock_hpte(hptep); 65 native_unlock_hpte(hptep);
70 } 66 }
@@ -75,56 +71,45 @@ long native_hpte_insert(unsigned long hpte_group, unsigned long va,
75 if (i == HPTES_PER_GROUP) 71 if (i == HPTES_PER_GROUP)
76 return -1; 72 return -1;
77 73
78 lhpte.dw1.dword1 = 0; 74 hpte_v = (va >> 23) << HPTE_V_AVPN_SHIFT | vflags | HPTE_V_VALID;
79 lhpte.dw1.dw1.rpn = arpn; 75 if (vflags & HPTE_V_LARGE)
80 lhpte.dw1.flags.flags = hpteflags; 76 va &= ~(1UL << HPTE_V_AVPN_SHIFT);
81 77 hpte_r = (arpn << HPTE_R_RPN_SHIFT) | rflags;
82 lhpte.dw0.dword0 = 0;
83 lhpte.dw0.dw0.avpn = va >> 23;
84 lhpte.dw0.dw0.h = secondary;
85 lhpte.dw0.dw0.bolted = bolted;
86 lhpte.dw0.dw0.v = 1;
87
88 if (large) {
89 lhpte.dw0.dw0.l = 1;
90 lhpte.dw0.dw0.avpn &= ~0x1UL;
91 }
92
93 hptep->dw1.dword1 = lhpte.dw1.dword1;
94 78
79 hptep->r = hpte_r;
95 /* Guarantee the second dword is visible before the valid bit */ 80 /* Guarantee the second dword is visible before the valid bit */
96 __asm__ __volatile__ ("eieio" : : : "memory"); 81 __asm__ __volatile__ ("eieio" : : : "memory");
97
98 /* 82 /*
99 * Now set the first dword including the valid bit 83 * Now set the first dword including the valid bit
100 * NOTE: this also unlocks the hpte 84 * NOTE: this also unlocks the hpte
101 */ 85 */
102 hptep->dw0.dword0 = lhpte.dw0.dword0; 86 hptep->v = hpte_v;
103 87
104 __asm__ __volatile__ ("ptesync" : : : "memory"); 88 __asm__ __volatile__ ("ptesync" : : : "memory");
105 89
106 return i | (secondary << 3); 90 return i | (!!(vflags & HPTE_V_SECONDARY) << 3);
107} 91}
108 92
109static long native_hpte_remove(unsigned long hpte_group) 93static long native_hpte_remove(unsigned long hpte_group)
110{ 94{
111 HPTE *hptep; 95 hpte_t *hptep;
112 Hpte_dword0 dw0;
113 int i; 96 int i;
114 int slot_offset; 97 int slot_offset;
98 unsigned long hpte_v;
115 99
116 /* pick a random entry to start at */ 100 /* pick a random entry to start at */
117 slot_offset = mftb() & 0x7; 101 slot_offset = mftb() & 0x7;
118 102
119 for (i = 0; i < HPTES_PER_GROUP; i++) { 103 for (i = 0; i < HPTES_PER_GROUP; i++) {
120 hptep = htab_address + hpte_group + slot_offset; 104 hptep = htab_address + hpte_group + slot_offset;
121 dw0 = hptep->dw0.dw0; 105 hpte_v = hptep->v;
122 106
123 if (dw0.v && !dw0.bolted) { 107 if ((hpte_v & HPTE_V_VALID) && !(hpte_v & HPTE_V_BOLTED)) {
124 /* retry with lock held */ 108 /* retry with lock held */
125 native_lock_hpte(hptep); 109 native_lock_hpte(hptep);
126 dw0 = hptep->dw0.dw0; 110 hpte_v = hptep->v;
127 if (dw0.v && !dw0.bolted) 111 if ((hpte_v & HPTE_V_VALID)
112 && !(hpte_v & HPTE_V_BOLTED))
128 break; 113 break;
129 native_unlock_hpte(hptep); 114 native_unlock_hpte(hptep);
130 } 115 }
@@ -137,15 +122,15 @@ static long native_hpte_remove(unsigned long hpte_group)
137 return -1; 122 return -1;
138 123
139 /* Invalidate the hpte. NOTE: this also unlocks it */ 124 /* Invalidate the hpte. NOTE: this also unlocks it */
140 hptep->dw0.dword0 = 0; 125 hptep->v = 0;
141 126
142 return i; 127 return i;
143} 128}
144 129
145static inline void set_pp_bit(unsigned long pp, HPTE *addr) 130static inline void set_pp_bit(unsigned long pp, hpte_t *addr)
146{ 131{
147 unsigned long old; 132 unsigned long old;
148 unsigned long *p = &addr->dw1.dword1; 133 unsigned long *p = &addr->r;
149 134
150 __asm__ __volatile__( 135 __asm__ __volatile__(
151 "1: ldarx %0,0,%3\n\ 136 "1: ldarx %0,0,%3\n\
@@ -163,11 +148,11 @@ static inline void set_pp_bit(unsigned long pp, HPTE *addr)
163 */ 148 */
164static long native_hpte_find(unsigned long vpn) 149static long native_hpte_find(unsigned long vpn)
165{ 150{
166 HPTE *hptep; 151 hpte_t *hptep;
167 unsigned long hash; 152 unsigned long hash;
168 unsigned long i, j; 153 unsigned long i, j;
169 long slot; 154 long slot;
170 Hpte_dword0 dw0; 155 unsigned long hpte_v;
171 156
172 hash = hpt_hash(vpn, 0); 157 hash = hpt_hash(vpn, 0);
173 158
@@ -175,10 +160,11 @@ static long native_hpte_find(unsigned long vpn)
175 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; 160 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
176 for (i = 0; i < HPTES_PER_GROUP; i++) { 161 for (i = 0; i < HPTES_PER_GROUP; i++) {
177 hptep = htab_address + slot; 162 hptep = htab_address + slot;
178 dw0 = hptep->dw0.dw0; 163 hpte_v = hptep->v;
179 164
180 if ((dw0.avpn == (vpn >> 11)) && dw0.v && 165 if ((HPTE_V_AVPN_VAL(hpte_v) == (vpn >> 11))
181 (dw0.h == j)) { 166 && (hpte_v & HPTE_V_VALID)
167 && ( !!(hpte_v & HPTE_V_SECONDARY) == j)) {
182 /* HPTE matches */ 168 /* HPTE matches */
183 if (j) 169 if (j)
184 slot = -slot; 170 slot = -slot;
@@ -195,20 +181,21 @@ static long native_hpte_find(unsigned long vpn)
195static long native_hpte_updatepp(unsigned long slot, unsigned long newpp, 181static long native_hpte_updatepp(unsigned long slot, unsigned long newpp,
196 unsigned long va, int large, int local) 182 unsigned long va, int large, int local)
197{ 183{
198 HPTE *hptep = htab_address + slot; 184 hpte_t *hptep = htab_address + slot;
199 Hpte_dword0 dw0; 185 unsigned long hpte_v;
200 unsigned long avpn = va >> 23; 186 unsigned long avpn = va >> 23;
201 int ret = 0; 187 int ret = 0;
202 188
203 if (large) 189 if (large)
204 avpn &= ~0x1UL; 190 avpn &= ~1;
205 191
206 native_lock_hpte(hptep); 192 native_lock_hpte(hptep);
207 193
208 dw0 = hptep->dw0.dw0; 194 hpte_v = hptep->v;
209 195
210 /* Even if we miss, we need to invalidate the TLB */ 196 /* Even if we miss, we need to invalidate the TLB */
211 if ((dw0.avpn != avpn) || !dw0.v) { 197 if ((HPTE_V_AVPN_VAL(hpte_v) != avpn)
198 || !(hpte_v & HPTE_V_VALID)) {
212 native_unlock_hpte(hptep); 199 native_unlock_hpte(hptep);
213 ret = -1; 200 ret = -1;
214 } else { 201 } else {
@@ -244,7 +231,7 @@ static void native_hpte_updateboltedpp(unsigned long newpp, unsigned long ea)
244{ 231{
245 unsigned long vsid, va, vpn, flags = 0; 232 unsigned long vsid, va, vpn, flags = 0;
246 long slot; 233 long slot;
247 HPTE *hptep; 234 hpte_t *hptep;
248 int lock_tlbie = !cpu_has_feature(CPU_FTR_LOCKLESS_TLBIE); 235 int lock_tlbie = !cpu_has_feature(CPU_FTR_LOCKLESS_TLBIE);
249 236
250 vsid = get_kernel_vsid(ea); 237 vsid = get_kernel_vsid(ea);
@@ -269,26 +256,27 @@ static void native_hpte_updateboltedpp(unsigned long newpp, unsigned long ea)
269static void native_hpte_invalidate(unsigned long slot, unsigned long va, 256static void native_hpte_invalidate(unsigned long slot, unsigned long va,
270 int large, int local) 257 int large, int local)
271{ 258{
272 HPTE *hptep = htab_address + slot; 259 hpte_t *hptep = htab_address + slot;
273 Hpte_dword0 dw0; 260 unsigned long hpte_v;
274 unsigned long avpn = va >> 23; 261 unsigned long avpn = va >> 23;
275 unsigned long flags; 262 unsigned long flags;
276 int lock_tlbie = !cpu_has_feature(CPU_FTR_LOCKLESS_TLBIE); 263 int lock_tlbie = !cpu_has_feature(CPU_FTR_LOCKLESS_TLBIE);
277 264
278 if (large) 265 if (large)
279 avpn &= ~0x1UL; 266 avpn &= ~1;
280 267
281 local_irq_save(flags); 268 local_irq_save(flags);
282 native_lock_hpte(hptep); 269 native_lock_hpte(hptep);
283 270
284 dw0 = hptep->dw0.dw0; 271 hpte_v = hptep->v;
285 272
286 /* Even if we miss, we need to invalidate the TLB */ 273 /* Even if we miss, we need to invalidate the TLB */
287 if ((dw0.avpn != avpn) || !dw0.v) { 274 if ((HPTE_V_AVPN_VAL(hpte_v) != avpn)
275 || !(hpte_v & HPTE_V_VALID)) {
288 native_unlock_hpte(hptep); 276 native_unlock_hpte(hptep);
289 } else { 277 } else {
290 /* Invalidate the hpte. NOTE: this also unlocks it */ 278 /* Invalidate the hpte. NOTE: this also unlocks it */
291 hptep->dw0.dword0 = 0; 279 hptep->v = 0;
292 } 280 }
293 281
294 /* Invalidate the tlb */ 282 /* Invalidate the tlb */
@@ -315,8 +303,8 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long va,
315static void native_hpte_clear(void) 303static void native_hpte_clear(void)
316{ 304{
317 unsigned long slot, slots, flags; 305 unsigned long slot, slots, flags;
318 HPTE *hptep = htab_address; 306 hpte_t *hptep = htab_address;
319 Hpte_dword0 dw0; 307 unsigned long hpte_v;
320 unsigned long pteg_count; 308 unsigned long pteg_count;
321 309
322 pteg_count = htab_hash_mask + 1; 310 pteg_count = htab_hash_mask + 1;
@@ -336,11 +324,11 @@ static void native_hpte_clear(void)
336 * running, right? and for crash dump, we probably 324 * running, right? and for crash dump, we probably
337 * don't want to wait for a maybe bad cpu. 325 * don't want to wait for a maybe bad cpu.
338 */ 326 */
339 dw0 = hptep->dw0.dw0; 327 hpte_v = hptep->v;
340 328
341 if (dw0.v) { 329 if (hpte_v & HPTE_V_VALID) {
342 hptep->dw0.dword0 = 0; 330 hptep->v = 0;
343 tlbie(slot2va(dw0.avpn, dw0.l, dw0.h, slot), dw0.l); 331 tlbie(slot2va(hpte_v, slot), hpte_v & HPTE_V_LARGE);
344 } 332 }
345 } 333 }
346 334
@@ -353,8 +341,8 @@ static void native_flush_hash_range(unsigned long context,
353{ 341{
354 unsigned long vsid, vpn, va, hash, secondary, slot, flags, avpn; 342 unsigned long vsid, vpn, va, hash, secondary, slot, flags, avpn;
355 int i, j; 343 int i, j;
356 HPTE *hptep; 344 hpte_t *hptep;
357 Hpte_dword0 dw0; 345 unsigned long hpte_v;
358 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); 346 struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch);
359 347
360 /* XXX fix for large ptes */ 348 /* XXX fix for large ptes */
@@ -390,14 +378,15 @@ static void native_flush_hash_range(unsigned long context,
390 378
391 native_lock_hpte(hptep); 379 native_lock_hpte(hptep);
392 380
393 dw0 = hptep->dw0.dw0; 381 hpte_v = hptep->v;
394 382
395 /* Even if we miss, we need to invalidate the TLB */ 383 /* Even if we miss, we need to invalidate the TLB */
396 if ((dw0.avpn != avpn) || !dw0.v) { 384 if ((HPTE_V_AVPN_VAL(hpte_v) != avpn)
385 || !(hpte_v & HPTE_V_VALID)) {
397 native_unlock_hpte(hptep); 386 native_unlock_hpte(hptep);
398 } else { 387 } else {
399 /* Invalidate the hpte. NOTE: this also unlocks it */ 388 /* Invalidate the hpte. NOTE: this also unlocks it */
400 hptep->dw0.dword0 = 0; 389 hptep->v = 0;
401 } 390 }
402 391
403 j++; 392 j++;
diff --git a/arch/ppc64/mm/hash_utils.c b/arch/ppc64/mm/hash_utils.c
index 1647b1c6f28e..623b5d130c31 100644
--- a/arch/ppc64/mm/hash_utils.c
+++ b/arch/ppc64/mm/hash_utils.c
@@ -75,8 +75,8 @@
75extern unsigned long dart_tablebase; 75extern unsigned long dart_tablebase;
76#endif /* CONFIG_U3_DART */ 76#endif /* CONFIG_U3_DART */
77 77
78HPTE *htab_address; 78hpte_t *htab_address;
79unsigned long htab_hash_mask; 79unsigned long htab_hash_mask;
80 80
81extern unsigned long _SDR1; 81extern unsigned long _SDR1;
82 82
@@ -97,11 +97,15 @@ static inline void create_pte_mapping(unsigned long start, unsigned long end,
97 unsigned long addr; 97 unsigned long addr;
98 unsigned int step; 98 unsigned int step;
99 unsigned long tmp_mode; 99 unsigned long tmp_mode;
100 unsigned long vflags;
100 101
101 if (large) 102 if (large) {
102 step = 16*MB; 103 step = 16*MB;
103 else 104 vflags = HPTE_V_BOLTED | HPTE_V_LARGE;
105 } else {
104 step = 4*KB; 106 step = 4*KB;
107 vflags = HPTE_V_BOLTED;
108 }
105 109
106 for (addr = start; addr < end; addr += step) { 110 for (addr = start; addr < end; addr += step) {
107 unsigned long vpn, hash, hpteg; 111 unsigned long vpn, hash, hpteg;
@@ -129,12 +133,12 @@ static inline void create_pte_mapping(unsigned long start, unsigned long end,
129 if (systemcfg->platform & PLATFORM_LPAR) 133 if (systemcfg->platform & PLATFORM_LPAR)
130 ret = pSeries_lpar_hpte_insert(hpteg, va, 134 ret = pSeries_lpar_hpte_insert(hpteg, va,
131 virt_to_abs(addr) >> PAGE_SHIFT, 135 virt_to_abs(addr) >> PAGE_SHIFT,
132 0, tmp_mode, 1, large); 136 vflags, tmp_mode);
133 else 137 else
134#endif /* CONFIG_PPC_PSERIES */ 138#endif /* CONFIG_PPC_PSERIES */
135 ret = native_hpte_insert(hpteg, va, 139 ret = native_hpte_insert(hpteg, va,
136 virt_to_abs(addr) >> PAGE_SHIFT, 140 virt_to_abs(addr) >> PAGE_SHIFT,
137 0, tmp_mode, 1, large); 141 vflags, tmp_mode);
138 142
139 if (ret == -1) { 143 if (ret == -1) {
140 ppc64_terminate_msg(0x20, "create_pte_mapping"); 144 ppc64_terminate_msg(0x20, "create_pte_mapping");
diff --git a/arch/ppc64/mm/hugetlbpage.c b/arch/ppc64/mm/hugetlbpage.c
index fdcfe97c75c1..f9524602818d 100644
--- a/arch/ppc64/mm/hugetlbpage.c
+++ b/arch/ppc64/mm/hugetlbpage.c
@@ -583,7 +583,7 @@ int hash_huge_page(struct mm_struct *mm, unsigned long access,
583 pte_t *ptep; 583 pte_t *ptep;
584 unsigned long va, vpn; 584 unsigned long va, vpn;
585 pte_t old_pte, new_pte; 585 pte_t old_pte, new_pte;
586 unsigned long hpteflags, prpn; 586 unsigned long rflags, prpn;
587 long slot; 587 long slot;
588 int err = 1; 588 int err = 1;
589 589
@@ -626,9 +626,9 @@ int hash_huge_page(struct mm_struct *mm, unsigned long access,
626 old_pte = *ptep; 626 old_pte = *ptep;
627 new_pte = old_pte; 627 new_pte = old_pte;
628 628
629 hpteflags = 0x2 | (! (pte_val(new_pte) & _PAGE_RW)); 629 rflags = 0x2 | (! (pte_val(new_pte) & _PAGE_RW));
630 /* _PAGE_EXEC -> HW_NO_EXEC since it's inverted */ 630 /* _PAGE_EXEC -> HW_NO_EXEC since it's inverted */
631 hpteflags |= ((pte_val(new_pte) & _PAGE_EXEC) ? 0 : HW_NO_EXEC); 631 rflags |= ((pte_val(new_pte) & _PAGE_EXEC) ? 0 : HW_NO_EXEC);
632 632
633 /* Check if pte already has an hpte (case 2) */ 633 /* Check if pte already has an hpte (case 2) */
634 if (unlikely(pte_val(old_pte) & _PAGE_HASHPTE)) { 634 if (unlikely(pte_val(old_pte) & _PAGE_HASHPTE)) {
@@ -641,7 +641,7 @@ int hash_huge_page(struct mm_struct *mm, unsigned long access,
641 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; 641 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
642 slot += (pte_val(old_pte) & _PAGE_GROUP_IX) >> 12; 642 slot += (pte_val(old_pte) & _PAGE_GROUP_IX) >> 12;
643 643
644 if (ppc_md.hpte_updatepp(slot, hpteflags, va, 1, local) == -1) 644 if (ppc_md.hpte_updatepp(slot, rflags, va, 1, local) == -1)
645 pte_val(old_pte) &= ~_PAGE_HPTEFLAGS; 645 pte_val(old_pte) &= ~_PAGE_HPTEFLAGS;
646 } 646 }
647 647
@@ -661,10 +661,10 @@ repeat:
661 661
662 /* Add in WIMG bits */ 662 /* Add in WIMG bits */
663 /* XXX We should store these in the pte */ 663 /* XXX We should store these in the pte */
664 hpteflags |= _PAGE_COHERENT; 664 rflags |= _PAGE_COHERENT;
665 665
666 slot = ppc_md.hpte_insert(hpte_group, va, prpn, 0, 666 slot = ppc_md.hpte_insert(hpte_group, va, prpn,
667 hpteflags, 0, 1); 667 HPTE_V_LARGE, rflags);
668 668
669 /* Primary is full, try the secondary */ 669 /* Primary is full, try the secondary */
670 if (unlikely(slot == -1)) { 670 if (unlikely(slot == -1)) {
@@ -672,7 +672,7 @@ repeat:
672 hpte_group = ((~hash & htab_hash_mask) * 672 hpte_group = ((~hash & htab_hash_mask) *
673 HPTES_PER_GROUP) & ~0x7UL; 673 HPTES_PER_GROUP) & ~0x7UL;
674 slot = ppc_md.hpte_insert(hpte_group, va, prpn, 674 slot = ppc_md.hpte_insert(hpte_group, va, prpn,
675 1, hpteflags, 0, 1); 675 HPTE_V_LARGE, rflags);
676 if (slot == -1) { 676 if (slot == -1) {
677 if (mftb() & 0x1) 677 if (mftb() & 0x1)
678 hpte_group = ((hash & htab_hash_mask) * HPTES_PER_GROUP) & ~0x7UL; 678 hpte_group = ((hash & htab_hash_mask) * HPTES_PER_GROUP) & ~0x7UL;
diff --git a/arch/ppc64/mm/init.c b/arch/ppc64/mm/init.c
index b50b3a446dbe..e58a24d42879 100644
--- a/arch/ppc64/mm/init.c
+++ b/arch/ppc64/mm/init.c
@@ -180,9 +180,10 @@ static int map_io_page(unsigned long ea, unsigned long pa, int flags)
180 hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP); 180 hpteg = ((hash & htab_hash_mask) * HPTES_PER_GROUP);
181 181
182 /* Panic if a pte grpup is full */ 182 /* Panic if a pte grpup is full */
183 if (ppc_md.hpte_insert(hpteg, va, pa >> PAGE_SHIFT, 0, 183 if (ppc_md.hpte_insert(hpteg, va, pa >> PAGE_SHIFT,
184 _PAGE_NO_CACHE|_PAGE_GUARDED|PP_RWXX, 184 HPTE_V_BOLTED,
185 1, 0) == -1) { 185 _PAGE_NO_CACHE|_PAGE_GUARDED|PP_RWXX)
186 == -1) {
186 panic("map_io_page: could not insert mapping"); 187 panic("map_io_page: could not insert mapping");
187 } 188 }
188 } 189 }
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index 614056222875..18610cea03a2 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -58,6 +58,7 @@
58#include <linux/compat.h> 58#include <linux/compat.h>
59#include <linux/vfs.h> 59#include <linux/vfs.h>
60#include <linux/ptrace.h> 60#include <linux/ptrace.h>
61#include <linux/fadvise.h>
61 62
62#include <asm/types.h> 63#include <asm/types.h>
63#include <asm/ipc.h> 64#include <asm/ipc.h>
@@ -1043,3 +1044,40 @@ sys32_timer_create(clockid_t which_clock, struct compat_sigevent *se32,
1043 1044
1044 return ret; 1045 return ret;
1045} 1046}
1047
1048/*
1049 * 31 bit emulation wrapper functions for sys_fadvise64/fadvise64_64.
1050 * These need to rewrite the advise values for POSIX_FADV_{DONTNEED,NOREUSE}
1051 * because the 31 bit values differ from the 64 bit values.
1052 */
1053
1054asmlinkage long
1055sys32_fadvise64(int fd, loff_t offset, size_t len, int advise)
1056{
1057 if (advise == 4)
1058 advise = POSIX_FADV_DONTNEED;
1059 else if (advise == 5)
1060 advise = POSIX_FADV_NOREUSE;
1061 return sys_fadvise64(fd, offset, len, advise);
1062}
1063
1064struct fadvise64_64_args {
1065 int fd;
1066 long long offset;
1067 long long len;
1068 int advice;
1069};
1070
1071asmlinkage long
1072sys32_fadvise64_64(struct fadvise64_64_args __user *args)
1073{
1074 struct fadvise64_64_args a;
1075
1076 if ( copy_from_user(&a, args, sizeof(a)) )
1077 return -EFAULT;
1078 if (a.advice == 4)
1079 a.advice = POSIX_FADV_DONTNEED;
1080 else if (a.advice == 5)
1081 a.advice = POSIX_FADV_NOREUSE;
1082 return sys_fadvise64_64(a.fd, a.offset, a.len, a.advice);
1083}
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index bf529739c8ab..799a98eac92d 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -1251,12 +1251,12 @@ sys32_fadvise64_wrapper:
1251 or %r3,%r4 # get low word of 64bit loff_t 1251 or %r3,%r4 # get low word of 64bit loff_t
1252 llgfr %r4,%r5 # size_t (unsigned long) 1252 llgfr %r4,%r5 # size_t (unsigned long)
1253 lgfr %r5,%r6 # int 1253 lgfr %r5,%r6 # int
1254 jg sys_fadvise64 1254 jg sys32_fadvise64
1255 1255
1256 .globl sys32_fadvise64_64_wrapper 1256 .globl sys32_fadvise64_64_wrapper
1257sys32_fadvise64_64_wrapper: 1257sys32_fadvise64_64_wrapper:
1258 llgtr %r2,%r2 # struct fadvise64_64_args * 1258 llgtr %r2,%r2 # struct fadvise64_64_args *
1259 jg s390_fadvise64_64 1259 jg sys32_fadvise64_64
1260 1260
1261 .globl sys32_clock_settime_wrapper 1261 .globl sys32_clock_settime_wrapper
1262sys32_clock_settime_wrapper: 1262sys32_clock_settime_wrapper:
diff --git a/arch/um/Kconfig_net b/arch/um/Kconfig_net
index 1c2f9a70d91d..fa2ab2dd78b7 100644
--- a/arch/um/Kconfig_net
+++ b/arch/um/Kconfig_net
@@ -135,7 +135,7 @@ config UML_NET_MCAST
135 135
136config UML_NET_PCAP 136config UML_NET_PCAP
137 bool "pcap transport" 137 bool "pcap transport"
138 depends on UML_NET && BROKEN 138 depends on UML_NET && EXPERIMENTAL
139 help 139 help
140 The pcap transport makes a pcap packet stream on the host look 140 The pcap transport makes a pcap packet stream on the host look
141 like an ethernet device inside UML. This is useful for making 141 like an ethernet device inside UML. This is useful for making
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 4a375bbac109..eb4ac403bd93 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -51,25 +51,26 @@ MRPROPER_DIRS += $(ARCH_DIR)/include2
51endif 51endif
52SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) 52SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
53 53
54include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH) 54# -Dvmap=kernel_vmap affects everything, and prevents anything from
55# referencing the libpcap.o symbol so named.
56
57CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
58 $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap
55 59
56core-y += $(SUBARCH_CORE) 60USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
57libs-y += $(SUBARCH_LIBS) 61USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
62 $(MODE_INCLUDE)
58 63
59# -Derrno=kernel_errno - This turns all kernel references to errno into 64# -Derrno=kernel_errno - This turns all kernel references to errno into
60# kernel_errno to separate them from the libc errno. This allows -fno-common 65# kernel_errno to separate them from the libc errno. This allows -fno-common
61# in CFLAGS. Otherwise, it would cause ld to complain about the two different 66# in CFLAGS. Otherwise, it would cause ld to complain about the two different
62# errnos. 67# errnos.
63 68
64CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
65 $(ARCH_INCLUDE) $(MODE_INCLUDE)
66
67USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
68USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
69 $(MODE_INCLUDE) $(ARCH_USER_CFLAGS)
70CFLAGS += -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask 69CFLAGS += -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask
71CFLAGS += $(call cc-option,-fno-unit-at-a-time,) 70CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
72 71
72include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
73
73#This will adjust *FLAGS accordingly to the platform. 74#This will adjust *FLAGS accordingly to the platform.
74include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS) 75include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
75 76
@@ -116,18 +117,19 @@ CONFIG_KERNEL_STACK_ORDER ?= 2
116STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] ) 117STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
117 118
118ifndef START 119ifndef START
119 START = $$(($(TOP_ADDR) - $(SIZE))) 120 START = $(shell echo $$[ $(TOP_ADDR) - $(SIZE) ] )
120endif 121endif
121 122
122CPPFLAGS_vmlinux.lds = $(shell echo -U$(SUBARCH) \ 123CPPFLAGS_vmlinux.lds = -U$(SUBARCH) \
123 -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \ 124 -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
124 -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE-y) \ 125 -DELF_FORMAT="$(ELF_FORMAT)" $(CPP_MODE-y) \
125 -DKERNEL_STACK_SIZE=$(STACK_SIZE) -DSUBARCH=$(SUBARCH)) 126 -DKERNEL_STACK_SIZE=$(STACK_SIZE) \
127 -DUNMAP_PATH=arch/um/sys-$(SUBARCH)/unmap_fin.o
126 128
127#The wrappers will select whether using "malloc" or the kernel allocator. 129#The wrappers will select whether using "malloc" or the kernel allocator.
128LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc 130LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
129 131
130CFLAGS_vmlinux = $(LINK-y) $(LINK_WRAPS) 132CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS)
131define cmd_vmlinux__ 133define cmd_vmlinux__
132 $(CC) $(CFLAGS_vmlinux) -o $@ \ 134 $(CC) $(CFLAGS_vmlinux) -o $@ \
133 -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \ 135 -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
index 301059062a3e..93d0818fa816 100644
--- a/arch/um/Makefile-i386
+++ b/arch/um/Makefile-i386
@@ -1,4 +1,4 @@
1SUBARCH_CORE := arch/um/sys-i386/ arch/i386/crypto/ 1core-y += arch/um/sys-i386/ arch/i386/crypto/
2 2
3TOP_ADDR := $(CONFIG_TOP_ADDR) 3TOP_ADDR := $(CONFIG_TOP_ADDR)
4 4
@@ -8,21 +8,32 @@ ifeq ($(CONFIG_MODE_SKAS),y)
8 endif 8 endif
9endif 9endif
10 10
11LDFLAGS += -m elf_i386
12ELF_ARCH := $(SUBARCH)
13ELF_FORMAT := elf32-$(SUBARCH)
14OBJCOPYFLAGS := -O binary -R .note -R .comment -S
15
16ifeq ("$(origin SUBARCH)", "command line")
17ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
18CFLAGS += $(call cc-option,-m32)
19USER_CFLAGS += $(call cc-option,-m32)
20HOSTCFLAGS += $(call cc-option,-m32)
21HOSTLDFLAGS += $(call cc-option,-m32)
22AFLAGS += $(call cc-option,-m32)
23LINK-y += $(call cc-option,-m32)
24UML_OBJCOPYFLAGS += -F $(ELF_FORMAT)
25
26export LDFLAGS HOSTCFLAGS HOSTLDFLAGS UML_OBJCOPYFLAGS
27endif
28endif
29
11CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH) $(STUB_CFLAGS) 30CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH) $(STUB_CFLAGS)
12ARCH_USER_CFLAGS :=
13 31
14ifneq ($(CONFIG_GPROF),y) 32ifneq ($(CONFIG_GPROF),y)
15ARCH_CFLAGS += -DUM_FASTCALL 33ARCH_CFLAGS += -DUM_FASTCALL
16endif 34endif
17 35
18ELF_ARCH := $(SUBARCH) 36SYS_HEADERS := $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h
19ELF_FORMAT := elf32-$(SUBARCH)
20
21OBJCOPYFLAGS := -O binary -R .note -R .comment -S
22
23SYS_UTIL_DIR := $(ARCH_DIR)/sys-i386/util
24
25SYS_HEADERS := $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h
26 37
27prepare: $(SYS_HEADERS) 38prepare: $(SYS_HEADERS)
28 39
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index d80bd0052e6b..aa2f7174ebca 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -1,11 +1,13 @@
1# Copyright 2003 - 2004 Pathscale, Inc 1# Copyright 2003 - 2004 Pathscale, Inc
2# Released under the GPL 2# Released under the GPL
3 3
4SUBARCH_LIBS := arch/um/sys-x86_64/ 4libs-y += arch/um/sys-x86_64/
5START := 0x60000000 5START := 0x60000000
6 6
7#We #undef __x86_64__ for kernelspace, not for userspace where
8#it's needed for headers to work!
7CFLAGS += -U__$(SUBARCH)__ -fno-builtin $(STUB_CFLAGS) 9CFLAGS += -U__$(SUBARCH)__ -fno-builtin $(STUB_CFLAGS)
8ARCH_USER_CFLAGS := -D__x86_64__ 10USER_CFLAGS += -fno-builtin
9 11
10ELF_ARCH := i386:x86-64 12ELF_ARCH := i386:x86-64
11ELF_FORMAT := elf64-x86-64 13ELF_FORMAT := elf64-x86-64
diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile
index b2de9916c32c..d6c31a95b887 100644
--- a/arch/um/drivers/Makefile
+++ b/arch/um/drivers/Makefile
@@ -10,7 +10,6 @@ slip-objs := slip_kern.o slip_user.o
10slirp-objs := slirp_kern.o slirp_user.o 10slirp-objs := slirp_kern.o slirp_user.o
11daemon-objs := daemon_kern.o daemon_user.o 11daemon-objs := daemon_kern.o daemon_user.o
12mcast-objs := mcast_kern.o mcast_user.o 12mcast-objs := mcast_kern.o mcast_user.o
13#pcap-objs := pcap_kern.o pcap_user.o $(PCAP)
14net-objs := net_kern.o net_user.o 13net-objs := net_kern.o net_user.o
15mconsole-objs := mconsole_kern.o mconsole_user.o 14mconsole-objs := mconsole_kern.o mconsole_user.o
16hostaudio-objs := hostaudio_kern.o 15hostaudio-objs := hostaudio_kern.o
@@ -18,6 +17,17 @@ ubd-objs := ubd_kern.o ubd_user.o
18port-objs := port_kern.o port_user.o 17port-objs := port_kern.o port_user.o
19harddog-objs := harddog_kern.o harddog_user.o 18harddog-objs := harddog_kern.o harddog_user.o
20 19
20LDFLAGS_pcap.o := -r $(shell $(CC) $(CFLAGS) -print-file-name=libpcap.a)
21
22$(obj)/pcap.o: $(obj)/pcap_kern.o $(obj)/pcap_user.o
23 $(LD) -r -dp -o $@ $^ $(LDFLAGS) $(LDFLAGS_pcap.o)
24#XXX: The call below does not work because the flags are added before the
25# object name, so nothing from the library gets linked.
26#$(call if_changed,ld)
27
28# When the above is fixed, don't forget to add this too!
29#targets := $(obj)/pcap.o
30
21obj-y := stdio_console.o fd.o chan_kern.o chan_user.o line.o 31obj-y := stdio_console.o fd.o chan_kern.o chan_user.o line.o
22obj-$(CONFIG_SSL) += ssl.o 32obj-$(CONFIG_SSL) += ssl.o
23obj-$(CONFIG_STDERR_CONSOLE) += stderr_console.o 33obj-$(CONFIG_STDERR_CONSOLE) += stderr_console.o
@@ -26,7 +36,7 @@ obj-$(CONFIG_UML_NET_SLIP) += slip.o slip_common.o
26obj-$(CONFIG_UML_NET_SLIRP) += slirp.o slip_common.o 36obj-$(CONFIG_UML_NET_SLIRP) += slirp.o slip_common.o
27obj-$(CONFIG_UML_NET_DAEMON) += daemon.o 37obj-$(CONFIG_UML_NET_DAEMON) += daemon.o
28obj-$(CONFIG_UML_NET_MCAST) += mcast.o 38obj-$(CONFIG_UML_NET_MCAST) += mcast.o
29#obj-$(CONFIG_UML_NET_PCAP) += pcap.o $(PCAP) 39obj-$(CONFIG_UML_NET_PCAP) += pcap.o
30obj-$(CONFIG_UML_NET) += net.o 40obj-$(CONFIG_UML_NET) += net.o
31obj-$(CONFIG_MCONSOLE) += mconsole.o 41obj-$(CONFIG_MCONSOLE) += mconsole.o
32obj-$(CONFIG_MMAPPER) += mmapper_kern.o 42obj-$(CONFIG_MMAPPER) += mmapper_kern.o
@@ -41,6 +51,7 @@ obj-$(CONFIG_UML_WATCHDOG) += harddog.o
41obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o 51obj-$(CONFIG_BLK_DEV_COW_COMMON) += cow_user.o
42obj-$(CONFIG_UML_RANDOM) += random.o 52obj-$(CONFIG_UML_RANDOM) += random.o
43 53
44USER_OBJS := fd.o null.o pty.o tty.o xterm.o slip_common.o 54# pcap_user.o must be added explicitly.
55USER_OBJS := fd.o null.o pty.o tty.o xterm.o slip_common.o pcap_user.o
45 56
46include arch/um/scripts/Makefile.rules 57include arch/um/scripts/Makefile.rules
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index 163476a8cb1b..b03326d391c9 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -16,8 +16,8 @@ SECTIONS
16 __binary_start = .; 16 __binary_start = .;
17 17
18#ifdef MODE_TT 18#ifdef MODE_TT
19 .remap_data : { arch/um/sys-SUBARCH/unmap_fin.o (.data .bss) } 19 .remap_data : { UNMAP_PATH (.data .bss) }
20 .remap : { arch/um/sys-SUBARCH/unmap_fin.o (.text) } 20 .remap : { UNMAP_PATH (.text) }
21 21
22 . = ALIGN(4096); /* Init code and data */ 22 . = ALIGN(4096); /* Init code and data */
23#endif 23#endif
diff --git a/arch/um/scripts/Makefile.unmap b/arch/um/scripts/Makefile.unmap
index 37a8f9765295..802d027a1e13 100644
--- a/arch/um/scripts/Makefile.unmap
+++ b/arch/um/scripts/Makefile.unmap
@@ -12,8 +12,8 @@ $(obj)/unmap.o: _c_flags = $(call unprofile,$(CFLAGS))
12 12
13quiet_cmd_wrapld = LD $@ 13quiet_cmd_wrapld = LD $@
14define cmd_wrapld 14define cmd_wrapld
15 $(LD) -r -o $(obj)/unmap_tmp.o $< $(shell $(CC) -print-file-name=libc.a); \ 15 $(LD) $(LDFLAGS) -r -o $(obj)/unmap_tmp.o $< $(shell $(CC) $(CFLAGS) -print-file-name=libc.a); \
16 $(OBJCOPY) $(obj)/unmap_tmp.o $@ -G switcheroo 16 $(OBJCOPY) $(UML_OBJCOPYFLAGS) $(obj)/unmap_tmp.o $@ -G switcheroo
17endef 17endef
18 18
19$(obj)/unmap_fin.o : $(obj)/unmap.o FORCE 19$(obj)/unmap_fin.o : $(obj)/unmap.o FORCE
diff --git a/arch/um/sys-i386/ldt.c b/arch/um/sys-i386/ldt.c
index dc755b0b9db8..bd3c34aa52e5 100644
--- a/arch/um/sys-i386/ldt.c
+++ b/arch/um/sys-i386/ldt.c
@@ -4,96 +4,106 @@
4 */ 4 */
5 5
6#include "linux/config.h" 6#include "linux/config.h"
7#include "linux/sched.h"
7#include "linux/slab.h" 8#include "linux/slab.h"
9#include "linux/types.h"
8#include "asm/uaccess.h" 10#include "asm/uaccess.h"
9#include "asm/ptrace.h" 11#include "asm/ptrace.h"
12#include "asm/smp.h"
13#include "asm/ldt.h"
10#include "choose-mode.h" 14#include "choose-mode.h"
11#include "kern.h" 15#include "kern.h"
16#include "mode_kern.h"
12 17
13#ifdef CONFIG_MODE_TT 18#ifdef CONFIG_MODE_TT
14extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
15 19
16/* XXX this needs copy_to_user and copy_from_user */ 20extern int modify_ldt(int func, void *ptr, unsigned long bytecount);
17 21
18int sys_modify_ldt_tt(int func, void __user *ptr, unsigned long bytecount) 22static int do_modify_ldt_tt(int func, void *ptr, unsigned long bytecount)
19{ 23{
20 if (!access_ok(VERIFY_READ, ptr, bytecount))
21 return -EFAULT;
22
23 return modify_ldt(func, ptr, bytecount); 24 return modify_ldt(func, ptr, bytecount);
24} 25}
26
25#endif 27#endif
26 28
27#ifdef CONFIG_MODE_SKAS 29#ifdef CONFIG_MODE_SKAS
28extern int userspace_pid[];
29 30
31#include "skas.h"
30#include "skas_ptrace.h" 32#include "skas_ptrace.h"
31 33
32int sys_modify_ldt_skas(int func, void __user *ptr, unsigned long bytecount) 34static int do_modify_ldt_skas(int func, void *ptr, unsigned long bytecount)
33{ 35{
34 struct ptrace_ldt ldt; 36 struct ptrace_ldt ldt;
35 void *buf; 37 u32 cpu;
36 int res, n; 38 int res;
37 39
38 buf = kmalloc(bytecount, GFP_KERNEL); 40 ldt = ((struct ptrace_ldt) { .func = func,
39 if(buf == NULL) 41 .ptr = ptr,
40 return(-ENOMEM); 42 .bytecount = bytecount });
41 43
42 res = 0; 44 cpu = get_cpu();
45 res = ptrace(PTRACE_LDT, userspace_pid[cpu], 0, (unsigned long) &ldt);
46 put_cpu();
47
48 return res;
49}
50#endif
51
52int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
53{
54 struct user_desc info;
55 int res = 0;
56 void *buf = NULL;
57 void *p = NULL; /* What we pass to host. */
43 58
44 switch(func){ 59 switch(func){
45 case 1: 60 case 1:
46 case 0x11: 61 case 0x11: /* write_ldt */
47 res = copy_from_user(buf, ptr, bytecount); 62 /* Do this check now to avoid overflows. */
48 break; 63 if (bytecount != sizeof(struct user_desc)) {
49 } 64 res = -EINVAL;
65 goto out;
66 }
67
68 if(copy_from_user(&info, ptr, sizeof(info))) {
69 res = -EFAULT;
70 goto out;
71 }
50 72
51 if(res != 0){ 73 p = &info;
52 res = -EFAULT; 74 break;
75 case 0:
76 case 2: /* read_ldt */
77
78 /* The use of info avoids kmalloc on the write case, not on the
79 * read one. */
80 buf = kmalloc(bytecount, GFP_KERNEL);
81 if (!buf) {
82 res = -ENOMEM;
83 goto out;
84 }
85 p = buf;
86 default:
87 res = -ENOSYS;
53 goto out; 88 goto out;
54 } 89 }
55 90
56 ldt = ((struct ptrace_ldt) { .func = func, 91 res = CHOOSE_MODE_PROC(do_modify_ldt_tt, do_modify_ldt_skas, func,
57 .ptr = buf, 92 p, bytecount);
58 .bytecount = bytecount });
59#warning Need to look up userspace_pid by cpu
60 res = ptrace(PTRACE_LDT, userspace_pid[0], 0, (unsigned long) &ldt);
61 if(res < 0) 93 if(res < 0)
62 goto out; 94 goto out;
63 95
64 switch(func){ 96 switch(func){
65 case 0: 97 case 0:
66 case 2: 98 case 2:
67 n = res; 99 /* Modify_ldt was for reading and returned the number of read
68 res = copy_to_user(ptr, buf, n); 100 * bytes.*/
69 if(res != 0) 101 if(copy_to_user(ptr, p, res))
70 res = -EFAULT; 102 res = -EFAULT;
71 else
72 res = n;
73 break; 103 break;
74 } 104 }
75 105
76 out: 106out:
77 kfree(buf); 107 kfree(buf);
78 return(res); 108 return res;
79}
80#endif
81
82int sys_modify_ldt(int func, void __user *ptr, unsigned long bytecount)
83{
84 return(CHOOSE_MODE_PROC(sys_modify_ldt_tt, sys_modify_ldt_skas, func,
85 ptr, bytecount));
86} 109}
87
88
89
90/*
91 * Overrides for Emacs so that we follow Linus's tabbing style.
92 * Emacs will notice this stuff at the end of the file and automatically
93 * adjust the settings for this buffer only. This must remain at the end
94 * of the file.
95 * ---------------------------------------------------------------------------
96 * Local variables:
97 * c-file-style: "linux"
98 * End:
99 */
diff --git a/arch/um/sys-i386/unmap.c b/arch/um/sys-i386/unmap.c
index 136875263d27..1b0ad0e4adcd 100644
--- a/arch/um/sys-i386/unmap.c
+++ b/arch/um/sys-i386/unmap.c
@@ -15,7 +15,7 @@ int switcheroo(int fd, int prot, void *from, void *to, int size)
15 if(munmap(to, size) < 0){ 15 if(munmap(to, size) < 0){
16 return(-1); 16 return(-1);
17 } 17 }
18 if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){ 18 if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
19 return(-1); 19 return(-1);
20 } 20 }
21 if(munmap(from, size) < 0){ 21 if(munmap(from, size) < 0){
diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c
index 73a7926f7370..8fdaed06c10d 100644
--- a/arch/um/sys-x86_64/signal.c
+++ b/arch/um/sys-x86_64/signal.c
@@ -168,7 +168,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
168 168
169 frame = (struct rt_sigframe __user *) 169 frame = (struct rt_sigframe __user *)
170 round_down(stack_top - sizeof(struct rt_sigframe), 16) - 8; 170 round_down(stack_top - sizeof(struct rt_sigframe), 16) - 8;
171 ((unsigned char *) frame) -= 128; 171 frame = (struct rt_sigframe *) ((unsigned long) frame - 128);
172 172
173 if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate))) 173 if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate)))
174 goto out; 174 goto out;
diff --git a/arch/um/sys-x86_64/unmap.c b/arch/um/sys-x86_64/unmap.c
index bc7094cce47e..f4a4bffd8a18 100644
--- a/arch/um/sys-x86_64/unmap.c
+++ b/arch/um/sys-x86_64/unmap.c
@@ -15,7 +15,7 @@ int switcheroo(int fd, int prot, void *from, void *to, int size)
15 if(munmap(to, size) < 0){ 15 if(munmap(to, size) < 0){
16 return(-1); 16 return(-1);
17 } 17 }
18 if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) != to){ 18 if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
19 return(-1); 19 return(-1);
20 } 20 }
21 if(munmap(from, size) < 0){ 21 if(munmap(from, size) < 0){
diff --git a/arch/v850/kernel/vmlinux.lds.S b/arch/v850/kernel/vmlinux.lds.S
index bbd3429bcffc..c366a8b326ee 100644
--- a/arch/v850/kernel/vmlinux.lds.S
+++ b/arch/v850/kernel/vmlinux.lds.S
@@ -1,8 +1,8 @@
1/* 1/*
2 * arch/v850/vmlinux.lds.S -- kernel linker script for v850 platforms 2 * arch/v850/vmlinux.lds.S -- kernel linker script for v850 platforms
3 * 3 *
4 * Copyright (C) 2002,03,04 NEC Electronics Corporation 4 * Copyright (C) 2002,03,04,05 NEC Electronics Corporation
5 * Copyright (C) 2002,03,04 Miles Bader <miles@gnu.org> 5 * Copyright (C) 2002,03,04,05 Miles Bader <miles@gnu.org>
6 * 6 *
7 * This file is subject to the terms and conditions of the GNU General 7 * This file is subject to the terms and conditions of the GNU General
8 * Public License. See the file COPYING in the main directory of this 8 * Public License. See the file COPYING in the main directory of this
@@ -61,6 +61,7 @@
61 *(__kcrctab_gpl) \ 61 *(__kcrctab_gpl) \
62 ___stop___kcrctab_gpl = .; \ 62 ___stop___kcrctab_gpl = .; \
63 /* Built-in module parameters */ \ 63 /* Built-in module parameters */ \
64 . = ALIGN (4) ; \
64 ___start___param = .; \ 65 ___start___param = .; \
65 *(__param) \ 66 *(__param) \
66 ___stop___param = .; 67 ___stop___param = .;
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c
index f463d6baa685..5b1d3680c8ab 100644
--- a/drivers/char/rocket.c
+++ b/drivers/char/rocket.c
@@ -355,7 +355,7 @@ static void rp_do_receive(struct r_port *info,
355 ToRecv = space; 355 ToRecv = space;
356 356
357 if (ToRecv <= 0) 357 if (ToRecv <= 0)
358 return; 358 goto done;
359 359
360 /* 360 /*
361 * if status indicates there are errored characters in the 361 * if status indicates there are errored characters in the
@@ -437,6 +437,7 @@ static void rp_do_receive(struct r_port *info,
437 } 437 }
438 /* Push the data up to the tty layer */ 438 /* Push the data up to the tty layer */
439 ld->receive_buf(tty, tty->flip.char_buf, tty->flip.flag_buf, count); 439 ld->receive_buf(tty, tty->flip.char_buf, tty->flip.flag_buf, count);
440done:
440 tty_ldisc_deref(ld); 441 tty_ldisc_deref(ld);
441} 442}
442 443
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index d7aa7a29f67e..30d96739fb23 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -2796,7 +2796,7 @@ void do_blank_screen(int entering_gfx)
2796 return; 2796 return;
2797 2797
2798 if (vesa_off_interval) { 2798 if (vesa_off_interval) {
2799 blank_state = blank_vesa_wait, 2799 blank_state = blank_vesa_wait;
2800 mod_timer(&console_timer, jiffies + vesa_off_interval); 2800 mod_timer(&console_timer, jiffies + vesa_off_interval);
2801 } 2801 }
2802 2802
diff --git a/drivers/firmware/pcdp.h b/drivers/firmware/pcdp.h
index e72cc47de33b..ce910d68bd19 100644
--- a/drivers/firmware/pcdp.h
+++ b/drivers/firmware/pcdp.h
@@ -52,6 +52,8 @@ struct pcdp_uart {
52 u32 clock_rate; 52 u32 clock_rate;
53 u8 pci_prog_intfc; 53 u8 pci_prog_intfc;
54 u8 flags; 54 u8 flags;
55 u16 conout_index;
56 u32 reserved;
55} __attribute__((packed)); 57} __attribute__((packed));
56 58
57#define PCDP_IF_PCI 1 59#define PCDP_IF_PCI 1
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index a485f47bb21e..b12a970cc9a3 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -1084,7 +1084,8 @@ static int ohci_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
1084 1084
1085 initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1); 1085 initialize_dma_rcv_ctx(&ohci->ir_legacy_context, 1);
1086 1086
1087 PRINT(KERN_ERR, "IR legacy activated"); 1087 if (printk_ratelimit())
1088 PRINT(KERN_ERR, "IR legacy activated");
1088 } 1089 }
1089 1090
1090 spin_lock_irqsave(&ohci->IR_channel_lock, flags); 1091 spin_lock_irqsave(&ohci->IR_channel_lock, flags);
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c
index 033456bb9fe0..e996183c5b06 100644
--- a/drivers/input/joystick/amijoy.c
+++ b/drivers/input/joystick/amijoy.c
@@ -105,7 +105,7 @@ out:
105 105
106static void amijoy_close(struct input_dev *dev) 106static void amijoy_close(struct input_dev *dev)
107{ 107{
108 down(&amijoysem); 108 down(&amijoy_sem);
109 if (!--amijoy_used) 109 if (!--amijoy_used)
110 free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt); 110 free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt);
111 up(&amijoy_sem); 111 up(&amijoy_sem);
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 95980ad6b27b..0c2ed99a3832 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1345,7 +1345,8 @@ void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long secto
1345 } 1345 }
1346} 1346}
1347 1347
1348int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks) 1348int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks,
1349 int degraded)
1349{ 1350{
1350 bitmap_counter_t *bmc; 1351 bitmap_counter_t *bmc;
1351 int rv; 1352 int rv;
@@ -1362,8 +1363,10 @@ int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks)
1362 rv = 1; 1363 rv = 1;
1363 else if (NEEDED(*bmc)) { 1364 else if (NEEDED(*bmc)) {
1364 rv = 1; 1365 rv = 1;
1365 *bmc |= RESYNC_MASK; 1366 if (!degraded) { /* don't set/clear bits if degraded */
1366 *bmc &= ~NEEDED_MASK; 1367 *bmc |= RESYNC_MASK;
1368 *bmc &= ~NEEDED_MASK;
1369 }
1367 } 1370 }
1368 } 1371 }
1369 spin_unlock_irq(&bitmap->lock); 1372 spin_unlock_irq(&bitmap->lock);
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index e11dd14d0b43..2120710172c5 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -314,16 +314,16 @@ static int raid0_run (mddev_t *mddev)
314 sector_t space = conf->hash_spacing; 314 sector_t space = conf->hash_spacing;
315 int round; 315 int round;
316 conf->preshift = 0; 316 conf->preshift = 0;
317 if (sizeof(sector_t) > sizeof(unsigned long)) { 317 if (sizeof(sector_t) > sizeof(u32)) {
318 /*shift down space and s so that sector_div will work */ 318 /*shift down space and s so that sector_div will work */
319 while (space > (sector_t) (~(unsigned long)0)) { 319 while (space > (sector_t) (~(u32)0)) {
320 s >>= 1; 320 s >>= 1;
321 space >>= 1; 321 space >>= 1;
322 s += 1; /* force round-up */ 322 s += 1; /* force round-up */
323 conf->preshift++; 323 conf->preshift++;
324 } 324 }
325 } 325 }
326 round = sector_div(s, (unsigned long)space) ? 1 : 0; 326 round = sector_div(s, (u32)space) ? 1 : 0;
327 nb_zone = s + round; 327 nb_zone = s + round;
328 } 328 }
329 printk("raid0 : nb_zone is %d.\n", nb_zone); 329 printk("raid0 : nb_zone is %d.\n", nb_zone);
@@ -443,7 +443,7 @@ static int raid0_make_request (request_queue_t *q, struct bio *bio)
443 volatile 443 volatile
444#endif 444#endif
445 sector_t x = block >> conf->preshift; 445 sector_t x = block >> conf->preshift;
446 sector_div(x, (unsigned long)conf->hash_spacing); 446 sector_div(x, (u32)conf->hash_spacing);
447 zone = conf->hash_table[x]; 447 zone = conf->hash_table[x];
448 } 448 }
449 449
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ff1dbec864af..5f253ee536bb 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1126,21 +1126,19 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1126 * only be one in raid1 resync. 1126 * only be one in raid1 resync.
1127 * We can find the current addess in mddev->curr_resync 1127 * We can find the current addess in mddev->curr_resync
1128 */ 1128 */
1129 if (!conf->fullsync) { 1129 if (mddev->curr_resync < max_sector) /* aborted */
1130 if (mddev->curr_resync < max_sector) 1130 bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
1131 bitmap_end_sync(mddev->bitmap,
1132 mddev->curr_resync,
1133 &sync_blocks, 1); 1131 &sync_blocks, 1);
1134 bitmap_close_sync(mddev->bitmap); 1132 else /* completed sync */
1135 }
1136 if (mddev->curr_resync >= max_sector)
1137 conf->fullsync = 0; 1133 conf->fullsync = 0;
1134
1135 bitmap_close_sync(mddev->bitmap);
1138 close_sync(conf); 1136 close_sync(conf);
1139 return 0; 1137 return 0;
1140 } 1138 }
1141 1139
1142 if (!conf->fullsync && 1140 if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, mddev->degraded) &&
1143 !bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks)) { 1141 !conf->fullsync) {
1144 /* We can skip this block, and probably several more */ 1142 /* We can skip this block, and probably several more */
1145 *skipped = 1; 1143 *skipped = 1;
1146 return sync_blocks; 1144 return sync_blocks;
@@ -1243,15 +1241,15 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1243 len = (max_sector - sector_nr) << 9; 1241 len = (max_sector - sector_nr) << 9;
1244 if (len == 0) 1242 if (len == 0)
1245 break; 1243 break;
1246 if (!conf->fullsync) { 1244 if (sync_blocks == 0) {
1247 if (sync_blocks == 0) { 1245 if (!bitmap_start_sync(mddev->bitmap, sector_nr,
1248 if (!bitmap_start_sync(mddev->bitmap, 1246 &sync_blocks, mddev->degraded) &&
1249 sector_nr, &sync_blocks)) 1247 !conf->fullsync)
1250 break; 1248 break;
1251 if (sync_blocks < (PAGE_SIZE>>9)) 1249 if (sync_blocks < (PAGE_SIZE>>9))
1252 BUG(); 1250 BUG();
1253 if (len > (sync_blocks<<9)) len = sync_blocks<<9; 1251 if (len > (sync_blocks<<9))
1254 } 1252 len = sync_blocks<<9;
1255 } 1253 }
1256 1254
1257 for (i=0 ; i < conf->raid_disks; i++) { 1255 for (i=0 ; i < conf->raid_disks; i++) {
@@ -1264,7 +1262,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1264 while (i > 0) { 1262 while (i > 0) {
1265 i--; 1263 i--;
1266 bio = r1_bio->bios[i]; 1264 bio = r1_bio->bios[i];
1267 if (bio->bi_end_io==NULL) continue; 1265 if (bio->bi_end_io==NULL)
1266 continue;
1268 /* remove last page from this bio */ 1267 /* remove last page from this bio */
1269 bio->bi_vcnt--; 1268 bio->bi_vcnt--;
1270 bio->bi_size -= len; 1269 bio->bi_size -= len;
diff --git a/drivers/media/dvb/frontends/lgdt3302.c b/drivers/media/dvb/frontends/lgdt3302.c
index 2eea03d218cd..c85a2a99df42 100644
--- a/drivers/media/dvb/frontends/lgdt3302.c
+++ b/drivers/media/dvb/frontends/lgdt3302.c
@@ -217,13 +217,11 @@ static int lgdt3302_set_parameters(struct dvb_frontend* fe,
217 static u8 demux_ctrl_cfg[] = { DEMUX_CONTROL, 0xfb }; 217 static u8 demux_ctrl_cfg[] = { DEMUX_CONTROL, 0xfb };
218 static u8 agc_rf_cfg[] = { AGC_RF_BANDWIDTH0, 0x40, 0x93, 0x00 }; 218 static u8 agc_rf_cfg[] = { AGC_RF_BANDWIDTH0, 0x40, 0x93, 0x00 };
219 static u8 agc_ctrl_cfg[] = { AGC_FUNC_CTRL2, 0xc6, 0x40 }; 219 static u8 agc_ctrl_cfg[] = { AGC_FUNC_CTRL2, 0xc6, 0x40 };
220 static u8 agc_delay_cfg[] = { AGC_DELAY0, 0x00, 0x00, 0x00 }; 220 static u8 agc_delay_cfg[] = { AGC_DELAY0, 0x07, 0x00, 0xfe };
221 static u8 agc_loop_cfg[] = { AGC_LOOP_BANDWIDTH0, 0x08, 0x9a }; 221 static u8 agc_loop_cfg[] = { AGC_LOOP_BANDWIDTH0, 0x08, 0x9a };
222 222
223 /* Change only if we are actually changing the modulation */ 223 /* Change only if we are actually changing the modulation */
224 if (state->current_modulation != param->u.vsb.modulation) { 224 if (state->current_modulation != param->u.vsb.modulation) {
225 int value;
226
227 switch(param->u.vsb.modulation) { 225 switch(param->u.vsb.modulation) {
228 case VSB_8: 226 case VSB_8:
229 dprintk("%s: VSB_8 MODE\n", __FUNCTION__); 227 dprintk("%s: VSB_8 MODE\n", __FUNCTION__);
@@ -276,16 +274,8 @@ static int lgdt3302_set_parameters(struct dvb_frontend* fe,
276 recovery center frequency register */ 274 recovery center frequency register */
277 i2c_writebytes(state, state->config->demod_address, 275 i2c_writebytes(state, state->config->demod_address,
278 vsb_freq_cfg, sizeof(vsb_freq_cfg)); 276 vsb_freq_cfg, sizeof(vsb_freq_cfg));
279 /* Set the value of 'INLVTHD' register 0x2a/0x2c 277
280 to value from 'IFACC' register 0x39/0x3b -1 */ 278 /* Set the value of 'INLVTHD' register 0x2a/0x2c to 0x7fe */
281 i2c_selectreadbytes(state, AGC_RFIF_ACC0,
282 &agc_delay_cfg[1], 3);
283 value = ((agc_delay_cfg[1] & 0x0f) << 8) | agc_delay_cfg[3];
284 value = value -1;
285 dprintk("%s IFACC -1 = 0x%03x\n", __FUNCTION__, value);
286 agc_delay_cfg[1] = (value >> 8) & 0x0f;
287 agc_delay_cfg[2] = 0x00;
288 agc_delay_cfg[3] = value & 0xff;
289 i2c_writebytes(state, state->config->demod_address, 279 i2c_writebytes(state, state->config->demod_address,
290 agc_delay_cfg, sizeof(agc_delay_cfg)); 280 agc_delay_cfg, sizeof(agc_delay_cfg));
291 281
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index b0b47c3cde3c..3d0c784b376f 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-cards.c,v 1.85 2005/07/04 19:35:05 mkrufky Exp $ 2 * $Id: cx88-cards.c,v 1.86 2005/07/14 03:06:43 mchehab Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * card-specific stuff. 5 * card-specific stuff.
@@ -682,9 +682,9 @@ struct cx88_board cx88_boards[] = {
682 .name = "PixelView PlayTV Ultra Pro (Stereo)", 682 .name = "PixelView PlayTV Ultra Pro (Stereo)",
683 /* May be also TUNER_YMEC_TVF_5533MF for NTSC/M or PAL/M */ 683 /* May be also TUNER_YMEC_TVF_5533MF for NTSC/M or PAL/M */
684 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3, 684 .tuner_type = TUNER_PHILIPS_FM1216ME_MK3,
685 .radio_type = TUNER_TEA5767, 685 .radio_type = UNSET,
686 .tuner_addr = 0xc2>>1, 686 .tuner_addr = ADDR_UNSET,
687 .radio_addr = 0xc0>>1, 687 .radio_addr = ADDR_UNSET,
688 .input = {{ 688 .input = {{
689 .type = CX88_VMUX_TELEVISION, 689 .type = CX88_VMUX_TELEVISION,
690 .vmux = 0, 690 .vmux = 0,
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 8db68f2d1351..6ad1458ab652 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-dvb.c,v 1.41 2005/07/04 19:35:05 mkrufky Exp $ 2 * $Id: cx88-dvb.c,v 1.42 2005/07/12 15:44:55 mkrufky Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * MPEG Transport Stream (DVB) routines 5 * MPEG Transport Stream (DVB) routines
@@ -180,12 +180,14 @@ static struct mt352_config dntv_live_dvbt_config = {
180#if CONFIG_DVB_CX22702 180#if CONFIG_DVB_CX22702
181static struct cx22702_config connexant_refboard_config = { 181static struct cx22702_config connexant_refboard_config = {
182 .demod_address = 0x43, 182 .demod_address = 0x43,
183 .output_mode = CX22702_SERIAL_OUTPUT,
183 .pll_address = 0x60, 184 .pll_address = 0x60,
184 .pll_desc = &dvb_pll_thomson_dtt7579, 185 .pll_desc = &dvb_pll_thomson_dtt7579,
185}; 186};
186 187
187static struct cx22702_config hauppauge_novat_config = { 188static struct cx22702_config hauppauge_novat_config = {
188 .demod_address = 0x43, 189 .demod_address = 0x43,
190 .output_mode = CX22702_SERIAL_OUTPUT,
189 .pll_address = 0x61, 191 .pll_address = 0x61,
190 .pll_desc = &dvb_pll_thomson_dtt759x, 192 .pll_desc = &dvb_pll_thomson_dtt759x,
191}; 193};
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index c44a079d08c0..5588a3aeecb4 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88-video.c,v 1.79 2005/07/07 14:17:47 mchehab Exp $ 2 * $Id: cx88-video.c,v 1.80 2005/07/13 08:49:08 mchehab Exp $
3 * 3 *
4 * device driver for Conexant 2388x based TV cards 4 * device driver for Conexant 2388x based TV cards
5 * video4linux video interface 5 * video4linux video interface
@@ -1346,6 +1346,11 @@ static int video_do_ioctl(struct inode *inode, struct file *file,
1346 dev->freq = f->frequency; 1346 dev->freq = f->frequency;
1347 cx88_newstation(core); 1347 cx88_newstation(core);
1348 cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f); 1348 cx88_call_i2c_clients(dev->core,VIDIOC_S_FREQUENCY,f);
1349
1350 /* When changing channels it is required to reset TVAUDIO */
1351 msleep (10);
1352 cx88_set_tvaudio(core);
1353
1349 up(&dev->lock); 1354 up(&dev->lock);
1350 return 0; 1355 return 0;
1351 } 1356 }
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 307beae04f2a..b008f7db6dfd 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cx88.h,v 1.68 2005/07/07 14:17:47 mchehab Exp $ 2 * $Id: cx88.h,v 1.69 2005/07/13 17:25:25 mchehab Exp $
3 * 3 *
4 * v4l2 device driver for cx2388x based TV cards 4 * v4l2 device driver for cx2388x based TV cards
5 * 5 *
@@ -35,8 +35,8 @@
35#include "btcx-risc.h" 35#include "btcx-risc.h"
36#include "cx88-reg.h" 36#include "cx88-reg.h"
37 37
38#include <linux/version.h> 38#include <linux/utsname.h>
39#define CX88_VERSION_CODE KERNEL_VERSION(0,0,4) 39#define CX88_VERSION_CODE KERNEL_VERSION(0,0,5)
40 40
41#ifndef TRUE 41#ifndef TRUE
42# define TRUE (1==1) 42# define TRUE (1==1)
diff --git a/drivers/media/video/tea5767.c b/drivers/media/video/tea5767.c
index b53c748caf2a..4d27ac1b7fb8 100644
--- a/drivers/media/video/tea5767.c
+++ b/drivers/media/video/tea5767.c
@@ -2,7 +2,7 @@
2 * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview 2 * For Philips TEA5767 FM Chip used on some TV Cards like Prolink Pixelview
3 * I2C address is allways 0xC0. 3 * I2C address is allways 0xC0.
4 * 4 *
5 * $Id: tea5767.c,v 1.18 2005/07/07 03:02:55 mchehab Exp $ 5 * $Id: tea5767.c,v 1.21 2005/07/14 03:06:43 mchehab Exp $
6 * 6 *
7 * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br) 7 * Copyright (c) 2005 Mauro Carvalho Chehab (mchehab@brturbo.com.br)
8 * This code is placed under the terms of the GNU General Public License 8 * This code is placed under the terms of the GNU General Public License
@@ -153,17 +153,17 @@ static void tea5767_status_dump(unsigned char *buffer)
153 153
154 switch (TEA5767_HIGH_LO_32768) { 154 switch (TEA5767_HIGH_LO_32768) {
155 case TEA5767_HIGH_LO_13MHz: 155 case TEA5767_HIGH_LO_13MHz:
156 frq = 1000 * (div * 50 - 700 - 225) / 4; /* Freq in KHz */ 156 frq = (div * 50000 - 700000 - 225000) / 4; /* Freq in KHz */
157 break; 157 break;
158 case TEA5767_LOW_LO_13MHz: 158 case TEA5767_LOW_LO_13MHz:
159 frq = 1000 * (div * 50 + 700 + 225) / 4; /* Freq in KHz */ 159 frq = (div * 50000 + 700000 + 225000) / 4; /* Freq in KHz */
160 break; 160 break;
161 case TEA5767_LOW_LO_32768: 161 case TEA5767_LOW_LO_32768:
162 frq = 1000 * (div * 32768 / 1000 + 700 + 225) / 4; /* Freq in KHz */ 162 frq = (div * 32768 + 700000 + 225000) / 4; /* Freq in KHz */
163 break; 163 break;
164 case TEA5767_HIGH_LO_32768: 164 case TEA5767_HIGH_LO_32768:
165 default: 165 default:
166 frq = 1000 * (div * 32768 / 1000 - 700 - 225) / 4; /* Freq in KHz */ 166 frq = (div * 32768 - 700000 - 225000) / 4; /* Freq in KHz */
167 break; 167 break;
168 } 168 }
169 buffer[0] = (div >> 8) & 0x3f; 169 buffer[0] = (div >> 8) & 0x3f;
@@ -196,7 +196,7 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
196 unsigned div; 196 unsigned div;
197 int rc; 197 int rc;
198 198
199 tuner_dbg (PREFIX "radio freq counter %d\n", frq); 199 tuner_dbg (PREFIX "radio freq = %d.%03d MHz\n", frq/16000,(frq/16)%1000);
200 200
201 /* Rounds freq to next decimal value - for 62.5 KHz step */ 201 /* Rounds freq to next decimal value - for 62.5 KHz step */
202 /* frq = 20*(frq/16)+radio_frq[frq%16]; */ 202 /* frq = 20*(frq/16)+radio_frq[frq%16]; */
@@ -224,19 +224,19 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
224 tuner_dbg ("TEA5767 radio HIGH LO inject xtal @ 13 MHz\n"); 224 tuner_dbg ("TEA5767 radio HIGH LO inject xtal @ 13 MHz\n");
225 buffer[2] |= TEA5767_HIGH_LO_INJECT; 225 buffer[2] |= TEA5767_HIGH_LO_INJECT;
226 buffer[4] |= TEA5767_PLLREF_ENABLE; 226 buffer[4] |= TEA5767_PLLREF_ENABLE;
227 div = (frq * 4 / 16 + 700 + 225 + 25) / 50; 227 div = (frq * 4000 / 16 + 700000 + 225000 + 25000) / 50000;
228 break; 228 break;
229 case TEA5767_LOW_LO_13MHz: 229 case TEA5767_LOW_LO_13MHz:
230 tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 13 MHz\n"); 230 tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 13 MHz\n");
231 231
232 buffer[4] |= TEA5767_PLLREF_ENABLE; 232 buffer[4] |= TEA5767_PLLREF_ENABLE;
233 div = (frq * 4 / 16 - 700 - 225 + 25) / 50; 233 div = (frq * 4000 / 16 - 700000 - 225000 + 25000) / 50000;
234 break; 234 break;
235 case TEA5767_LOW_LO_32768: 235 case TEA5767_LOW_LO_32768:
236 tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 32,768 MHz\n"); 236 tuner_dbg ("TEA5767 radio LOW LO inject xtal @ 32,768 MHz\n");
237 buffer[3] |= TEA5767_XTAL_32768; 237 buffer[3] |= TEA5767_XTAL_32768;
238 /* const 700=4000*175 Khz - to adjust freq to right value */ 238 /* const 700=4000*175 Khz - to adjust freq to right value */
239 div = (1000 * (frq * 4 / 16 - 700 - 225) + 16384) >> 15; 239 div = ((frq * 4000 / 16 - 700000 - 225000) + 16384) >> 15;
240 break; 240 break;
241 case TEA5767_HIGH_LO_32768: 241 case TEA5767_HIGH_LO_32768:
242 default: 242 default:
@@ -244,17 +244,21 @@ static void set_radio_freq(struct i2c_client *c, unsigned int frq)
244 244
245 buffer[2] |= TEA5767_HIGH_LO_INJECT; 245 buffer[2] |= TEA5767_HIGH_LO_INJECT;
246 buffer[3] |= TEA5767_XTAL_32768; 246 buffer[3] |= TEA5767_XTAL_32768;
247 div = (1000 * (frq * 4 / 16 + 700 + 225) + 16384) >> 15; 247 div = ((frq * (4000 / 16) + 700000 + 225000) + 16384) >> 15;
248 break; 248 break;
249 } 249 }
250 buffer[0] = (div >> 8) & 0x3f; 250 buffer[0] = (div >> 8) & 0x3f;
251 buffer[1] = div & 0xff; 251 buffer[1] = div & 0xff;
252 252
253 if (tuner_debug)
254 tea5767_status_dump(buffer);
255
256 if (5 != (rc = i2c_master_send(c, buffer, 5))) 253 if (5 != (rc = i2c_master_send(c, buffer, 5)))
257 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc); 254 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
255
256 if (tuner_debug) {
257 if (5 != (rc = i2c_master_recv(c, buffer, 5)))
258 tuner_warn("i2c i/o error: rc == %d (should be 5)\n", rc);
259 else
260 tea5767_status_dump(buffer);
261 }
258} 262}
259 263
260static int tea5767_signal(struct i2c_client *c) 264static int tea5767_signal(struct i2c_client *c)
@@ -294,7 +298,7 @@ int tea5767_autodetection(struct i2c_client *c)
294 struct tuner *t = i2c_get_clientdata(c); 298 struct tuner *t = i2c_get_clientdata(c);
295 299
296 if (5 != (rc = i2c_master_recv(c, buffer, 5))) { 300 if (5 != (rc = i2c_master_recv(c, buffer, 5))) {
297 tuner_warn("it is not a TEA5767. Received %i chars.\n", rc); 301 tuner_warn("It is not a TEA5767. Received %i bytes.\n", rc);
298 return EINVAL; 302 return EINVAL;
299 } 303 }
300 304
@@ -310,11 +314,11 @@ int tea5767_autodetection(struct i2c_client *c)
310 * bit 0 : internally set to 0 314 * bit 0 : internally set to 0
311 * Byte 5: bit 7:0 : == 0 315 * Byte 5: bit 7:0 : == 0
312 */ 316 */
313
314 if (!((buffer[3] & 0x0f) == 0x00) && (buffer[4] == 0x00)) { 317 if (!((buffer[3] & 0x0f) == 0x00) && (buffer[4] == 0x00)) {
315 tuner_warn("Chip ID is not zero. It is not a TEA5767\n"); 318 tuner_warn("Chip ID is not zero. It is not a TEA5767\n");
316 return EINVAL; 319 return EINVAL;
317 } 320 }
321
318 tuner_warn("TEA5767 detected.\n"); 322 tuner_warn("TEA5767 detected.\n");
319 return 0; 323 return 0;
320} 324}
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index de190630babb..b25a9c08ac02 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: tuner-core.c,v 1.55 2005/07/08 13:20:33 mchehab Exp $ 2 * $Id: tuner-core.c,v 1.58 2005/07/14 03:06:43 mchehab Exp $
3 * 3 *
4 * i2c tv tuner chip device driver 4 * i2c tv tuner chip device driver
5 * core core, i.e. kernel interfaces, registering and so on 5 * core core, i.e. kernel interfaces, registering and so on
@@ -39,6 +39,9 @@ I2C_CLIENT_INSMOD;
39static unsigned int addr = 0; 39static unsigned int addr = 0;
40module_param(addr, int, 0444); 40module_param(addr, int, 0444);
41 41
42static unsigned int no_autodetect = 0;
43module_param(no_autodetect, int, 0444);
44
42/* insmod options used at runtime => read/write */ 45/* insmod options used at runtime => read/write */
43unsigned int tuner_debug = 0; 46unsigned int tuner_debug = 0;
44module_param(tuner_debug, int, 0644); 47module_param(tuner_debug, int, 0644);
@@ -318,17 +321,19 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
318 tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name); 321 tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
319 322
320 /* TEA5767 autodetection code - only for addr = 0xc0 */ 323 /* TEA5767 autodetection code - only for addr = 0xc0 */
321 if (addr == 0x60) { 324 if (!no_autodetect) {
322 if (tea5767_autodetection(&t->i2c) != EINVAL) { 325 if (addr == 0x60) {
323 t->type = TUNER_TEA5767; 326 if (tea5767_autodetection(&t->i2c) != EINVAL) {
324 t->mode_mask = T_RADIO; 327 t->type = TUNER_TEA5767;
325 t->mode = T_STANDBY; 328 t->mode_mask = T_RADIO;
326 t->freq = 87.5 * 16; /* Sets freq to FM range */ 329 t->mode = T_STANDBY;
327 default_mode_mask &= ~T_RADIO; 330 t->freq = 87.5 * 16; /* Sets freq to FM range */
328 331 default_mode_mask &= ~T_RADIO;
329 i2c_attach_client (&t->i2c); 332
330 set_type(&t->i2c,t->type, t->mode_mask); 333 i2c_attach_client (&t->i2c);
331 return 0; 334 set_type(&t->i2c,t->type, t->mode_mask);
335 return 0;
336 }
332 } 337 }
333 } 338 }
334 339
@@ -631,7 +636,9 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
631 break; 636 break;
632 } 637 }
633 default: 638 default:
634 tuner_dbg("Unimplemented IOCTL 0x%08x called to tuner.\n", cmd); 639 tuner_dbg("Unimplemented IOCTL 0x%08x(dir=%d,tp=0x%02x,nr=%d,sz=%d)\n",
640 cmd, _IOC_DIR(cmd), _IOC_TYPE(cmd),
641 _IOC_NR(cmd), _IOC_SIZE(cmd));
635 break; 642 break;
636 } 643 }
637 644
diff --git a/drivers/mtd/chips/Kconfig b/drivers/mtd/chips/Kconfig
index b5dc59389bb3..df95d2158b16 100644
--- a/drivers/mtd/chips/Kconfig
+++ b/drivers/mtd/chips/Kconfig
@@ -300,7 +300,7 @@ config MTD_JEDEC
300 300
301config MTD_XIP 301config MTD_XIP
302 bool "XIP aware MTD support" 302 bool "XIP aware MTD support"
303 depends on !SMP && (MTD_CFI_INTELEXT || MTD_CFI_AMDSTD) && EXPERIMENTAL 303 depends on !SMP && (MTD_CFI_INTELEXT || MTD_CFI_AMDSTD) && EXPERIMENTAL && ARM
304 default y if XIP_KERNEL 304 default y if XIP_KERNEL
305 help 305 help
306 This allows MTD support to work with flash memory which is also 306 This allows MTD support to work with flash memory which is also
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index 8c24e18db3b4..c894f8801578 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * $Id: cfi_cmdset_0020.c,v 1.17 2004/11/20 12:49:04 dwmw2 Exp $ 7 * $Id: cfi_cmdset_0020.c,v 1.19 2005/07/13 15:52:45 dwmw2 Exp $
8 * 8 *
9 * 10/10/2000 Nicolas Pitre <nico@cam.org> 9 * 10/10/2000 Nicolas Pitre <nico@cam.org>
10 * - completely revamped method functions so they are aware and 10 * - completely revamped method functions so they are aware and
@@ -16,6 +16,8 @@
16 * - modified Intel Command Set 0x0001 to support ST Advanced Architecture 16 * - modified Intel Command Set 0x0001 to support ST Advanced Architecture
17 * (command set 0x0020) 17 * (command set 0x0020)
18 * - added a writev function 18 * - added a writev function
19 * 07/13/2005 Joern Engel <joern@wh.fh-wedel.de>
20 * - Plugged memory leak in cfi_staa_writev().
19 */ 21 */
20 22
21#include <linux/version.h> 23#include <linux/version.h>
@@ -719,6 +721,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
719write_error: 721write_error:
720 if (retlen) 722 if (retlen)
721 *retlen = totlen; 723 *retlen = totlen;
724 kfree(buffer);
722 return ret; 725 return ret;
723} 726}
724 727
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index b722175f108f..e9256408757f 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -12,14 +12,25 @@
12 History: 12 History:
13 13
14 2005-05-19 v0.1 Initial version, based on incomplete docs 14 2005-05-19 v0.1 Initial version, based on incomplete docs
15 and analysis of misbehavior of the standard driver 15 and analysis of misbehavior with the standard driver
16 2005-05-20 v0.2 Extended the input buffer to avoid losing 16 2005-05-20 v0.2 Extended the input buffer to avoid losing
17 random 64-byte chunks of data 17 random 64-byte chunks of data
18 2005-05-21 v0.3 implemented chars_in_buffer() 18 2005-05-21 v0.3 implemented chars_in_buffer()
19 turned on low_latency 19 turned on low_latency
20 simplified the code somewhat 20 simplified the code somewhat
21 2005-05-24 v0.4 option_write() sometimes deadlocked under heavy load
22 removed some dead code
23 added sponsor notice
24 coding style clean-up
25 2005-06-20 v0.4.1 add missing braces :-/
26 killed end-of-line whitespace
27 2005-07-15 v0.4.2 rename WLAN product to FUSION, add FUSION2
28
29 Work sponsored by: Sigos GmbH, Germany <info@sigos.de>
30
21*/ 31*/
22#define DRIVER_VERSION "v0.3" 32
33#define DRIVER_VERSION "v0.4"
23#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>" 34#define DRIVER_AUTHOR "Matthias Urlichs <smurf@smurf.noris.de>"
24#define DRIVER_DESC "Option Card (PC-Card to) USB to Serial Driver" 35#define DRIVER_DESC "Option Card (PC-Card to) USB to Serial Driver"
25 36
@@ -44,7 +55,6 @@ static int option_write_room (struct usb_serial_port *port);
44 55
45static void option_instat_callback(struct urb *urb, struct pt_regs *regs); 56static void option_instat_callback(struct urb *urb, struct pt_regs *regs);
46 57
47
48static int option_write (struct usb_serial_port *port, 58static int option_write (struct usb_serial_port *port,
49 const unsigned char *buf, int count); 59 const unsigned char *buf, int count);
50 60
@@ -60,14 +70,17 @@ static int option_tiocmset (struct usb_serial_port *port, struct file *file,
60static int option_send_setup (struct usb_serial_port *port); 70static int option_send_setup (struct usb_serial_port *port);
61 71
62/* Vendor and product IDs */ 72/* Vendor and product IDs */
63#define OPTION_VENDOR_ID 0x0AF0 73#define OPTION_VENDOR_ID 0x0AF0
74
75#define OPTION_PRODUCT_OLD 0x5000
76#define OPTION_PRODUCT_FUSION 0x6000
77#define OPTION_PRODUCT_FUSION2 0x6300
64 78
65#define OPTION_PRODUCT_OLD 0x5000
66#define OPTION_PRODUCT_WLAN 0x6000
67 79
68static struct usb_device_id option_ids[] = { 80static struct usb_device_id option_ids[] = {
69 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) }, 81 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_OLD) },
70 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_WLAN) }, 82 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION) },
83 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_FUSION2) },
71 { } /* Terminating entry */ 84 { } /* Terminating entry */
72}; 85};
73 86
@@ -85,58 +98,62 @@ static struct usb_driver option_driver = {
85 * recognizes separately, thus num_port=1. 98 * recognizes separately, thus num_port=1.
86 */ 99 */
87static struct usb_serial_device_type option_3port_device = { 100static struct usb_serial_device_type option_3port_device = {
88 .owner = THIS_MODULE, 101 .owner = THIS_MODULE,
89 .name = "Option 3-port card", 102 .name = "Option 3G data card",
90 .short_name = "option", 103 .short_name = "option",
91 .id_table = option_ids, 104 .id_table = option_ids,
92 .num_interrupt_in = NUM_DONT_CARE, 105 .num_interrupt_in = NUM_DONT_CARE,
93 .num_bulk_in = NUM_DONT_CARE, 106 .num_bulk_in = NUM_DONT_CARE,
94 .num_bulk_out = NUM_DONT_CARE, 107 .num_bulk_out = NUM_DONT_CARE,
95 .num_ports = 1, /* 3 */ 108 .num_ports = 1, /* 3, but the card reports its ports separately */
96 .open = option_open, 109 .open = option_open,
97 .close = option_close, 110 .close = option_close,
98 .write = option_write, 111 .write = option_write,
99 .write_room = option_write_room, 112 .write_room = option_write_room,
100 .chars_in_buffer = option_chars_in_buffer, 113 .chars_in_buffer = option_chars_in_buffer,
101 .throttle = option_rx_throttle, 114 .throttle = option_rx_throttle,
102 .unthrottle = option_rx_unthrottle, 115 .unthrottle = option_rx_unthrottle,
103 .ioctl = option_ioctl, 116 .ioctl = option_ioctl,
104 .set_termios = option_set_termios, 117 .set_termios = option_set_termios,
105 .break_ctl = option_break_ctl, 118 .break_ctl = option_break_ctl,
106 .tiocmget = option_tiocmget, 119 .tiocmget = option_tiocmget,
107 .tiocmset = option_tiocmset, 120 .tiocmset = option_tiocmset,
108 .attach = option_startup, 121 .attach = option_startup,
109 .shutdown = option_shutdown, 122 .shutdown = option_shutdown,
110 .read_int_callback = option_instat_callback, 123 .read_int_callback = option_instat_callback,
111}; 124};
112 125
126#ifdef CONFIG_USB_DEBUG
113static int debug; 127static int debug;
128#else
129#define debug 0
130#endif
131
114 132
115/* per port private data */ 133/* per port private data */
116 134
117#define N_IN_URB 4 135#define N_IN_URB 4
118#define N_OUT_URB 1 136#define N_OUT_URB 1
119#define IN_BUFLEN 1024 137#define IN_BUFLEN 1024
120#define OUT_BUFLEN 1024 138#define OUT_BUFLEN 128
121 139
122struct option_port_private { 140struct option_port_private {
123 /* Input endpoints and buffer for this port */ 141 /* Input endpoints and buffer for this port */
124 struct urb *in_urbs[N_IN_URB]; 142 struct urb *in_urbs[N_IN_URB];
125 char in_buffer[N_IN_URB][IN_BUFLEN]; 143 char in_buffer[N_IN_URB][IN_BUFLEN];
126 /* Output endpoints and buffer for this port */ 144 /* Output endpoints and buffer for this port */
127 struct urb *out_urbs[N_OUT_URB]; 145 struct urb *out_urbs[N_OUT_URB];
128 char out_buffer[N_OUT_URB][OUT_BUFLEN]; 146 char out_buffer[N_OUT_URB][OUT_BUFLEN];
129 147
130 /* Settings for the port */ 148 /* Settings for the port */
131 int rts_state; /* Handshaking pins (outputs) */ 149 int rts_state; /* Handshaking pins (outputs) */
132 int dtr_state; 150 int dtr_state;
133 int cts_state; /* Handshaking pins (inputs) */ 151 int cts_state; /* Handshaking pins (inputs) */
134 int dsr_state; 152 int dsr_state;
135 int dcd_state; 153 int dcd_state;
136 int ri_state; 154 int ri_state;
137 // int break_on; 155
138 156 unsigned long tx_start_time[N_OUT_URB];
139 unsigned long tx_start_time[N_OUT_URB];
140}; 157};
141 158
142 159
@@ -190,13 +207,13 @@ static void
190option_break_ctl (struct usb_serial_port *port, int break_state) 207option_break_ctl (struct usb_serial_port *port, int break_state)
191{ 208{
192 /* Unfortunately, I don't know how to send a break */ 209 /* Unfortunately, I don't know how to send a break */
193 dbg("%s", __FUNCTION__); 210 dbg("%s", __FUNCTION__);
194} 211}
195 212
196 213
197static void 214static void
198option_set_termios (struct usb_serial_port *port, 215option_set_termios (struct usb_serial_port *port,
199 struct termios *old_termios) 216 struct termios *old_termios)
200{ 217{
201 dbg("%s", __FUNCTION__); 218 dbg("%s", __FUNCTION__);
202 219
@@ -204,10 +221,10 @@ option_set_termios (struct usb_serial_port *port,
204} 221}
205 222
206static int 223static int
207option_tiocmget(struct usb_serial_port *port, struct file *file) 224option_tiocmget (struct usb_serial_port *port, struct file *file)
208{ 225{
209 unsigned int value; 226 unsigned int value;
210 struct option_port_private *portdata; 227 struct option_port_private *portdata;
211 228
212 portdata = usb_get_serial_port_data(port); 229 portdata = usb_get_serial_port_data(port);
213 230
@@ -225,7 +242,7 @@ static int
225option_tiocmset (struct usb_serial_port *port, struct file *file, 242option_tiocmset (struct usb_serial_port *port, struct file *file,
226 unsigned int set, unsigned int clear) 243 unsigned int set, unsigned int clear)
227{ 244{
228 struct option_port_private *portdata; 245 struct option_port_private *portdata;
229 246
230 portdata = usb_get_serial_port_data(port); 247 portdata = usb_get_serial_port_data(port);
231 248
@@ -250,71 +267,50 @@ option_ioctl (struct usb_serial_port *port, struct file *file,
250 267
251/* Write */ 268/* Write */
252static int 269static int
253option_write(struct usb_serial_port *port, 270option_write (struct usb_serial_port *port,
254 const unsigned char *buf, int count) 271 const unsigned char *buf, int count)
255{ 272{
256 struct option_port_private *portdata; 273 struct option_port_private *portdata;
257 int i; 274 int i;
258 int left, todo; 275 int left, todo;
259 struct urb *this_urb = NULL; /* spurious */ 276 struct urb *this_urb = NULL; /* spurious */
260 int err; 277 int err;
261 278
262 portdata = usb_get_serial_port_data(port); 279 portdata = usb_get_serial_port_data(port);
263 280
264 dbg("%s: write (%d chars)", __FUNCTION__, count); 281 dbg("%s: write (%d chars)", __FUNCTION__, count);
265 282
266#if 0
267 spin_lock(&port->lock);
268 if (port->write_urb_busy) {
269 spin_unlock(&port->lock);
270 dbg("%s: already writing", __FUNCTION__);
271 return 0;
272 }
273 port->write_urb_busy = 1;
274 spin_unlock(&port->lock);
275#endif
276
277 i = 0; 283 i = 0;
278 left = count; 284 left = count;
279 while (left>0) { 285 for (i=0; left > 0 && i < N_OUT_URB; i++) {
280 todo = left; 286 todo = left;
281 if (todo > OUT_BUFLEN) 287 if (todo > OUT_BUFLEN)
282 todo = OUT_BUFLEN; 288 todo = OUT_BUFLEN;
283 289
284 for (;i < N_OUT_URB; i++) { 290 this_urb = portdata->out_urbs[i];
285 /* Check we have a valid urb/endpoint before we use it... */ 291 if (this_urb->status == -EINPROGRESS) {
286 this_urb = portdata->out_urbs[i];
287 if (this_urb->status != -EINPROGRESS)
288 break;
289 if (this_urb->transfer_flags & URB_ASYNC_UNLINK) 292 if (this_urb->transfer_flags & URB_ASYNC_UNLINK)
290 continue; 293 continue;
291 if (time_before(jiffies, portdata->tx_start_time[i] + 10 * HZ)) 294 if (time_before(jiffies, portdata->tx_start_time[i] + 10 * HZ))
292 continue; 295 continue;
293 this_urb->transfer_flags |= URB_ASYNC_UNLINK; 296 this_urb->transfer_flags |= URB_ASYNC_UNLINK;
294 usb_unlink_urb(this_urb); 297 usb_unlink_urb(this_urb);
298 continue;
295 } 299 }
296 300 if (this_urb->status != 0)
297 if (i == N_OUT_URB) { 301 dbg("usb_write %p failed (err=%d)", this_urb, this_urb->status);
298 /* no bulk out free! */
299 dbg("%s: no output urb -- left %d", __FUNCTION__,count-left);
300#if 0
301 port->write_urb_busy = 0;
302#endif
303 return count-left;
304 }
305 302
306 dbg("%s: endpoint %d buf %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), i); 303 dbg("%s: endpoint %d buf %d", __FUNCTION__, usb_pipeendpoint(this_urb->pipe), i);
307 304
305 /* send the data */
308 memcpy (this_urb->transfer_buffer, buf, todo); 306 memcpy (this_urb->transfer_buffer, buf, todo);
309
310 /* send the data out the bulk port */
311 this_urb->transfer_buffer_length = todo; 307 this_urb->transfer_buffer_length = todo;
312 308
313 this_urb->transfer_flags &= ~URB_ASYNC_UNLINK; 309 this_urb->transfer_flags &= ~URB_ASYNC_UNLINK;
314 this_urb->dev = port->serial->dev; 310 this_urb->dev = port->serial->dev;
315 err = usb_submit_urb(this_urb, GFP_ATOMIC); 311 err = usb_submit_urb(this_urb, GFP_ATOMIC);
316 if (err) { 312 if (err) {
317 dbg("usb_submit_urb %p (write bulk) failed (%d,, has %d)", this_urb, err, this_urb->status); 313 dbg("usb_submit_urb %p (write bulk) failed (%d, has %d)", this_urb, err, this_urb->status);
318 continue; 314 continue;
319 } 315 }
320 portdata->tx_start_time[i] = jiffies; 316 portdata->tx_start_time[i] = jiffies;
@@ -323,9 +319,6 @@ option_write(struct usb_serial_port *port,
323 } 319 }
324 320
325 count -= left; 321 count -= left;
326#if 0
327 port->write_urb_busy = 0;
328#endif
329 dbg("%s: wrote (did %d)", __FUNCTION__, count); 322 dbg("%s: wrote (did %d)", __FUNCTION__, count);
330 return count; 323 return count;
331} 324}
@@ -333,7 +326,7 @@ option_write(struct usb_serial_port *port,
333static void 326static void
334option_indat_callback (struct urb *urb, struct pt_regs *regs) 327option_indat_callback (struct urb *urb, struct pt_regs *regs)
335{ 328{
336 int i, err; 329 int i, err;
337 int endpoint; 330 int endpoint;
338 struct usb_serial_port *port; 331 struct usb_serial_port *port;
339 struct tty_struct *tty; 332 struct tty_struct *tty;
@@ -444,10 +437,11 @@ option_write_room (struct usb_serial_port *port)
444 437
445 portdata = usb_get_serial_port_data(port); 438 portdata = usb_get_serial_port_data(port);
446 439
447 for (i=0; i < N_OUT_URB; i++) 440 for (i=0; i < N_OUT_URB; i++) {
448 this_urb = portdata->out_urbs[i]; 441 this_urb = portdata->out_urbs[i];
449 if (this_urb && this_urb->status != -EINPROGRESS) 442 if (this_urb && this_urb->status != -EINPROGRESS)
450 data_len += OUT_BUFLEN; 443 data_len += OUT_BUFLEN;
444 }
451 445
452 dbg("%s: %d", __FUNCTION__, data_len); 446 dbg("%s: %d", __FUNCTION__, data_len);
453 return data_len; 447 return data_len;
@@ -464,11 +458,11 @@ option_chars_in_buffer (struct usb_serial_port *port)
464 458
465 portdata = usb_get_serial_port_data(port); 459 portdata = usb_get_serial_port_data(port);
466 460
467 for (i=0; i < N_OUT_URB; i++) 461 for (i=0; i < N_OUT_URB; i++) {
468 this_urb = portdata->out_urbs[i]; 462 this_urb = portdata->out_urbs[i];
469 if (this_urb && this_urb->status == -EINPROGRESS) 463 if (this_urb && this_urb->status == -EINPROGRESS)
470 data_len += this_urb->transfer_buffer_length; 464 data_len += this_urb->transfer_buffer_length;
471 465 }
472 dbg("%s: %d", __FUNCTION__, data_len); 466 dbg("%s: %d", __FUNCTION__, data_len);
473 return data_len; 467 return data_len;
474} 468}
@@ -477,10 +471,10 @@ option_chars_in_buffer (struct usb_serial_port *port)
477static int 471static int
478option_open (struct usb_serial_port *port, struct file *filp) 472option_open (struct usb_serial_port *port, struct file *filp)
479{ 473{
480 struct option_port_private *portdata; 474 struct option_port_private *portdata;
481 struct usb_serial *serial = port->serial; 475 struct usb_serial *serial = port->serial;
482 int i, err; 476 int i, err;
483 struct urb *urb; 477 struct urb *urb;
484 478
485 portdata = usb_get_serial_port_data(port); 479 portdata = usb_get_serial_port_data(port);
486 480
@@ -528,7 +522,7 @@ option_open (struct usb_serial_port *port, struct file *filp)
528} 522}
529 523
530static inline void 524static inline void
531stop_urb(struct urb *urb) 525stop_urb (struct urb *urb)
532{ 526{
533 if (urb && urb->status == -EINPROGRESS) { 527 if (urb && urb->status == -EINPROGRESS) {
534 urb->transfer_flags &= ~URB_ASYNC_UNLINK; 528 urb->transfer_flags &= ~URB_ASYNC_UNLINK;
@@ -537,11 +531,11 @@ stop_urb(struct urb *urb)
537} 531}
538 532
539static void 533static void
540option_close(struct usb_serial_port *port, struct file *filp) 534option_close (struct usb_serial_port *port, struct file *filp)
541{ 535{
542 int i; 536 int i;
543 struct usb_serial *serial = port->serial; 537 struct usb_serial *serial = port->serial;
544 struct option_port_private *portdata; 538 struct option_port_private *portdata;
545 539
546 dbg("%s", __FUNCTION__); 540 dbg("%s", __FUNCTION__);
547 portdata = usb_get_serial_port_data(port); 541 portdata = usb_get_serial_port_data(port);
@@ -589,11 +583,11 @@ option_setup_urb (struct usb_serial *serial, int endpoint,
589 583
590/* Setup urbs */ 584/* Setup urbs */
591static void 585static void
592option_setup_urbs(struct usb_serial *serial) 586option_setup_urbs (struct usb_serial *serial)
593{ 587{
594 int j; 588 int j;
595 struct usb_serial_port *port; 589 struct usb_serial_port *port;
596 struct option_port_private *portdata; 590 struct option_port_private *portdata;
597 591
598 dbg("%s", __FUNCTION__); 592 dbg("%s", __FUNCTION__);
599 593
@@ -617,7 +611,7 @@ option_setup_urbs(struct usb_serial *serial)
617 611
618 612
619static int 613static int
620option_send_setup(struct usb_serial_port *port) 614option_send_setup (struct usb_serial_port *port)
621{ 615{
622 struct usb_serial *serial = port->serial; 616 struct usb_serial *serial = port->serial;
623 struct option_port_private *portdata; 617 struct option_port_private *portdata;
@@ -644,9 +638,9 @@ option_send_setup(struct usb_serial_port *port)
644static int 638static int
645option_startup (struct usb_serial *serial) 639option_startup (struct usb_serial *serial)
646{ 640{
647 int i, err; 641 int i, err;
648 struct usb_serial_port *port; 642 struct usb_serial_port *port;
649 struct option_port_private *portdata; 643 struct option_port_private *portdata;
650 644
651 dbg("%s", __FUNCTION__); 645 dbg("%s", __FUNCTION__);
652 646
@@ -677,9 +671,9 @@ option_startup (struct usb_serial *serial)
677static void 671static void
678option_shutdown (struct usb_serial *serial) 672option_shutdown (struct usb_serial *serial)
679{ 673{
680 int i, j; 674 int i, j;
681 struct usb_serial_port *port; 675 struct usb_serial_port *port;
682 struct option_port_private *portdata; 676 struct option_port_private *portdata;
683 677
684 dbg("%s", __FUNCTION__); 678 dbg("%s", __FUNCTION__);
685 679
@@ -724,6 +718,8 @@ MODULE_DESCRIPTION(DRIVER_DESC);
724MODULE_VERSION(DRIVER_VERSION); 718MODULE_VERSION(DRIVER_VERSION);
725MODULE_LICENSE("GPL"); 719MODULE_LICENSE("GPL");
726 720
721#ifdef CONFIG_USB_DEBUG
727module_param(debug, bool, S_IRUGO | S_IWUSR); 722module_param(debug, bool, S_IRUGO | S_IWUSR);
728MODULE_PARM_DESC(debug, "Debug messages"); 723MODULE_PARM_DESC(debug, "Debug messages");
724#endif
729 725
diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c
index d44431d1a338..0aa5ac159c09 100644
--- a/fs/ext2/xip.c
+++ b/fs/ext2/xip.c
@@ -15,66 +15,79 @@
15#include "xip.h" 15#include "xip.h"
16 16
17static inline int 17static inline int
18__inode_direct_access(struct inode *inode, sector_t sector, unsigned long *data) { 18__inode_direct_access(struct inode *inode, sector_t sector,
19 unsigned long *data)
20{
19 BUG_ON(!inode->i_sb->s_bdev->bd_disk->fops->direct_access); 21 BUG_ON(!inode->i_sb->s_bdev->bd_disk->fops->direct_access);
20 return inode->i_sb->s_bdev->bd_disk->fops 22 return inode->i_sb->s_bdev->bd_disk->fops
21 ->direct_access(inode->i_sb->s_bdev,sector,data); 23 ->direct_access(inode->i_sb->s_bdev,sector,data);
22} 24}
23 25
26static inline int
27__ext2_get_sector(struct inode *inode, sector_t offset, int create,
28 sector_t *result)
29{
30 struct buffer_head tmp;
31 int rc;
32
33 memset(&tmp, 0, sizeof(struct buffer_head));
34 rc = ext2_get_block(inode, offset/ (PAGE_SIZE/512), &tmp,
35 create);
36 *result = tmp.b_blocknr;
37
38 /* did we get a sparse block (hole in the file)? */
39 if (!(*result)) {
40 BUG_ON(create);
41 rc = -ENODATA;
42 }
43
44 return rc;
45}
46
24int 47int
25ext2_clear_xip_target(struct inode *inode, int block) { 48ext2_clear_xip_target(struct inode *inode, int block)
26 sector_t sector = block*(PAGE_SIZE/512); 49{
50 sector_t sector = block * (PAGE_SIZE/512);
27 unsigned long data; 51 unsigned long data;
28 int rc; 52 int rc;
29 53
30 rc = __inode_direct_access(inode, sector, &data); 54 rc = __inode_direct_access(inode, sector, &data);
31 if (rc) 55 if (!rc)
32 return rc; 56 clear_page((void*)data);
33 clear_page((void*)data); 57 return rc;
34 return 0;
35} 58}
36 59
37void ext2_xip_verify_sb(struct super_block *sb) 60void ext2_xip_verify_sb(struct super_block *sb)
38{ 61{
39 struct ext2_sb_info *sbi = EXT2_SB(sb); 62 struct ext2_sb_info *sbi = EXT2_SB(sb);
40 63
41 if ((sbi->s_mount_opt & EXT2_MOUNT_XIP)) { 64 if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) &&
42 if ((sb->s_bdev == NULL) || 65 !sb->s_bdev->bd_disk->fops->direct_access) {
43 sb->s_bdev->bd_disk == NULL || 66 sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
44 sb->s_bdev->bd_disk->fops == NULL || 67 ext2_warning(sb, __FUNCTION__,
45 sb->s_bdev->bd_disk->fops->direct_access == NULL) { 68 "ignoring xip option - not supported by bdev");
46 sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
47 ext2_warning(sb, __FUNCTION__,
48 "ignoring xip option - not supported by bdev");
49 }
50 } 69 }
51} 70}
52 71
53struct page* 72struct page *
54ext2_get_xip_page(struct address_space *mapping, sector_t blockno, 73ext2_get_xip_page(struct address_space *mapping, sector_t offset,
55 int create) 74 int create)
56{ 75{
57 int rc; 76 int rc;
58 unsigned long data; 77 unsigned long data;
59 struct buffer_head tmp; 78 sector_t sector;
60 79
61 tmp.b_state = 0; 80 /* first, retrieve the sector number */
62 tmp.b_blocknr = 0; 81 rc = __ext2_get_sector(mapping->host, offset, create, &sector);
63 rc = ext2_get_block(mapping->host, blockno/(PAGE_SIZE/512) , &tmp,
64 create);
65 if (rc) 82 if (rc)
66 return ERR_PTR(rc); 83 goto error;
67 if (tmp.b_blocknr == 0) {
68 /* SPARSE block */
69 BUG_ON(create);
70 return ERR_PTR(-ENODATA);
71 }
72 84
85 /* retrieve address of the target data */
73 rc = __inode_direct_access 86 rc = __inode_direct_access
74 (mapping->host,tmp.b_blocknr*(PAGE_SIZE/512) ,&data); 87 (mapping->host, sector * (PAGE_SIZE/512), &data);
75 if (rc) 88 if (!rc)
76 return ERR_PTR(rc); 89 return virt_to_page(data);
77 90
78 SetPageUptodate(virt_to_page(data)); 91 error:
79 return virt_to_page(data); 92 return ERR_PTR(rc);
80} 93}
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 4bf43ea87c46..88e68caa3784 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -15,7 +15,6 @@
15#include <linux/pagemap.h> 15#include <linux/pagemap.h>
16#include <linux/blkdev.h> 16#include <linux/blkdev.h>
17#include <linux/list.h> 17#include <linux/list.h>
18#include <linux/root_dev.h>
19#include <linux/statfs.h> 18#include <linux/statfs.h>
20#include <linux/kdev_t.h> 19#include <linux/kdev_t.h>
21#include <asm/uaccess.h> 20#include <asm/uaccess.h>
@@ -160,8 +159,6 @@ static int read_name(struct inode *ino, char *name)
160 ino->i_size = i_size; 159 ino->i_size = i_size;
161 ino->i_blksize = i_blksize; 160 ino->i_blksize = i_blksize;
162 ino->i_blocks = i_blocks; 161 ino->i_blocks = i_blocks;
163 if((ino->i_sb->s_dev == ROOT_DEV) && (ino->i_uid == getuid()))
164 ino->i_uid = 0;
165 return(0); 162 return(0);
166} 163}
167 164
@@ -841,16 +838,10 @@ int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
841 attrs.ia_mode = attr->ia_mode; 838 attrs.ia_mode = attr->ia_mode;
842 } 839 }
843 if(attr->ia_valid & ATTR_UID){ 840 if(attr->ia_valid & ATTR_UID){
844 if((dentry->d_inode->i_sb->s_dev == ROOT_DEV) &&
845 (attr->ia_uid == 0))
846 attr->ia_uid = getuid();
847 attrs.ia_valid |= HOSTFS_ATTR_UID; 841 attrs.ia_valid |= HOSTFS_ATTR_UID;
848 attrs.ia_uid = attr->ia_uid; 842 attrs.ia_uid = attr->ia_uid;
849 } 843 }
850 if(attr->ia_valid & ATTR_GID){ 844 if(attr->ia_valid & ATTR_GID){
851 if((dentry->d_inode->i_sb->s_dev == ROOT_DEV) &&
852 (attr->ia_gid == 0))
853 attr->ia_gid = getgid();
854 attrs.ia_valid |= HOSTFS_ATTR_GID; 845 attrs.ia_valid |= HOSTFS_ATTR_GID;
855 attrs.ia_gid = attr->ia_gid; 846 attrs.ia_gid = attr->ia_gid;
856 } 847 }
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs_kern.c
index 6f553e17c375..ff150fedb981 100644
--- a/fs/hppfs/hppfs_kern.c
+++ b/fs/hppfs/hppfs_kern.c
@@ -233,7 +233,7 @@ static ssize_t read_proc(struct file *file, char *buf, ssize_t count,
233 set_fs(USER_DS); 233 set_fs(USER_DS);
234 234
235 if(ppos) *ppos = file->f_pos; 235 if(ppos) *ppos = file->f_pos;
236 return(n); 236 return n;
237} 237}
238 238
239static ssize_t hppfs_read_file(int fd, char *buf, ssize_t count) 239static ssize_t hppfs_read_file(int fd, char *buf, ssize_t count)
@@ -254,7 +254,7 @@ static ssize_t hppfs_read_file(int fd, char *buf, ssize_t count)
254 err = os_read_file(fd, new_buf, cur); 254 err = os_read_file(fd, new_buf, cur);
255 if(err < 0){ 255 if(err < 0){
256 printk("hppfs_read : read failed, errno = %d\n", 256 printk("hppfs_read : read failed, errno = %d\n",
257 count); 257 err);
258 n = err; 258 n = err;
259 goto out_free; 259 goto out_free;
260 } 260 }
@@ -271,7 +271,7 @@ static ssize_t hppfs_read_file(int fd, char *buf, ssize_t count)
271 out_free: 271 out_free:
272 kfree(new_buf); 272 kfree(new_buf);
273 out: 273 out:
274 return(n); 274 return n;
275} 275}
276 276
277static ssize_t hppfs_read(struct file *file, char *buf, size_t count, 277static ssize_t hppfs_read(struct file *file, char *buf, size_t count,
diff --git a/fs/inode.c b/fs/inode.c
index 96364fae0844..e57f1724db3e 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -757,6 +757,7 @@ EXPORT_SYMBOL(igrab);
757 * @head: the head of the list to search 757 * @head: the head of the list to search
758 * @test: callback used for comparisons between inodes 758 * @test: callback used for comparisons between inodes
759 * @data: opaque data pointer to pass to @test 759 * @data: opaque data pointer to pass to @test
760 * @wait: if true wait for the inode to be unlocked, if false do not
760 * 761 *
761 * ifind() searches for the inode specified by @data in the inode 762 * ifind() searches for the inode specified by @data in the inode
762 * cache. This is a generalized version of ifind_fast() for file systems where 763 * cache. This is a generalized version of ifind_fast() for file systems where
@@ -771,7 +772,7 @@ EXPORT_SYMBOL(igrab);
771 */ 772 */
772static inline struct inode *ifind(struct super_block *sb, 773static inline struct inode *ifind(struct super_block *sb,
773 struct hlist_head *head, int (*test)(struct inode *, void *), 774 struct hlist_head *head, int (*test)(struct inode *, void *),
774 void *data) 775 void *data, const int wait)
775{ 776{
776 struct inode *inode; 777 struct inode *inode;
777 778
@@ -780,7 +781,8 @@ static inline struct inode *ifind(struct super_block *sb,
780 if (inode) { 781 if (inode) {
781 __iget(inode); 782 __iget(inode);
782 spin_unlock(&inode_lock); 783 spin_unlock(&inode_lock);
783 wait_on_inode(inode); 784 if (likely(wait))
785 wait_on_inode(inode);
784 return inode; 786 return inode;
785 } 787 }
786 spin_unlock(&inode_lock); 788 spin_unlock(&inode_lock);
@@ -820,7 +822,7 @@ static inline struct inode *ifind_fast(struct super_block *sb,
820} 822}
821 823
822/** 824/**
823 * ilookup5 - search for an inode in the inode cache 825 * ilookup5_nowait - search for an inode in the inode cache
824 * @sb: super block of file system to search 826 * @sb: super block of file system to search
825 * @hashval: hash value (usually inode number) to search for 827 * @hashval: hash value (usually inode number) to search for
826 * @test: callback used for comparisons between inodes 828 * @test: callback used for comparisons between inodes
@@ -832,7 +834,38 @@ static inline struct inode *ifind_fast(struct super_block *sb,
832 * identification of an inode. 834 * identification of an inode.
833 * 835 *
834 * If the inode is in the cache, the inode is returned with an incremented 836 * If the inode is in the cache, the inode is returned with an incremented
835 * reference count. 837 * reference count. Note, the inode lock is not waited upon so you have to be
838 * very careful what you do with the returned inode. You probably should be
839 * using ilookup5() instead.
840 *
841 * Otherwise NULL is returned.
842 *
843 * Note, @test is called with the inode_lock held, so can't sleep.
844 */
845struct inode *ilookup5_nowait(struct super_block *sb, unsigned long hashval,
846 int (*test)(struct inode *, void *), void *data)
847{
848 struct hlist_head *head = inode_hashtable + hash(sb, hashval);
849
850 return ifind(sb, head, test, data, 0);
851}
852
853EXPORT_SYMBOL(ilookup5_nowait);
854
855/**
856 * ilookup5 - search for an inode in the inode cache
857 * @sb: super block of file system to search
858 * @hashval: hash value (usually inode number) to search for
859 * @test: callback used for comparisons between inodes
860 * @data: opaque data pointer to pass to @test
861 *
862 * ilookup5() uses ifind() to search for the inode specified by @hashval and
863 * @data in the inode cache. This is a generalized version of ilookup() for
864 * file systems where the inode number is not sufficient for unique
865 * identification of an inode.
866 *
867 * If the inode is in the cache, the inode lock is waited upon and the inode is
868 * returned with an incremented reference count.
836 * 869 *
837 * Otherwise NULL is returned. 870 * Otherwise NULL is returned.
838 * 871 *
@@ -843,7 +876,7 @@ struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
843{ 876{
844 struct hlist_head *head = inode_hashtable + hash(sb, hashval); 877 struct hlist_head *head = inode_hashtable + hash(sb, hashval);
845 878
846 return ifind(sb, head, test, data); 879 return ifind(sb, head, test, data, 1);
847} 880}
848 881
849EXPORT_SYMBOL(ilookup5); 882EXPORT_SYMBOL(ilookup5);
@@ -900,7 +933,7 @@ struct inode *iget5_locked(struct super_block *sb, unsigned long hashval,
900 struct hlist_head *head = inode_hashtable + hash(sb, hashval); 933 struct hlist_head *head = inode_hashtable + hash(sb, hashval);
901 struct inode *inode; 934 struct inode *inode;
902 935
903 inode = ifind(sb, head, test, data); 936 inode = ifind(sb, head, test, data, 1);
904 if (inode) 937 if (inode)
905 return inode; 938 return inode;
906 /* 939 /*
diff --git a/fs/inotify.c b/fs/inotify.c
index e423bfe0c86f..54757be888b6 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -29,8 +29,6 @@
29#include <linux/mount.h> 29#include <linux/mount.h>
30#include <linux/namei.h> 30#include <linux/namei.h>
31#include <linux/poll.h> 31#include <linux/poll.h>
32#include <linux/device.h>
33#include <linux/miscdevice.h>
34#include <linux/init.h> 32#include <linux/init.h>
35#include <linux/list.h> 33#include <linux/list.h>
36#include <linux/writeback.h> 34#include <linux/writeback.h>
@@ -45,8 +43,8 @@ static kmem_cache_t *event_cachep;
45 43
46static struct vfsmount *inotify_mnt; 44static struct vfsmount *inotify_mnt;
47 45
48/* These are configurable via /proc/sys/inotify */ 46/* these are configurable via /proc/sys/fs/inotify/ */
49int inotify_max_user_devices; 47int inotify_max_user_instances;
50int inotify_max_user_watches; 48int inotify_max_user_watches;
51int inotify_max_queued_events; 49int inotify_max_queued_events;
52 50
@@ -125,6 +123,47 @@ struct inotify_watch {
125 u32 mask; /* event mask for this watch */ 123 u32 mask; /* event mask for this watch */
126}; 124};
127 125
126#ifdef CONFIG_SYSCTL
127
128#include <linux/sysctl.h>
129
130static int zero;
131
132ctl_table inotify_table[] = {
133 {
134 .ctl_name = INOTIFY_MAX_USER_INSTANCES,
135 .procname = "max_user_instances",
136 .data = &inotify_max_user_instances,
137 .maxlen = sizeof(int),
138 .mode = 0644,
139 .proc_handler = &proc_dointvec_minmax,
140 .strategy = &sysctl_intvec,
141 .extra1 = &zero,
142 },
143 {
144 .ctl_name = INOTIFY_MAX_USER_WATCHES,
145 .procname = "max_user_watches",
146 .data = &inotify_max_user_watches,
147 .maxlen = sizeof(int),
148 .mode = 0644,
149 .proc_handler = &proc_dointvec_minmax,
150 .strategy = &sysctl_intvec,
151 .extra1 = &zero,
152 },
153 {
154 .ctl_name = INOTIFY_MAX_QUEUED_EVENTS,
155 .procname = "max_queued_events",
156 .data = &inotify_max_queued_events,
157 .maxlen = sizeof(int),
158 .mode = 0644,
159 .proc_handler = &proc_dointvec_minmax,
160 .strategy = &sysctl_intvec,
161 .extra1 = &zero
162 },
163 { .ctl_name = 0 }
164};
165#endif /* CONFIG_SYSCTL */
166
128static inline void get_inotify_dev(struct inotify_device *dev) 167static inline void get_inotify_dev(struct inotify_device *dev)
129{ 168{
130 atomic_inc(&dev->count); 169 atomic_inc(&dev->count);
@@ -842,7 +881,7 @@ asmlinkage long sys_inotify_init(void)
842 881
843 user = get_uid(current->user); 882 user = get_uid(current->user);
844 883
845 if (unlikely(atomic_read(&user->inotify_devs) >= inotify_max_user_devices)) { 884 if (unlikely(atomic_read(&user->inotify_devs) >= inotify_max_user_instances)) {
846 ret = -EMFILE; 885 ret = -EMFILE;
847 goto out_err; 886 goto out_err;
848 } 887 }
@@ -893,7 +932,7 @@ asmlinkage long sys_inotify_add_watch(int fd, const char *path, u32 mask)
893 932
894 dev = filp->private_data; 933 dev = filp->private_data;
895 934
896 ret = find_inode ((const char __user*)path, &nd); 935 ret = find_inode((const char __user*) path, &nd);
897 if (ret) 936 if (ret)
898 goto fput_and_out; 937 goto fput_and_out;
899 938
@@ -950,8 +989,9 @@ asmlinkage long sys_inotify_rm_watch(int fd, u32 wd)
950 if (!filp) 989 if (!filp)
951 return -EBADF; 990 return -EBADF;
952 dev = filp->private_data; 991 dev = filp->private_data;
953 ret = inotify_ignore (dev, wd); 992 ret = inotify_ignore(dev, wd);
954 fput(filp); 993 fput(filp);
994
955 return ret; 995 return ret;
956} 996}
957 997
@@ -979,7 +1019,7 @@ static int __init inotify_init(void)
979 inotify_mnt = kern_mount(&inotify_fs_type); 1019 inotify_mnt = kern_mount(&inotify_fs_type);
980 1020
981 inotify_max_queued_events = 8192; 1021 inotify_max_queued_events = 8192;
982 inotify_max_user_devices = 128; 1022 inotify_max_user_instances = 8;
983 inotify_max_user_watches = 8192; 1023 inotify_max_user_watches = 8192;
984 1024
985 atomic_set(&inotify_cookie, 0); 1025 atomic_set(&inotify_cookie, 0);
@@ -991,8 +1031,6 @@ static int __init inotify_init(void)
991 sizeof(struct inotify_kernel_event), 1031 sizeof(struct inotify_kernel_event),
992 0, SLAB_PANIC, NULL, NULL); 1032 0, SLAB_PANIC, NULL, NULL);
993 1033
994 printk(KERN_INFO "inotify syscall\n");
995
996 return 0; 1034 return 0;
997} 1035}
998 1036
diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c
index 3dd5394921c9..97dc39796e2c 100644
--- a/fs/jffs2/build.c
+++ b/fs/jffs2/build.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: build.c,v 1.70 2005/02/28 08:21:05 dedekind Exp $ 10 * $Id: build.c,v 1.71 2005/07/12 16:37:08 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -336,13 +336,6 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
336 c->blocks[i].bad_count = 0; 336 c->blocks[i].bad_count = 0;
337 } 337 }
338 338
339 init_MUTEX(&c->alloc_sem);
340 init_MUTEX(&c->erase_free_sem);
341 init_waitqueue_head(&c->erase_wait);
342 init_waitqueue_head(&c->inocache_wq);
343 spin_lock_init(&c->erase_completion_lock);
344 spin_lock_init(&c->inocache_lock);
345
346 INIT_LIST_HEAD(&c->clean_list); 339 INIT_LIST_HEAD(&c->clean_list);
347 INIT_LIST_HEAD(&c->very_dirty_list); 340 INIT_LIST_HEAD(&c->very_dirty_list);
348 INIT_LIST_HEAD(&c->dirty_list); 341 INIT_LIST_HEAD(&c->dirty_list);
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index c7bbdeec93a6..4991c348f6ec 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: nodelist.c,v 1.97 2005/07/06 15:18:41 dwmw2 Exp $ 10 * $Id: nodelist.c,v 1.98 2005/07/10 15:15:32 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -55,11 +55,11 @@ void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new
55 }); 55 });
56} 56}
57 57
58/* Put a new tmp_dnode_info into the list, keeping the list in 58/*
59 order of increasing version 59 * Put a new tmp_dnode_info into the temporaty RB-tree, keeping the list in
60*/ 60 * order of increasing version.
61 61 */
62static void jffs2_add_tn_to_list(struct jffs2_tmp_dnode_info *tn, struct rb_root *list) 62static void jffs2_add_tn_to_tree(struct jffs2_tmp_dnode_info *tn, struct rb_root *list)
63{ 63{
64 struct rb_node **p = &list->rb_node; 64 struct rb_node **p = &list->rb_node;
65 struct rb_node * parent = NULL; 65 struct rb_node * parent = NULL;
@@ -420,7 +420,7 @@ int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
420 D1(printk(KERN_DEBUG "dnode @%08x: ver %u, offset %04x, dsize %04x\n", 420 D1(printk(KERN_DEBUG "dnode @%08x: ver %u, offset %04x, dsize %04x\n",
421 ref_offset(ref), je32_to_cpu(node.i.version), 421 ref_offset(ref), je32_to_cpu(node.i.version),
422 je32_to_cpu(node.i.offset), je32_to_cpu(node.i.dsize))); 422 je32_to_cpu(node.i.offset), je32_to_cpu(node.i.dsize)));
423 jffs2_add_tn_to_list(tn, &ret_tn); 423 jffs2_add_tn_to_tree(tn, &ret_tn);
424 break; 424 break;
425 425
426 default: 426 default:
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index 7bf72e012c94..d900c8929b09 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: os-linux.h,v 1.57 2005/07/06 12:13:09 dwmw2 Exp $ 10 * $Id: os-linux.h,v 1.58 2005/07/12 02:34:35 tpoynor Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -86,6 +86,8 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
86#define jffs2_dataflash(c) (0) 86#define jffs2_dataflash(c) (0)
87#define jffs2_nor_ecc_flash_setup(c) (0) 87#define jffs2_nor_ecc_flash_setup(c) (0)
88#define jffs2_nor_ecc_flash_cleanup(c) do {} while (0) 88#define jffs2_nor_ecc_flash_cleanup(c) do {} while (0)
89#define jffs2_dataflash_setup(c) (0)
90#define jffs2_dataflash_cleanup(c) do {} while (0)
89 91
90#else /* NAND and/or ECC'd NOR support present */ 92#else /* NAND and/or ECC'd NOR support present */
91 93
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 081656c1d49e..5b2a83599d73 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: readinode.c,v 1.120 2005/07/05 21:03:07 dwmw2 Exp $ 10 * $Id: readinode.c,v 1.125 2005/07/10 13:13:55 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -151,6 +151,9 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
151 151
152 D1(printk(KERN_DEBUG "jffs2_add_full_dnode_to_inode(ino #%u, f %p, fn %p)\n", f->inocache->ino, f, fn)); 152 D1(printk(KERN_DEBUG "jffs2_add_full_dnode_to_inode(ino #%u, f %p, fn %p)\n", f->inocache->ino, f, fn));
153 153
154 if (unlikely(!fn->size))
155 return 0;
156
154 newfrag = jffs2_alloc_node_frag(); 157 newfrag = jffs2_alloc_node_frag();
155 if (unlikely(!newfrag)) 158 if (unlikely(!newfrag))
156 return -ENOMEM; 159 return -ENOMEM;
@@ -158,11 +161,6 @@ int jffs2_add_full_dnode_to_inode(struct jffs2_sb_info *c, struct jffs2_inode_in
158 D2(printk(KERN_DEBUG "adding node %04x-%04x @0x%08x on flash, newfrag *%p\n", 161 D2(printk(KERN_DEBUG "adding node %04x-%04x @0x%08x on flash, newfrag *%p\n",
159 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag)); 162 fn->ofs, fn->ofs+fn->size, ref_offset(fn->raw), newfrag));
160 163
161 if (unlikely(!fn->size)) {
162 jffs2_free_node_frag(newfrag);
163 return 0;
164 }
165
166 newfrag->ofs = fn->ofs; 164 newfrag->ofs = fn->ofs;
167 newfrag->size = fn->size; 165 newfrag->size = fn->size;
168 newfrag->node = fn; 166 newfrag->node = fn;
@@ -560,7 +558,6 @@ static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c,
560 } 558 }
561 next_tn: 559 next_tn:
562 BUG_ON(rb->rb_left); 560 BUG_ON(rb->rb_left);
563 repl_rb = NULL;
564 if (rb->rb_parent && rb->rb_parent->rb_left == rb) { 561 if (rb->rb_parent && rb->rb_parent->rb_left == rb) {
565 /* We were then left-hand child of our parent. We need 562 /* We were then left-hand child of our parent. We need
566 to move our own right-hand child into our place. */ 563 to move our own right-hand child into our place. */
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 2cf14cf8b35a..aaf9475cfb6a 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: super.c,v 1.106 2005/05/18 11:37:25 dedekind Exp $ 10 * $Id: super.c,v 1.107 2005/07/12 16:37:08 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -140,6 +140,15 @@ static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type,
140 D1(printk(KERN_DEBUG "jffs2_get_sb_mtd(): New superblock for device %d (\"%s\")\n", 140 D1(printk(KERN_DEBUG "jffs2_get_sb_mtd(): New superblock for device %d (\"%s\")\n",
141 mtd->index, mtd->name)); 141 mtd->index, mtd->name));
142 142
143 /* Initialize JFFS2 superblock locks, the further initialization will be
144 * done later */
145 init_MUTEX(&c->alloc_sem);
146 init_MUTEX(&c->erase_free_sem);
147 init_waitqueue_head(&c->erase_wait);
148 init_waitqueue_head(&c->inocache_wq);
149 spin_lock_init(&c->erase_completion_lock);
150 spin_lock_init(&c->inocache_lock);
151
143 sb->s_op = &jffs2_super_operations; 152 sb->s_op = &jffs2_super_operations;
144 sb->s_flags = flags | MS_NOATIME; 153 sb->s_flags = flags | MS_NOATIME;
145 154
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index cced2fed9d0f..0732f206ca60 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -26,36 +26,6 @@
26#include "jfs_debug.h" 26#include "jfs_debug.h"
27 27
28/* 28/*
29 * Debug code for double-checking block map
30 */
31/* #define _JFS_DEBUG_DMAP 1 */
32
33#ifdef _JFS_DEBUG_DMAP
34#define DBINITMAP(size,ipbmap,results) \
35 DBinitmap(size,ipbmap,results)
36#define DBALLOC(dbmap,mapsize,blkno,nblocks) \
37 DBAlloc(dbmap,mapsize,blkno,nblocks)
38#define DBFREE(dbmap,mapsize,blkno,nblocks) \
39 DBFree(dbmap,mapsize,blkno,nblocks)
40#define DBALLOCCK(dbmap,mapsize,blkno,nblocks) \
41 DBAllocCK(dbmap,mapsize,blkno,nblocks)
42#define DBFREECK(dbmap,mapsize,blkno,nblocks) \
43 DBFreeCK(dbmap,mapsize,blkno,nblocks)
44
45static void DBinitmap(s64, struct inode *, u32 **);
46static void DBAlloc(uint *, s64, s64, s64);
47static void DBFree(uint *, s64, s64, s64);
48static void DBAllocCK(uint *, s64, s64, s64);
49static void DBFreeCK(uint *, s64, s64, s64);
50#else
51#define DBINITMAP(size,ipbmap,results)
52#define DBALLOC(dbmap, mapsize, blkno, nblocks)
53#define DBFREE(dbmap, mapsize, blkno, nblocks)
54#define DBALLOCCK(dbmap, mapsize, blkno, nblocks)
55#define DBFREECK(dbmap, mapsize, blkno, nblocks)
56#endif /* _JFS_DEBUG_DMAP */
57
58/*
59 * SERIALIZATION of the Block Allocation Map. 29 * SERIALIZATION of the Block Allocation Map.
60 * 30 *
61 * the working state of the block allocation map is accessed in 31 * the working state of the block allocation map is accessed in
@@ -242,7 +212,6 @@ int dbMount(struct inode *ipbmap)
242 JFS_SBI(ipbmap->i_sb)->bmap = bmp; 212 JFS_SBI(ipbmap->i_sb)->bmap = bmp;
243 213
244 memset(bmp->db_active, 0, sizeof(bmp->db_active)); 214 memset(bmp->db_active, 0, sizeof(bmp->db_active));
245 DBINITMAP(bmp->db_mapsize, ipbmap, &bmp->db_DBmap);
246 215
247 /* 216 /*
248 * allocate/initialize the bmap lock 217 * allocate/initialize the bmap lock
@@ -407,16 +376,12 @@ int dbFree(struct inode *ip, s64 blkno, s64 nblocks)
407 */ 376 */
408 nb = min(rem, BPERDMAP - (blkno & (BPERDMAP - 1))); 377 nb = min(rem, BPERDMAP - (blkno & (BPERDMAP - 1)));
409 378
410 DBALLOCCK(bmp->db_DBmap, bmp->db_mapsize, blkno, nb);
411
412 /* free the blocks. */ 379 /* free the blocks. */
413 if ((rc = dbFreeDmap(bmp, dp, blkno, nb))) { 380 if ((rc = dbFreeDmap(bmp, dp, blkno, nb))) {
414 release_metapage(mp); 381 release_metapage(mp);
415 IREAD_UNLOCK(ipbmap); 382 IREAD_UNLOCK(ipbmap);
416 return (rc); 383 return (rc);
417 } 384 }
418
419 DBFREE(bmp->db_DBmap, bmp->db_mapsize, blkno, nb);
420 } 385 }
421 386
422 /* write the last buffer. */ 387 /* write the last buffer. */
@@ -775,10 +740,6 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
775 IWRITE_LOCK(ipbmap); 740 IWRITE_LOCK(ipbmap);
776 741
777 rc = dbAllocAny(bmp, nblocks, l2nb, results); 742 rc = dbAllocAny(bmp, nblocks, l2nb, results);
778 if (rc == 0) {
779 DBALLOC(bmp->db_DBmap, bmp->db_mapsize, *results,
780 nblocks);
781 }
782 743
783 goto write_unlock; 744 goto write_unlock;
784 } 745 }
@@ -836,8 +797,6 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
836 != -ENOSPC) { 797 != -ENOSPC) {
837 if (rc == 0) { 798 if (rc == 0) {
838 *results = blkno; 799 *results = blkno;
839 DBALLOC(bmp->db_DBmap, bmp->db_mapsize,
840 *results, nblocks);
841 mark_metapage_dirty(mp); 800 mark_metapage_dirty(mp);
842 } 801 }
843 802
@@ -863,11 +822,8 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
863 if ((rc = 822 if ((rc =
864 dbAllocNear(bmp, dp, blkno, (int) nblocks, l2nb, results)) 823 dbAllocNear(bmp, dp, blkno, (int) nblocks, l2nb, results))
865 != -ENOSPC) { 824 != -ENOSPC) {
866 if (rc == 0) { 825 if (rc == 0)
867 DBALLOC(bmp->db_DBmap, bmp->db_mapsize,
868 *results, nblocks);
869 mark_metapage_dirty(mp); 826 mark_metapage_dirty(mp);
870 }
871 827
872 release_metapage(mp); 828 release_metapage(mp);
873 goto read_unlock; 829 goto read_unlock;
@@ -878,11 +834,8 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
878 */ 834 */
879 if ((rc = dbAllocDmapLev(bmp, dp, (int) nblocks, l2nb, results)) 835 if ((rc = dbAllocDmapLev(bmp, dp, (int) nblocks, l2nb, results))
880 != -ENOSPC) { 836 != -ENOSPC) {
881 if (rc == 0) { 837 if (rc == 0)
882 DBALLOC(bmp->db_DBmap, bmp->db_mapsize,
883 *results, nblocks);
884 mark_metapage_dirty(mp); 838 mark_metapage_dirty(mp);
885 }
886 839
887 release_metapage(mp); 840 release_metapage(mp);
888 goto read_unlock; 841 goto read_unlock;
@@ -896,13 +849,9 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
896 * the same allocation group as the hint. 849 * the same allocation group as the hint.
897 */ 850 */
898 IWRITE_LOCK(ipbmap); 851 IWRITE_LOCK(ipbmap);
899 if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) 852 if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) != -ENOSPC)
900 != -ENOSPC) {
901 if (rc == 0)
902 DBALLOC(bmp->db_DBmap, bmp->db_mapsize,
903 *results, nblocks);
904 goto write_unlock; 853 goto write_unlock;
905 } 854
906 IWRITE_UNLOCK(ipbmap); 855 IWRITE_UNLOCK(ipbmap);
907 856
908 857
@@ -918,9 +867,6 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results)
918 */ 867 */
919 if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) == -ENOSPC) 868 if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) == -ENOSPC)
920 rc = dbAllocAny(bmp, nblocks, l2nb, results); 869 rc = dbAllocAny(bmp, nblocks, l2nb, results);
921 if (rc == 0) {
922 DBALLOC(bmp->db_DBmap, bmp->db_mapsize, *results, nblocks);
923 }
924 870
925 write_unlock: 871 write_unlock:
926 IWRITE_UNLOCK(ipbmap); 872 IWRITE_UNLOCK(ipbmap);
@@ -992,10 +938,9 @@ int dbAllocExact(struct inode *ip, s64 blkno, int nblocks)
992 938
993 IREAD_UNLOCK(ipbmap); 939 IREAD_UNLOCK(ipbmap);
994 940
995 if (rc == 0) { 941 if (rc == 0)
996 DBALLOC(bmp->db_DBmap, bmp->db_mapsize, blkno, nblocks);
997 mark_metapage_dirty(mp); 942 mark_metapage_dirty(mp);
998 } 943
999 release_metapage(mp); 944 release_metapage(mp);
1000 945
1001 return (rc); 946 return (rc);
@@ -1144,7 +1089,6 @@ static int dbExtend(struct inode *ip, s64 blkno, s64 nblocks, s64 addnblocks)
1144 return -EIO; 1089 return -EIO;
1145 } 1090 }
1146 1091
1147 DBALLOCCK(bmp->db_DBmap, bmp->db_mapsize, blkno, nblocks);
1148 dp = (struct dmap *) mp->data; 1092 dp = (struct dmap *) mp->data;
1149 1093
1150 /* try to allocate the blocks immediately following the 1094 /* try to allocate the blocks immediately following the
@@ -1155,11 +1099,9 @@ static int dbExtend(struct inode *ip, s64 blkno, s64 nblocks, s64 addnblocks)
1155 IREAD_UNLOCK(ipbmap); 1099 IREAD_UNLOCK(ipbmap);
1156 1100
1157 /* were we successful ? */ 1101 /* were we successful ? */
1158 if (rc == 0) { 1102 if (rc == 0)
1159 DBALLOC(bmp->db_DBmap, bmp->db_mapsize, extblkno,
1160 addnblocks);
1161 write_metapage(mp); 1103 write_metapage(mp);
1162 } else 1104 else
1163 /* we were not successful */ 1105 /* we were not successful */
1164 release_metapage(mp); 1106 release_metapage(mp);
1165 1107
@@ -3185,16 +3127,12 @@ int dbAllocBottomUp(struct inode *ip, s64 blkno, s64 nblocks)
3185 */ 3127 */
3186 nb = min(rem, BPERDMAP - (blkno & (BPERDMAP - 1))); 3128 nb = min(rem, BPERDMAP - (blkno & (BPERDMAP - 1)));
3187 3129
3188 DBFREECK(bmp->db_DBmap, bmp->db_mapsize, blkno, nb);
3189
3190 /* allocate the blocks. */ 3130 /* allocate the blocks. */
3191 if ((rc = dbAllocDmapBU(bmp, dp, blkno, nb))) { 3131 if ((rc = dbAllocDmapBU(bmp, dp, blkno, nb))) {
3192 release_metapage(mp); 3132 release_metapage(mp);
3193 IREAD_UNLOCK(ipbmap); 3133 IREAD_UNLOCK(ipbmap);
3194 return (rc); 3134 return (rc);
3195 } 3135 }
3196
3197 DBALLOC(bmp->db_DBmap, bmp->db_mapsize, blkno, nb);
3198 } 3136 }
3199 3137
3200 /* write the last buffer. */ 3138 /* write the last buffer. */
@@ -4041,223 +3979,3 @@ s64 dbMapFileSizeToMapSize(struct inode * ipbmap)
4041 3979
4042 return (nblocks); 3980 return (nblocks);
4043} 3981}
4044
4045
4046#ifdef _JFS_DEBUG_DMAP
4047/*
4048 * DBinitmap()
4049 */
4050static void DBinitmap(s64 size, struct inode *ipbmap, u32 ** results)
4051{
4052 int npages;
4053 u32 *dbmap, *d;
4054 int n;
4055 s64 lblkno, cur_block;
4056 struct dmap *dp;
4057 struct metapage *mp;
4058
4059 npages = size / 32768;
4060 npages += (size % 32768) ? 1 : 0;
4061
4062 dbmap = (u32 *) xmalloc(npages * 4096, L2PSIZE, kernel_heap);
4063 if (dbmap == NULL)
4064 BUG(); /* Not robust since this is only unused debug code */
4065
4066 for (n = 0, d = dbmap; n < npages; n++, d += 1024)
4067 bzero(d, 4096);
4068
4069 /* Need to initialize from disk map pages
4070 */
4071 for (d = dbmap, cur_block = 0; cur_block < size;
4072 cur_block += BPERDMAP, d += LPERDMAP) {
4073 lblkno = BLKTODMAP(cur_block,
4074 JFS_SBI(ipbmap->i_sb)->bmap->
4075 db_l2nbperpage);
4076 mp = read_metapage(ipbmap, lblkno, PSIZE, 0);
4077 if (mp == NULL) {
4078 jfs_error(ipbmap->i_sb,
4079 "DBinitmap: could not read disk map page");
4080 continue;
4081 }
4082 dp = (struct dmap *) mp->data;
4083
4084 for (n = 0; n < LPERDMAP; n++)
4085 d[n] = le32_to_cpu(dp->wmap[n]);
4086
4087 release_metapage(mp);
4088 }
4089
4090 *results = dbmap;
4091}
4092
4093
4094/*
4095 * DBAlloc()
4096 */
4097void DBAlloc(uint * dbmap, s64 mapsize, s64 blkno, s64 nblocks)
4098{
4099 int word, nb, bitno;
4100 u32 mask;
4101
4102 assert(blkno > 0 && blkno < mapsize);
4103 assert(nblocks > 0 && nblocks <= mapsize);
4104
4105 assert(blkno + nblocks <= mapsize);
4106
4107 dbmap += (blkno / 32);
4108 while (nblocks > 0) {
4109 bitno = blkno & (32 - 1);
4110 nb = min(nblocks, 32 - bitno);
4111
4112 mask = (0xffffffff << (32 - nb) >> bitno);
4113 assert((mask & *dbmap) == 0);
4114 *dbmap |= mask;
4115
4116 dbmap++;
4117 blkno += nb;
4118 nblocks -= nb;
4119 }
4120}
4121
4122
4123/*
4124 * DBFree()
4125 */
4126static void DBFree(uint * dbmap, s64 mapsize, s64 blkno, s64 nblocks)
4127{
4128 int word, nb, bitno;
4129 u32 mask;
4130
4131 assert(blkno > 0 && blkno < mapsize);
4132 assert(nblocks > 0 && nblocks <= mapsize);
4133
4134 assert(blkno + nblocks <= mapsize);
4135
4136 dbmap += (blkno / 32);
4137 while (nblocks > 0) {
4138 bitno = blkno & (32 - 1);
4139 nb = min(nblocks, 32 - bitno);
4140
4141 mask = (0xffffffff << (32 - nb) >> bitno);
4142 assert((mask & *dbmap) == mask);
4143 *dbmap &= ~mask;
4144
4145 dbmap++;
4146 blkno += nb;
4147 nblocks -= nb;
4148 }
4149}
4150
4151
4152/*
4153 * DBAllocCK()
4154 */
4155static void DBAllocCK(uint * dbmap, s64 mapsize, s64 blkno, s64 nblocks)
4156{
4157 int word, nb, bitno;
4158 u32 mask;
4159
4160 assert(blkno > 0 && blkno < mapsize);
4161 assert(nblocks > 0 && nblocks <= mapsize);
4162
4163 assert(blkno + nblocks <= mapsize);
4164
4165 dbmap += (blkno / 32);
4166 while (nblocks > 0) {
4167 bitno = blkno & (32 - 1);
4168 nb = min(nblocks, 32 - bitno);
4169
4170 mask = (0xffffffff << (32 - nb) >> bitno);
4171 assert((mask & *dbmap) == mask);
4172
4173 dbmap++;
4174 blkno += nb;
4175 nblocks -= nb;
4176 }
4177}
4178
4179
4180/*
4181 * DBFreeCK()
4182 */
4183static void DBFreeCK(uint * dbmap, s64 mapsize, s64 blkno, s64 nblocks)
4184{
4185 int word, nb, bitno;
4186 u32 mask;
4187
4188 assert(blkno > 0 && blkno < mapsize);
4189 assert(nblocks > 0 && nblocks <= mapsize);
4190
4191 assert(blkno + nblocks <= mapsize);
4192
4193 dbmap += (blkno / 32);
4194 while (nblocks > 0) {
4195 bitno = blkno & (32 - 1);
4196 nb = min(nblocks, 32 - bitno);
4197
4198 mask = (0xffffffff << (32 - nb) >> bitno);
4199 assert((mask & *dbmap) == 0);
4200
4201 dbmap++;
4202 blkno += nb;
4203 nblocks -= nb;
4204 }
4205}
4206
4207
4208/*
4209 * dbPrtMap()
4210 */
4211static void dbPrtMap(struct bmap * bmp)
4212{
4213 printk(" mapsize: %d%d\n", bmp->db_mapsize);
4214 printk(" nfree: %d%d\n", bmp->db_nfree);
4215 printk(" numag: %d\n", bmp->db_numag);
4216 printk(" agsize: %d%d\n", bmp->db_agsize);
4217 printk(" agl2size: %d\n", bmp->db_agl2size);
4218 printk(" agwidth: %d\n", bmp->db_agwidth);
4219 printk(" agstart: %d\n", bmp->db_agstart);
4220 printk(" agheigth: %d\n", bmp->db_agheigth);
4221 printk(" aglevel: %d\n", bmp->db_aglevel);
4222 printk(" maxlevel: %d\n", bmp->db_maxlevel);
4223 printk(" maxag: %d\n", bmp->db_maxag);
4224 printk(" agpref: %d\n", bmp->db_agpref);
4225 printk(" l2nbppg: %d\n", bmp->db_l2nbperpage);
4226}
4227
4228
4229/*
4230 * dbPrtCtl()
4231 */
4232static void dbPrtCtl(struct dmapctl * dcp)
4233{
4234 int i, j, n;
4235
4236 printk(" height: %08x\n", le32_to_cpu(dcp->height));
4237 printk(" leafidx: %08x\n", le32_to_cpu(dcp->leafidx));
4238 printk(" budmin: %08x\n", dcp->budmin);
4239 printk(" nleafs: %08x\n", le32_to_cpu(dcp->nleafs));
4240 printk(" l2nleafs: %08x\n", le32_to_cpu(dcp->l2nleafs));
4241
4242 printk("\n Tree:\n");
4243 for (i = 0; i < CTLLEAFIND; i += 8) {
4244 n = min(8, CTLLEAFIND - i);
4245
4246 for (j = 0; j < n; j++)
4247 printf(" [%03x]: %02x", i + j,
4248 (char) dcp->stree[i + j]);
4249 printf("\n");
4250 }
4251
4252 printk("\n Tree Leaves:\n");
4253 for (i = 0; i < LPERCTL; i += 8) {
4254 n = min(8, LPERCTL - i);
4255
4256 for (j = 0; j < n; j++)
4257 printf(" [%03x]: %02x",
4258 i + j,
4259 (char) dcp->stree[i + j + CTLLEAFIND]);
4260 printf("\n");
4261 }
4262}
4263#endif /* _JFS_DEBUG_DMAP */
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 8676aee3ae48..73b5fc7eda80 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -4554,202 +4554,3 @@ int dtModify(tid_t tid, struct inode *ip,
4554 4554
4555 return 0; 4555 return 0;
4556} 4556}
4557
4558#ifdef _JFS_DEBUG_DTREE
4559/*
4560 * dtDisplayTree()
4561 *
4562 * function: traverse forward
4563 */
4564int dtDisplayTree(struct inode *ip)
4565{
4566 int rc;
4567 struct metapage *mp;
4568 dtpage_t *p;
4569 s64 bn, pbn;
4570 int index, lastindex, v, h;
4571 pxd_t *xd;
4572 struct btstack btstack;
4573 struct btframe *btsp;
4574 struct btframe *parent;
4575 u8 *stbl;
4576 int psize = 256;
4577
4578 printk("display B+-tree.\n");
4579
4580 /* clear stack */
4581 btsp = btstack.stack;
4582
4583 /*
4584 * start with root
4585 *
4586 * root resides in the inode
4587 */
4588 bn = 0;
4589 v = h = 0;
4590
4591 /*
4592 * first access of each page:
4593 */
4594 newPage:
4595 DT_GETPAGE(ip, bn, mp, psize, p, rc);
4596 if (rc)
4597 return rc;
4598
4599 /* process entries forward from first index */
4600 index = 0;
4601 lastindex = p->header.nextindex - 1;
4602
4603 if (p->header.flag & BT_INTERNAL) {
4604 /*
4605 * first access of each internal page
4606 */
4607 printf("internal page ");
4608 dtDisplayPage(ip, bn, p);
4609
4610 goto getChild;
4611 } else { /* (p->header.flag & BT_LEAF) */
4612
4613 /*
4614 * first access of each leaf page
4615 */
4616 printf("leaf page ");
4617 dtDisplayPage(ip, bn, p);
4618
4619 /*
4620 * process leaf page entries
4621 *
4622 for ( ; index <= lastindex; index++)
4623 {
4624 }
4625 */
4626
4627 /* unpin the leaf page */
4628 DT_PUTPAGE(mp);
4629 }
4630
4631 /*
4632 * go back up to the parent page
4633 */
4634 getParent:
4635 /* pop/restore parent entry for the current child page */
4636 if ((parent = (btsp == btstack.stack ? NULL : --btsp)) == NULL)
4637 /* current page must have been root */
4638 return;
4639
4640 /*
4641 * parent page scan completed
4642 */
4643 if ((index = parent->index) == (lastindex = parent->lastindex)) {
4644 /* go back up to the parent page */
4645 goto getParent;
4646 }
4647
4648 /*
4649 * parent page has entries remaining
4650 */
4651 /* get back the parent page */
4652 bn = parent->bn;
4653 /* v = parent->level; */
4654 DT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
4655 if (rc)
4656 return rc;
4657
4658 /* get next parent entry */
4659 index++;
4660
4661 /*
4662 * internal page: go down to child page of current entry
4663 */
4664 getChild:
4665 /* push/save current parent entry for the child page */
4666 btsp->bn = pbn = bn;
4667 btsp->index = index;
4668 btsp->lastindex = lastindex;
4669 /* btsp->level = v; */
4670 /* btsp->node = h; */
4671 ++btsp;
4672
4673 /* get current entry for the child page */
4674 stbl = DT_GETSTBL(p);
4675 xd = (pxd_t *) & p->slot[stbl[index]];
4676
4677 /*
4678 * first access of each internal entry:
4679 */
4680
4681 /* get child page */
4682 bn = addressPXD(xd);
4683 psize = lengthPXD(xd) << ip->i_ipmnt->i_l2bsize;
4684
4685 printk("traverse down 0x%Lx[%d]->0x%Lx\n", pbn, index, bn);
4686 v++;
4687 h = index;
4688
4689 /* release parent page */
4690 DT_PUTPAGE(mp);
4691
4692 /* process the child page */
4693 goto newPage;
4694}
4695
4696
4697/*
4698 * dtDisplayPage()
4699 *
4700 * function: display page
4701 */
4702int dtDisplayPage(struct inode *ip, s64 bn, dtpage_t * p)
4703{
4704 int rc;
4705 struct metapage *mp;
4706 struct ldtentry *lh;
4707 struct idtentry *ih;
4708 pxd_t *xd;
4709 int i, j;
4710 u8 *stbl;
4711 wchar_t name[JFS_NAME_MAX + 1];
4712 struct component_name key = { 0, name };
4713 int freepage = 0;
4714
4715 if (p == NULL) {
4716 freepage = 1;
4717 DT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
4718 if (rc)
4719 return rc;
4720 }
4721
4722 /* display page control */
4723 printk("bn:0x%Lx flag:0x%08x nextindex:%d\n",
4724 bn, p->header.flag, p->header.nextindex);
4725
4726 /* display entries */
4727 stbl = DT_GETSTBL(p);
4728 for (i = 0, j = 1; i < p->header.nextindex; i++, j++) {
4729 dtGetKey(p, i, &key, JFS_SBI(ip->i_sb)->mntflag);
4730 key.name[key.namlen] = '\0';
4731 if (p->header.flag & BT_LEAF) {
4732 lh = (struct ldtentry *) & p->slot[stbl[i]];
4733 printf("\t[%d] %s:%d", i, key.name,
4734 le32_to_cpu(lh->inumber));
4735 } else {
4736 ih = (struct idtentry *) & p->slot[stbl[i]];
4737 xd = (pxd_t *) ih;
4738 bn = addressPXD(xd);
4739 printf("\t[%d] %s:0x%Lx", i, key.name, bn);
4740 }
4741
4742 if (j == 4) {
4743 printf("\n");
4744 j = 0;
4745 }
4746 }
4747
4748 printf("\n");
4749
4750 if (freepage)
4751 DT_PUTPAGE(mp);
4752
4753 return 0;
4754}
4755#endif /* _JFS_DEBUG_DTREE */
diff --git a/fs/jfs/jfs_dtree.h b/fs/jfs/jfs_dtree.h
index 273a80130c9d..13e4fdf07724 100644
--- a/fs/jfs/jfs_dtree.h
+++ b/fs/jfs/jfs_dtree.h
@@ -269,11 +269,4 @@ extern int dtModify(tid_t tid, struct inode *ip, struct component_name * key,
269 ino_t * orig_ino, ino_t new_ino, int flag); 269 ino_t * orig_ino, ino_t new_ino, int flag);
270 270
271extern int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir); 271extern int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir);
272
273#ifdef _JFS_DEBUG_DTREE
274extern int dtDisplayTree(struct inode *ip);
275
276extern int dtDisplayPage(struct inode *ip, s64 bn, dtpage_t * p);
277#endif /* _JFS_DEBUG_DTREE */
278
279#endif /* !_H_JFS_DTREE */ 272#endif /* !_H_JFS_DTREE */
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index 971af2977eff..4021d46da7e3 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -87,25 +87,6 @@ static int copy_from_dinode(struct dinode *, struct inode *);
87static void copy_to_dinode(struct dinode *, struct inode *); 87static void copy_to_dinode(struct dinode *, struct inode *);
88 88
89/* 89/*
90 * debug code for double-checking inode map
91 */
92/* #define _JFS_DEBUG_IMAP 1 */
93
94#ifdef _JFS_DEBUG_IMAP
95#define DBG_DIINIT(imap) DBGdiInit(imap)
96#define DBG_DIALLOC(imap, ino) DBGdiAlloc(imap, ino)
97#define DBG_DIFREE(imap, ino) DBGdiFree(imap, ino)
98
99static void *DBGdiInit(struct inomap * imap);
100static void DBGdiAlloc(struct inomap * imap, ino_t ino);
101static void DBGdiFree(struct inomap * imap, ino_t ino);
102#else
103#define DBG_DIINIT(imap)
104#define DBG_DIALLOC(imap, ino)
105#define DBG_DIFREE(imap, ino)
106#endif /* _JFS_DEBUG_IMAP */
107
108/*
109 * NAME: diMount() 90 * NAME: diMount()
110 * 91 *
111 * FUNCTION: initialize the incore inode map control structures for 92 * FUNCTION: initialize the incore inode map control structures for
@@ -188,8 +169,6 @@ int diMount(struct inode *ipimap)
188 imap->im_ipimap = ipimap; 169 imap->im_ipimap = ipimap;
189 JFS_IP(ipimap)->i_imap = imap; 170 JFS_IP(ipimap)->i_imap = imap;
190 171
191// DBG_DIINIT(imap);
192
193 return (0); 172 return (0);
194} 173}
195 174
@@ -1043,7 +1022,6 @@ int diFree(struct inode *ip)
1043 /* update the bitmap. 1022 /* update the bitmap.
1044 */ 1023 */
1045 iagp->wmap[extno] = cpu_to_le32(bitmap); 1024 iagp->wmap[extno] = cpu_to_le32(bitmap);
1046 DBG_DIFREE(imap, inum);
1047 1025
1048 /* update the free inode counts at the iag, ag and 1026 /* update the free inode counts at the iag, ag and
1049 * map level. 1027 * map level.
@@ -1231,7 +1209,6 @@ int diFree(struct inode *ip)
1231 jfs_error(ip->i_sb, "diFree: the pmap does not show inode free"); 1209 jfs_error(ip->i_sb, "diFree: the pmap does not show inode free");
1232 } 1210 }
1233 iagp->wmap[extno] = 0; 1211 iagp->wmap[extno] = 0;
1234 DBG_DIFREE(imap, inum);
1235 PXDlength(&iagp->inoext[extno], 0); 1212 PXDlength(&iagp->inoext[extno], 0);
1236 PXDaddress(&iagp->inoext[extno], 0); 1213 PXDaddress(&iagp->inoext[extno], 0);
1237 1214
@@ -1350,7 +1327,6 @@ diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp)
1350 struct jfs_inode_info *jfs_ip = JFS_IP(ip); 1327 struct jfs_inode_info *jfs_ip = JFS_IP(ip);
1351 1328
1352 ip->i_ino = (iagno << L2INOSPERIAG) + ino; 1329 ip->i_ino = (iagno << L2INOSPERIAG) + ino;
1353 DBG_DIALLOC(JFS_IP(ipimap)->i_imap, ip->i_ino);
1354 jfs_ip->ixpxd = iagp->inoext[extno]; 1330 jfs_ip->ixpxd = iagp->inoext[extno];
1355 jfs_ip->agno = BLKTOAG(le64_to_cpu(iagp->agstart), sbi); 1331 jfs_ip->agno = BLKTOAG(le64_to_cpu(iagp->agstart), sbi);
1356 jfs_ip->active_ag = -1; 1332 jfs_ip->active_ag = -1;
@@ -3185,84 +3161,3 @@ static void copy_to_dinode(struct dinode * dip, struct inode *ip)
3185 if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode)) 3161 if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode))
3186 dip->di_rdev = cpu_to_le32(jfs_ip->dev); 3162 dip->di_rdev = cpu_to_le32(jfs_ip->dev);
3187} 3163}
3188
3189#ifdef _JFS_DEBUG_IMAP
3190/*
3191 * DBGdiInit()
3192 */
3193static void *DBGdiInit(struct inomap * imap)
3194{
3195 u32 *dimap;
3196 int size;
3197 size = 64 * 1024;
3198 if ((dimap = (u32 *) xmalloc(size, L2PSIZE, kernel_heap)) == NULL)
3199 assert(0);
3200 bzero((void *) dimap, size);
3201 imap->im_DBGdimap = dimap;
3202}
3203
3204/*
3205 * DBGdiAlloc()
3206 */
3207static void DBGdiAlloc(struct inomap * imap, ino_t ino)
3208{
3209 u32 *dimap = imap->im_DBGdimap;
3210 int w, b;
3211 u32 m;
3212 w = ino >> 5;
3213 b = ino & 31;
3214 m = 0x80000000 >> b;
3215 assert(w < 64 * 256);
3216 if (dimap[w] & m) {
3217 printk("DEBUG diAlloc: duplicate alloc ino:0x%x\n", ino);
3218 }
3219 dimap[w] |= m;
3220}
3221
3222/*
3223 * DBGdiFree()
3224 */
3225static void DBGdiFree(struct inomap * imap, ino_t ino)
3226{
3227 u32 *dimap = imap->im_DBGdimap;
3228 int w, b;
3229 u32 m;
3230 w = ino >> 5;
3231 b = ino & 31;
3232 m = 0x80000000 >> b;
3233 assert(w < 64 * 256);
3234 if ((dimap[w] & m) == 0) {
3235 printk("DEBUG diFree: duplicate free ino:0x%x\n", ino);
3236 }
3237 dimap[w] &= ~m;
3238}
3239
3240static void dump_cp(struct inomap * ipimap, char *function, int line)
3241{
3242 printk("\n* ********* *\nControl Page %s %d\n", function, line);
3243 printk("FreeIAG %d\tNextIAG %d\n", ipimap->im_freeiag,
3244 ipimap->im_nextiag);
3245 printk("NumInos %d\tNumFree %d\n",
3246 atomic_read(&ipimap->im_numinos),
3247 atomic_read(&ipimap->im_numfree));
3248 printk("AG InoFree %d\tAG ExtFree %d\n",
3249 ipimap->im_agctl[0].inofree, ipimap->im_agctl[0].extfree);
3250 printk("AG NumInos %d\tAG NumFree %d\n",
3251 ipimap->im_agctl[0].numinos, ipimap->im_agctl[0].numfree);
3252}
3253
3254static void dump_iag(struct iag * iag, char *function, int line)
3255{
3256 printk("\n* ********* *\nIAG %s %d\n", function, line);
3257 printk("IagNum %d\tIAG Free %d\n", le32_to_cpu(iag->iagnum),
3258 le32_to_cpu(iag->iagfree));
3259 printk("InoFreeFwd %d\tInoFreeBack %d\n",
3260 le32_to_cpu(iag->inofreefwd),
3261 le32_to_cpu(iag->inofreeback));
3262 printk("ExtFreeFwd %d\tExtFreeBack %d\n",
3263 le32_to_cpu(iag->extfreefwd),
3264 le32_to_cpu(iag->extfreeback));
3265 printk("NFreeInos %d\tNFreeExts %d\n", le32_to_cpu(iag->nfreeinos),
3266 le32_to_cpu(iag->nfreeexts));
3267}
3268#endif /* _JFS_DEBUG_IMAP */
diff --git a/fs/jfs/jfs_unicode.c b/fs/jfs/jfs_unicode.c
index b32208aad550..f327decfb155 100644
--- a/fs/jfs/jfs_unicode.c
+++ b/fs/jfs/jfs_unicode.c
@@ -51,8 +51,9 @@ int jfs_strfromUCS_le(char *to, const __le16 * from,
51 } 51 }
52 } else { 52 } else {
53 for (i = 0; (i < len) && from[i]; i++) { 53 for (i = 0; (i < len) && from[i]; i++) {
54 if (le16_to_cpu(from[i]) & 0xff00) { 54 if (unlikely(le16_to_cpu(from[i]) & 0xff00)) {
55 if (warn) { 55 to[i] = '?';
56 if (unlikely(warn)) {
56 warn--; 57 warn--;
57 warn_again--; 58 warn_again--;
58 printk(KERN_ERR 59 printk(KERN_ERR
@@ -61,7 +62,7 @@ int jfs_strfromUCS_le(char *to, const __le16 * from,
61 printk(KERN_ERR 62 printk(KERN_ERR
62 "mount with iocharset=utf8 to access\n"); 63 "mount with iocharset=utf8 to access\n");
63 } 64 }
64 to[i] = '?'; 65
65 } 66 }
66 else 67 else
67 to[i] = (char) (le16_to_cpu(from[i])); 68 to[i] = (char) (le16_to_cpu(from[i]));
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c
index 31b34db4519e..a7fe2f2b969f 100644
--- a/fs/jfs/jfs_xtree.c
+++ b/fs/jfs/jfs_xtree.c
@@ -135,14 +135,6 @@ static int xtSearchNode(struct inode *ip,
135static int xtRelink(tid_t tid, struct inode *ip, xtpage_t * fp); 135static int xtRelink(tid_t tid, struct inode *ip, xtpage_t * fp);
136#endif /* _STILL_TO_PORT */ 136#endif /* _STILL_TO_PORT */
137 137
138/* External references */
139
140/*
141 * debug control
142 */
143/* #define _JFS_DEBUG_XTREE 1 */
144
145
146/* 138/*
147 * xtLookup() 139 * xtLookup()
148 * 140 *
@@ -4140,338 +4132,6 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size)
4140 return 0; 4132 return 0;
4141} 4133}
4142 4134
4143
4144#ifdef _JFS_DEBUG_XTREE
4145/*
4146 * xtDisplayTree()
4147 *
4148 * function: traverse forward
4149 */
4150int xtDisplayTree(struct inode *ip)
4151{
4152 int rc = 0;
4153 struct metapage *mp;
4154 xtpage_t *p;
4155 s64 bn, pbn;
4156 int index, lastindex, v, h;
4157 xad_t *xad;
4158 struct btstack btstack;
4159 struct btframe *btsp;
4160 struct btframe *parent;
4161
4162 printk("display B+-tree.\n");
4163
4164 /* clear stack */
4165 btsp = btstack.stack;
4166
4167 /*
4168 * start with root
4169 *
4170 * root resides in the inode
4171 */
4172 bn = 0;
4173 v = h = 0;
4174
4175 /*
4176 * first access of each page:
4177 */
4178 getPage:
4179 XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
4180 if (rc)
4181 return rc;
4182
4183 /* process entries forward from first index */
4184 index = XTENTRYSTART;
4185 lastindex = le16_to_cpu(p->header.nextindex) - 1;
4186
4187 if (p->header.flag & BT_INTERNAL) {
4188 /*
4189 * first access of each internal page
4190 */
4191 goto getChild;
4192 } else { /* (p->header.flag & BT_LEAF) */
4193
4194 /*
4195 * first access of each leaf page
4196 */
4197 printf("leaf page ");
4198 xtDisplayPage(ip, bn, p);
4199
4200 /* unpin the leaf page */
4201 XT_PUTPAGE(mp);
4202 }
4203
4204 /*
4205 * go back up to the parent page
4206 */
4207 getParent:
4208 /* pop/restore parent entry for the current child page */
4209 if ((parent = (btsp == btstack.stack ? NULL : --btsp)) == NULL)
4210 /* current page must have been root */
4211 return;
4212
4213 /*
4214 * parent page scan completed
4215 */
4216 if ((index = parent->index) == (lastindex = parent->lastindex)) {
4217 /* go back up to the parent page */
4218 goto getParent;
4219 }
4220
4221 /*
4222 * parent page has entries remaining
4223 */
4224 /* get back the parent page */
4225 bn = parent->bn;
4226 /* v = parent->level; */
4227 XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
4228 if (rc)
4229 return rc;
4230
4231 /* get next parent entry */
4232 index++;
4233
4234 /*
4235 * internal page: go down to child page of current entry
4236 */
4237 getChild:
4238 /* push/save current parent entry for the child page */
4239 btsp->bn = pbn = bn;
4240 btsp->index = index;
4241 btsp->lastindex = lastindex;
4242 /* btsp->level = v; */
4243 /* btsp->node = h; */
4244 ++btsp;
4245
4246 /* get child page */
4247 xad = &p->xad[index];
4248 bn = addressXAD(xad);
4249
4250 /*
4251 * first access of each internal entry:
4252 */
4253 /* release parent page */
4254 XT_PUTPAGE(mp);
4255
4256 printk("traverse down 0x%lx[%d]->0x%lx\n", (ulong) pbn, index,
4257 (ulong) bn);
4258 v++;
4259 h = index;
4260
4261 /* process the child page */
4262 goto getPage;
4263}
4264
4265
4266/*
4267 * xtDisplayPage()
4268 *
4269 * function: display page
4270 */
4271int xtDisplayPage(struct inode *ip, s64 bn, xtpage_t * p)
4272{
4273 int rc = 0;
4274 xad_t *xad;
4275 s64 xaddr, xoff;
4276 int xlen, i, j;
4277
4278 /* display page control */
4279 printf("bn:0x%lx flag:0x%x nextindex:%d\n",
4280 (ulong) bn, p->header.flag,
4281 le16_to_cpu(p->header.nextindex));
4282
4283 /* display entries */
4284 xad = &p->xad[XTENTRYSTART];
4285 for (i = XTENTRYSTART, j = 1; i < le16_to_cpu(p->header.nextindex);
4286 i++, xad++, j++) {
4287 xoff = offsetXAD(xad);
4288 xaddr = addressXAD(xad);
4289 xlen = lengthXAD(xad);
4290 printf("\t[%d] 0x%lx:0x%lx(0x%x)", i, (ulong) xoff,
4291 (ulong) xaddr, xlen);
4292
4293 if (j == 4) {
4294 printf("\n");
4295 j = 0;
4296 }
4297 }
4298
4299 printf("\n");
4300}
4301#endif /* _JFS_DEBUG_XTREE */
4302
4303
4304#ifdef _JFS_WIP
4305/*
4306 * xtGather()
4307 *
4308 * function:
4309 * traverse for allocation acquiring tlock at commit time
4310 * (vs at the time of update) logging backward top down
4311 *
4312 * note:
4313 * problem - establishing that all new allocation have been
4314 * processed both for append and random write in sparse file
4315 * at the current entry at the current subtree root page
4316 *
4317 */
4318int xtGather(btree_t *t)
4319{
4320 int rc = 0;
4321 xtpage_t *p;
4322 u64 bn;
4323 int index;
4324 btentry_t *e;
4325 struct btstack btstack;
4326 struct btsf *parent;
4327
4328 /* clear stack */
4329 BT_CLR(&btstack);
4330
4331 /*
4332 * start with root
4333 *
4334 * root resides in the inode
4335 */
4336 bn = 0;
4337 XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
4338 if (rc)
4339 return rc;
4340
4341 /* new root is NOT pointed by a new entry
4342 if (p->header.flag & NEW)
4343 allocate new page lock;
4344 write a NEWPAGE log;
4345 */
4346
4347 dopage:
4348 /*
4349 * first access of each page:
4350 */
4351 /* process entries backward from last index */
4352 index = le16_to_cpu(p->header.nextindex) - 1;
4353
4354 if (p->header.flag & BT_LEAF) {
4355 /*
4356 * first access of each leaf page
4357 */
4358 /* process leaf page entries backward */
4359 for (; index >= XTENTRYSTART; index--) {
4360 e = &p->xad[index];
4361 /*
4362 * if newpage, log NEWPAGE.
4363 *
4364 if (e->flag & XAD_NEW) {
4365 nfound =+ entry->length;
4366 update current page lock for the entry;
4367 newpage(entry);
4368 *
4369 * if moved, log move.
4370 *
4371 } else if (e->flag & XAD_MOVED) {
4372 reset flag;
4373 update current page lock for the entry;
4374 }
4375 */
4376 }
4377
4378 /* unpin the leaf page */
4379 XT_PUTPAGE(mp);
4380
4381 /*
4382 * go back up to the parent page
4383 */
4384 getParent:
4385 /* restore parent entry for the current child page */
4386 if ((parent = BT_POP(&btstack)) == NULL)
4387 /* current page must have been root */
4388 return 0;
4389
4390 if ((index = parent->index) == XTENTRYSTART) {
4391 /*
4392 * parent page scan completed
4393 */
4394 /* go back up to the parent page */
4395 goto getParent;
4396 } else {
4397 /*
4398 * parent page has entries remaining
4399 */
4400 /* get back the parent page */
4401 bn = parent->bn;
4402 XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
4403 if (rc)
4404 return -EIO;
4405
4406 /* first subroot page which
4407 * covers all new allocated blocks
4408 * itself not new/modified.
4409 * (if modified from split of descendent,
4410 * go down path of split page)
4411
4412 if (nfound == nnew &&
4413 !(p->header.flag & (NEW | MOD)))
4414 exit scan;
4415 */
4416
4417 /* process parent page entries backward */
4418 index--;
4419 }
4420 } else {
4421 /*
4422 * first access of each internal page
4423 */
4424 }
4425
4426 /*
4427 * internal page: go down to child page of current entry
4428 */
4429
4430 /* save current parent entry for the child page */
4431 BT_PUSH(&btstack, bn, index);
4432
4433 /* get current entry for the child page */
4434 e = &p->xad[index];
4435
4436 /*
4437 * first access of each internal entry:
4438 */
4439 /*
4440 * if new entry, log btree_tnewentry.
4441 *
4442 if (e->flag & XAD_NEW)
4443 update parent page lock for the entry;
4444 */
4445
4446 /* release parent page */
4447 XT_PUTPAGE(mp);
4448
4449 /* get child page */
4450 bn = e->bn;
4451 XT_GETPAGE(ip, bn, mp, PSIZE, p, rc);
4452 if (rc)
4453 return rc;
4454
4455 /*
4456 * first access of each non-root page:
4457 */
4458 /*
4459 * if new, log btree_newpage.
4460 *
4461 if (p->header.flag & NEW)
4462 allocate new page lock;
4463 write a NEWPAGE log (next, prev);
4464 */
4465
4466 /* process the child page */
4467 goto dopage;
4468
4469 out:
4470 return 0;
4471}
4472#endif /* _JFS_WIP */
4473
4474
4475#ifdef CONFIG_JFS_STATISTICS 4135#ifdef CONFIG_JFS_STATISTICS
4476int jfs_xtstat_read(char *buffer, char **start, off_t offset, int length, 4136int jfs_xtstat_read(char *buffer, char **start, off_t offset, int length,
4477 int *eof, void *data) 4137 int *eof, void *data)
diff --git a/fs/jfs/jfs_xtree.h b/fs/jfs/jfs_xtree.h
index a69784254fe7..af668a80b40f 100644
--- a/fs/jfs/jfs_xtree.h
+++ b/fs/jfs/jfs_xtree.h
@@ -131,10 +131,4 @@ extern int xtRelocate(tid_t tid, struct inode *ip,
131extern int xtAppend(tid_t tid, 131extern int xtAppend(tid_t tid,
132 struct inode *ip, int xflag, s64 xoff, int maxblocks, 132 struct inode *ip, int xflag, s64 xoff, int maxblocks,
133 int *xlenp, s64 * xaddrp, int flag); 133 int *xlenp, s64 * xaddrp, int flag);
134
135#ifdef _JFS_DEBUG_XTREE
136extern int xtDisplayTree(struct inode *ip);
137extern int xtDisplayPage(struct inode *ip, s64 bn, xtpage_t * p);
138#endif /* _JFS_DEBUG_XTREE */
139
140#endif /* !_H_JFS_XTREE */ 134#endif /* !_H_JFS_XTREE */
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index ee438d429d45..554ec739e49b 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -781,7 +781,7 @@ static int can_set_xattr(struct inode *inode, const char *name,
781 if (IS_RDONLY(inode)) 781 if (IS_RDONLY(inode))
782 return -EROFS; 782 return -EROFS;
783 783
784 if (IS_IMMUTABLE(inode) || IS_APPEND(inode) || S_ISLNK(inode->i_mode)) 784 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
785 return -EPERM; 785 return -EPERM;
786 786
787 if(strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN) == 0) 787 if(strncmp(name, XATTR_SYSTEM_PREFIX, XATTR_SYSTEM_PREFIX_LEN) == 0)
@@ -790,12 +790,12 @@ static int can_set_xattr(struct inode *inode, const char *name,
790 */ 790 */
791 return can_set_system_xattr(inode, name, value, value_len); 791 return can_set_system_xattr(inode, name, value, value_len);
792 792
793 if(strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) != 0) 793 if(strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN) == 0)
794 return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM); 794 return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM);
795 795
796#ifdef CONFIG_JFS_SECURITY 796#ifdef CONFIG_JFS_SECURITY
797 if (strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN) 797 if (strncmp(name, XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN)
798 != 0) 798 == 0)
799 return 0; /* Leave it to the security module */ 799 return 0; /* Leave it to the security module */
800#endif 800#endif
801 801
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 6e242556b903..12a857c29e25 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -331,7 +331,7 @@ static ctl_table nlm_sysctls[] = {
331 .ctl_name = CTL_UNNUMBERED, 331 .ctl_name = CTL_UNNUMBERED,
332 .procname = "nlm_grace_period", 332 .procname = "nlm_grace_period",
333 .data = &nlm_grace_period, 333 .data = &nlm_grace_period,
334 .maxlen = sizeof(int), 334 .maxlen = sizeof(unsigned long),
335 .mode = 0644, 335 .mode = 0644,
336 .proc_handler = &proc_doulongvec_minmax, 336 .proc_handler = &proc_doulongvec_minmax,
337 .extra1 = (unsigned long *) &nlm_grace_period_min, 337 .extra1 = (unsigned long *) &nlm_grace_period_min,
@@ -341,7 +341,7 @@ static ctl_table nlm_sysctls[] = {
341 .ctl_name = CTL_UNNUMBERED, 341 .ctl_name = CTL_UNNUMBERED,
342 .procname = "nlm_timeout", 342 .procname = "nlm_timeout",
343 .data = &nlm_timeout, 343 .data = &nlm_timeout,
344 .maxlen = sizeof(int), 344 .maxlen = sizeof(unsigned long),
345 .mode = 0644, 345 .mode = 0644,
346 .proc_handler = &proc_doulongvec_minmax, 346 .proc_handler = &proc_doulongvec_minmax,
347 .extra1 = (unsigned long *) &nlm_timeout_min, 347 .extra1 = (unsigned long *) &nlm_timeout_min,
diff --git a/include/asm-arm/smp.h b/include/asm-arm/smp.h
index 6c6c60adbbaa..dbb4d859c586 100644
--- a/include/asm-arm/smp.h
+++ b/include/asm-arm/smp.h
@@ -23,9 +23,6 @@
23 23
24#define raw_smp_processor_id() (current_thread_info()->cpu) 24#define raw_smp_processor_id() (current_thread_info()->cpu)
25 25
26extern cpumask_t cpu_present_mask;
27#define cpu_possible_map cpu_present_mask
28
29/* 26/*
30 * at the moment, there's not a big penalty for changing CPUs 27 * at the moment, there's not a big penalty for changing CPUs
31 * (the >big< penalty is running SMP in the first place) 28 * (the >big< penalty is running SMP in the first place)
diff --git a/include/asm-ia64/pci.h b/include/asm-ia64/pci.h
index f11771eadc48..dba9f220be71 100644
--- a/include/asm-ia64/pci.h
+++ b/include/asm-ia64/pci.h
@@ -128,6 +128,7 @@ struct pci_controller {
128 void *acpi_handle; 128 void *acpi_handle;
129 void *iommu; 129 void *iommu;
130 int segment; 130 int segment;
131 int node; /* nearest node with memory or -1 for global allocation */
131 132
132 unsigned int windows; 133 unsigned int windows;
133 struct pci_window *window; 134 struct pci_window *window;
diff --git a/include/asm-ia64/sn/pcibr_provider.h b/include/asm-ia64/sn/pcibr_provider.h
index f9b8d2164007..2b42d9ece26b 100644
--- a/include/asm-ia64/sn/pcibr_provider.h
+++ b/include/asm-ia64/sn/pcibr_provider.h
@@ -128,7 +128,7 @@ pcibr_lock(struct pcibus_info *pcibus_info)
128#define pcibr_unlock(pcibus_info, flag) spin_unlock_irqrestore(&pcibus_info->pbi_lock, flag) 128#define pcibr_unlock(pcibus_info, flag) spin_unlock_irqrestore(&pcibus_info->pbi_lock, flag)
129 129
130extern int pcibr_init_provider(void); 130extern int pcibr_init_provider(void);
131extern void *pcibr_bus_fixup(struct pcibus_bussoft *); 131extern void *pcibr_bus_fixup(struct pcibus_bussoft *, struct pci_controller *);
132extern dma_addr_t pcibr_dma_map(struct pci_dev *, unsigned long, size_t); 132extern dma_addr_t pcibr_dma_map(struct pci_dev *, unsigned long, size_t);
133extern dma_addr_t pcibr_dma_map_consistent(struct pci_dev *, unsigned long, size_t); 133extern dma_addr_t pcibr_dma_map_consistent(struct pci_dev *, unsigned long, size_t);
134extern void pcibr_dma_unmap(struct pci_dev *, dma_addr_t, int); 134extern void pcibr_dma_unmap(struct pci_dev *, dma_addr_t, int);
diff --git a/include/asm-ia64/sn/pcibus_provider_defs.h b/include/asm-ia64/sn/pcibus_provider_defs.h
index 04e27d5b3820..976f5eff0539 100644
--- a/include/asm-ia64/sn/pcibus_provider_defs.h
+++ b/include/asm-ia64/sn/pcibus_provider_defs.h
@@ -37,6 +37,7 @@ struct pcibus_bussoft {
37 struct xwidget_info *bs_xwidget_info; 37 struct xwidget_info *bs_xwidget_info;
38}; 38};
39 39
40struct pci_controller;
40/* 41/*
41 * SN pci bus indirection 42 * SN pci bus indirection
42 */ 43 */
@@ -45,7 +46,7 @@ struct sn_pcibus_provider {
45 dma_addr_t (*dma_map)(struct pci_dev *, unsigned long, size_t); 46 dma_addr_t (*dma_map)(struct pci_dev *, unsigned long, size_t);
46 dma_addr_t (*dma_map_consistent)(struct pci_dev *, unsigned long, size_t); 47 dma_addr_t (*dma_map_consistent)(struct pci_dev *, unsigned long, size_t);
47 void (*dma_unmap)(struct pci_dev *, dma_addr_t, int); 48 void (*dma_unmap)(struct pci_dev *, dma_addr_t, int);
48 void * (*bus_fixup)(struct pcibus_bussoft *); 49 void * (*bus_fixup)(struct pcibus_bussoft *, struct pci_controller *);
49}; 50};
50 51
51extern struct sn_pcibus_provider *sn_pci_provider[]; 52extern struct sn_pcibus_provider *sn_pci_provider[];
diff --git a/include/asm-ia64/sn/simulator.h b/include/asm-ia64/sn/simulator.h
index cf770e246af5..16a48b5a039c 100644
--- a/include/asm-ia64/sn/simulator.h
+++ b/include/asm-ia64/sn/simulator.h
@@ -13,16 +13,9 @@
13#define SNMAGIC 0xaeeeeeee8badbeefL 13#define SNMAGIC 0xaeeeeeee8badbeefL
14#define IS_MEDUSA() ({long sn; asm("mov %0=cpuid[%1]" : "=r"(sn) : "r"(2)); sn == SNMAGIC;}) 14#define IS_MEDUSA() ({long sn; asm("mov %0=cpuid[%1]" : "=r"(sn) : "r"(2)); sn == SNMAGIC;})
15 15
16#ifdef CONFIG_IA64_SGI_SN_SIM
17#define SIMULATOR_SLEEP() asm("nop.i 0x8beef") 16#define SIMULATOR_SLEEP() asm("nop.i 0x8beef")
18#define IS_RUNNING_ON_SIMULATOR() (sn_prom_type) 17#define IS_RUNNING_ON_SIMULATOR() (sn_prom_type)
19#define IS_RUNNING_ON_FAKE_PROM() (sn_prom_type == 2) 18#define IS_RUNNING_ON_FAKE_PROM() (sn_prom_type == 2)
20extern int sn_prom_type; /* 0=hardware, 1=medusa/realprom, 2=medusa/fakeprom */ 19extern int sn_prom_type; /* 0=hardware, 1=medusa/realprom, 2=medusa/fakeprom */
21#else
22#define IS_RUNNING_ON_SIMULATOR() (0)
23#define IS_RUNNING_ON_FAKE_PROM() (0)
24#define SIMULATOR_SLEEP()
25
26#endif
27 20
28#endif /* _ASM_IA64_SN_SIMULATOR_H */ 21#endif /* _ASM_IA64_SN_SIMULATOR_H */
diff --git a/include/asm-ia64/topology.h b/include/asm-ia64/topology.h
index 4e64c2a6b369..399bc29729fd 100644
--- a/include/asm-ia64/topology.h
+++ b/include/asm-ia64/topology.h
@@ -40,6 +40,11 @@
40 */ 40 */
41#define node_to_first_cpu(node) (__ffs(node_to_cpumask(node))) 41#define node_to_first_cpu(node) (__ffs(node_to_cpumask(node)))
42 42
43/*
44 * Determines the node for a given pci bus
45 */
46#define pcibus_to_node(bus) PCI_CONTROLLER(bus)->node
47
43void build_cpu_to_node_map(void); 48void build_cpu_to_node_map(void);
44 49
45#define SD_CPU_INIT (struct sched_domain) { \ 50#define SD_CPU_INIT (struct sched_domain) { \
diff --git a/include/asm-ppc/mmu_context.h b/include/asm-ppc/mmu_context.h
index ccabbce39d85..afe26ffc2e2d 100644
--- a/include/asm-ppc/mmu_context.h
+++ b/include/asm-ppc/mmu_context.h
@@ -149,6 +149,7 @@ static inline void get_mmu_context(struct mm_struct *mm)
149 */ 149 */
150static inline void destroy_context(struct mm_struct *mm) 150static inline void destroy_context(struct mm_struct *mm)
151{ 151{
152 preempt_disable();
152 if (mm->context != NO_CONTEXT) { 153 if (mm->context != NO_CONTEXT) {
153 clear_bit(mm->context, context_map); 154 clear_bit(mm->context, context_map);
154 mm->context = NO_CONTEXT; 155 mm->context = NO_CONTEXT;
@@ -156,6 +157,7 @@ static inline void destroy_context(struct mm_struct *mm)
156 atomic_inc(&nr_free_contexts); 157 atomic_inc(&nr_free_contexts);
157#endif 158#endif
158 } 159 }
160 preempt_enable();
159} 161}
160 162
161static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, 163static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
diff --git a/include/asm-ppc64/iSeries/HvCallHpt.h b/include/asm-ppc64/iSeries/HvCallHpt.h
index 66f38222ff75..43a1969230b8 100644
--- a/include/asm-ppc64/iSeries/HvCallHpt.h
+++ b/include/asm-ppc64/iSeries/HvCallHpt.h
@@ -77,27 +77,26 @@ static inline u64 HvCallHpt_invalidateSetSwBitsGet(u32 hpteIndex, u8 bitson,
77 return compressedStatus; 77 return compressedStatus;
78} 78}
79 79
80static inline u64 HvCallHpt_findValid(HPTE *hpte, u64 vpn) 80static inline u64 HvCallHpt_findValid(hpte_t *hpte, u64 vpn)
81{ 81{
82 return HvCall3Ret16(HvCallHptFindValid, hpte, vpn, 0, 0); 82 return HvCall3Ret16(HvCallHptFindValid, hpte, vpn, 0, 0);
83} 83}
84 84
85static inline u64 HvCallHpt_findNextValid(HPTE *hpte, u32 hpteIndex, 85static inline u64 HvCallHpt_findNextValid(hpte_t *hpte, u32 hpteIndex,
86 u8 bitson, u8 bitsoff) 86 u8 bitson, u8 bitsoff)
87{ 87{
88 return HvCall3Ret16(HvCallHptFindNextValid, hpte, hpteIndex, 88 return HvCall3Ret16(HvCallHptFindNextValid, hpte, hpteIndex,
89 bitson, bitsoff); 89 bitson, bitsoff);
90} 90}
91 91
92static inline void HvCallHpt_get(HPTE *hpte, u32 hpteIndex) 92static inline void HvCallHpt_get(hpte_t *hpte, u32 hpteIndex)
93{ 93{
94 HvCall2Ret16(HvCallHptGet, hpte, hpteIndex, 0); 94 HvCall2Ret16(HvCallHptGet, hpte, hpteIndex, 0);
95} 95}
96 96
97static inline void HvCallHpt_addValidate(u32 hpteIndex, u32 hBit, HPTE *hpte) 97static inline void HvCallHpt_addValidate(u32 hpteIndex, u32 hBit, hpte_t *hpte)
98{ 98{
99 HvCall4(HvCallHptAddValidate, hpteIndex, hBit, (*((u64 *)hpte)), 99 HvCall4(HvCallHptAddValidate, hpteIndex, hBit, hpte->v, hpte->r);
100 (*(((u64 *)hpte)+1)));
101} 100}
102 101
103#endif /* _HVCALLHPT_H */ 102#endif /* _HVCALLHPT_H */
diff --git a/include/asm-ppc64/machdep.h b/include/asm-ppc64/machdep.h
index 1e6ad4824132..f0c1d2d92672 100644
--- a/include/asm-ppc64/machdep.h
+++ b/include/asm-ppc64/machdep.h
@@ -53,10 +53,8 @@ struct machdep_calls {
53 long (*hpte_insert)(unsigned long hpte_group, 53 long (*hpte_insert)(unsigned long hpte_group,
54 unsigned long va, 54 unsigned long va,
55 unsigned long prpn, 55 unsigned long prpn,
56 int secondary, 56 unsigned long vflags,
57 unsigned long hpteflags, 57 unsigned long rflags);
58 int bolted,
59 int large);
60 long (*hpte_remove)(unsigned long hpte_group); 58 long (*hpte_remove)(unsigned long hpte_group);
61 void (*flush_hash_range)(unsigned long context, 59 void (*flush_hash_range)(unsigned long context,
62 unsigned long number, 60 unsigned long number,
diff --git a/include/asm-ppc64/mmu.h b/include/asm-ppc64/mmu.h
index f373de5e3dd9..3d07ddd11e3b 100644
--- a/include/asm-ppc64/mmu.h
+++ b/include/asm-ppc64/mmu.h
@@ -60,6 +60,22 @@
60 60
61#define HPTES_PER_GROUP 8 61#define HPTES_PER_GROUP 8
62 62
63#define HPTE_V_AVPN_SHIFT 7
64#define HPTE_V_AVPN ASM_CONST(0xffffffffffffff80)
65#define HPTE_V_AVPN_VAL(x) (((x) & HPTE_V_AVPN) >> HPTE_V_AVPN_SHIFT)
66#define HPTE_V_BOLTED ASM_CONST(0x0000000000000010)
67#define HPTE_V_LOCK ASM_CONST(0x0000000000000008)
68#define HPTE_V_LARGE ASM_CONST(0x0000000000000004)
69#define HPTE_V_SECONDARY ASM_CONST(0x0000000000000002)
70#define HPTE_V_VALID ASM_CONST(0x0000000000000001)
71
72#define HPTE_R_PP0 ASM_CONST(0x8000000000000000)
73#define HPTE_R_TS ASM_CONST(0x4000000000000000)
74#define HPTE_R_RPN_SHIFT 12
75#define HPTE_R_RPN ASM_CONST(0x3ffffffffffff000)
76#define HPTE_R_FLAGS ASM_CONST(0x00000000000003ff)
77#define HPTE_R_PP ASM_CONST(0x0000000000000003)
78
63/* Values for PP (assumes Ks=0, Kp=1) */ 79/* Values for PP (assumes Ks=0, Kp=1) */
64/* pp0 will always be 0 for linux */ 80/* pp0 will always be 0 for linux */
65#define PP_RWXX 0 /* Supervisor read/write, User none */ 81#define PP_RWXX 0 /* Supervisor read/write, User none */
@@ -69,54 +85,13 @@
69 85
70#ifndef __ASSEMBLY__ 86#ifndef __ASSEMBLY__
71 87
72/* Hardware Page Table Entry */
73typedef struct {
74 unsigned long avpn:57; /* vsid | api == avpn */
75 unsigned long : 2; /* Software use */
76 unsigned long bolted: 1; /* HPTE is "bolted" */
77 unsigned long lock: 1; /* lock on pSeries SMP */
78 unsigned long l: 1; /* Virtual page is large (L=1) or 4 KB (L=0) */
79 unsigned long h: 1; /* Hash function identifier */
80 unsigned long v: 1; /* Valid (v=1) or invalid (v=0) */
81} Hpte_dword0;
82
83typedef struct {
84 unsigned long pp0: 1; /* Page protection bit 0 */
85 unsigned long ts: 1; /* Tag set bit */
86 unsigned long rpn: 50; /* Real page number */
87 unsigned long : 2; /* Reserved */
88 unsigned long ac: 1; /* Address compare */
89 unsigned long r: 1; /* Referenced */
90 unsigned long c: 1; /* Changed */
91 unsigned long w: 1; /* Write-thru cache mode */
92 unsigned long i: 1; /* Cache inhibited */
93 unsigned long m: 1; /* Memory coherence required */
94 unsigned long g: 1; /* Guarded */
95 unsigned long n: 1; /* No-execute */
96 unsigned long pp: 2; /* Page protection bits 1:2 */
97} Hpte_dword1;
98
99typedef struct {
100 char padding[6]; /* padding */
101 unsigned long : 6; /* padding */
102 unsigned long flags: 10; /* HPTE flags */
103} Hpte_dword1_flags;
104
105typedef struct { 88typedef struct {
106 union { 89 unsigned long v;
107 unsigned long dword0; 90 unsigned long r;
108 Hpte_dword0 dw0; 91} hpte_t;
109 } dw0;
110
111 union {
112 unsigned long dword1;
113 Hpte_dword1 dw1;
114 Hpte_dword1_flags flags;
115 } dw1;
116} HPTE;
117 92
118extern HPTE * htab_address; 93extern hpte_t *htab_address;
119extern unsigned long htab_hash_mask; 94extern unsigned long htab_hash_mask;
120 95
121static inline unsigned long hpt_hash(unsigned long vpn, int large) 96static inline unsigned long hpt_hash(unsigned long vpn, int large)
122{ 97{
@@ -181,18 +156,18 @@ static inline void tlbiel(unsigned long va)
181 asm volatile("ptesync": : :"memory"); 156 asm volatile("ptesync": : :"memory");
182} 157}
183 158
184static inline unsigned long slot2va(unsigned long avpn, unsigned long large, 159static inline unsigned long slot2va(unsigned long hpte_v, unsigned long slot)
185 unsigned long secondary, unsigned long slot)
186{ 160{
161 unsigned long avpn = HPTE_V_AVPN_VAL(hpte_v);
187 unsigned long va; 162 unsigned long va;
188 163
189 va = avpn << 23; 164 va = avpn << 23;
190 165
191 if (!large) { 166 if (! (hpte_v & HPTE_V_LARGE)) {
192 unsigned long vpi, pteg; 167 unsigned long vpi, pteg;
193 168
194 pteg = slot / HPTES_PER_GROUP; 169 pteg = slot / HPTES_PER_GROUP;
195 if (secondary) 170 if (hpte_v & HPTE_V_SECONDARY)
196 pteg = ~pteg; 171 pteg = ~pteg;
197 172
198 vpi = ((va >> 28) ^ pteg) & htab_hash_mask; 173 vpi = ((va >> 28) ^ pteg) & htab_hash_mask;
@@ -219,11 +194,11 @@ extern void hpte_init_iSeries(void);
219 194
220extern long pSeries_lpar_hpte_insert(unsigned long hpte_group, 195extern long pSeries_lpar_hpte_insert(unsigned long hpte_group,
221 unsigned long va, unsigned long prpn, 196 unsigned long va, unsigned long prpn,
222 int secondary, unsigned long hpteflags, 197 unsigned long vflags,
223 int bolted, int large); 198 unsigned long rflags);
224extern long native_hpte_insert(unsigned long hpte_group, unsigned long va, 199extern long native_hpte_insert(unsigned long hpte_group, unsigned long va,
225 unsigned long prpn, int secondary, 200 unsigned long prpn,
226 unsigned long hpteflags, int bolted, int large); 201 unsigned long vflags, unsigned long rflags);
227 202
228#endif /* __ASSEMBLY__ */ 203#endif /* __ASSEMBLY__ */
229 204
diff --git a/include/asm-um/ldt.h b/include/asm-um/ldt.h
new file mode 100644
index 000000000000..e908439d338a
--- /dev/null
+++ b/include/asm-um/ldt.h
@@ -0,0 +1,5 @@
1#ifndef __UM_LDT_H
2#define __UM_LDT_H
3
4#include "asm/arch/ldt.h"
5#endif
diff --git a/include/linux/fadvise.h b/include/linux/fadvise.h
index 6fc656dfb93d..e8e747139b9a 100644
--- a/include/linux/fadvise.h
+++ b/include/linux/fadvise.h
@@ -5,7 +5,17 @@
5#define POSIX_FADV_RANDOM 1 /* Expect random page references. */ 5#define POSIX_FADV_RANDOM 1 /* Expect random page references. */
6#define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */ 6#define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
7#define POSIX_FADV_WILLNEED 3 /* Will need these pages. */ 7#define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
8
9/*
10 * The advise values for POSIX_FADV_DONTNEED and POSIX_ADV_NOREUSE
11 * for s390-64 differ from the values for the rest of the world.
12 */
13#if defined(__s390x__)
14#define POSIX_FADV_DONTNEED 6 /* Don't need these pages. */
15#define POSIX_FADV_NOREUSE 7 /* Data will be accessed once. */
16#else
8#define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */ 17#define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
9#define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */ 18#define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
19#endif
10 20
11#endif /* FADVISE_H_INCLUDED */ 21#endif /* FADVISE_H_INCLUDED */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c9bf3746a9fb..0f53e0124941 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1441,6 +1441,9 @@ extern int inode_needs_sync(struct inode *inode);
1441extern void generic_delete_inode(struct inode *inode); 1441extern void generic_delete_inode(struct inode *inode);
1442extern void generic_drop_inode(struct inode *inode); 1442extern void generic_drop_inode(struct inode *inode);
1443 1443
1444extern struct inode *ilookup5_nowait(struct super_block *sb,
1445 unsigned long hashval, int (*test)(struct inode *, void *),
1446 void *data);
1444extern struct inode *ilookup5(struct super_block *sb, unsigned long hashval, 1447extern struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
1445 int (*test)(struct inode *, void *), void *data); 1448 int (*test)(struct inode *, void *), void *data);
1446extern struct inode *ilookup(struct super_block *sb, unsigned long ino); 1449extern struct inode *ilookup(struct super_block *sb, unsigned long ino);
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index eb581b6cfca9..d07a92c94776 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -125,8 +125,8 @@ static inline void fsnotify_open(struct dentry *dentry)
125 if (S_ISDIR(inode->i_mode)) 125 if (S_ISDIR(inode->i_mode))
126 mask |= IN_ISDIR; 126 mask |= IN_ISDIR;
127 127
128 inotify_inode_queue_event(inode, mask, 0, NULL);
129 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name); 128 inotify_dentry_parent_queue_event(dentry, mask, 0, dentry->d_name.name);
129 inotify_inode_queue_event(inode, mask, 0, NULL);
130} 130}
131 131
132/* 132/*
diff --git a/include/linux/raid/bitmap.h b/include/linux/raid/bitmap.h
index e24b74b11150..6213e976eade 100644
--- a/include/linux/raid/bitmap.h
+++ b/include/linux/raid/bitmap.h
@@ -262,7 +262,7 @@ void bitmap_write_all(struct bitmap *bitmap);
262int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors); 262int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors);
263void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors, 263void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors,
264 int success); 264 int success);
265int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks); 265int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int degraded);
266void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted); 266void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted);
267void bitmap_close_sync(struct bitmap *bitmap); 267void bitmap_close_sync(struct bitmap *bitmap);
268 268
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index ce19a2aa0b21..bfbbe94b297d 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -61,8 +61,7 @@ enum
61 CTL_DEV=7, /* Devices */ 61 CTL_DEV=7, /* Devices */
62 CTL_BUS=8, /* Busses */ 62 CTL_BUS=8, /* Busses */
63 CTL_ABI=9, /* Binary emulation */ 63 CTL_ABI=9, /* Binary emulation */
64 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */ 64 CTL_CPU=10 /* CPU stuff (speed scaling, etc) */
65 CTL_INOTIFY=11 /* Inotify */
66}; 65};
67 66
68/* CTL_BUS names: */ 67/* CTL_BUS names: */
@@ -71,12 +70,12 @@ enum
71 CTL_BUS_ISA=1 /* ISA */ 70 CTL_BUS_ISA=1 /* ISA */
72}; 71};
73 72
74/* CTL_INOTIFY names: */ 73/* /proc/sys/fs/inotify/ */
75enum 74enum
76{ 75{
77 INOTIFY_MAX_USER_DEVICES=1, /* max number of inotify device instances per user */ 76 INOTIFY_MAX_USER_INSTANCES=1, /* max instances per user */
78 INOTIFY_MAX_USER_WATCHES=2, /* max number of inotify watches per user */ 77 INOTIFY_MAX_USER_WATCHES=2, /* max watches per user */
79 INOTIFY_MAX_QUEUED_EVENTS=3 /* Max number of queued events per inotify device instance */ 78 INOTIFY_MAX_QUEUED_EVENTS=3 /* max queued events per instance */
80}; 79};
81 80
82/* CTL_KERN names: */ 81/* CTL_KERN names: */
@@ -685,6 +684,7 @@ enum
685 FS_XFS=17, /* struct: control xfs parameters */ 684 FS_XFS=17, /* struct: control xfs parameters */
686 FS_AIO_NR=18, /* current system-wide number of aio requests */ 685 FS_AIO_NR=18, /* current system-wide number of aio requests */
687 FS_AIO_MAX_NR=19, /* system-wide maximum number of aio requests */ 686 FS_AIO_MAX_NR=19, /* system-wide maximum number of aio requests */
687 FS_INOTIFY=20, /* inotify submenu */
688}; 688};
689 689
690/* /proc/sys/fs/quota/ */ 690/* /proc/sys/fs/quota/ */
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 1b02be734ccc..4e11a9aaf14a 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -26,8 +26,6 @@ static char __initdata saved_root_name[64];
26/* this is initialized in init/main.c */ 26/* this is initialized in init/main.c */
27dev_t ROOT_DEV; 27dev_t ROOT_DEV;
28 28
29EXPORT_SYMBOL(ROOT_DEV);
30
31static int __init load_ramdisk(char *str) 29static int __init load_ramdisk(char *str)
32{ 30{
33 rd_doload = simple_strtol(str,NULL,0) & 3; 31 rd_doload = simple_strtol(str,NULL,0) & 3;
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index b240e2cb86fc..e60b9c36f1f0 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -67,12 +67,6 @@ extern int printk_ratelimit_jiffies;
67extern int printk_ratelimit_burst; 67extern int printk_ratelimit_burst;
68extern int pid_max_min, pid_max_max; 68extern int pid_max_min, pid_max_max;
69 69
70#ifdef CONFIG_INOTIFY
71extern int inotify_max_user_devices;
72extern int inotify_max_user_watches;
73extern int inotify_max_queued_events;
74#endif
75
76#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 70#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
77int unknown_nmi_panic; 71int unknown_nmi_panic;
78extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *, 72extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *,
@@ -152,6 +146,9 @@ extern ctl_table random_table[];
152#ifdef CONFIG_UNIX98_PTYS 146#ifdef CONFIG_UNIX98_PTYS
153extern ctl_table pty_table[]; 147extern ctl_table pty_table[];
154#endif 148#endif
149#ifdef CONFIG_INOTIFY
150extern ctl_table inotify_table[];
151#endif
155 152
156#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 153#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
157int sysctl_legacy_va_layout; 154int sysctl_legacy_va_layout;
@@ -957,6 +954,14 @@ static ctl_table fs_table[] = {
957 .mode = 0644, 954 .mode = 0644,
958 .proc_handler = &proc_dointvec, 955 .proc_handler = &proc_dointvec,
959 }, 956 },
957#ifdef CONFIG_INOTIFY
958 {
959 .ctl_name = FS_INOTIFY,
960 .procname = "inotify",
961 .mode = 0555,
962 .child = inotify_table,
963 },
964#endif
960#endif 965#endif
961 { 966 {
962 .ctl_name = KERN_SETUID_DUMPABLE, 967 .ctl_name = KERN_SETUID_DUMPABLE,
@@ -966,40 +971,6 @@ static ctl_table fs_table[] = {
966 .mode = 0644, 971 .mode = 0644,
967 .proc_handler = &proc_dointvec, 972 .proc_handler = &proc_dointvec,
968 }, 973 },
969#ifdef CONFIG_INOTIFY
970 {
971 .ctl_name = INOTIFY_MAX_USER_DEVICES,
972 .procname = "max_user_devices",
973 .data = &inotify_max_user_devices,
974 .maxlen = sizeof(int),
975 .mode = 0644,
976 .proc_handler = &proc_dointvec_minmax,
977 .strategy = &sysctl_intvec,
978 .extra1 = &zero,
979 },
980
981 {
982 .ctl_name = INOTIFY_MAX_USER_WATCHES,
983 .procname = "max_user_watches",
984 .data = &inotify_max_user_watches,
985 .maxlen = sizeof(int),
986 .mode = 0644,
987 .proc_handler = &proc_dointvec_minmax,
988 .strategy = &sysctl_intvec,
989 .extra1 = &zero,
990 },
991
992 {
993 .ctl_name = INOTIFY_MAX_QUEUED_EVENTS,
994 .procname = "max_queued_events",
995 .data = &inotify_max_queued_events,
996 .maxlen = sizeof(int),
997 .mode = 0644,
998 .proc_handler = &proc_dointvec_minmax,
999 .strategy = &sysctl_intvec,
1000 .extra1 = &zero
1001 },
1002#endif
1003 { .ctl_name = 0 } 974 { .ctl_name = 0 }
1004}; 975};
1005 976
diff --git a/mm/filemap_xip.c b/mm/filemap_xip.c
index 4553b2c5aab4..8c199f537732 100644
--- a/mm/filemap_xip.c
+++ b/mm/filemap_xip.c
@@ -68,13 +68,12 @@ do_xip_mapping_read(struct address_space *mapping,
68 if (unlikely(IS_ERR(page))) { 68 if (unlikely(IS_ERR(page))) {
69 if (PTR_ERR(page) == -ENODATA) { 69 if (PTR_ERR(page) == -ENODATA) {
70 /* sparse */ 70 /* sparse */
71 page = virt_to_page(empty_zero_page); 71 page = ZERO_PAGE(0);
72 } else { 72 } else {
73 desc->error = PTR_ERR(page); 73 desc->error = PTR_ERR(page);
74 goto out; 74 goto out;
75 } 75 }
76 } else 76 }
77 BUG_ON(!PageUptodate(page));
78 77
79 /* If users can be writing to this page using arbitrary 78 /* If users can be writing to this page using arbitrary
80 * virtual addresses, take care about potential aliasing 79 * virtual addresses, take care about potential aliasing
@@ -84,8 +83,7 @@ do_xip_mapping_read(struct address_space *mapping,
84 flush_dcache_page(page); 83 flush_dcache_page(page);
85 84
86 /* 85 /*
87 * Ok, we have the page, and it's up-to-date, so 86 * Ok, we have the page, so now we can copy it to user space...
88 * now we can copy it to user space...
89 * 87 *
90 * The actor routine returns how many bytes were actually used.. 88 * The actor routine returns how many bytes were actually used..
91 * NOTE! This may not be the same as how much of a user buffer 89 * NOTE! This may not be the same as how much of a user buffer
@@ -164,7 +162,7 @@ EXPORT_SYMBOL_GPL(xip_file_sendfile);
164 * xip_write 162 * xip_write
165 * 163 *
166 * This function walks all vmas of the address_space and unmaps the 164 * This function walks all vmas of the address_space and unmaps the
167 * empty_zero_page when found at pgoff. Should it go in rmap.c? 165 * ZERO_PAGE when found at pgoff. Should it go in rmap.c?
168 */ 166 */
169static void 167static void
170__xip_unmap (struct address_space * mapping, 168__xip_unmap (struct address_space * mapping,
@@ -187,7 +185,7 @@ __xip_unmap (struct address_space * mapping,
187 * We need the page_table_lock to protect us from page faults, 185 * We need the page_table_lock to protect us from page faults,
188 * munmap, fork, etc... 186 * munmap, fork, etc...
189 */ 187 */
190 pte = page_check_address(virt_to_page(empty_zero_page), mm, 188 pte = page_check_address(ZERO_PAGE(address), mm,
191 address); 189 address);
192 if (!IS_ERR(pte)) { 190 if (!IS_ERR(pte)) {
193 /* Nuke the page table entry. */ 191 /* Nuke the page table entry. */
@@ -230,7 +228,6 @@ xip_file_nopage(struct vm_area_struct * area,
230 228
231 page = mapping->a_ops->get_xip_page(mapping, pgoff*(PAGE_SIZE/512), 0); 229 page = mapping->a_ops->get_xip_page(mapping, pgoff*(PAGE_SIZE/512), 0);
232 if (!IS_ERR(page)) { 230 if (!IS_ERR(page)) {
233 BUG_ON(!PageUptodate(page));
234 return page; 231 return page;
235 } 232 }
236 if (PTR_ERR(page) != -ENODATA) 233 if (PTR_ERR(page) != -ENODATA)
@@ -245,12 +242,11 @@ xip_file_nopage(struct vm_area_struct * area,
245 pgoff*(PAGE_SIZE/512), 1); 242 pgoff*(PAGE_SIZE/512), 1);
246 if (IS_ERR(page)) 243 if (IS_ERR(page))
247 return NULL; 244 return NULL;
248 BUG_ON(!PageUptodate(page));
249 /* unmap page at pgoff from all other vmas */ 245 /* unmap page at pgoff from all other vmas */
250 __xip_unmap(mapping, pgoff); 246 __xip_unmap(mapping, pgoff);
251 } else { 247 } else {
252 /* not shared and writable, use empty_zero_page */ 248 /* not shared and writable, use ZERO_PAGE() */
253 page = virt_to_page(empty_zero_page); 249 page = ZERO_PAGE(address);
254 } 250 }
255 251
256 return page; 252 return page;
@@ -319,8 +315,6 @@ __xip_file_write(struct file *filp, const char __user *buf,
319 break; 315 break;
320 } 316 }
321 317
322 BUG_ON(!PageUptodate(page));
323
324 copied = filemap_copy_from_user(page, offset, buf, bytes); 318 copied = filemap_copy_from_user(page, offset, buf, bytes);
325 flush_dcache_page(page); 319 flush_dcache_page(page);
326 if (likely(copied > 0)) { 320 if (likely(copied > 0)) {
@@ -435,8 +429,7 @@ xip_truncate_page(struct address_space *mapping, loff_t from)
435 return 0; 429 return 0;
436 else 430 else
437 return PTR_ERR(page); 431 return PTR_ERR(page);
438 } else 432 }
439 BUG_ON(!PageUptodate(page));
440 kaddr = kmap_atomic(page, KM_USER0); 433 kaddr = kmap_atomic(page, KM_USER0);
441 memset(kaddr + offset, 0, length); 434 memset(kaddr + offset, 0, length);
442 kunmap_atomic(kaddr, KM_USER0); 435 kunmap_atomic(kaddr, KM_USER0);
diff --git a/scripts/Lindent b/scripts/Lindent
index 34ed785116b6..7d8d8896e309 100755
--- a/scripts/Lindent
+++ b/scripts/Lindent
@@ -1,2 +1,2 @@
1#!/bin/sh 1#!/bin/sh
2indent -kr -i8 -ts8 -sob -l80 -ss -ncs "$@" 2indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs "$@"