From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 832F1606A322 for ; Wed, 2 Dec 2026 22:29:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=m7IBMlUB Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 487DB10E0D6; Wed, 2 Dec 2026 22:29:39 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6EEE5112592 for ; Wed, 2 Dec 2026 22:29:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796250572; x=1827786572; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=Yz4WD05uVZN3gPaMWARr2m+CgqXvRt5JJiv0E+Jhras=; b=m7IBMlUBttVBv2ZLaG0rorS+sA/nPd8XQX81kQUk8c9Z/iOU4K5y3Z+W 09TdUV0R+gAqRT+diF/0Z9oacBpBoBhKXkpSovxhlc925D+zepPUR/WwL EyRsopzRNrAAy5KjSPhMEoZa+NlzLi0hJB2Nxe02k3nAoyjzDviL3fEZM 9tc7ScHtNzywEo/x7dqbQ9/f6LIbe9zU/AiproHnGpwsGW/BUvZaaob8D fetga4xnHdqEKptr1Wr8NhvMcT7pH9MplR/omPYdcEoQcKln/Q6CNwQcI 771zQAa3A7Hruyth/6PH4+3W/Rk/5JlAsM0UrkOIgb9IwX4D2S1JTNfB/ g==; X-CSE-ConnectionGUID: hBP+pJxTSp6/h01ncW+nCg== X-CSE-MsgGUID: 4ZYm21u0Q2yihyujU86wSg== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5207348" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5207348" Received: from fmviesa013.fm.intel.com ([10.60.135.153]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 14:29:32 -0800 X-CSE-ConnectionGUID: l4wieTHiS56F+79IJ8Mxsg== X-CSE-MsgGUID: 36SjWgIrQweegBS2VgWY6A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="15621586" Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25]) by fmviesa013.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 14:29:32 -0800 Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 14:29:31 -0800 Received: from ORSEDG902.ED.cps.intel.com (10.7.248.12) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Wed, 2 Dec 2026 14:29:31 -0800 Received: from CY3PR05CU001.outbound.protection.outlook.com (40.93.201.55) by edgegateway.intel.com (134.134.137.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 14:29:31 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UzxgjViqFeCoJNH5F0G/WT/7d6v1KYF3F/57ZzxBR8UlyolHgn4cAfUxehMIWaMIIrH6I5vIB3qI0lnscW6gTj7us4CLboiIsEXRxJfWEhWmCf1amnwz5nJfQ/4ueDzuvU+13xGELO8EqUHm2j2QGsVfHk2Os7MmnlyY6a2lFT//GKMRrPHif3O+M2DeNGR6wzxBcmwUaCAJC1eYzD0fKJbGXmJJiNGeGVvUEBoR3pa9WwsOxDOlIj+yU9FOBvVu0iWYJc5LhqhUSN/MHltCqIRvvgKJjfqUNKnRTODdswM6yJvG764g4iord1gRs/TNWSBWlY+ZRkYTrgH5dztiPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Yz4WD05uVZN3gPaMWARr2m+CgqXvRt5JJiv0E+Jhras=; b=co/3v0gNg1ex5qGCFYpqLhBdm0+pnfuqN2lgSqEcFX6NwGncCYXuRWrphyP2T5/lvkZThci0hSHjRZxl4rZ/OH62oNHqnBFjo9A0RVJMpW5KtJ5FQjOPkyqZy3X9N8V09ujQyJEfYxFFblDNhu/e4Q/Gq7fP2XCM0n7puS/ge9SKqS4ikkZBdM119INT2WJpzsk6+/PlL/YwoUEBcXc4KtzPMgAO7IJLH1TEPpB+/7F3ewGcG4xW/Tj/Jf2YtBmnrB/aWrb9qi3Z/03fpDjHlk/FfX/tGq4P4HLYnxgRWNcziRvDfbrJW1JPHdFL/g0v++jaZfTW/wR4dJ8XNmCXeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS7PR11MB5990.namprd11.prod.outlook.com (2603:10b6:8:71::5) by CH9PR11MB9903.namprd11.prod.outlook.com (2603:10b6:610:341::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 22:29:29 +0000 Received: from DS7PR11MB5990.namprd11.prod.outlook.com ([fe80::133c:5eed:3aec:b899]) by DS7PR11MB5990.namprd11.prod.outlook.com ([fe80::133c:5eed:3aec:b899%3]) with mapi id 15.21.0688.009; Wed, 2 Dec 2026 22:29:29 +0000 Date: Wed, 2 Dec 2026 17:29:26 -0500 From: Rodrigo Vivi To: Karthik Poosa CC: , , , , Subject: Re: [PATCH v9 09/11] drm/xe/hwmon: Restore fan user tables after resume Message-ID: References: <20261202195221.1862825-1-karthik.poosa@intel.com> <20261202195221.1862825-10-karthik.poosa@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261202195221.1862825-10-karthik.poosa@intel.com> X-ClientProxiedBy: SJ0PR03CA0072.namprd03.prod.outlook.com (2603:10b6:a03:331::17) To DS7PR11MB5990.namprd11.prod.outlook.com (2603:10b6:8:71::5) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS7PR11MB5990:EE_|CH9PR11MB9903:EE_ X-MS-Office365-Filtering-Correlation-Id: 49d86347-b66b-4098-8f4f-08df50c3bade X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|376014|23010399003|22082099003|261028144727099003|56012099006|261021123027099003|261102123227099003|261026140227099003|261022075727099003|261026121527099003|261022105027099003|261021121427099003|10067099003|261009223027099003|4143699003|11063799006|18002099003; X-Microsoft-Antispam-Message-Info: eQciftSKDHeP7kUbZs25N620ups5GDzF3y+Z0l/Ie1f9GPQEuGESKdNsswcAFesF09fGaXml0Yp1jOp2uaesyFIYhgn0DiLMP7tEPtv47T1VIT+156k0DqLV3JCtL0rlhig90p2RmSOnc3zJHy5GHkWFBHP1WteQLvpXpaaIjcsrx8HJ3/DUg6nu4lsKyi4UpVeEVOc3LJP4P896mIaPtWa7kOUEcM8sgf0KgUwdUsNk2/Kkay2tCNehqQiWCMF6G/14ZGWJNAq1/0umTv77LVCBeablZNB1FcZrWugkUcmeuPwTSrCo2hwJe3BGEhZZ0RlADJJeLl3Kr5SNUBeMfEPB5vOQt/ylV946fuzQWli04KOeR7fh91NE6x8P8qJG73rRPv9QNeyG53L/frDhEaWX+UiQZvBFEeiFct2o1thwwFt5KFPeZOuiwwdAPDxCHmba1ZYb+sMQb/jiWvPiW1Pka3G1vdpUUJuYMzyloPaQXrJwY6xz/coGCOTZtMhdC9nIt0reVSLofvrk1b2xK3mzO51J4UcjeiVMbt4qABvJfqAVa7/yYMZH+k61Nmy8lMXJLXXtYmFvcFvWFmkIyS2a9c41Wd9sDxZVBl9u5X0uGuj1Mb1J6kepFcAVkrJw0JySrRsJ1sd2CWDsVVq8bHGS/0GDP9h6csk56TVPtuk= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS7PR11MB5990.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(23010399003)(22082099003)(261028144727099003)(56012099006)(261021123027099003)(261102123227099003)(261026140227099003)(261022075727099003)(261026121527099003)(261022105027099003)(261021121427099003)(10067099003)(261009223027099003)(4143699003)(11063799006)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?PbKnCg6a/DuPkOIYDCLxEFTZn4snR7CStKA72/VbNAv9/9BC7mZYf/QLiN0l?= =?us-ascii?Q?zZPhkVvD0009D4YSquKgjkS82NaVll++HB+ReeEwS5Z88m7xSdCI+xOsskID?= =?us-ascii?Q?G8bZnVwhXUWgxto5BfV5ee8NyX+E2HFKcPaL/vpIQMDakezGi1JZpt77i9Ac?= =?us-ascii?Q?BnGgQYcxKm2VbKyZHb13X9RuQKirGkkBTosMPz2XtmePVy2I3qCtyJSUK7b2?= =?us-ascii?Q?RnzAwN1DhtOqwv1wkWgG23qY4c4cipoJBUwHji9rd4lWZnKTr8AsA7mpcMve?= =?us-ascii?Q?JVWG8HKV+A0RS3psVBaoPhbY4iH+8GsTT6fhHZK+/CCVmKOhMlmkjMlUBXZ8?= =?us-ascii?Q?iV3HAIgErFKhSAtWn32mnq9CiFp1U7ZnneVfv5HQrApRP5vt2BvatlOpgeu9?= =?us-ascii?Q?jCY9wBRHuth4midsk9HlRvO4J6v7LgvMSVpumgZUtO2JUn1ju+3HEJy8KVk9?= =?us-ascii?Q?nykpxbWNkX2mYu9FcxzikeiR/lIiiOhcIzWXhdqiRKN6jJiSX+QCl1eDyBD6?= =?us-ascii?Q?TbauJF2ElcYNM3knuFUNiuxX2U7kCUasT7yMxEKhp9+raEeOR3y0tW1isWyd?= =?us-ascii?Q?z1Fzbi2qDewoFbX19Vw4aaYBKsrxHNwBuHvTpRADvaeaB7saIr8WptpVeDZj?= =?us-ascii?Q?tuh4ojgHPchvaLItr6GSVycn+toRZAn7L1+UGmjVQNhvkBaoJ8s9FLvvXKqE?= =?us-ascii?Q?iNqauQGL5r+oIY5zQjWx/c0Q+R21QGEyg4Gyn+nL59MR4tHcn05fEFpr32ok?= =?us-ascii?Q?9zqSoqTigBVpTq8eaNwfQLESRccR8BzPMjMiyVs4lv77gz1R4coXxHpdbmA2?= =?us-ascii?Q?ZYz4y8usW2pzk8gqnf80UzafKYUevyzpuyOHwG4jct1uZHS9hK+nrrBG1HbR?= =?us-ascii?Q?BUfp52RuQl+ryqN5Dr39zVaDB8PGkheu5IoQ+Z9dxtD53i4k9NqOKVPFiq25?= =?us-ascii?Q?HN4YKUT0uH3QtfGz6yYLSI0Y4UlEKh5cfSsVnBqme7tU3TYR8Jn9ozXClnVe?= =?us-ascii?Q?Ab2XTux15cU/gMx/yWwhChI5521n4YBnFW8HorVaUvRm4yyaX/5Vp5/5lbX6?= =?us-ascii?Q?J9Bpx9MO+T5GRrFj8t25b7oy465UZM2i56NUE7Rgi6mKJ9oLu4btCTLfwSU5?= =?us-ascii?Q?WucjLjYWfNlJofp1JOBORek+Hr0dVEDHjMDysXiHzDTCnHshUakY24JHeDG+?= =?us-ascii?Q?6+tQ6pWMdomVNYjcr9O4iYhZzs1+yQi/iTadF12XAAo1qo049vGlC3ju34aX?= =?us-ascii?Q?FpBgqVQ/xC8irNbhgnUurRgWZKDaxDzStw/nntqrLsXx9bVZcbqZCQhLDpFO?= =?us-ascii?Q?NwxL/2CoO1y4eouTDK0fTRfvhMvUFeRxHgrw/8Geq5lVxYQwea/jZfq8zyum?= =?us-ascii?Q?jMz/Npvx8hXsv0ksYcJ4JZW8tzb7fSNbZHQPl9saR3uLcMYbr6zTE+7tCVnq?= =?us-ascii?Q?tBgktgCIUpEXEEsOcUbRHZyIIf6hqsgDtW04gUshkUVf9Y7aHykZyOLGXl2h?= =?us-ascii?Q?zVPlyWu/ezARznko5A4hiJR1QrqorG+cnWjAwgmHMm9q3ARsLALkN2akM3ZI?= =?us-ascii?Q?BtQA1SCZBkcHX6+y4QHdG49PUuFjt0jmmwEAxWeddmjqcBYEoSYbxMGhEpsZ?= =?us-ascii?Q?40jKS4YaSfn8jX5PuAt7EtBzyw2YNb2t0MoQGF6LKNvpXR/CbJU2Tzpp0RM6?= =?us-ascii?Q?5i7uYTCmJOs1EaLJKmHY7X87zNz23jbbgqLYO1NG/XWI3edDYhOs6mw5jefo?= =?us-ascii?Q?J8dZF3dfog=3D=3D?= X-Exchange-RoutingPolicyChecked: dEqR5ULbUNQmofwacgMB3smE9JDStHQjMlawHr+HpwLMyysPyKvn4C5aEV++rgTM6m9Hl1izHMp40g58NjkTTo/LSAFxx4sW1cJETS3HPzdgXYmV+pw6rZSQ/op/khizwQKhUDOw98iVgNqIFQQUAC51YXKAQs4lQ5S83d3o61++eO14fNPkIJIE6ceqthY4FouOSnYw1Lyqqk/jfKF443BapfiHl9BEoreJur4gHchr0Ay45CMo/MJUpIWOhhJ1nu0y9xLwY/cuE/zb8cjnv1Cf+JwRTAlo8IlJ0Jwi9HFsXjmGXRY5AikEK5hVe7eaWP/Y8N/2KvU6WlRNz1eCvQ== X-MS-Exchange-CrossTenant-Network-Message-Id: 49d86347-b66b-4098-8f4f-08df50c3bade X-MS-Exchange-CrossTenant-AuthSource: DS7PR11MB5990.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 22:29:29.5973 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: S+7VVt8o3aYJOWOD43o2zGolTmq69g4cUcZDG/PV+qKzidm7mRdOYK5O+B3OnHftZUlxPJfqFRNjIcPPe6Hs5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH9PR11MB9903 X-OriginatorOrg: intel.com X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thu, Dec 03, 2026 at 01:22:19AM +0530, Karthik Poosa wrote: > Preserve active manual and full-speed fan tables and > tjmax_fan_control_enable across system suspend, runtime D3cold, and FLR. > > On resume, restore the cached table without waiting for the late-bound > fan-control firmware, which reloads asynchronously. If restoration fails, > fall back to stock fan control. > > Signed-off-by: Karthik Poosa Reviewed-by: Rodrigo Vivi > --- > > v2: Use xe_pcode_read() instead of xe_pcode_read_timeout(). > > v3: > - Use u32 for the point index. (Soham) > - Say "user table point" in suspend warnings. (Soham) > - Sort the xe_hwmon.h include. (Soham) > - Call the system PM hooks from xe_device_suspend() and > xe_device_resume() after the upstream refactor, so FLR also > restores the table. > - Check d3cold.allowed only for runtime PM; system suspend always > loses the table. > - Pass hwmon to IS_FAN_ENABLED(). > > v4: > - Avoid fan-table reads during suspend. > - Fall back to the stock fan table on user-table restore failure. > > v5: > - Do not flush the late-binding work from xe_late_bind_pm_resume(); > it can deadlock against the MEI device resume. (sashiko) > - Drop the duplicate stock fallback in xe_hwmon_resume(). (sashiko) > > v6: Preserve fan TjMax control across suspend and resume. (Soham) > > drivers/gpu/drm/xe/xe_device.c | 3 + > drivers/gpu/drm/xe/xe_hwmon.c | 145 ++++++++++++++++++++++++++++++ > drivers/gpu/drm/xe/xe_hwmon.h | 4 + > drivers/gpu/drm/xe/xe_pcode_api.h | 6 +- > drivers/gpu/drm/xe/xe_pm.c | 11 ++- > 5 files changed, 163 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c > index 86de5f183c0a..d11e01ce50ca 100644 > --- a/drivers/gpu/drm/xe/xe_device.c > +++ b/drivers/gpu/drm/xe/xe_device.c > @@ -1425,6 +1425,8 @@ int xe_device_suspend(struct xe_device *xe, bool hibernate, bool flr) > > xe_late_bind_pm_suspend(&xe->late_bind); > > + xe_hwmon_suspend(xe, false); > + > for_each_gt(gt, xe, id) > xe_gt_suspend_prepare(gt); > > @@ -1555,6 +1557,7 @@ int xe_device_resume(struct xe_device *xe, bool flr) > xe_pxp_pm_resume(xe->pxp); > > xe_late_bind_pm_resume(&xe->late_bind); > + xe_hwmon_resume(xe, false); > > return 0; > } > diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c > index e0a0c0ba41b7..94825d1f2928 100644 > --- a/drivers/gpu/drm/xe/xe_hwmon.c > +++ b/drivers/gpu/drm/xe/xe_hwmon.c > @@ -153,6 +153,18 @@ enum xe_fan_pwm_enable_mode { > XE_FAN_PWM_UNINITIALIZED = 0xff, > }; > > +/** > + * enum xe_tjmax_fan_control_state - saved TjMax fan-control state > + */ > +enum xe_tjmax_fan_control_state { > + /** @XE_TJMAX_FAN_CONTROL_UNKNOWN: no state to restore */ > + XE_TJMAX_FAN_CONTROL_UNKNOWN, > + /** @XE_TJMAX_FAN_CONTROL_DISABLED: state was disabled before suspend */ > + XE_TJMAX_FAN_CONTROL_DISABLED, > + /** @XE_TJMAX_FAN_CONTROL_ENABLED: state was enabled before suspend */ > + XE_TJMAX_FAN_CONTROL_ENABLED, > +}; > + > /** > * enum fan_table_type - fan table types tracked per fan > */ > @@ -217,6 +229,8 @@ struct xe_hwmon_fan_info { > u32 max_rps; > /** @pwm_enable_mode: current xe_fan_pwm_enable_mode */ > u8 pwm_enable_mode; > + /** @restore_user_table: restore user fan table on next resume */ > + bool restore_user_table; > }; > > /** > @@ -277,6 +291,8 @@ struct xe_hwmon { > u32 pl2_on_boot[CHANNEL_MAX]; > /** @temp: Temperature info */ > struct xe_hwmon_thermal_info temp; > + /** @tjmax_fan_control_state: saved TjMax fan-control state */ > + enum xe_tjmax_fan_control_state tjmax_fan_control_state; > /** @curve_sda: fan curve sensor attributes */ > struct sensor_device_attribute curve_sda[XE_CURVE_ATTRS]; > /** @curve_names: names of the fan curve sensor attributes */ > @@ -2886,6 +2902,8 @@ int xe_hwmon_register(struct xe_device *xe) > if (!hwmon) > return -ENOMEM; > > + hwmon->tjmax_fan_control_state = XE_TJMAX_FAN_CONTROL_UNKNOWN; > + > /* Zero is XE_FAN_PWM_FULL_SPEED; stay unset until the stock table is read. */ > for (fan = 0; fan < FAN_MAX; fan++) > hwmon->fi[fan].pwm_enable_mode = XE_FAN_PWM_UNINITIALIZED; > @@ -2942,4 +2960,131 @@ void xe_hwmon_unregister(struct xe_device *xe) > hwmon_device_unregister(xe->hwmon->hwmon_dev); > xe->hwmon = NULL; > } > + > +/** > + * xe_hwmon_suspend - Save hwmon state before suspend > + * @xe: xe device instance > + * @runtime: true for runtime suspend, false for system suspend or FLR prepare > + * > + * Save any hwmon runtime state that must survive PM suspend transitions. > + */ > +void xe_hwmon_suspend(struct xe_device *xe, bool runtime) > +{ > + struct xe_hwmon *hwmon = READ_ONCE(xe->hwmon); > + int fan; > + > + if (!hwmon || !xe->info.has_fan_control) > + return; > + > + /* Runtime suspend keeps the fan tables unless the device enters d3cold. */ > + if (runtime && !xe->d3cold.allowed) { > + xe_dbg(xe, "d3cold not allowed, skipping fan state snapshot\n"); > + return; > + } > + > + guard(mutex)(&hwmon->hwmon_lock); > + > + if (!runtime || xe->d3cold.allowed) { > + u32 val = 0; > + int ret; > + > + hwmon->tjmax_fan_control_state = XE_TJMAX_FAN_CONTROL_UNKNOWN; > + > + ret = xe_pcode_read(xe_device_get_root_tile(xe), > + PCODE_MBOX(FAN_SPEED_CONTROL, > + FSC_READ_TJMAX_FAN_CONTROL_MODE, 0), > + &val, NULL); > + if (ret) { > + xe_warn(xe, "failed to save fan tjmax control, ret=%d\n", ret); > + } else { > + hwmon->tjmax_fan_control_state = > + (val & TJMAX_FAN_CONTROL_ENABLE) ? > + XE_TJMAX_FAN_CONTROL_ENABLED : > + XE_TJMAX_FAN_CONTROL_DISABLED; > + } > + } > + > + for (fan = 0; fan < FAN_MAX; fan++) { > + struct xe_hwmon_fan_info *fi = &hwmon->fi[fan]; > + u32 point_count = fi->fan_table[USER_FAN_TABLE].point_count; > + > + if (!IS_FAN_ENABLED(hwmon, fan)) > + continue; > + > + fi->restore_user_table = false; > + if (fi->pwm_enable_mode != XE_FAN_PWM_MANUAL_USER_TABLE && > + fi->pwm_enable_mode != XE_FAN_PWM_FULL_SPEED) > + continue; > + > + if (point_count < MIN_FAN_CONTROL_POINTS || > + point_count > MAX_FAN_CONTROL_POINTS) > + continue; > + fi->restore_user_table = true; > + xe_dbg(hwmon->xe, > + "fan %d cached user table marked for restore, point_count=%u\n", fan, > + point_count); > + } > +} > + > +/** > + * xe_hwmon_resume - Restore hwmon state after resume > + * @xe: xe device instance > + * @runtime: true for runtime resume, false for system resume or FLR done > + * > + * Restore any hwmon runtime state that was saved across suspend. > + */ > +void xe_hwmon_resume(struct xe_device *xe, bool runtime) > +{ > + struct xe_hwmon *hwmon = READ_ONCE(xe->hwmon); > + int fan; > + > + if (!hwmon || !xe->info.has_fan_control) > + return; > + > + if (runtime && !xe->d3cold.allowed) { > + xe_dbg(xe, "d3cold not allowed, skipping fan state restore\n"); > + return; > + } > + > + guard(mutex)(&hwmon->hwmon_lock); > + > + if (hwmon->tjmax_fan_control_state != XE_TJMAX_FAN_CONTROL_UNKNOWN) { > + bool enable = hwmon->tjmax_fan_control_state == XE_TJMAX_FAN_CONTROL_ENABLED; > + int ret = xe_pcode_write(xe_device_get_root_tile(xe), > + PCODE_MBOX(FAN_SPEED_CONTROL, > + FSC_WRITE_TJMAX_FAN_CONTROL_MODE, 0), > + enable); > + if (ret) > + xe_warn(xe, "failed to restore fan tjmax control, ret=%d\n", ret); > + else > + hwmon->tjmax_fan_control_state = XE_TJMAX_FAN_CONTROL_UNKNOWN; > + } > + > + for (fan = 0; fan < FAN_MAX; fan++) { > + struct xe_hwmon_fan_info *fi = &hwmon->fi[fan]; > + int ret; > + > + if (!IS_FAN_ENABLED(hwmon, fan)) > + continue; > + > + if (!fi->restore_user_table) { > + xe_dbg(xe, "fan %d user table restore not required\n", fan); > + continue; > + } > + > + /* Re-program cached user-table settings for fans active before suspend. */ > + ret = xe_hwmon_activate_user_fan_table(hwmon, fan, > + fi->pwm_enable_mode == XE_FAN_PWM_FULL_SPEED, > + USER_FAN_TABLE); > + fi->restore_user_table = false; > + if (ret) { > + xe_warn(xe, "failed to restore fan %d user table after resume, ret=%d\n", > + fan, ret); > + continue; > + } > + > + xe_dbg(xe, "fan %d user table restored\n", fan); > + } > +} > + > MODULE_IMPORT_NS("INTEL_PMT_TELEMETRY"); > diff --git a/drivers/gpu/drm/xe/xe_hwmon.h b/drivers/gpu/drm/xe/xe_hwmon.h > index e67e0134f02a..50874b6b6527 100644 > --- a/drivers/gpu/drm/xe/xe_hwmon.h > +++ b/drivers/gpu/drm/xe/xe_hwmon.h > @@ -13,9 +13,13 @@ struct xe_device; > #if IS_REACHABLE(CONFIG_HWMON) > int xe_hwmon_register(struct xe_device *xe); > void xe_hwmon_unregister(struct xe_device *xe); > +void xe_hwmon_suspend(struct xe_device *xe, bool runtime); > +void xe_hwmon_resume(struct xe_device *xe, bool runtime); > #else > static inline int xe_hwmon_register(struct xe_device *xe) { return 0; }; > static inline void xe_hwmon_unregister(struct xe_device *xe) { } > +static inline void xe_hwmon_suspend(struct xe_device *xe, bool runtime) {} > +static inline void xe_hwmon_resume(struct xe_device *xe, bool runtime) {} > #endif > > #endif /* _XE_HWMON_H_ */ > diff --git a/drivers/gpu/drm/xe/xe_pcode_api.h b/drivers/gpu/drm/xe/xe_pcode_api.h > index a217256f9e9d..b950bb064b01 100644 > --- a/drivers/gpu/drm/xe/xe_pcode_api.h > +++ b/drivers/gpu/drm/xe/xe_pcode_api.h > @@ -93,11 +93,11 @@ > #define FSC_READ_STOCK_FAN_CONTROL_POINTS 0x5 > #define FSC_READ_USER_FAN_CONTROL_POINTS 0x6 > #define FSC_READ_FAN_TABLE 0x7 > +#define FSC_WRITE_TJMAX_FAN_CONTROL_MODE 0x8 > +#define FSC_READ_TJMAX_FAN_CONTROL_MODE 0x9 > +#define TJMAX_FAN_CONTROL_ENABLE REG_BIT(0) > #define FAN_CONTROL_POINT_TEMP_MASK REG_GENMASK(7, 0) > #define FAN_CONTROL_POINT_SPEED_MASK REG_GENMASK(15, 8) > -#define FSC_WRITE_TJMAX_FAN_CONTROL_MODE 0x8 > -#define FSC_READ_TJMAX_FAN_CONTROL_MODE 0x9 > -#define TJMAX_FAN_CONTROL_ENABLE REG_BIT(0) > > #define PCODE_SCRATCH(x) XE_REG(0x138320 + ((x) * 4)) > /* PCODE_SCRATCH0 */ > diff --git a/drivers/gpu/drm/xe/xe_pm.c b/drivers/gpu/drm/xe/xe_pm.c > index f73f68bd449b..4d4b398cbeda 100644 > --- a/drivers/gpu/drm/xe/xe_pm.c > +++ b/drivers/gpu/drm/xe/xe_pm.c > @@ -20,6 +20,7 @@ > #include "xe_ggtt.h" > #include "xe_gt.h" > #include "xe_gt_idle.h" > +#include "xe_hwmon.h" > #include "xe_i2c.h" > #include "xe_irq.h" > #include "xe_late_bind_fw.h" > @@ -567,6 +568,8 @@ int xe_pm_runtime_suspend(struct xe_device *xe) > if (err) > goto out; > > + xe_hwmon_suspend(xe, true); > + > /* > * Applying lock for entire list op as xe_ttm_bo_destroy and xe_bo_move_notify > * also checks and deletes bo entry from user fault list. > @@ -683,12 +686,14 @@ int xe_pm_runtime_resume(struct xe_device *xe) > > xe_pxp_pm_resume(xe->pxp); > > - if (IS_VF_CCS_READY(xe)) > - xe_sriov_vf_ccs_register_context(xe); > - > if (xe->d3cold.allowed) > xe_late_bind_pm_resume(&xe->late_bind); > > + xe_hwmon_resume(xe, true); > + > + if (IS_VF_CCS_READY(xe)) > + xe_sriov_vf_ccs_register_context(xe); > + > out: > xe_rpm_lockmap_release(xe); > xe_pm_write_callback_task(xe, NULL); > -- > 2.34.1 >