Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1781073rdb; Wed, 31 Jan 2024 08:53:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZnFaOztB0GnERxH1giA0sbqaFP5oMcvQ/6Yoqno9B9c4dtCgAeKPwo8Mw2KfBSOyBZFfm X-Received: by 2002:a05:620a:4d7:b0:783:da62:9b09 with SMTP id 23-20020a05620a04d700b00783da629b09mr2153390qks.73.1706719983419; Wed, 31 Jan 2024 08:53:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706719983; cv=pass; d=google.com; s=arc-20160816; b=WdeTIVetQ0QEYQTNr1ZEj1VCKND5jf4M6tzeFetKKx3uKjkgXVPIgNPNyXP32g4exA bmRYnGDkKnR+YMiL4LnQlYt11bpGhw2L1VtyZdj07lu6nPz1OkAojUJgVecfNbIvtOF0 NpjBvDuM043Zc+EDCzj6UyyGUABvcAKs3aZOBeueKHGkBzT0GYgO/eiDtvvR/h5Yz7Zy 3VI8m89dioZg2a4e3zaEuu8rYwyiE0cgUbuWyrM5BXte/1x+qAmf0XN4wCZVF81+inut 704IF38v4Pngf+xIkKj+E4IihxcSbuXPe+3t8i/XRLO8+OiOd1GJA32pTVM8lBDSiybm 2JpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:sender:message-id:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:subject:cc:to:from:references:in-reply-to :dkim-signature; bh=o6Glb67KDkye22sh0IgMCxcnl6KGrDkZ8W668rj+oDE=; fh=3Mqee05QkW3EJy3cn3xFigY+lOivKXpcoqwr8W3cQJM=; b=FKYvSpWyl6Waog1EbrTK2srEjxtVtyOZkAYTaF4XTOoorMO1JoGb2RR5dSlsaPFyXa uhGX4Sj8MeZwMIYwwo03IXJaAO4HUJhHMt9P7dYqoLyHSGqlqA9Z5L2q+DQY4JHFOmDE QW2pSS3XDhQLKj0Wab9VENu1OH6SWqBUudZ1Z8rERwfkF2WX6EX27lel8uWbCDIb/vDL YQWZq16KLd1tRNTuM5ACzMKJaH8rqhpvHyLIG5x3Hd0WPE99Z+01oZEd4e7UxI396jRn OgE1zfXqWLTrzH4zOtFRe+KP980zoLEd+8LSLbPd0gmuaHjY7Kj4ixwCXupHXi7YE+Zv wAaQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=uNwhdf+a; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-46833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk X-Forwarded-Encrypted: i=1; AJvYcCXDeZvf4haxqntZkVAOa3GpPhK9Pf/6dr3wQWVawukiiCT0moedV9cbkxmqCsohc+jQ/93OBvw4D0fZSl/5OplWpX+oQEQh38L5UcYd5g== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j8-20020a05620a000800b00783f4c38aa1si8719556qki.151.2024.01.31.08.53.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 08:53:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=uNwhdf+a; arc=pass (i=1 dkim=pass dkdomain=armlinux.org.uk dmarc=pass fromdomain=armlinux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-46833-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46833-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CA7BB1C20A1F for ; Wed, 31 Jan 2024 16:53:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5FB5134738; Wed, 31 Jan 2024 16:50:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="uNwhdf+a" Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [78.32.30.218]) (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 0D41912BF2B; Wed, 31 Jan 2024 16:50:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.32.30.218 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706719833; cv=none; b=GRFSj0+aEvXuQ3ptdkXaBWpZzeBalu5GTUz7k77WX/qyiXjpKv26CvDud1JbCdrwnOaKkaPOsLhT4SSte521lbhDjAX6bLLkovVll5sj1m1wZjyKI+zEnCs5faM5yEuK8z7/C+BOuONpY0KWqDPxbh8O6qdPuVGHBIuDxUDzD5g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706719833; c=relaxed/simple; bh=jdTC5mRwIFwrOo7IhIQS0r7fT5YPS0GVHFuaypNbK7g=; h=In-Reply-To:References:From:To:Cc:Subject:MIME-Version: Content-Disposition:Content-Type:Message-Id:Date; b=FpGaKjOdq/SCHW9AeojaZnn3JJ6d6jIUg2i+cHsFQZ15Ln32yqQ1pyV3wQ5AXPSOzHZBDXKueft1opBx5brsbhW6jxBMmTwkNal4fwjyoSfnno2Hkfmo3gCsRhnH2JQ3f+z+mTKZShzzig27m8eIe2wQZHRRVeipeAeiu3m8dTs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk; spf=none smtp.mailfrom=armlinux.org.uk; dkim=pass (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b=uNwhdf+a; arc=none smtp.client-ip=78.32.30.218 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=armlinux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=o6Glb67KDkye22sh0IgMCxcnl6KGrDkZ8W668rj+oDE=; b=uNwhdf+aQwGXAoj/8ZR+IMfI9G gC+e/IPVfipWz9zoMxQnmDU1wMD4Wx2H9YhnkbIru2iRYmjXSqC6YJjabWEAVfKZv2VyX+1bufgob a03mwaF1+NJMSH56mQGM6CHD8SZ/dYwhkgxoxfV3Y0zLK+/iZ7DsCwTUha7E56wuwuVdTFVub/aib w31vNUojMuuBmF/Y681Z0FKrz7qC2vhNgWVWaIobSxmmDDkJ1hv6kwwkhwmnK37vnesZOocvR36WH uffGiC9v4wA3huUOmjHMYk7Eec+aS2R8DqrjFePvfj831B00NlS/t0ycISPjoxCBiYVaX5XbhMqpV 7OL4sDhg==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:35768 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rVDmz-0003Uk-2B; Wed, 31 Jan 2024 16:50:18 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1rVDmu-0027Ys-An; Wed, 31 Jan 2024 16:50:12 +0000 In-Reply-To: References: From: Russell King (Oracle) To: linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kvmarm@lists.linux.dev, x86@kernel.org, acpica-devel@lists.linuxfoundation.org, linux-csky@vger.kernel.org, linux-doc@vger.kernel.org, linux-ia64@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Salil Mehta , Jean-Philippe Brucker , jianyong.wu@arm.com, justin.he@arm.com, James Morse , Jonathan Cameron , "Rafael J. Wysocki" Subject: [PATCH RFC v4 07/15] ACPI: Check _STA present bit before making CPUs not present Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" Message-Id: Sender: Russell King Date: Wed, 31 Jan 2024 16:50:12 +0000 From: James Morse When called acpi_processor_post_eject() unconditionally make a CPU not-present and unregisters it. To add support for AML events where the CPU has become disabled, but remains present, the _STA method should be checked before calling acpi_processor_remove(). Rename acpi_processor_post_eject() acpi_processor_remove_possible(), and check the _STA before calling. Adding the function prototype for arch_unregister_cpu() allows the preprocessor guards to be removed. After this change CPUs will remain registered and visible to user-space as offline if buggy firmware triggers an eject-request, but doesn't clear the corresponding _STA bits after _EJ0 has been called. Signed-off-by: James Morse Tested-by: Miguel Luis Tested-by: Vishnu Pajjuri Tested-by: Jianyong Wu Reviewed-by: Jonathan Cameron Signed-off-by: Russell King (Oracle) --- Changes since RFC v3: * Move IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU) into separate patch. --- drivers/acpi/acpi_processor.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 5351095b6968..77d47e6c2474 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -458,16 +458,13 @@ static int acpi_processor_add(struct acpi_device *device, } /* Removal */ -static void acpi_processor_post_eject(struct acpi_device *device) +static void acpi_processor_make_not_present(struct acpi_device *device) { struct acpi_processor *pr; if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_CPU)) return; - if (!device || !acpi_driver_data(device)) - return; - pr = acpi_driver_data(device); if (pr->id >= nr_cpu_ids) goto out; @@ -504,6 +501,29 @@ static void acpi_processor_post_eject(struct acpi_device *device) kfree(pr); } +static void acpi_processor_post_eject(struct acpi_device *device) +{ + struct acpi_processor *pr; + unsigned long long sta; + acpi_status status; + + if (!device) + return; + + pr = acpi_driver_data(device); + if (!pr || pr->id >= nr_cpu_ids || invalid_phys_cpuid(pr->phys_id)) + return; + + status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); + if (ACPI_FAILURE(status)) + return; + + if (cpu_present(pr->id) && !(sta & ACPI_STA_DEVICE_PRESENT)) { + acpi_processor_make_not_present(device); + return; + } +} + #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC bool __init processor_physically_present(acpi_handle handle) { -- 2.30.2