Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1440123ioo; Sun, 22 May 2022 14:46:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2Rc0PrappDAQ+hSyOVYiroV8eXu1Bc/h/yFFj2mX+jibDcwA4nfxO+Tsw3Cl/gZk9YANM X-Received: by 2002:a05:6402:5190:b0:42b:b2d:19b8 with SMTP id q16-20020a056402519000b0042b0b2d19b8mr17047680edd.390.1653255965711; Sun, 22 May 2022 14:46:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653255965; cv=none; d=google.com; s=arc-20160816; b=ZzJj8+CyLHp4tYtFxsE6G7esfqys7yV1Nxuep7fHkWpl9kA8g4iyVsbbrVmAivk1aB GFmNgiET7cyTZigD0+tBehU5zr/+CSUWd0gx5uDsdhi2hccB+g2M5BFLGowRzfOmEr+J 4QHphlDersEgG2huVmvcNP9aX4V4nSDMm4xRWf7CTQTKEjfr2SdaN3SDwgrnmWtOTjNS 5FWUDaHc/esTJraBD3n+8fYr7a05lIkkdJAm8P75D2reGUuE67adPnDbCBT3iBeQ3laz 7xXOnZ7LSEaLWDCr7E3pR0bVIzI5yTG9ESWEaFAIu6HMSeeW9usRxkPuUvCW9B2ApnTB V2Og== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=rEq8jll1uVlKvKIVY/03w49mqN4gfPkZB6PAOSFOLso=; b=EdZfkoFq+V8+ergEyhphM+kcKS24TAt97qEI8F39p8/1sjgjif8l/oqVbpR7sKDbIF uLvm3YQYXvDh/x6xU/SQgGXvfEZ7xlTVzChzr+xxq/5Xz2zgociHI3/upTmv5EFzhUjy nQcGgh30xSpajWZWqJBirmEJHwDnrKK07TqX+3PUg4LYGpevM3MuSyU+KaJ9S6l4eo6S YOIR9K7O7wnxqeOJtM/m5+1qcugTHC6askIvhPPD1gfiwnD9VKV9c438n+bRHYZJCqpE SyKdTbKyaia3cD6VzkI8ncKoLDoiej+ieJ399l/u8GHFgK3MfKkd1KoSOkqKO+BdlHQA CAHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=ndirlIC7; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=vs1p2+tv; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m21-20020a056402051500b00424013eaa32si12364116edv.585.2022.05.22.14.45.40; Sun, 22 May 2022 14:46:05 -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=@suse.cz header.s=susede2_rsa header.b=ndirlIC7; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=vs1p2+tv; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351473AbiETQLn (ORCPT + 99 others); Fri, 20 May 2022 12:11:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351583AbiETQL0 (ORCPT ); Fri, 20 May 2022 12:11:26 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF8471FCD0 for ; Fri, 20 May 2022 09:11:23 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0EE581F8A3; Fri, 20 May 2022 16:11:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1653063082; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rEq8jll1uVlKvKIVY/03w49mqN4gfPkZB6PAOSFOLso=; b=ndirlIC7tTrN0fg2qWW8hBXrCC7olF2A3LIKxv6frbORFi8C+K8CM2RFT2ql+CtgC0woHZ /BHC/zIPgazT5xlpKF6sUGxNnRikFB1DtAtHuSO/nDN7pk3TekBVhKFKYPHBZHdduOSvsI gRNu0bA0tNI6xuv8e4oA0ggtQhTpk4E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1653063082; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rEq8jll1uVlKvKIVY/03w49mqN4gfPkZB6PAOSFOLso=; b=vs1p2+tv18yui+vygQgkcB4quw34X8YNysCUr3KaumEkjK9PpGiSrSgItVSvjV4pv0KVu9 3iIdxAHUOhfEl7Aw== Received: from linux-ni6k.suse.de (unknown [10.163.44.102]) by relay2.suse.de (Postfix) with ESMTP id C7EAA2C142; Fri, 20 May 2022 16:11:21 +0000 (UTC) From: Giovanni Gherdovich To: Borislav Petkov , Ingo Molnar , Peter Zijlstra , Dave Hansen , Thomas Gleixner Cc: "Rafael J . Wysocki" , Dan Carpenter , Srinivas Pandruvada , x86@kernel.org, linux-kernel@vger.kernel.org, Giovanni Gherdovich Subject: [PATCH 2/2] x86: fix platform info detection in frequency invariance Date: Fri, 20 May 2022 18:10:22 +0200 Message-Id: <20220520161022.5972-2-ggherdovich@suse.cz> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220520161022.5972-1-ggherdovich@suse.cz> References: <20220520161022.5972-1-ggherdovich@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Once the microarchitecture is recognized (via x86_match_cpu()), a failure in setting base_freq/turbo_freq should result in bailing out from frequency invariance, not in trying the next microarchitecture. This is because the call to core_set_max_freq_ratio() isn't guarded by x86_match_cpu(). The call to core_set_max_freq_ratio() should happen if no more specific microarch matched, but not in case of prior errors. Initializing base_freq=0 and turbo_freq=0 gives a mean for later code to check if setup failed. Fixes: db441bd9f630 ("x86, sched: Move check for CPU type to caller function") Signed-off-by: Giovanni Gherdovich --- arch/x86/kernel/smpboot.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 225a3c31297c..d0a692ea8294 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -2044,23 +2044,26 @@ static bool core_set_max_freq_ratio(u64 *base_freq, u64 *turbo_freq) static bool intel_set_max_freq_ratio(void) { - u64 base_freq, turbo_freq; + u64 base_freq = 0, turbo_freq = 0; u64 turbo_ratio; if (slv_set_max_freq_ratio(&base_freq, &turbo_freq)) goto out; - if (x86_match_cpu(has_glm_turbo_ratio_limits) && - skx_set_max_freq_ratio(&base_freq, &turbo_freq, 1)) + if (x86_match_cpu(has_glm_turbo_ratio_limits)) { + skx_set_max_freq_ratio(&base_freq, &turbo_freq, 1); goto out; + } - if (x86_match_cpu(has_knl_turbo_ratio_limits) && - knl_set_max_freq_ratio(&base_freq, &turbo_freq, 1)) + if (x86_match_cpu(has_knl_turbo_ratio_limits)) { + knl_set_max_freq_ratio(&base_freq, &turbo_freq, 1); goto out; + } - if (x86_match_cpu(has_skx_turbo_ratio_limits) && - skx_set_max_freq_ratio(&base_freq, &turbo_freq, 4)) + if (x86_match_cpu(has_skx_turbo_ratio_limits)) { + skx_set_max_freq_ratio(&base_freq, &turbo_freq, 4); goto out; + } if (core_set_max_freq_ratio(&base_freq, &turbo_freq)) goto out; -- 2.31.1