Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2136744lqa; Tue, 30 Apr 2024 09:02:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXX10kOzxVQbMOg4U7IZylhHGw90Ol+YtpsBKapZFwM7tAjZwr0eLGRh96BFh15kIbgHaFTVehqWxT+LeGVjxUJ0gngAyxUC2uHqHWZmQ== X-Google-Smtp-Source: AGHT+IG7FT+1h1ODG6cxrch0dQiUsc1KCoNSJeUYcMWSiwqIamq/aU8E/w6LVuIV0CgJqKXutoFe X-Received: by 2002:a05:620a:271a:b0:790:efae:1bd with SMTP id b26-20020a05620a271a00b00790efae01bdmr10055489qkp.51.1714492972034; Tue, 30 Apr 2024 09:02:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714492972; cv=pass; d=google.com; s=arc-20160816; b=Lrp9FpCeAPd+mKkbI/cSnSPW1llBR7D5Xn1B5cCvKVB2iOs1a5gW3Wy1xlsMoqU4QR 9XVz8AAYhhQhbsbQ9C5NONrAF+6I8TZVtYSFfQ/OGCf5JK1T9mYHFqt7xMgDAcKSMroJ N/unFazO7XBjyDOFwZpx9lFV9QhO7D2Am5ApVjqvHjc40dkjpZc9h/BoP08EQpL7RZnV uCmYeZX1A0+JVF4HpiPg/c+6RFMfASduNHVt8jMFKSWtfcitj2uxnEX1vMMdHFwmGRGE VZnht92YwiOaGYtHFEAcsX7xabnlWb5RtO4/n4uHqKXKco6jH3w7VlPz1n+i9jpiNyzn Zp3A== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=D69oRZIZ474jd9BmLcQAJt2OqA7M7GZi/cmcRcIUy3U=; fh=2s+bAMIPZXffpTBQHgLv3X8vwTJ0bLB0PukyeqKlu2o=; b=uSHKHBEZZDVud2FbrdUeXOtPBRo1b/X1t4e7q9lFSVsjKCKk/J4Fa9D8wsSDoSeeH2 UTdam/duqkeucH17TYmCOUdI96PqGiU2w0ZZ9CsK3WH5sUjsYnUyppLd3DW80pm0ulmf uPuSiFO0mBbu7ACS5yFCwUiXK2hMXv4Kmrz30BMZmr/cmQrHQDYexUBx7qG9ohX/dE45 Yw3oylk+/RdnO07MX5AyGhLGeLTt5btA+knZY1UIgdOTn8lvJCiQ5bEKm3F86wL2u68T wIcRyoG3uHlqfO9ueol8ajFEjAd3YpTueiHpnDV1wqlL0Oc0KRij+v3t6XKRrV6J6E5C MzJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=PvvJNeoq; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-164336-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164336-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pe15-20020a05620a850f00b0078ebade24b1si28531878qkn.548.2024.04.30.09.02.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 09:02:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164336-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=fail header.i=@rjwysocki.net header.s=dkim header.b=PvvJNeoq; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-164336-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164336-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 207021C218CC for ; Tue, 30 Apr 2024 16:02:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 486C0176FDF; Tue, 30 Apr 2024 16:02:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b="PvvJNeoq" 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 82361176FB2; Tue, 30 Apr 2024 16:02:23 +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=1714492945; cv=none; b=LYQOOfdmvJQ8MORYf7aRkZriGxy/j1vfoXahCOBWg7uFDJ28D4TK/7zAFbj1ennJDZx2Boe61AJVfabCPIvB9zSQrlblLUqK5HmoWliI5rxc+B0OFNeDHzkPn/gwiYXXTlICilQVTwEzbOYw8MEO8W/9guGPp0ebBsFvWtSmgYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714492945; c=relaxed/simple; bh=1XpWqYY6FpW+nYEyvngkH/20vtybIC+9kZBc7rpJxEQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=eDXpUdpInxnF8cMRvlryoI5fsEczQ5sMjIZ7Ioyt8bpg9TAVrx3Ph2jvqnKOnO25vBkULXRgwtlYmdJeuUCM0/SlTZ91UtOuA3IkN6lljGHyvDGbDcK37NalsyNs+MPxGgt/520zWLnQWlg+s9f/gxiRu5pMuwMAOimB2ycC0f4= 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; dkim=fail (2048-bit key) header.d=rjwysocki.net header.i=@rjwysocki.net header.b=PvvJNeoq reason="signature verification failed"; 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 6.0.0) id 5ee6a7844c993097; Tue, 30 Apr 2024 18:02:21 +0200 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 0C26D66E643; Tue, 30 Apr 2024 18:02:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rjwysocki.net; s=dkim; t=1714492941; bh=1XpWqYY6FpW+nYEyvngkH/20vtybIC+9kZBc7rpJxEQ=; h=From:To:Cc:Subject:Date; b=PvvJNeoqYzENUZZBlwJRp3Cfq4aS+BRbWjHBDUy5YY4y9RrtqIZa0z+yNDSEhlRTj d7I8TD6HdT1YWcstC8wrNPWmOkMQSrh7/NYT/ZwDxsGvAjzR+MTxz0P2wolkz898g5 zDS2KV+vBTVbss87RlEgE90Q+jfMTKI4NVV8POA7c9g0wtNpoRYZdob1UJSILVEuUg zS49eOK7OzVIiTxMylPM+wp6wU93ILEqIcvvC1Zl1IYX3wXvvOxh42AF7HOsFe9877 vkzvUMoY67EIh5FtDHc2RqXGttCWiasihhR9ADDXlseX1nVuoeRPkFByaNgVuHk4PT On7dgcmqT4xdw== From: "Rafael J. Wysocki" To: Linux ACPI Cc: LKML , Salil Mehta , Jonathan Cameron , Zhang Rui Subject: [PATCH v2] ACPI: scan: Avoid enumerating devices with clearly invalid _STA values Date: Tue, 30 Apr 2024 18:02:20 +0200 Message-ID: <12427278.O9o76ZdvQC@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrvddufedgleefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepueeugffhuddtueeiledukeeileffieetudfhuedtfeejgefhveeigeegleettedvnecuffhomhgrihhnpehuvghfihdrohhrghdpkhgvrhhnvghlrdhorhhgnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohephedprhgtphhtthhopehlihhnuhigqdgrtghpihesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehsrghlihhlrdhmvghhthgrsehhuhgrfigvihdrtghomhdprhgtphhtthhopehjohhnrght hhgrnhdrtggrmhgvrhhonheshhhurgifvghirdgtohhmpdhrtghpthhtoheprhhuihdriihhrghnghesihhnthgvlhdrtghomh X-DCC--Metrics: v370.home.net.pl 1024; Body=5 Fuz1=5 Fuz2=5 From: Rafael J. Wysocki The return value of _STA with the "present" bit unset and the "enabled" bit set is clearly invalid as per the ACPI specification, Section 6.3.7 "_STA (Device Status)", so make the ACPI device enumeration code disregard devices with such _STA return values. Also, because this implies that status.enabled will only be set if status.present is set too, acpi_device_is_enabled() can be modified to simply return the value of the former. Link: https://uefi.org/specs/ACPI/6.5/06_Device_Configuration.html#sta-device-status Link: https://lore.kernel.org/linux-acpi/88179311a503493099028c12ca37d430@huawei.com/ Suggested-by: Salil Mehta Signed-off-by: Rafael J. Wysocki Reviewed-by: Jonathan Cameron --- v1 -> v2: * Fix a confusing comment. * Add R-by from Jonathan (thank you!) --- drivers/acpi/bus.c | 11 +++++++++++ drivers/acpi/scan.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) Index: linux-pm/drivers/acpi/bus.c =================================================================== --- linux-pm.orig/drivers/acpi/bus.c +++ linux-pm/drivers/acpi/bus.c @@ -112,6 +112,17 @@ int acpi_bus_get_status(struct acpi_devi if (ACPI_FAILURE(status)) return -ENODEV; + if (!device->status.present && device->status.enabled) { + pr_info(FW_BUG "Device [%s] status [%08x]: not present and enabled\n", + device->pnp.bus_id, (u32)sta); + device->status.enabled = 0; + /* + * The status is clearly invalid, so clear the functional bit as + * well to avoid attempting to use the device. + */ + device->status.functional = 0; + } + acpi_set_device_status(device, sta); if (device->status.functional && !device->status.present) { Index: linux-pm/drivers/acpi/scan.c =================================================================== --- linux-pm.orig/drivers/acpi/scan.c +++ linux-pm/drivers/acpi/scan.c @@ -1962,7 +1962,7 @@ bool acpi_device_is_present(const struct bool acpi_device_is_enabled(const struct acpi_device *adev) { - return adev->status.present && adev->status.enabled; + return adev->status.enabled; } static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,