Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3399967pxj; Tue, 11 May 2021 03:46:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXg1LaZAv1X8+cnlDAy70w5FhuP3NI+3fYMrf890zqvnhQlloo2TDIAti5CQIRwUC9mSJe X-Received: by 2002:a5d:8a10:: with SMTP id w16mr18727339iod.26.1620729982689; Tue, 11 May 2021 03:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620729982; cv=none; d=google.com; s=arc-20160816; b=zVFvk8mK2BOTpHkal1zVbJrjKGJMtBW1vAweVxde8bGe23zzM+BFP2b9TfMIIRWiyQ o/Gg9eZZZQ0ZbwNnDwbaza3rbBOsuGQwZi0JLJjq7X4cEwWV6S05Hu8VC/PbJ24126QN 6/GygcWkBcvvrT+NSAux4F1vFbD/1pr+JpcqmmV1vw0Bm3q+x1CZOxT9jLnyuzZmzi2a k40j9oR2H4S3Ea75BllywRiBfIxP3KnqqLdsAFZGPdc29E698ELrTpLnU0ZnJBQKF80t cSQmKgmeKaL4my0XKrt80VUN4MeWi8CQmNDDJI2cMNM3MaEaZBd2QSe/AHQ7sD6WW6pz NuRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=G6u/v5pBgRg/r9/xunKJA/aeWT5HHENr+pYBgEABwaM=; b=HG4R3n/kFlLA8ZTrfqVoIOgG2kAkZGXpkkdxDClL/akEMI+iwrmBNyrkHsKh/feSyI YnFm/UMzGlT7zp8QKo+p4CUd0mSp+1gkfN2xbyP5ZBYwnGRS8hhWfrjq6JQJTAzDke6l dxO5zp2miyoOjOVbrSuteketHfXAZMIl/nJ1DrqvZcutjImPTezrl3FS0avJQXftWaEi vsJfnS05GfcUFv4tUnBZ5aBoLKE4NZp/7n7Bld6KhBbuXR36kZbfOKuwmpYEnn/+ENoX XQ2gc3pTzIohtEtQ0bTHEOWi2kIHALwk2mUX1sTcW7WLl508MC4Beea69sg5FKxd8p/n m1Ug== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si18458377ilk.84.2021.05.11.03.46.10; Tue, 11 May 2021 03:46:22 -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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231300AbhEKKqi (ORCPT + 99 others); Tue, 11 May 2021 06:46:38 -0400 Received: from mail-oi1-f177.google.com ([209.85.167.177]:44740 "EHLO mail-oi1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbhEKKqg (ORCPT ); Tue, 11 May 2021 06:46:36 -0400 Received: by mail-oi1-f177.google.com with SMTP id d21so18587629oic.11; Tue, 11 May 2021 03:45:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G6u/v5pBgRg/r9/xunKJA/aeWT5HHENr+pYBgEABwaM=; b=q/4k+4OGGYRDa9kbEsfj1VEhPY/iot2u8WacJO58PfbR0lBc3dm55m0xRG6DeIbPH2 oi9ygkjp4xo9fr/oFCQha7/he5s3JOvf+QwD5/t8uI1NNSzudkLWYqjZeSs1CWTSF4LR F3e8upnpZ6a7ggux4tsHemuIEpyjXjBu0+4tX8A3peYfJlvsAIoD2gaUMlXlroKEVMS3 rfkCKzr9S5Gq4v5dQVD5ZNIJWCR8rVsLptTq0J8RdidzM5VF8wu8skEPdK+VLmH4Q++M THwYjA+5KfzJcuo/DOnl8LxnDGP/VuqL2QuSdHhhjTKgN7sUBR6/tulVvz9ATQkwoPU+ HEzw== X-Gm-Message-State: AOAM5308nATc1dNf0f/lUopDZLtXSnAXo7Teu2f9j/LycHLktQgpAsGs ksp4QLshuKeuXGWthEIVILlxnFW3HKNlE5IpsPs= X-Received: by 2002:a05:6808:90d:: with SMTP id w13mr6972892oih.71.1620729928220; Tue, 11 May 2021 03:45:28 -0700 (PDT) MIME-Version: 1.0 References: <20210426023941.729334-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210426023941.729334-4-sathyanarayanan.kuppuswamy@linux.intel.com> <97e14cdc-ea98-18b8-0c89-db52440a7716@linux.intel.com> <4fa40e7a-bcb2-db0f-8dc5-28728b14377d@linux.intel.com> <20210510172237.GU4032392@tassilo.jf.intel.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Tue, 11 May 2021 12:45:17 +0200 Message-ID: Subject: Re: [PATCH v3 3/3] x86/acpi, x86/boot: Add multiprocessor wake-up support To: "Kuppuswamy, Sathyanarayanan" Cc: "Rafael J. Wysocki" , Andi Kleen , Rafael J Wysocki , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Len Brown , Robert Moore , Erik Kaneda , ACPI Devel Maling List , "open list:ACPI COMPONENT ARCHITECTURE (ACPICA)" , Linux Kernel Mailing List , "the arch/x86 maintainers" , Sean Christopherson Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 10, 2021 at 11:15 PM Kuppuswamy, Sathyanarayanan wrote: > > > > On 5/10/21 10:24 AM, Rafael J. Wysocki wrote: > > The wakeup function can return an error when it is called for the > > second time on the same CPU. > > To do this, we can only maintain the wakeup status of the CPUs. Can > you check whether following physid_mask based status maintenance is > acceptable? It would work for me except for a couple of nits below. > --- a/arch/x86/kernel/acpi/boot.c > +++ b/arch/x86/kernel/acpi/boot.c > @@ -67,6 +67,7 @@ static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; > > static struct acpi_madt_multiproc_wakeup_mailbox *acpi_mp_wake_mailbox; > static u64 acpi_mp_wake_mailbox_paddr; > +static physid_mask_t apic_id_wakemap = PHYSID_MASK_NONE; > > #ifdef CONFIG_X86_IO_APIC > /* > @@ -347,6 +348,13 @@ static int acpi_wakeup_cpu(int apicid, unsigned long start_ip) > > acpi_mp_wake_mailbox_init(); > > + /* Check if the given CPU (apicid) is already awake */ The reason why is that the wakeup mechanism used here is only usable once per CPU by the spec, so I would add this information to the comment. Maybe something like "According to the ACPI specification (ACPI 6.4, Section ...), the mailbox-based wakeup mechanism cannot be used more than once for the same CPU, so avoid doing that." > + if (physid_isset(apicid, apic_id_wakemap)) { > + pr_err("APIC ID %x is already awake, so failed to wakeup\n", > + apicid); And I would reword the message like this "CPU already awake (APIC ID %x), skipping wakeup\n". > + return -EINVAL; > + } > + > if (!acpi_mp_wake_mailbox) Note, though, that instead of having this additional flag, you may as well create a mask that is fully populated initially and clear the IDs of the woken-up CPUs in it. Then, you'd only need one check here instead of two. > return -EINVAL; > > @@ -374,8 +382,18 @@ static int acpi_wakeup_cpu(int apicid, unsigned long start_ip) > while (READ_ONCE(acpi_mp_wake_mailbox->command) && timeout--) > cpu_relax(); > > - /* If timedout, return error */ > - return timeout ? 0 : -EIO; > + if (timeout) { > + /* > + * If the CPU wakeup process is successful, store the > + * status in apic_id_wakemap to prevent re-wakeup > + * requests. > + */ > + physid_set(apicid, apic_id_wakemap); > + return 0; > + } > + > + /* If timed out (timeout == 0), return error */ > + return -EIO; > } > > > -- > Sathyanarayanan Kuppuswamy > Linux Kernel Developer