[{"id":1746133,"web_url":"http://patchwork.ozlabs.org/comment/1746133/","msgid":"<20170814045215.GH3452@umbus.fritz.box>","date":"2017-08-14T04:52:15","subject":"Re: [PATCH v2 1/8] powerpc/xive: introduce a common routine\n\txive_queue_page_alloc()","submitter":{"id":47,"url":"http://patchwork.ozlabs.org/api/people/47/","name":"David Gibson","email":"david@gibson.dropbear.id.au"},"content":"On Fri, Aug 11, 2017 at 04:23:34PM +0200, Cédric Le Goater wrote:\n> This routine will be used in the spapr backend. Also introduce a short\n> xive_alloc_order() helper.\n> \n> Signed-off-by: Cédric Le Goater <clg@kaod.org>\n\nReviewed-by: David Gibson <david@gibson.dropbear.id.au>\n\n> ---\n>  arch/powerpc/sysdev/xive/common.c        | 16 ++++++++++++++++\n>  arch/powerpc/sysdev/xive/native.c        | 16 +++++-----------\n>  arch/powerpc/sysdev/xive/xive-internal.h |  6 ++++++\n>  3 files changed, 27 insertions(+), 11 deletions(-)\n> \n> diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c\n> index 6e0c9dee724f..26999ceae20e 100644\n> --- a/arch/powerpc/sysdev/xive/common.c\n> +++ b/arch/powerpc/sysdev/xive/common.c\n> @@ -1424,6 +1424,22 @@ bool xive_core_init(const struct xive_ops *ops, void __iomem *area, u32 offset,\n>  \treturn true;\n>  }\n>  \n> +__be32 *xive_queue_page_alloc(unsigned int cpu, u32 queue_shift)\n> +{\n> +\tunsigned int alloc_order;\n> +\tstruct page *pages;\n> +\t__be32 *qpage;\n> +\n> +\talloc_order = xive_alloc_order(queue_shift);\n> +\tpages = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL, alloc_order);\n> +\tif (!pages)\n> +\t\treturn ERR_PTR(-ENOMEM);\n> +\tqpage = (__be32 *)page_address(pages);\n> +\tmemset(qpage, 0, 1 << queue_shift);\n> +\n> +\treturn qpage;\n> +}\n> +\n>  static int __init xive_off(char *arg)\n>  {\n>  \txive_cmdline_disabled = true;\n> diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c\n> index 0f95476b01f6..ef92a83090e1 100644\n> --- a/arch/powerpc/sysdev/xive/native.c\n> +++ b/arch/powerpc/sysdev/xive/native.c\n> @@ -202,17 +202,12 @@ EXPORT_SYMBOL_GPL(xive_native_disable_queue);\n>  static int xive_native_setup_queue(unsigned int cpu, struct xive_cpu *xc, u8 prio)\n>  {\n>  \tstruct xive_q *q = &xc->queue[prio];\n> -\tunsigned int alloc_order;\n> -\tstruct page *pages;\n>  \t__be32 *qpage;\n>  \n> -\talloc_order = (xive_queue_shift > PAGE_SHIFT) ?\n> -\t\t(xive_queue_shift - PAGE_SHIFT) : 0;\n> -\tpages = alloc_pages_node(cpu_to_node(cpu), GFP_KERNEL, alloc_order);\n> -\tif (!pages)\n> -\t\treturn -ENOMEM;\n> -\tqpage = (__be32 *)page_address(pages);\n> -\tmemset(qpage, 0, 1 << xive_queue_shift);\n> +\tqpage = xive_queue_page_alloc(cpu, xive_queue_shift);\n> +\tif (IS_ERR(qpage))\n> +\t\treturn PTR_ERR(qpage);\n> +\n>  \treturn xive_native_configure_queue(get_hard_smp_processor_id(cpu),\n>  \t\t\t\t\t   q, prio, qpage, xive_queue_shift, false);\n>  }\n> @@ -227,8 +222,7 @@ static void xive_native_cleanup_queue(unsigned int cpu, struct xive_cpu *xc, u8\n>  \t * from an IPI and iounmap isn't safe\n>  \t */\n>  \t__xive_native_disable_queue(get_hard_smp_processor_id(cpu), q, prio);\n> -\talloc_order = (xive_queue_shift > PAGE_SHIFT) ?\n> -\t\t(xive_queue_shift - PAGE_SHIFT) : 0;\n> +\talloc_order = xive_alloc_order(xive_queue_shift);\n>  \tfree_pages((unsigned long)q->qpage, alloc_order);\n>  \tq->qpage = NULL;\n>  }\n> diff --git a/arch/powerpc/sysdev/xive/xive-internal.h b/arch/powerpc/sysdev/xive/xive-internal.h\n> index d07ef2d29caf..dd1e2022cce4 100644\n> --- a/arch/powerpc/sysdev/xive/xive-internal.h\n> +++ b/arch/powerpc/sysdev/xive/xive-internal.h\n> @@ -56,6 +56,12 @@ struct xive_ops {\n>  \n>  bool xive_core_init(const struct xive_ops *ops, void __iomem *area, u32 offset,\n>  \t\t    u8 max_prio);\n> +__be32 *xive_queue_page_alloc(unsigned int cpu, u32 queue_shift);\n> +\n> +static inline u32 xive_alloc_order(u32 queue_shift)\n> +{\n> +\treturn (queue_shift > PAGE_SHIFT) ? (queue_shift - PAGE_SHIFT) : 0;\n> +}\n>  \n>  extern bool xive_cmdline_disabled;\n>","headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xW54d6nkYz9t3f\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 14 Aug 2017 16:17:37 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xW54d5XTXzDqm9\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 14 Aug 2017 16:17:37 +1000 (AEST)","from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xW52y42lGzDqlG\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tMon, 14 Aug 2017 16:16:10 +1000 (AEST)","by ozlabs.org (Postfix, from userid 1007)\n\tid 3xW52y2rYzz9t3s; Mon, 14 Aug 2017 16:16:10 +1000 (AEST)"],"Authentication-Results":["ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=gibson.dropbear.id.au\n\theader.i=@gibson.dropbear.id.au header.b=\"aAC5PL+g\"; \n\tdkim-atps=neutral","lists.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=gibson.dropbear.id.au\n\theader.i=@gibson.dropbear.id.au header.b=\"aAC5PL+g\"; \n\tdkim-atps=neutral","lists.ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gibson.dropbear.id.au\n\theader.i=@gibson.dropbear.id.au\n\theader.b=\"aAC5PL+g\"; dkim-atps=neutral"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n\td=gibson.dropbear.id.au; s=201602; t=1502691370;\n\tbh=xoyKhB0Y3LcYb1E43EiGgLu+Gk8pw9Geb7THm52YloA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=aAC5PL+gA5WWUriK6vWX/NaShR/Tv64gGQdMpUXF2ROKu8gj1mS9/cRWRQ+fSFP0N\n\tqMM6i1WEOFcps5dBbWZl5mFaTS204ENrpWj593v1fylsuq3q2YqD5QNzGp5NSBBQ96\n\tX001HiUAUOn/Vt/jd+v/Tu9x+tT7Y9XKjN2u1dPc=","Date":"Mon, 14 Aug 2017 14:52:15 +1000","From":"David Gibson <david@gibson.dropbear.id.au>","To":"=?iso-8859-1?Q?C=E9dric?= Le Goater <clg@kaod.org>","Subject":"Re: [PATCH v2 1/8] powerpc/xive: introduce a common routine\n\txive_queue_page_alloc()","Message-ID":"<20170814045215.GH3452@umbus.fritz.box>","References":"<20170811142341.22715-1-clg@kaod.org>\n\t<20170811142341.22715-2-clg@kaod.org>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"smOfPzt+Qjm5bNGJ\"","Content-Disposition":"inline","In-Reply-To":"<20170811142341.22715-2-clg@kaod.org>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"linuxppc-dev@lists.ozlabs.org, Paul Mackerras <paulus@samba.org>","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"}}]