From nobody Mon Feb 9 09:33:06 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26E26187332; Fri, 17 Oct 2025 02:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669331; cv=none; b=p106G71RoiccaTtBLBkPNj4pLx9Jtyit2cbH6ZtGmr4LtSxA4dfTCxI7hvW8RZMaHahgJz9mag4oS9JsFIweje0UhiGFWh1uK2yiTUfinQa1k8957efSRD/2hLiiCEcfKIe1XkO/0kKcOcJPMuF8aSFO3CzUsFniomp7XV9Yrwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760669331; c=relaxed/simple; bh=LIqUV6VOVMcoYUSWfWyv8zoYNppCVbs3oUzzRQpEXEg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AGtJGMAHaaAX9zjiHV/4NbR0/nTMX6smFOFnH5hOiOHYkRO1DMzuuHrlySfSH1wbaMTviaeFylKS8CMlMxgjh63KL3vssXnRU6adtvQLvDpy47MJTqnMAkDOn421ywUuNlHSFPTXOqozQqThbOZflewSDuXLaRsF3R0FLoEWpoU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=T/nPod4+; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="T/nPod4+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1760669330; x=1792205330; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=LIqUV6VOVMcoYUSWfWyv8zoYNppCVbs3oUzzRQpEXEg=; b=T/nPod4+MsuIJPkraaSxA9tb+BLI9pxcaBArtzJ5XrrChgZNbKwxMc2P B0C12NTqHjRNc4CxPtxzgzRu3uq/UiHjAJrxCeAMhvDlgsSk9/mD0IETB jnmOdZeVcA3xBJzcfYWNnA0lxx1W9b8YGVbDeLJcKVvJOBHtm1v8TQArt lHOJ2TZ8rKBVIzTVlea/cJxqz9hv3gUW5DwIFSOmvbweDXFud6AgXshhV 6bJVA4sAUw20joIrKVgSYN/KdYZYiER2GQ5bUGHNsHytGPinFMRUIpp7y tdb8uF9CFrLW07Hsoaq1iW6oQYkYjVrkK5R2uARnpUKn6rUguq00Sr5N2 w==; X-CSE-ConnectionGUID: +moL93ZpSVOaPEMTNgnLNw== X-CSE-MsgGUID: VgYWD3JsToWUtgo5/vsQ3Q== X-IronPort-AV: E=McAfee;i="6800,10657,11584"; a="80321894" X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="80321894" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:48 -0700 X-CSE-ConnectionGUID: gdYNjOJRSKKgN8E2Uinm6Q== X-CSE-MsgGUID: F/5yH4ydS+aUmw5e+aQz6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.19,234,1754982000"; d="scan'208";a="219776543" Received: from unknown (HELO [172.25.112.21]) ([172.25.112.21]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2025 19:48:47 -0700 From: Ricardo Neri Date: Thu, 16 Oct 2025 19:57:23 -0700 Subject: [PATCH v6 01/10] x86/acpi: Add helper functions to setup and access the wakeup mailbox Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251016-rneri-wakeup-mailbox-v6-1-40435fb9305e@linux.intel.com> References: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> In-Reply-To: <20251016-rneri-wakeup-mailbox-v6-0-40435fb9305e@linux.intel.com> To: x86@kernel.org, Krzysztof Kozlowski , Conor Dooley , Rob Herring , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Michael Kelley , "Rafael J. Wysocki" Cc: Saurabh Sengar , Chris Oo , "Kirill A. Shutemov" , linux-hyperv@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , "Rafael J. Wysocki" , Ricardo Neri X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1760669902; l=4248; i=ricardo.neri-calderon@linux.intel.com; s=20250602; h=from:subject:message-id; bh=LIqUV6VOVMcoYUSWfWyv8zoYNppCVbs3oUzzRQpEXEg=; b=qy4W3Ui4SabjPrVoIccHWHv3fyFCugOxl9VAGFCq62NxCXwgqYna+EdYAKn9VuPgyPXSrORuw ubpVWxpR+enB3qGLWHRkm/8JOABuCnHv/fTdVEdZ3fWFWGIyI29cpf0 X-Developer-Key: i=ricardo.neri-calderon@linux.intel.com; a=ed25519; pk=NfZw5SyQ2lxVfmNMaMR6KUj3+0OhcwDPyRzFDH9gY2w= In preparation to move the functionality to wake secondary CPUs up from the ACPI code, add two helper functions. The function acpi_setup_mp_wakeup_mailbox() stores the physical address of the mailbox and updates the wakeup_secondary_cpu_64() APIC callback. There is a slight change in behavior: now the APIC callback is updated before configuring CPU hotplug offline behavior. This is fine as the APIC callback continues to be updated unconditionally, regardless of the restriction on CPU offlining. The function acpi_madt_multiproc_wakeup_mailbox() returns a pointer to the mailbox. Use this helper function only in the portions of the code for which the variable acpi_mp_wake_mailbox will be out of scope once it is relocated out of the ACPI directory. The wakeup mailbox is only supported for CONFIG_X86_64 and needed only with CONFIG_SMP=3Dy. Reviewed-by: Dexuan Cui Acked-by: Rafael J. Wysocki Signed-off-by: Ricardo Neri Acked-by: Rafael J. Wysocki (Intel) --- Changes since v5: - Fixed grammar error in the subject of the patch. (Rafael) - Added Acked-by tag from Rafael. Thanks! - Added Reviewed-by tag from Dexuan. Thanks! Changes since v4: - None Changes since v3: - Squashed the two first patches of the series into one, both introduce helper functions. (Rafael) - Renamed setup_mp_wakeup_mailbox() as acpi_setup_mp_wakeup_mailbox(). (Rafael) - Dropped the function prototype for !CONFIG_X86_64. (Rafael) Changes since v2: - Introduced this patch. Changes since v1: - N/A --- arch/x86/include/asm/smp.h | 3 +++ arch/x86/kernel/acpi/madt_wakeup.c | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index 22bfebe6776d..47ac4381a805 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -149,6 +149,9 @@ static inline struct cpumask *cpu_l2c_shared_mask(int c= pu) return per_cpu(cpu_l2c_shared_map, cpu); } =20 +void acpi_setup_mp_wakeup_mailbox(u64 addr); +struct acpi_madt_multiproc_wakeup_mailbox *acpi_get_mp_wakeup_mailbox(void= ); + #else /* !CONFIG_SMP */ #define wbinvd_on_cpu(cpu) wbinvd() static inline void wbinvd_on_all_cpus(void) diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b/arch/x86/kernel/acpi/madt= _wakeup.c index 6d7603511f52..c3ac5ecf3e7d 100644 --- a/arch/x86/kernel/acpi/madt_wakeup.c +++ b/arch/x86/kernel/acpi/madt_wakeup.c @@ -37,6 +37,7 @@ static void acpi_mp_play_dead(void) =20 static void acpi_mp_cpu_die(unsigned int cpu) { + struct acpi_madt_multiproc_wakeup_mailbox *mailbox =3D acpi_get_mp_wakeup= _mailbox(); u32 apicid =3D per_cpu(x86_cpu_to_apicid, cpu); unsigned long timeout; =20 @@ -46,13 +47,13 @@ static void acpi_mp_cpu_die(unsigned int cpu) * * BIOS has to clear 'command' field of the mailbox. */ - acpi_mp_wake_mailbox->apic_id =3D apicid; - smp_store_release(&acpi_mp_wake_mailbox->command, + mailbox->apic_id =3D apicid; + smp_store_release(&mailbox->command, ACPI_MP_WAKE_COMMAND_TEST); =20 /* Don't wait longer than a second. */ timeout =3D USEC_PER_SEC; - while (READ_ONCE(acpi_mp_wake_mailbox->command) && --timeout) + while (READ_ONCE(mailbox->command) && --timeout) udelay(1); =20 if (!timeout) @@ -227,7 +228,7 @@ int __init acpi_parse_mp_wake(union acpi_subtable_heade= rs *header, =20 acpi_table_print_madt_entry(&header->common); =20 - acpi_mp_wake_mailbox_paddr =3D mp_wake->mailbox_address; + acpi_setup_mp_wakeup_mailbox(mp_wake->mailbox_address); =20 if (mp_wake->version >=3D ACPI_MADT_MP_WAKEUP_VERSION_V1 && mp_wake->header.length >=3D ACPI_MADT_MP_WAKEUP_SIZE_V1) { @@ -243,7 +244,16 @@ int __init acpi_parse_mp_wake(union acpi_subtable_head= ers *header, acpi_mp_disable_offlining(mp_wake); } =20 + return 0; +} + +void __init acpi_setup_mp_wakeup_mailbox(u64 mailbox_paddr) +{ + acpi_mp_wake_mailbox_paddr =3D mailbox_paddr; apic_update_callback(wakeup_secondary_cpu_64, acpi_wakeup_cpu); +} =20 - return 0; +struct acpi_madt_multiproc_wakeup_mailbox *acpi_get_mp_wakeup_mailbox(void) +{ + return acpi_mp_wake_mailbox; } --=20 2.43.0