Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp3203280rdb; Tue, 26 Dec 2023 22:28:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEuOLQ8JWJ5Ic+5XnefSINjgRFI9cRdpx9LBz3mnHq8zdEqiIKaW5n5NUaBOuCTwJW7vxu X-Received: by 2002:a17:903:11d1:b0:1d4:a64:daf2 with SMTP id q17-20020a17090311d100b001d40a64daf2mr9838132plh.101.1703658515196; Tue, 26 Dec 2023 22:28:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703658515; cv=none; d=google.com; s=arc-20160816; b=ystlITMjxiUNDXdnlrL7jvv3J7hODqb5gQcjoTjpzDzlecumjmDhY30XrkQnhQBA5P phZwStlKigTsRN2HoxszTXivszzSXHbwRXKjPFT+1Ybfwn26tGvZDdVVCwN09rB1y8xt H9AhxQBu9LvRTIFNM4CcrhjNT+Z2qG215rlGqH1vMoH03mRslwaGgrzbSmAWEjR3ADj3 1nnkKROm2oLQc3YNrrDH8pjDtJu1/HY3AulUtXeOWosLHVKq3Q0ymcizuB+5HdtI58xO CbVfMBDLUPT2N1KUxI6tSsMYW3OYhSrbfbPnfPwpUFm0Xm1RJ5ACHvd229zzwrx2oWti x1GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=RgHloiBNXkAD0pnH7f4nlfVv5X1gGe+tsv0NUuggyyA=; fh=+uoRuePerzEUtGMtUkxhzXG+DZX8dBsFnLC2Ry+GNNY=; b=aAiWQuEpTuanWJGZX1SqmCOOH+pBpVE9e9jDsQTURFRlgd77RWyfxFF8VXJO1tp29W pZTJIBOUntkiawDeNlZ5IC+fMX2JnydP2hA1vikGTIsU+TDUjl6P9Z6hULJcot9+DTYA 0Qy7sWSFmASUrHTXqGSXfY3pwL+y5o0P5kJOUpDBS7JTesI/YiXVQe2MBgYMlIJSeopl evoknA3c5/NfdVcHLQ4vFpZzBUJMqvFd9nDz0RwRrQT3rDMLq68g8B6E/BNEidEji9EP 2xuHhpHM6rVNeznv+4pA8GKnGQQ5/0sHrLX3mh4N7uxsrRhBstJwhLCs7EEwChupFN6y XzPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E2tO3DFc; spf=pass (google.com: domain of linux-kernel+bounces-11860-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h2-20020a170902748200b001d450fbd1fesi4929378pll.578.2023.12.26.22.28.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Dec 2023 22:28:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11860-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=E2tO3DFc; spf=pass (google.com: domain of linux-kernel+bounces-11860-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D747128372B for ; Wed, 27 Dec 2023 06:28:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CCAB63C5; Wed, 27 Dec 2023 06:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="E2tO3DFc" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3F26538D; Wed, 27 Dec 2023 06:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1703658483; x=1735194483; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=1cYYK5ByGwjzQSWbNjPnL+R1+DM1//XjIOt7Mqw3UFE=; b=E2tO3DFcnLK85DXklMGcpvgRKpo8+BbpjN4dninGgTJQKC0OMPzVnn4Y XLXEffo89izAH16QUWjmTTlEglOpSHatN792s4kB3PlddKRWM23TXcF0z 4Zesse4uKlnvvHuuda4Wp1BkoI4I46EDDl8FL+7lT/g3IYL/M9bwpAN+6 ISGu9V2kxkmlzBUUk79jCum9yfaSYlpKWa+grA28+beBW9e+DPztbPFH7 C31NHSOAjdUPgg/LVW0018EffiWoS+fivfLzjWFy74fwq3cnIAWtktqv9 vYrPIT5O9uu3JRcjPeY118lXO9HZIKxViXAjChYhWjQiZ2JQA7ILSW5Wv g==; X-IronPort-AV: E=McAfee;i="6600,9927,10935"; a="427584073" X-IronPort-AV: E=Sophos;i="6.04,308,1695711600"; d="scan'208";a="427584073" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Dec 2023 22:28:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10935"; a="1025316085" X-IronPort-AV: E=Sophos;i="6.04,308,1695711600"; d="scan'208";a="1025316085" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by fmsmga006.fm.intel.com with ESMTP; 26 Dec 2023 22:28:00 -0800 From: Ricardo Neri To: "Rafael J. Wysocki" Cc: Chen Yu , Len Brown , Srinivas Pandruvada , Stanislaw Gruszka , Zhang Rui , Zhao Liu , stable@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri , Zhao Liu Subject: [PATCH 2/4] thermal: intel: hfi: Enable an HFI instance from its first online CPU Date: Tue, 26 Dec 2023 22:29:38 -0800 Message-Id: <20231227062940.10780-3-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231227062940.10780-1-ricardo.neri-calderon@linux.intel.com> References: <20231227062940.10780-1-ricardo.neri-calderon@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Previously, HFI instances were never disabled once enabled. A CPU in an instance only had to check during boot whether another CPU had previously initialized the instance and its corresponding data structure. A subsequent changeset will add functionality to disable instances to support hibernation. Such change will also make possible to disable an HFI instance during runtime via CPU hotplug. Enable an HFI instance from the first of its CPUs that comes online. This covers the boot, CPU hotplug, and resume-from-suspend cases. It also covers systems with one or more HFI instances (i.e., packages). Cc: Chen Yu Cc: Len Brown Cc: Srinivas Pandruvada Cc: Stanislaw Gruszka Cc: Zhang Rui Cc: Zhao Liu Cc: linux-pm@vger.kernel.org Cc: stable@vger.kernel.org Signed-off-by: Ricardo Neri --- drivers/thermal/intel/intel_hfi.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c index 87ac7b196981..15c8c3b841d2 100644 --- a/drivers/thermal/intel/intel_hfi.c +++ b/drivers/thermal/intel/intel_hfi.c @@ -409,13 +409,12 @@ void intel_hfi_online(unsigned int cpu) /* * Now check if the HFI instance of the package/die of @cpu has been * initialized (by checking its header). In such case, all we have to - * do is to add @cpu to this instance's cpumask. + * do is to add @cpu to this instance's cpumask and enable the instance + * if needed. */ mutex_lock(&hfi_instance_lock); - if (hfi_instance->hdr) { - cpumask_set_cpu(cpu, hfi_instance->cpus); - goto unlock; - } + if (hfi_instance->hdr) + goto enable; /* * Hardware is programmed with the physical address of the first page @@ -445,10 +444,14 @@ void intel_hfi_online(unsigned int cpu) raw_spin_lock_init(&hfi_instance->table_lock); raw_spin_lock_init(&hfi_instance->event_lock); +enable: cpumask_set_cpu(cpu, hfi_instance->cpus); - hfi_set_hw_table(hfi_instance); - hfi_enable(); + /* Enable this HFI instance if this is its first online CPU. */ + if (cpumask_weight(hfi_instance->cpus) == 1) { + hfi_set_hw_table(hfi_instance); + hfi_enable(); + } unlock: mutex_unlock(&hfi_instance_lock); -- 2.25.1