From patchwork Tue Aug 1 13:36:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Punit Agrawal X-Patchwork-Id: 9874621 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CD2F660361 for ; Tue, 1 Aug 2017 13:37:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8DCA283CB for ; Tue, 1 Aug 2017 13:37:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD4972867E; Tue, 1 Aug 2017 13:37:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A528283CB for ; Tue, 1 Aug 2017 13:37:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752357AbdHANhB (ORCPT ); Tue, 1 Aug 2017 09:37:01 -0400 Received: from foss.arm.com ([217.140.101.70]:40884 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752347AbdHANg6 (ORCPT ); Tue, 1 Aug 2017 09:36:58 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6B07C80D; Tue, 1 Aug 2017 06:36:58 -0700 (PDT) Received: from localhost (e105922-lin.cambridge.arm.com [10.1.207.56]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DDEC93F540; Tue, 1 Aug 2017 06:36:57 -0700 (PDT) From: Punit Agrawal To: linux-acpi@vger.kernel.org Cc: Punit Agrawal , lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, linux-kernel@vger.kernel.org, Borislav Petkov , "Rafael J . Wysocki" , James Morse Subject: [PATCH 1/3] GHES: Expand the estatus pool in ghes_estatus_pool_init() Date: Tue, 1 Aug 2017 14:36:06 +0100 Message-Id: <20170801133608.21017-2-punit.agrawal@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170801133608.21017-1-punit.agrawal@arm.com> References: <20170801133608.21017-1-punit.agrawal@arm.com> X-ARM-No-Footer: FoSSMail Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP During the GHES driver initialisation, a pool of memory is created by calling ghes_estatus_pool_init() which is then immediately expanded by making a call to ghes_estatus_pool_expand(). Re-factor the code so that on successful creation of the pool, ghes_estatus_pool_init() expands the initialised pool by calling ghes_estatus_pool_expand(). The change is in preparation for moving the pool creation out of driver initialisation to when a platform device is being probed. Signed-off-by: Punit Agrawal Cc: Borislav Petkov Cc: James Morse --- drivers/acpi/apei/ghes.c | 55 +++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index d661d452b238..007b38abcb34 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -207,11 +207,25 @@ static void ghes_iounmap_irq(void __iomem *vaddr_ptr) arch_apei_flush_tlb_one(vaddr); } -static int ghes_estatus_pool_init(void) +static int ghes_estatus_pool_expand(unsigned long len) { - ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1); - if (!ghes_estatus_pool) - return -ENOMEM; + unsigned long i, pages, size, addr; + int ret; + + ghes_estatus_pool_size_request += PAGE_ALIGN(len); + size = gen_pool_size(ghes_estatus_pool); + if (size >= ghes_estatus_pool_size_request) + return 0; + pages = (ghes_estatus_pool_size_request - size) / PAGE_SIZE; + for (i = 0; i < pages; i++) { + addr = __get_free_page(GFP_KERNEL); + if (!addr) + return -ENOMEM; + ret = gen_pool_add(ghes_estatus_pool, addr, PAGE_SIZE, -1); + if (ret) + return ret; + } + return 0; } @@ -229,26 +243,20 @@ static void ghes_estatus_pool_exit(void) gen_pool_destroy(ghes_estatus_pool); } -static int ghes_estatus_pool_expand(unsigned long len) +static int ghes_estatus_pool_init(void) { - unsigned long i, pages, size, addr; - int ret; + int rc; - ghes_estatus_pool_size_request += PAGE_ALIGN(len); - size = gen_pool_size(ghes_estatus_pool); - if (size >= ghes_estatus_pool_size_request) - return 0; - pages = (ghes_estatus_pool_size_request - size) / PAGE_SIZE; - for (i = 0; i < pages; i++) { - addr = __get_free_page(GFP_KERNEL); - if (!addr) - return -ENOMEM; - ret = gen_pool_add(ghes_estatus_pool, addr, PAGE_SIZE, -1); - if (ret) - return ret; - } + ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1); + if (!ghes_estatus_pool) + return -ENOMEM; - return 0; + rc = ghes_estatus_pool_expand(GHES_ESTATUS_CACHE_AVG_SIZE * + GHES_ESTATUS_CACHE_ALLOCED_MAX); + if (rc) + ghes_estatus_pool_exit(); + + return rc; } static int map_gen_v2(struct ghes *ghes) @@ -1285,11 +1293,6 @@ static int __init ghes_init(void) if (rc) goto err_ioremap_exit; - rc = ghes_estatus_pool_expand(GHES_ESTATUS_CACHE_AVG_SIZE * - GHES_ESTATUS_CACHE_ALLOCED_MAX); - if (rc) - goto err_pool_exit; - rc = platform_driver_register(&ghes_platform_driver); if (rc) goto err_pool_exit;