From patchwork Thu Mar 30 13:42:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Arcari X-Patchwork-Id: 668788 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BCA9C6FD1D for ; Thu, 30 Mar 2023 13:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232084AbjC3NoH (ORCPT ); Thu, 30 Mar 2023 09:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232220AbjC3Nnw (ORCPT ); Thu, 30 Mar 2023 09:43:52 -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 8551EBBBA 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 Reviewed-by: Srinivas Pandruvada <>> When cpumask is specified as a module parameter the value is Reviewed-by: Srinivas Pandruvada --- 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)