Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2935029pxj; Mon, 10 May 2021 14:18:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7oElrkFwhvkVGnUKXDy9bJT8a6GVESNt4REHpFqEL4BubsUgbYTumOuvPRKUNVgeT2BXh X-Received: by 2002:a17:907:399:: with SMTP id ss25mr28196565ejb.134.1620681539009; Mon, 10 May 2021 14:18:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620681539; cv=none; d=google.com; s=arc-20160816; b=dn/f/HhjQXjSMMR4IV+SAAIA2ORVJeJgFN88xNPlyw3nT/GW9lx1fSFlHKqEfp9iTi Ck82FZ77nZ8A2Gebe/kKM2UpRHT94OZHLiCm6X1zXKcnb29q0+NxuG8pVD/bdkseMbSN ICgtyVrsGcVtyF4xmtZo2VPyhMT9rXiEXscW1778Z2FSrHqif6msJwklY/Q8E8Ftr3JB wyjP7wx/dA3IZMLtcV6xZ4ZjtzG7DJ8u8cO7drjoiTzv5pldhb9dPY04d3RUo/TFxrfU 2+Y98Kv+s4iWdHtIS4CalYR/xV2MV9aW40hoCuS6GYQBCfbsFEu5fJjmXTVw2cZ8ZZNh QD/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=GoTzW4kp/boq5AgWyv4pdEfR0I9vjeKyKxYy/D2DTJw=; b=QONCcoyGMMlo47algmRdBhfUmLwS+QIiEiHR8vM5Nvq5Ea6Rau8DqWHuyFf3YJEQxI 2UAtkUXt2aZJM3+hkxN5FWIK+ajj+DFjHpNKUthdu/Ibir0MU2UL7hgB/J3QhI6lZDTB SBwMJZN/cn1700eAJIhkEEt5snLvqRj+QmIoy1NvS7gLznRv2BwszIYmKzsKj34QUPas NMhrVuvrSm13/tU+ls2G6Rm02mNEwGio5S5UEEt9HbOrdo6dSv42Srz2pD99BIc8aH3i BoMMs0VhwZMeTl7OQ3c0LRlepbZuVjUOUvdmT4mOdzJKYUrNXrvpAou/olt1cDi5eoC7 WuFw== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k12si14682862edr.115.2021.05.10.14.18.35; Mon, 10 May 2021 14:18:58 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232082AbhEJVQo (ORCPT + 99 others); Mon, 10 May 2021 17:16:44 -0400 Received: from mga14.intel.com ([192.55.52.115]:45546 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231513AbhEJVQl (ORCPT ); Mon, 10 May 2021 17:16:41 -0400 IronPort-SDR: ecENmbDRyXll9+PZnfYA0vsBspDsd4YXYtWsegyLRC9K4T3VcpgVPE1MkEcUQmmwB4XTiKAgFi Z8tumezBIeog== X-IronPort-AV: E=McAfee;i="6200,9189,9980"; a="198967440" X-IronPort-AV: E=Sophos;i="5.82,288,1613462400"; d="scan'208";a="198967440" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2021 14:15:33 -0700 IronPort-SDR: 58WND2tgoU/dRxyOi3LBPnEIt1gw3O3ZPDFupLGoKUvC1YHpM0pz7dkmtZ3OAIKRKL03mFCBQb KcS663lLOZfA== X-IronPort-AV: E=Sophos;i="5.82,288,1613462400"; d="scan'208";a="609240214" Received: from kcmorris-mobl1.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.213.165.53]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2021 14:15:31 -0700 Subject: Re: [PATCH v3 3/3] x86/acpi, x86/boot: Add multiprocessor wake-up support To: "Rafael J. Wysocki" , Andi Kleen Cc: 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 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> From: "Kuppuswamy, Sathyanarayanan" Message-ID: Date: Mon, 10 May 2021 14:15:29 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? --- 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 */ + if (physid_isset(apicid, apic_id_wakemap)) { + pr_err("APIC ID %x is already awake, so failed to wakeup\n", + apicid); + return -EINVAL; + } + if (!acpi_mp_wake_mailbox) 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