From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "Cédric Le Goater" <clg@kaod.org>, linuxppc-dev@lists.ozlabs.org
Cc: Michael Ellerman <mpe@ellerman.id.au>,
Paul Mackerras <paulus@samba.org>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v3 1/8] powerpc/xive: introduce a common routine xive_queue_page_alloc()
Date: Fri, 01 Sep 2017 15:26:43 +1000 [thread overview]
Message-ID: <1504243603.4974.68.camel@kernel.crashing.org> (raw)
In-Reply-To: <20170830194617.26621-2-clg@kaod.org>
On Wed, 2017-08-30 at 21:46 +0200, Cédric Le Goater wrote:
> This routine will be used in the spapr backend. Also introduce a short
> xive_alloc_order() helper.
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/sysdev/xive/common.c | 16 ++++++++++++++++
> arch/powerpc/sysdev/xive/native.c | 16 +++++-----------
> 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 6e0c9dee724f..26999ceae20e 100644
> --- a/arch/powerpc/sysdev/xive/common.c
> +++ b/arch/powerpc/sysdev/xive/common.c
> @@ -1424,6 +1424,22 @@ bool xive_core_init(const struct xive_ops *ops, void __iomem *area, u32 offset,
> return true;
> }
>
> +__be32 *xive_queue_page_alloc(unsigned int cpu, u32 queue_shift)
> +{
> + unsigned int alloc_order;
> + struct page *pages;
> + __be32 *qpage;
> +
> + alloc_order = xive_alloc_order(queue_shift);
> + pages = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL, alloc_order);
> + if (!pages)
> + return ERR_PTR(-ENOMEM);
> + qpage = (__be32 *)page_address(pages);
> + memset(qpage, 0, 1 << queue_shift);
> +
> + return qpage;
> +}
> +
> static int __init xive_off(char *arg)
> {
> xive_cmdline_disabled = true;
> diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c
> index 0f95476b01f6..ef92a83090e1 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);
> static int xive_native_setup_queue(unsigned int cpu, struct xive_cpu *xc, u8 prio)
> {
> struct xive_q *q = &xc->queue[prio];
> - unsigned int alloc_order;
> - struct page *pages;
> __be32 *qpage;
>
> - alloc_order = (xive_queue_shift > PAGE_SHIFT) ?
> - (xive_queue_shift - PAGE_SHIFT) : 0;
> - pages = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL, alloc_order);
> - if (!pages)
> - return -ENOMEM;
> - qpage = (__be32 *)page_address(pages);
> - memset(qpage, 0, 1 << xive_queue_shift);
> + qpage = xive_queue_page_alloc(cpu, xive_queue_shift);
> + if (IS_ERR(qpage))
> + return PTR_ERR(qpage);
> +
> return xive_native_configure_queue(get_hard_smp_processor_id(cpu),
> q, prio, qpage, xive_queue_shift, false);
> }
> @@ -227,8 +222,7 @@ static void xive_native_cleanup_queue(unsigned int cpu, struct xive_cpu *xc, u8
> * from an IPI and iounmap isn't safe
> */
> __xive_native_disable_queue(get_hard_smp_processor_id(cpu), q, prio);
> - alloc_order = (xive_queue_shift > PAGE_SHIFT) ?
> - (xive_queue_shift - PAGE_SHIFT) : 0;
> + alloc_order = xive_alloc_order(xive_queue_shift);
> free_pages((unsigned long)q->qpage, alloc_order);
> q->qpage = NULL;
> }
> 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 {
>
> bool xive_core_init(const struct xive_ops *ops, void __iomem *area, u32 offset,
> u8 max_prio);
> +__be32 *xive_queue_page_alloc(unsigned int cpu, u32 queue_shift);
> +
> +static inline u32 xive_alloc_order(u32 queue_shift)
> +{
> + return (queue_shift > PAGE_SHIFT) ? (queue_shift - PAGE_SHIFT) : 0;
> +}
>
> extern bool xive_cmdline_disabled;
>
next prev parent reply other threads:[~2017-09-01 5:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-30 19:46 [PATCH v3 0/8] guest exploitation of the XIVE interrupt controller Cédric Le Goater
2017-08-30 19:46 ` [PATCH v3 1/8] powerpc/xive: introduce a common routine xive_queue_page_alloc() Cédric Le Goater
2017-09-01 5:26 ` Benjamin Herrenschmidt [this message]
2017-09-06 10:55 ` [v3, " Michael Ellerman
2017-08-30 19:46 ` [PATCH v3 2/8] powerpc/xive: guest exploitation of the XIVE interrupt controller Cédric Le Goater
2017-09-01 5:29 ` Benjamin Herrenschmidt
2017-08-30 19:46 ` [PATCH v3 3/8] powerpc/xive: rename xive_poke_esb() in xive_esb_read() Cédric Le Goater
2017-09-01 5:30 ` Benjamin Herrenschmidt
2017-08-30 19:46 ` [PATCH v3 4/8] powerpc/xive: introduce xive_esb_write() Cédric Le Goater
2017-09-01 5:31 ` Benjamin Herrenschmidt
2017-08-30 19:46 ` [PATCH v3 5/8] powerpc/xive: add the HW IRQ number under xive_irq_data Cédric Le Goater
2017-09-01 5:34 ` Benjamin Herrenschmidt
2017-08-30 19:46 ` [PATCH v3 6/8] powerpc/xive: introduce H_INT_ESB hcall Cédric Le Goater
2017-09-01 6:01 ` Benjamin Herrenschmidt
2017-08-30 19:46 ` [PATCH v3 7/8] powerpc/xive: add XIVE Exploitation Mode to CAS Cédric Le Goater
2017-08-30 19:46 ` [PATCH v3 8/8] powerpc/xive: improve debugging macros Cédric Le Goater
2017-09-01 5:43 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1504243603.4974.68.camel@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.