Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1463360lqa; Mon, 29 Apr 2024 09:07:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUvJqwr+KaI87LFQ6unaVbRUkFoI+wg6P6wB8qWuK6vamfojeyPflYf0vmTevxFGkJwJSteq/eRdKPzWJhedYQYSqFuHLD/Sh037kNWbg== X-Google-Smtp-Source: AGHT+IFPtqC3zvb8cNymFcqVlFaSyE5PiRUNmAMyys4VLqoUJHKoModTmKOb/uPFb9JnpF3bhPIL X-Received: by 2002:a05:6a20:2d0c:b0:1a3:c3e0:518c with SMTP id g12-20020a056a202d0c00b001a3c3e0518cmr15535588pzl.52.1714406849371; Mon, 29 Apr 2024 09:07:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714406849; cv=pass; d=google.com; s=arc-20160816; b=f73RH/XYxTzHUkESMBZwzbZV6B71+cJ1UiZItO1rJL/HfBnxJ34Dw1ldOLD2nlDBdK KuWthP2OOBoHpLllyB5x6Gy+xng6db23wQfEO0GIUw0d7K3WZgWZov1nSPIpQm8bWtIs pCElxgYpdw4HXwvSexi3TpEEAVzFlR+UWAZbSv6Ufq5hT2q9lrfx06FOBM1C7o7QAUcw kAWPJBonyXMmAo+JP/UbQq8ScCuSHXU7UuCyPDWoCIct4FSnxNgurk6CvpjE0Qfn8Mk9 NWf5zxpcDDt9l6RozzEqXwWfn2NWzgu48DKYbooVF5qiUZ5/unvPbRJ269/2ux1LC2dg XWtQ== 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=EpMnTd3V2spYjx4dbBhNp4NoMgU5Zqhfk2/gg9XbcQs=; fh=lWb/yiD9cPRldSkypaWx+/qnKiag6ED5hqmzw86j5uA=; b=jGb7/TUXWd4LGX2A1kbZLJ6BWwfT++qaZ0oNvpbavKBVCNBPDL9hAn3HH/OC3li4Sg S0KqmE/2EXc9n+W9Gh3UXUqJdABh8L+5MvjL+I8pGFHWL9VHtB2CXATMf3kJrmXwmapV cmA0gb5IBP1vK1XSwItVY5ccEolA2fqQPjYvJ20ylfV5vUDGLEmsh92PutcWXPr/6kNZ XwOSDZ+wwJHJOuntSuApqmhqV071RZ9WlSF1I2MCrwoPzOAjdnDOzMfm446L4WwhipyF AjYZl96Gzd4+R+QuHHpDTlI10tLRGiJrzjYLqIZYcyxUFSu5llwrM9LLSwsS01sO3RgX mygw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="A/yelYC3"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-162652-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162652-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w186-20020a6362c3000000b0060b5b3ce372si7504449pgb.309.2024.04.29.09.07.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 09:07:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162652-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="A/yelYC3"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-162652-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162652-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 5A13B284749 for ; Mon, 29 Apr 2024 16:06:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 95EE083CD9; Mon, 29 Apr 2024 16:06:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A/yelYC3" 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 AB66F839EB; Mon, 29 Apr 2024 16:06:30 +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=1714406790; cv=none; b=FBw5+XGaYhrzRG3s3nFq4nfxhPzLaShXMcsHUQS32DfZIP/+m0kggFw963XId+nvxY3gGuN/ZUCkgALlqmY3u4R1DZ0RLMz4/NxsX25qFRgHjuGVktd/KY75ZbjcQXEXOTivKJx3QlEAefSRQb13h/7XLri/5kL6ZpAYnvDQ9d8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714406790; c=relaxed/simple; bh=afERztb9pVx17pXtbd9iQT9EUE2xeuhnB2fps9eTU2M=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=saUXrxLnuqAl56pHCTyebcxO5zwPoopYRHTwbsC80jgOCF/ibI2oZm2yTJ0r5rnC3I89SVxraorbsnFbmUlLImdMdkAIogjkxKu9pCbsK7yvpypVHafvZoibBAk5uTvy18P9Lx5wkzsxdCINBHR+zyvQVH+h2It7DD3cxUxVWCE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A/yelYC3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39557C4AF14; Mon, 29 Apr 2024 16:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714406790; bh=afERztb9pVx17pXtbd9iQT9EUE2xeuhnB2fps9eTU2M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=A/yelYC3XQWHy2t462WvCtZugMJLgKpzXy9mNaFTqXtCTN38WaZJY+s+D1hNbr3DR W87uOgUVp1h2JuRBjRspQ4TRUQgVA1qlVZV90Mipt3fsFA7sAebneGw1R/BuKfN0Zu 2oDesbX775ljUihmmaC9+1HRd+Gz+5bQ8ypJxRtMajNM9HgclDh4il8FquIrirJ+ST 9aY9S8LjYNFuE6fmQ/epgbkfJp6+P3d/ioBTPkcxPdrEDuxWHOXH4yjTWE/RMQUDUF URj77m7f59ZyhPeeAYZ1IRLculf0Ya3VtidaPSKQTogOBOYDdyuDlaokQkeIyVqfuY 79R+4A3n9kv1g== Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-5af609de0d2so452074eaf.2; Mon, 29 Apr 2024 09:06:30 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXHZSpEmAd+BDZX4XI3aK41ZT9hcXoHeLkaR+/AblOzukJBS/q4yLgdz6/ss4ciBrdCbYffT5JzOy9SN3MNfnrVVvILUpNPyIaD8cAn4/fiYkxzmJmrvIOcmhCyb1Nhqvq4T1saJzKeyA== X-Gm-Message-State: AOJu0YxXiuKa9Cv2ZGvesiyxkjp+AmaIT4w4v7zmC8MFxbGL1AmfMwf/ o7Q11P10apsrU2js4glZbKg6C5SrV+JMbBvijQRcOG8phzCJ3ahuVdbBIXSHoEnF5BvKOpmvWgw CEEluGtOa99hAtJn+2oxC1TNyNxs= X-Received: by 2002:a4a:be9a:0:b0:5ac:6fc1:c2cb with SMTP id o26-20020a4abe9a000000b005ac6fc1c2cbmr12303338oop.0.1714406789435; Mon, 29 Apr 2024 09:06:29 -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> <278b47946efd7f67229e26335c419570871427cc.camel@intel.com> In-Reply-To: <278b47946efd7f67229e26335c419570871427cc.camel@intel.com> From: "Rafael J. Wysocki" Date: Mon, 29 Apr 2024 18:06:13 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1] ACPI: scan: Avoid enumerating devices with clearly invalid _STA values To: "Zhang, Rui" Cc: "rjw@rjwysocki.net" , "linux-acpi@vger.kernel.org" , "salil.mehta@huawei.com" , "jonathan.cameron@huawei.com" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Apr 28, 2024 at 6:17=E2=80=AFAM Zhang, Rui wr= ote: > > On Fri, 2024-04-26 at 18:56 +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/88179311a503493099028c12ca37d430@hua= wei.com/ > > Suggested-by: Salil Mehta > > Signed-off-by: Rafael J. Wysocki > > --- > > 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 and enabled\n", > > + device->pnp.bus_id, (u32)sta); > > + device->status.enabled =3D 0; > > + /* > > + * The status is clearly invalid, so clear the > > enabled bit as > > + * well to avoid attempting to use the device. > > + */ > > seems that this comment is for the line above? No, I meant "functional" and wrote "enabled". Not sure why really. > > + 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 > > *handler, > > > > > > > > >