aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2008-03-03 23:22:00 -0500
committerSteve French <sfrench@us.ibm.com>2008-03-03 23:22:00 -0500
commit966ea8c4b74aa6fde2d58c50a904619fd849ae93 (patch)
tree15f02bbcf6112575dbec30c3f7603a393b4dee3a
parent41c5ae6898454277ec88e8e7278c8c58026363a3 (diff)
parent976dde010e513a9c7c3117a32b7b015f84b37430 (diff)
Merge branch 'master' of /pub/scm/linux/kernel/git/torvalds/linux-2.6
-rw-r--r--arch/arm/mm/pgd.c6
-rw-r--r--arch/powerpc/boot/cuboot-bamboo.c1
-rw-r--r--arch/powerpc/boot/cuboot-ebony.c1
-rw-r--r--arch/powerpc/boot/cuboot-katmai.c1
-rw-r--r--arch/powerpc/boot/cuboot-taishan.c2
-rw-r--r--arch/powerpc/boot/cuboot-warp.c1
-rw-r--r--arch/powerpc/boot/dts/haleakala.dts2
-rw-r--r--arch/powerpc/boot/dts/katmai.dts58
-rw-r--r--arch/powerpc/oprofile/op_model_cell.c2
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_common.c1
-rw-r--r--arch/powerpc/platforms/cell/iommu.c151
-rw-r--r--arch/powerpc/platforms/cell/setup.c7
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c16
-rw-r--r--arch/powerpc/platforms/cell/spufs/context.c7
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c12
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c2
-rw-r--r--arch/powerpc/platforms/cell/spufs/sputrace.c7
-rw-r--r--arch/powerpc/platforms/cell/spufs/switch.c6
-rw-r--r--arch/powerpc/platforms/celleb/beat.h3
-rw-r--r--arch/x86/mm/pageattr.c21
-rw-r--r--drivers/acorn/char/defkeymap-l7200.c68
-rw-r--r--drivers/base/transport_class.c4
-rw-r--r--drivers/char/defkeymap.c_shipped68
-rw-r--r--drivers/char/xilinx_hwicap/buffer_icap.c80
-rw-r--r--drivers/char/xilinx_hwicap/fifo_icap.c60
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.c138
-rw-r--r--drivers/char/xilinx_hwicap/xilinx_hwicap.h24
-rw-r--r--drivers/message/fusion/mptbase.c25
-rw-r--r--drivers/message/fusion/mptscsih.c14
-rw-r--r--drivers/pci/rom.c3
-rw-r--r--drivers/rapidio/rio-driver.c8
-rw-r--r--drivers/s390/char/defkeymap.c4
-rw-r--r--drivers/scsi/scsi_scan.c3
-rw-r--r--drivers/usb/core/usb.c6
-rw-r--r--fs/buffer.c3
-rw-r--r--fs/exec.c10
-rw-r--r--fs/jbd/transaction.c17
-rw-r--r--fs/mpage.c11
-rw-r--r--include/asm-powerpc/reg.h3
-rw-r--r--include/asm-x86/pgtable_32.h4
-rw-r--r--include/asm-x86/pgtable_64.h6
-rw-r--r--include/linux/mm_types.h5
-rw-r--r--include/linux/slub_def.h4
-rw-r--r--include/linux/usb.h9
-rw-r--r--kernel/exit.c96
-rw-r--r--mm/slub.c204
-rw-r--r--mm/truncate.c3
47 files changed, 593 insertions, 594 deletions
diff --git a/arch/arm/mm/pgd.c b/arch/arm/mm/pgd.c
index 500c9610ab30..e0f19ab91163 100644
--- a/arch/arm/mm/pgd.c
+++ b/arch/arm/mm/pgd.c
@@ -75,7 +75,7 @@ no_pgd:
75void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd) 75void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd)
76{ 76{
77 pmd_t *pmd; 77 pmd_t *pmd;
78 struct page *pte; 78 pgtable_t pte;
79 79
80 if (!pgd) 80 if (!pgd)
81 return; 81 return;
@@ -90,10 +90,8 @@ void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd)
90 goto free; 90 goto free;
91 } 91 }
92 92
93 pte = pmd_page(*pmd); 93 pte = pmd_pgtable(*pmd);
94 pmd_clear(pmd); 94 pmd_clear(pmd);
95 dec_zone_page_state(virt_to_page((unsigned long *)pgd), NR_PAGETABLE);
96 pte_lock_deinit(pte);
97 pte_free(mm, pte); 95 pte_free(mm, pte);
98 pmd_free(mm, pmd); 96 pmd_free(mm, pmd);
99free: 97free:
diff --git a/arch/powerpc/boot/cuboot-bamboo.c b/arch/powerpc/boot/cuboot-bamboo.c
index 900c7ff2b7e9..b5c30f766c40 100644
--- a/arch/powerpc/boot/cuboot-bamboo.c
+++ b/arch/powerpc/boot/cuboot-bamboo.c
@@ -17,6 +17,7 @@
17#include "44x.h" 17#include "44x.h"
18#include "cuboot.h" 18#include "cuboot.h"
19 19
20#define TARGET_4xx
20#define TARGET_44x 21#define TARGET_44x
21#include "ppcboot.h" 22#include "ppcboot.h"
22 23
diff --git a/arch/powerpc/boot/cuboot-ebony.c b/arch/powerpc/boot/cuboot-ebony.c
index c5f37ce172ea..56564ba37f62 100644
--- a/arch/powerpc/boot/cuboot-ebony.c
+++ b/arch/powerpc/boot/cuboot-ebony.c
@@ -17,6 +17,7 @@
17#include "44x.h" 17#include "44x.h"
18#include "cuboot.h" 18#include "cuboot.h"
19 19
20#define TARGET_4xx
20#define TARGET_44x 21#define TARGET_44x
21#include "ppcboot.h" 22#include "ppcboot.h"
22 23
diff --git a/arch/powerpc/boot/cuboot-katmai.c b/arch/powerpc/boot/cuboot-katmai.c
index c021167f9381..5434d70b5660 100644
--- a/arch/powerpc/boot/cuboot-katmai.c
+++ b/arch/powerpc/boot/cuboot-katmai.c
@@ -22,6 +22,7 @@
22#include "44x.h" 22#include "44x.h"
23#include "cuboot.h" 23#include "cuboot.h"
24 24
25#define TARGET_4xx
25#define TARGET_44x 26#define TARGET_44x
26#include "ppcboot.h" 27#include "ppcboot.h"
27 28
diff --git a/arch/powerpc/boot/cuboot-taishan.c b/arch/powerpc/boot/cuboot-taishan.c
index f66455a45ab1..b55b80467eed 100644
--- a/arch/powerpc/boot/cuboot-taishan.c
+++ b/arch/powerpc/boot/cuboot-taishan.c
@@ -21,7 +21,9 @@
21#include "dcr.h" 21#include "dcr.h"
22#include "4xx.h" 22#include "4xx.h"
23 23
24#define TARGET_4xx
24#define TARGET_44x 25#define TARGET_44x
26#define TARGET_440GX
25#include "ppcboot.h" 27#include "ppcboot.h"
26 28
27static bd_t bd; 29static bd_t bd;
diff --git a/arch/powerpc/boot/cuboot-warp.c b/arch/powerpc/boot/cuboot-warp.c
index bdedebe1bc14..3db93e85e9ea 100644
--- a/arch/powerpc/boot/cuboot-warp.c
+++ b/arch/powerpc/boot/cuboot-warp.c
@@ -11,6 +11,7 @@
11#include "4xx.h" 11#include "4xx.h"
12#include "cuboot.h" 12#include "cuboot.h"
13 13
14#define TARGET_4xx
14#define TARGET_44x 15#define TARGET_44x
15#include "ppcboot.h" 16#include "ppcboot.h"
16 17
diff --git a/arch/powerpc/boot/dts/haleakala.dts b/arch/powerpc/boot/dts/haleakala.dts
index 5dd3d15f0feb..ae68fefc01b6 100644
--- a/arch/powerpc/boot/dts/haleakala.dts
+++ b/arch/powerpc/boot/dts/haleakala.dts
@@ -235,7 +235,7 @@
235 #interrupt-cells = <1>; 235 #interrupt-cells = <1>;
236 #size-cells = <2>; 236 #size-cells = <2>;
237 #address-cells = <3>; 237 #address-cells = <3>;
238 compatible = "ibm,plb-pciex-405exr", "ibm,plb-pciex"; 238 compatible = "ibm,plb-pciex-405ex", "ibm,plb-pciex";
239 primary; 239 primary;
240 port = <0>; /* port number */ 240 port = <0>; /* port number */
241 reg = <a0000000 20000000 /* Config space access */ 241 reg = <a0000000 20000000 /* Config space access */
diff --git a/arch/powerpc/boot/dts/katmai.dts b/arch/powerpc/boot/dts/katmai.dts
index bc32ac7250ec..fc86e5a3afc4 100644
--- a/arch/powerpc/boot/dts/katmai.dts
+++ b/arch/powerpc/boot/dts/katmai.dts
@@ -38,8 +38,8 @@
38 timebase-frequency = <0>; /* Filled in by zImage */ 38 timebase-frequency = <0>; /* Filled in by zImage */
39 i-cache-line-size = <20>; 39 i-cache-line-size = <20>;
40 d-cache-line-size = <20>; 40 d-cache-line-size = <20>;
41 i-cache-size = <20000>; 41 i-cache-size = <8000>;
42 d-cache-size = <20000>; 42 d-cache-size = <8000>;
43 dcr-controller; 43 dcr-controller;
44 dcr-access-method = "native"; 44 dcr-access-method = "native";
45 }; 45 };
@@ -136,11 +136,11 @@
136 }; 136 };
137 137
138 POB0: opb { 138 POB0: opb {
139 compatible = "ibm,opb-440spe", "ibm,opb-440gp", "ibm,opb"; 139 compatible = "ibm,opb-440spe", "ibm,opb-440gp", "ibm,opb";
140 #address-cells = <1>; 140 #address-cells = <1>;
141 #size-cells = <1>; 141 #size-cells = <1>;
142 ranges = <00000000 4 e0000000 20000000>; 142 ranges = <00000000 4 e0000000 20000000>;
143 clock-frequency = <0>; /* Filled in by zImage */ 143 clock-frequency = <0>; /* Filled in by zImage */
144 144
145 EBC0: ebc { 145 EBC0: ebc {
146 compatible = "ibm,ebc-440spe", "ibm,ebc-440gp", "ibm,ebc"; 146 compatible = "ibm,ebc-440spe", "ibm,ebc-440gp", "ibm,ebc";
@@ -153,38 +153,38 @@
153 }; 153 };
154 154
155 UART0: serial@10000200 { 155 UART0: serial@10000200 {
156 device_type = "serial"; 156 device_type = "serial";
157 compatible = "ns16550"; 157 compatible = "ns16550";
158 reg = <10000200 8>; 158 reg = <10000200 8>;
159 virtual-reg = <a0000200>; 159 virtual-reg = <a0000200>;
160 clock-frequency = <0>; /* Filled in by zImage */ 160 clock-frequency = <0>; /* Filled in by zImage */
161 current-speed = <1c200>; 161 current-speed = <1c200>;
162 interrupt-parent = <&UIC0>; 162 interrupt-parent = <&UIC0>;
163 interrupts = <0 4>; 163 interrupts = <0 4>;
164 }; 164 };
165 165
166 UART1: serial@10000300 { 166 UART1: serial@10000300 {
167 device_type = "serial"; 167 device_type = "serial";
168 compatible = "ns16550"; 168 compatible = "ns16550";
169 reg = <10000300 8>; 169 reg = <10000300 8>;
170 virtual-reg = <a0000300>; 170 virtual-reg = <a0000300>;
171 clock-frequency = <0>; 171 clock-frequency = <0>;
172 current-speed = <0>; 172 current-speed = <0>;
173 interrupt-parent = <&UIC0>; 173 interrupt-parent = <&UIC0>;
174 interrupts = <1 4>; 174 interrupts = <1 4>;
175 }; 175 };
176 176
177 177
178 UART2: serial@10000600 { 178 UART2: serial@10000600 {
179 device_type = "serial"; 179 device_type = "serial";
180 compatible = "ns16550"; 180 compatible = "ns16550";
181 reg = <10000600 8>; 181 reg = <10000600 8>;
182 virtual-reg = <a0000600>; 182 virtual-reg = <a0000600>;
183 clock-frequency = <0>; 183 clock-frequency = <0>;
184 current-speed = <0>; 184 current-speed = <0>;
185 interrupt-parent = <&UIC1>; 185 interrupt-parent = <&UIC1>;
186 interrupts = <5 4>; 186 interrupts = <5 4>;
187 }; 187 };
188 188
189 IIC0: i2c@10000400 { 189 IIC0: i2c@10000400 {
190 compatible = "ibm,iic-440spe", "ibm,iic-440gp", "ibm,iic"; 190 compatible = "ibm,iic-440spe", "ibm,iic-440gp", "ibm,iic";
diff --git a/arch/powerpc/oprofile/op_model_cell.c b/arch/powerpc/oprofile/op_model_cell.c
index 13929771bee7..9eed1f68fcab 100644
--- a/arch/powerpc/oprofile/op_model_cell.c
+++ b/arch/powerpc/oprofile/op_model_cell.c
@@ -1151,7 +1151,7 @@ static void cell_handle_interrupt(struct pt_regs *regs,
1151 for (i = 0; i < num_counters; ++i) { 1151 for (i = 0; i < num_counters; ++i) {
1152 if ((interrupt_mask & CBE_PM_CTR_OVERFLOW_INTR(i)) 1152 if ((interrupt_mask & CBE_PM_CTR_OVERFLOW_INTR(i))
1153 && ctr[i].enabled) { 1153 && ctr[i].enabled) {
1154 oprofile_add_pc(pc, is_kernel, i); 1154 oprofile_add_ext_sample(pc, regs, i, is_kernel);
1155 cbe_write_ctr(cpu, i, reset_value[i]); 1155 cbe_write_ctr(cpu, i, reset_value[i]);
1156 } 1156 }
1157 } 1157 }
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c
index 9aa4425d80b2..4d5fd1dbd400 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_common.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c
@@ -199,6 +199,7 @@ int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv)
199 199
200 return 0; 200 return 0;
201} 201}
202EXPORT_SYMBOL(mpc52xx_set_psc_clkdiv);
202 203
203/** 204/**
204 * mpc52xx_restart: ppc_md->restart hook for mpc5200 using the watchdog timer 205 * mpc52xx_restart: ppc_md->restart hook for mpc5200 using the watchdog timer
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index edab631a8dcb..20ea0e118f24 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -113,7 +113,7 @@
113 113
114/* IOMMU sizing */ 114/* IOMMU sizing */
115#define IO_SEGMENT_SHIFT 28 115#define IO_SEGMENT_SHIFT 28
116#define IO_PAGENO_BITS (IO_SEGMENT_SHIFT - IOMMU_PAGE_SHIFT) 116#define IO_PAGENO_BITS(shift) (IO_SEGMENT_SHIFT - (shift))
117 117
118/* The high bit needs to be set on every DMA address */ 118/* The high bit needs to be set on every DMA address */
119#define SPIDER_DMA_OFFSET 0x80000000ul 119#define SPIDER_DMA_OFFSET 0x80000000ul
@@ -123,7 +123,6 @@ struct iommu_window {
123 struct cbe_iommu *iommu; 123 struct cbe_iommu *iommu;
124 unsigned long offset; 124 unsigned long offset;
125 unsigned long size; 125 unsigned long size;
126 unsigned long pte_offset;
127 unsigned int ioid; 126 unsigned int ioid;
128 struct iommu_table table; 127 struct iommu_table table;
129}; 128};
@@ -200,7 +199,7 @@ static void tce_build_cell(struct iommu_table *tbl, long index, long npages,
200 (window->ioid & IOPTE_IOID_Mask); 199 (window->ioid & IOPTE_IOID_Mask);
201#endif 200#endif
202 201
203 io_pte = (unsigned long *)tbl->it_base + (index - window->pte_offset); 202 io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset);
204 203
205 for (i = 0; i < npages; i++, uaddr += IOMMU_PAGE_SIZE) 204 for (i = 0; i < npages; i++, uaddr += IOMMU_PAGE_SIZE)
206 io_pte[i] = base_pte | (__pa(uaddr) & IOPTE_RPN_Mask); 205 io_pte[i] = base_pte | (__pa(uaddr) & IOPTE_RPN_Mask);
@@ -232,7 +231,7 @@ static void tce_free_cell(struct iommu_table *tbl, long index, long npages)
232 | (window->ioid & IOPTE_IOID_Mask); 231 | (window->ioid & IOPTE_IOID_Mask);
233#endif 232#endif
234 233
235 io_pte = (unsigned long *)tbl->it_base + (index - window->pte_offset); 234 io_pte = (unsigned long *)tbl->it_base + (index - tbl->it_offset);
236 235
237 for (i = 0; i < npages; i++) 236 for (i = 0; i < npages; i++)
238 io_pte[i] = pte; 237 io_pte[i] = pte;
@@ -307,76 +306,84 @@ static int cell_iommu_find_ioc(int nid, unsigned long *base)
307 return -ENODEV; 306 return -ENODEV;
308} 307}
309 308
310static void cell_iommu_setup_page_tables(struct cbe_iommu *iommu, 309static void cell_iommu_setup_stab(struct cbe_iommu *iommu,
311 unsigned long dbase, unsigned long dsize, 310 unsigned long dbase, unsigned long dsize,
312 unsigned long fbase, unsigned long fsize) 311 unsigned long fbase, unsigned long fsize)
313{ 312{
314 struct page *page; 313 struct page *page;
315 int i; 314 unsigned long segments, stab_size;
316 unsigned long reg, segments, pages_per_segment, ptab_size, stab_size,
317 n_pte_pages, base;
318
319 base = dbase;
320 if (fsize != 0)
321 base = min(fbase, dbase);
322 315
323 segments = max(dbase + dsize, fbase + fsize) >> IO_SEGMENT_SHIFT; 316 segments = max(dbase + dsize, fbase + fsize) >> IO_SEGMENT_SHIFT;
324 pages_per_segment = 1ull << IO_PAGENO_BITS;
325 317
326 pr_debug("%s: iommu[%d]: segments: %lu, pages per segment: %lu\n", 318 pr_debug("%s: iommu[%d]: segments: %lu\n",
327 __FUNCTION__, iommu->nid, segments, pages_per_segment); 319 __FUNCTION__, iommu->nid, segments);
328 320
329 /* set up the segment table */ 321 /* set up the segment table */
330 stab_size = segments * sizeof(unsigned long); 322 stab_size = segments * sizeof(unsigned long);
331 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(stab_size)); 323 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(stab_size));
332 BUG_ON(!page); 324 BUG_ON(!page);
333 iommu->stab = page_address(page); 325 iommu->stab = page_address(page);
334 clear_page(iommu->stab); 326 memset(iommu->stab, 0, stab_size);
327}
328
329static unsigned long *cell_iommu_alloc_ptab(struct cbe_iommu *iommu,
330 unsigned long base, unsigned long size, unsigned long gap_base,
331 unsigned long gap_size, unsigned long page_shift)
332{
333 struct page *page;
334 int i;
335 unsigned long reg, segments, pages_per_segment, ptab_size,
336 n_pte_pages, start_seg, *ptab;
337
338 start_seg = base >> IO_SEGMENT_SHIFT;
339 segments = size >> IO_SEGMENT_SHIFT;
340 pages_per_segment = 1ull << IO_PAGENO_BITS(page_shift);
341 /* PTEs for each segment must start on a 4K bounday */
342 pages_per_segment = max(pages_per_segment,
343 (1 << 12) / sizeof(unsigned long));
335 344
336 /* ... and the page tables. Since these are contiguous, we can treat
337 * the page tables as one array of ptes, like pSeries does.
338 */
339 ptab_size = segments * pages_per_segment * sizeof(unsigned long); 345 ptab_size = segments * pages_per_segment * sizeof(unsigned long);
340 pr_debug("%s: iommu[%d]: ptab_size: %lu, order: %d\n", __FUNCTION__, 346 pr_debug("%s: iommu[%d]: ptab_size: %lu, order: %d\n", __FUNCTION__,
341 iommu->nid, ptab_size, get_order(ptab_size)); 347 iommu->nid, ptab_size, get_order(ptab_size));
342 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(ptab_size)); 348 page = alloc_pages_node(iommu->nid, GFP_KERNEL, get_order(ptab_size));
343 BUG_ON(!page); 349 BUG_ON(!page);
344 350
345 iommu->ptab = page_address(page); 351 ptab = page_address(page);
346 memset(iommu->ptab, 0, ptab_size); 352 memset(ptab, 0, ptab_size);
347 353
348 /* allocate a bogus page for the end of each mapping */ 354 /* number of 4K pages needed for a page table */
349 page = alloc_pages_node(iommu->nid, GFP_KERNEL, 0); 355 n_pte_pages = (pages_per_segment * sizeof(unsigned long)) >> 12;
350 BUG_ON(!page);
351 iommu->pad_page = page_address(page);
352 clear_page(iommu->pad_page);
353
354 /* number of pages needed for a page table */
355 n_pte_pages = (pages_per_segment *
356 sizeof(unsigned long)) >> IOMMU_PAGE_SHIFT;
357 356
358 pr_debug("%s: iommu[%d]: stab at %p, ptab at %p, n_pte_pages: %lu\n", 357 pr_debug("%s: iommu[%d]: stab at %p, ptab at %p, n_pte_pages: %lu\n",
359 __FUNCTION__, iommu->nid, iommu->stab, iommu->ptab, 358 __FUNCTION__, iommu->nid, iommu->stab, ptab,
360 n_pte_pages); 359 n_pte_pages);
361 360
362 /* initialise the STEs */ 361 /* initialise the STEs */
363 reg = IOSTE_V | ((n_pte_pages - 1) << 5); 362 reg = IOSTE_V | ((n_pte_pages - 1) << 5);
364 363
365 if (IOMMU_PAGE_SIZE == 0x1000) 364 switch (page_shift) {
366 reg |= IOSTE_PS_4K; 365 case 12: reg |= IOSTE_PS_4K; break;
367 else if (IOMMU_PAGE_SIZE == 0x10000) 366 case 16: reg |= IOSTE_PS_64K; break;
368 reg |= IOSTE_PS_64K; 367 case 20: reg |= IOSTE_PS_1M; break;
369 else { 368 case 24: reg |= IOSTE_PS_16M; break;
370 extern void __unknown_page_size_error(void); 369 default: BUG();
371 __unknown_page_size_error();
372 } 370 }
373 371
372 gap_base = gap_base >> IO_SEGMENT_SHIFT;
373 gap_size = gap_size >> IO_SEGMENT_SHIFT;
374
374 pr_debug("Setting up IOMMU stab:\n"); 375 pr_debug("Setting up IOMMU stab:\n");
375 for (i = base >> IO_SEGMENT_SHIFT; i < segments; i++) { 376 for (i = start_seg; i < (start_seg + segments); i++) {
376 iommu->stab[i] = reg | 377 if (i >= gap_base && i < (gap_base + gap_size)) {
377 (__pa(iommu->ptab) + n_pte_pages * IOMMU_PAGE_SIZE * i); 378 pr_debug("\toverlap at %d, skipping\n", i);
379 continue;
380 }
381 iommu->stab[i] = reg | (__pa(ptab) + (n_pte_pages << 12) *
382 (i - start_seg));
378 pr_debug("\t[%d] 0x%016lx\n", i, iommu->stab[i]); 383 pr_debug("\t[%d] 0x%016lx\n", i, iommu->stab[i]);
379 } 384 }
385
386 return ptab;
380} 387}
381 388
382static void cell_iommu_enable_hardware(struct cbe_iommu *iommu) 389static void cell_iommu_enable_hardware(struct cbe_iommu *iommu)
@@ -423,7 +430,9 @@ static void cell_iommu_enable_hardware(struct cbe_iommu *iommu)
423static void cell_iommu_setup_hardware(struct cbe_iommu *iommu, 430static void cell_iommu_setup_hardware(struct cbe_iommu *iommu,
424 unsigned long base, unsigned long size) 431 unsigned long base, unsigned long size)
425{ 432{
426 cell_iommu_setup_page_tables(iommu, base, size, 0, 0); 433 cell_iommu_setup_stab(iommu, base, size, 0, 0);
434 iommu->ptab = cell_iommu_alloc_ptab(iommu, base, size, 0, 0,
435 IOMMU_PAGE_SHIFT);
427 cell_iommu_enable_hardware(iommu); 436 cell_iommu_enable_hardware(iommu);
428} 437}
429 438
@@ -464,6 +473,7 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
464 unsigned long pte_offset) 473 unsigned long pte_offset)
465{ 474{
466 struct iommu_window *window; 475 struct iommu_window *window;
476 struct page *page;
467 u32 ioid; 477 u32 ioid;
468 478
469 ioid = cell_iommu_get_ioid(np); 479 ioid = cell_iommu_get_ioid(np);
@@ -475,13 +485,11 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
475 window->size = size; 485 window->size = size;
476 window->ioid = ioid; 486 window->ioid = ioid;
477 window->iommu = iommu; 487 window->iommu = iommu;
478 window->pte_offset = pte_offset;
479 488
480 window->table.it_blocksize = 16; 489 window->table.it_blocksize = 16;
481 window->table.it_base = (unsigned long)iommu->ptab; 490 window->table.it_base = (unsigned long)iommu->ptab;
482 window->table.it_index = iommu->nid; 491 window->table.it_index = iommu->nid;
483 window->table.it_offset = (offset >> IOMMU_PAGE_SHIFT) + 492 window->table.it_offset = (offset >> IOMMU_PAGE_SHIFT) + pte_offset;
484 window->pte_offset;
485 window->table.it_size = size >> IOMMU_PAGE_SHIFT; 493 window->table.it_size = size >> IOMMU_PAGE_SHIFT;
486 494
487 iommu_init_table(&window->table, iommu->nid); 495 iommu_init_table(&window->table, iommu->nid);
@@ -504,6 +512,11 @@ cell_iommu_setup_window(struct cbe_iommu *iommu, struct device_node *np,
504 * This code also assumes that we have a window that starts at 0, 512 * This code also assumes that we have a window that starts at 0,
505 * which is the case on all spider based blades. 513 * which is the case on all spider based blades.
506 */ 514 */
515 page = alloc_pages_node(iommu->nid, GFP_KERNEL, 0);
516 BUG_ON(!page);
517 iommu->pad_page = page_address(page);
518 clear_page(iommu->pad_page);
519
507 __set_bit(0, window->table.it_map); 520 __set_bit(0, window->table.it_map);
508 tce_build_cell(&window->table, window->table.it_offset, 1, 521 tce_build_cell(&window->table, window->table.it_offset, 1,
509 (unsigned long)iommu->pad_page, DMA_TO_DEVICE); 522 (unsigned long)iommu->pad_page, DMA_TO_DEVICE);
@@ -549,7 +562,7 @@ static void cell_dma_dev_setup_iommu(struct device *dev)
549 archdata->dma_data = &window->table; 562 archdata->dma_data = &window->table;
550} 563}
551 564
552static void cell_dma_dev_setup_static(struct device *dev); 565static void cell_dma_dev_setup_fixed(struct device *dev);
553 566
554static void cell_dma_dev_setup(struct device *dev) 567static void cell_dma_dev_setup(struct device *dev)
555{ 568{
@@ -557,7 +570,7 @@ static void cell_dma_dev_setup(struct device *dev)
557 570
558 /* Order is important here, these are not mutually exclusive */ 571 /* Order is important here, these are not mutually exclusive */
559 if (get_dma_ops(dev) == &dma_iommu_fixed_ops) 572 if (get_dma_ops(dev) == &dma_iommu_fixed_ops)
560 cell_dma_dev_setup_static(dev); 573 cell_dma_dev_setup_fixed(dev);
561 else if (get_pci_dma_ops() == &dma_iommu_ops) 574 else if (get_pci_dma_ops() == &dma_iommu_ops)
562 cell_dma_dev_setup_iommu(dev); 575 cell_dma_dev_setup_iommu(dev);
563 else if (get_pci_dma_ops() == &dma_direct_ops) 576 else if (get_pci_dma_ops() == &dma_direct_ops)
@@ -858,7 +871,7 @@ static int dma_set_mask_and_switch(struct device *dev, u64 dma_mask)
858 return 0; 871 return 0;
859} 872}
860 873
861static void cell_dma_dev_setup_static(struct device *dev) 874static void cell_dma_dev_setup_fixed(struct device *dev)
862{ 875{
863 struct dev_archdata *archdata = &dev->archdata; 876 struct dev_archdata *archdata = &dev->archdata;
864 u64 addr; 877 u64 addr;
@@ -869,35 +882,45 @@ static void cell_dma_dev_setup_static(struct device *dev)
869 dev_dbg(dev, "iommu: fixed addr = %lx\n", addr); 882 dev_dbg(dev, "iommu: fixed addr = %lx\n", addr);
870} 883}
871 884
885static void insert_16M_pte(unsigned long addr, unsigned long *ptab,
886 unsigned long base_pte)
887{
888 unsigned long segment, offset;
889
890 segment = addr >> IO_SEGMENT_SHIFT;
891 offset = (addr >> 24) - (segment << IO_PAGENO_BITS(24));
892 ptab = ptab + (segment * (1 << 12) / sizeof(unsigned long));
893
894 pr_debug("iommu: addr %lx ptab %p segment %lx offset %lx\n",
895 addr, ptab, segment, offset);
896
897 ptab[offset] = base_pte | (__pa(addr) & IOPTE_RPN_Mask);
898}
899
872static void cell_iommu_setup_fixed_ptab(struct cbe_iommu *iommu, 900static void cell_iommu_setup_fixed_ptab(struct cbe_iommu *iommu,
873 struct device_node *np, unsigned long dbase, unsigned long dsize, 901 struct device_node *np, unsigned long dbase, unsigned long dsize,
874 unsigned long fbase, unsigned long fsize) 902 unsigned long fbase, unsigned long fsize)
875{ 903{
876 unsigned long base_pte, uaddr, *io_pte; 904 unsigned long base_pte, uaddr, ioaddr, *ptab;
877 int i;
878 905
879 dma_iommu_fixed_base = fbase; 906 ptab = cell_iommu_alloc_ptab(iommu, fbase, fsize, dbase, dsize, 24);
880 907
881 /* convert from bytes into page table indices */ 908 dma_iommu_fixed_base = fbase;
882 dbase = dbase >> IOMMU_PAGE_SHIFT;
883 dsize = dsize >> IOMMU_PAGE_SHIFT;
884 fbase = fbase >> IOMMU_PAGE_SHIFT;
885 fsize = fsize >> IOMMU_PAGE_SHIFT;
886 909
887 pr_debug("iommu: mapping 0x%lx pages from 0x%lx\n", fsize, fbase); 910 pr_debug("iommu: mapping 0x%lx pages from 0x%lx\n", fsize, fbase);
888 911
889 io_pte = iommu->ptab;
890 base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW 912 base_pte = IOPTE_PP_W | IOPTE_PP_R | IOPTE_M | IOPTE_SO_RW
891 | (cell_iommu_get_ioid(np) & IOPTE_IOID_Mask); 913 | (cell_iommu_get_ioid(np) & IOPTE_IOID_Mask);
892 914
893 uaddr = 0; 915 for (uaddr = 0; uaddr < fsize; uaddr += (1 << 24)) {
894 for (i = fbase; i < fbase + fsize; i++, uaddr += IOMMU_PAGE_SIZE) {
895 /* Don't touch the dynamic region */ 916 /* Don't touch the dynamic region */
896 if (i >= dbase && i < (dbase + dsize)) { 917 ioaddr = uaddr + fbase;
897 pr_debug("iommu: static/dynamic overlap, skipping\n"); 918 if (ioaddr >= dbase && ioaddr < (dbase + dsize)) {
919 pr_debug("iommu: fixed/dynamic overlap, skipping\n");
898 continue; 920 continue;
899 } 921 }
900 io_pte[i] = base_pte | (__pa(uaddr) & IOPTE_RPN_Mask); 922
923 insert_16M_pte(uaddr, ptab, base_pte);
901 } 924 }
902 925
903 mb(); 926 mb();
@@ -995,7 +1018,9 @@ static int __init cell_iommu_fixed_mapping_init(void)
995 "fixed window 0x%lx-0x%lx\n", iommu->nid, dbase, 1018 "fixed window 0x%lx-0x%lx\n", iommu->nid, dbase,
996 dbase + dsize, fbase, fbase + fsize); 1019 dbase + dsize, fbase, fbase + fsize);
997 1020
998 cell_iommu_setup_page_tables(iommu, dbase, dsize, fbase, fsize); 1021 cell_iommu_setup_stab(iommu, dbase, dsize, fbase, fsize);
1022 iommu->ptab = cell_iommu_alloc_ptab(iommu, dbase, dsize, 0, 0,
1023 IOMMU_PAGE_SHIFT);
999 cell_iommu_setup_fixed_ptab(iommu, np, dbase, dsize, 1024 cell_iommu_setup_fixed_ptab(iommu, np, dbase, dsize,
1000 fbase, fsize); 1025 fbase, fsize);
1001 cell_iommu_enable_hardware(iommu); 1026 cell_iommu_enable_hardware(iommu);
diff --git a/arch/powerpc/platforms/cell/setup.c b/arch/powerpc/platforms/cell/setup.c
index a7f609b3b876..dda34650cb07 100644
--- a/arch/powerpc/platforms/cell/setup.c
+++ b/arch/powerpc/platforms/cell/setup.c
@@ -149,6 +149,11 @@ static void __init cell_init_irq(void)
149 mpic_init_IRQ(); 149 mpic_init_IRQ();
150} 150}
151 151
152static void __init cell_set_dabrx(void)
153{
154 mtspr(SPRN_DABRX, DABRX_KERNEL | DABRX_USER);
155}
156
152static void __init cell_setup_arch(void) 157static void __init cell_setup_arch(void)
153{ 158{
154#ifdef CONFIG_SPU_BASE 159#ifdef CONFIG_SPU_BASE
@@ -158,6 +163,8 @@ static void __init cell_setup_arch(void)
158 163
159 cbe_regs_init(); 164 cbe_regs_init();
160 165
166 cell_set_dabrx();
167
161#ifdef CONFIG_CBE_RAS 168#ifdef CONFIG_CBE_RAS
162 cbe_ras_init(); 169 cbe_ras_init();
163#endif 170#endif
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index 87eb07f94c5f..712001f6b7da 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -81,9 +81,12 @@ struct spu_slb {
81void spu_invalidate_slbs(struct spu *spu) 81void spu_invalidate_slbs(struct spu *spu)
82{ 82{
83 struct spu_priv2 __iomem *priv2 = spu->priv2; 83 struct spu_priv2 __iomem *priv2 = spu->priv2;
84 unsigned long flags;
84 85
86 spin_lock_irqsave(&spu->register_lock, flags);
85 if (spu_mfc_sr1_get(spu) & MFC_STATE1_RELOCATE_MASK) 87 if (spu_mfc_sr1_get(spu) & MFC_STATE1_RELOCATE_MASK)
86 out_be64(&priv2->slb_invalidate_all_W, 0UL); 88 out_be64(&priv2->slb_invalidate_all_W, 0UL);
89 spin_unlock_irqrestore(&spu->register_lock, flags);
87} 90}
88EXPORT_SYMBOL_GPL(spu_invalidate_slbs); 91EXPORT_SYMBOL_GPL(spu_invalidate_slbs);
89 92
@@ -148,7 +151,11 @@ static inline void spu_load_slb(struct spu *spu, int slbe, struct spu_slb *slb)
148 __func__, slbe, slb->vsid, slb->esid); 151 __func__, slbe, slb->vsid, slb->esid);
149 152
150 out_be64(&priv2->slb_index_W, slbe); 153 out_be64(&priv2->slb_index_W, slbe);
154 /* set invalid before writing vsid */
155 out_be64(&priv2->slb_esid_RW, 0);
156 /* now it's safe to write the vsid */
151 out_be64(&priv2->slb_vsid_RW, slb->vsid); 157 out_be64(&priv2->slb_vsid_RW, slb->vsid);
158 /* setting the new esid makes the entry valid again */
152 out_be64(&priv2->slb_esid_RW, slb->esid); 159 out_be64(&priv2->slb_esid_RW, slb->esid);
153} 160}
154 161
@@ -290,9 +297,11 @@ void spu_setup_kernel_slbs(struct spu *spu, struct spu_lscsa *lscsa,
290 nr_slbs++; 297 nr_slbs++;
291 } 298 }
292 299
300 spin_lock_irq(&spu->register_lock);
293 /* Add the set of SLBs */ 301 /* Add the set of SLBs */
294 for (i = 0; i < nr_slbs; i++) 302 for (i = 0; i < nr_slbs; i++)
295 spu_load_slb(spu, i, &slbs[i]); 303 spu_load_slb(spu, i, &slbs[i]);
304 spin_unlock_irq(&spu->register_lock);
296} 305}
297EXPORT_SYMBOL_GPL(spu_setup_kernel_slbs); 306EXPORT_SYMBOL_GPL(spu_setup_kernel_slbs);
298 307
@@ -337,13 +346,14 @@ spu_irq_class_1(int irq, void *data)
337 if (stat & CLASS1_STORAGE_FAULT_INTR) 346 if (stat & CLASS1_STORAGE_FAULT_INTR)
338 spu_mfc_dsisr_set(spu, 0ul); 347 spu_mfc_dsisr_set(spu, 0ul);
339 spu_int_stat_clear(spu, 1, stat); 348 spu_int_stat_clear(spu, 1, stat);
340 spin_unlock(&spu->register_lock);
341 pr_debug("%s: %lx %lx %lx %lx\n", __FUNCTION__, mask, stat,
342 dar, dsisr);
343 349
344 if (stat & CLASS1_SEGMENT_FAULT_INTR) 350 if (stat & CLASS1_SEGMENT_FAULT_INTR)
345 __spu_trap_data_seg(spu, dar); 351 __spu_trap_data_seg(spu, dar);
346 352
353 spin_unlock(&spu->register_lock);
354 pr_debug("%s: %lx %lx %lx %lx\n", __FUNCTION__, mask, stat,
355 dar, dsisr);
356
347 if (stat & CLASS1_STORAGE_FAULT_INTR) 357 if (stat & CLASS1_STORAGE_FAULT_INTR)
348 __spu_trap_data_map(spu, dar, dsisr); 358 __spu_trap_data_map(spu, dar, dsisr);
349 359
diff --git a/arch/powerpc/platforms/cell/spufs/context.c b/arch/powerpc/platforms/cell/spufs/context.c
index 133995ed5cc7..cf6c2c89211d 100644
--- a/arch/powerpc/platforms/cell/spufs/context.c
+++ b/arch/powerpc/platforms/cell/spufs/context.c
@@ -109,13 +109,12 @@ void spu_forget(struct spu_context *ctx)
109 109
110 /* 110 /*
111 * This is basically an open-coded spu_acquire_saved, except that 111 * This is basically an open-coded spu_acquire_saved, except that
112 * we don't acquire the state mutex interruptible. 112 * we don't acquire the state mutex interruptible, and we don't
113 * want this context to be rescheduled on release.
113 */ 114 */
114 mutex_lock(&ctx->state_mutex); 115 mutex_lock(&ctx->state_mutex);
115 if (ctx->state != SPU_STATE_SAVED) { 116 if (ctx->state != SPU_STATE_SAVED)
116 set_bit(SPU_SCHED_WAS_ACTIVE, &ctx->sched_flags);
117 spu_deactivate(ctx); 117 spu_deactivate(ctx);
118 }
119 118
120 mm = ctx->owner; 119 mm = ctx->owner;
121 ctx->owner = NULL; 120 ctx->owner = NULL;
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index c66c3756970d..f7a7e8635fb6 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -367,6 +367,13 @@ static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
367 return NOPFN_SIGBUS; 367 return NOPFN_SIGBUS;
368 368
369 /* 369 /*
370 * Because we release the mmap_sem, the context may be destroyed while
371 * we're in spu_wait. Grab an extra reference so it isn't destroyed
372 * in the meantime.
373 */
374 get_spu_context(ctx);
375
376 /*
370 * We have to wait for context to be loaded before we have 377 * We have to wait for context to be loaded before we have
371 * pages to hand out to the user, but we don't want to wait 378 * pages to hand out to the user, but we don't want to wait
372 * with the mmap_sem held. 379 * with the mmap_sem held.
@@ -375,7 +382,7 @@ static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
375 * hanged. 382 * hanged.
376 */ 383 */
377 if (spu_acquire(ctx)) 384 if (spu_acquire(ctx))
378 return NOPFN_REFAULT; 385 goto refault;
379 386
380 if (ctx->state == SPU_STATE_SAVED) { 387 if (ctx->state == SPU_STATE_SAVED) {
381 up_read(&current->mm->mmap_sem); 388 up_read(&current->mm->mmap_sem);
@@ -391,6 +398,9 @@ static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
391 398
392 if (!ret) 399 if (!ret)
393 spu_release(ctx); 400 spu_release(ctx);
401
402refault:
403 put_spu_context(ctx);
394 return NOPFN_REFAULT; 404 return NOPFN_REFAULT;
395} 405}
396 406
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 3a5972117de7..5d5f680cd0b8 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -246,7 +246,7 @@ static void spu_bind_context(struct spu *spu, struct spu_context *ctx)
246 spu_switch_notify(spu, ctx); 246 spu_switch_notify(spu, ctx);
247 ctx->state = SPU_STATE_RUNNABLE; 247 ctx->state = SPU_STATE_RUNNABLE;
248 248
249 spuctx_switch_state(ctx, SPU_UTIL_IDLE_LOADED); 249 spuctx_switch_state(ctx, SPU_UTIL_USER);
250} 250}
251 251
252/* 252/*
diff --git a/arch/powerpc/platforms/cell/spufs/sputrace.c b/arch/powerpc/platforms/cell/spufs/sputrace.c
index 01974f7776e1..79aa773f3c99 100644
--- a/arch/powerpc/platforms/cell/spufs/sputrace.c
+++ b/arch/powerpc/platforms/cell/spufs/sputrace.c
@@ -58,12 +58,12 @@ static int sputrace_sprint(char *tbuf, int n)
58 ktime_to_timespec(ktime_sub(t->tstamp, sputrace_start)); 58 ktime_to_timespec(ktime_sub(t->tstamp, sputrace_start));
59 59
60 return snprintf(tbuf, n, 60 return snprintf(tbuf, n,
61 "[%lu.%09lu] %d: %s (thread = %d, spu = %d)\n", 61 "[%lu.%09lu] %d: %s (ctxthread = %d, spu = %d)\n",
62 (unsigned long) tv.tv_sec, 62 (unsigned long) tv.tv_sec,
63 (unsigned long) tv.tv_nsec, 63 (unsigned long) tv.tv_nsec,
64 t->owner_tid,
65 t->name,
66 t->curr_tid, 64 t->curr_tid,
65 t->name,
66 t->owner_tid,
67 t->number); 67 t->number);
68} 68}
69 69
@@ -188,6 +188,7 @@ struct spu_probe spu_probes[] = {
188 { "spufs_ps_nopfn__insert", "%p %p", spu_context_event }, 188 { "spufs_ps_nopfn__insert", "%p %p", spu_context_event },
189 { "spu_acquire_saved__enter", "%p", spu_context_nospu_event }, 189 { "spu_acquire_saved__enter", "%p", spu_context_nospu_event },
190 { "destroy_spu_context__enter", "%p", spu_context_nospu_event }, 190 { "destroy_spu_context__enter", "%p", spu_context_nospu_event },
191 { "spufs_stop_callback__enter", "%p %p", spu_context_event },
191}; 192};
192 193
193static int __init sputrace_init(void) 194static int __init sputrace_init(void)
diff --git a/arch/powerpc/platforms/cell/spufs/switch.c b/arch/powerpc/platforms/cell/spufs/switch.c
index 6f5886c7b1f9..e9dc7a55d1b9 100644
--- a/arch/powerpc/platforms/cell/spufs/switch.c
+++ b/arch/powerpc/platforms/cell/spufs/switch.c
@@ -34,6 +34,7 @@
34 34
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/errno.h> 36#include <linux/errno.h>
37#include <linux/hardirq.h>
37#include <linux/sched.h> 38#include <linux/sched.h>
38#include <linux/kernel.h> 39#include <linux/kernel.h>
39#include <linux/mm.h> 40#include <linux/mm.h>
@@ -117,6 +118,8 @@ static inline void disable_interrupts(struct spu_state *csa, struct spu *spu)
117 * Write INT_MASK_class1 with value of 0. 118 * Write INT_MASK_class1 with value of 0.
118 * Save INT_Mask_class2 in CSA. 119 * Save INT_Mask_class2 in CSA.
119 * Write INT_MASK_class2 with value of 0. 120 * Write INT_MASK_class2 with value of 0.
121 * Synchronize all three interrupts to be sure
122 * we no longer execute a handler on another CPU.
120 */ 123 */
121 spin_lock_irq(&spu->register_lock); 124 spin_lock_irq(&spu->register_lock);
122 if (csa) { 125 if (csa) {
@@ -129,6 +132,9 @@ static inline void disable_interrupts(struct spu_state *csa, struct spu *spu)
129 spu_int_mask_set(spu, 2, 0ul); 132 spu_int_mask_set(spu, 2, 0ul);
130 eieio(); 133 eieio();
131 spin_unlock_irq(&spu->register_lock); 134 spin_unlock_irq(&spu->register_lock);
135 synchronize_irq(spu->irqs[0]);
136 synchronize_irq(spu->irqs[1]);
137 synchronize_irq(spu->irqs[2]);
132} 138}
133 139
134static inline void set_watchdog_timer(struct spu_state *csa, struct spu *spu) 140static inline void set_watchdog_timer(struct spu_state *csa, struct spu *spu)
diff --git a/arch/powerpc/platforms/celleb/beat.h b/arch/powerpc/platforms/celleb/beat.h
index b2e292df13ca..ac82ac35b991 100644
--- a/arch/powerpc/platforms/celleb/beat.h
+++ b/arch/powerpc/platforms/celleb/beat.h
@@ -21,9 +21,6 @@
21#ifndef _CELLEB_BEAT_H 21#ifndef _CELLEB_BEAT_H
22#define _CELLEB_BEAT_H 22#define _CELLEB_BEAT_H
23 23
24#define DABRX_KERNEL (1UL<<1)
25#define DABRX_USER (1UL<<0)
26
27int64_t beat_get_term_char(uint64_t,uint64_t*,uint64_t*,uint64_t*); 24int64_t beat_get_term_char(uint64_t,uint64_t*,uint64_t*,uint64_t*);
28int64_t beat_put_term_char(uint64_t,uint64_t,uint64_t,uint64_t); 25int64_t beat_put_term_char(uint64_t,uint64_t,uint64_t,uint64_t);
29int64_t beat_repository_encode(int, const char *, uint64_t[4]); 26int64_t beat_repository_encode(int, const char *, uint64_t[4]);
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 7049294fb469..14e48b5a94ba 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -26,7 +26,6 @@ struct cpa_data {
26 pgprot_t mask_set; 26 pgprot_t mask_set;
27 pgprot_t mask_clr; 27 pgprot_t mask_clr;
28 int numpages; 28 int numpages;
29 int processed;
30 int flushtlb; 29 int flushtlb;
31 unsigned long pfn; 30 unsigned long pfn;
32}; 31};
@@ -291,8 +290,8 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
291 */ 290 */
292 nextpage_addr = (address + psize) & pmask; 291 nextpage_addr = (address + psize) & pmask;
293 numpages = (nextpage_addr - address) >> PAGE_SHIFT; 292 numpages = (nextpage_addr - address) >> PAGE_SHIFT;
294 if (numpages < cpa->processed) 293 if (numpages < cpa->numpages)
295 cpa->processed = numpages; 294 cpa->numpages = numpages;
296 295
297 /* 296 /*
298 * We are safe now. Check whether the new pgprot is the same: 297 * We are safe now. Check whether the new pgprot is the same:
@@ -319,7 +318,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
319 */ 318 */
320 addr = address + PAGE_SIZE; 319 addr = address + PAGE_SIZE;
321 pfn++; 320 pfn++;
322 for (i = 1; i < cpa->processed; i++, addr += PAGE_SIZE, pfn++) { 321 for (i = 1; i < cpa->numpages; i++, addr += PAGE_SIZE, pfn++) {
323 pgprot_t chk_prot = static_protections(new_prot, addr, pfn); 322 pgprot_t chk_prot = static_protections(new_prot, addr, pfn);
324 323
325 if (pgprot_val(chk_prot) != pgprot_val(new_prot)) 324 if (pgprot_val(chk_prot) != pgprot_val(new_prot))
@@ -343,7 +342,7 @@ try_preserve_large_page(pte_t *kpte, unsigned long address,
343 * that we limited the number of possible pages already to 342 * that we limited the number of possible pages already to
344 * the number of pages in the large page. 343 * the number of pages in the large page.
345 */ 344 */
346 if (address == (nextpage_addr - psize) && cpa->processed == numpages) { 345 if (address == (nextpage_addr - psize) && cpa->numpages == numpages) {
347 /* 346 /*
348 * The address is aligned and the number of pages 347 * The address is aligned and the number of pages
349 * covers the full page. 348 * covers the full page.
@@ -573,7 +572,7 @@ repeat:
573 set_pte_atomic(kpte, new_pte); 572 set_pte_atomic(kpte, new_pte);
574 cpa->flushtlb = 1; 573 cpa->flushtlb = 1;
575 } 574 }
576 cpa->processed = 1; 575 cpa->numpages = 1;
577 return 0; 576 return 0;
578 } 577 }
579 578
@@ -584,7 +583,7 @@ repeat:
584 do_split = try_preserve_large_page(kpte, address, cpa); 583 do_split = try_preserve_large_page(kpte, address, cpa);
585 /* 584 /*
586 * When the range fits into the existing large page, 585 * When the range fits into the existing large page,
587 * return. cp->processed and cpa->tlbflush have been updated in 586 * return. cp->numpages and cpa->tlbflush have been updated in
588 * try_large_page: 587 * try_large_page:
589 */ 588 */
590 if (do_split <= 0) 589 if (do_split <= 0)
@@ -663,7 +662,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
663 * Store the remaining nr of pages for the large page 662 * Store the remaining nr of pages for the large page
664 * preservation check. 663 * preservation check.
665 */ 664 */
666 cpa->numpages = cpa->processed = numpages; 665 cpa->numpages = numpages;
667 666
668 ret = __change_page_attr(cpa, checkalias); 667 ret = __change_page_attr(cpa, checkalias);
669 if (ret) 668 if (ret)
@@ -680,9 +679,9 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias)
680 * CPA operation. Either a large page has been 679 * CPA operation. Either a large page has been
681 * preserved or a single page update happened. 680 * preserved or a single page update happened.
682 */ 681 */
683 BUG_ON(cpa->processed > numpages); 682 BUG_ON(cpa->numpages > numpages);
684 numpages -= cpa->processed; 683 numpages -= cpa->numpages;
685 cpa->vaddr += cpa->processed * PAGE_SIZE; 684 cpa->vaddr += cpa->numpages * PAGE_SIZE;
686 } 685 }
687 return 0; 686 return 0;
688} 687}
diff --git a/drivers/acorn/char/defkeymap-l7200.c b/drivers/acorn/char/defkeymap-l7200.c
index 28a5fbc6aa1a..93d80a1c36f9 100644
--- a/drivers/acorn/char/defkeymap-l7200.c
+++ b/drivers/acorn/char/defkeymap-l7200.c
@@ -347,40 +347,40 @@ char *func_table[MAX_NR_FUNC] = {
347}; 347};
348 348
349struct kbdiacruc accent_table[MAX_DIACR] = { 349struct kbdiacruc accent_table[MAX_DIACR] = {
350 {'`', 'A', '\300'}, {'`', 'a', '\340'}, 350 {'`', 'A', 0300}, {'`', 'a', 0340},
351 {'\'', 'A', '\301'}, {'\'', 'a', '\341'}, 351 {'\'', 'A', 0301}, {'\'', 'a', 0341},
352 {'^', 'A', '\302'}, {'^', 'a', '\342'}, 352 {'^', 'A', 0302}, {'^', 'a', 0342},
353 {'~', 'A', '\303'}, {'~', 'a', '\343'}, 353 {'~', 'A', 0303}, {'~', 'a', 0343},
354 {'"', 'A', '\304'}, {'"', 'a', '\344'}, 354 {'"', 'A', 0304}, {'"', 'a', 0344},
355 {'O', 'A', '\305'}, {'o', 'a', '\345'}, 355 {'O', 'A', 0305}, {'o', 'a', 0345},
356 {'0', 'A', '\305'}, {'0', 'a', '\345'}, 356 {'0', 'A', 0305}, {'0', 'a', 0345},
357 {'A', 'A', '\305'}, {'a', 'a', '\345'}, 357 {'A', 'A', 0305}, {'a', 'a', 0345},
358 {'A', 'E', '\306'}, {'a', 'e', '\346'}, 358 {'A', 'E', 0306}, {'a', 'e', 0346},
359 {',', 'C', '\307'}, {',', 'c', '\347'}, 359 {',', 'C', 0307}, {',', 'c', 0347},
360 {'`', 'E', '\310'}, {'`', 'e', '\350'}, 360 {'`', 'E', 0310}, {'`', 'e', 0350},
361 {'\'', 'E', '\311'}, {'\'', 'e', '\351'}, 361 {'\'', 'E', 0311}, {'\'', 'e', 0351},
362 {'^', 'E', '\312'}, {'^', 'e', '\352'}, 362 {'^', 'E', 0312}, {'^', 'e', 0352},
363 {'"', 'E', '\313'}, {'"', 'e', '\353'}, 363 {'"', 'E', 0313}, {'"', 'e', 0353},
364 {'`', 'I', '\314'}, {'`', 'i', '\354'}, 364 {'`', 'I', 0314}, {'`', 'i', 0354},
365 {'\'', 'I', '\315'}, {'\'', 'i', '\355'}, 365 {'\'', 'I', 0315}, {'\'', 'i', 0355},
366 {'^', 'I', '\316'}, {'^', 'i', '\356'}, 366 {'^', 'I', 0316}, {'^', 'i', 0356},
367 {'"', 'I', '\317'}, {'"', 'i', '\357'}, 367 {'"', 'I', 0317}, {'"', 'i', 0357},
368 {'-', 'D', '\320'}, {'-', 'd', '\360'}, 368 {'-', 'D', 0320}, {'-', 'd', 0360},
369 {'~', 'N', '\321'}, {'~', 'n', '\361'}, 369 {'~', 'N', 0321}, {'~', 'n', 0361},
370 {'`', 'O', '\322'}, {'`', 'o', '\362'}, 370 {'`', 'O', 0322}, {'`', 'o', 0362},
371 {'\'', 'O', '\323'}, {'\'', 'o', '\363'}, 371 {'\'', 'O', 0323}, {'\'', 'o', 0363},
372 {'^', 'O', '\324'}, {'^', 'o', '\364'}, 372 {'^', 'O', 0324}, {'^', 'o', 0364},
373 {'~', 'O', '\325'}, {'~', 'o', '\365'}, 373 {'~', 'O', 0325}, {'~', 'o', 0365},
374 {'"', 'O', '\326'}, {'"', 'o', '\366'}, 374 {'"', 'O', 0326}, {'"', 'o', 0366},
375 {'/', 'O', '\330'}, {'/', 'o', '\370'}, 375 {'/', 'O', 0330}, {'/', 'o', 0370},
376 {'`', 'U', '\331'}, {'`', 'u', '\371'}, 376 {'`', 'U', 0331}, {'`', 'u', 0371},
377 {'\'', 'U', '\332'}, {'\'', 'u', '\372'}, 377 {'\'', 'U', 0332}, {'\'', 'u', 0372},
378 {'^', 'U', '\333'}, {'^', 'u', '\373'}, 378 {'^', 'U', 0333}, {'^', 'u', 0373},
379 {'"', 'U', '\334'}, {'"', 'u', '\374'}, 379 {'"', 'U', 0334}, {'"', 'u', 0374},
380 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'}, 380 {'\'', 'Y', 0335}, {'\'', 'y', 0375},
381 {'T', 'H', '\336'}, {'t', 'h', '\376'}, 381 {'T', 'H', 0336}, {'t', 'h', 0376},
382 {'s', 's', '\337'}, {'"', 'y', '\377'}, 382 {'s', 's', 0337}, {'"', 'y', 0377},
383 {'s', 'z', '\337'}, {'i', 'j', '\377'}, 383 {'s', 'z', 0337}, {'i', 'j', 0377},
384}; 384};
385 385
386unsigned int accent_table_size = 68; 386unsigned int accent_table_size = 68;
diff --git a/drivers/base/transport_class.c b/drivers/base/transport_class.c
index f25e7c6b2d27..40bca48abc12 100644
--- a/drivers/base/transport_class.c
+++ b/drivers/base/transport_class.c
@@ -126,9 +126,7 @@ static int transport_setup_classdev(struct attribute_container *cont,
126} 126}
127 127
128/** 128/**
129 * transport_setup_device - declare a new dev for transport class association 129 * transport_setup_device - declare a new dev for transport class association but don't make it visible yet.
130 * but don't make it visible yet.
131 *
132 * @dev: the generic device representing the entity being added 130 * @dev: the generic device representing the entity being added
133 * 131 *
134 * Usually, dev represents some component in the HBA system (either 132 * Usually, dev represents some component in the HBA system (either
diff --git a/drivers/char/defkeymap.c_shipped b/drivers/char/defkeymap.c_shipped
index 0aa419a61767..d2208dfe3f67 100644
--- a/drivers/char/defkeymap.c_shipped
+++ b/drivers/char/defkeymap.c_shipped
@@ -223,40 +223,40 @@ char *func_table[MAX_NR_FUNC] = {
223}; 223};
224 224
225struct kbdiacruc accent_table[MAX_DIACR] = { 225struct kbdiacruc accent_table[MAX_DIACR] = {
226 {'`', 'A', '\300'}, {'`', 'a', '\340'}, 226 {'`', 'A', 0300}, {'`', 'a', 0340},
227 {'\'', 'A', '\301'}, {'\'', 'a', '\341'}, 227 {'\'', 'A', 0301}, {'\'', 'a', 0341},
228 {'^', 'A', '\302'}, {'^', 'a', '\342'}, 228 {'^', 'A', 0302}, {'^', 'a', 0342},
229 {'~', 'A', '\303'}, {'~', 'a', '\343'}, 229 {'~', 'A', 0303}, {'~', 'a', 0343},
230 {'"', 'A', '\304'}, {'"', 'a', '\344'}, 230 {'"', 'A', 0304}, {'"', 'a', 0344},
231 {'O', 'A', '\305'}, {'o', 'a', '\345'}, 231 {'O', 'A', 0305}, {'o', 'a', 0345},
232 {'0', 'A', '\305'}, {'0', 'a', '\345'}, 232 {'0', 'A', 0305}, {'0', 'a', 0345},
233 {'A', 'A', '\305'}, {'a', 'a', '\345'}, 233 {'A', 'A', 0305}, {'a', 'a', 0345},
234 {'A', 'E', '\306'}, {'a', 'e', '\346'}, 234 {'A', 'E', 0306}, {'a', 'e', 0346},
235 {',', 'C', '\307'}, {',', 'c', '\347'}, 235 {',', 'C', 0307}, {',', 'c', 0347},
236 {'`', 'E', '\310'}, {'`', 'e', '\350'}, 236 {'`', 'E', 0310}, {'`', 'e', 0350},
237 {'\'', 'E', '\311'}, {'\'', 'e', '\351'}, 237 {'\'', 'E', 0311}, {'\'', 'e', 0351},
238 {'^', 'E', '\312'}, {'^', 'e', '\352'}, 238 {'^', 'E', 0312}, {'^', 'e', 0352},
239 {'"', 'E', '\313'}, {'"', 'e', '\353'}, 239 {'"', 'E', 0313}, {'"', 'e', 0353},
240 {'`', 'I', '\314'}, {'`', 'i', '\354'}, 240 {'`', 'I', 0314}, {'`', 'i', 0354},
241 {'\'', 'I', '\315'}, {'\'', 'i', '\355'}, 241 {'\'', 'I', 0315}, {'\'', 'i', 0355},
242 {'^', 'I', '\316'}, {'^', 'i', '\356'}, 242 {'^', 'I', 0316}, {'^', 'i', 0356},
243 {'"', 'I', '\317'}, {'"', 'i', '\357'}, 243 {'"', 'I', 0317}, {'"', 'i', 0357},
244 {'-', 'D', '\320'}, {'-', 'd', '\360'}, 244 {'-', 'D', 0320}, {'-', 'd', 0360},
245 {'~', 'N', '\321'}, {'~', 'n', '\361'}, 245 {'~', 'N', 0321}, {'~', 'n', 0361},
246 {'`', 'O', '\322'}, {'`', 'o', '\362'}, 246 {'`', 'O', 0322}, {'`', 'o', 0362},
247 {'\'', 'O', '\323'}, {'\'', 'o', '\363'}, 247 {'\'', 'O', 0323}, {'\'', 'o', 0363},
248 {'^', 'O', '\324'}, {'^', 'o', '\364'}, 248 {'^', 'O', 0324}, {'^', 'o', 0364},
249 {'~', 'O', '\325'}, {'~', 'o', '\365'}, 249 {'~', 'O', 0325}, {'~', 'o', 0365},
250 {'"', 'O', '\326'}, {'"', 'o', '\366'}, 250 {'"', 'O', 0326}, {'"', 'o', 0366},
251 {'/', 'O', '\330'}, {'/', 'o', '\370'}, 251 {'/', 'O', 0330}, {'/', 'o', 0370},
252 {'`', 'U', '\331'}, {'`', 'u', '\371'}, 252 {'`', 'U', 0331}, {'`', 'u', 0371},
253 {'\'', 'U', '\332'}, {'\'', 'u', '\372'}, 253 {'\'', 'U', 0332}, {'\'', 'u', 0372},
254 {'^', 'U', '\333'}, {'^', 'u', '\373'}, 254 {'^', 'U', 0333}, {'^', 'u', 0373},
255 {'"', 'U', '\334'}, {'"', 'u', '\374'}, 255 {'"', 'U', 0334}, {'"', 'u', 0374},
256 {'\'', 'Y', '\335'}, {'\'', 'y', '\375'}, 256 {'\'', 'Y', 0335}, {'\'', 'y', 0375},
257 {'T', 'H', '\336'}, {'t', 'h', '\376'}, 257 {'T', 'H', 0336}, {'t', 'h', 0376},
258 {'s', 's', '\337'}, {'"', 'y', '\377'}, 258 {'s', 's', 0337}, {'"', 'y', 0377},
259 {'s', 'z', '\337'}, {'i', 'j', '\377'}, 259 {'s', 'z', 0337}, {'i', 'j', 0377},
260}; 260};
261 261
262unsigned int accent_table_size = 68; 262unsigned int accent_table_size = 68;
diff --git a/drivers/char/xilinx_hwicap/buffer_icap.c b/drivers/char/xilinx_hwicap/buffer_icap.c
index dfea2bde162b..f577daedb630 100644
--- a/drivers/char/xilinx_hwicap/buffer_icap.c
+++ b/drivers/char/xilinx_hwicap/buffer_icap.c
@@ -73,8 +73,8 @@
73#define XHI_BUFFER_START 0 73#define XHI_BUFFER_START 0
74 74
75/** 75/**
76 * buffer_icap_get_status: Get the contents of the status register. 76 * buffer_icap_get_status - Get the contents of the status register.
77 * @parameter base_address: is the base address of the device 77 * @base_address: is the base address of the device
78 * 78 *
79 * The status register contains the ICAP status and the done bit. 79 * The status register contains the ICAP status and the done bit.
80 * 80 *
@@ -94,9 +94,9 @@ static inline u32 buffer_icap_get_status(void __iomem *base_address)
94} 94}
95 95
96/** 96/**
97 * buffer_icap_get_bram: Reads data from the storage buffer bram. 97 * buffer_icap_get_bram - Reads data from the storage buffer bram.
98 * @parameter base_address: contains the base address of the component. 98 * @base_address: contains the base address of the component.
99 * @parameter offset: The word offset from which the data should be read. 99 * @offset: The word offset from which the data should be read.
100 * 100 *
101 * A bram is used as a configuration memory cache. One frame of data can 101 * A bram is used as a configuration memory cache. One frame of data can
102 * be stored in this "storage buffer". 102 * be stored in this "storage buffer".
@@ -108,8 +108,8 @@ static inline u32 buffer_icap_get_bram(void __iomem *base_address,
108} 108}
109 109
110/** 110/**
111 * buffer_icap_busy: Return true if the icap device is busy 111 * buffer_icap_busy - Return true if the icap device is busy
112 * @parameter base_address: is the base address of the device 112 * @base_address: is the base address of the device
113 * 113 *
114 * The queries the low order bit of the status register, which 114 * The queries the low order bit of the status register, which
115 * indicates whether the current configuration or readback operation 115 * indicates whether the current configuration or readback operation
@@ -121,8 +121,8 @@ static inline bool buffer_icap_busy(void __iomem *base_address)
121} 121}
122 122
123/** 123/**
124 * buffer_icap_busy: Return true if the icap device is not busy 124 * buffer_icap_busy - Return true if the icap device is not busy
125 * @parameter base_address: is the base address of the device 125 * @base_address: is the base address of the device
126 * 126 *
127 * The queries the low order bit of the status register, which 127 * The queries the low order bit of the status register, which
128 * indicates whether the current configuration or readback operation 128 * indicates whether the current configuration or readback operation
@@ -134,9 +134,9 @@ static inline bool buffer_icap_done(void __iomem *base_address)
134} 134}
135 135
136/** 136/**
137 * buffer_icap_set_size: Set the size register. 137 * buffer_icap_set_size - Set the size register.
138 * @parameter base_address: is the base address of the device 138 * @base_address: is the base address of the device
139 * @parameter data: The size in bytes. 139 * @data: The size in bytes.
140 * 140 *
141 * The size register holds the number of 8 bit bytes to transfer between 141 * The size register holds the number of 8 bit bytes to transfer between
142 * bram and the icap (or icap to bram). 142 * bram and the icap (or icap to bram).
@@ -148,9 +148,9 @@ static inline void buffer_icap_set_size(void __iomem *base_address,
148} 148}
149 149
150/** 150/**
151 * buffer_icap_mSetoffsetReg: Set the bram offset register. 151 * buffer_icap_set_offset - Set the bram offset register.
152 * @parameter base_address: contains the base address of the device. 152 * @base_address: contains the base address of the device.
153 * @parameter data: is the value to be written to the data register. 153 * @data: is the value to be written to the data register.
154 * 154 *
155 * The bram offset register holds the starting bram address to transfer 155 * The bram offset register holds the starting bram address to transfer
156 * data from during configuration or write data to during readback. 156 * data from during configuration or write data to during readback.
@@ -162,9 +162,9 @@ static inline void buffer_icap_set_offset(void __iomem *base_address,
162} 162}
163 163
164/** 164/**
165 * buffer_icap_set_rnc: Set the RNC (Readback not Configure) register. 165 * buffer_icap_set_rnc - Set the RNC (Readback not Configure) register.
166 * @parameter base_address: contains the base address of the device. 166 * @base_address: contains the base address of the device.
167 * @parameter data: is the value to be written to the data register. 167 * @data: is the value to be written to the data register.
168 * 168 *
169 * The RNC register determines the direction of the data transfer. It 169 * The RNC register determines the direction of the data transfer. It
170 * controls whether a configuration or readback take place. Writing to 170 * controls whether a configuration or readback take place. Writing to
@@ -178,10 +178,10 @@ static inline void buffer_icap_set_rnc(void __iomem *base_address,
178} 178}
179 179
180/** 180/**
181 * buffer_icap_set_bram: Write data to the storage buffer bram. 181 * buffer_icap_set_bram - Write data to the storage buffer bram.
182 * @parameter base_address: contains the base address of the component. 182 * @base_address: contains the base address of the component.
183 * @parameter offset: The word offset at which the data should be written. 183 * @offset: The word offset at which the data should be written.
184 * @parameter data: The value to be written to the bram offset. 184 * @data: The value to be written to the bram offset.
185 * 185 *
186 * A bram is used as a configuration memory cache. One frame of data can 186 * A bram is used as a configuration memory cache. One frame of data can
187 * be stored in this "storage buffer". 187 * be stored in this "storage buffer".
@@ -193,10 +193,10 @@ static inline void buffer_icap_set_bram(void __iomem *base_address,
193} 193}
194 194
195/** 195/**
196 * buffer_icap_device_read: Transfer bytes from ICAP to the storage buffer. 196 * buffer_icap_device_read - Transfer bytes from ICAP to the storage buffer.
197 * @parameter drvdata: a pointer to the drvdata. 197 * @drvdata: a pointer to the drvdata.
198 * @parameter offset: The storage buffer start address. 198 * @offset: The storage buffer start address.
199 * @parameter count: The number of words (32 bit) to read from the 199 * @count: The number of words (32 bit) to read from the
200 * device (ICAP). 200 * device (ICAP).
201 **/ 201 **/
202static int buffer_icap_device_read(struct hwicap_drvdata *drvdata, 202static int buffer_icap_device_read(struct hwicap_drvdata *drvdata,
@@ -227,10 +227,10 @@ static int buffer_icap_device_read(struct hwicap_drvdata *drvdata,
227}; 227};
228 228
229/** 229/**
230 * buffer_icap_device_write: Transfer bytes from ICAP to the storage buffer. 230 * buffer_icap_device_write - Transfer bytes from ICAP to the storage buffer.
231 * @parameter drvdata: a pointer to the drvdata. 231 * @drvdata: a pointer to the drvdata.
232 * @parameter offset: The storage buffer start address. 232 * @offset: The storage buffer start address.
233 * @parameter count: The number of words (32 bit) to read from the 233 * @count: The number of words (32 bit) to read from the
234 * device (ICAP). 234 * device (ICAP).
235 **/ 235 **/
236static int buffer_icap_device_write(struct hwicap_drvdata *drvdata, 236static int buffer_icap_device_write(struct hwicap_drvdata *drvdata,
@@ -261,8 +261,8 @@ static int buffer_icap_device_write(struct hwicap_drvdata *drvdata,
261}; 261};
262 262
263/** 263/**
264 * buffer_icap_reset: Reset the logic of the icap device. 264 * buffer_icap_reset - Reset the logic of the icap device.
265 * @parameter drvdata: a pointer to the drvdata. 265 * @drvdata: a pointer to the drvdata.
266 * 266 *
267 * Writing to the status register resets the ICAP logic in an internal 267 * Writing to the status register resets the ICAP logic in an internal
268 * version of the core. For the version of the core published in EDK, 268 * version of the core. For the version of the core published in EDK,
@@ -274,10 +274,10 @@ void buffer_icap_reset(struct hwicap_drvdata *drvdata)
274} 274}
275 275
276/** 276/**
277 * buffer_icap_set_configuration: Load a partial bitstream from system memory. 277 * buffer_icap_set_configuration - Load a partial bitstream from system memory.
278 * @parameter drvdata: a pointer to the drvdata. 278 * @drvdata: a pointer to the drvdata.
279 * @parameter data: Kernel address of the partial bitstream. 279 * @data: Kernel address of the partial bitstream.
280 * @parameter size: the size of the partial bitstream in 32 bit words. 280 * @size: the size of the partial bitstream in 32 bit words.
281 **/ 281 **/
282int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data, 282int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data,
283 u32 size) 283 u32 size)
@@ -333,10 +333,10 @@ int buffer_icap_set_configuration(struct hwicap_drvdata *drvdata, u32 *data,
333}; 333};
334 334
335/** 335/**
336 * buffer_icap_get_configuration: Read configuration data from the device. 336 * buffer_icap_get_configuration - Read configuration data from the device.
337 * @parameter drvdata: a pointer to the drvdata. 337 * @drvdata: a pointer to the drvdata.
338 * @parameter data: Address of the data representing the partial bitstream 338 * @data: Address of the data representing the partial bitstream
339 * @parameter size: the size of the partial bitstream in 32 bit words. 339 * @size: the size of the partial bitstream in 32 bit words.
340 **/ 340 **/
341int buffer_icap_get_configuration(struct hwicap_drvdata *drvdata, u32 *data, 341int buffer_icap_get_configuration(struct hwicap_drvdata *drvdata, u32 *data,
342 u32 size) 342 u32 size)
diff --git a/drivers/char/xilinx_hwicap/fifo_icap.c b/drivers/char/xilinx_hwicap/fifo_icap.c
index 0988314694a6..6f45dbd47125 100644
--- a/drivers/char/xilinx_hwicap/fifo_icap.c
+++ b/drivers/char/xilinx_hwicap/fifo_icap.c
@@ -94,9 +94,9 @@
94 94
95 95
96/** 96/**
97 * fifo_icap_fifo_write: Write data to the write FIFO. 97 * fifo_icap_fifo_write - Write data to the write FIFO.
98 * @parameter drvdata: a pointer to the drvdata. 98 * @drvdata: a pointer to the drvdata.
99 * @parameter data: the 32-bit value to be written to the FIFO. 99 * @data: the 32-bit value to be written to the FIFO.
100 * 100 *
101 * This function will silently fail if the fifo is full. 101 * This function will silently fail if the fifo is full.
102 **/ 102 **/
@@ -108,8 +108,8 @@ static inline void fifo_icap_fifo_write(struct hwicap_drvdata *drvdata,
108} 108}
109 109
110/** 110/**
111 * fifo_icap_fifo_read: Read data from the Read FIFO. 111 * fifo_icap_fifo_read - Read data from the Read FIFO.
112 * @parameter drvdata: a pointer to the drvdata. 112 * @drvdata: a pointer to the drvdata.
113 * 113 *
114 * This function will silently fail if the fifo is empty. 114 * This function will silently fail if the fifo is empty.
115 **/ 115 **/
@@ -121,9 +121,9 @@ static inline u32 fifo_icap_fifo_read(struct hwicap_drvdata *drvdata)
121} 121}
122 122
123/** 123/**
124 * fifo_icap_set_read_size: Set the the size register. 124 * fifo_icap_set_read_size - Set the the size register.
125 * @parameter drvdata: a pointer to the drvdata. 125 * @drvdata: a pointer to the drvdata.
126 * @parameter data: the size of the following read transaction, in words. 126 * @data: the size of the following read transaction, in words.
127 **/ 127 **/
128static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata, 128static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata,
129 u32 data) 129 u32 data)
@@ -132,8 +132,8 @@ static inline void fifo_icap_set_read_size(struct hwicap_drvdata *drvdata,
132} 132}
133 133
134/** 134/**
135 * fifo_icap_start_config: Initiate a configuration (write) to the device. 135 * fifo_icap_start_config - Initiate a configuration (write) to the device.
136 * @parameter drvdata: a pointer to the drvdata. 136 * @drvdata: a pointer to the drvdata.
137 **/ 137 **/
138static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata) 138static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata)
139{ 139{
@@ -142,8 +142,8 @@ static inline void fifo_icap_start_config(struct hwicap_drvdata *drvdata)
142} 142}
143 143
144/** 144/**
145 * fifo_icap_start_readback: Initiate a readback from the device. 145 * fifo_icap_start_readback - Initiate a readback from the device.
146 * @parameter drvdata: a pointer to the drvdata. 146 * @drvdata: a pointer to the drvdata.
147 **/ 147 **/
148static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata) 148static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata)
149{ 149{
@@ -152,8 +152,8 @@ static inline void fifo_icap_start_readback(struct hwicap_drvdata *drvdata)
152} 152}
153 153
154/** 154/**
155 * fifo_icap_busy: Return true if the ICAP is still processing a transaction. 155 * fifo_icap_busy - Return true if the ICAP is still processing a transaction.
156 * @parameter drvdata: a pointer to the drvdata. 156 * @drvdata: a pointer to the drvdata.
157 **/ 157 **/
158static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata) 158static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata)
159{ 159{
@@ -163,8 +163,8 @@ static inline u32 fifo_icap_busy(struct hwicap_drvdata *drvdata)
163} 163}
164 164
165/** 165/**
166 * fifo_icap_write_fifo_vacancy: Query the write fifo available space. 166 * fifo_icap_write_fifo_vacancy - Query the write fifo available space.
167 * @parameter drvdata: a pointer to the drvdata. 167 * @drvdata: a pointer to the drvdata.
168 * 168 *
169 * Return the number of words that can be safely pushed into the write fifo. 169 * Return the number of words that can be safely pushed into the write fifo.
170 **/ 170 **/
@@ -175,8 +175,8 @@ static inline u32 fifo_icap_write_fifo_vacancy(
175} 175}
176 176
177/** 177/**
178 * fifo_icap_read_fifo_occupancy: Query the read fifo available data. 178 * fifo_icap_read_fifo_occupancy - Query the read fifo available data.
179 * @parameter drvdata: a pointer to the drvdata. 179 * @drvdata: a pointer to the drvdata.
180 * 180 *
181 * Return the number of words that can be safely read from the read fifo. 181 * Return the number of words that can be safely read from the read fifo.
182 **/ 182 **/
@@ -187,11 +187,11 @@ static inline u32 fifo_icap_read_fifo_occupancy(
187} 187}
188 188
189/** 189/**
190 * fifo_icap_set_configuration: Send configuration data to the ICAP. 190 * fifo_icap_set_configuration - Send configuration data to the ICAP.
191 * @parameter drvdata: a pointer to the drvdata. 191 * @drvdata: a pointer to the drvdata.
192 * @parameter frame_buffer: a pointer to the data to be written to the 192 * @frame_buffer: a pointer to the data to be written to the
193 * ICAP device. 193 * ICAP device.
194 * @parameter num_words: the number of words (32 bit) to write to the ICAP 194 * @num_words: the number of words (32 bit) to write to the ICAP
195 * device. 195 * device.
196 196
197 * This function writes the given user data to the Write FIFO in 197 * This function writes the given user data to the Write FIFO in
@@ -266,10 +266,10 @@ int fifo_icap_set_configuration(struct hwicap_drvdata *drvdata,
266} 266}
267 267
268/** 268/**
269 * fifo_icap_get_configuration: Read configuration data from the device. 269 * fifo_icap_get_configuration - Read configuration data from the device.
270 * @parameter drvdata: a pointer to the drvdata. 270 * @drvdata: a pointer to the drvdata.
271 * @parameter data: Address of the data representing the partial bitstream 271 * @data: Address of the data representing the partial bitstream
272 * @parameter size: the size of the partial bitstream in 32 bit words. 272 * @size: the size of the partial bitstream in 32 bit words.
273 * 273 *
274 * This function reads the specified number of words from the ICAP device in 274 * This function reads the specified number of words from the ICAP device in
275 * the polled mode. 275 * the polled mode.
@@ -335,8 +335,8 @@ int fifo_icap_get_configuration(struct hwicap_drvdata *drvdata,
335} 335}
336 336
337/** 337/**
338 * buffer_icap_reset: Reset the logic of the icap device. 338 * buffer_icap_reset - Reset the logic of the icap device.
339 * @parameter drvdata: a pointer to the drvdata. 339 * @drvdata: a pointer to the drvdata.
340 * 340 *
341 * This function forces the software reset of the complete HWICAP device. 341 * This function forces the software reset of the complete HWICAP device.
342 * All the registers will return to the default value and the FIFO is also 342 * All the registers will return to the default value and the FIFO is also
@@ -360,8 +360,8 @@ void fifo_icap_reset(struct hwicap_drvdata *drvdata)
360} 360}
361 361
362/** 362/**
363 * fifo_icap_flush_fifo: This function flushes the FIFOs in the device. 363 * fifo_icap_flush_fifo - This function flushes the FIFOs in the device.
364 * @parameter drvdata: a pointer to the drvdata. 364 * @drvdata: a pointer to the drvdata.
365 */ 365 */
366void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata) 366void fifo_icap_flush_fifo(struct hwicap_drvdata *drvdata)
367{ 367{
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
index 24f6aef0fd3c..2284fa2a5a57 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c
@@ -84,7 +84,7 @@
84#include <linux/init.h> 84#include <linux/init.h>
85#include <linux/poll.h> 85#include <linux/poll.h>
86#include <linux/proc_fs.h> 86#include <linux/proc_fs.h>
87#include <asm/semaphore.h> 87#include <linux/mutex.h>
88#include <linux/sysctl.h> 88#include <linux/sysctl.h>
89#include <linux/version.h> 89#include <linux/version.h>
90#include <linux/fs.h> 90#include <linux/fs.h>
@@ -119,6 +119,7 @@ module_param(xhwicap_minor, int, S_IRUGO);
119 119
120/* An array, which is set to true when the device is registered. */ 120/* An array, which is set to true when the device is registered. */
121static bool probed_devices[HWICAP_DEVICES]; 121static bool probed_devices[HWICAP_DEVICES];
122static struct mutex icap_sem;
122 123
123static struct class *icap_class; 124static struct class *icap_class;
124 125
@@ -199,14 +200,14 @@ static const struct config_registers v5_config_registers = {
199}; 200};
200 201
201/** 202/**
202 * hwicap_command_desync: Send a DESYNC command to the ICAP port. 203 * hwicap_command_desync - Send a DESYNC command to the ICAP port.
203 * @parameter drvdata: a pointer to the drvdata. 204 * @drvdata: a pointer to the drvdata.
204 * 205 *
205 * This command desynchronizes the ICAP After this command, a 206 * This command desynchronizes the ICAP After this command, a
206 * bitstream containing a NULL packet, followed by a SYNCH packet is 207 * bitstream containing a NULL packet, followed by a SYNCH packet is
207 * required before the ICAP will recognize commands. 208 * required before the ICAP will recognize commands.
208 */ 209 */
209int hwicap_command_desync(struct hwicap_drvdata *drvdata) 210static int hwicap_command_desync(struct hwicap_drvdata *drvdata)
210{ 211{
211 u32 buffer[4]; 212 u32 buffer[4];
212 u32 index = 0; 213 u32 index = 0;
@@ -228,51 +229,18 @@ int hwicap_command_desync(struct hwicap_drvdata *drvdata)
228} 229}
229 230
230/** 231/**
231 * hwicap_command_capture: Send a CAPTURE command to the ICAP port. 232 * hwicap_get_configuration_register - Query a configuration register.
232 * @parameter drvdata: a pointer to the drvdata. 233 * @drvdata: a pointer to the drvdata.
233 * 234 * @reg: a constant which represents the configuration
234 * This command captures all of the flip flop states so they will be
235 * available during readback. One can use this command instead of
236 * enabling the CAPTURE block in the design.
237 */
238int hwicap_command_capture(struct hwicap_drvdata *drvdata)
239{
240 u32 buffer[7];
241 u32 index = 0;
242
243 /*
244 * Create the data to be written to the ICAP.
245 */
246 buffer[index++] = XHI_DUMMY_PACKET;
247 buffer[index++] = XHI_SYNC_PACKET;
248 buffer[index++] = XHI_NOOP_PACKET;
249 buffer[index++] = hwicap_type_1_write(drvdata->config_regs->CMD) | 1;
250 buffer[index++] = XHI_CMD_GCAPTURE;
251 buffer[index++] = XHI_DUMMY_PACKET;
252 buffer[index++] = XHI_DUMMY_PACKET;
253
254 /*
255 * Write the data to the FIFO and intiate the transfer of data
256 * present in the FIFO to the ICAP device.
257 */
258 return drvdata->config->set_configuration(drvdata,
259 &buffer[0], index);
260
261}
262
263/**
264 * hwicap_get_configuration_register: Query a configuration register.
265 * @parameter drvdata: a pointer to the drvdata.
266 * @parameter reg: a constant which represents the configuration
267 * register value to be returned. 235 * register value to be returned.
268 * Examples: XHI_IDCODE, XHI_FLR. 236 * Examples: XHI_IDCODE, XHI_FLR.
269 * @parameter RegData: returns the value of the register. 237 * @reg_data: returns the value of the register.
270 * 238 *
271 * Sends a query packet to the ICAP and then receives the response. 239 * Sends a query packet to the ICAP and then receives the response.
272 * The icap is left in Synched state. 240 * The icap is left in Synched state.
273 */ 241 */
274int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata, 242static int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata,
275 u32 reg, u32 *RegData) 243 u32 reg, u32 *reg_data)
276{ 244{
277 int status; 245 int status;
278 u32 buffer[6]; 246 u32 buffer[6];
@@ -300,14 +268,14 @@ int hwicap_get_configuration_register(struct hwicap_drvdata *drvdata,
300 /* 268 /*
301 * Read the configuration register 269 * Read the configuration register
302 */ 270 */
303 status = drvdata->config->get_configuration(drvdata, RegData, 1); 271 status = drvdata->config->get_configuration(drvdata, reg_data, 1);
304 if (status) 272 if (status)
305 return status; 273 return status;
306 274
307 return 0; 275 return 0;
308} 276}
309 277
310int hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata) 278static int hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata)
311{ 279{
312 int status; 280 int status;
313 u32 idcode; 281 u32 idcode;
@@ -344,7 +312,7 @@ int hwicap_initialize_hwicap(struct hwicap_drvdata *drvdata)
344} 312}
345 313
346static ssize_t 314static ssize_t
347hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos) 315hwicap_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
348{ 316{
349 struct hwicap_drvdata *drvdata = file->private_data; 317 struct hwicap_drvdata *drvdata = file->private_data;
350 ssize_t bytes_to_read = 0; 318 ssize_t bytes_to_read = 0;
@@ -353,8 +321,9 @@ hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos)
353 u32 bytes_remaining; 321 u32 bytes_remaining;
354 int status; 322 int status;
355 323
356 if (down_interruptible(&drvdata->sem)) 324 status = mutex_lock_interruptible(&drvdata->sem);
357 return -ERESTARTSYS; 325 if (status)
326 return status;
358 327
359 if (drvdata->read_buffer_in_use) { 328 if (drvdata->read_buffer_in_use) {
360 /* If there are leftover bytes in the buffer, just */ 329 /* If there are leftover bytes in the buffer, just */
@@ -370,8 +339,9 @@ hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos)
370 goto error; 339 goto error;
371 } 340 }
372 drvdata->read_buffer_in_use -= bytes_to_read; 341 drvdata->read_buffer_in_use -= bytes_to_read;
373 memcpy(drvdata->read_buffer + bytes_to_read, 342 memmove(drvdata->read_buffer,
374 drvdata->read_buffer, 4 - bytes_to_read); 343 drvdata->read_buffer + bytes_to_read,
344 4 - bytes_to_read);
375 } else { 345 } else {
376 /* Get new data from the ICAP, and return was was requested. */ 346 /* Get new data from the ICAP, and return was was requested. */
377 kbuf = (u32 *) get_zeroed_page(GFP_KERNEL); 347 kbuf = (u32 *) get_zeroed_page(GFP_KERNEL);
@@ -414,18 +384,20 @@ hwicap_read(struct file *file, char *buf, size_t count, loff_t *ppos)
414 status = -EFAULT; 384 status = -EFAULT;
415 goto error; 385 goto error;
416 } 386 }
417 memcpy(kbuf, drvdata->read_buffer, bytes_remaining); 387 memcpy(drvdata->read_buffer,
388 kbuf,
389 bytes_remaining);
418 drvdata->read_buffer_in_use = bytes_remaining; 390 drvdata->read_buffer_in_use = bytes_remaining;
419 free_page((unsigned long)kbuf); 391 free_page((unsigned long)kbuf);
420 } 392 }
421 status = bytes_to_read; 393 status = bytes_to_read;
422 error: 394 error:
423 up(&drvdata->sem); 395 mutex_unlock(&drvdata->sem);
424 return status; 396 return status;
425} 397}
426 398
427static ssize_t 399static ssize_t
428hwicap_write(struct file *file, const char *buf, 400hwicap_write(struct file *file, const char __user *buf,
429 size_t count, loff_t *ppos) 401 size_t count, loff_t *ppos)
430{ 402{
431 struct hwicap_drvdata *drvdata = file->private_data; 403 struct hwicap_drvdata *drvdata = file->private_data;
@@ -435,8 +407,9 @@ hwicap_write(struct file *file, const char *buf,
435 ssize_t len; 407 ssize_t len;
436 ssize_t status; 408 ssize_t status;
437 409
438 if (down_interruptible(&drvdata->sem)) 410 status = mutex_lock_interruptible(&drvdata->sem);
439 return -ERESTARTSYS; 411 if (status)
412 return status;
440 413
441 left += drvdata->write_buffer_in_use; 414 left += drvdata->write_buffer_in_use;
442 415
@@ -465,7 +438,7 @@ hwicap_write(struct file *file, const char *buf,
465 memcpy(kbuf, drvdata->write_buffer, 438 memcpy(kbuf, drvdata->write_buffer,
466 drvdata->write_buffer_in_use); 439 drvdata->write_buffer_in_use);
467 if (copy_from_user( 440 if (copy_from_user(
468 (((char *)kbuf) + (drvdata->write_buffer_in_use)), 441 (((char *)kbuf) + drvdata->write_buffer_in_use),
469 buf + written, 442 buf + written,
470 len - (drvdata->write_buffer_in_use))) { 443 len - (drvdata->write_buffer_in_use))) {
471 free_page((unsigned long)kbuf); 444 free_page((unsigned long)kbuf);
@@ -508,7 +481,7 @@ hwicap_write(struct file *file, const char *buf,
508 free_page((unsigned long)kbuf); 481 free_page((unsigned long)kbuf);
509 status = written; 482 status = written;
510 error: 483 error:
511 up(&drvdata->sem); 484 mutex_unlock(&drvdata->sem);
512 return status; 485 return status;
513} 486}
514 487
@@ -519,8 +492,9 @@ static int hwicap_open(struct inode *inode, struct file *file)
519 492
520 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); 493 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev);
521 494
522 if (down_interruptible(&drvdata->sem)) 495 status = mutex_lock_interruptible(&drvdata->sem);
523 return -ERESTARTSYS; 496 if (status)
497 return status;
524 498
525 if (drvdata->is_open) { 499 if (drvdata->is_open) {
526 status = -EBUSY; 500 status = -EBUSY;
@@ -539,7 +513,7 @@ static int hwicap_open(struct inode *inode, struct file *file)
539 drvdata->is_open = 1; 513 drvdata->is_open = 1;
540 514
541 error: 515 error:
542 up(&drvdata->sem); 516 mutex_unlock(&drvdata->sem);
543 return status; 517 return status;
544} 518}
545 519
@@ -549,8 +523,7 @@ static int hwicap_release(struct inode *inode, struct file *file)
549 int i; 523 int i;
550 int status = 0; 524 int status = 0;
551 525
552 if (down_interruptible(&drvdata->sem)) 526 mutex_lock(&drvdata->sem);
553 return -ERESTARTSYS;
554 527
555 if (drvdata->write_buffer_in_use) { 528 if (drvdata->write_buffer_in_use) {
556 /* Flush write buffer. */ 529 /* Flush write buffer. */
@@ -569,7 +542,7 @@ static int hwicap_release(struct inode *inode, struct file *file)
569 542
570 error: 543 error:
571 drvdata->is_open = 0; 544 drvdata->is_open = 0;
572 up(&drvdata->sem); 545 mutex_unlock(&drvdata->sem);
573 return status; 546 return status;
574} 547}
575 548
@@ -592,31 +565,36 @@ static int __devinit hwicap_setup(struct device *dev, int id,
592 565
593 dev_info(dev, "Xilinx icap port driver\n"); 566 dev_info(dev, "Xilinx icap port driver\n");
594 567
568 mutex_lock(&icap_sem);
569
595 if (id < 0) { 570 if (id < 0) {
596 for (id = 0; id < HWICAP_DEVICES; id++) 571 for (id = 0; id < HWICAP_DEVICES; id++)
597 if (!probed_devices[id]) 572 if (!probed_devices[id])
598 break; 573 break;
599 } 574 }
600 if (id < 0 || id >= HWICAP_DEVICES) { 575 if (id < 0 || id >= HWICAP_DEVICES) {
576 mutex_unlock(&icap_sem);
601 dev_err(dev, "%s%i too large\n", DRIVER_NAME, id); 577 dev_err(dev, "%s%i too large\n", DRIVER_NAME, id);
602 return -EINVAL; 578 return -EINVAL;
603 } 579 }
604 if (probed_devices[id]) { 580 if (probed_devices[id]) {
581 mutex_unlock(&icap_sem);
605 dev_err(dev, "cannot assign to %s%i; it is already in use\n", 582 dev_err(dev, "cannot assign to %s%i; it is already in use\n",
606 DRIVER_NAME, id); 583 DRIVER_NAME, id);
607 return -EBUSY; 584 return -EBUSY;
608 } 585 }
609 586
610 probed_devices[id] = 1; 587 probed_devices[id] = 1;
588 mutex_unlock(&icap_sem);
611 589
612 devt = MKDEV(xhwicap_major, xhwicap_minor + id); 590 devt = MKDEV(xhwicap_major, xhwicap_minor + id);
613 591
614 drvdata = kmalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL); 592 drvdata = kzalloc(sizeof(struct hwicap_drvdata), GFP_KERNEL);
615 if (!drvdata) { 593 if (!drvdata) {
616 dev_err(dev, "Couldn't allocate device private record\n"); 594 dev_err(dev, "Couldn't allocate device private record\n");
617 return -ENOMEM; 595 retval = -ENOMEM;
596 goto failed0;
618 } 597 }
619 memset((void *)drvdata, 0, sizeof(struct hwicap_drvdata));
620 dev_set_drvdata(dev, (void *)drvdata); 598 dev_set_drvdata(dev, (void *)drvdata);
621 599
622 if (!regs_res) { 600 if (!regs_res) {
@@ -648,7 +626,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
648 drvdata->config = config; 626 drvdata->config = config;
649 drvdata->config_regs = config_regs; 627 drvdata->config_regs = config_regs;
650 628
651 init_MUTEX(&drvdata->sem); 629 mutex_init(&drvdata->sem);
652 drvdata->is_open = 0; 630 drvdata->is_open = 0;
653 631
654 dev_info(dev, "ioremap %lx to %p with size %x\n", 632 dev_info(dev, "ioremap %lx to %p with size %x\n",
@@ -663,7 +641,7 @@ static int __devinit hwicap_setup(struct device *dev, int id,
663 goto failed3; 641 goto failed3;
664 } 642 }
665 /* devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */ 643 /* devfs_mk_cdev(devt, S_IFCHR|S_IRUGO|S_IWUGO, DRIVER_NAME); */
666 class_device_create(icap_class, NULL, devt, NULL, DRIVER_NAME); 644 device_create(icap_class, dev, devt, "%s%d", DRIVER_NAME, id);
667 return 0; /* success */ 645 return 0; /* success */
668 646
669 failed3: 647 failed3:
@@ -675,6 +653,11 @@ static int __devinit hwicap_setup(struct device *dev, int id,
675 failed1: 653 failed1:
676 kfree(drvdata); 654 kfree(drvdata);
677 655
656 failed0:
657 mutex_lock(&icap_sem);
658 probed_devices[id] = 0;
659 mutex_unlock(&icap_sem);
660
678 return retval; 661 return retval;
679} 662}
680 663
@@ -699,14 +682,16 @@ static int __devexit hwicap_remove(struct device *dev)
699 if (!drvdata) 682 if (!drvdata)
700 return 0; 683 return 0;
701 684
702 class_device_destroy(icap_class, drvdata->devt); 685 device_destroy(icap_class, drvdata->devt);
703 cdev_del(&drvdata->cdev); 686 cdev_del(&drvdata->cdev);
704 iounmap(drvdata->base_address); 687 iounmap(drvdata->base_address);
705 release_mem_region(drvdata->mem_start, drvdata->mem_size); 688 release_mem_region(drvdata->mem_start, drvdata->mem_size);
706 kfree(drvdata); 689 kfree(drvdata);
707 dev_set_drvdata(dev, NULL); 690 dev_set_drvdata(dev, NULL);
708 probed_devices[MINOR(dev->devt)-xhwicap_minor] = 0;
709 691
692 mutex_lock(&icap_sem);
693 probed_devices[MINOR(dev->devt)-xhwicap_minor] = 0;
694 mutex_unlock(&icap_sem);
710 return 0; /* success */ 695 return 0; /* success */
711} 696}
712 697
@@ -821,28 +806,29 @@ static struct of_platform_driver hwicap_of_driver = {
821}; 806};
822 807
823/* Registration helpers to keep the number of #ifdefs to a minimum */ 808/* Registration helpers to keep the number of #ifdefs to a minimum */
824static inline int __devinit hwicap_of_register(void) 809static inline int __init hwicap_of_register(void)
825{ 810{
826 pr_debug("hwicap: calling of_register_platform_driver()\n"); 811 pr_debug("hwicap: calling of_register_platform_driver()\n");
827 return of_register_platform_driver(&hwicap_of_driver); 812 return of_register_platform_driver(&hwicap_of_driver);
828} 813}
829 814
830static inline void __devexit hwicap_of_unregister(void) 815static inline void __exit hwicap_of_unregister(void)
831{ 816{
832 of_unregister_platform_driver(&hwicap_of_driver); 817 of_unregister_platform_driver(&hwicap_of_driver);
833} 818}
834#else /* CONFIG_OF */ 819#else /* CONFIG_OF */
835/* CONFIG_OF not enabled; do nothing helpers */ 820/* CONFIG_OF not enabled; do nothing helpers */
836static inline int __devinit hwicap_of_register(void) { return 0; } 821static inline int __init hwicap_of_register(void) { return 0; }
837static inline void __devexit hwicap_of_unregister(void) { } 822static inline void __exit hwicap_of_unregister(void) { }
838#endif /* CONFIG_OF */ 823#endif /* CONFIG_OF */
839 824
840static int __devinit hwicap_module_init(void) 825static int __init hwicap_module_init(void)
841{ 826{
842 dev_t devt; 827 dev_t devt;
843 int retval; 828 int retval;
844 829
845 icap_class = class_create(THIS_MODULE, "xilinx_config"); 830 icap_class = class_create(THIS_MODULE, "xilinx_config");
831 mutex_init(&icap_sem);
846 832
847 if (xhwicap_major) { 833 if (xhwicap_major) {
848 devt = MKDEV(xhwicap_major, xhwicap_minor); 834 devt = MKDEV(xhwicap_major, xhwicap_minor);
@@ -883,7 +869,7 @@ static int __devinit hwicap_module_init(void)
883 return retval; 869 return retval;
884} 870}
885 871
886static void __devexit hwicap_module_cleanup(void) 872static void __exit hwicap_module_cleanup(void)
887{ 873{
888 dev_t devt = MKDEV(xhwicap_major, xhwicap_minor); 874 dev_t devt = MKDEV(xhwicap_major, xhwicap_minor);
889 875
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.h b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
index ae771cac1629..405fee7e189b 100644
--- a/drivers/char/xilinx_hwicap/xilinx_hwicap.h
+++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.h
@@ -48,9 +48,9 @@ struct hwicap_drvdata {
48 u8 write_buffer[4]; 48 u8 write_buffer[4];
49 u32 read_buffer_in_use; /* Always in [0,3] */ 49 u32 read_buffer_in_use; /* Always in [0,3] */
50 u8 read_buffer[4]; 50 u8 read_buffer[4];
51 u32 mem_start; /* phys. address of the control registers */ 51 resource_size_t mem_start;/* phys. address of the control registers */
52 u32 mem_end; /* phys. address of the control registers */ 52 resource_size_t mem_end; /* phys. address of the control registers */
53 u32 mem_size; 53 resource_size_t mem_size;
54 void __iomem *base_address;/* virt. address of the control registers */ 54 void __iomem *base_address;/* virt. address of the control registers */
55 55
56 struct device *dev; 56 struct device *dev;
@@ -61,7 +61,7 @@ struct hwicap_drvdata {
61 const struct config_registers *config_regs; 61 const struct config_registers *config_regs;
62 void *private_data; 62 void *private_data;
63 bool is_open; 63 bool is_open;
64 struct semaphore sem; 64 struct mutex sem;
65}; 65};
66 66
67struct hwicap_driver_config { 67struct hwicap_driver_config {
@@ -164,29 +164,29 @@ struct config_registers {
164#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL 164#define XHI_DISABLED_AUTO_CRC 0x0000DEFCUL
165 165
166/** 166/**
167 * hwicap_type_1_read: Generates a Type 1 read packet header. 167 * hwicap_type_1_read - Generates a Type 1 read packet header.
168 * @parameter: Register is the address of the register to be read back. 168 * @reg: is the address of the register to be read back.
169 * 169 *
170 * Generates a Type 1 read packet header, which is used to indirectly 170 * Generates a Type 1 read packet header, which is used to indirectly
171 * read registers in the configuration logic. This packet must then 171 * read registers in the configuration logic. This packet must then
172 * be sent through the icap device, and a return packet received with 172 * be sent through the icap device, and a return packet received with
173 * the information. 173 * the information.
174 **/ 174 **/
175static inline u32 hwicap_type_1_read(u32 Register) 175static inline u32 hwicap_type_1_read(u32 reg)
176{ 176{
177 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) | 177 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) |
178 (Register << XHI_REGISTER_SHIFT) | 178 (reg << XHI_REGISTER_SHIFT) |
179 (XHI_OP_READ << XHI_OP_SHIFT); 179 (XHI_OP_READ << XHI_OP_SHIFT);
180} 180}
181 181
182/** 182/**
183 * hwicap_type_1_write: Generates a Type 1 write packet header 183 * hwicap_type_1_write - Generates a Type 1 write packet header
184 * @parameter: Register is the address of the register to be read back. 184 * @reg: is the address of the register to be read back.
185 **/ 185 **/
186static inline u32 hwicap_type_1_write(u32 Register) 186static inline u32 hwicap_type_1_write(u32 reg)
187{ 187{
188 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) | 188 return (XHI_TYPE_1 << XHI_TYPE_SHIFT) |
189 (Register << XHI_REGISTER_SHIFT) | 189 (reg << XHI_REGISTER_SHIFT) |
190 (XHI_OP_WRITE << XHI_OP_SHIFT); 190 (XHI_OP_WRITE << XHI_OP_SHIFT);
191} 191}
192 192
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 0c303c84b37b..6b6df8679585 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -632,8 +632,7 @@ mpt_deregister(u8 cb_idx)
632 632
633/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 633/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
634/** 634/**
635 * mpt_event_register - Register protocol-specific event callback 635 * mpt_event_register - Register protocol-specific event callback handler.
636 * handler.
637 * @cb_idx: previously registered (via mpt_register) callback handle 636 * @cb_idx: previously registered (via mpt_register) callback handle
638 * @ev_cbfunc: callback function 637 * @ev_cbfunc: callback function
639 * 638 *
@@ -654,8 +653,7 @@ mpt_event_register(u8 cb_idx, MPT_EVHANDLER ev_cbfunc)
654 653
655/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 654/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
656/** 655/**
657 * mpt_event_deregister - Deregister protocol-specific event callback 656 * mpt_event_deregister - Deregister protocol-specific event callback handler
658 * handler.
659 * @cb_idx: previously registered callback handle 657 * @cb_idx: previously registered callback handle
660 * 658 *
661 * Each protocol-specific driver should call this routine 659 * Each protocol-specific driver should call this routine
@@ -765,11 +763,13 @@ mpt_device_driver_deregister(u8 cb_idx)
765 763
766/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 764/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
767/** 765/**
768 * mpt_get_msg_frame - Obtain a MPT request frame from the pool (of 1024) 766 * mpt_get_msg_frame - Obtain an MPT request frame from the pool
769 * allocated per MPT adapter.
770 * @cb_idx: Handle of registered MPT protocol driver 767 * @cb_idx: Handle of registered MPT protocol driver
771 * @ioc: Pointer to MPT adapter structure 768 * @ioc: Pointer to MPT adapter structure
772 * 769 *
770 * Obtain an MPT request frame from the pool (of 1024) that are
771 * allocated per MPT adapter.
772 *
773 * Returns pointer to a MPT request frame or %NULL if none are available 773 * Returns pointer to a MPT request frame or %NULL if none are available
774 * or IOC is not active. 774 * or IOC is not active.
775 */ 775 */
@@ -834,13 +834,12 @@ mpt_get_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc)
834 834
835/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 835/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
836/** 836/**
837 * mpt_put_msg_frame - Send a protocol specific MPT request frame 837 * mpt_put_msg_frame - Send a protocol-specific MPT request frame to an IOC
838 * to a IOC.
839 * @cb_idx: Handle of registered MPT protocol driver 838 * @cb_idx: Handle of registered MPT protocol driver
840 * @ioc: Pointer to MPT adapter structure 839 * @ioc: Pointer to MPT adapter structure
841 * @mf: Pointer to MPT request frame 840 * @mf: Pointer to MPT request frame
842 * 841 *
843 * This routine posts a MPT request frame to the request post FIFO of a 842 * This routine posts an MPT request frame to the request post FIFO of a
844 * specific MPT adapter. 843 * specific MPT adapter.
845 */ 844 */
846void 845void
@@ -868,13 +867,15 @@ mpt_put_msg_frame(u8 cb_idx, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
868} 867}
869 868
870/** 869/**
871 * mpt_put_msg_frame_hi_pri - Send a protocol specific MPT request frame 870 * mpt_put_msg_frame_hi_pri - Send a hi-pri protocol-specific MPT request frame
872 * to a IOC using hi priority request queue.
873 * @cb_idx: Handle of registered MPT protocol driver 871 * @cb_idx: Handle of registered MPT protocol driver
874 * @ioc: Pointer to MPT adapter structure 872 * @ioc: Pointer to MPT adapter structure
875 * @mf: Pointer to MPT request frame 873 * @mf: Pointer to MPT request frame
876 * 874 *
877 * This routine posts a MPT request frame to the request post FIFO of a 875 * Send a protocol-specific MPT request frame to an IOC using
876 * hi-priority request queue.
877 *
878 * This routine posts an MPT request frame to the request post FIFO of a
878 * specific MPT adapter. 879 * specific MPT adapter.
879 **/ 880 **/
880void 881void
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index af1de0ccee2f..0c252f60c4c1 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1533,7 +1533,7 @@ mptscsih_freeChainBuffers(MPT_ADAPTER *ioc, int req_idx)
1533 * 1533 *
1534 * Remark: Currently invoked from a non-interrupt thread (_bh). 1534 * Remark: Currently invoked from a non-interrupt thread (_bh).
1535 * 1535 *
1536 * Remark: With old EH code, at most 1 SCSI TaskMgmt function per IOC 1536 * Note: With old EH code, at most 1 SCSI TaskMgmt function per IOC
1537 * will be active. 1537 * will be active.
1538 * 1538 *
1539 * Returns 0 for SUCCESS, or %FAILED. 1539 * Returns 0 for SUCCESS, or %FAILED.
@@ -2537,14 +2537,12 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2537 2537
2538/** 2538/**
2539 * mptscsih_get_scsi_lookup 2539 * mptscsih_get_scsi_lookup
2540 *
2541 * retrieves scmd entry from ScsiLookup[] array list
2542 *
2543 * @ioc: Pointer to MPT_ADAPTER structure 2540 * @ioc: Pointer to MPT_ADAPTER structure
2544 * @i: index into the array 2541 * @i: index into the array
2545 * 2542 *
2546 * Returns the scsi_cmd pointer 2543 * retrieves scmd entry from ScsiLookup[] array list
2547 * 2544 *
2545 * Returns the scsi_cmd pointer
2548 **/ 2546 **/
2549static struct scsi_cmnd * 2547static struct scsi_cmnd *
2550mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i) 2548mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i)
@@ -2561,14 +2559,12 @@ mptscsih_get_scsi_lookup(MPT_ADAPTER *ioc, int i)
2561 2559
2562/** 2560/**
2563 * mptscsih_getclear_scsi_lookup 2561 * mptscsih_getclear_scsi_lookup
2564 *
2565 * retrieves and clears scmd entry from ScsiLookup[] array list
2566 *
2567 * @ioc: Pointer to MPT_ADAPTER structure 2562 * @ioc: Pointer to MPT_ADAPTER structure
2568 * @i: index into the array 2563 * @i: index into the array
2569 * 2564 *
2570 * Returns the scsi_cmd pointer 2565 * retrieves and clears scmd entry from ScsiLookup[] array list
2571 * 2566 *
2567 * Returns the scsi_cmd pointer
2572 **/ 2568 **/
2573static struct scsi_cmnd * 2569static struct scsi_cmnd *
2574mptscsih_getclear_scsi_lookup(MPT_ADAPTER *ioc, int i) 2570mptscsih_getclear_scsi_lookup(MPT_ADAPTER *ioc, int i)
diff --git a/drivers/pci/rom.c b/drivers/pci/rom.c
index a98b2470b9ea..bd5c0e031398 100644
--- a/drivers/pci/rom.c
+++ b/drivers/pci/rom.c
@@ -242,8 +242,7 @@ void pci_remove_rom(struct pci_dev *pdev)
242#endif /* 0 */ 242#endif /* 0 */
243 243
244/** 244/**
245 * pci_cleanup_rom - internal routine for freeing the ROM copy created 245 * pci_cleanup_rom - free the ROM copy created by pci_map_rom_copy
246 * by pci_map_rom_copy called from remove.c
247 * @pdev: pointer to pci device struct 246 * @pdev: pointer to pci device struct
248 * 247 *
249 * Free the copied ROM if we allocated one. 248 * Free the copied ROM if we allocated one.
diff --git a/drivers/rapidio/rio-driver.c b/drivers/rapidio/rio-driver.c
index 5480119ff9d3..3ce9f3defc12 100644
--- a/drivers/rapidio/rio-driver.c
+++ b/drivers/rapidio/rio-driver.c
@@ -78,8 +78,7 @@ void rio_dev_put(struct rio_dev *rdev)
78} 78}
79 79
80/** 80/**
81 * rio_device_probe - Tell if a RIO device structure has a matching RIO 81 * rio_device_probe - Tell if a RIO device structure has a matching RIO device id structure
82 * device id structure
83 * @id: the RIO device id structure to match against 82 * @id: the RIO device id structure to match against
84 * @dev: the RIO device structure to match against 83 * @dev: the RIO device structure to match against
85 * 84 *
@@ -137,7 +136,7 @@ static int rio_device_remove(struct device *dev)
137 * rio_register_driver - register a new RIO driver 136 * rio_register_driver - register a new RIO driver
138 * @rdrv: the RIO driver structure to register 137 * @rdrv: the RIO driver structure to register
139 * 138 *
140 * Adds a &struct rio_driver to the list of registered drivers 139 * Adds a &struct rio_driver to the list of registered drivers.
141 * Returns a negative value on error, otherwise 0. If no error 140 * Returns a negative value on error, otherwise 0. If no error
142 * occurred, the driver remains registered even if no device 141 * occurred, the driver remains registered even if no device
143 * was claimed during registration. 142 * was claimed during registration.
@@ -167,8 +166,7 @@ void rio_unregister_driver(struct rio_driver *rdrv)
167} 166}
168 167
169/** 168/**
170 * rio_match_bus - Tell if a RIO device structure has a matching RIO 169 * rio_match_bus - Tell if a RIO device structure has a matching RIO driver device id structure
171 * driver device id structure
172 * @dev: the standard device structure to match against 170 * @dev: the standard device structure to match against
173 * @drv: the standard driver structure containing the ids to match against 171 * @drv: the standard driver structure containing the ids to match against
174 * 172 *
diff --git a/drivers/s390/char/defkeymap.c b/drivers/s390/char/defkeymap.c
index 389346cda6c8..9692d6a205ef 100644
--- a/drivers/s390/char/defkeymap.c
+++ b/drivers/s390/char/defkeymap.c
@@ -151,8 +151,8 @@ char *func_table[MAX_NR_FUNC] = {
151}; 151};
152 152
153struct kbdiacruc accent_table[MAX_DIACR] = { 153struct kbdiacruc accent_table[MAX_DIACR] = {
154 {'^', 'c', '\003'}, {'^', 'd', '\004'}, 154 {'^', 'c', 0003}, {'^', 'd', 0004},
155 {'^', 'z', '\032'}, {'^', '\012', '\000'}, 155 {'^', 'z', 0032}, {'^', 0012', 0000},
156}; 156};
157 157
158unsigned int accent_table_size = 4; 158unsigned int accent_table_size = 4;
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 1dc165ad17fb..e67c14e31bab 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1577,8 +1577,7 @@ static void __scsi_scan_target(struct device *parent, unsigned int channel,
1577} 1577}
1578 1578
1579/** 1579/**
1580 * scsi_scan_target - scan a target id, possibly including all LUNs on the 1580 * scsi_scan_target - scan a target id, possibly including all LUNs on the target.
1581 * target.
1582 * @parent: host to scan 1581 * @parent: host to scan
1583 * @channel: channel to scan 1582 * @channel: channel to scan
1584 * @id: target id to scan 1583 * @id: target id to scan
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 4e984060c984..f6f19908f5f0 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -99,8 +99,7 @@ struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev,
99EXPORT_SYMBOL_GPL(usb_ifnum_to_if); 99EXPORT_SYMBOL_GPL(usb_ifnum_to_if);
100 100
101/** 101/**
102 * usb_altnum_to_altsetting - get the altsetting structure with a given 102 * usb_altnum_to_altsetting - get the altsetting structure with a given alternate setting number.
103 * alternate setting number.
104 * @intf: the interface containing the altsetting in question 103 * @intf: the interface containing the altsetting in question
105 * @altnum: the desired alternate setting number 104 * @altnum: the desired alternate setting number
106 * 105 *
@@ -442,8 +441,7 @@ EXPORT_SYMBOL_GPL(usb_put_intf);
442 */ 441 */
443 442
444/** 443/**
445 * usb_lock_device_for_reset - cautiously acquire the lock for a 444 * usb_lock_device_for_reset - cautiously acquire the lock for a usb device structure
446 * usb device structure
447 * @udev: device that's being locked 445 * @udev: device that's being locked
448 * @iface: interface bound to the driver making the request (optional) 446 * @iface: interface bound to the driver making the request (optional)
449 * 447 *
diff --git a/fs/buffer.c b/fs/buffer.c
index 3ebccf4aa7e3..897cd7477b34 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -627,8 +627,7 @@ repeat:
627} 627}
628 628
629/** 629/**
630 * sync_mapping_buffers - write out and wait upon a mapping's "associated" 630 * sync_mapping_buffers - write out & wait upon a mapping's "associated" buffers
631 * buffers
632 * @mapping: the mapping which wants those buffers written 631 * @mapping: the mapping which wants those buffers written
633 * 632 *
634 * Starts I/O against the buffers at mapping->private_list, and waits upon 633 * Starts I/O against the buffers at mapping->private_list, and waits upon
diff --git a/fs/exec.c b/fs/exec.c
index a44b142fb460..54a0a557b678 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -173,8 +173,15 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
173 return NULL; 173 return NULL;
174 174
175 if (write) { 175 if (write) {
176 struct rlimit *rlim = current->signal->rlim;
177 unsigned long size = bprm->vma->vm_end - bprm->vma->vm_start; 176 unsigned long size = bprm->vma->vm_end - bprm->vma->vm_start;
177 struct rlimit *rlim;
178
179 /*
180 * We've historically supported up to 32 pages (ARG_MAX)
181 * of argument strings even with small stacks
182 */
183 if (size <= ARG_MAX)
184 return page;
178 185
179 /* 186 /*
180 * Limit to 1/4-th the stack size for the argv+env strings. 187 * Limit to 1/4-th the stack size for the argv+env strings.
@@ -183,6 +190,7 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
183 * - the program will have a reasonable amount of stack left 190 * - the program will have a reasonable amount of stack left
184 * to work from. 191 * to work from.
185 */ 192 */
193 rlim = current->signal->rlim;
186 if (size > rlim[RLIMIT_STACK].rlim_cur / 4) { 194 if (size > rlim[RLIMIT_STACK].rlim_cur / 4) {
187 put_page(page); 195 put_page(page);
188 return NULL; 196 return NULL;
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 038ed7436199..c6cbb6cd59b2 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -369,7 +369,7 @@ out:
369 369
370 370
371/** 371/**
372 * int journal_restart() - restart a handle . 372 * int journal_restart() - restart a handle.
373 * @handle: handle to restart 373 * @handle: handle to restart
374 * @nblocks: nr credits requested 374 * @nblocks: nr credits requested
375 * 375 *
@@ -844,8 +844,7 @@ out:
844} 844}
845 845
846/** 846/**
847 * int journal_get_undo_access() - Notify intent to modify metadata with 847 * int journal_get_undo_access() - Notify intent to modify metadata with non-rewindable consequences
848 * non-rewindable consequences
849 * @handle: transaction 848 * @handle: transaction
850 * @bh: buffer to undo 849 * @bh: buffer to undo
851 * @credits: store the number of taken credits here (if not NULL) 850 * @credits: store the number of taken credits here (if not NULL)
@@ -921,12 +920,14 @@ out:
921} 920}
922 921
923/** 922/**
924 * int journal_dirty_data() - mark a buffer as containing dirty data which 923 * int journal_dirty_data() - mark a buffer as containing dirty data to be flushed
925 * needs to be flushed before we can commit the
926 * current transaction.
927 * @handle: transaction 924 * @handle: transaction
928 * @bh: bufferhead to mark 925 * @bh: bufferhead to mark
929 * 926 *
927 * Description:
928 * Mark a buffer as containing dirty data which needs to be flushed before
929 * we can commit the current transaction.
930 *
930 * The buffer is placed on the transaction's data list and is marked as 931 * The buffer is placed on the transaction's data list and is marked as
931 * belonging to the transaction. 932 * belonging to the transaction.
932 * 933 *
@@ -1098,11 +1099,11 @@ no_journal:
1098} 1099}
1099 1100
1100/** 1101/**
1101 * int journal_dirty_metadata() - mark a buffer as containing dirty metadata 1102 * int journal_dirty_metadata() - mark a buffer as containing dirty metadata
1102 * @handle: transaction to add buffer to. 1103 * @handle: transaction to add buffer to.
1103 * @bh: buffer to mark 1104 * @bh: buffer to mark
1104 * 1105 *
1105 * mark dirty metadata which needs to be journaled as part of the current 1106 * Mark dirty metadata which needs to be journaled as part of the current
1106 * transaction. 1107 * transaction.
1107 * 1108 *
1108 * The buffer is placed on the transaction's metadata list and is marked 1109 * The buffer is placed on the transaction's metadata list and is marked
diff --git a/fs/mpage.c b/fs/mpage.c
index 5df564366f36..235e4d3873a8 100644
--- a/fs/mpage.c
+++ b/fs/mpage.c
@@ -325,16 +325,12 @@ confused:
325} 325}
326 326
327/** 327/**
328 * mpage_readpages - populate an address space with some pages, and 328 * mpage_readpages - populate an address space with some pages & start reads against them
329 * start reads against them.
330 *
331 * @mapping: the address_space 329 * @mapping: the address_space
332 * @pages: The address of a list_head which contains the target pages. These 330 * @pages: The address of a list_head which contains the target pages. These
333 * pages have their ->index populated and are otherwise uninitialised. 331 * pages have their ->index populated and are otherwise uninitialised.
334 *
335 * The page at @pages->prev has the lowest file offset, and reads should be 332 * The page at @pages->prev has the lowest file offset, and reads should be
336 * issued in @pages->prev to @pages->next order. 333 * issued in @pages->prev to @pages->next order.
337 *
338 * @nr_pages: The number of pages at *@pages 334 * @nr_pages: The number of pages at *@pages
339 * @get_block: The filesystem's block mapper function. 335 * @get_block: The filesystem's block mapper function.
340 * 336 *
@@ -360,6 +356,7 @@ confused:
360 * So an mpage read of the first 16 blocks of an ext2 file will cause I/O to be 356 * So an mpage read of the first 16 blocks of an ext2 file will cause I/O to be
361 * submitted in the following order: 357 * submitted in the following order:
362 * 12 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16 358 * 12 0 1 2 3 4 5 6 7 8 9 10 11 13 14 15 16
359 *
363 * because the indirect block has to be read to get the mappings of blocks 360 * because the indirect block has to be read to get the mappings of blocks
364 * 13,14,15,16. Obviously, this impacts performance. 361 * 13,14,15,16. Obviously, this impacts performance.
365 * 362 *
@@ -656,9 +653,7 @@ out:
656} 653}
657 654
658/** 655/**
659 * mpage_writepages - walk the list of dirty pages of the given 656 * mpage_writepages - walk the list of dirty pages of the given address space & writepage() all of them
660 * address space and writepage() all of them.
661 *
662 * @mapping: address space structure to write 657 * @mapping: address space structure to write
663 * @wbc: subtract the number of written pages from *@wbc->nr_to_write 658 * @wbc: subtract the number of written pages from *@wbc->nr_to_write
664 * @get_block: the filesystem's block mapper function. 659 * @get_block: the filesystem's block mapper function.
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h
index 0d6238987df8..edc0cfd7f6e2 100644
--- a/include/asm-powerpc/reg.h
+++ b/include/asm-powerpc/reg.h
@@ -153,6 +153,9 @@
153#define CTRL_RUNLATCH 0x1 153#define CTRL_RUNLATCH 0x1
154#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ 154#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */
155#define DABR_TRANSLATION (1UL << 2) 155#define DABR_TRANSLATION (1UL << 2)
156#define SPRN_DABRX 0x3F7 /* Data Address Breakpoint Register Extension */
157#define DABRX_USER (1UL << 0)
158#define DABRX_KERNEL (1UL << 1)
156#define SPRN_DAR 0x013 /* Data Address Register */ 159#define SPRN_DAR 0x013 /* Data Address Register */
157#define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ 160#define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
158#define DSISR_NOHPTE 0x40000000 /* no translation found */ 161#define DSISR_NOHPTE 0x40000000 /* no translation found */
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
index b478efa971e0..a842c7222b1e 100644
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -91,9 +91,7 @@ extern unsigned long pg0[];
91/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */ 91/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */
92#define pmd_none(x) (!(unsigned long)pmd_val(x)) 92#define pmd_none(x) (!(unsigned long)pmd_val(x))
93#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 93#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
94#define pmd_bad(x) ((pmd_val(x) \ 94#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
95 & ~(PAGE_MASK | _PAGE_USER | _PAGE_PSE | _PAGE_NX)) \
96 != _KERNPG_TABLE)
97 95
98 96
99#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 97#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index 0a9258333cbd..0a0b77bc736a 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -153,14 +153,12 @@ static inline unsigned long pgd_bad(pgd_t pgd)
153 153
154static inline unsigned long pud_bad(pud_t pud) 154static inline unsigned long pud_bad(pud_t pud)
155{ 155{
156 return pud_val(pud) & 156 return pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
157 ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER | _PAGE_PSE | _PAGE_NX);
158} 157}
159 158
160static inline unsigned long pmd_bad(pmd_t pmd) 159static inline unsigned long pmd_bad(pmd_t pmd)
161{ 160{
162 return pmd_val(pmd) & 161 return pmd_val(pmd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
163 ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER | _PAGE_PSE | _PAGE_NX);
164} 162}
165 163
166#define pte_none(x) (!pte_val(x)) 164#define pte_none(x) (!pte_val(x))
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index bfee0bd1d435..34023c65d466 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -64,10 +64,7 @@ struct page {
64#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS 64#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
65 spinlock_t ptl; 65 spinlock_t ptl;
66#endif 66#endif
67 struct { 67 struct kmem_cache *slab; /* SLUB: Pointer to slab */
68 struct kmem_cache *slab; /* SLUB: Pointer to slab */
69 void *end; /* SLUB: end marker */
70 };
71 struct page *first_page; /* Compound tail pages */ 68 struct page *first_page; /* Compound tail pages */
72 }; 69 };
73 union { 70 union {
diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
index 57deecc79d52..b00c1c73eb0a 100644
--- a/include/linux/slub_def.h
+++ b/include/linux/slub_def.h
@@ -61,7 +61,7 @@ struct kmem_cache {
61 int size; /* The size of an object including meta data */ 61 int size; /* The size of an object including meta data */
62 int objsize; /* The size of an object without meta data */ 62 int objsize; /* The size of an object without meta data */
63 int offset; /* Free pointer offset. */ 63 int offset; /* Free pointer offset. */
64 int order; 64 int order; /* Current preferred allocation order */
65 65
66 /* 66 /*
67 * Avoid an extra cache line for UP, SMP and for the node local to 67 * Avoid an extra cache line for UP, SMP and for the node local to
@@ -138,11 +138,11 @@ static __always_inline int kmalloc_index(size_t size)
138 if (size <= 512) return 9; 138 if (size <= 512) return 9;
139 if (size <= 1024) return 10; 139 if (size <= 1024) return 10;
140 if (size <= 2 * 1024) return 11; 140 if (size <= 2 * 1024) return 11;
141 if (size <= 4 * 1024) return 12;
141/* 142/*
142 * The following is only needed to support architectures with a larger page 143 * The following is only needed to support architectures with a larger page
143 * size than 4k. 144 * size than 4k.
144 */ 145 */
145 if (size <= 4 * 1024) return 12;
146 if (size <= 8 * 1024) return 13; 146 if (size <= 8 * 1024) return 13;
147 if (size <= 16 * 1024) return 14; 147 if (size <= 16 * 1024) return 14;
148 if (size <= 32 * 1024) return 15; 148 if (size <= 32 * 1024) return 15;
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 2372e2e6b527..5bd3ae8aaaf4 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -781,8 +781,7 @@ static inline int usb_endpoint_is_isoc_out(
781 .idVendor = (vend), \ 781 .idVendor = (vend), \
782 .idProduct = (prod) 782 .idProduct = (prod)
783/** 783/**
784 * USB_DEVICE_VER - macro used to describe a specific usb device with a 784 * USB_DEVICE_VER - describe a specific usb device with a version range
785 * version range
786 * @vend: the 16 bit USB Vendor ID 785 * @vend: the 16 bit USB Vendor ID
787 * @prod: the 16 bit USB Product ID 786 * @prod: the 16 bit USB Product ID
788 * @lo: the bcdDevice_lo value 787 * @lo: the bcdDevice_lo value
@@ -799,8 +798,7 @@ static inline int usb_endpoint_is_isoc_out(
799 .bcdDevice_hi = (hi) 798 .bcdDevice_hi = (hi)
800 799
801/** 800/**
802 * USB_DEVICE_INTERFACE_PROTOCOL - macro used to describe a usb 801 * USB_DEVICE_INTERFACE_PROTOCOL - describe a usb device with a specific interface protocol
803 * device with a specific interface protocol
804 * @vend: the 16 bit USB Vendor ID 802 * @vend: the 16 bit USB Vendor ID
805 * @prod: the 16 bit USB Product ID 803 * @prod: the 16 bit USB Product ID
806 * @pr: bInterfaceProtocol value 804 * @pr: bInterfaceProtocol value
@@ -846,8 +844,7 @@ static inline int usb_endpoint_is_isoc_out(
846 .bInterfaceProtocol = (pr) 844 .bInterfaceProtocol = (pr)
847 845
848/** 846/**
849 * USB_DEVICE_AND_INTERFACE_INFO - macro used to describe a specific usb device 847 * USB_DEVICE_AND_INTERFACE_INFO - describe a specific usb device with a class of usb interfaces
850 * with a class of usb interfaces
851 * @vend: the 16 bit USB Vendor ID 848 * @vend: the 16 bit USB Vendor ID
852 * @prod: the 16 bit USB Product ID 849 * @prod: the 16 bit USB Product ID
853 * @cl: bInterfaceClass value 850 * @cl: bInterfaceClass value
diff --git a/kernel/exit.c b/kernel/exit.c
index 506a957b665a..cd20bf07e9e3 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -214,20 +214,19 @@ struct pid *session_of_pgrp(struct pid *pgrp)
214static int will_become_orphaned_pgrp(struct pid *pgrp, struct task_struct *ignored_task) 214static int will_become_orphaned_pgrp(struct pid *pgrp, struct task_struct *ignored_task)
215{ 215{
216 struct task_struct *p; 216 struct task_struct *p;
217 int ret = 1;
218 217
219 do_each_pid_task(pgrp, PIDTYPE_PGID, p) { 218 do_each_pid_task(pgrp, PIDTYPE_PGID, p) {
220 if (p == ignored_task 219 if ((p == ignored_task) ||
221 || p->exit_state 220 (p->exit_state && thread_group_empty(p)) ||
222 || is_global_init(p->real_parent)) 221 is_global_init(p->real_parent))
223 continue; 222 continue;
223
224 if (task_pgrp(p->real_parent) != pgrp && 224 if (task_pgrp(p->real_parent) != pgrp &&
225 task_session(p->real_parent) == task_session(p)) { 225 task_session(p->real_parent) == task_session(p))
226 ret = 0; 226 return 0;
227 break;
228 }
229 } while_each_pid_task(pgrp, PIDTYPE_PGID, p); 227 } while_each_pid_task(pgrp, PIDTYPE_PGID, p);
230 return ret; /* (sighing) "Often!" */ 228
229 return 1;
231} 230}
232 231
233int is_current_pgrp_orphaned(void) 232int is_current_pgrp_orphaned(void)
@@ -255,6 +254,37 @@ static int has_stopped_jobs(struct pid *pgrp)
255 return retval; 254 return retval;
256} 255}
257 256
257/*
258 * Check to see if any process groups have become orphaned as
259 * a result of our exiting, and if they have any stopped jobs,
260 * send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2)
261 */
262static void
263kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent)
264{
265 struct pid *pgrp = task_pgrp(tsk);
266 struct task_struct *ignored_task = tsk;
267
268 if (!parent)
269 /* exit: our father is in a different pgrp than
270 * we are and we were the only connection outside.
271 */
272 parent = tsk->real_parent;
273 else
274 /* reparent: our child is in a different pgrp than
275 * we are, and it was the only connection outside.
276 */
277 ignored_task = NULL;
278
279 if (task_pgrp(parent) != pgrp &&
280 task_session(parent) == task_session(tsk) &&
281 will_become_orphaned_pgrp(pgrp, ignored_task) &&
282 has_stopped_jobs(pgrp)) {
283 __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp);
284 __kill_pgrp_info(SIGCONT, SEND_SIG_PRIV, pgrp);
285 }
286}
287
258/** 288/**
259 * reparent_to_kthreadd - Reparent the calling kernel thread to kthreadd 289 * reparent_to_kthreadd - Reparent the calling kernel thread to kthreadd
260 * 290 *
@@ -635,22 +665,7 @@ reparent_thread(struct task_struct *p, struct task_struct *father, int traced)
635 p->exit_signal != -1 && thread_group_empty(p)) 665 p->exit_signal != -1 && thread_group_empty(p))
636 do_notify_parent(p, p->exit_signal); 666 do_notify_parent(p, p->exit_signal);
637 667
638 /* 668 kill_orphaned_pgrp(p, father);
639 * process group orphan check
640 * Case ii: Our child is in a different pgrp
641 * than we are, and it was the only connection
642 * outside, so the child pgrp is now orphaned.
643 */
644 if ((task_pgrp(p) != task_pgrp(father)) &&
645 (task_session(p) == task_session(father))) {
646 struct pid *pgrp = task_pgrp(p);
647
648 if (will_become_orphaned_pgrp(pgrp, NULL) &&
649 has_stopped_jobs(pgrp)) {
650 __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp);
651 __kill_pgrp_info(SIGCONT, SEND_SIG_PRIV, pgrp);
652 }
653 }
654} 669}
655 670
656/* 671/*
@@ -735,11 +750,9 @@ static void forget_original_parent(struct task_struct *father)
735 * Send signals to all our closest relatives so that they know 750 * Send signals to all our closest relatives so that they know
736 * to properly mourn us.. 751 * to properly mourn us..
737 */ 752 */
738static void exit_notify(struct task_struct *tsk) 753static void exit_notify(struct task_struct *tsk, int group_dead)
739{ 754{
740 int state; 755 int state;
741 struct task_struct *t;
742 struct pid *pgrp;
743 756
744 /* 757 /*
745 * This does two things: 758 * This does two things:
@@ -753,25 +766,8 @@ static void exit_notify(struct task_struct *tsk)
753 exit_task_namespaces(tsk); 766 exit_task_namespaces(tsk);
754 767
755 write_lock_irq(&tasklist_lock); 768 write_lock_irq(&tasklist_lock);
756 /* 769 if (group_dead)
757 * Check to see if any process groups have become orphaned 770 kill_orphaned_pgrp(tsk->group_leader, NULL);
758 * as a result of our exiting, and if they have any stopped
759 * jobs, send them a SIGHUP and then a SIGCONT. (POSIX 3.2.2.2)
760 *
761 * Case i: Our father is in a different pgrp than we are
762 * and we were the only connection outside, so our pgrp
763 * is about to become orphaned.
764 */
765 t = tsk->real_parent;
766
767 pgrp = task_pgrp(tsk);
768 if ((task_pgrp(t) != pgrp) &&
769 (task_session(t) == task_session(tsk)) &&
770 will_become_orphaned_pgrp(pgrp, tsk) &&
771 has_stopped_jobs(pgrp)) {
772 __kill_pgrp_info(SIGHUP, SEND_SIG_PRIV, pgrp);
773 __kill_pgrp_info(SIGCONT, SEND_SIG_PRIV, pgrp);
774 }
775 771
776 /* Let father know we died 772 /* Let father know we died
777 * 773 *
@@ -788,8 +784,8 @@ static void exit_notify(struct task_struct *tsk)
788 * the same after a fork. 784 * the same after a fork.
789 */ 785 */
790 if (tsk->exit_signal != SIGCHLD && tsk->exit_signal != -1 && 786 if (tsk->exit_signal != SIGCHLD && tsk->exit_signal != -1 &&
791 ( tsk->parent_exec_id != t->self_exec_id || 787 (tsk->parent_exec_id != tsk->real_parent->self_exec_id ||
792 tsk->self_exec_id != tsk->parent_exec_id) 788 tsk->self_exec_id != tsk->parent_exec_id)
793 && !capable(CAP_KILL)) 789 && !capable(CAP_KILL))
794 tsk->exit_signal = SIGCHLD; 790 tsk->exit_signal = SIGCHLD;
795 791
@@ -986,7 +982,7 @@ NORET_TYPE void do_exit(long code)
986 module_put(tsk->binfmt->module); 982 module_put(tsk->binfmt->module);
987 983
988 proc_exit_connector(tsk); 984 proc_exit_connector(tsk);
989 exit_notify(tsk); 985 exit_notify(tsk, group_dead);
990#ifdef CONFIG_NUMA 986#ifdef CONFIG_NUMA
991 mpol_free(tsk->mempolicy); 987 mpol_free(tsk->mempolicy);
992 tsk->mempolicy = NULL; 988 tsk->mempolicy = NULL;
diff --git a/mm/slub.c b/mm/slub.c
index 74c65af0a54f..0863fd38a5ce 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -291,32 +291,16 @@ static inline struct kmem_cache_cpu *get_cpu_slab(struct kmem_cache *s, int cpu)
291#endif 291#endif
292} 292}
293 293
294/* 294/* Verify that a pointer has an address that is valid within a slab page */
295 * The end pointer in a slab is special. It points to the first object in the
296 * slab but has bit 0 set to mark it.
297 *
298 * Note that SLUB relies on page_mapping returning NULL for pages with bit 0
299 * in the mapping set.
300 */
301static inline int is_end(void *addr)
302{
303 return (unsigned long)addr & PAGE_MAPPING_ANON;
304}
305
306static void *slab_address(struct page *page)
307{
308 return page->end - PAGE_MAPPING_ANON;
309}
310
311static inline int check_valid_pointer(struct kmem_cache *s, 295static inline int check_valid_pointer(struct kmem_cache *s,
312 struct page *page, const void *object) 296 struct page *page, const void *object)
313{ 297{
314 void *base; 298 void *base;
315 299
316 if (object == page->end) 300 if (!object)
317 return 1; 301 return 1;
318 302
319 base = slab_address(page); 303 base = page_address(page);
320 if (object < base || object >= base + s->objects * s->size || 304 if (object < base || object >= base + s->objects * s->size ||
321 (object - base) % s->size) { 305 (object - base) % s->size) {
322 return 0; 306 return 0;
@@ -349,8 +333,7 @@ static inline void set_freepointer(struct kmem_cache *s, void *object, void *fp)
349 333
350/* Scan freelist */ 334/* Scan freelist */
351#define for_each_free_object(__p, __s, __free) \ 335#define for_each_free_object(__p, __s, __free) \
352 for (__p = (__free); (__p) != page->end; __p = get_freepointer((__s),\ 336 for (__p = (__free); __p; __p = get_freepointer((__s), __p))
353 __p))
354 337
355/* Determine object index from a given position */ 338/* Determine object index from a given position */
356static inline int slab_index(void *p, struct kmem_cache *s, void *addr) 339static inline int slab_index(void *p, struct kmem_cache *s, void *addr)
@@ -502,7 +485,7 @@ static void slab_fix(struct kmem_cache *s, char *fmt, ...)
502static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) 485static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p)
503{ 486{
504 unsigned int off; /* Offset of last byte */ 487 unsigned int off; /* Offset of last byte */
505 u8 *addr = slab_address(page); 488 u8 *addr = page_address(page);
506 489
507 print_tracking(s, p); 490 print_tracking(s, p);
508 491
@@ -637,7 +620,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct page *page,
637 * A. Free pointer (if we cannot overwrite object on free) 620 * A. Free pointer (if we cannot overwrite object on free)
638 * B. Tracking data for SLAB_STORE_USER 621 * B. Tracking data for SLAB_STORE_USER
639 * C. Padding to reach required alignment boundary or at mininum 622 * C. Padding to reach required alignment boundary or at mininum
640 * one word if debuggin is on to be able to detect writes 623 * one word if debugging is on to be able to detect writes
641 * before the word boundary. 624 * before the word boundary.
642 * 625 *
643 * Padding is done using 0x5a (POISON_INUSE) 626 * Padding is done using 0x5a (POISON_INUSE)
@@ -680,7 +663,7 @@ static int slab_pad_check(struct kmem_cache *s, struct page *page)
680 if (!(s->flags & SLAB_POISON)) 663 if (!(s->flags & SLAB_POISON))
681 return 1; 664 return 1;
682 665
683 start = slab_address(page); 666 start = page_address(page);
684 end = start + (PAGE_SIZE << s->order); 667 end = start + (PAGE_SIZE << s->order);
685 length = s->objects * s->size; 668 length = s->objects * s->size;
686 remainder = end - (start + length); 669 remainder = end - (start + length);
@@ -748,7 +731,7 @@ static int check_object(struct kmem_cache *s, struct page *page,
748 * of the free objects in this slab. May cause 731 * of the free objects in this slab. May cause
749 * another error because the object count is now wrong. 732 * another error because the object count is now wrong.
750 */ 733 */
751 set_freepointer(s, p, page->end); 734 set_freepointer(s, p, NULL);
752 return 0; 735 return 0;
753 } 736 }
754 return 1; 737 return 1;
@@ -782,18 +765,18 @@ static int on_freelist(struct kmem_cache *s, struct page *page, void *search)
782 void *fp = page->freelist; 765 void *fp = page->freelist;
783 void *object = NULL; 766 void *object = NULL;
784 767
785 while (fp != page->end && nr <= s->objects) { 768 while (fp && nr <= s->objects) {
786 if (fp == search) 769 if (fp == search)
787 return 1; 770 return 1;
788 if (!check_valid_pointer(s, page, fp)) { 771 if (!check_valid_pointer(s, page, fp)) {
789 if (object) { 772 if (object) {
790 object_err(s, page, object, 773 object_err(s, page, object,
791 "Freechain corrupt"); 774 "Freechain corrupt");
792 set_freepointer(s, object, page->end); 775 set_freepointer(s, object, NULL);
793 break; 776 break;
794 } else { 777 } else {
795 slab_err(s, page, "Freepointer corrupt"); 778 slab_err(s, page, "Freepointer corrupt");
796 page->freelist = page->end; 779 page->freelist = NULL;
797 page->inuse = s->objects; 780 page->inuse = s->objects;
798 slab_fix(s, "Freelist cleared"); 781 slab_fix(s, "Freelist cleared");
799 return 0; 782 return 0;
@@ -870,7 +853,7 @@ static int alloc_debug_processing(struct kmem_cache *s, struct page *page,
870 if (!check_slab(s, page)) 853 if (!check_slab(s, page))
871 goto bad; 854 goto bad;
872 855
873 if (object && !on_freelist(s, page, object)) { 856 if (!on_freelist(s, page, object)) {
874 object_err(s, page, object, "Object already allocated"); 857 object_err(s, page, object, "Object already allocated");
875 goto bad; 858 goto bad;
876 } 859 }
@@ -880,7 +863,7 @@ static int alloc_debug_processing(struct kmem_cache *s, struct page *page,
880 goto bad; 863 goto bad;
881 } 864 }
882 865
883 if (object && !check_object(s, page, object, 0)) 866 if (!check_object(s, page, object, 0))
884 goto bad; 867 goto bad;
885 868
886 /* Success perform special debug activities for allocs */ 869 /* Success perform special debug activities for allocs */
@@ -899,7 +882,7 @@ bad:
899 */ 882 */
900 slab_fix(s, "Marking all objects used"); 883 slab_fix(s, "Marking all objects used");
901 page->inuse = s->objects; 884 page->inuse = s->objects;
902 page->freelist = page->end; 885 page->freelist = NULL;
903 } 886 }
904 return 0; 887 return 0;
905} 888}
@@ -939,7 +922,7 @@ static int free_debug_processing(struct kmem_cache *s, struct page *page,
939 } 922 }
940 923
941 /* Special debug activities for freeing objects */ 924 /* Special debug activities for freeing objects */
942 if (!SlabFrozen(page) && page->freelist == page->end) 925 if (!SlabFrozen(page) && !page->freelist)
943 remove_full(s, page); 926 remove_full(s, page);
944 if (s->flags & SLAB_STORE_USER) 927 if (s->flags & SLAB_STORE_USER)
945 set_track(s, object, TRACK_FREE, addr); 928 set_track(s, object, TRACK_FREE, addr);
@@ -1015,30 +998,11 @@ static unsigned long kmem_cache_flags(unsigned long objsize,
1015 void (*ctor)(struct kmem_cache *, void *)) 998 void (*ctor)(struct kmem_cache *, void *))
1016{ 999{
1017 /* 1000 /*
1018 * The page->offset field is only 16 bit wide. This is an offset 1001 * Enable debugging if selected on the kernel commandline.
1019 * in units of words from the beginning of an object. If the slab
1020 * size is bigger then we cannot move the free pointer behind the
1021 * object anymore.
1022 *
1023 * On 32 bit platforms the limit is 256k. On 64bit platforms
1024 * the limit is 512k.
1025 *
1026 * Debugging or ctor may create a need to move the free
1027 * pointer. Fail if this happens.
1028 */ 1002 */
1029 if (objsize >= 65535 * sizeof(void *)) { 1003 if (slub_debug && (!slub_debug_slabs ||
1030 BUG_ON(flags & (SLAB_RED_ZONE | SLAB_POISON | 1004 strncmp(slub_debug_slabs, name, strlen(slub_debug_slabs)) == 0))
1031 SLAB_STORE_USER | SLAB_DESTROY_BY_RCU)); 1005 flags |= slub_debug;
1032 BUG_ON(ctor);
1033 } else {
1034 /*
1035 * Enable debugging if selected on the kernel commandline.
1036 */
1037 if (slub_debug && (!slub_debug_slabs ||
1038 strncmp(slub_debug_slabs, name,
1039 strlen(slub_debug_slabs)) == 0))
1040 flags |= slub_debug;
1041 }
1042 1006
1043 return flags; 1007 return flags;
1044} 1008}
@@ -1124,7 +1088,6 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
1124 SetSlabDebug(page); 1088 SetSlabDebug(page);
1125 1089
1126 start = page_address(page); 1090 start = page_address(page);
1127 page->end = start + 1;
1128 1091
1129 if (unlikely(s->flags & SLAB_POISON)) 1092 if (unlikely(s->flags & SLAB_POISON))
1130 memset(start, POISON_INUSE, PAGE_SIZE << s->order); 1093 memset(start, POISON_INUSE, PAGE_SIZE << s->order);
@@ -1136,7 +1099,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node)
1136 last = p; 1099 last = p;
1137 } 1100 }
1138 setup_object(s, page, last); 1101 setup_object(s, page, last);
1139 set_freepointer(s, last, page->end); 1102 set_freepointer(s, last, NULL);
1140 1103
1141 page->freelist = start; 1104 page->freelist = start;
1142 page->inuse = 0; 1105 page->inuse = 0;
@@ -1152,7 +1115,7 @@ static void __free_slab(struct kmem_cache *s, struct page *page)
1152 void *p; 1115 void *p;
1153 1116
1154 slab_pad_check(s, page); 1117 slab_pad_check(s, page);
1155 for_each_object(p, s, slab_address(page)) 1118 for_each_object(p, s, page_address(page))
1156 check_object(s, page, p, 0); 1119 check_object(s, page, p, 0);
1157 ClearSlabDebug(page); 1120 ClearSlabDebug(page);
1158 } 1121 }
@@ -1162,7 +1125,6 @@ static void __free_slab(struct kmem_cache *s, struct page *page)
1162 NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE, 1125 NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE,
1163 -pages); 1126 -pages);
1164 1127
1165 page->mapping = NULL;
1166 __free_pages(page, s->order); 1128 __free_pages(page, s->order);
1167} 1129}
1168 1130
@@ -1307,7 +1269,7 @@ static struct page *get_any_partial(struct kmem_cache *s, gfp_t flags)
1307 * may return off node objects because partial slabs are obtained 1269 * may return off node objects because partial slabs are obtained
1308 * from other nodes and filled up. 1270 * from other nodes and filled up.
1309 * 1271 *
1310 * If /sys/slab/xx/defrag_ratio is set to 100 (which makes 1272 * If /sys/kernel/slab/xx/defrag_ratio is set to 100 (which makes
1311 * defrag_ratio = 1000) then every (well almost) allocation will 1273 * defrag_ratio = 1000) then every (well almost) allocation will
1312 * first attempt to defrag slab caches on other nodes. This means 1274 * first attempt to defrag slab caches on other nodes. This means
1313 * scanning over all nodes to look for partial slabs which may be 1275 * scanning over all nodes to look for partial slabs which may be
@@ -1366,7 +1328,7 @@ static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail)
1366 ClearSlabFrozen(page); 1328 ClearSlabFrozen(page);
1367 if (page->inuse) { 1329 if (page->inuse) {
1368 1330
1369 if (page->freelist != page->end) { 1331 if (page->freelist) {
1370 add_partial(n, page, tail); 1332 add_partial(n, page, tail);
1371 stat(c, tail ? DEACTIVATE_TO_TAIL : DEACTIVATE_TO_HEAD); 1333 stat(c, tail ? DEACTIVATE_TO_TAIL : DEACTIVATE_TO_HEAD);
1372 } else { 1334 } else {
@@ -1382,9 +1344,11 @@ static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail)
1382 * Adding an empty slab to the partial slabs in order 1344 * Adding an empty slab to the partial slabs in order
1383 * to avoid page allocator overhead. This slab needs 1345 * to avoid page allocator overhead. This slab needs
1384 * to come after the other slabs with objects in 1346 * to come after the other slabs with objects in
1385 * order to fill them up. That way the size of the 1347 * so that the others get filled first. That way the
1386 * partial list stays small. kmem_cache_shrink can 1348 * size of the partial list stays small.
1387 * reclaim empty slabs from the partial list. 1349 *
1350 * kmem_cache_shrink can reclaim any empty slabs from the
1351 * partial list.
1388 */ 1352 */
1389 add_partial(n, page, 1); 1353 add_partial(n, page, 1);
1390 slab_unlock(page); 1354 slab_unlock(page);
@@ -1407,15 +1371,11 @@ static void deactivate_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
1407 if (c->freelist) 1371 if (c->freelist)
1408 stat(c, DEACTIVATE_REMOTE_FREES); 1372 stat(c, DEACTIVATE_REMOTE_FREES);
1409 /* 1373 /*
1410 * Merge cpu freelist into freelist. Typically we get here 1374 * Merge cpu freelist into slab freelist. Typically we get here
1411 * because both freelists are empty. So this is unlikely 1375 * because both freelists are empty. So this is unlikely
1412 * to occur. 1376 * to occur.
1413 *
1414 * We need to use _is_end here because deactivate slab may
1415 * be called for a debug slab. Then c->freelist may contain
1416 * a dummy pointer.
1417 */ 1377 */
1418 while (unlikely(!is_end(c->freelist))) { 1378 while (unlikely(c->freelist)) {
1419 void **object; 1379 void **object;
1420 1380
1421 tail = 0; /* Hot objects. Put the slab first */ 1381 tail = 0; /* Hot objects. Put the slab first */
@@ -1442,6 +1402,7 @@ static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c)
1442 1402
1443/* 1403/*
1444 * Flush cpu slab. 1404 * Flush cpu slab.
1405 *
1445 * Called from IPI handler with interrupts disabled. 1406 * Called from IPI handler with interrupts disabled.
1446 */ 1407 */
1447static inline void __flush_cpu_slab(struct kmem_cache *s, int cpu) 1408static inline void __flush_cpu_slab(struct kmem_cache *s, int cpu)
@@ -1500,7 +1461,8 @@ static inline int node_match(struct kmem_cache_cpu *c, int node)
1500 * rest of the freelist to the lockless freelist. 1461 * rest of the freelist to the lockless freelist.
1501 * 1462 *
1502 * And if we were unable to get a new slab from the partial slab lists then 1463 * And if we were unable to get a new slab from the partial slab lists then
1503 * we need to allocate a new slab. This is slowest path since we may sleep. 1464 * we need to allocate a new slab. This is the slowest path since it involves
1465 * a call to the page allocator and the setup of a new slab.
1504 */ 1466 */
1505static void *__slab_alloc(struct kmem_cache *s, 1467static void *__slab_alloc(struct kmem_cache *s,
1506 gfp_t gfpflags, int node, void *addr, struct kmem_cache_cpu *c) 1468 gfp_t gfpflags, int node, void *addr, struct kmem_cache_cpu *c)
@@ -1514,18 +1476,19 @@ static void *__slab_alloc(struct kmem_cache *s,
1514 slab_lock(c->page); 1476 slab_lock(c->page);
1515 if (unlikely(!node_match(c, node))) 1477 if (unlikely(!node_match(c, node)))
1516 goto another_slab; 1478 goto another_slab;
1479
1517 stat(c, ALLOC_REFILL); 1480 stat(c, ALLOC_REFILL);
1481
1518load_freelist: 1482load_freelist:
1519 object = c->page->freelist; 1483 object = c->page->freelist;
1520 if (unlikely(object == c->page->end)) 1484 if (unlikely(!object))
1521 goto another_slab; 1485 goto another_slab;
1522 if (unlikely(SlabDebug(c->page))) 1486 if (unlikely(SlabDebug(c->page)))
1523 goto debug; 1487 goto debug;
1524 1488
1525 object = c->page->freelist;
1526 c->freelist = object[c->offset]; 1489 c->freelist = object[c->offset];
1527 c->page->inuse = s->objects; 1490 c->page->inuse = s->objects;
1528 c->page->freelist = c->page->end; 1491 c->page->freelist = NULL;
1529 c->node = page_to_nid(c->page); 1492 c->node = page_to_nid(c->page);
1530unlock_out: 1493unlock_out:
1531 slab_unlock(c->page); 1494 slab_unlock(c->page);
@@ -1578,7 +1541,6 @@ new_slab:
1578 1541
1579 return NULL; 1542 return NULL;
1580debug: 1543debug:
1581 object = c->page->freelist;
1582 if (!alloc_debug_processing(s, c->page, object, addr)) 1544 if (!alloc_debug_processing(s, c->page, object, addr))
1583 goto another_slab; 1545 goto another_slab;
1584 1546
@@ -1607,7 +1569,7 @@ static __always_inline void *slab_alloc(struct kmem_cache *s,
1607 1569
1608 local_irq_save(flags); 1570 local_irq_save(flags);
1609 c = get_cpu_slab(s, smp_processor_id()); 1571 c = get_cpu_slab(s, smp_processor_id());
1610 if (unlikely(is_end(c->freelist) || !node_match(c, node))) 1572 if (unlikely(!c->freelist || !node_match(c, node)))
1611 1573
1612 object = __slab_alloc(s, gfpflags, node, addr, c); 1574 object = __slab_alloc(s, gfpflags, node, addr, c);
1613 1575
@@ -1659,6 +1621,7 @@ static void __slab_free(struct kmem_cache *s, struct page *page,
1659 1621
1660 if (unlikely(SlabDebug(page))) 1622 if (unlikely(SlabDebug(page)))
1661 goto debug; 1623 goto debug;
1624
1662checks_ok: 1625checks_ok:
1663 prior = object[offset] = page->freelist; 1626 prior = object[offset] = page->freelist;
1664 page->freelist = object; 1627 page->freelist = object;
@@ -1673,11 +1636,10 @@ checks_ok:
1673 goto slab_empty; 1636 goto slab_empty;
1674 1637
1675 /* 1638 /*
1676 * Objects left in the slab. If it 1639 * Objects left in the slab. If it was not on the partial list before
1677 * was not on the partial list before
1678 * then add it. 1640 * then add it.
1679 */ 1641 */
1680 if (unlikely(prior == page->end)) { 1642 if (unlikely(!prior)) {
1681 add_partial(get_node(s, page_to_nid(page)), page, 1); 1643 add_partial(get_node(s, page_to_nid(page)), page, 1);
1682 stat(c, FREE_ADD_PARTIAL); 1644 stat(c, FREE_ADD_PARTIAL);
1683 } 1645 }
@@ -1687,7 +1649,7 @@ out_unlock:
1687 return; 1649 return;
1688 1650
1689slab_empty: 1651slab_empty:
1690 if (prior != page->end) { 1652 if (prior) {
1691 /* 1653 /*
1692 * Slab still on the partial list. 1654 * Slab still on the partial list.
1693 */ 1655 */
@@ -1724,8 +1686,8 @@ static __always_inline void slab_free(struct kmem_cache *s,
1724 unsigned long flags; 1686 unsigned long flags;
1725 1687
1726 local_irq_save(flags); 1688 local_irq_save(flags);
1727 debug_check_no_locks_freed(object, s->objsize);
1728 c = get_cpu_slab(s, smp_processor_id()); 1689 c = get_cpu_slab(s, smp_processor_id());
1690 debug_check_no_locks_freed(object, c->objsize);
1729 if (likely(page == c->page && c->node >= 0)) { 1691 if (likely(page == c->page && c->node >= 0)) {
1730 object[c->offset] = c->freelist; 1692 object[c->offset] = c->freelist;
1731 c->freelist = object; 1693 c->freelist = object;
@@ -1888,13 +1850,11 @@ static unsigned long calculate_alignment(unsigned long flags,
1888 unsigned long align, unsigned long size) 1850 unsigned long align, unsigned long size)
1889{ 1851{
1890 /* 1852 /*
1891 * If the user wants hardware cache aligned objects then 1853 * If the user wants hardware cache aligned objects then follow that
1892 * follow that suggestion if the object is sufficiently 1854 * suggestion if the object is sufficiently large.
1893 * large.
1894 * 1855 *
1895 * The hardware cache alignment cannot override the 1856 * The hardware cache alignment cannot override the specified
1896 * specified alignment though. If that is greater 1857 * alignment though. If that is greater then use it.
1897 * then use it.
1898 */ 1858 */
1899 if ((flags & SLAB_HWCACHE_ALIGN) && 1859 if ((flags & SLAB_HWCACHE_ALIGN) &&
1900 size > cache_line_size() / 2) 1860 size > cache_line_size() / 2)
@@ -1910,7 +1870,7 @@ static void init_kmem_cache_cpu(struct kmem_cache *s,
1910 struct kmem_cache_cpu *c) 1870 struct kmem_cache_cpu *c)
1911{ 1871{
1912 c->page = NULL; 1872 c->page = NULL;
1913 c->freelist = (void *)PAGE_MAPPING_ANON; 1873 c->freelist = NULL;
1914 c->node = 0; 1874 c->node = 0;
1915 c->offset = s->offset / sizeof(void *); 1875 c->offset = s->offset / sizeof(void *);
1916 c->objsize = s->objsize; 1876 c->objsize = s->objsize;
@@ -2092,6 +2052,7 @@ static struct kmem_cache_node *early_kmem_cache_node_alloc(gfp_t gfpflags,
2092#endif 2052#endif
2093 init_kmem_cache_node(n); 2053 init_kmem_cache_node(n);
2094 atomic_long_inc(&n->nr_slabs); 2054 atomic_long_inc(&n->nr_slabs);
2055
2095 /* 2056 /*
2096 * lockdep requires consistent irq usage for each lock 2057 * lockdep requires consistent irq usage for each lock
2097 * so even though there cannot be a race this early in 2058 * so even though there cannot be a race this early in
@@ -2173,6 +2134,14 @@ static int calculate_sizes(struct kmem_cache *s)
2173 unsigned long align = s->align; 2134 unsigned long align = s->align;
2174 2135
2175 /* 2136 /*
2137 * Round up object size to the next word boundary. We can only
2138 * place the free pointer at word boundaries and this determines
2139 * the possible location of the free pointer.
2140 */
2141 size = ALIGN(size, sizeof(void *));
2142
2143#ifdef CONFIG_SLUB_DEBUG
2144 /*
2176 * Determine if we can poison the object itself. If the user of 2145 * Determine if we can poison the object itself. If the user of
2177 * the slab may touch the object after free or before allocation 2146 * the slab may touch the object after free or before allocation
2178 * then we should never poison the object itself. 2147 * then we should never poison the object itself.
@@ -2183,14 +2152,7 @@ static int calculate_sizes(struct kmem_cache *s)
2183 else 2152 else
2184 s->flags &= ~__OBJECT_POISON; 2153 s->flags &= ~__OBJECT_POISON;
2185 2154
2186 /*
2187 * Round up object size to the next word boundary. We can only
2188 * place the free pointer at word boundaries and this determines
2189 * the possible location of the free pointer.
2190 */
2191 size = ALIGN(size, sizeof(void *));
2192 2155
2193#ifdef CONFIG_SLUB_DEBUG
2194 /* 2156 /*
2195 * If we are Redzoning then check if there is some space between the 2157 * If we are Redzoning then check if there is some space between the
2196 * end of the object and the free pointer. If not then add an 2158 * end of the object and the free pointer. If not then add an
@@ -2343,7 +2305,7 @@ int kmem_ptr_validate(struct kmem_cache *s, const void *object)
2343 /* 2305 /*
2344 * We could also check if the object is on the slabs freelist. 2306 * We could also check if the object is on the slabs freelist.
2345 * But this would be too expensive and it seems that the main 2307 * But this would be too expensive and it seems that the main
2346 * purpose of kmem_ptr_valid is to check if the object belongs 2308 * purpose of kmem_ptr_valid() is to check if the object belongs
2347 * to a certain slab. 2309 * to a certain slab.
2348 */ 2310 */
2349 return 1; 2311 return 1;
@@ -2630,13 +2592,24 @@ void *__kmalloc(size_t size, gfp_t flags)
2630} 2592}
2631EXPORT_SYMBOL(__kmalloc); 2593EXPORT_SYMBOL(__kmalloc);
2632 2594
2595static void *kmalloc_large_node(size_t size, gfp_t flags, int node)
2596{
2597 struct page *page = alloc_pages_node(node, flags | __GFP_COMP,
2598 get_order(size));
2599
2600 if (page)
2601 return page_address(page);
2602 else
2603 return NULL;
2604}
2605
2633#ifdef CONFIG_NUMA 2606#ifdef CONFIG_NUMA
2634void *__kmalloc_node(size_t size, gfp_t flags, int node) 2607void *__kmalloc_node(size_t size, gfp_t flags, int node)
2635{ 2608{
2636 struct kmem_cache *s; 2609 struct kmem_cache *s;
2637 2610
2638 if (unlikely(size > PAGE_SIZE)) 2611 if (unlikely(size > PAGE_SIZE))
2639 return kmalloc_large(size, flags); 2612 return kmalloc_large_node(size, flags, node);
2640 2613
2641 s = get_slab(size, flags); 2614 s = get_slab(size, flags);
2642 2615
@@ -2653,19 +2626,17 @@ size_t ksize(const void *object)
2653 struct page *page; 2626 struct page *page;
2654 struct kmem_cache *s; 2627 struct kmem_cache *s;
2655 2628
2656 BUG_ON(!object);
2657 if (unlikely(object == ZERO_SIZE_PTR)) 2629 if (unlikely(object == ZERO_SIZE_PTR))
2658 return 0; 2630 return 0;
2659 2631
2660 page = virt_to_head_page(object); 2632 page = virt_to_head_page(object);
2661 BUG_ON(!page);
2662 2633
2663 if (unlikely(!PageSlab(page))) 2634 if (unlikely(!PageSlab(page)))
2664 return PAGE_SIZE << compound_order(page); 2635 return PAGE_SIZE << compound_order(page);
2665 2636
2666 s = page->slab; 2637 s = page->slab;
2667 BUG_ON(!s);
2668 2638
2639#ifdef CONFIG_SLUB_DEBUG
2669 /* 2640 /*
2670 * Debugging requires use of the padding between object 2641 * Debugging requires use of the padding between object
2671 * and whatever may come after it. 2642 * and whatever may come after it.
@@ -2673,6 +2644,7 @@ size_t ksize(const void *object)
2673 if (s->flags & (SLAB_RED_ZONE | SLAB_POISON)) 2644 if (s->flags & (SLAB_RED_ZONE | SLAB_POISON))
2674 return s->objsize; 2645 return s->objsize;
2675 2646
2647#endif
2676 /* 2648 /*
2677 * If we have the need to store the freelist pointer 2649 * If we have the need to store the freelist pointer
2678 * back there or track user information then we can 2650 * back there or track user information then we can
@@ -2680,7 +2652,6 @@ size_t ksize(const void *object)
2680 */ 2652 */
2681 if (s->flags & (SLAB_DESTROY_BY_RCU | SLAB_STORE_USER)) 2653 if (s->flags & (SLAB_DESTROY_BY_RCU | SLAB_STORE_USER))
2682 return s->inuse; 2654 return s->inuse;
2683
2684 /* 2655 /*
2685 * Else we can use all the padding etc for the allocation 2656 * Else we can use all the padding etc for the allocation
2686 */ 2657 */
@@ -2957,7 +2928,7 @@ void __init kmem_cache_init(void)
2957 /* 2928 /*
2958 * Patch up the size_index table if we have strange large alignment 2929 * Patch up the size_index table if we have strange large alignment
2959 * requirements for the kmalloc array. This is only the case for 2930 * requirements for the kmalloc array. This is only the case for
2960 * mips it seems. The standard arches will not generate any code here. 2931 * MIPS it seems. The standard arches will not generate any code here.
2961 * 2932 *
2962 * Largest permitted alignment is 256 bytes due to the way we 2933 * Largest permitted alignment is 256 bytes due to the way we
2963 * handle the index determination for the smaller caches. 2934 * handle the index determination for the smaller caches.
@@ -2986,7 +2957,6 @@ void __init kmem_cache_init(void)
2986 kmem_size = sizeof(struct kmem_cache); 2957 kmem_size = sizeof(struct kmem_cache);
2987#endif 2958#endif
2988 2959
2989
2990 printk(KERN_INFO 2960 printk(KERN_INFO
2991 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d," 2961 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
2992 " CPUs=%d, Nodes=%d\n", 2962 " CPUs=%d, Nodes=%d\n",
@@ -3083,12 +3053,15 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
3083 */ 3053 */
3084 for_each_online_cpu(cpu) 3054 for_each_online_cpu(cpu)
3085 get_cpu_slab(s, cpu)->objsize = s->objsize; 3055 get_cpu_slab(s, cpu)->objsize = s->objsize;
3056
3086 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); 3057 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
3087 up_write(&slub_lock); 3058 up_write(&slub_lock);
3059
3088 if (sysfs_slab_alias(s, name)) 3060 if (sysfs_slab_alias(s, name))
3089 goto err; 3061 goto err;
3090 return s; 3062 return s;
3091 } 3063 }
3064
3092 s = kmalloc(kmem_size, GFP_KERNEL); 3065 s = kmalloc(kmem_size, GFP_KERNEL);
3093 if (s) { 3066 if (s) {
3094 if (kmem_cache_open(s, GFP_KERNEL, name, 3067 if (kmem_cache_open(s, GFP_KERNEL, name,
@@ -3184,7 +3157,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
3184 struct kmem_cache *s; 3157 struct kmem_cache *s;
3185 3158
3186 if (unlikely(size > PAGE_SIZE)) 3159 if (unlikely(size > PAGE_SIZE))
3187 return kmalloc_large(size, gfpflags); 3160 return kmalloc_large_node(size, gfpflags, node);
3188 3161
3189 s = get_slab(size, gfpflags); 3162 s = get_slab(size, gfpflags);
3190 3163
@@ -3199,7 +3172,7 @@ static int validate_slab(struct kmem_cache *s, struct page *page,
3199 unsigned long *map) 3172 unsigned long *map)
3200{ 3173{
3201 void *p; 3174 void *p;
3202 void *addr = slab_address(page); 3175 void *addr = page_address(page);
3203 3176
3204 if (!check_slab(s, page) || 3177 if (!check_slab(s, page) ||
3205 !on_freelist(s, page, NULL)) 3178 !on_freelist(s, page, NULL))
@@ -3482,7 +3455,7 @@ static int add_location(struct loc_track *t, struct kmem_cache *s,
3482static void process_slab(struct loc_track *t, struct kmem_cache *s, 3455static void process_slab(struct loc_track *t, struct kmem_cache *s,
3483 struct page *page, enum track_item alloc) 3456 struct page *page, enum track_item alloc)
3484{ 3457{
3485 void *addr = slab_address(page); 3458 void *addr = page_address(page);
3486 DECLARE_BITMAP(map, s->objects); 3459 DECLARE_BITMAP(map, s->objects);
3487 void *p; 3460 void *p;
3488 3461
@@ -3591,8 +3564,8 @@ enum slab_stat_type {
3591#define SO_CPU (1 << SL_CPU) 3564#define SO_CPU (1 << SL_CPU)
3592#define SO_OBJECTS (1 << SL_OBJECTS) 3565#define SO_OBJECTS (1 << SL_OBJECTS)
3593 3566
3594static unsigned long slab_objects(struct kmem_cache *s, 3567static ssize_t show_slab_objects(struct kmem_cache *s,
3595 char *buf, unsigned long flags) 3568 char *buf, unsigned long flags)
3596{ 3569{
3597 unsigned long total = 0; 3570 unsigned long total = 0;
3598 int cpu; 3571 int cpu;
@@ -3602,6 +3575,8 @@ static unsigned long slab_objects(struct kmem_cache *s,
3602 unsigned long *per_cpu; 3575 unsigned long *per_cpu;
3603 3576
3604 nodes = kzalloc(2 * sizeof(unsigned long) * nr_node_ids, GFP_KERNEL); 3577 nodes = kzalloc(2 * sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
3578 if (!nodes)
3579 return -ENOMEM;
3605 per_cpu = nodes + nr_node_ids; 3580 per_cpu = nodes + nr_node_ids;
3606 3581
3607 for_each_possible_cpu(cpu) { 3582 for_each_possible_cpu(cpu) {
@@ -3754,25 +3729,25 @@ SLAB_ATTR_RO(aliases);
3754 3729
3755static ssize_t slabs_show(struct kmem_cache *s, char *buf) 3730static ssize_t slabs_show(struct kmem_cache *s, char *buf)
3756{ 3731{
3757 return slab_objects(s, buf, SO_FULL|SO_PARTIAL|SO_CPU); 3732 return show_slab_objects(s, buf, SO_FULL|SO_PARTIAL|SO_CPU);
3758} 3733}
3759SLAB_ATTR_RO(slabs); 3734SLAB_ATTR_RO(slabs);
3760 3735
3761static ssize_t partial_show(struct kmem_cache *s, char *buf) 3736static ssize_t partial_show(struct kmem_cache *s, char *buf)
3762{ 3737{
3763 return slab_objects(s, buf, SO_PARTIAL); 3738 return show_slab_objects(s, buf, SO_PARTIAL);
3764} 3739}
3765SLAB_ATTR_RO(partial); 3740SLAB_ATTR_RO(partial);
3766 3741
3767static ssize_t cpu_slabs_show(struct kmem_cache *s, char *buf) 3742static ssize_t cpu_slabs_show(struct kmem_cache *s, char *buf)
3768{ 3743{
3769 return slab_objects(s, buf, SO_CPU); 3744 return show_slab_objects(s, buf, SO_CPU);
3770} 3745}
3771SLAB_ATTR_RO(cpu_slabs); 3746SLAB_ATTR_RO(cpu_slabs);
3772 3747
3773static ssize_t objects_show(struct kmem_cache *s, char *buf) 3748static ssize_t objects_show(struct kmem_cache *s, char *buf)
3774{ 3749{
3775 return slab_objects(s, buf, SO_FULL|SO_PARTIAL|SO_CPU|SO_OBJECTS); 3750 return show_slab_objects(s, buf, SO_FULL|SO_PARTIAL|SO_CPU|SO_OBJECTS);
3776} 3751}
3777SLAB_ATTR_RO(objects); 3752SLAB_ATTR_RO(objects);
3778 3753
@@ -3971,7 +3946,6 @@ SLAB_ATTR(remote_node_defrag_ratio);
3971#endif 3946#endif
3972 3947
3973#ifdef CONFIG_SLUB_STATS 3948#ifdef CONFIG_SLUB_STATS
3974
3975static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si) 3949static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si)
3976{ 3950{
3977 unsigned long sum = 0; 3951 unsigned long sum = 0;
@@ -4155,8 +4129,8 @@ static struct kset *slab_kset;
4155#define ID_STR_LENGTH 64 4129#define ID_STR_LENGTH 64
4156 4130
4157/* Create a unique string id for a slab cache: 4131/* Create a unique string id for a slab cache:
4158 * format 4132 *
4159 * :[flags-]size:[memory address of kmemcache] 4133 * Format :[flags-]size
4160 */ 4134 */
4161static char *create_unique_id(struct kmem_cache *s) 4135static char *create_unique_id(struct kmem_cache *s)
4162{ 4136{
diff --git a/mm/truncate.c b/mm/truncate.c
index c35c49e54fb6..7d20ce41ecf5 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -134,8 +134,7 @@ invalidate_complete_page(struct address_space *mapping, struct page *page)
134} 134}
135 135
136/** 136/**
137 * truncate_inode_pages - truncate range of pages specified by start and 137 * truncate_inode_pages - truncate range of pages specified by start & end byte offsets
138 * end byte offsets
139 * @mapping: mapping to truncate 138 * @mapping: mapping to truncate
140 * @lstart: offset from which to truncate 139 * @lstart: offset from which to truncate
141 * @lend: offset to which to truncate 140 * @lend: offset to which to truncate