Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1216151rdb; Wed, 6 Dec 2023 11:47:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCoNuEqAYbwKg5y/3YwFH7qa7yjU8rkxDldRbFoJ/Sp8PrBqTG31ngzg4MUzGsXkwScIwk X-Received: by 2002:a17:90b:1c85:b0:286:cf0b:3cec with SMTP id oo5-20020a17090b1c8500b00286cf0b3cecmr1380972pjb.4.1701892067879; Wed, 06 Dec 2023 11:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701892067; cv=none; d=google.com; s=arc-20160816; b=m0t7MRjUGlZJSYv2b/4I0Jr8xBlm4vRxUflSn1za4LcmPVoOJvGJTFo09Df3DlxJu4 eCZXV7RGdEaoIMzIG2LMqc33HC/J6Ez3mJl5OP2oEqftuv1UWnyaYrp0ITeG5ulux0z9 UyPfb3mfCAQGkdfwCMUHFjMOM8R68b8L+nPhqc3+s4oQ/bo1q0ZeEARG8HtMrl3tWgjA wjSzduDtV1V9tbV3EQ9XDJR36O1E7N4m4wyRqFMcDnqrWqCc/8ajRW2C0rrXhspPLM/G iJkHMZghA7L+JgRrFBAl+iC6UDpQlPMGv1cYVrViC2AO/KeIsdHxBWEJ+11w1mYFb5cC MVYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=N/rYaAakp67u/FaSeQXceCrMZRiB8u5G9D86KTCQ6P8=; fh=yUyz3kSxn5wTDRBmtdYca5HcSXMZHezHYiQot8WQJwg=; b=Nygzt5/HZ4qBQaz0MRw7AJnRYa8kJvUr2w2MIA1ZYi9MGcT31GhjxyOws7ea5AA4Tg GR8ORFQiMkBmU9MhXHoHBBySM+k3C3LFKl3cXnG0XcaPhDZWQtAY6ldzt2ZHlEPUQM0Z aJCGOtLyEwRf+PR9b77Di7L2pPOeeK+sXixWBx2RweyDhOMrzH6EP6pBXZEyLwV+a6YA VlWEpEKRWi0sHiJ7n7fLlKX3exmp/kfmzeuq3zN2o0rK33mPNgqzuw4IJS9QIBqdOoR4 uB1WEDx4M5Y7JwjlvbWTto6ulmTtSgFVO/qO/a3SaZs3NTaVZWTDcYUjwDOspE4z8ac3 ZBqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id mp13-20020a17090b190d00b0026305080a6fsi297743pjb.63.2023.12.06.11.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 11:47:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 5B2A281C8D9A; Wed, 6 Dec 2023 11:47:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379411AbjLFTr3 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 6 Dec 2023 14:47:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379391AbjLFTr2 (ORCPT ); Wed, 6 Dec 2023 14:47:28 -0500 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ED5D122; Wed, 6 Dec 2023 11:47:32 -0800 (PST) Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-1fb2b83986cso34897fac.0; Wed, 06 Dec 2023 11:47:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701892052; x=1702496852; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Eye1pIVAzvd8vmh6Sf9HoBroJHBM9TBK6FZNnnZG10=; b=gaWEWd0w8/eDrKR4JQtRo8HKUbpPb+8W4YcS7t+8JjwTOoL+gkq3+L1H3sZk/Cl690 TrURp9laYUua5tBqsDrv/vMNCQ0JalgX7Hq+4XgjuhBcZRxFII/5LyVgBz904SUYbzWO q5FyzB4Z6TN6wesZxzt+LqEM7dajL8a8lweL9oPD9ydvLE81rTklmIzC3hncbr+ltK8C 3sY3eK3vvB03SMWsFgqn7BoszpZ/nd7vzBkDeXN+W8oO4a7W+hd+/7D5x7YqC9R9/yMm Y0g+L/XqPHePSfZx5DyNYfp7KtLheLoQqCOXDICC0YsWevu4VWdxaWvpKmfRJSZimXnj N4hQ== X-Gm-Message-State: AOJu0YzC7T8rIu/9Zby0w0L2z8U2XYHB9ust3YFN9FNp9N40x9w+flb7 dUNZBHLgUhU/EkqIOpWv2wXkivRDiBJ10D/5GRY= X-Received: by 2002:a05:6871:5d1:b0:1fb:30b8:bb5c with SMTP id v17-20020a05687105d100b001fb30b8bb5cmr2696263oan.3.1701892051808; Wed, 06 Dec 2023 11:47:31 -0800 (PST) MIME-Version: 1.0 References: <20231120114143.95305-1-ytcoode@gmail.com> <575e4395-dfe1-4399-9706-cc02f56d7ebe@intel.com> In-Reply-To: <575e4395-dfe1-4399-9706-cc02f56d7ebe@intel.com> From: "Rafael J. Wysocki" Date: Wed, 6 Dec 2023 20:47:20 +0100 Message-ID: Subject: Re: [PATCH] ACPI: Correct and clean up the logic of acpi_parse_entries_array() To: Dave Jiang , Yuntao Wang Cc: "Rafael J. Wysocki" , Dan Williams , Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 06 Dec 2023 11:47:44 -0800 (PST) On Wed, Dec 6, 2023 at 6:02 PM Dave Jiang wrote: > > > > On 12/6/23 09:42, Rafael J. Wysocki wrote: > > On Mon, Nov 20, 2023 at 12:42 PM Yuntao Wang wrote: > >> > >> The original intention of acpi_parse_entries_array() is to return the > >> number of all matching entries on success. This number may be greater than > >> the value of the max_entries parameter. When this happens, the function > >> will output a warning message, indicating that `count - max_entries` > >> matching entries remain unprocessed and have been ignored. > >> > >> However, commit 4ceacd02f5a1 ("ACPI / table: Always count matched and > >> successfully parsed entries") changed this logic to return the number of > >> entries successfully processed by the handler. In this case, when the > >> max_entries parameter is not zero, the number of entries successfully > >> processed can never be greater than the value of max_entries. In other > >> words, the expression `count > max_entries` will always evaluate to false. > >> This means that the logic in the final if statement will never be executed. > >> > >> Commit 99b0efd7c886 ("ACPI / tables: do not report the number of entries > >> ignored by acpi_parse_entries()") mentioned this issue, but it tried to fix > >> it by removing part of the warning message. This is meaningless because the > >> pr_warn statement will never be executed in the first place. > >> > >> Commit 8726d4f44150 ("ACPI / tables: fix acpi_parse_entries_array() so it > >> traverses all subtables") introduced an errs variable, which is intended to > >> make acpi_parse_entries_array() always traverse all of the subtables, > >> calling as many of the callbacks as possible. However, it seems that the > >> commit does not achieve this goal. For example, when a handler returns an > >> error, none of the handlers will be called again in the subsequent > >> iterations. This result appears to be no different from before the change. > >> > >> This patch corrects and cleans up the logic of acpi_parse_entries_array(), > >> making it return the number of all matching entries, rather than the number > >> of entries successfully processed by handlers. Additionally, if an error > >> occurs when executing a handler, the function will return -EINVAL immediately. > >> > >> This patch should not affect existing users of acpi_parse_entries_array(). > >> > >> Signed-off-by: Yuntao Wang > > > > This needs to be ACKed by Dave Jiang or Dan Williams. > > Reviewed-by: Dave Jiang Applied as 6.8 material, thanks!