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 1E169606A320 for ; Mon, 30 Nov 2026 21:04:08 +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=geM8GKI/ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D399210E0C5; Mon, 30 Nov 2026 21:04:02 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id 35C1210E0C5 for ; Mon, 30 Nov 2026 21:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796072637; x=1827608637; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=nyM6uQiSM2dfnkiNYBL58feMwIZFkAyVGF5QAYJZvfc=; b=geM8GKI/fIaZG/EK7hB3ykSE3VdZYp2O4p3KYpa/WBC18LfXmapqf2J7 Db3g3IONWoPZcl/m1k+UZ1ygAfkWOKESv39NDhrt0TeuNdJFCqN5kk9UB vOm/Ba4354aCGhHqKNe4wWWA9MAN0blE/Pem2Vx2ata/otKtu4CeZEgZl ncLgYjf4or72xLwOAgQ/6GkD+CKGA0t8l06AQlJnY0Ghb1zK8PJLeHcUB dkEfqrKPjJ17fnHzk+kPqUz24+05GC7xbu8Qas6LPMURdsvF1nxm7pxZB 63TEIybiM/yJBfySxRGaslszo0fBiN/9RVHgKdS/rX1HskeJos8/WqmjH w==; X-CSE-ConnectionGUID: IZMy8SKyRnOr5WQAmIthLw== X-CSE-MsgGUID: Z50PHrNDTKKJbw0BVPIYDQ== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4829661" X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="4829661" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 13:03:56 -0800 X-CSE-ConnectionGUID: v4kLvl1ARcyK9i7zW4M4fA== X-CSE-MsgGUID: jStUPECXSfyncqdCaSynLA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="13642748" Received: from orsmsx901.amr.corp.intel.com ([10.22.229.23]) by fmviesa010.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 13:03:56 -0800 Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by ORSMSX901.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Mon, 30 Nov 2026 13:03:55 -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; Mon, 30 Nov 2026 13:03:55 -0800 Received: from BL2PR02CU003.outbound.protection.outlook.com (52.101.52.3) 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; Mon, 30 Nov 2026 13:03:53 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=v4TAiWE/CNk9Bq6RE8Jc4k7v6kwdHQFsEnRpv09H2+ya6ohBOijm5qZmZPVYPQOZTtffZdMQtcqdDXIpYe8gibtF3OlQ2zt2MyNj3+FlPCBsX+DObazRnvUlPSJ/N27zzQyaFq4rzYTMUiwRE3AHS/qH/VuXPpqNgF62jkvoPMOLagiiLI0HP4iA+dCgy67saspK+OXJH6NB3HpUd0FsQINQKBV6kP57O2cKbqt9jsPBJJC/KN6ur1vzlK9RwICdziqvf73jEQVrwKRX6iKyMQrtY4EcnQktbtrjqgU/3RzfhXDFCbvH7tCsM7FArjozneeGovGiJ2h19VUKBZjBAw== 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=nyM6uQiSM2dfnkiNYBL58feMwIZFkAyVGF5QAYJZvfc=; b=H7wy8nHObK9osHOPbflZFe2tTUSPkUlkwSncJ2PKn1JiyfzggszRC5N4Awizbg8z8sfNGmwbS6Pu+ucva3ynU3he7sioWJAWqSjuZS7L4rXKCECaRLNCmwR6IeLskXuxN/GJTVAkJRAWzFl65co7Vrb9wfAdV1pema42fQPprISjQRmi2REHqQkR4MdrlOReXQskfvjIN3Jlm2x56Wh9lnuKqCvcoHbPA9bdKGsCk2jFZ+8vCOlt7NgXS5jvSPSVCtnGp3hL2IsvhhVlLY7Vdv8biVarorMPHbG7RSISGzQ9tifOAgBn5WScT3ge7nz97fqBz6Fdc4GpG5SLT97KxA== 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 PH3PPF5A636EDE4.namprd11.prod.outlook.com (2603:10b6:518:1::d21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Mon, 30 Nov 2026 21:03:50 +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.0662.007; Mon, 30 Nov 2026 21:03:50 +0000 Date: Mon, 30 Nov 2026 16:03:46 -0500 From: Rodrigo Vivi To: Karthik Poosa CC: , , , , , , , , Subject: Re: [PATCH v6 07/10] drm/xe/hwmon: Restore fan user tables after resume Message-ID: References: <20261130185050.36979-1-karthik.poosa@intel.com> <20261130185050.36979-8-karthik.poosa@intel.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261130185050.36979-8-karthik.poosa@intel.com> X-ClientProxiedBy: SJ0PR03CA0254.namprd03.prod.outlook.com (2603:10b6:a03:3a0::19) 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_|PH3PPF5A636EDE4:EE_ X-MS-Office365-Filtering-Correlation-Id: 6dc494c5-c54b-467e-c951-08df4f256e9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|376014|23010399003|10067099003|56012099006|11063799006|261021121427099003|261026140227099003|261021123027099003|261009223027099003|261026121527099003|261028144727099003|261102123227099003|261022105027099003|261022075727099003|22082099003|18002099003|4143699003; X-Microsoft-Antispam-Message-Info: t/7KouTvQDA8RlRpsa9rIk7PaCZuCZyLL0vGruJGeN0nXKfls1J6gslZI32QQOKjAf0BQcb1lxmQ620MYV8Gzae9RQz+zUvO+CkhCkZOIwj5R2vuSFkUF2p+8Iw72UPWOQMRi965bjQVF7tkrzeYsXyKR8bfG+DE6E/yR5Weq+A845lZAcRW5pYTYROA77jQruRE8EVWUSfsGKBtmKKTEZ4kQs02vp7a+o85Cmp3HQgdM87eokLDvlVklSHQXP+POKu4JmzYeOTSdu58aKqYc4yGpSLJ3AdQmHY+eocM00gP3eJ6341PWoel/r/cx68VYLblCMct4MNSRJU4sjJXbhwXBqcnrZA3wtNuqGRh1rnMZDwjlgcz1Lx7aZdmb4+oUXfzh38j9amLnwvdsmun56VS1IrWzC9mT8kmA3CWYmYbaQ7A/vM4FxpTPXInRe2oCq6zdJnJ7tZmsLgyStzqS0ekvIi/EIAYA9nYNLK2QfuI/+d59meAAgiMQ8Dzc4WtADQSaQOo6UNf2O9Vqx9eUq8aROxPyPZ4H3CcCUruu/y2qY9LbabQrEYoV9wJ5JDj52X4jwpiqJgPsDYWIJP4+l+WzifQ2dfL/ABpp/I6uqVrgdtOyMb+02/q7s1FUVKxOe+jRSD/72P5n3Mbhoib8YSvW3NB3iCjL0qO56paNUM= 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)(10067099003)(56012099006)(11063799006)(261021121427099003)(261026140227099003)(261021123027099003)(261009223027099003)(261026121527099003)(261028144727099003)(261102123227099003)(261022105027099003)(261022075727099003)(22082099003)(18002099003)(4143699003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?edXJNcX3t0m0isfcdPQauKQrsSpPSbUmI+XkczSxKFiwHa2/5qpliQTKGMVC?= =?us-ascii?Q?axqkD/CAdcCeGtYfDGW3AQPArK1En/xdFb6M7Y04I/hx45bR+y4W6S9zZhan?= =?us-ascii?Q?UiQkz2l9GnfdCFiW9rE8Ya4iQ8z87lzzlqFUzZ8ryxpprjjWCIBPeQKdBFIe?= =?us-ascii?Q?DJdRtAZ3722fz8L8zBGqinAWgjRtDhX7lpjRSEmmidxuhtRku3EYLbDTEeKU?= =?us-ascii?Q?fo+ONB54UaOpFxEGMoiJqA2ZTruY4X0Se7RI7nnPEpycT8CMsqGR70d6j5WS?= =?us-ascii?Q?99wOEW7Kvr8+rccdfWsRyIwihvmURYycymnTNHdvZ4ofshNlv/MFaRES0xUY?= =?us-ascii?Q?FT89B/XZuijz5W9Xs/A/og0/+gGjAlGnY/QG81KQQ8i8kX6zXu1rf/8rblc1?= =?us-ascii?Q?OI0L3ULt/4g/Hf5/FPJ00JNiMyyRAzzrdSL/fYs2zOfoog0k28/jeQpXYh0O?= =?us-ascii?Q?MntDKENlTzNFMYehQ/WsrY5vLzteVHlIpqER7o2hIg7iff8PmT60wMCJVvlW?= =?us-ascii?Q?rrc6EUDGMeJRJeURI3v3K+93wi66mrgpp36xvxq8uDrciS8nPxaeaBKpSpj2?= =?us-ascii?Q?5DINpwP4omh1w5kI6myswBEWNSoy+hWfTyyAnWd0taooWwf7wTF3R6YJGegq?= =?us-ascii?Q?CmN46wAfgyaTRUPjClh3d6drV3dxZ7ecpGPIES1TyNvnE+cXykXTnJAtmqbz?= =?us-ascii?Q?1iTn5Yiz2XfL/i903yjBRlywh1OkiUEqPIBQBSG84Pdq4CTDdkNUhfiG1bn5?= =?us-ascii?Q?kn8zWAU9Lhn7ycnHyneesuTTzH+Obogtz/Zh44Wz+4hyK9AD5ct9epVWCR69?= =?us-ascii?Q?ippMIdr1K6KVhA2nVpeoSfIq3KKvzE6w7fpQ96uha5hZScYic7tqbYvAGyEr?= =?us-ascii?Q?11lRZC9t5ntnZpfAJLnWOtkG8OPKUWh/6tUP9QioT6noZaysKenSE1fylhiq?= =?us-ascii?Q?cibtBErm/pzhl05d2iTxmMIAw/n6Ixjoa+JUvmPpamvJGSz6cwVQVg6i1JcU?= =?us-ascii?Q?lQEzhh5wMjuaxxJgqMbM4NjZ5ukDdkA154aukJ/g1txzuodoj/ul/F+y4p0U?= =?us-ascii?Q?u1tPuInUZGa1EWX03xJ9M/cNetnSUiQdouJeno7NpAEBm/OwU9ZKu8LTdiMa?= =?us-ascii?Q?OauKm5gdFjIvdvZH+1Ihz/oXWTrhuDqFItVHja6WBPUrPzzeksrtYPie/Od1?= =?us-ascii?Q?Cn0P+mC6iqoxQ09bAIdhy7pTtXyH90HYh6ZRN/9d2GjadAiSVLSjYdTxgINM?= =?us-ascii?Q?mpv+zVMjKxRWsmW0/BTK93MLGV6GOihuXi2v0WrLt2fJtETcaM7J55nVyTmv?= =?us-ascii?Q?W0r/R592v+YDHaci6tBQzXIzi3ouIw4GGlezEvs7hWfnuIq7do1BpTFDw9pt?= =?us-ascii?Q?12nGoythWPH/XjbuIMVJAB352nE/aNe0Fn0h0Mzs2VHqIkA3n4RP9yd4/evO?= =?us-ascii?Q?+TNAevAIf8azq402UbKC+MvfpMSpxgK7SeUQOxzts3+d1BtO4n4A1GAHVaJ5?= =?us-ascii?Q?E5zAzrJ7MyQ7YhTUZbSGr1MlueDWqhiE7W6K4Amay/ZBT/ptbBDfLiPanIVw?= =?us-ascii?Q?S5EJnyyTDnsyz0uh4hdojAkG1XaoAVZiWACmjfSQjkDqw/kTtIwkus+QxVge?= =?us-ascii?Q?8hQnBhCPw7bMzZCisKhKNskeA8xEgq2SqS9wh4eGC4U86yDd3+8DEskeOpBu?= =?us-ascii?Q?u+ECM4xsepuOlWcWhHoBbtjqzdeAqDHaF0cmj+6YJE1EMinUENOovNMvcxlA?= =?us-ascii?Q?G8Qnu3ll7g=3D=3D?= X-Exchange-RoutingPolicyChecked: ejIdXmKc10AO6sJ7Uof6EJa0H1a0Gf49hrU5seT8JnvctnR1cUnVWiGGXEwJq/GXlteB8G5Px6Rt47t7+R7dgBFCkV+TzsLnjEfYz9pkDdKl2uutA3+w/AG/LV56e/4hynlqGz/vulZ9yY6leFbIaeunQ0UZD+5P5u53sQV0g+ImLWQO5cDsXxmOh4958EhFuq5EQo4qpdmWJ9JHU+E+FHOjOjxZgCygF1GjitvasSdpghm78psj/YFXI1oZrMf0gsrnV4c6qB3V8WMUqek4sj0iEqBP0TbusihqMOMDl3AeXqvnAtO5zDvfycggxBlVRFISMSSiyKIFsCP/+bGRTg== X-MS-Exchange-CrossTenant-Network-Message-Id: 6dc494c5-c54b-467e-c951-08df4f256e9a X-MS-Exchange-CrossTenant-AuthSource: DS7PR11MB5990.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 21:03:50.0072 (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: n8p0vJcJVDaRZGMmo3ncF/KG+Q+fbB9eW2F6cac6JxT3n+dg5aQ/W1+HLexmEJWLaTZqd+CbkjrBDZX5XLqOIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH3PPF5A636EDE4 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 Tue, Dec 01, 2026 at 12:20:47AM +0530, Karthik Poosa wrote: > Preserve active manual and full-speed fan tables 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. Waiting for it from > the resume path can deadlock against the resume of the MEI device that > loads it. If restoration fails, fall back to stock fan control. > > Signed-off-by: Karthik Poosa > --- > > 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) > > drivers/gpu/drm/xe/xe_device.c | 3 + > drivers/gpu/drm/xe/xe_hwmon.c | 101 +++++++++++++++++++++++++++++++++ > drivers/gpu/drm/xe/xe_hwmon.h | 4 ++ > drivers/gpu/drm/xe/xe_pm.c | 11 +++- > 4 files changed, 116 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c > index fccb0eff54ee..066949bee1ac 100644 > --- a/drivers/gpu/drm/xe/xe_device.c > +++ b/drivers/gpu/drm/xe/xe_device.c > @@ -1428,6 +1428,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); > > @@ -1558,6 +1560,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 857c9d293f09..ea342f12a756 100644 > --- a/drivers/gpu/drm/xe/xe_hwmon.c > +++ b/drivers/gpu/drm/xe/xe_hwmon.c > @@ -217,6 +217,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; > }; > > /** > @@ -2920,4 +2922,103 @@ 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 user-table snapshot\n"); > + return; > + } > + > + mutex_lock(&hwmon->hwmon_lock); > + > + 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); > + } > + > + mutex_unlock(&hwmon->hwmon_lock); > +} > + > +/** > + * 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 user-table restore\n"); > + return; > + } > + > + mutex_lock(&hwmon->hwmon_lock); > + > + 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); > + } > + > + mutex_unlock(&hwmon->hwmon_lock); We should prefer guard() or scoped_guard() rather than explicit lock/unlock, here and in xe_hwmon_suspend(). I'm not blocking on it, but since there will likely be a v7 anyway, please change it there. Reviewed-by: Rodrigo Vivi > +} > + > 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_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 >