From patchwork Mon Feb 26 16:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 206808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2214856dyb; Mon, 26 Feb 2024 09:14:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWjX9hFOSal3KTNtjmaUQfW4aaP5376UZ1g4hF+UpDU9BUeJJOrXiGn0msiQGVRMKh0ycOGWD2ZqJyBxvrP6EloNcvecw== X-Google-Smtp-Source: AGHT+IEACs5ohzmzxmXIt/UPMqvWuXA5HOZyW4i4Xkm104AdSUn5JE2Y+0kUvEotMI30hv3tNgMR X-Received: by 2002:a17:903:191:b0:1dc:b323:6f97 with SMTP id z17-20020a170903019100b001dcb3236f97mr1055089plg.27.1708967644233; Mon, 26 Feb 2024 09:14:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708967644; cv=pass; d=google.com; s=arc-20160816; b=k+sCZPc+jYIxH5WU+Mm/N1zEnwCly4B81GjeoDrMU5rGeOYexaZErlwNl1ECgJ5PQl lGDwWwyImhgiJwLuvXI+MTmHC4f0zACJTVPX/SMTiQjGkzog2Go82wxVlffg4V9aq5yg 8Z+Hre5pF/nMeghzYS8n7q1rFG1gBlHmWvzxF1wQXVnvVcxNJ2RzEL0SZUXYuoh56eoz Wv9/jnrXYgZgUMc+6w9aIUoqV+Bv3BA5oL3WV4vdpDD+b/pXkJI6MCGL5xQGw0v/VN+1 OfuniMSKGwd5b2n/Yu1xzF7l+yX43Vgi2QZTVCH1s7l7G5HhfMX6Y2tSJ/jCaU5hrNbZ xLGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=js50eI+cbhWERBxDwI/51ztGdqnVIEkB3Xj64/h+BuA=; fh=s5Fc0MEg8Xcp85xwyejK4S4zs7msQB7g1OY0X3YpOJg=; b=NFAKuOtY6BM4mTuud+jd68qj9y29BARs0dqDFcoYL9QHoAhpoSlmyyHJUum76s9mGB Qnkc6Sh7aNozvjO6tED9z1Z0UMgHuRY9uTrHQ91C/LKVbFWzt9dLiwGoDpqIpC1bTVjX DSrgc4QahpvLjbG1RFiEWWgtSx/e0rYaoAaf1P9mq+rxOtRC91bL8+qDjRKK2X3/fhM2 ayoS2Xp/KG8QoiLUE2htKNDYSHzVJv6NAbMlMVePCCD3hCLxKaHs6QFh5uBhjEoI1PC6 JqObc8ce3UaCoJEhifF2fHRMkqoct/TGaHsy4uBGOPd3o0BXvhCcNvG2y/VR9NAMfhnQ kZUw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-81932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81932-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s4-20020a170902b18400b001dca8522561si1396951plr.638.2024.02.26.09.14.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:14:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-81932-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81932-ouuuleilei=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9985FB26DBA for ; Mon, 26 Feb 2024 16:48:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8C8012F37E; Mon, 26 Feb 2024 16:47:11 +0000 (UTC) Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (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 CC7E912C81A; Mon, 26 Feb 2024 16:47:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966026; cv=none; b=kpVvZJstz5Ip5+exIos4NhvBRirhMuRYUkAT9tbuw9LuHbMEi39qu5b7bI+/n4cmAGahqP3ktwvqKNXmSkCTCEasgZkGBPo31s5qqrNG/vFby0Jqr8w0scnO1IoxWvqvuNgyZvHOX+R1B4awnSd9kSqUlVxOAu8FrvxthFPPbvU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966026; c=relaxed/simple; bh=H6jbNlhYPKxICX9pBOmoUAMwvEsvPiIS9SR2byJFPLg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gYAqqHcsh9wtym5F0CvQNmx0vqcb/gavkbweCrJ4Fzy7yaXcTKW9CtF82G25mtawTkm4/cCuW9RLTuglv4hlIsN4u7jKqbHrfjGM3p+3y7jwVzPyga80mHJFgfTG/wDdnNV22rCLdekOW7PXK43szPa3fAALpffub02Qsh9akEQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.4.0) id 109f2822a4f54781; Mon, 26 Feb 2024 17:46:55 +0100 Received: from kreacher.localnet (unknown [195.136.19.94]) (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 cloudserver094114.home.pl (Postfix) with ESMTPSA id 4415566A4D4; Mon, 26 Feb 2024 17:46:55 +0100 (CET) From: "Rafael J. Wysocki" To: Linux ACPI , Jonathan Cameron Cc: LKML , Mika Westerberg , "Rafael J. Wysocki" , "Russell King (Oracle)" Subject: [PATCH v2 3/5] ACPI: scan: Make acpi_processor_add() check the device enabled bit Date: Mon, 26 Feb 2024 17:40:52 +0100 Message-ID: <3283809.44csPzL39Z@kreacher> In-Reply-To: <6021126.lOV4Wx5bFT@kreacher> References: <6021126.lOV4Wx5bFT@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrgedvgdeltdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpeektddvveeijeekveekvdffieffheeitdehkeekfeeiheffkefgledtheelhedvudenucffohhmrghinhepuhgvfhhirdhorhhgnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepiedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehjohhnrghthhgrnhdrtggrmhgvrhhonheshhhurgifvghirdgtohhmpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhhikhgrrdifvghsthgv rhgsvghrgheslhhinhhugidrihhnthgvlhdrtghomhdprhgtphhtthhopehrrghfrggvlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugiesrghrmhhlihhnuhigrdhorhhgrdhukh X-DCC--Metrics: v370.home.net.pl 1024; Body=6 Fuz1=6 Fuz2=6 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791982456964829500 X-GMAIL-MSGID: 1791982456964829500 From: Rafael J. Wysocki Modify acpi_processor_add() return an error if _STA returns the enabled bit clear for the given processor device, so as to avoid using processors that don't decode their resources, as per the ACPI specification. [1] Link: https://uefi.org/specs/ACPI/6.5/06_Device_Configuration.html#sta-device-status # [1] Signed-off-by: Rafael J. Wysocki --- v1 -> v2: * Move acpi_device_is_enabled() to this patch. * Change patch ordering. * Do not check the "functional" _STA bit in acpi_device_is_present(). --- drivers/acpi/acpi_processor.c | 3 +++ drivers/acpi/internal.h | 1 + drivers/acpi/scan.c | 5 +++++ 3 files changed, 9 insertions(+) Index: linux-pm/drivers/acpi/internal.h =================================================================== --- linux-pm.orig/drivers/acpi/internal.h +++ linux-pm/drivers/acpi/internal.h @@ -121,6 +121,7 @@ int acpi_device_setup_files(struct acpi_ void acpi_device_remove_files(struct acpi_device *dev); void acpi_device_add_finalize(struct acpi_device *device); void acpi_free_pnp_ids(struct acpi_device_pnp *pnp); +bool acpi_device_is_enabled(const struct acpi_device *adev); bool acpi_device_is_present(const struct acpi_device *adev); bool acpi_device_is_battery(struct acpi_device *adev); bool acpi_device_is_first_physical_node(struct acpi_device *adev, Index: linux-pm/drivers/acpi/acpi_processor.c =================================================================== --- linux-pm.orig/drivers/acpi/acpi_processor.c +++ linux-pm/drivers/acpi/acpi_processor.c @@ -381,6 +381,9 @@ static int acpi_processor_add(struct acp struct device *dev; int result = 0; + if (!acpi_device_is_enabled(device)) + return -ENODEV; + pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); if (!pr) return -ENOMEM; Index: linux-pm/drivers/acpi/scan.c =================================================================== --- linux-pm.orig/drivers/acpi/scan.c +++ linux-pm/drivers/acpi/scan.c @@ -1945,6 +1945,11 @@ bool acpi_device_is_present(const struct return adev->status.present || adev->status.functional; } +bool acpi_device_is_enabled(const struct acpi_device *adev) +{ + return adev->status.present && adev->status.enabled; +} + static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler, const char *idstr, const struct acpi_device_id **matchid)