Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1463736lqa; Mon, 29 Apr 2024 09:08:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6QSAnDu+Ty1et5+i4XWEOVhnbnt1L2vY4JgJs8z2kWXVHQANgv/mOBKn5/DKkowD619lgQshEBbJaYSubRHr1J5VhPqIlfSEstOyk7w== X-Google-Smtp-Source: AGHT+IGzdVaYKaDvBJFXWfz5pFbEaLkKCLwi812SZn2DnJAQQSZmP2KwPCme/7zlE0fd1oCQ52KN X-Received: by 2002:a05:620a:470b:b0:790:e76a:33e2 with SMTP id bs11-20020a05620a470b00b00790e76a33e2mr7042702qkb.61.1714406881004; Mon, 29 Apr 2024 09:08:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714406880; cv=pass; d=google.com; s=arc-20160816; b=N3c+x/FGbNmgtk0f/VzlmGmTbK9clmGL6YIsJxyVMMCi4FfdrQyiRfzv1DgAj6JYSg VaQsncexKk4e9mwKXeXHM5RflOudPZnKQGUwRwups5hBSbGKzsXKeVZ/OaTHnCnKRat7 GxcFnftRSS9M+yrRHTgyfaVWVkiIQG7dj/4OMv2Pj9Nwf4fkm66r6IdmuVLKOO7M7XGs kqLa655u/dQFUeR5HB1p7WWUyZ+RQ+8HYKmHu8SXIBOEf6ztdwTwpidE0dxmRrUwsVrZ scM6tbyJOxrxnUpJniJBkL/DOhzmhvTUb3GBYAuZnFUlLFe4i3j5gi8KSHVsdOrmFrW+ Ityg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=jXmtzYx6vmATxBGG5VSUeee480yXMx37iioL8kpAmVU=; fh=/KFkrwSEgnD5f8bwLVNA07PfVOhvtq48UAlmdsViIWE=; b=IJkjH0uGzoFxvD1Trd9mfU4tFRdJqSFulWwlbT7shmMfsEIoEygFCMWNpkoWVTDQVT GZJWQOJDRO7X0FirvX1sEsdTVtrqLbqcEXHlHpnaZo9xhASooqq9pIndAZcQPsjh71cj p7rckS3a75y0YKkfg/M61fg0eerLZMs1op2hSAJV7jxlZQtPc4h4Jox6V43XYYwr2RjZ x45DH599SERQykRCBB12JtJ8bxUnlAwQb1/Mywsu0h1P7+0k69PpfUtZ6rjWXx8QyrY2 zR4762cvdzCYAsE3Ftes306OgTSoGbEP2cv+Ww7ThXmEjJ2b2KGbktMV1jKHqrGNJzTF +8rg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Sz0OvXaj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-162655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ea24-20020a05620a489800b00790e84d74d2si5016610qkb.299.2024.04.29.09.08.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 09:08:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162655-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=pass header.i=@kernel.org header.s=k20201202 header.b=Sz0OvXaj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-162655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 B28E51C20F9B for ; Mon, 29 Apr 2024 16:08:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2680684D22; Mon, 29 Apr 2024 16:07:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sz0OvXaj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 45A8C74400; Mon, 29 Apr 2024 16:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714406868; cv=none; b=RlN4rWOfexMqZI+AMDG5Jr+X+Oh/Jurbz98e3y5rnqObvH1GxpCz91AUBrcD9R62Ujbl3NntU3syS+6+y+mK0MqK3fBf6HG7uYF5q3tNCNnWqsdQpSg123PRtNHAE6lkDhlQkUyHLMGk4X5Q0Qg3JoMkvftu5Xiz0XfKu1a9Vrk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714406868; c=relaxed/simple; bh=vOPo2tC/GsMIJkgdLxRfFzKWoQbXSFV0p9q7pK6+vak=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=gwKrXyjELRAsitkmGrLfC5AzuxJL9vkLjhI6HqPUTR0q0T2UST8wr5i2tmx2Xj2namhvFH22gc4+KkQQxa06eB4xX+bBIpYjTYbgu3PcKP7tbMziO2eWRXMXPjuH151wAf6FTDNpEy1NETLOptGMABO3CaOy/xRhtQctlnsz09o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sz0OvXaj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2901C113CD; Mon, 29 Apr 2024 16:07:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714406867; bh=vOPo2tC/GsMIJkgdLxRfFzKWoQbXSFV0p9q7pK6+vak=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Sz0OvXajBFXicFUN1iTUq/mwMrPDUuCFy/fKhcOIcu+0VbIbR8+NaMgMVHx/cqB3b Fzy17+JNPthru0hHHnfq8Ne18JtwluqXvcSoIxv9xx9QELaBgt2MZILaigf3de60OP f/JjOYysjyOmqrixKf027vbfO9v+2v3mEDFi5/yW7niHugLeNr6CMumldJlVAJsjSc mVphjrYRUo3cobtEJyYY3W5mKKVMxckoGm1CAsDhCPmn1grzyavB/JP6hDT/4r15B+ oIr3mogEVLwjav8vC8zmEQRJGPzRhhrlWI2vUCgx2HUAyzynOngk5pRcWogU2t0mYv F01w85ZjZVxhg== Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-5ac4470de3bso1038973eaf.0; Mon, 29 Apr 2024 09:07:47 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWb0lCxCmhCbq0rcJwqkoNPVhmf8q2ZYI0PN2FKFs6DynFFxP5BHDOW4aMOzMpiBEwJBsBzOFQtBvnet0zAkiB7N4+eFqm7vSqVahfgDU0mLInaGVJvbWHCImQjC4aS81f6wPJowTmyBw== X-Gm-Message-State: AOJu0YxdVCEEv30gbxvzsWPYIuCjCTENj08U60vMtFbvtSaTnXg6TKLO PEvvyTIFNEkDVKohrdvuv6CLlLOairkvwktjBSx5mxlNCrb7sNU+r/YBj7PpDJOZezDK66qtZvS PcIUOy2fnjkVVLVL+Cvi+wDOkNsU= X-Received: by 2002:a4a:a882:0:b0:5aa:241a:7f4b with SMTP id q2-20020a4aa882000000b005aa241a7f4bmr12612134oom.1.1714406867234; Mon, 29 Apr 2024 09:07:47 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <2741433.mvXUDI8C0e@kreacher> <20240429092942.00004c96@Huawei.com> In-Reply-To: <20240429092942.00004c96@Huawei.com> From: "Rafael J. Wysocki" Date: Mon, 29 Apr 2024 18:07:32 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1] ACPI: scan: Avoid enumerating devices with clearly invalid _STA values To: Jonathan Cameron Cc: "Rafael J. Wysocki" , Linux ACPI , LKML , Salil Mehta Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Apr 29, 2024 at 10:29=E2=80=AFAM Jonathan Cameron wrote: > > On Fri, 26 Apr 2024 18:56:21 +0200 > "Rafael J. Wysocki" wrote: > > > 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/88179311a503493099028c12ca37d4= 30@huawei.com/ > > Suggested-by: Salil Mehta > > Signed-off-by: Rafael J. Wysocki > Seems a sensible tidying up. Hopefully nothing was relying on > this looser behavior. One trivial thing inline. > > Reviewed-by: Jonathan Cameron Thanks! > > --- > > drivers/acpi/bus.c | 11 +++++++++++ > > drivers/acpi/scan.c | 2 +- > > 2 files changed, 12 insertions(+), 1 deletion(-) > > > > Index: linux-pm/drivers/acpi/bus.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- 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 an= d enabled\n", > > + device->pnp.bus_id, (u32)sta); > > + device->status.enabled =3D 0; > > + /* > > + * The status is clearly invalid, so clear the enabled bi= t as > > + * well to avoid attempting to use the device. > > + */ > > Comment seems to be in a slightly odd place. Perhaps one line earlier ma= kes > more sense? Or was the intent to mention functional here? Rui has noticed this already. I thought "functional" and wrote "enabled". Oh well, I'll send a v2. > > + device->status.functional =3D 0; > > + } > > + > > acpi_set_device_status(device, sta); > > > > if (device->status.functional && !device->status.present) { > > Index: linux-pm/drivers/acpi/scan.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > --- 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 *handl= er, > > > > > > > >