From patchwork Tue Feb 7 17:58:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Salisbury X-Patchwork-Id: 1739114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=Do1y04mn; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PB9qm1QGFz23yB for ; Wed, 8 Feb 2023 04:59:15 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pPSFI-0005iQ-BZ; Tue, 07 Feb 2023 17:59:08 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pPSFF-0005cE-Pm for kernel-team@lists.ubuntu.com; Tue, 07 Feb 2023 17:59:05 +0000 Received: from smtp.gmail.com (1.general.jsalisbury.us.vpn [10.172.66.188]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 25CCA3FDAA for ; Tue, 7 Feb 2023 17:59:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675792744; bh=7XwWYGwoXTDS3qLKM0tpDHBGl6CyLa2drfJe5WDFZqw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Do1y04mniWTNOv9haUrTh4kIO3/wI5m/NTAu/j+Fl5O1Z2pWglHmbGx6HPte1+MfN KsKUBWaELvj7ftU4A61ZYjO1/myd/sL9z7IULT/E7YpXu604f2z4C4vTGQFCyhJbnk F5COb4C7zN/1AYiOsg6UooV4r0sPN9h8UoT32FJneHk6QmiC1vewtE29xxaUFgFvMy GDiE+8fHU5fgXp0uWU4GBoqwl76YMjy0OzxJ3UTB7M4UusLOvBYFuWvN5XsDvSJVdQ CQo2p/YQ0kb4Cwna3pqAXEVbXNFSI/GhFrI7cwP0/OBtFyyK/lis4kMThUf0r+cMV9 y1Oobk9cLfDPw== From: Joseph Salisbury To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy][PATCH 6/7] intel_idle: Fix SPR C6 optimization Date: Tue, 7 Feb 2023 12:58:56 -0500 Message-Id: <20230207175857.164618-7-joseph.salisbury@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230207175857.164618-1-joseph.salisbury@canonical.com> References: <20230207175857.164618-1-joseph.salisbury@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Artem Bityutskiy BugLink: https://bugs.launchpad.net/bugs/2003267 The Sapphire Rapids (SPR) C6 optimization was added to the end of the 'spr_idle_state_table_update()' function. However, the function has a 'return' which may happen before the optimization has a chance to run. And this may prevent the optimization from happening. This is an unlikely scenario, but possible if user boots with, say, the 'intel_idle.preferred_cstates=6' kernel boot option. This patch fixes the issue by eliminating the problematic 'return' statement. Fixes: 3a9cf77b60dc ("intel_idle: add core C6 optimization for SPR") Suggested-by: Jan Beulich Reported-by: Jan Beulich Signed-off-by: Artem Bityutskiy [ rjw: Minor changelog edits ] Signed-off-by: Rafael J. Wysocki (cherry picked from commit 7eac3bd38d18cd3317756649921b8264ddfee692) Signed-off-by: Joseph Salisbury --- drivers/idle/intel_idle.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c index 7ff47d9f6822..97b3891c500e 100644 --- a/drivers/idle/intel_idle.c +++ b/drivers/idle/intel_idle.c @@ -1601,11 +1601,9 @@ static void __init spr_idle_state_table_update(void) unsigned long long msr; /* Check if user prefers C1E over C1. */ - if (preferred_states_mask & BIT(2)) { - if (preferred_states_mask & BIT(1)) - /* Both can't be enabled, stick to the defaults. */ - return; - + if ((preferred_states_mask & BIT(2)) && + !(preferred_states_mask & BIT(1))) { + /* Disable C1 and enable C1E. */ spr_cstates[0].flags |= CPUIDLE_FLAG_UNUSABLE; spr_cstates[1].flags &= ~CPUIDLE_FLAG_UNUSABLE;