aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-generic')
-rw-r--r--include/asm-generic/bug.h6
-rw-r--r--include/asm-generic/getorder.h53
-rw-r--r--include/asm-generic/iomap.h2
-rw-r--r--include/asm-generic/mman-common.h4
-rw-r--r--include/asm-generic/pci-bridge.h6
-rw-r--r--include/asm-generic/pci.h24
-rw-r--r--include/asm-generic/pci_iomap.h2
-rw-r--r--include/asm-generic/pgtable.h61
-rw-r--r--include/asm-generic/socket.h5
-rw-r--r--include/asm-generic/vmlinux.lds.h1
10 files changed, 127 insertions, 37 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 84458b0c38d1..2520a6e241dc 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -134,7 +134,7 @@ extern void warn_slowpath_null(const char *file, const int line);
134#endif 134#endif
135 135
136#define WARN_ON_ONCE(condition) ({ \ 136#define WARN_ON_ONCE(condition) ({ \
137 static bool __warned; \ 137 static bool __section(.data.unlikely) __warned; \
138 int __ret_warn_once = !!(condition); \ 138 int __ret_warn_once = !!(condition); \
139 \ 139 \
140 if (unlikely(__ret_warn_once)) \ 140 if (unlikely(__ret_warn_once)) \
@@ -144,7 +144,7 @@ extern void warn_slowpath_null(const char *file, const int line);
144}) 144})
145 145
146#define WARN_ONCE(condition, format...) ({ \ 146#define WARN_ONCE(condition, format...) ({ \
147 static bool __warned; \ 147 static bool __section(.data.unlikely) __warned; \
148 int __ret_warn_once = !!(condition); \ 148 int __ret_warn_once = !!(condition); \
149 \ 149 \
150 if (unlikely(__ret_warn_once)) \ 150 if (unlikely(__ret_warn_once)) \
@@ -154,7 +154,7 @@ extern void warn_slowpath_null(const char *file, const int line);
154}) 154})
155 155
156#define WARN_TAINT_ONCE(condition, taint, format...) ({ \ 156#define WARN_TAINT_ONCE(condition, taint, format...) ({ \
157 static bool __warned; \ 157 static bool __section(.data.unlikely) __warned; \
158 int __ret_warn_once = !!(condition); \ 158 int __ret_warn_once = !!(condition); \
159 \ 159 \
160 if (unlikely(__ret_warn_once)) \ 160 if (unlikely(__ret_warn_once)) \
diff --git a/include/asm-generic/getorder.h b/include/asm-generic/getorder.h
index 67e7245dc9b3..65e4468ac53d 100644
--- a/include/asm-generic/getorder.h
+++ b/include/asm-generic/getorder.h
@@ -4,21 +4,58 @@
4#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
5 5
6#include <linux/compiler.h> 6#include <linux/compiler.h>
7#include <linux/log2.h>
7 8
8/* Pure 2^n version of get_order */ 9/*
9static inline __attribute_const__ int get_order(unsigned long size) 10 * Runtime evaluation of get_order()
11 */
12static inline __attribute_const__
13int __get_order(unsigned long size)
10{ 14{
11 int order; 15 int order;
12 16
13 size = (size - 1) >> (PAGE_SHIFT - 1); 17 size--;
14 order = -1; 18 size >>= PAGE_SHIFT;
15 do { 19#if BITS_PER_LONG == 32
16 size >>= 1; 20 order = fls(size);
17 order++; 21#else
18 } while (size); 22 order = fls64(size);
23#endif
19 return order; 24 return order;
20} 25}
21 26
27/**
28 * get_order - Determine the allocation order of a memory size
29 * @size: The size for which to get the order
30 *
31 * Determine the allocation order of a particular sized block of memory. This
32 * is on a logarithmic scale, where:
33 *
34 * 0 -> 2^0 * PAGE_SIZE and below
35 * 1 -> 2^1 * PAGE_SIZE to 2^0 * PAGE_SIZE + 1
36 * 2 -> 2^2 * PAGE_SIZE to 2^1 * PAGE_SIZE + 1
37 * 3 -> 2^3 * PAGE_SIZE to 2^2 * PAGE_SIZE + 1
38 * 4 -> 2^4 * PAGE_SIZE to 2^3 * PAGE_SIZE + 1
39 * ...
40 *
41 * The order returned is used to find the smallest allocation granule required
42 * to hold an object of the specified size.
43 *
44 * The result is undefined if the size is 0.
45 *
46 * This function may be used to initialise variables with compile time
47 * evaluations of constants.
48 */
49#define get_order(n) \
50( \
51 __builtin_constant_p(n) ? ( \
52 ((n) == 0UL) ? BITS_PER_LONG - PAGE_SHIFT : \
53 (((n) < (1UL << PAGE_SHIFT)) ? 0 : \
54 ilog2((n) - 1) - PAGE_SHIFT + 1) \
55 ) : \
56 __get_order(n) \
57)
58
22#endif /* __ASSEMBLY__ */ 59#endif /* __ASSEMBLY__ */
23 60
24#endif /* __ASM_GENERIC_GETORDER_H */ 61#endif /* __ASM_GENERIC_GETORDER_H */
diff --git a/include/asm-generic/iomap.h b/include/asm-generic/iomap.h
index 8a3d4fde2604..6afd7d6a9899 100644
--- a/include/asm-generic/iomap.h
+++ b/include/asm-generic/iomap.h
@@ -70,7 +70,7 @@ extern void ioport_unmap(void __iomem *);
70/* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */ 70/* Destroy a virtual mapping cookie for a PCI BAR (memory or IO) */
71struct pci_dev; 71struct pci_dev;
72extern void pci_iounmap(struct pci_dev *dev, void __iomem *); 72extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
73#else 73#elif defined(CONFIG_GENERIC_IOMAP)
74struct pci_dev; 74struct pci_dev;
75static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr) 75static inline void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
76{ } 76{ }
diff --git a/include/asm-generic/mman-common.h b/include/asm-generic/mman-common.h
index 787abbb6d867..d030d2c2647a 100644
--- a/include/asm-generic/mman-common.h
+++ b/include/asm-generic/mman-common.h
@@ -48,6 +48,10 @@
48#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */ 48#define MADV_HUGEPAGE 14 /* Worth backing with hugepages */
49#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */ 49#define MADV_NOHUGEPAGE 15 /* Not worth backing with hugepages */
50 50
51#define MADV_DONTDUMP 16 /* Explicity exclude from the core dump,
52 overrides the coredump filter bits */
53#define MADV_DODUMP 17 /* Clear the MADV_NODUMP flag */
54
51/* compatibility flags */ 55/* compatibility flags */
52#define MAP_FILE 0 56#define MAP_FILE 0
53 57
diff --git a/include/asm-generic/pci-bridge.h b/include/asm-generic/pci-bridge.h
index 4a5aca2a2c94..a5b5d5a89a4f 100644
--- a/include/asm-generic/pci-bridge.h
+++ b/include/asm-generic/pci-bridge.h
@@ -45,6 +45,11 @@ static inline void pci_add_flags(int flags)
45 pci_flags |= flags; 45 pci_flags |= flags;
46} 46}
47 47
48static inline void pci_clear_flags(int flags)
49{
50 pci_flags &= ~flags;
51}
52
48static inline int pci_has_flag(int flag) 53static inline int pci_has_flag(int flag)
49{ 54{
50 return pci_flags & flag; 55 return pci_flags & flag;
@@ -52,6 +57,7 @@ static inline int pci_has_flag(int flag)
52#else 57#else
53static inline void pci_set_flags(int flags) { } 58static inline void pci_set_flags(int flags) { }
54static inline void pci_add_flags(int flags) { } 59static inline void pci_add_flags(int flags) { }
60static inline void pci_clear_flags(int flags) { }
55static inline int pci_has_flag(int flag) 61static inline int pci_has_flag(int flag)
56{ 62{
57 return 0; 63 return 0;
diff --git a/include/asm-generic/pci.h b/include/asm-generic/pci.h
index 26373cff4546..e80a0495e5b0 100644
--- a/include/asm-generic/pci.h
+++ b/include/asm-generic/pci.h
@@ -6,30 +6,6 @@
6#ifndef _ASM_GENERIC_PCI_H 6#ifndef _ASM_GENERIC_PCI_H
7#define _ASM_GENERIC_PCI_H 7#define _ASM_GENERIC_PCI_H
8 8
9/**
10 * pcibios_resource_to_bus - convert resource to PCI bus address
11 * @dev: device which owns this resource
12 * @region: converted bus-centric region (start,end)
13 * @res: resource to convert
14 *
15 * Convert a resource to a PCI device bus address or bus window.
16 */
17static inline void
18pcibios_resource_to_bus(struct pci_dev *dev, struct pci_bus_region *region,
19 struct resource *res)
20{
21 region->start = res->start;
22 region->end = res->end;
23}
24
25static inline void
26pcibios_bus_to_resource(struct pci_dev *dev, struct resource *res,
27 struct pci_bus_region *region)
28{
29 res->start = region->start;
30 res->end = region->end;
31}
32
33static inline struct resource * 9static inline struct resource *
34pcibios_select_root(struct pci_dev *pdev, struct resource *res) 10pcibios_select_root(struct pci_dev *pdev, struct resource *res)
35{ 11{
diff --git a/include/asm-generic/pci_iomap.h b/include/asm-generic/pci_iomap.h
index e58fcf891370..ce37349860fe 100644
--- a/include/asm-generic/pci_iomap.h
+++ b/include/asm-generic/pci_iomap.h
@@ -25,7 +25,7 @@ extern void __iomem *__pci_ioport_map(struct pci_dev *dev, unsigned long port,
25#define __pci_ioport_map(dev, port, nr) ioport_map((port), (nr)) 25#define __pci_ioport_map(dev, port, nr) ioport_map((port), (nr))
26#endif 26#endif
27 27
28#else 28#elif defined(CONFIG_GENERIC_PCI_IOMAP)
29static inline void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max) 29static inline void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long max)
30{ 30{
31 return NULL; 31 return NULL;
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
index 236b1056839f..125c54e98517 100644
--- a/include/asm-generic/pgtable.h
+++ b/include/asm-generic/pgtable.h
@@ -426,6 +426,8 @@ extern void untrack_pfn_vma(struct vm_area_struct *vma, unsigned long pfn,
426 unsigned long size); 426 unsigned long size);
427#endif 427#endif
428 428
429#ifdef CONFIG_MMU
430
429#ifndef CONFIG_TRANSPARENT_HUGEPAGE 431#ifndef CONFIG_TRANSPARENT_HUGEPAGE
430static inline int pmd_trans_huge(pmd_t pmd) 432static inline int pmd_trans_huge(pmd_t pmd)
431{ 433{
@@ -442,7 +444,66 @@ static inline int pmd_write(pmd_t pmd)
442 return 0; 444 return 0;
443} 445}
444#endif /* __HAVE_ARCH_PMD_WRITE */ 446#endif /* __HAVE_ARCH_PMD_WRITE */
447#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
448
449/*
450 * This function is meant to be used by sites walking pagetables with
451 * the mmap_sem hold in read mode to protect against MADV_DONTNEED and
452 * transhuge page faults. MADV_DONTNEED can convert a transhuge pmd
453 * into a null pmd and the transhuge page fault can convert a null pmd
454 * into an hugepmd or into a regular pmd (if the hugepage allocation
455 * fails). While holding the mmap_sem in read mode the pmd becomes
456 * stable and stops changing under us only if it's not null and not a
457 * transhuge pmd. When those races occurs and this function makes a
458 * difference vs the standard pmd_none_or_clear_bad, the result is
459 * undefined so behaving like if the pmd was none is safe (because it
460 * can return none anyway). The compiler level barrier() is critically
461 * important to compute the two checks atomically on the same pmdval.
462 */
463static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
464{
465 /* depend on compiler for an atomic pmd read */
466 pmd_t pmdval = *pmd;
467 /*
468 * The barrier will stabilize the pmdval in a register or on
469 * the stack so that it will stop changing under the code.
470 */
471#ifdef CONFIG_TRANSPARENT_HUGEPAGE
472 barrier();
473#endif
474 if (pmd_none(pmdval))
475 return 1;
476 if (unlikely(pmd_bad(pmdval))) {
477 if (!pmd_trans_huge(pmdval))
478 pmd_clear_bad(pmd);
479 return 1;
480 }
481 return 0;
482}
483
484/*
485 * This is a noop if Transparent Hugepage Support is not built into
486 * the kernel. Otherwise it is equivalent to
487 * pmd_none_or_trans_huge_or_clear_bad(), and shall only be called in
488 * places that already verified the pmd is not none and they want to
489 * walk ptes while holding the mmap sem in read mode (write mode don't
490 * need this). If THP is not enabled, the pmd can't go away under the
491 * code even if MADV_DONTNEED runs, but if THP is enabled we need to
492 * run a pmd_trans_unstable before walking the ptes after
493 * split_huge_page_pmd returns (because it may have run when the pmd
494 * become null, but then a page fault can map in a THP and not a
495 * regular page).
496 */
497static inline int pmd_trans_unstable(pmd_t *pmd)
498{
499#ifdef CONFIG_TRANSPARENT_HUGEPAGE
500 return pmd_none_or_trans_huge_or_clear_bad(pmd);
501#else
502 return 0;
445#endif 503#endif
504}
505
506#endif /* CONFIG_MMU */
446 507
447#endif /* !__ASSEMBLY__ */ 508#endif /* !__ASSEMBLY__ */
448 509
diff --git a/include/asm-generic/socket.h b/include/asm-generic/socket.h
index 49c1704173e7..b1bea03274d5 100644
--- a/include/asm-generic/socket.h
+++ b/include/asm-generic/socket.h
@@ -67,4 +67,9 @@
67 67
68#define SO_WIFI_STATUS 41 68#define SO_WIFI_STATUS 41
69#define SCM_WIFI_STATUS SO_WIFI_STATUS 69#define SCM_WIFI_STATUS SO_WIFI_STATUS
70#define SO_PEEK_OFF 42
71
72/* Instruct lower device to use last 4-bytes of skb data as FCS */
73#define SO_NOFCS 43
74
70#endif /* __ASM_GENERIC_SOCKET_H */ 75#endif /* __ASM_GENERIC_SOCKET_H */
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index b5e2e4c6b017..798603e8ec38 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -167,6 +167,7 @@
167 CPU_KEEP(exit.data) \ 167 CPU_KEEP(exit.data) \
168 MEM_KEEP(init.data) \ 168 MEM_KEEP(init.data) \
169 MEM_KEEP(exit.data) \ 169 MEM_KEEP(exit.data) \
170 *(.data.unlikely) \
170 STRUCT_ALIGN(); \ 171 STRUCT_ALIGN(); \
171 *(__tracepoints) \ 172 *(__tracepoints) \
172 /* implement dynamic printk debug */ \ 173 /* implement dynamic printk debug */ \