aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-07-04 13:29:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-04 13:29:23 -0400
commit65b97fb7303050fc826e518cf67fc283da23314f (patch)
tree595e7f04d65d95a39d65bd2dcf2385b3b6ea7969 /arch/powerpc/include
parentddcf6600b133697adbafd96e080818bdc0dfd028 (diff)
parent1d8b368ab4aacfc3f864655baad4d31a3028ec1a (diff)
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
Pull powerpc updates from Ben Herrenschmidt: "This is the powerpc changes for the 3.11 merge window. In addition to the usual bug fixes and small updates, the main highlights are: - Support for transparent huge pages by Aneesh Kumar for 64-bit server processors. This allows the use of 16M pages as transparent huge pages on kernels compiled with a 64K base page size. - Base VFIO support for KVM on power by Alexey Kardashevskiy - Wiring up of our nvram to the pstore infrastructure, including putting compressed oopses in there by Aruna Balakrishnaiah - Move, rework and improve our "EEH" (basically PCI error handling and recovery) infrastructure. It is no longer specific to pseries but is now usable by the new "powernv" platform as well (no hypervisor) by Gavin Shan. - I fixed some bugs in our math-emu instruction decoding and made it usable to emulate some optional FP instructions on processors with hard FP that lack them (such as fsqrt on Freescale embedded processors). - Support for Power8 "Event Based Branch" facility by Michael Ellerman. This facility allows what is basically "userspace interrupts" for performance monitor events. - A bunch of Transactional Memory vs. Signals bug fixes and HW breakpoint/watchpoint fixes by Michael Neuling. And more ... I appologize in advance if I've failed to highlight something that somebody deemed worth it." * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: (156 commits) pstore: Add hsize argument in write_buf call of pstore_ftrace_call powerpc/fsl: add MPIC timer wakeup support powerpc/mpic: create mpic subsystem object powerpc/mpic: add global timer support powerpc/mpic: add irq_set_wake support powerpc/85xx: enable coreint for all the 64bit boards powerpc/8xx: Erroneous double irq_eoi() on CPM IRQ in MPC8xx powerpc/fsl: Enable CONFIG_E1000E in mpc85xx_smp_defconfig powerpc/mpic: Add get_version API both for internal and external use powerpc: Handle both new style and old style reserve maps powerpc/hw_brk: Fix off by one error when validating DAWR region end powerpc/pseries: Support compression of oops text via pstore powerpc/pseries: Re-organise the oops compression code pstore: Pass header size in the pstore write callback powerpc/powernv: Fix iommu initialization again powerpc/pseries: Inform the hypervisor we are using EBB regs powerpc/perf: Add power8 EBB support powerpc/perf: Core EBB support for 64-bit book3s powerpc/perf: Drop MMCRA from thread_struct powerpc/perf: Don't enable if we have zero events ...
Diffstat (limited to 'arch/powerpc/include')
-rw-r--r--arch/powerpc/include/asm/eeh.h36
-rw-r--r--arch/powerpc/include/asm/eeh_event.h2
-rw-r--r--arch/powerpc/include/asm/exception-64s.h8
-rw-r--r--arch/powerpc/include/asm/hugetlb.h8
-rw-r--r--arch/powerpc/include/asm/iommu.h33
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_64.h58
-rw-r--r--arch/powerpc/include/asm/lppaca.h3
-rw-r--r--arch/powerpc/include/asm/machdep.h11
-rw-r--r--arch/powerpc/include/asm/mmu-hash64.h14
-rw-r--r--arch/powerpc/include/asm/mpc5121.h1
-rw-r--r--arch/powerpc/include/asm/mpic.h5
-rw-r--r--arch/powerpc/include/asm/mpic_timer.h46
-rw-r--r--arch/powerpc/include/asm/opal.h140
-rw-r--r--arch/powerpc/include/asm/perf_event_server.h6
-rw-r--r--arch/powerpc/include/asm/pgalloc-64.h6
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc64-64k.h3
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc64.h241
-rw-r--r--arch/powerpc/include/asm/pgtable.h6
-rw-r--r--arch/powerpc/include/asm/probes.h25
-rw-r--r--arch/powerpc/include/asm/processor.h16
-rw-r--r--arch/powerpc/include/asm/reg.h9
-rw-r--r--arch/powerpc/include/asm/rtas.h4
-rw-r--r--arch/powerpc/include/asm/switch_to.h14
-rw-r--r--arch/powerpc/include/asm/tlbflush.h3
-rw-r--r--arch/powerpc/include/asm/vdso.h2
25 files changed, 577 insertions, 123 deletions
diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index a80e32b46c11..09a8743143f3 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/list.h> 25#include <linux/list.h>
26#include <linux/string.h> 26#include <linux/string.h>
27#include <linux/time.h>
27 28
28struct pci_dev; 29struct pci_dev;
29struct pci_bus; 30struct pci_bus;
@@ -52,6 +53,7 @@ struct device_node;
52 53
53#define EEH_PE_ISOLATED (1 << 0) /* Isolated PE */ 54#define EEH_PE_ISOLATED (1 << 0) /* Isolated PE */
54#define EEH_PE_RECOVERING (1 << 1) /* Recovering PE */ 55#define EEH_PE_RECOVERING (1 << 1) /* Recovering PE */
56#define EEH_PE_PHB_DEAD (1 << 2) /* Dead PHB */
55 57
56struct eeh_pe { 58struct eeh_pe {
57 int type; /* PE type: PHB/Bus/Device */ 59 int type; /* PE type: PHB/Bus/Device */
@@ -59,8 +61,10 @@ struct eeh_pe {
59 int config_addr; /* Traditional PCI address */ 61 int config_addr; /* Traditional PCI address */
60 int addr; /* PE configuration address */ 62 int addr; /* PE configuration address */
61 struct pci_controller *phb; /* Associated PHB */ 63 struct pci_controller *phb; /* Associated PHB */
64 struct pci_bus *bus; /* Top PCI bus for bus PE */
62 int check_count; /* Times of ignored error */ 65 int check_count; /* Times of ignored error */
63 int freeze_count; /* Times of froze up */ 66 int freeze_count; /* Times of froze up */
67 struct timeval tstamp; /* Time on first-time freeze */
64 int false_positives; /* Times of reported #ff's */ 68 int false_positives; /* Times of reported #ff's */
65 struct eeh_pe *parent; /* Parent PE */ 69 struct eeh_pe *parent; /* Parent PE */
66 struct list_head child_list; /* Link PE to the child list */ 70 struct list_head child_list; /* Link PE to the child list */
@@ -95,12 +99,12 @@ struct eeh_dev {
95 99
96static inline struct device_node *eeh_dev_to_of_node(struct eeh_dev *edev) 100static inline struct device_node *eeh_dev_to_of_node(struct eeh_dev *edev)
97{ 101{
98 return edev->dn; 102 return edev ? edev->dn : NULL;
99} 103}
100 104
101static inline struct pci_dev *eeh_dev_to_pci_dev(struct eeh_dev *edev) 105static inline struct pci_dev *eeh_dev_to_pci_dev(struct eeh_dev *edev)
102{ 106{
103 return edev->pdev; 107 return edev ? edev->pdev : NULL;
104} 108}
105 109
106/* 110/*
@@ -130,8 +134,9 @@ static inline struct pci_dev *eeh_dev_to_pci_dev(struct eeh_dev *edev)
130struct eeh_ops { 134struct eeh_ops {
131 char *name; 135 char *name;
132 int (*init)(void); 136 int (*init)(void);
137 int (*post_init)(void);
133 void* (*of_probe)(struct device_node *dn, void *flag); 138 void* (*of_probe)(struct device_node *dn, void *flag);
134 void* (*dev_probe)(struct pci_dev *dev, void *flag); 139 int (*dev_probe)(struct pci_dev *dev, void *flag);
135 int (*set_option)(struct eeh_pe *pe, int option); 140 int (*set_option)(struct eeh_pe *pe, int option);
136 int (*get_pe_addr)(struct eeh_pe *pe); 141 int (*get_pe_addr)(struct eeh_pe *pe);
137 int (*get_state)(struct eeh_pe *pe, int *state); 142 int (*get_state)(struct eeh_pe *pe, int *state);
@@ -141,11 +146,12 @@ struct eeh_ops {
141 int (*configure_bridge)(struct eeh_pe *pe); 146 int (*configure_bridge)(struct eeh_pe *pe);
142 int (*read_config)(struct device_node *dn, int where, int size, u32 *val); 147 int (*read_config)(struct device_node *dn, int where, int size, u32 *val);
143 int (*write_config)(struct device_node *dn, int where, int size, u32 val); 148 int (*write_config)(struct device_node *dn, int where, int size, u32 val);
149 int (*next_error)(struct eeh_pe **pe);
144}; 150};
145 151
146extern struct eeh_ops *eeh_ops; 152extern struct eeh_ops *eeh_ops;
147extern int eeh_subsystem_enabled; 153extern int eeh_subsystem_enabled;
148extern struct mutex eeh_mutex; 154extern raw_spinlock_t confirm_error_lock;
149extern int eeh_probe_mode; 155extern int eeh_probe_mode;
150 156
151#define EEH_PROBE_MODE_DEV (1<<0) /* From PCI device */ 157#define EEH_PROBE_MODE_DEV (1<<0) /* From PCI device */
@@ -166,14 +172,14 @@ static inline int eeh_probe_mode_dev(void)
166 return (eeh_probe_mode == EEH_PROBE_MODE_DEV); 172 return (eeh_probe_mode == EEH_PROBE_MODE_DEV);
167} 173}
168 174
169static inline void eeh_lock(void) 175static inline void eeh_serialize_lock(unsigned long *flags)
170{ 176{
171 mutex_lock(&eeh_mutex); 177 raw_spin_lock_irqsave(&confirm_error_lock, *flags);
172} 178}
173 179
174static inline void eeh_unlock(void) 180static inline void eeh_serialize_unlock(unsigned long flags)
175{ 181{
176 mutex_unlock(&eeh_mutex); 182 raw_spin_unlock_irqrestore(&confirm_error_lock, flags);
177} 183}
178 184
179/* 185/*
@@ -184,8 +190,11 @@ static inline void eeh_unlock(void)
184 190
185typedef void *(*eeh_traverse_func)(void *data, void *flag); 191typedef void *(*eeh_traverse_func)(void *data, void *flag);
186int eeh_phb_pe_create(struct pci_controller *phb); 192int eeh_phb_pe_create(struct pci_controller *phb);
193struct eeh_pe *eeh_phb_pe_get(struct pci_controller *phb);
194struct eeh_pe *eeh_pe_get(struct eeh_dev *edev);
187int eeh_add_to_parent_pe(struct eeh_dev *edev); 195int eeh_add_to_parent_pe(struct eeh_dev *edev);
188int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe); 196int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe);
197void eeh_pe_update_time_stamp(struct eeh_pe *pe);
189void *eeh_pe_dev_traverse(struct eeh_pe *root, 198void *eeh_pe_dev_traverse(struct eeh_pe *root,
190 eeh_traverse_func fn, void *flag); 199 eeh_traverse_func fn, void *flag);
191void eeh_pe_restore_bars(struct eeh_pe *pe); 200void eeh_pe_restore_bars(struct eeh_pe *pe);
@@ -193,12 +202,13 @@ struct pci_bus *eeh_pe_bus_get(struct eeh_pe *pe);
193 202
194void *eeh_dev_init(struct device_node *dn, void *data); 203void *eeh_dev_init(struct device_node *dn, void *data);
195void eeh_dev_phb_init_dynamic(struct pci_controller *phb); 204void eeh_dev_phb_init_dynamic(struct pci_controller *phb);
205int eeh_init(void);
196int __init eeh_ops_register(struct eeh_ops *ops); 206int __init eeh_ops_register(struct eeh_ops *ops);
197int __exit eeh_ops_unregister(const char *name); 207int __exit eeh_ops_unregister(const char *name);
198unsigned long eeh_check_failure(const volatile void __iomem *token, 208unsigned long eeh_check_failure(const volatile void __iomem *token,
199 unsigned long val); 209 unsigned long val);
200int eeh_dev_check_failure(struct eeh_dev *edev); 210int eeh_dev_check_failure(struct eeh_dev *edev);
201void __init eeh_addr_cache_build(void); 211void eeh_addr_cache_build(void);
202void eeh_add_device_tree_early(struct device_node *); 212void eeh_add_device_tree_early(struct device_node *);
203void eeh_add_device_tree_late(struct pci_bus *); 213void eeh_add_device_tree_late(struct pci_bus *);
204void eeh_add_sysfs_files(struct pci_bus *); 214void eeh_add_sysfs_files(struct pci_bus *);
@@ -221,6 +231,11 @@ void eeh_remove_bus_device(struct pci_dev *, int);
221 231
222#else /* !CONFIG_EEH */ 232#else /* !CONFIG_EEH */
223 233
234static inline int eeh_init(void)
235{
236 return 0;
237}
238
224static inline void *eeh_dev_init(struct device_node *dn, void *data) 239static inline void *eeh_dev_init(struct device_node *dn, void *data)
225{ 240{
226 return NULL; 241 return NULL;
@@ -245,9 +260,6 @@ static inline void eeh_add_sysfs_files(struct pci_bus *bus) { }
245 260
246static inline void eeh_remove_bus_device(struct pci_dev *dev, int purge_pe) { } 261static inline void eeh_remove_bus_device(struct pci_dev *dev, int purge_pe) { }
247 262
248static inline void eeh_lock(void) { }
249static inline void eeh_unlock(void) { }
250
251#define EEH_POSSIBLE_ERROR(val, type) (0) 263#define EEH_POSSIBLE_ERROR(val, type) (0)
252#define EEH_IO_ERROR_VALUE(size) (-1UL) 264#define EEH_IO_ERROR_VALUE(size) (-1UL)
253#endif /* CONFIG_EEH */ 265#endif /* CONFIG_EEH */
diff --git a/arch/powerpc/include/asm/eeh_event.h b/arch/powerpc/include/asm/eeh_event.h
index de67d830151b..89d5670b2eeb 100644
--- a/arch/powerpc/include/asm/eeh_event.h
+++ b/arch/powerpc/include/asm/eeh_event.h
@@ -31,7 +31,9 @@ struct eeh_event {
31 struct eeh_pe *pe; /* EEH PE */ 31 struct eeh_pe *pe; /* EEH PE */
32}; 32};
33 33
34int eeh_event_init(void);
34int eeh_send_failure_event(struct eeh_pe *pe); 35int eeh_send_failure_event(struct eeh_pe *pe);
36void eeh_remove_event(struct eeh_pe *pe);
35void eeh_handle_event(struct eeh_pe *pe); 37void eeh_handle_event(struct eeh_pe *pe);
36 38
37#endif /* __KERNEL__ */ 39#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index 46793b58a761..07ca627e52c0 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -358,12 +358,12 @@ label##_relon_pSeries: \
358 /* No guest interrupts come through here */ \ 358 /* No guest interrupts come through here */ \
359 SET_SCRATCH0(r13); /* save r13 */ \ 359 SET_SCRATCH0(r13); /* save r13 */ \
360 EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label##_common, \ 360 EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label##_common, \
361 EXC_STD, KVMTEST_PR, vec) 361 EXC_STD, NOTEST, vec)
362 362
363#define STD_RELON_EXCEPTION_PSERIES_OOL(vec, label) \ 363#define STD_RELON_EXCEPTION_PSERIES_OOL(vec, label) \
364 .globl label##_relon_pSeries; \ 364 .globl label##_relon_pSeries; \
365label##_relon_pSeries: \ 365label##_relon_pSeries: \
366 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST_PR, vec); \ 366 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, vec); \
367 EXCEPTION_RELON_PROLOG_PSERIES_1(label##_common, EXC_STD) 367 EXCEPTION_RELON_PROLOG_PSERIES_1(label##_common, EXC_STD)
368 368
369#define STD_RELON_EXCEPTION_HV(loc, vec, label) \ 369#define STD_RELON_EXCEPTION_HV(loc, vec, label) \
@@ -374,12 +374,12 @@ label##_relon_hv: \
374 /* No guest interrupts come through here */ \ 374 /* No guest interrupts come through here */ \
375 SET_SCRATCH0(r13); /* save r13 */ \ 375 SET_SCRATCH0(r13); /* save r13 */ \
376 EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label##_common, \ 376 EXCEPTION_RELON_PROLOG_PSERIES(PACA_EXGEN, label##_common, \
377 EXC_HV, KVMTEST, vec) 377 EXC_HV, NOTEST, vec)
378 378
379#define STD_RELON_EXCEPTION_HV_OOL(vec, label) \ 379#define STD_RELON_EXCEPTION_HV_OOL(vec, label) \
380 .globl label##_relon_hv; \ 380 .globl label##_relon_hv; \
381label##_relon_hv: \ 381label##_relon_hv: \
382 EXCEPTION_PROLOG_1(PACA_EXGEN, KVMTEST, vec); \ 382 EXCEPTION_PROLOG_1(PACA_EXGEN, NOTEST, vec); \
383 EXCEPTION_RELON_PROLOG_PSERIES_1(label##_common, EXC_HV) 383 EXCEPTION_RELON_PROLOG_PSERIES_1(label##_common, EXC_HV)
384 384
385/* This associate vector numbers with bits in paca->irq_happened */ 385/* This associate vector numbers with bits in paca->irq_happened */
diff --git a/arch/powerpc/include/asm/hugetlb.h b/arch/powerpc/include/asm/hugetlb.h
index f2498c8e595d..d750336b171d 100644
--- a/arch/powerpc/include/asm/hugetlb.h
+++ b/arch/powerpc/include/asm/hugetlb.h
@@ -191,8 +191,14 @@ static inline void flush_hugetlb_page(struct vm_area_struct *vma,
191 unsigned long vmaddr) 191 unsigned long vmaddr)
192{ 192{
193} 193}
194#endif /* CONFIG_HUGETLB_PAGE */
195 194
195#define hugepd_shift(x) 0
196static inline pte_t *hugepte_offset(hugepd_t *hpdp, unsigned long addr,
197 unsigned pdshift)
198{
199 return 0;
200}
201#endif /* CONFIG_HUGETLB_PAGE */
196 202
197/* 203/*
198 * FSL Book3E platforms require special gpage handling - the gpages 204 * FSL Book3E platforms require special gpage handling - the gpages
diff --git a/arch/powerpc/include/asm/iommu.h b/arch/powerpc/include/asm/iommu.h
index cbfe678e3dbe..c34656a8925e 100644
--- a/arch/powerpc/include/asm/iommu.h
+++ b/arch/powerpc/include/asm/iommu.h
@@ -76,6 +76,9 @@ struct iommu_table {
76 struct iommu_pool large_pool; 76 struct iommu_pool large_pool;
77 struct iommu_pool pools[IOMMU_NR_POOLS]; 77 struct iommu_pool pools[IOMMU_NR_POOLS];
78 unsigned long *it_map; /* A simple allocation bitmap for now */ 78 unsigned long *it_map; /* A simple allocation bitmap for now */
79#ifdef CONFIG_IOMMU_API
80 struct iommu_group *it_group;
81#endif
79}; 82};
80 83
81struct scatterlist; 84struct scatterlist;
@@ -98,6 +101,8 @@ extern void iommu_free_table(struct iommu_table *tbl, const char *node_name);
98 */ 101 */
99extern struct iommu_table *iommu_init_table(struct iommu_table * tbl, 102extern struct iommu_table *iommu_init_table(struct iommu_table * tbl,
100 int nid); 103 int nid);
104extern void iommu_register_group(struct iommu_table *tbl,
105 int pci_domain_number, unsigned long pe_num);
101 106
102extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl, 107extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
103 struct scatterlist *sglist, int nelems, 108 struct scatterlist *sglist, int nelems,
@@ -125,13 +130,6 @@ extern void iommu_init_early_pSeries(void);
125extern void iommu_init_early_dart(void); 130extern void iommu_init_early_dart(void);
126extern void iommu_init_early_pasemi(void); 131extern void iommu_init_early_pasemi(void);
127 132
128#ifdef CONFIG_PCI
129extern void pci_iommu_init(void);
130extern void pci_direct_iommu_init(void);
131#else
132static inline void pci_iommu_init(void) { }
133#endif
134
135extern void alloc_dart_table(void); 133extern void alloc_dart_table(void);
136#if defined(CONFIG_PPC64) && defined(CONFIG_PM) 134#if defined(CONFIG_PPC64) && defined(CONFIG_PM)
137static inline void iommu_save(void) 135static inline void iommu_save(void)
@@ -147,5 +145,26 @@ static inline void iommu_restore(void)
147} 145}
148#endif 146#endif
149 147
148/* The API to support IOMMU operations for VFIO */
149extern int iommu_tce_clear_param_check(struct iommu_table *tbl,
150 unsigned long ioba, unsigned long tce_value,
151 unsigned long npages);
152extern int iommu_tce_put_param_check(struct iommu_table *tbl,
153 unsigned long ioba, unsigned long tce);
154extern int iommu_tce_build(struct iommu_table *tbl, unsigned long entry,
155 unsigned long hwaddr, enum dma_data_direction direction);
156extern unsigned long iommu_clear_tce(struct iommu_table *tbl,
157 unsigned long entry);
158extern int iommu_clear_tces_and_put_pages(struct iommu_table *tbl,
159 unsigned long entry, unsigned long pages);
160extern int iommu_put_tce_user_mode(struct iommu_table *tbl,
161 unsigned long entry, unsigned long tce);
162
163extern void iommu_flush_tce(struct iommu_table *tbl);
164extern int iommu_take_ownership(struct iommu_table *tbl);
165extern void iommu_release_ownership(struct iommu_table *tbl);
166
167extern enum dma_data_direction iommu_tce_direction(unsigned long tce);
168
150#endif /* __KERNEL__ */ 169#endif /* __KERNEL__ */
151#endif /* _ASM_IOMMU_H */ 170#endif /* _ASM_IOMMU_H */
diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h
index 9c1ff330c805..a1ecb14e4442 100644
--- a/arch/powerpc/include/asm/kvm_book3s_64.h
+++ b/arch/powerpc/include/asm/kvm_book3s_64.h
@@ -159,36 +159,46 @@ static inline int hpte_cache_flags_ok(unsigned long ptel, unsigned long io_type)
159} 159}
160 160
161/* 161/*
162 * Lock and read a linux PTE. If it's present and writable, atomically 162 * If it's present and writable, atomically set dirty and referenced bits and
163 * set dirty and referenced bits and return the PTE, otherwise return 0. 163 * return the PTE, otherwise return 0. If we find a transparent hugepage
164 * and if it is marked splitting we return 0;
164 */ 165 */
165static inline pte_t kvmppc_read_update_linux_pte(pte_t *p, int writing) 166static inline pte_t kvmppc_read_update_linux_pte(pte_t *ptep, int writing,
167 unsigned int hugepage)
166{ 168{
167 pte_t pte, tmp; 169 pte_t old_pte, new_pte = __pte(0);
168 170
169 /* wait until _PAGE_BUSY is clear then set it atomically */ 171 while (1) {
170 __asm__ __volatile__ ( 172 old_pte = pte_val(*ptep);
171 "1: ldarx %0,0,%3\n" 173 /*
172 " andi. %1,%0,%4\n" 174 * wait until _PAGE_BUSY is clear then set it atomically
173 " bne- 1b\n" 175 */
174 " ori %1,%0,%4\n" 176 if (unlikely(old_pte & _PAGE_BUSY)) {
175 " stdcx. %1,0,%3\n" 177 cpu_relax();
176 " bne- 1b" 178 continue;
177 : "=&r" (pte), "=&r" (tmp), "=m" (*p) 179 }
178 : "r" (p), "i" (_PAGE_BUSY) 180#ifdef CONFIG_TRANSPARENT_HUGEPAGE
179 : "cc"); 181 /* If hugepage and is trans splitting return None */
180 182 if (unlikely(hugepage &&
181 if (pte_present(pte)) { 183 pmd_trans_splitting(pte_pmd(old_pte))))
182 pte = pte_mkyoung(pte); 184 return __pte(0);
183 if (writing && pte_write(pte)) 185#endif
184 pte = pte_mkdirty(pte); 186 /* If pte is not present return None */
185 } 187 if (unlikely(!(old_pte & _PAGE_PRESENT)))
188 return __pte(0);
186 189
187 *p = pte; /* clears _PAGE_BUSY */ 190 new_pte = pte_mkyoung(old_pte);
191 if (writing && pte_write(old_pte))
192 new_pte = pte_mkdirty(new_pte);
188 193
189 return pte; 194 if (old_pte == __cmpxchg_u64((unsigned long *)ptep, old_pte,
195 new_pte))
196 break;
197 }
198 return new_pte;
190} 199}
191 200
201
192/* Return HPTE cache control bits corresponding to Linux pte bits */ 202/* Return HPTE cache control bits corresponding to Linux pte bits */
193static inline unsigned long hpte_cache_bits(unsigned long pte_val) 203static inline unsigned long hpte_cache_bits(unsigned long pte_val)
194{ 204{
diff --git a/arch/powerpc/include/asm/lppaca.h b/arch/powerpc/include/asm/lppaca.h
index b1e7f2af1016..9b12f88d4adb 100644
--- a/arch/powerpc/include/asm/lppaca.h
+++ b/arch/powerpc/include/asm/lppaca.h
@@ -66,7 +66,8 @@ struct lppaca {
66 66
67 u8 reserved6[48]; 67 u8 reserved6[48];
68 u8 cede_latency_hint; 68 u8 cede_latency_hint;
69 u8 reserved7[7]; 69 u8 ebb_regs_in_use;
70 u8 reserved7[6];
70 u8 dtl_enable_mask; /* Dispatch Trace Log mask */ 71 u8 dtl_enable_mask; /* Dispatch Trace Log mask */
71 u8 donate_dedicated_cpu; /* Donate dedicated CPU cycles */ 72 u8 donate_dedicated_cpu; /* Donate dedicated CPU cycles */
72 u8 fpregs_in_use; 73 u8 fpregs_in_use;
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 92386fc4e82a..8b480901165a 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -36,13 +36,13 @@ struct machdep_calls {
36#ifdef CONFIG_PPC64 36#ifdef CONFIG_PPC64
37 void (*hpte_invalidate)(unsigned long slot, 37 void (*hpte_invalidate)(unsigned long slot,
38 unsigned long vpn, 38 unsigned long vpn,
39 int psize, int ssize, 39 int bpsize, int apsize,
40 int local); 40 int ssize, int local);
41 long (*hpte_updatepp)(unsigned long slot, 41 long (*hpte_updatepp)(unsigned long slot,
42 unsigned long newpp, 42 unsigned long newpp,
43 unsigned long vpn, 43 unsigned long vpn,
44 int psize, int ssize, 44 int bpsize, int apsize,
45 int local); 45 int ssize, int local);
46 void (*hpte_updateboltedpp)(unsigned long newpp, 46 void (*hpte_updateboltedpp)(unsigned long newpp,
47 unsigned long ea, 47 unsigned long ea,
48 int psize, int ssize); 48 int psize, int ssize);
@@ -57,6 +57,9 @@ struct machdep_calls {
57 void (*hpte_removebolted)(unsigned long ea, 57 void (*hpte_removebolted)(unsigned long ea,
58 int psize, int ssize); 58 int psize, int ssize);
59 void (*flush_hash_range)(unsigned long number, int local); 59 void (*flush_hash_range)(unsigned long number, int local);
60 void (*hugepage_invalidate)(struct mm_struct *mm,
61 unsigned char *hpte_slot_array,
62 unsigned long addr, int psize);
60 63
61 /* special for kexec, to be called in real mode, linear mapping is 64 /* special for kexec, to be called in real mode, linear mapping is
62 * destroyed as well */ 65 * destroyed as well */
diff --git a/arch/powerpc/include/asm/mmu-hash64.h b/arch/powerpc/include/asm/mmu-hash64.h
index 2accc9611248..c4cf01197273 100644
--- a/arch/powerpc/include/asm/mmu-hash64.h
+++ b/arch/powerpc/include/asm/mmu-hash64.h
@@ -340,6 +340,20 @@ extern int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
340int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, 340int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid,
341 pte_t *ptep, unsigned long trap, int local, int ssize, 341 pte_t *ptep, unsigned long trap, int local, int ssize,
342 unsigned int shift, unsigned int mmu_psize); 342 unsigned int shift, unsigned int mmu_psize);
343#ifdef CONFIG_TRANSPARENT_HUGEPAGE
344extern int __hash_page_thp(unsigned long ea, unsigned long access,
345 unsigned long vsid, pmd_t *pmdp, unsigned long trap,
346 int local, int ssize, unsigned int psize);
347#else
348static inline int __hash_page_thp(unsigned long ea, unsigned long access,
349 unsigned long vsid, pmd_t *pmdp,
350 unsigned long trap, int local,
351 int ssize, unsigned int psize)
352{
353 BUG();
354 return -1;
355}
356#endif
343extern void hash_failure_debug(unsigned long ea, unsigned long access, 357extern void hash_failure_debug(unsigned long ea, unsigned long access,
344 unsigned long vsid, unsigned long trap, 358 unsigned long vsid, unsigned long trap,
345 int ssize, int psize, int lpsize, 359 int ssize, int psize, int lpsize,
diff --git a/arch/powerpc/include/asm/mpc5121.h b/arch/powerpc/include/asm/mpc5121.h
index 885c040d6194..8ae133eaf9fa 100644
--- a/arch/powerpc/include/asm/mpc5121.h
+++ b/arch/powerpc/include/asm/mpc5121.h
@@ -68,6 +68,5 @@ struct mpc512x_lpc {
68}; 68};
69 69
70int mpc512x_cs_config(unsigned int cs, u32 val); 70int mpc512x_cs_config(unsigned int cs, u32 val);
71int __init mpc5121_clk_init(void);
72 71
73#endif /* __ASM_POWERPC_MPC5121_H__ */ 72#endif /* __ASM_POWERPC_MPC5121_H__ */
diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index c0f9ef90f0b8..4a1ac9fbf186 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -339,6 +339,8 @@ struct mpic
339#endif 339#endif
340}; 340};
341 341
342extern struct bus_type mpic_subsys;
343
342/* 344/*
343 * MPIC flags (passed to mpic_alloc) 345 * MPIC flags (passed to mpic_alloc)
344 * 346 *
@@ -393,6 +395,9 @@ struct mpic
393#define MPIC_REGSET_STANDARD MPIC_REGSET(0) /* Original MPIC */ 395#define MPIC_REGSET_STANDARD MPIC_REGSET(0) /* Original MPIC */
394#define MPIC_REGSET_TSI108 MPIC_REGSET(1) /* Tsi108/109 PIC */ 396#define MPIC_REGSET_TSI108 MPIC_REGSET(1) /* Tsi108/109 PIC */
395 397
398/* Get the version of primary MPIC */
399extern u32 fsl_mpic_primary_get_version(void);
400
396/* Allocate the controller structure and setup the linux irq descs 401/* Allocate the controller structure and setup the linux irq descs
397 * for the range if interrupts passed in. No HW initialization is 402 * for the range if interrupts passed in. No HW initialization is
398 * actually performed. 403 * actually performed.
diff --git a/arch/powerpc/include/asm/mpic_timer.h b/arch/powerpc/include/asm/mpic_timer.h
new file mode 100644
index 000000000000..0e23cd4ac8aa
--- /dev/null
+++ b/arch/powerpc/include/asm/mpic_timer.h
@@ -0,0 +1,46 @@
1/*
2 * arch/powerpc/include/asm/mpic_timer.h
3 *
4 * Header file for Mpic Global Timer
5 *
6 * Copyright 2013 Freescale Semiconductor, Inc.
7 *
8 * Author: Wang Dongsheng <Dongsheng.Wang@freescale.com>
9 * Li Yang <leoli@freescale.com>
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 */
16
17#ifndef __MPIC_TIMER__
18#define __MPIC_TIMER__
19
20#include <linux/interrupt.h>
21#include <linux/time.h>
22
23struct mpic_timer {
24 void *dev;
25 struct cascade_priv *cascade_handle;
26 unsigned int num;
27 unsigned int irq;
28};
29
30#ifdef CONFIG_MPIC_TIMER
31struct mpic_timer *mpic_request_timer(irq_handler_t fn, void *dev,
32 const struct timeval *time);
33void mpic_start_timer(struct mpic_timer *handle);
34void mpic_stop_timer(struct mpic_timer *handle);
35void mpic_get_remain_time(struct mpic_timer *handle, struct timeval *time);
36void mpic_free_timer(struct mpic_timer *handle);
37#else
38struct mpic_timer *mpic_request_timer(irq_handler_t fn, void *dev,
39 const struct timeval *time) { return NULL; }
40void mpic_start_timer(struct mpic_timer *handle) { }
41void mpic_stop_timer(struct mpic_timer *handle) { }
42void mpic_get_remain_time(struct mpic_timer *handle, struct timeval *time) { }
43void mpic_free_timer(struct mpic_timer *handle) { }
44#endif
45
46#endif
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index cbb9305ab15a..029fe85722aa 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -117,7 +117,13 @@ extern int opal_enter_rtas(struct rtas_args *args,
117#define OPAL_SET_SLOT_LED_STATUS 55 117#define OPAL_SET_SLOT_LED_STATUS 55
118#define OPAL_GET_EPOW_STATUS 56 118#define OPAL_GET_EPOW_STATUS 56
119#define OPAL_SET_SYSTEM_ATTENTION_LED 57 119#define OPAL_SET_SYSTEM_ATTENTION_LED 57
120#define OPAL_RESERVED1 58
121#define OPAL_RESERVED2 59
122#define OPAL_PCI_NEXT_ERROR 60
123#define OPAL_PCI_EEH_FREEZE_STATUS2 61
124#define OPAL_PCI_POLL 62
120#define OPAL_PCI_MSI_EOI 63 125#define OPAL_PCI_MSI_EOI 63
126#define OPAL_PCI_GET_PHB_DIAG_DATA2 64
121 127
122#ifndef __ASSEMBLY__ 128#ifndef __ASSEMBLY__
123 129
@@ -125,6 +131,7 @@ extern int opal_enter_rtas(struct rtas_args *args,
125enum OpalVendorApiTokens { 131enum OpalVendorApiTokens {
126 OPAL_START_VENDOR_API_RANGE = 1000, OPAL_END_VENDOR_API_RANGE = 1999 132 OPAL_START_VENDOR_API_RANGE = 1000, OPAL_END_VENDOR_API_RANGE = 1999
127}; 133};
134
128enum OpalFreezeState { 135enum OpalFreezeState {
129 OPAL_EEH_STOPPED_NOT_FROZEN = 0, 136 OPAL_EEH_STOPPED_NOT_FROZEN = 0,
130 OPAL_EEH_STOPPED_MMIO_FREEZE = 1, 137 OPAL_EEH_STOPPED_MMIO_FREEZE = 1,
@@ -134,55 +141,69 @@ enum OpalFreezeState {
134 OPAL_EEH_STOPPED_TEMP_UNAVAIL = 5, 141 OPAL_EEH_STOPPED_TEMP_UNAVAIL = 5,
135 OPAL_EEH_STOPPED_PERM_UNAVAIL = 6 142 OPAL_EEH_STOPPED_PERM_UNAVAIL = 6
136}; 143};
144
137enum OpalEehFreezeActionToken { 145enum OpalEehFreezeActionToken {
138 OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO = 1, 146 OPAL_EEH_ACTION_CLEAR_FREEZE_MMIO = 1,
139 OPAL_EEH_ACTION_CLEAR_FREEZE_DMA = 2, 147 OPAL_EEH_ACTION_CLEAR_FREEZE_DMA = 2,
140 OPAL_EEH_ACTION_CLEAR_FREEZE_ALL = 3 148 OPAL_EEH_ACTION_CLEAR_FREEZE_ALL = 3
141}; 149};
150
142enum OpalPciStatusToken { 151enum OpalPciStatusToken {
143 OPAL_EEH_PHB_NO_ERROR = 0, 152 OPAL_EEH_NO_ERROR = 0,
144 OPAL_EEH_PHB_FATAL = 1, 153 OPAL_EEH_IOC_ERROR = 1,
145 OPAL_EEH_PHB_RECOVERABLE = 2, 154 OPAL_EEH_PHB_ERROR = 2,
146 OPAL_EEH_PHB_BUS_ERROR = 3, 155 OPAL_EEH_PE_ERROR = 3,
147 OPAL_EEH_PCI_NO_DEVSEL = 4, 156 OPAL_EEH_PE_MMIO_ERROR = 4,
148 OPAL_EEH_PCI_TA = 5, 157 OPAL_EEH_PE_DMA_ERROR = 5
149 OPAL_EEH_PCIEX_UR = 6,
150 OPAL_EEH_PCIEX_CA = 7,
151 OPAL_EEH_PCI_MMIO_ERROR = 8,
152 OPAL_EEH_PCI_DMA_ERROR = 9
153}; 158};
159
160enum OpalPciErrorSeverity {
161 OPAL_EEH_SEV_NO_ERROR = 0,
162 OPAL_EEH_SEV_IOC_DEAD = 1,
163 OPAL_EEH_SEV_PHB_DEAD = 2,
164 OPAL_EEH_SEV_PHB_FENCED = 3,
165 OPAL_EEH_SEV_PE_ER = 4,
166 OPAL_EEH_SEV_INF = 5
167};
168
154enum OpalShpcAction { 169enum OpalShpcAction {
155 OPAL_SHPC_GET_LINK_STATE = 0, 170 OPAL_SHPC_GET_LINK_STATE = 0,
156 OPAL_SHPC_GET_SLOT_STATE = 1 171 OPAL_SHPC_GET_SLOT_STATE = 1
157}; 172};
173
158enum OpalShpcLinkState { 174enum OpalShpcLinkState {
159 OPAL_SHPC_LINK_DOWN = 0, 175 OPAL_SHPC_LINK_DOWN = 0,
160 OPAL_SHPC_LINK_UP = 1 176 OPAL_SHPC_LINK_UP = 1
161}; 177};
178
162enum OpalMmioWindowType { 179enum OpalMmioWindowType {
163 OPAL_M32_WINDOW_TYPE = 1, 180 OPAL_M32_WINDOW_TYPE = 1,
164 OPAL_M64_WINDOW_TYPE = 2, 181 OPAL_M64_WINDOW_TYPE = 2,
165 OPAL_IO_WINDOW_TYPE = 3 182 OPAL_IO_WINDOW_TYPE = 3
166}; 183};
184
167enum OpalShpcSlotState { 185enum OpalShpcSlotState {
168 OPAL_SHPC_DEV_NOT_PRESENT = 0, 186 OPAL_SHPC_DEV_NOT_PRESENT = 0,
169 OPAL_SHPC_DEV_PRESENT = 1 187 OPAL_SHPC_DEV_PRESENT = 1
170}; 188};
189
171enum OpalExceptionHandler { 190enum OpalExceptionHandler {
172 OPAL_MACHINE_CHECK_HANDLER = 1, 191 OPAL_MACHINE_CHECK_HANDLER = 1,
173 OPAL_HYPERVISOR_MAINTENANCE_HANDLER = 2, 192 OPAL_HYPERVISOR_MAINTENANCE_HANDLER = 2,
174 OPAL_SOFTPATCH_HANDLER = 3 193 OPAL_SOFTPATCH_HANDLER = 3
175}; 194};
195
176enum OpalPendingState { 196enum OpalPendingState {
177 OPAL_EVENT_OPAL_INTERNAL = 0x1, 197 OPAL_EVENT_OPAL_INTERNAL = 0x1,
178 OPAL_EVENT_NVRAM = 0x2, 198 OPAL_EVENT_NVRAM = 0x2,
179 OPAL_EVENT_RTC = 0x4, 199 OPAL_EVENT_RTC = 0x4,
180 OPAL_EVENT_CONSOLE_OUTPUT = 0x8, 200 OPAL_EVENT_CONSOLE_OUTPUT = 0x8,
181 OPAL_EVENT_CONSOLE_INPUT = 0x10, 201 OPAL_EVENT_CONSOLE_INPUT = 0x10,
182 OPAL_EVENT_ERROR_LOG_AVAIL = 0x20, 202 OPAL_EVENT_ERROR_LOG_AVAIL = 0x20,
183 OPAL_EVENT_ERROR_LOG = 0x40, 203 OPAL_EVENT_ERROR_LOG = 0x40,
184 OPAL_EVENT_EPOW = 0x80, 204 OPAL_EVENT_EPOW = 0x80,
185 OPAL_EVENT_LED_STATUS = 0x100 205 OPAL_EVENT_LED_STATUS = 0x100,
206 OPAL_EVENT_PCI_ERROR = 0x200
186}; 207};
187 208
188/* Machine check related definitions */ 209/* Machine check related definitions */
@@ -364,15 +385,80 @@ struct opal_machine_check_event {
364 } u; 385 } u;
365}; 386};
366 387
388enum {
389 OPAL_P7IOC_DIAG_TYPE_NONE = 0,
390 OPAL_P7IOC_DIAG_TYPE_RGC = 1,
391 OPAL_P7IOC_DIAG_TYPE_BI = 2,
392 OPAL_P7IOC_DIAG_TYPE_CI = 3,
393 OPAL_P7IOC_DIAG_TYPE_MISC = 4,
394 OPAL_P7IOC_DIAG_TYPE_I2C = 5,
395 OPAL_P7IOC_DIAG_TYPE_LAST = 6
396};
397
398struct OpalIoP7IOCErrorData {
399 uint16_t type;
400
401 /* GEM */
402 uint64_t gemXfir;
403 uint64_t gemRfir;
404 uint64_t gemRirqfir;
405 uint64_t gemMask;
406 uint64_t gemRwof;
407
408 /* LEM */
409 uint64_t lemFir;
410 uint64_t lemErrMask;
411 uint64_t lemAction0;
412 uint64_t lemAction1;
413 uint64_t lemWof;
414
415 union {
416 struct OpalIoP7IOCRgcErrorData {
417 uint64_t rgcStatus; /* 3E1C10 */
418 uint64_t rgcLdcp; /* 3E1C18 */
419 }rgc;
420 struct OpalIoP7IOCBiErrorData {
421 uint64_t biLdcp0; /* 3C0100, 3C0118 */
422 uint64_t biLdcp1; /* 3C0108, 3C0120 */
423 uint64_t biLdcp2; /* 3C0110, 3C0128 */
424 uint64_t biFenceStatus; /* 3C0130, 3C0130 */
425
426 uint8_t biDownbound; /* BI Downbound or Upbound */
427 }bi;
428 struct OpalIoP7IOCCiErrorData {
429 uint64_t ciPortStatus; /* 3Dn008 */
430 uint64_t ciPortLdcp; /* 3Dn010 */
431
432 uint8_t ciPort; /* Index of CI port: 0/1 */
433 }ci;
434 };
435};
436
367/** 437/**
368 * This structure defines the overlay which will be used to store PHB error 438 * This structure defines the overlay which will be used to store PHB error
369 * data upon request. 439 * data upon request.
370 */ 440 */
371enum { 441enum {
442 OPAL_PHB_ERROR_DATA_VERSION_1 = 1,
443};
444
445enum {
446 OPAL_PHB_ERROR_DATA_TYPE_P7IOC = 1,
447};
448
449enum {
372 OPAL_P7IOC_NUM_PEST_REGS = 128, 450 OPAL_P7IOC_NUM_PEST_REGS = 128,
373}; 451};
374 452
453struct OpalIoPhbErrorCommon {
454 uint32_t version;
455 uint32_t ioType;
456 uint32_t len;
457};
458
375struct OpalIoP7IOCPhbErrorData { 459struct OpalIoP7IOCPhbErrorData {
460 struct OpalIoPhbErrorCommon common;
461
376 uint32_t brdgCtl; 462 uint32_t brdgCtl;
377 463
378 // P7IOC utl regs 464 // P7IOC utl regs
@@ -530,14 +616,21 @@ int64_t opal_pci_map_pe_dma_window_real(uint64_t phb_id, uint16_t pe_number,
530 uint64_t pci_mem_size); 616 uint64_t pci_mem_size);
531int64_t opal_pci_reset(uint64_t phb_id, uint8_t reset_scope, uint8_t assert_state); 617int64_t opal_pci_reset(uint64_t phb_id, uint8_t reset_scope, uint8_t assert_state);
532 618
533int64_t opal_pci_get_hub_diag_data(uint64_t hub_id, void *diag_buffer, uint64_t diag_buffer_len); 619int64_t opal_pci_get_hub_diag_data(uint64_t hub_id, void *diag_buffer,
534int64_t opal_pci_get_phb_diag_data(uint64_t phb_id, void *diag_buffer, uint64_t diag_buffer_len); 620 uint64_t diag_buffer_len);
621int64_t opal_pci_get_phb_diag_data(uint64_t phb_id, void *diag_buffer,
622 uint64_t diag_buffer_len);
623int64_t opal_pci_get_phb_diag_data2(uint64_t phb_id, void *diag_buffer,
624 uint64_t diag_buffer_len);
535int64_t opal_pci_fence_phb(uint64_t phb_id); 625int64_t opal_pci_fence_phb(uint64_t phb_id);
536int64_t opal_pci_reinit(uint64_t phb_id, uint8_t reinit_scope); 626int64_t opal_pci_reinit(uint64_t phb_id, uint8_t reinit_scope);
537int64_t opal_pci_mask_pe_error(uint64_t phb_id, uint16_t pe_number, uint8_t error_type, uint8_t mask_action); 627int64_t opal_pci_mask_pe_error(uint64_t phb_id, uint16_t pe_number, uint8_t error_type, uint8_t mask_action);
538int64_t opal_set_slot_led_status(uint64_t phb_id, uint64_t slot_id, uint8_t led_type, uint8_t led_action); 628int64_t opal_set_slot_led_status(uint64_t phb_id, uint64_t slot_id, uint8_t led_type, uint8_t led_action);
539int64_t opal_get_epow_status(uint64_t *status); 629int64_t opal_get_epow_status(uint64_t *status);
540int64_t opal_set_system_attention_led(uint8_t led_action); 630int64_t opal_set_system_attention_led(uint8_t led_action);
631int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe,
632 uint16_t *pci_error_type, uint16_t *severity);
633int64_t opal_pci_poll(uint64_t phb_id);
541 634
542/* Internal functions */ 635/* Internal functions */
543extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data); 636extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data);
@@ -551,6 +644,11 @@ extern void hvc_opal_init_early(void);
551extern int early_init_dt_scan_opal(unsigned long node, const char *uname, 644extern int early_init_dt_scan_opal(unsigned long node, const char *uname,
552 int depth, void *data); 645 int depth, void *data);
553 646
647extern int opal_notifier_register(struct notifier_block *nb);
648extern void opal_notifier_enable(void);
649extern void opal_notifier_disable(void);
650extern void opal_notifier_update_evt(uint64_t evt_mask, uint64_t evt_val);
651
554extern int opal_get_chars(uint32_t vtermno, char *buf, int count); 652extern int opal_get_chars(uint32_t vtermno, char *buf, int count);
555extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len); 653extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len);
556 654
diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h
index f265049dd7d6..2dd7bfc459be 100644
--- a/arch/powerpc/include/asm/perf_event_server.h
+++ b/arch/powerpc/include/asm/perf_event_server.h
@@ -60,6 +60,7 @@ struct power_pmu {
60#define PPMU_HAS_SSLOT 0x00000020 /* Has sampled slot in MMCRA */ 60#define PPMU_HAS_SSLOT 0x00000020 /* Has sampled slot in MMCRA */
61#define PPMU_HAS_SIER 0x00000040 /* Has SIER */ 61#define PPMU_HAS_SIER 0x00000040 /* Has SIER */
62#define PPMU_BHRB 0x00000080 /* has BHRB feature enabled */ 62#define PPMU_BHRB 0x00000080 /* has BHRB feature enabled */
63#define PPMU_EBB 0x00000100 /* supports event based branch */
63 64
64/* 65/*
65 * Values for flags to get_alternatives() 66 * Values for flags to get_alternatives()
@@ -68,6 +69,11 @@ struct power_pmu {
68#define PPMU_LIMITED_PMC_REQD 2 /* have to put this on a limited PMC */ 69#define PPMU_LIMITED_PMC_REQD 2 /* have to put this on a limited PMC */
69#define PPMU_ONLY_COUNT_RUN 4 /* only counting in run state */ 70#define PPMU_ONLY_COUNT_RUN 4 /* only counting in run state */
70 71
72/*
73 * We use the event config bit 63 as a flag to request EBB.
74 */
75#define EVENT_CONFIG_EBB_SHIFT 63
76
71extern int register_power_pmu(struct power_pmu *); 77extern int register_power_pmu(struct power_pmu *);
72 78
73struct pt_regs; 79struct pt_regs;
diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
index b66ae722a8e9..f65e27b09bd3 100644
--- a/arch/powerpc/include/asm/pgalloc-64.h
+++ b/arch/powerpc/include/asm/pgalloc-64.h
@@ -221,17 +221,17 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t table,
221 221
222static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) 222static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
223{ 223{
224 return kmem_cache_alloc(PGT_CACHE(PMD_INDEX_SIZE), 224 return kmem_cache_alloc(PGT_CACHE(PMD_CACHE_INDEX),
225 GFP_KERNEL|__GFP_REPEAT); 225 GFP_KERNEL|__GFP_REPEAT);
226} 226}
227 227
228static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) 228static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
229{ 229{
230 kmem_cache_free(PGT_CACHE(PMD_INDEX_SIZE), pmd); 230 kmem_cache_free(PGT_CACHE(PMD_CACHE_INDEX), pmd);
231} 231}
232 232
233#define __pmd_free_tlb(tlb, pmd, addr) \ 233#define __pmd_free_tlb(tlb, pmd, addr) \
234 pgtable_free_tlb(tlb, pmd, PMD_INDEX_SIZE) 234 pgtable_free_tlb(tlb, pmd, PMD_CACHE_INDEX)
235#ifndef CONFIG_PPC_64K_PAGES 235#ifndef CONFIG_PPC_64K_PAGES
236#define __pud_free_tlb(tlb, pud, addr) \ 236#define __pud_free_tlb(tlb, pud, addr) \
237 pgtable_free_tlb(tlb, pud, PUD_INDEX_SIZE) 237 pgtable_free_tlb(tlb, pud, PUD_INDEX_SIZE)
diff --git a/arch/powerpc/include/asm/pgtable-ppc64-64k.h b/arch/powerpc/include/asm/pgtable-ppc64-64k.h
index 45142d640720..a56b82fb0609 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64-64k.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64-64k.h
@@ -33,7 +33,8 @@
33#define PGDIR_MASK (~(PGDIR_SIZE-1)) 33#define PGDIR_MASK (~(PGDIR_SIZE-1))
34 34
35/* Bits to mask out from a PMD to get to the PTE page */ 35/* Bits to mask out from a PMD to get to the PTE page */
36#define PMD_MASKED_BITS 0x1ff 36/* PMDs point to PTE table fragments which are 4K aligned. */
37#define PMD_MASKED_BITS 0xfff
37/* Bits to mask out from a PGD/PUD to get to the PMD page */ 38/* Bits to mask out from a PGD/PUD to get to the PMD page */
38#define PUD_MASKED_BITS 0x1ff 39#define PUD_MASKED_BITS 0x1ff
39 40
diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h
index e3d55f6f24fe..46db09414a10 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -10,6 +10,7 @@
10#else 10#else
11#include <asm/pgtable-ppc64-4k.h> 11#include <asm/pgtable-ppc64-4k.h>
12#endif 12#endif
13#include <asm/barrier.h>
13 14
14#define FIRST_USER_ADDRESS 0 15#define FIRST_USER_ADDRESS 0
15 16
@@ -20,7 +21,11 @@
20 PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT) 21 PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT)
21#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE) 22#define PGTABLE_RANGE (ASM_CONST(1) << PGTABLE_EADDR_SIZE)
22 23
23 24#ifdef CONFIG_TRANSPARENT_HUGEPAGE
25#define PMD_CACHE_INDEX (PMD_INDEX_SIZE + 1)
26#else
27#define PMD_CACHE_INDEX PMD_INDEX_SIZE
28#endif
24/* 29/*
25 * Define the address range of the kernel non-linear virtual area 30 * Define the address range of the kernel non-linear virtual area
26 */ 31 */
@@ -150,7 +155,7 @@
150#define pmd_present(pmd) (pmd_val(pmd) != 0) 155#define pmd_present(pmd) (pmd_val(pmd) != 0)
151#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0) 156#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0)
152#define pmd_page_vaddr(pmd) (pmd_val(pmd) & ~PMD_MASKED_BITS) 157#define pmd_page_vaddr(pmd) (pmd_val(pmd) & ~PMD_MASKED_BITS)
153#define pmd_page(pmd) virt_to_page(pmd_page_vaddr(pmd)) 158extern struct page *pmd_page(pmd_t pmd);
154 159
155#define pud_set(pudp, pudval) (pud_val(*(pudp)) = (pudval)) 160#define pud_set(pudp, pudval) (pud_val(*(pudp)) = (pudval))
156#define pud_none(pud) (!pud_val(pud)) 161#define pud_none(pud) (!pud_val(pud))
@@ -339,43 +344,217 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
339 344
340void pgtable_cache_add(unsigned shift, void (*ctor)(void *)); 345void pgtable_cache_add(unsigned shift, void (*ctor)(void *));
341void pgtable_cache_init(void); 346void pgtable_cache_init(void);
347#endif /* __ASSEMBLY__ */
348
349/*
350 * THP pages can't be special. So use the _PAGE_SPECIAL
351 */
352#define _PAGE_SPLITTING _PAGE_SPECIAL
353
354/*
355 * We need to differentiate between explicit huge page and THP huge
356 * page, since THP huge page also need to track real subpage details
357 */
358#define _PAGE_THP_HUGE _PAGE_4K_PFN
342 359
343/* 360/*
344 * find_linux_pte returns the address of a linux pte for a given 361 * set of bits not changed in pmd_modify.
345 * effective address and directory. If not found, it returns zero.
346 */ 362 */
347static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea) 363#define _HPAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | \
364 _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_SPLITTING | \
365 _PAGE_THP_HUGE)
366
367#ifndef __ASSEMBLY__
368/*
369 * The linux hugepage PMD now include the pmd entries followed by the address
370 * to the stashed pgtable_t. The stashed pgtable_t contains the hpte bits.
371 * [ 1 bit secondary | 3 bit hidx | 1 bit valid | 000]. We use one byte per
372 * each HPTE entry. With 16MB hugepage and 64K HPTE we need 256 entries and
373 * with 4K HPTE we need 4096 entries. Both will fit in a 4K pgtable_t.
374 *
375 * The last three bits are intentionally left to zero. This memory location
376 * are also used as normal page PTE pointers. So if we have any pointers
377 * left around while we collapse a hugepage, we need to make sure
378 * _PAGE_PRESENT and _PAGE_FILE bits of that are zero when we look at them
379 */
380static inline unsigned int hpte_valid(unsigned char *hpte_slot_array, int index)
348{ 381{
349 pgd_t *pg; 382 return (hpte_slot_array[index] >> 3) & 0x1;
350 pud_t *pu;
351 pmd_t *pm;
352 pte_t *pt = NULL;
353
354 pg = pgdir + pgd_index(ea);
355 if (!pgd_none(*pg)) {
356 pu = pud_offset(pg, ea);
357 if (!pud_none(*pu)) {
358 pm = pmd_offset(pu, ea);
359 if (pmd_present(*pm))
360 pt = pte_offset_kernel(pm, ea);
361 }
362 }
363 return pt;
364} 383}
365 384
366#ifdef CONFIG_HUGETLB_PAGE 385static inline unsigned int hpte_hash_index(unsigned char *hpte_slot_array,
367pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea, 386 int index)
368 unsigned *shift);
369#else
370static inline pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
371 unsigned *shift)
372{ 387{
373 if (shift) 388 return hpte_slot_array[index] >> 4;
374 *shift = 0;
375 return find_linux_pte(pgdir, ea);
376} 389}
377#endif /* !CONFIG_HUGETLB_PAGE */
378 390
379#endif /* __ASSEMBLY__ */ 391static inline void mark_hpte_slot_valid(unsigned char *hpte_slot_array,
392 unsigned int index, unsigned int hidx)
393{
394 hpte_slot_array[index] = hidx << 4 | 0x1 << 3;
395}
380 396
397static inline char *get_hpte_slot_array(pmd_t *pmdp)
398{
399 /*
400 * The hpte hindex is stored in the pgtable whose address is in the
401 * second half of the PMD
402 *
403 * Order this load with the test for pmd_trans_huge in the caller
404 */
405 smp_rmb();
406 return *(char **)(pmdp + PTRS_PER_PMD);
407
408
409}
410
411extern void hpte_do_hugepage_flush(struct mm_struct *mm, unsigned long addr,
412 pmd_t *pmdp);
413#ifdef CONFIG_TRANSPARENT_HUGEPAGE
414extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot);
415extern pmd_t mk_pmd(struct page *page, pgprot_t pgprot);
416extern pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot);
417extern void set_pmd_at(struct mm_struct *mm, unsigned long addr,
418 pmd_t *pmdp, pmd_t pmd);
419extern void update_mmu_cache_pmd(struct vm_area_struct *vma, unsigned long addr,
420 pmd_t *pmd);
421
422static inline int pmd_trans_huge(pmd_t pmd)
423{
424 /*
425 * leaf pte for huge page, bottom two bits != 00
426 */
427 return (pmd_val(pmd) & 0x3) && (pmd_val(pmd) & _PAGE_THP_HUGE);
428}
429
430static inline int pmd_large(pmd_t pmd)
431{
432 /*
433 * leaf pte for huge page, bottom two bits != 00
434 */
435 if (pmd_trans_huge(pmd))
436 return pmd_val(pmd) & _PAGE_PRESENT;
437 return 0;
438}
439
440static inline int pmd_trans_splitting(pmd_t pmd)
441{
442 if (pmd_trans_huge(pmd))
443 return pmd_val(pmd) & _PAGE_SPLITTING;
444 return 0;
445}
446
447extern int has_transparent_hugepage(void);
448#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
449
450static inline pte_t pmd_pte(pmd_t pmd)
451{
452 return __pte(pmd_val(pmd));
453}
454
455static inline pmd_t pte_pmd(pte_t pte)
456{
457 return __pmd(pte_val(pte));
458}
459
460static inline pte_t *pmdp_ptep(pmd_t *pmd)
461{
462 return (pte_t *)pmd;
463}
464
465#define pmd_pfn(pmd) pte_pfn(pmd_pte(pmd))
466#define pmd_young(pmd) pte_young(pmd_pte(pmd))
467#define pmd_mkold(pmd) pte_pmd(pte_mkold(pmd_pte(pmd)))
468#define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd)))
469#define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd)))
470#define pmd_mkyoung(pmd) pte_pmd(pte_mkyoung(pmd_pte(pmd)))
471#define pmd_mkwrite(pmd) pte_pmd(pte_mkwrite(pmd_pte(pmd)))
472
473#define __HAVE_ARCH_PMD_WRITE
474#define pmd_write(pmd) pte_write(pmd_pte(pmd))
475
476static inline pmd_t pmd_mkhuge(pmd_t pmd)
477{
478 /* Do nothing, mk_pmd() does this part. */
479 return pmd;
480}
481
482static inline pmd_t pmd_mknotpresent(pmd_t pmd)
483{
484 pmd_val(pmd) &= ~_PAGE_PRESENT;
485 return pmd;
486}
487
488static inline pmd_t pmd_mksplitting(pmd_t pmd)
489{
490 pmd_val(pmd) |= _PAGE_SPLITTING;
491 return pmd;
492}
493
494#define __HAVE_ARCH_PMD_SAME
495static inline int pmd_same(pmd_t pmd_a, pmd_t pmd_b)
496{
497 return (((pmd_val(pmd_a) ^ pmd_val(pmd_b)) & ~_PAGE_HPTEFLAGS) == 0);
498}
499
500#define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS
501extern int pmdp_set_access_flags(struct vm_area_struct *vma,
502 unsigned long address, pmd_t *pmdp,
503 pmd_t entry, int dirty);
504
505extern unsigned long pmd_hugepage_update(struct mm_struct *mm,
506 unsigned long addr,
507 pmd_t *pmdp, unsigned long clr);
508
509static inline int __pmdp_test_and_clear_young(struct mm_struct *mm,
510 unsigned long addr, pmd_t *pmdp)
511{
512 unsigned long old;
513
514 if ((pmd_val(*pmdp) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0)
515 return 0;
516 old = pmd_hugepage_update(mm, addr, pmdp, _PAGE_ACCESSED);
517 return ((old & _PAGE_ACCESSED) != 0);
518}
519
520#define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
521extern int pmdp_test_and_clear_young(struct vm_area_struct *vma,
522 unsigned long address, pmd_t *pmdp);
523#define __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
524extern int pmdp_clear_flush_young(struct vm_area_struct *vma,
525 unsigned long address, pmd_t *pmdp);
526
527#define __HAVE_ARCH_PMDP_GET_AND_CLEAR
528extern pmd_t pmdp_get_and_clear(struct mm_struct *mm,
529 unsigned long addr, pmd_t *pmdp);
530
531#define __HAVE_ARCH_PMDP_CLEAR_FLUSH
532extern pmd_t pmdp_clear_flush(struct vm_area_struct *vma, unsigned long address,
533 pmd_t *pmdp);
534
535#define __HAVE_ARCH_PMDP_SET_WRPROTECT
536static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long addr,
537 pmd_t *pmdp)
538{
539
540 if ((pmd_val(*pmdp) & _PAGE_RW) == 0)
541 return;
542
543 pmd_hugepage_update(mm, addr, pmdp, _PAGE_RW);
544}
545
546#define __HAVE_ARCH_PMDP_SPLITTING_FLUSH
547extern void pmdp_splitting_flush(struct vm_area_struct *vma,
548 unsigned long address, pmd_t *pmdp);
549
550#define __HAVE_ARCH_PGTABLE_DEPOSIT
551extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp,
552 pgtable_t pgtable);
553#define __HAVE_ARCH_PGTABLE_WITHDRAW
554extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp);
555
556#define __HAVE_ARCH_PMDP_INVALIDATE
557extern void pmdp_invalidate(struct vm_area_struct *vma, unsigned long address,
558 pmd_t *pmdp);
559#endif /* __ASSEMBLY__ */
381#endif /* _ASM_POWERPC_PGTABLE_PPC64_H_ */ 560#endif /* _ASM_POWERPC_PGTABLE_PPC64_H_ */
diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index b6293d26bd39..7d6eacf249cf 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -217,6 +217,12 @@ extern int gup_hugepd(hugepd_t *hugepd, unsigned pdshift, unsigned long addr,
217 217
218extern int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, 218extern int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr,
219 unsigned long end, int write, struct page **pages, int *nr); 219 unsigned long end, int write, struct page **pages, int *nr);
220#ifndef CONFIG_TRANSPARENT_HUGEPAGE
221#define pmd_large(pmd) 0
222#define has_transparent_hugepage() 0
223#endif
224pte_t *find_linux_pte_or_hugepte(pgd_t *pgdir, unsigned long ea,
225 unsigned *shift);
220#endif /* __ASSEMBLY__ */ 226#endif /* __ASSEMBLY__ */
221 227
222#endif /* __KERNEL__ */ 228#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/probes.h b/arch/powerpc/include/asm/probes.h
index 5f1e15b68704..3421637cfd7b 100644
--- a/arch/powerpc/include/asm/probes.h
+++ b/arch/powerpc/include/asm/probes.h
@@ -38,5 +38,30 @@ typedef u32 ppc_opcode_t;
38#define is_trap(instr) (IS_TW(instr) || IS_TWI(instr)) 38#define is_trap(instr) (IS_TW(instr) || IS_TWI(instr))
39#endif /* CONFIG_PPC64 */ 39#endif /* CONFIG_PPC64 */
40 40
41#ifdef CONFIG_PPC_ADV_DEBUG_REGS
42#define MSR_SINGLESTEP (MSR_DE)
43#else
44#define MSR_SINGLESTEP (MSR_SE)
45#endif
46
47/* Enable single stepping for the current task */
48static inline void enable_single_step(struct pt_regs *regs)
49{
50 regs->msr |= MSR_SINGLESTEP;
51#ifdef CONFIG_PPC_ADV_DEBUG_REGS
52 /*
53 * We turn off Critical Input Exception(CE) to ensure that the single
54 * step will be for the instruction we have the probe on; if we don't,
55 * it is possible we'd get the single step reported for CE.
56 */
57 regs->msr &= ~MSR_CE;
58 mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
59#ifdef CONFIG_PPC_47x
60 isync();
61#endif
62#endif
63}
64
65
41#endif /* __KERNEL__ */ 66#endif /* __KERNEL__ */
42#endif /* _ASM_POWERPC_PROBES_H */ 67#endif /* _ASM_POWERPC_PROBES_H */
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 14a658363698..47a35b08b963 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -168,10 +168,10 @@ struct thread_struct {
168 * The following help to manage the use of Debug Control Registers 168 * The following help to manage the use of Debug Control Registers
169 * om the BookE platforms. 169 * om the BookE platforms.
170 */ 170 */
171 unsigned long dbcr0; 171 uint32_t dbcr0;
172 unsigned long dbcr1; 172 uint32_t dbcr1;
173#ifdef CONFIG_BOOKE 173#ifdef CONFIG_BOOKE
174 unsigned long dbcr2; 174 uint32_t dbcr2;
175#endif 175#endif
176 /* 176 /*
177 * The stored value of the DBSR register will be the value at the 177 * The stored value of the DBSR register will be the value at the
@@ -179,7 +179,7 @@ struct thread_struct {
179 * user (will never be written to) and has value while helping to 179 * user (will never be written to) and has value while helping to
180 * describe the reason for the last debug trap. Torez 180 * describe the reason for the last debug trap. Torez
181 */ 181 */
182 unsigned long dbsr; 182 uint32_t dbsr;
183 /* 183 /*
184 * The following will contain addresses used by debug applications 184 * The following will contain addresses used by debug applications
185 * to help trace and trap on particular address locations. 185 * to help trace and trap on particular address locations.
@@ -200,7 +200,7 @@ struct thread_struct {
200#endif 200#endif
201#endif 201#endif
202 /* FP and VSX 0-31 register set */ 202 /* FP and VSX 0-31 register set */
203 double fpr[32][TS_FPRWIDTH]; 203 double fpr[32][TS_FPRWIDTH] __attribute__((aligned(16)));
204 struct { 204 struct {
205 205
206 unsigned int pad; 206 unsigned int pad;
@@ -287,9 +287,9 @@ struct thread_struct {
287 unsigned long siar; 287 unsigned long siar;
288 unsigned long sdar; 288 unsigned long sdar;
289 unsigned long sier; 289 unsigned long sier;
290 unsigned long mmcr0;
291 unsigned long mmcr2; 290 unsigned long mmcr2;
292 unsigned long mmcra; 291 unsigned mmcr0;
292 unsigned used_ebb;
293#endif 293#endif
294}; 294};
295 295
@@ -404,9 +404,7 @@ static inline void prefetchw(const void *x)
404 404
405#define spin_lock_prefetch(x) prefetchw(x) 405#define spin_lock_prefetch(x) prefetchw(x)
406 406
407#ifdef CONFIG_PPC64
408#define HAVE_ARCH_PICK_MMAP_LAYOUT 407#define HAVE_ARCH_PICK_MMAP_LAYOUT
409#endif
410 408
411#ifdef CONFIG_PPC64 409#ifdef CONFIG_PPC64
412static inline unsigned long get_clean_sp(unsigned long sp, int is_32) 410static inline unsigned long get_clean_sp(unsigned long sp, int is_32)
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 4a9e408644fe..5d7d9c2a5473 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -621,11 +621,15 @@
621#define MMCR0_PMXE 0x04000000UL /* performance monitor exception enable */ 621#define MMCR0_PMXE 0x04000000UL /* performance monitor exception enable */
622#define MMCR0_FCECE 0x02000000UL /* freeze ctrs on enabled cond or event */ 622#define MMCR0_FCECE 0x02000000UL /* freeze ctrs on enabled cond or event */
623#define MMCR0_TBEE 0x00400000UL /* time base exception enable */ 623#define MMCR0_TBEE 0x00400000UL /* time base exception enable */
624#define MMCR0_EBE 0x00100000UL /* Event based branch enable */
625#define MMCR0_PMCC 0x000c0000UL /* PMC control */
626#define MMCR0_PMCC_U6 0x00080000UL /* PMC1-6 are R/W by user (PR) */
624#define MMCR0_PMC1CE 0x00008000UL /* PMC1 count enable*/ 627#define MMCR0_PMC1CE 0x00008000UL /* PMC1 count enable*/
625#define MMCR0_PMCjCE 0x00004000UL /* PMCj count enable*/ 628#define MMCR0_PMCjCE 0x00004000UL /* PMCj count enable*/
626#define MMCR0_TRIGGER 0x00002000UL /* TRIGGER enable */ 629#define MMCR0_TRIGGER 0x00002000UL /* TRIGGER enable */
627#define MMCR0_PMAO 0x00000080UL /* performance monitor alert has occurred, set to 0 after handling exception */ 630#define MMCR0_PMAO 0x00000080UL /* performance monitor alert has occurred, set to 0 after handling exception */
628#define MMCR0_SHRFC 0x00000040UL /* SHRre freeze conditions between threads */ 631#define MMCR0_SHRFC 0x00000040UL /* SHRre freeze conditions between threads */
632#define MMCR0_FC56 0x00000010UL /* freeze counters 5 and 6 */
629#define MMCR0_FCTI 0x00000008UL /* freeze counters in tags inactive mode */ 633#define MMCR0_FCTI 0x00000008UL /* freeze counters in tags inactive mode */
630#define MMCR0_FCTA 0x00000004UL /* freeze counters in tags active mode */ 634#define MMCR0_FCTA 0x00000004UL /* freeze counters in tags active mode */
631#define MMCR0_FCWAIT 0x00000002UL /* freeze counter in WAIT state */ 635#define MMCR0_FCWAIT 0x00000002UL /* freeze counter in WAIT state */
@@ -673,6 +677,11 @@
673#define SIER_SIAR_VALID 0x0400000 /* SIAR contents valid */ 677#define SIER_SIAR_VALID 0x0400000 /* SIAR contents valid */
674#define SIER_SDAR_VALID 0x0200000 /* SDAR contents valid */ 678#define SIER_SDAR_VALID 0x0200000 /* SDAR contents valid */
675 679
680/* When EBB is enabled, some of MMCR0/MMCR2/SIER are user accessible */
681#define MMCR0_USER_MASK (MMCR0_FC | MMCR0_PMXE | MMCR0_PMAO)
682#define MMCR2_USER_MASK 0x4020100804020000UL /* (FC1P|FC2P|FC3P|FC4P|FC5P|FC6P) */
683#define SIER_USER_MASK 0x7fffffUL
684
676#define SPRN_PA6T_MMCR0 795 685#define SPRN_PA6T_MMCR0 795
677#define PA6T_MMCR0_EN0 0x0000000000000001UL 686#define PA6T_MMCR0_EN0 0x0000000000000001UL
678#define PA6T_MMCR0_EN1 0x0000000000000002UL 687#define PA6T_MMCR0_EN1 0x0000000000000002UL
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 34fd70488d83..c7a8bfc9f6f5 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -350,8 +350,8 @@ static inline u32 rtas_config_addr(int busno, int devfn, int reg)
350 (devfn << 8) | (reg & 0xff); 350 (devfn << 8) | (reg & 0xff);
351} 351}
352 352
353extern void __cpuinit rtas_give_timebase(void); 353extern void rtas_give_timebase(void);
354extern void __cpuinit rtas_take_timebase(void); 354extern void rtas_take_timebase(void);
355 355
356#ifdef CONFIG_PPC_RTAS 356#ifdef CONFIG_PPC_RTAS
357static inline int page_is_rtas_user_buf(unsigned long pfn) 357static inline int page_is_rtas_user_buf(unsigned long pfn)
diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h
index 200d763a0a67..49a13e0ef234 100644
--- a/arch/powerpc/include/asm/switch_to.h
+++ b/arch/powerpc/include/asm/switch_to.h
@@ -67,4 +67,18 @@ static inline void flush_spe_to_thread(struct task_struct *t)
67} 67}
68#endif 68#endif
69 69
70static inline void clear_task_ebb(struct task_struct *t)
71{
72#ifdef CONFIG_PPC_BOOK3S_64
73 /* EBB perf events are not inherited, so clear all EBB state. */
74 t->thread.bescr = 0;
75 t->thread.mmcr2 = 0;
76 t->thread.mmcr0 = 0;
77 t->thread.siar = 0;
78 t->thread.sdar = 0;
79 t->thread.sier = 0;
80 t->thread.used_ebb = 0;
81#endif
82}
83
70#endif /* _ASM_POWERPC_SWITCH_TO_H */ 84#endif /* _ASM_POWERPC_SWITCH_TO_H */
diff --git a/arch/powerpc/include/asm/tlbflush.h b/arch/powerpc/include/asm/tlbflush.h
index 61a59271665b..2def01ed0cb2 100644
--- a/arch/powerpc/include/asm/tlbflush.h
+++ b/arch/powerpc/include/asm/tlbflush.h
@@ -165,7 +165,8 @@ static inline void flush_tlb_kernel_range(unsigned long start,
165/* Private function for use by PCI IO mapping code */ 165/* Private function for use by PCI IO mapping code */
166extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start, 166extern void __flush_hash_table_range(struct mm_struct *mm, unsigned long start,
167 unsigned long end); 167 unsigned long end);
168 168extern void flush_tlb_pmd_range(struct mm_struct *mm, pmd_t *pmd,
169 unsigned long addr);
169#else 170#else
170#error Unsupported MMU type 171#error Unsupported MMU type
171#endif 172#endif
diff --git a/arch/powerpc/include/asm/vdso.h b/arch/powerpc/include/asm/vdso.h
index 50f261bc3e95..0d9cecddf8a4 100644
--- a/arch/powerpc/include/asm/vdso.h
+++ b/arch/powerpc/include/asm/vdso.h
@@ -22,7 +22,7 @@ extern unsigned long vdso64_rt_sigtramp;
22extern unsigned long vdso32_sigtramp; 22extern unsigned long vdso32_sigtramp;
23extern unsigned long vdso32_rt_sigtramp; 23extern unsigned long vdso32_rt_sigtramp;
24 24
25int __cpuinit vdso_getcpu_init(void); 25int vdso_getcpu_init(void);
26 26
27#else /* __ASSEMBLY__ */ 27#else /* __ASSEMBLY__ */
28 28