Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2151841rwl; Thu, 30 Mar 2023 06:45:32 -0700 (PDT) X-Google-Smtp-Source: AKy350Yyu0lbuF0mSMP5BkXoCE9bUlfWgEEqfJ+JQ7tBs2qzM4rneFzXyj2dqQtnOtXFIqq+0LIg X-Received: by 2002:a05:6402:524e:b0:4fd:2978:d80 with SMTP id t14-20020a056402524e00b004fd29780d80mr24286659edd.1.1680183932313; Thu, 30 Mar 2023 06:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680183932; cv=none; d=google.com; s=arc-20160816; b=l6Yt06fplAp/vDhnULPhTilKG48hm0wvoFVL6kMlabjVZXwS6k/nof3HgmqLsl5mCN X/GLm4IbxXmxu/m84IH6zqKa+prnD0SL0/IZAfzrX/KoQGcNn9IUq3QiIDdIqKVF6yf0 TTfW3sfZY5irb/CieECfADVFVqhrBDLZGKuCSELOZULHHLNq/dGtV1BWHMbWXnKnxd9O K+O8IJuef/75Tml9TywkVEU+Ae9Lq+DPpUsYXYJnpdLqVgfimtT3QFc1tzh1bX/UWYfn bmS1RgWXIZYIbF7Thf22WgglXwjvP0oooTIpSerTSdlluEUGEc/qm8b/Vh61mmUHltx0 w9nA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=dMBYYLyfgZhPJMlJlU0M/wdSvmkWIhoOy3DzMIOwJ1w=; b=SONpFbZmR7vP+AD+J4shmPgZyNXTixxsQsPTy1Y5jx2wfliZxK+6f3uduGG1/oq1hP fHTR6O4G3655I2JwoeCSZ65AxQKE43dnglBHJUVBVL4N+l3xLOCcsolI3/3Uxt1MpuSc p0Nrc08X9dRceFY6qialKu6/cM0WnrWNKZN9iBa//OIVeIjsscsPPLzRrpZ3tQWiO+5u QeM6eaWRRYQ4WvkYM27ZuvDpk6whdbFKAEKevL0A9nufpMdNFW8+ENVnYDQKJuhfawOz A01fy7lNkAJqtiFKLZR3SQpgEq+Sj7/nRe590HZULah9WpFYu59S7NXGVa5GXFE1H1WY +Ogw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=WDEQOvzA; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w13-20020aa7dccd000000b004c5a8aa02fcsi39288747edu.435.2023.03.30.06.45.07; Thu, 30 Mar 2023 06:45:32 -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=@redhat.com header.s=mimecast20190719 header.b=WDEQOvzA; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232151AbjC3NoI (ORCPT + 99 others); Thu, 30 Mar 2023 09:44:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232184AbjC3Nnx (ORCPT ); Thu, 30 Mar 2023 09:43:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAFC8BDEA for ; Thu, 30 Mar 2023 06:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680183764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=dMBYYLyfgZhPJMlJlU0M/wdSvmkWIhoOy3DzMIOwJ1w=; b=WDEQOvzA2jztTq3CQqM0UtNTjOUc+jgfouQyZDY6DEfSHCi9SLgtfkxVED2E89RtqsKXUp HLb930vNHhhTg3k7eEuMgQfCYNZoAv+evKtj4+Qk1VG6XpkALi/lPtlplXxsMFgyDXOhKF QeyYuXYA3pVSXh2zM8VAGrfKljqZNtM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-phDZn31VM7WEPRnFnizwEw-1; Thu, 30 Mar 2023 09:42:41 -0400 X-MC-Unique: phDZn31VM7WEPRnFnizwEw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A67C58028B3; Thu, 30 Mar 2023 13:42:40 +0000 (UTC) Received: from dba62.ml3.eng.bos.redhat.com (dba62.ml3.eng.bos.redhat.com [10.19.176.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 508EE18EC6; Thu, 30 Mar 2023 13:42:40 +0000 (UTC) From: David Arcari To: linux-pm@vger.kernel.org Cc: David Arcari , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Srinivas Pandruvada , Chen Yu , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] thermal: intel: powerclamp: Fix cpumask and max_idle module parameters Date: Thu, 30 Mar 2023 09:42:18 -0400 Message-Id: <20230330134218.1897786-1-darcari@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 When cpumask is specified as a module parameter the value is overwritten by the module init routine. This can easily be fixed by checking to see if the mask has already been allocated in the init routine. When max_idle is specified as a module parameter a panic will occur. The problem is that the idle_injection_cpu_mask is not allocated until the module init routine executes. This can easily be fixed by allocating the cpumask if it's not already allocated. Fixes: ebf519710218 ("thermal: intel: powerclamp: Add two module parameters") Signed-off-by: David Arcari Cc: "Rafael J. Wysocki" Cc: Daniel Lezcano Cc: Amit Kucheria Cc: Zhang Rui Cc: Srinivas Pandruvada Cc: David Arcari Cc: Chen Yu Cc: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org --- drivers/thermal/intel/intel_powerclamp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c index c7ba5680cd48..91fc7e239497 100644 --- a/drivers/thermal/intel/intel_powerclamp.c +++ b/drivers/thermal/intel/intel_powerclamp.c @@ -235,6 +235,12 @@ static int max_idle_set(const char *arg, const struct kernel_param *kp) goto skip_limit_set; } + if (!cpumask_available(idle_injection_cpu_mask)) { + ret = allocate_copy_idle_injection_mask(cpu_present_mask); + if (ret) + goto skip_limit_set; + } + if (check_invalid(idle_injection_cpu_mask, new_max_idle)) { ret = -EINVAL; goto skip_limit_set; @@ -791,7 +797,8 @@ static int __init powerclamp_init(void) return retval; mutex_lock(&powerclamp_lock); - retval = allocate_copy_idle_injection_mask(cpu_present_mask); + if (!cpumask_available(idle_injection_cpu_mask)) + retval = allocate_copy_idle_injection_mask(cpu_present_mask); mutex_unlock(&powerclamp_lock); if (retval) -- 2.27.0