Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1229004rdb; Fri, 2 Feb 2024 20:04:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IETlT+xK1SK6gink0KJp3T4M4gXhqfTQxpXMqs3XOjcu9b6eveBgksaBohSNZfHIT0vPqIj X-Received: by 2002:a17:907:960c:b0:a36:5e44:a2dd with SMTP id gb12-20020a170907960c00b00a365e44a2ddmr3519327ejc.5.1706933094880; Fri, 02 Feb 2024 20:04:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706933094; cv=pass; d=google.com; s=arc-20160816; b=Su/LqmFxiNth4xFd5HeMuKf3tzWXWxbW7Jd0aW13/PfJ0jAEctnp/pYGpVtd8Pqire dVIfUyMmgL5iuK/YvljUzVcYdM4sKjI3e9m93BKSpQptG0VET+9/aA/mdm/Cw5oUmF72 BCbN8Cogd4XuW4B14WmAx4Ww39lg4rUEV3M+slGYYorL6+m9lkuLBKTYFIaTz1ZJrNRa Mff2/7jB5gCnYPpVerJHwgdzrwJBYKxDcd38ZBgSxKP/I1eiwcGas6M/g7XBqDFTcMCg 5HzdeYE41oaAzoy4num/RQsZJ2R9dXaZSaSkjlz6akQi34X01aUkNAADiepwapXhoRRW Cfpg== ARC-Message-Signature: i=2; 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=oWOHlbPX0rDrFruP0l1f5L4DVZiGOD1Yje1cIYqpC1Q=; fh=xA6CZXHzZPmUyAv84t4BHZavk08RQHdhWmZbrJ8sXdA=; b=EA6S2R3UTtLR8zyKjyKW6JhGHeKDyBBGXIKbnedfNoVXP8+xcokZQw87VrEdETuO9i krHusg9MGoj1gOAMxFrsJnnk9yhhZT0kk03DIiajkFxywVCYeybJUpcJjOca9QQsEn25 IXyIXVZKlc8Qjh6Y1ReKhfPQFjncmg9IV3D13wqZiKeU5r262gHA8vC+aI15Zt2NQa3b JwEKHJqbAodPpamsQMpd91bdbbzDgfc0vpng42/8bolB1KVwdJQWQdotmLJQ9A6YBvj/ FuBcJbOpi8AowA1FHU2PNSqlzUNbxJ78ezUBMuBpWI6ETHlLWS/qk66BcCY0yK4nk3ZO rMPw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Utd78SGz; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-50900-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50900-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCVqpQYvXwKUlI6mopomdULgcEqyVu3HU4iSWioWLgNnzqflhEBCZjno61GTPnKsAWgn/8gV/q4FXLPDK8apjrEfDuNGJ9G3Qkc8Y2DWpQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b11-20020a170906038b00b00a35a68e9e91si1412064eja.909.2024.02.02.20.04.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 20:04:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50900-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Utd78SGz; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-50900-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50900-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4360F1F28CD3 for ; Sat, 3 Feb 2024 04:04:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E7F911188; Sat, 3 Feb 2024 04:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Utd78SGz" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.15]) (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 7C270F9E5; Sat, 3 Feb 2024 04:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706933047; cv=none; b=fAxET8hPq4Kb1mo4vO8fVWwZiGfGjHpM/ilwHyAKKUoIApjcE+4W6Je6164KUC99ZcXldBAM9j8Uw/kfu1hFUlWzJ48QqTUs667nRVcP3Z1Dk+fMCcy2mb68ST8woVlZJMkJaLShX91+4JBmdTvEtTLIejkxoxrrFMMtEoNVtQI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706933047; c=relaxed/simple; bh=z1W8+46dFSMzS7P+ODJHug2hSnG5Nh7Cru/GHZYPbV8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=hBiBL0k2hLXZSAeb5CZ3KonZLgoMde9Tkszf0kwZt0Sy0/bN4z5o+IYvB7o6uVjfcXeIcNqDU1YSfMdKLNZDHWLLrWHQmsu0RUwnbnkm1HQjhltOODVfISbDmtraotvmhGOIWCfDmm5JazjyJQDiqyRRPhVAQoNwYmZs4kd9aNc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Utd78SGz; arc=none smtp.client-ip=198.175.65.15 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=1706933046; x=1738469046; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=z1W8+46dFSMzS7P+ODJHug2hSnG5Nh7Cru/GHZYPbV8=; b=Utd78SGzVZLPDE6/3vkRaH+wii6D0kyU3gJqtSaS9NViZ+Y565/ElL7l pgWj+Eca71nJrjJV+t5WQBN4/JjZM/t+wN625ibVbXW4nuGgKbYlHp/6l FIQEDcZ1+XKEUNqpq15e0kztn5c2ZJJkVjXlbI7ns1ymE3HDuh3/bNpel qEKa/FEdJ9VdnpG5fE4dwpWr9f7anjjWWn5Bx50yY/LGW70llL162N3GB XkuXPsRte+ULIOorSrAfLdc930HAre73Qv2/TgWYySLF/JtxAiqdaS/bq AWB+ZaX0fDLjnsAoaMLSE6DW5dzZv8kI+SkBV1ujyapKP/QoACmg3iptI w==; X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="4181415" X-IronPort-AV: E=Sophos;i="6.05,238,1701158400"; d="scan'208";a="4181415" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Feb 2024 20:04:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="823382506" X-IronPort-AV: E=Sophos;i="6.05,238,1701158400"; d="scan'208";a="823382506" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga001.jf.intel.com with ESMTP; 02 Feb 2024 20:04:03 -0800 From: Ricardo Neri To: "Rafael J. Wysocki" Cc: Len Brown , Srinivas Pandruvada , Stanislaw Gruszka , Zhao Liu , Zhuocheng Ding , x86@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Ricardo Neri Subject: [PATCH 2/9] thermal: intel: hfi: Introduce the hfi_table structure Date: Fri, 2 Feb 2024 20:05:08 -0800 Message-Id: <20240203040515.23947-3-ricardo.neri-calderon@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240203040515.23947-1-ricardo.neri-calderon@linux.intel.com> References: <20240203040515.23947-1-ricardo.neri-calderon@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Zhao Liu The virtualization of HFI requires to parse the HFI table of the host system. Instead of exposing several pointers to the various section of the table, create a single data structure that describes the table and can be shared more cleanly. A separate data structure that represents an HFI table improves readability as it makes it clear that the table is one of several attributes of an HFI instance. No functional changes. Cc: Len Brown Cc: Rafael J. Wysocki Cc: Srinivas Pandruvada Cc: Stanislaw Gruszka Cc: x86@kernel.org Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Suggested-by: Ricardo Neri Co-developed-by: Zhuocheng Ding Signed-off-by: Zhuocheng Ding Signed-off-by: Zhao Liu Signed-off-by: Ricardo Neri --- drivers/thermal/intel/intel_hfi.c | 47 ++++++++++++++++++------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c index 9aaca74bdfa3..eeabdf072efd 100644 --- a/drivers/thermal/intel/intel_hfi.c +++ b/drivers/thermal/intel/intel_hfi.c @@ -97,12 +97,25 @@ struct hfi_hdr { } __packed; /** - * struct hfi_instance - Representation of an HFI instance (i.e., a table) - * @local_table: Base of the local copy of the HFI table + * struct hfi_table - Representation of an HFI table + * @base_addr: Base address of the local copy of the HFI table * @timestamp: Timestamp of the last update of the local table. * Located at the base of the local table. * @hdr: Base address of the header of the local table * @data: Base address of the data of the local table + */ +struct hfi_table { + union { + void *base_addr; + u64 *timestamp; + }; + void *hdr; + void *data; +}; + +/** + * struct hfi_instance - Representation of an HFI instance (i.e., a table) + * @local_table: Local copy of HFI table for this instance * @cpus: CPUs represented in this HFI table instance * @hw_table: Pointer to the HFI table of this instance * @update_work: Delayed work to process HFI updates @@ -112,12 +125,7 @@ struct hfi_hdr { * A set of parameters to parse and navigate a specific HFI table. */ struct hfi_instance { - union { - void *local_table; - u64 *timestamp; - }; - void *hdr; - void *data; + struct hfi_table local_table; cpumask_var_t cpus; void *hw_table; struct delayed_work update_work; @@ -175,7 +183,7 @@ static void get_hfi_caps(struct hfi_instance *hfi_instance, s16 index; index = per_cpu(hfi_cpu_info, cpu).index; - caps = hfi_instance->data + index * hfi_features.cpu_stride; + caps = hfi_instance->local_table.data + index * hfi_features.cpu_stride; cpu_caps[i].cpu = cpu; /* @@ -292,7 +300,7 @@ void intel_hfi_process_event(__u64 pkg_therm_status_msr_val) * where a lagging CPU entered the locked region. */ new_timestamp = *(u64 *)hfi_instance->hw_table; - if (*hfi_instance->timestamp == new_timestamp) { + if (*hfi_instance->local_table.timestamp == new_timestamp) { thermal_clear_package_intr_status(PACKAGE_LEVEL, PACKAGE_THERM_STATUS_HFI_UPDATED); raw_spin_unlock(&hfi_instance->event_lock); return; @@ -304,7 +312,7 @@ void intel_hfi_process_event(__u64 pkg_therm_status_msr_val) * Copy the updated table into our local copy. This includes the new * timestamp. */ - memcpy(hfi_instance->local_table, hfi_instance->hw_table, + memcpy(hfi_instance->local_table.base_addr, hfi_instance->hw_table, hfi_features.nr_table_pages << PAGE_SHIFT); /* @@ -339,11 +347,12 @@ static void init_hfi_cpu_index(struct hfi_cpu_info *info) static void init_hfi_instance(struct hfi_instance *hfi_instance) { /* The HFI header is below the time-stamp. */ - hfi_instance->hdr = hfi_instance->local_table + - sizeof(*hfi_instance->timestamp); + hfi_instance->local_table.hdr = hfi_instance->local_table.base_addr + + sizeof(*hfi_instance->local_table.timestamp); /* The HFI data starts below the header. */ - hfi_instance->data = hfi_instance->hdr + hfi_features.hdr_size; + hfi_instance->local_table.data = hfi_instance->local_table.hdr + + hfi_features.hdr_size; } /* Caller must hold hfi_instance_lock. */ @@ -439,7 +448,7 @@ void intel_hfi_online(unsigned int cpu) * if needed. */ mutex_lock(&hfi_instance_lock); - if (hfi_instance->hdr) + if (hfi_instance->local_table.hdr) goto enable; /* @@ -459,9 +468,9 @@ void intel_hfi_online(unsigned int cpu) * Allocate memory to keep a local copy of the table that * hardware generates. */ - hfi_instance->local_table = kzalloc(hfi_features.nr_table_pages << PAGE_SHIFT, - GFP_KERNEL); - if (!hfi_instance->local_table) + hfi_instance->local_table.base_addr = kzalloc(hfi_features.nr_table_pages << PAGE_SHIFT, + GFP_KERNEL); + if (!hfi_instance->local_table.base_addr) goto free_hw_table; init_hfi_instance(hfi_instance); @@ -512,7 +521,7 @@ void intel_hfi_offline(unsigned int cpu) if (!hfi_instance) return; - if (!hfi_instance->hdr) + if (!hfi_instance->local_table.hdr) return; mutex_lock(&hfi_instance_lock); -- 2.25.1