Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3518449rwa; Tue, 23 Aug 2022 06:09:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR7T95MamVWalMNJkaTFVrK1vEZH9AM7qDuK1B0wv60go2juyO2lGePWtM/zMSxnEPQL7Cdl X-Received: by 2002:a62:7b14:0:b0:536:b424:3780 with SMTP id w20-20020a627b14000000b00536b4243780mr8443915pfc.63.1661260142963; Tue, 23 Aug 2022 06:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661260142; cv=none; d=google.com; s=arc-20160816; b=b5Jb/cKdT6aytCFbdItVC83JcyioAYuKeEjNRrVX0RtWCBcKhlX1RJwRGYNTQTgN55 S3ks3Zr9L0dbwUEJYBKiPmWCRjPtF0ZHKvse7JXfX7s6JHM8sQrJFLP0/t/qYgpOKqvy atxp0zNlYo6r6I3rcwPfH5MZ5rpZmuAHu0BsgkeZYj5+CM+ldLgPSgJvM2zojFCbQZEJ XM3m24ZCq3B6A7JZPPuqE+jbypoBSmMiNprWRJtt3WxR1B4UDoLajfi3BO/aodJKi2fp pvy/qKKgNC7MVLeq190mAK5HyU7V7+4tvKZDqsah5R2fOB3J9+W7MO7l0dzxd06lojEs AUOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sTotDvr8WuDXDZkeNQyE1MbxlvvGhwBAOFXkKT69Eig=; b=XCVv9foq5nndMTtPJqk2OIOkYY4smCWlUHPZgIxM1/fNXRPxOfLVrX2yQl79xR54kR OcZ5z7+tmWH6TZeb0hWTs+D/9zaiIauc4+cVaRBmoEOGqhSkeuYZPKGuAPomtEcqcAIN iLW8MwmVX8j/HwyucCUyjFpFYhOzW/YEqbyoMPc9SZN+8zYYfYqxEOlb/8JJ+2P5sH8c /jIWk6FjeZUPaV1wRFvjsfmamu7GqWa8JWYEhO6fql0WxyHuhadvwb32i+Dj5as5ygjU ITOvvCUUGNkfwjwuUn3/3QvN4FPbdJjEcyZypAEnImnCtNWHHYpTsrWsqy5RHAn89lox srZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0ZaxsSH7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k21-20020a63ff15000000b00412b1d694d6si16039454pgi.155.2022.08.23.06.08.52; Tue, 23 Aug 2022 06:09:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0ZaxsSH7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358115AbiHWLpI (ORCPT + 99 others); Tue, 23 Aug 2022 07:45:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358392AbiHWLlo (ORCPT ); Tue, 23 Aug 2022 07:41:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBCD0CC309; Tue, 23 Aug 2022 02:29:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1521DB81C88; Tue, 23 Aug 2022 09:29:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E9C5C433D7; Tue, 23 Aug 2022 09:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246950; bh=zVySbhQmCrYQm9KPBepVFw8ABGXfVmDjaPbNpaUnL0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0ZaxsSH7vNaKuw3DV2WDznZvWcPdJqRPn8fQIA2KsIKnXWnHObJA1JTg7J4WHxr6E ODhfsRQEbMJ+4Zt6WBffDdbnX9jcpno6Ux+87Z7ILq1C4t/hoUnvAF1QSpYF/JTScO FJU1kwnRTkGAqL5LfxCqWezt26Xe3ErPd/LSu0c0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Rafael J. Wysocki" Subject: [PATCH 5.4 271/389] ACPI: CPPC: Do not prevent CPPC from working in the future Date: Tue, 23 Aug 2022 10:25:49 +0200 Message-Id: <20220823080126.879035447@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080115.331990024@linuxfoundation.org> References: <20220823080115.331990024@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rafael J. Wysocki commit 4f4179fcf420873002035cf1941d844c9e0e7cb3 upstream. There is a problem with the current revision checks in is_cppc_supported() that they essentially prevent the CPPC support from working if a new _CPC package format revision being a proper superset of the v3 and only causing _CPC to return a package with more entries (while retaining the types and meaning of the entries defined by the v3) is introduced in the future and used by the platform firmware. In that case, as long as the number of entries in the _CPC return package is at least CPPC_V3_NUM_ENT, it should be perfectly fine to use the v3 support code and disregard the additional package entries added by the new package format revision. For this reason, drop is_cppc_supported() altogether, put the revision checks directly into acpi_cppc_processor_probe() so they are easier to follow and rework them to take the case mentioned above into account. Fixes: 4773e77cdc9b ("ACPI / CPPC: Add support for CPPC v3") Cc: 4.18+ # 4.18+ Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/cppc_acpi.c | 54 ++++++++++++++++++++--------------------------- include/acpi/cppc_acpi.h | 2 - 2 files changed, 25 insertions(+), 31 deletions(-) --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -626,33 +626,6 @@ int pcc_data_alloc(int pcc_ss_id) return 0; } -/* Check if CPPC revision + num_ent combination is supported */ -static bool is_cppc_supported(int revision, int num_ent) -{ - int expected_num_ent; - - switch (revision) { - case CPPC_V2_REV: - expected_num_ent = CPPC_V2_NUM_ENT; - break; - case CPPC_V3_REV: - expected_num_ent = CPPC_V3_NUM_ENT; - break; - default: - pr_debug("Firmware exports unsupported CPPC revision: %d\n", - revision); - return false; - } - - if (expected_num_ent != num_ent) { - pr_debug("Firmware exports %d entries. Expected: %d for CPPC rev:%d\n", - num_ent, expected_num_ent, revision); - return false; - } - - return true; -} - /* * An example CPC table looks like the following. * @@ -748,7 +721,6 @@ int acpi_cppc_processor_probe(struct acp cpc_obj->type); goto out_free; } - cpc_ptr->num_entries = num_ent; /* Second entry should be revision. */ cpc_obj = &out_obj->package.elements[1]; @@ -759,10 +731,32 @@ int acpi_cppc_processor_probe(struct acp cpc_obj->type); goto out_free; } - cpc_ptr->version = cpc_rev; - if (!is_cppc_supported(cpc_rev, num_ent)) + if (cpc_rev < CPPC_V2_REV) { + pr_debug("Unsupported _CPC Revision (%d) for CPU:%d\n", cpc_rev, + pr->id); goto out_free; + } + + /* + * Disregard _CPC if the number of entries in the return pachage is not + * as expected, but support future revisions being proper supersets of + * the v3 and only causing more entries to be returned by _CPC. + */ + if ((cpc_rev == CPPC_V2_REV && num_ent != CPPC_V2_NUM_ENT) || + (cpc_rev == CPPC_V3_REV && num_ent != CPPC_V3_NUM_ENT) || + (cpc_rev > CPPC_V3_REV && num_ent <= CPPC_V3_NUM_ENT)) { + pr_debug("Unexpected number of _CPC return package entries (%d) for CPU:%d\n", + num_ent, pr->id); + goto out_free; + } + if (cpc_rev > CPPC_V3_REV) { + num_ent = CPPC_V3_NUM_ENT; + cpc_rev = CPPC_V3_REV; + } + + cpc_ptr->num_entries = num_ent; + cpc_ptr->version = cpc_rev; /* Iterate through remaining entries in _CPC */ for (i = 2; i < num_ent; i++) { --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -16,7 +16,7 @@ #include #include -/* Support CPPCv2 and CPPCv3 */ +/* CPPCv2 and CPPCv3 support */ #define CPPC_V2_REV 2 #define CPPC_V3_REV 3 #define CPPC_V2_NUM_ENT 21