diff options
| -rw-r--r-- | arch/powerpc/sysdev/xive/common.c | 16 | ||||
| -rw-r--r-- | arch/powerpc/sysdev/xive/native.c | 16 | ||||
| -rw-r--r-- | arch/powerpc/sysdev/xive/xive-internal.h | 6 |
3 files changed, 27 insertions, 11 deletions
diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c index 558df6542b1a..a30d6d12b92b 100644 --- a/arch/powerpc/sysdev/xive/common.c +++ b/arch/powerpc/sysdev/xive/common.c | |||
| @@ -1428,6 +1428,22 @@ bool __init xive_core_init(const struct xive_ops *ops, void __iomem *area, u32 o | |||
| 1428 | return true; | 1428 | return true; |
| 1429 | } | 1429 | } |
| 1430 | 1430 | ||
| 1431 | __be32 *xive_queue_page_alloc(unsigned int cpu, u32 queue_shift) | ||
| 1432 | { | ||
| 1433 | unsigned int alloc_order; | ||
| 1434 | struct page *pages; | ||
| 1435 | __be32 *qpage; | ||
| 1436 | |||
| 1437 | alloc_order = xive_alloc_order(queue_shift); | ||
| 1438 | pages = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL, alloc_order); | ||
| 1439 | if (!pages) | ||
| 1440 | return ERR_PTR(-ENOMEM); | ||
| 1441 | qpage = (__be32 *)page_address(pages); | ||
| 1442 | memset(qpage, 0, 1 << queue_shift); | ||
| 1443 | |||
| 1444 | return qpage; | ||
| 1445 | } | ||
| 1446 | |||
| 1431 | static int __init xive_off(char *arg) | 1447 | static int __init xive_off(char *arg) |
| 1432 | { | 1448 | { |
| 1433 | xive_cmdline_disabled = true; | 1449 | xive_cmdline_disabled = true; |
diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c index edc2e81b7280..ace3d7aedfb7 100644 --- a/arch/powerpc/sysdev/xive/native.c +++ b/arch/powerpc/sysdev/xive/native.c | |||
| @@ -202,17 +202,12 @@ EXPORT_SYMBOL_GPL(xive_native_disable_queue); | |||
| 202 | static int xive_native_setup_queue(unsigned int cpu, struct xive_cpu *xc, u8 prio) | 202 | static int xive_native_setup_queue(unsigned int cpu, struct xive_cpu *xc, u8 prio) |
| 203 | { | 203 | { |
| 204 | struct xive_q *q = &xc->queue[prio]; | 204 | struct xive_q *q = &xc->queue[prio]; |
| 205 | unsigned int alloc_order; | ||
| 206 | struct page *pages; | ||
| 207 | __be32 *qpage; | 205 | __be32 *qpage; |
| 208 | 206 | ||
| 209 | alloc_order = (xive_queue_shift > PAGE_SHIFT) ? | 207 | qpage = xive_queue_page_alloc(cpu, xive_queue_shift); |
| 210 | (xive_queue_shift - PAGE_SHIFT) : 0; | 208 | if (IS_ERR(qpage)) |
| 211 | pages = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL, alloc_order); | 209 | return PTR_ERR(qpage); |
| 212 | if (!pages) | 210 | |
| 213 | return -ENOMEM; | ||
| 214 | qpage = (__be32 *)page_address(pages); | ||
| 215 | memset(qpage, 0, 1 << xive_queue_shift); | ||
| 216 | return xive_native_configure_queue(get_hard_smp_processor_id(cpu), | 211 | return xive_native_configure_queue(get_hard_smp_processor_id(cpu), |
| 217 | q, prio, qpage, xive_queue_shift, false); | 212 | q, prio, qpage, xive_queue_shift, false); |
| 218 | } | 213 | } |
| @@ -227,8 +222,7 @@ static void xive_native_cleanup_queue(unsigned int cpu, struct xive_cpu *xc, u8 | |||
| 227 | * from an IPI and iounmap isn't safe | 222 | * from an IPI and iounmap isn't safe |
| 228 | */ | 223 | */ |
| 229 | __xive_native_disable_queue(get_hard_smp_processor_id(cpu), q, prio); | 224 | __xive_native_disable_queue(get_hard_smp_processor_id(cpu), q, prio); |
| 230 | alloc_order = (xive_queue_shift > PAGE_SHIFT) ? | 225 | alloc_order = xive_alloc_order(xive_queue_shift); |
| 231 | (xive_queue_shift - PAGE_SHIFT) : 0; | ||
| 232 | free_pages((unsigned long)q->qpage, alloc_order); | 226 | free_pages((unsigned long)q->qpage, alloc_order); |
| 233 | q->qpage = NULL; | 227 | q->qpage = NULL; |
| 234 | } | 228 | } |
diff --git a/arch/powerpc/sysdev/xive/xive-internal.h b/arch/powerpc/sysdev/xive/xive-internal.h index d07ef2d29caf..dd1e2022cce4 100644 --- a/arch/powerpc/sysdev/xive/xive-internal.h +++ b/arch/powerpc/sysdev/xive/xive-internal.h | |||
| @@ -56,6 +56,12 @@ struct xive_ops { | |||
| 56 | 56 | ||
| 57 | bool xive_core_init(const struct xive_ops *ops, void __iomem *area, u32 offset, | 57 | bool xive_core_init(const struct xive_ops *ops, void __iomem *area, u32 offset, |
| 58 | u8 max_prio); | 58 | u8 max_prio); |
| 59 | __be32 *xive_queue_page_alloc(unsigned int cpu, u32 queue_shift); | ||
| 60 | |||
| 61 | static inline u32 xive_alloc_order(u32 queue_shift) | ||
| 62 | { | ||
| 63 | return (queue_shift > PAGE_SHIFT) ? (queue_shift - PAGE_SHIFT) : 0; | ||
| 64 | } | ||
| 59 | 65 | ||
| 60 | extern bool xive_cmdline_disabled; | 66 | extern bool xive_cmdline_disabled; |
| 61 | 67 | ||
