From patchwork Mon Dec 3 18:05:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10710201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE8681057 for ; Mon, 3 Dec 2018 18:06:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A35A12B47E for ; Mon, 3 Dec 2018 18:06:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 971132B48F; Mon, 3 Dec 2018 18:06:54 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B53F2B47E for ; Mon, 3 Dec 2018 18:06:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 52ADD6B6A31; Mon, 3 Dec 2018 13:06:52 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4B0B46B6A32; Mon, 3 Dec 2018 13:06:52 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 387796B6A78; Mon, 3 Dec 2018 13:06:52 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) by kanga.kvack.org (Postfix) with ESMTP id 0FFC26B6A31 for ; Mon, 3 Dec 2018 13:06:52 -0500 (EST) Received: by mail-oi1-f199.google.com with SMTP id n196so8714791oig.15 for ; Mon, 03 Dec 2018 10:06:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Jb/HfFcVRIO+ukolQMwK2cGv9REut3HKPUb8Vf9DTOg=; b=IZPp2WO6g8NIC+Q6TcdN8wDPY+FnTlJvhRoC5goIqj0+87LTGHlj8v+e+4QP1QoAJl 8gFflXmBIVVq23LO+myKOFckF1QRy82qyXLNiaNCJ8Nm9gPB/P3PXAyBEUfLYrLz6Zi4 IFLoh8L3kS8+kCRq3gXQ+8F/aia7vhSmi2GZDhEKxLEnSTlFt4smjdX5pDbzTH+rOMn7 QkPfltUzd1JIjgL1KruzrimRuJrdcDk6Js+5qY/GDYRz8VepBdeQfbC0u5JzueAJ+B4I B2I+TuROevsqLN3ZAXdevE0jJD1SAvs/8Fe4nNfeXL66xMcq1MrW5GMCN8r8MJEIhtfQ NNYw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com X-Gm-Message-State: AA+aEWYEJYkZWbiib/t4JK/otu78NAvJk1Cy/zPnr/KIBArQLRcbPE/P 5mymXSHPUkIqlesbF5xlDAloSUJTX2ZaapKRyRwo7Jv/XMtXXOKF9BEgAps9Tlr7+jqPNcDbATA +kLdqx8RaftA8DsXEQcMWCJ3bdeA8bGp06cqEkU6+7+88wvt1XzRR158sCu5mhP+TPw== X-Received: by 2002:a9d:1b2c:: with SMTP id l41mr10213248otl.1.1543860411799; Mon, 03 Dec 2018 10:06:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/U+wDfwrOoDXnmCBZLoLOQF3VTQo7DRV2TAGXcmlIPR0oMBY98924jE72HcsrxT0QTC2rRi X-Received: by 2002:a9d:1b2c:: with SMTP id l41mr10213183otl.1.1543860410759; Mon, 03 Dec 2018 10:06:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543860410; cv=none; d=google.com; s=arc-20160816; b=hst0bV1u74Jg95zEWi1CInbYue+zKILkdsMa12v+ByikQq6orG4k0i3Xrz0USCVc/g +z3g2XweMGtoOzVPk2sNttuXamVIDo64z/xZf8JdjBSo9CPc0twKuWpGIIQ4Xpmnbu5t /a6t2/E7Is40Ee12WHFj2Iqc4dk1Bx0OivJyVGdxjAYVqlHW8xlR1XNWYbP/+MQFPInk m+Jzwg/hqHGw+v5gX+qtFbm+1bp1gU56RLdmscmi+aoWcZ+H0GuTmofezLwmiPrVmINn fK7lxrSwDr1NCTEymyqbCR0dOui+1QeQ1AiSD6T1I5Edas48y7MzxU0yPXfYxIMU9KyD Ucxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Jb/HfFcVRIO+ukolQMwK2cGv9REut3HKPUb8Vf9DTOg=; b=PWqyePIUOU7oopaHqd5oW9BCOtR6JwBAxGbCx5r9TzHDGQ/WLKmOmSptI1bSEjvRG8 Iy6LpW84mmuRvcYxvBmjy2Eo772/KI3HwF2CUEINv+1lKU1oA5tizMl/bg57mPgyGWN6 PfbKODhrdVvbiSJa8CMRaWwl8WufZHbe1PIKKMUWDGd7cF/rAYWnnmoIMy8Buo4Uqeu/ U1XRJDtVO1mpGFe7j3dvwAL0CpFY5/HNr2l11cDNZZcF3BEldWTmz+60byMzII4q7ioJ ttdST6PeztlIRxhdgrPt4q2BA6FYADNV+8IsYLD6TlH8thzQduM7llFeoPFPgGv4WluC cvxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id k186si5994816oih.238.2018.12.03.10.06.50 for ; Mon, 03 Dec 2018 10:06:50 -0800 (PST) Received-SPF: pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com 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 108D11713; Mon, 3 Dec 2018 10:06:50 -0800 (PST) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 404C33F59C; Mon, 3 Dec 2018 10:06:47 -0800 (PST) From: James Morse To: linux-acpi@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Borislav Petkov , Marc Zyngier , Christoffer Dall , Will Deacon , Catalin Marinas , Naoya Horiguchi , Rafael Wysocki , Len Brown , Tony Luck , Dongjiu Geng , Xie XiuQi , Fan Wu , James Morse Subject: [PATCH v7 04/25] ACPI / APEI: Make hest.c manage the estatus memory pool Date: Mon, 3 Dec 2018 18:05:52 +0000 Message-Id: <20181203180613.228133-5-james.morse@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181203180613.228133-1-james.morse@arm.com> References: <20181203180613.228133-1-james.morse@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP ghes.c has a memory pool it uses for the estatus cache and the estatus queue. The cache is initialised when registering the platform driver. For the queue, an NMI-like notification has to grow/shrink the pool as it is registered and unregistered. This is all pretty noisy when adding new NMI-like notifications, it would be better to replace this with a static pool size based on the number of users. As a precursor, move the call that creates the pool from ghes_init(), into hest.c. Later this will take the number of ghes entries and consolidate the queue allocations. Remove ghes_estatus_pool_exit() as hest.c doesn't have anywhere to put this. The pool is now initialised as part of ACPI's subsys_initcall(): (acpi_init(), acpi_scan_init(), acpi_pci_root_init(), acpi_hest_init()) Before this patch it happened later as a GHES specific device_initcall(). Signed-off-by: James Morse --- drivers/acpi/apei/ghes.c | 33 ++++++--------------------------- drivers/acpi/apei/hest.c | 5 +++++ include/acpi/ghes.h | 2 ++ 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index c15264f2dc4b..78058adb2574 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -162,26 +162,16 @@ static void ghes_iounmap_irq(void) clear_fixmap(FIX_APEI_GHES_IRQ); } -static int ghes_estatus_pool_init(void) +static int ghes_estatus_pool_expand(unsigned long len); //temporary + +int ghes_estatus_pool_init(void) { ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1); if (!ghes_estatus_pool) return -ENOMEM; - return 0; -} -static void ghes_estatus_pool_free_chunk(struct gen_pool *pool, - struct gen_pool_chunk *chunk, - void *data) -{ - vfree((void *)chunk->start_addr); -} - -static void ghes_estatus_pool_exit(void) -{ - gen_pool_for_each_chunk(ghes_estatus_pool, - ghes_estatus_pool_free_chunk, NULL); - gen_pool_destroy(ghes_estatus_pool); + return ghes_estatus_pool_expand(GHES_ESTATUS_CACHE_AVG_SIZE * + GHES_ESTATUS_CACHE_ALLOCED_MAX); } static int ghes_estatus_pool_expand(unsigned long len) @@ -1225,18 +1215,9 @@ static int __init ghes_init(void) ghes_nmi_init_cxt(); - rc = ghes_estatus_pool_init(); - if (rc) - goto err; - - 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; + goto err; rc = apei_osc_setup(); if (rc == 0 && osc_sb_apei_support_acked) @@ -1249,8 +1230,6 @@ static int __init ghes_init(void) pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n"); return 0; -err_pool_exit: - ghes_estatus_pool_exit(); err: return rc; } diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c index b1e9f81ebeea..da5fabaeb48f 100644 --- a/drivers/acpi/apei/hest.c +++ b/drivers/acpi/apei/hest.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "apei-internal.h" @@ -200,6 +201,10 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count) if (!ghes_arr.ghes_devs) return -ENOMEM; + rc = ghes_estatus_pool_init(); + if (rc) + goto out; + rc = apei_hest_parse(hest_parse_ghes, &ghes_arr); if (rc) goto err; diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index 82cb4eb225a4..46ef5566e052 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -52,6 +52,8 @@ enum { GHES_SEV_PANIC = 0x3, }; +int ghes_estatus_pool_init(void); + /* From drivers/edac/ghes_edac.c */ #ifdef CONFIG_EDAC_GHES