From patchwork Wed Sep 11 04:27:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1983624 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X3SH04jHpz1y1C for ; Wed, 11 Sep 2024 14:27:56 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1soExI-0003vx-Um; Wed, 11 Sep 2024 04:27:48 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1soExH-0003tw-Im for kernel-team@lists.ubuntu.com; Wed, 11 Sep 2024 04:27:47 +0000 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 2FE393F12E for ; Wed, 11 Sep 2024 04:27:47 +0000 (UTC) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-7db1762d70fso31409a12.2 for ; Tue, 10 Sep 2024 21:27:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726028865; x=1726633665; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CunWbNwDUWaGJJPWVl6dpJfT+aHH9sr1VrwpfRJXNU0=; b=cd2mNP5ts4iIlywGf2YeVU68vqQTqW1LGSX0jNcszOO1/NPbHJmiUdwoFnZpBB3jze SPXKe4b8h72ILD5Efovo/c1vdHL1kd4oyN63C/1JOHZBPUVexQT6tFe42xZEl9SWV0+/ 1n7GokEofzT4mR4AN6ACZtLTcsUOKg15BrKT0Ux0IdKDRSstKBSkySAMrqgIpdWlmd1i HUTMBOOzccOaheYu9cOtXxF8P8Di7ggJrVeaTxWhdD9F9FC0q0iPfeimB+vfiJbhxoND rDcI/ryKqZPrZJ0UiJbAybcVDp4Q+TqxBhjy8diQ6GjgLPc8rLWEtCo+YevNwA1zy7LB zfQg== X-Gm-Message-State: AOJu0YxgiREUnH8N9FkQIcauZ4hRdgX9hROSPARM9IQU0y8zyLC4M7A9 grFCHije6CndMVah57TzD/eqEhTKwvwsib/LK2+VAAYlwSHKWhB9xl+ypIdIODFz4y1VzldMEXv SNLyL4IUNr3LnjdEyR5FDOgyANVNGk466CKMnfkUPhH1BlUhQSppjZ0tbO9ES1iZxi1N8yK4PYv OQ0GV0ZmLX X-Received: by 2002:a05:6300:404c:b0:1cf:460d:8b75 with SMTP id adf61e73a8af0-1cf5e041762mr5165024637.7.1726028865464; Tue, 10 Sep 2024 21:27:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHWvvuDENHM1LtXrUQxszRaplYYoFitJ0wvBTOzoCHrf56FbKAHSOnJai+Gt+T12YsvP3dJiQ== X-Received: by 2002:a05:6300:404c:b0:1cf:460d:8b75 with SMTP id adf61e73a8af0-1cf5e041762mr5164992637.7.1726028865031; Tue, 10 Sep 2024 21:27:45 -0700 (PDT) Received: from canonical.com ([189.78.78.86]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-719090af969sm2118959b3a.183.2024.09.10.21.27.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2024 21:27:44 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [SRU][focal:linux-gcp][PATCH 04/17] ACPI: processor: Export function to claim _CST control Date: Wed, 11 Sep 2024 01:27:13 -0300 Message-Id: <20240911042726.959018-5-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240911042726.959018-1-marcelo.cerri@canonical.com> References: <20240911042726.959018-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: "Rafael J. Wysocki" BugLink: https://bugs.launchpad.net/bugs/2080324 The intel_idle driver will be modified to use ACPI _CST subsequently and it will need to notify the platform firmware of that if acpi_gbl_FADT.cst_control is set, so add a routine for this purpose, acpi_processor_claim_cst_control(), to acpi_processor.c (so that it is always present which is required by intel_idle) and export it to allow the ACPI processor driver (which is modular) to call it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki (cherry picked from commit bc94638886ab21f8247d3f7f39573d3feb7d8284) Signed-off-by: Marcelo Henrique Cerri --- drivers/acpi/acpi_processor.c | 25 +++++++++++++++++++++++++ drivers/acpi/processor_idle.c | 12 ++++-------- include/linux/acpi.h | 6 ++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 2c4dda0787e8..8a53f3c5b70e 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -705,3 +705,28 @@ void __init acpi_processor_init(void) acpi_scan_add_handler_with_hotplug(&processor_handler, "processor"); acpi_scan_add_handler(&processor_container_handler); } + +#ifdef CONFIG_ACPI_PROCESSOR_CSTATE +/** + * acpi_processor_claim_cst_control - Request _CST control from the platform. + */ +bool acpi_processor_claim_cst_control(void) +{ + static bool cst_control_claimed; + acpi_status status; + + if (!acpi_gbl_FADT.cst_control || cst_control_claimed) + return true; + + status = acpi_os_write_port(acpi_gbl_FADT.smi_command, + acpi_gbl_FADT.cst_control, 8); + if (ACPI_FAILURE(status)) { + pr_warn("ACPI: Failed to claim processor _CST control\n"); + return false; + } + + cst_control_claimed = true; + return true; +} +EXPORT_SYMBOL_GPL(acpi_processor_claim_cst_control); +#endif /* CONFIG_ACPI_PROCESSOR_CSTATE */ diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c index ab21643e0685..34cc23abd038 100644 --- a/drivers/acpi/processor_idle.c +++ b/drivers/acpi/processor_idle.c @@ -966,7 +966,6 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr) static inline void acpi_processor_cstate_first_run_checks(void) { - acpi_status status; static int first_run; if (first_run) @@ -978,13 +977,10 @@ static inline void acpi_processor_cstate_first_run_checks(void) max_cstate); first_run++; - if (acpi_gbl_FADT.cst_control && !nocst) { - status = acpi_os_write_port(acpi_gbl_FADT.smi_command, - acpi_gbl_FADT.cst_control, 8); - if (ACPI_FAILURE(status)) - ACPI_EXCEPTION((AE_INFO, status, - "Notifying BIOS of _CST ability failed")); - } + if (nocst) + return; + + acpi_processor_claim_cst_control(); } #else diff --git a/include/linux/acpi.h b/include/linux/acpi.h index c708fd831565..f80bd32daa29 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -283,6 +283,12 @@ static inline bool invalid_phys_cpuid(phys_cpuid_t phys_id) /* Validate the processor object's proc_id */ bool acpi_duplicate_processor_id(int proc_id); +/* Processor _CTS control */ +#ifdef CONFIG_ACPI_PROCESSOR_CSTATE +bool acpi_processor_claim_cst_control(void); +#else +static inline bool acpi_processor_claim_cst_control(void) { return false; } +#endif #ifdef CONFIG_ACPI_HOTPLUG_CPU /* Arch dependent functions for cpu hotplug support */