Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1568880pxb; Fri, 22 Oct 2021 03:37:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxloZqWEiEkzU5AeXVeDw5yrHwxP1J+1a13tMNhwf12Aid61OmZG+Rb8JdYxlI0/0t350qS X-Received: by 2002:a05:6402:5249:: with SMTP id t9mr16344896edd.135.1634899052480; Fri, 22 Oct 2021 03:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634899052; cv=none; d=google.com; s=arc-20160816; b=vbVO+lDTbCnn93rtMlIP1R16O616BuFj0zuZfm1h8V8uGzt6x2TLSGqTUp0E8jpW2e sMu67JEfruFfqVWz5i4fbH63NZ7uSzltiYe5X4CbXo+HJVHQAl67TPjQ3rQ5OIXjDNqJ YXUg0Wne6F8Phz7LOQLC7IaqE5W/vC2K7zbj9QxxtnWg/4Y4uvx9wJjpJTItVwke09zc 1uHvC8gjqGnsWUGfPZ/yM35geIeviV4fj6pf71BcpB7HpcHJDnH4VIEDXb6RrY+8XG9O bkBwlqmJF8IAhwxola58EcIKr6Ukoeqqe2QYWHe2EZePrB5cIOtin4BviwUBdy7bJELE AzSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RSTCiSbwVYK3JXFZpdrnrpnG1taZp3KDxq+pJGHOS/Y=; b=HoPx6U8SX17u81YUR+f142fmYUc3xPr6qDT31k01oImAaoOj1Brn4krKErBoCpzh4u zapMEX06CY9xG4CXokGYXDccUgH2CsGO++6nR6GBw8c8ce3h9YovyH7oeHXfs8cBAA7l hfJo95qQp1Iz9mP1gVH9HthHEk8GbB0ASg12hqFh3pX4opgJDy1uzOBEQi6Jg+YmuuS+ p32rGUTIOSc5HPZpb47GyrFWaJ5hKMIUNN6QZnuOkk1ThAliO5MpGiLAszVOLtnEgA6C ewigBjgdCRvW7Cd7Mm641ytouULK/8CfhFPcyO8NiLGOQK8jbo6oryFSIgrdDOl3jmUv 0lQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s5si12472888ejs.270.2021.10.22.03.37.09; Fri, 22 Oct 2021 03:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232767AbhJVKfv (ORCPT + 99 others); Fri, 22 Oct 2021 06:35:51 -0400 Received: from foss.arm.com ([217.140.110.172]:52574 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232721AbhJVKfs (ORCPT ); Fri, 22 Oct 2021 06:35:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B96BC13A1; Fri, 22 Oct 2021 03:33:30 -0700 (PDT) Received: from e113632-lin.cambridge.arm.com (e113632-lin.cambridge.arm.com [10.1.196.57]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 673CC3F70D; Fri, 22 Oct 2021 03:33:29 -0700 (PDT) From: Valentin Schneider To: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Will Deacon , Mark Rutland , Marc Zyngier , Thomas Gleixner , Sebastian Andrzej Siewior , Ard Biesheuvel Subject: [PATCH 3/3] irqchip/gic-v3-its: Limit memreserve cpuhp state lifetime Date: Fri, 22 Oct 2021 11:33:07 +0100 Message-Id: <20211022103307.1711619-4-valentin.schneider@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022103307.1711619-1-valentin.schneider@arm.com> References: <20211022103307.1711619-1-valentin.schneider@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The new memreserve cpuhp callback only needs to survive up until a point where every CPU in the system has booted once. Beyond that, it becomes a no-op and can be put in the bin. Signed-off-by: Valentin Schneider --- drivers/irqchip/irq-gic-v3-its.c | 23 ++++++++++++++++++++--- include/linux/irqchip/arm-gic-v3.h | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index a6a4af59205e..4ae9ae6b90fe 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -5206,6 +5206,15 @@ int its_cpu_init(void) } #ifdef CONFIG_EFI +static void rdist_memreserve_cpuhp_cleanup_workfn(struct work_struct *work) +{ + cpuhp_remove_state_nocalls(gic_rdists->cpuhp_memreserve_state); + gic_rdists->cpuhp_memreserve_state = CPUHP_INVALID; +} + +static DECLARE_WORK(rdist_memreserve_cpuhp_cleanup_work, + rdist_memreserve_cpuhp_cleanup_workfn); + static int its_cpu_memreserve_lpi(unsigned int cpu) { struct page *pend_page = gic_data_rdist()->pend_page; @@ -5226,7 +5235,7 @@ static int its_cpu_memreserve_lpi(unsigned int cpu) * invocation of this callback, or in a previous life before kexec. */ if (gic_data_rdist()->flags & RDIST_FLAGS_PENDTABLE_RESERVED) - return 0; + goto out; gic_data_rdist()->flags |= RDIST_FLAGS_PENDTABLE_RESERVED; @@ -5234,6 +5243,11 @@ static int its_cpu_memreserve_lpi(unsigned int cpu) paddr = page_to_phys(pend_page); WARN_ON(gic_reserve_range(paddr, LPI_PENDBASE_SZ)); +out: + /* This only needs to run once per CPU */ + if (cpumask_equal(&cpus_booted_once_mask, cpu_possible_mask)) + schedule_work(&rdist_memreserve_cpuhp_cleanup_work); + return 0; } #endif @@ -5421,13 +5435,14 @@ static void __init its_acpi_probe(void) static void __init its_acpi_probe(void) { } #endif -static int __init its_lpi_memreserve_init(void) +static int __init its_lpi_memreserve_init(struct rdists *rdists) { int state; if (!efi_enabled(EFI_CONFIG_TABLES)) return 0; + rdists->cpuhp_memreserve_state = CPUHP_INVALID; state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "irqchip/arm/gicv3/memreserve:online", its_cpu_memreserve_lpi, @@ -5435,6 +5450,8 @@ static int __init its_lpi_memreserve_init(void) if (state < 0) return state; + rdists->cpuhp_memreserve_state = state; + return 0; } @@ -5465,7 +5482,7 @@ int __init its_init(struct fwnode_handle *handle, struct rdists *rdists, if (err) return err; - err = its_lpi_memreserve_init(); + err = its_lpi_memreserve_init(rdists); if (err) return err; diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index 0dc34d7d735a..95479b315918 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -624,6 +624,7 @@ struct rdists { u64 flags; u32 gicd_typer; u32 gicd_typer2; + int cpuhp_memreserve_state; bool has_vlpis; bool has_rvpeid; bool has_direct_lpi; -- 2.25.1