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 C3087606A31C for ; Mon, 30 Nov 2026 15:56:02 +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=Xw5nipRZ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 83F5010E90C; Mon, 30 Nov 2026 15:55:57 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4202F10E90C for ; Mon, 30 Nov 2026 15:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796054151; x=1827590151; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=2CZPx5zo8SQKBN31OfbFtCDXec4DzWLo0oCnPAafOBM=; b=Xw5nipRZT9DUNnv5Q+7uLK8uLVtAMo/i8wuZ/M+lV+L5c88U7Rti9vXP akAyR4xkxRNGd9NAlqKL/ZvnbPhobJkQLxKjzZW5KUvyJRpjzTQrZlKpm kyDfVnhHfU3iR7wsImRWm87JGwUsVgSwC01Fz5pvgtZRl9pugRO8O6vTL Jr1E87lvibbYYeiHs/hYBk10Pg+6XsBR5A1ZGAIEDmBiTliF/5VzI+HSe xP3rCjPHdngL073CWPlBKudz3VY39vApWxCNiRkRgl8LNopSAUE1qP1ok hZmhGWj8GEudbJrj9JKztc6+JdchOstraaTEqXwZuTER0yzv6HP7Ad+Nd Q==; X-CSE-ConnectionGUID: yn5LVYkMQwuLfw12yL5Rzg== X-CSE-MsgGUID: GBUsI0L0SfSlj/dcs5rLoA== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4896836" X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="4896836" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 07:55:47 -0800 X-CSE-ConnectionGUID: 0gS7K8pLRJCOQVrejQ5Lkw== X-CSE-MsgGUID: VSybZqwVROS2rPbu3Nzo1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,243,1787036400"; d="scan'208";a="13134188" Received: from orsmsx902.amr.corp.intel.com ([10.22.229.24]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 07:55:47 -0800 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by ORSMSX902.amr.corp.intel.com (10.22.229.24) 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 07:55:46 -0800 Received: from ORSEDG902.ED.cps.intel.com (10.7.248.12) 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 via Frontend Transport; Mon, 30 Nov 2026 07:55:46 -0800 Received: from BYAPR05CU005.outbound.protection.outlook.com (52.101.85.0) 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 07:55:41 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RD/4m+HbTcqjCUUXqKUySQ1YbWA/FUeXBWFMC0EbrParytO6qLt8LvqcyTOt245Kq8b6Qj1Tltuosf1Ab8dccFijuwaU3MXvyjnOJMY8QYmgXCitVCHfPkejLI0br3DvdFwOR4fotJUgwz9A2UiztmyOR7VVuwyXzLpteulFb0cTCL5ajDwSweYmL/s3osnpy58UHKE4WfkRfNbnnNG4OMJjNYMBnwrtZT3Ixo+JRgREHr4/4QaEEyjvl5H3CRBQ/q5IQPQpgdKTQauV/6TlkkHCtgnW7SBkRy2o6GsBCvAxsWTqdxYGMuVlj0QKA4vq6tBIeUBEsl58x0WW+6P+OQ== 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=2CZPx5zo8SQKBN31OfbFtCDXec4DzWLo0oCnPAafOBM=; b=ogSZ/V/e0AuZiFDRHe7jbhR4Sk0jDi543PfZ/kTzVp8hbRa6C6IVPEh78z52V2nya0jBYKvLTaNE4Ev6KwrVX5wkgKbIZBLo+ZSa4ukvmAUS04M8V0ks0uWp5ShfmYwd26L9eUpQJS4Fu/jPWc0IwGNsPVkR6MyOPJxJFWTfPAhgnFH3NKoK9AM8rSvSjSv6YPiQlt+7YmCbvDhT+ue1PmRZtoFJRqqu39qrYiB5OeTl0whtGQO7oMH5U8sjjwnzwTchUviWj0XewRf4zX0taiPTevNxmgMwzMYZuhmkEoRjE7PYDyaQrpIJDxL5p6Wtegrx6ITLW/O8+faas3O22g== 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 DS6PR11MB087165.namprd11.prod.outlook.com (2603:10b6:8:4c4::7) by MN6PR11MB8219.namprd11.prod.outlook.com (2603:10b6:208:471::7) 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 15:55:33 +0000 Received: from DS6PR11MB087165.namprd11.prod.outlook.com ([fe80::4223:7b03:1329:265f]) by DS6PR11MB087165.namprd11.prod.outlook.com ([fe80::4223:7b03:1329:265f%6]) with mapi id 15.21.0662.007; Mon, 30 Nov 2026 15:55:33 +0000 Message-ID: Date: Mon, 30 Nov 2026 21:25:24 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 08/10] drm/xe/hwmon: Refresh fan data after late binding To: Karthik Poosa , CC: , , , , , , , References: <20261128055923.3316956-1-karthik.poosa@intel.com> <20261128055923.3316956-9-karthik.poosa@intel.com> Content-Language: en-US From: "Purkait, Soham" In-Reply-To: <20261128055923.3316956-9-karthik.poosa@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MA5PR01CA0021.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:177::13) To DS6PR11MB087165.namprd11.prod.outlook.com (2603:10b6:8:4c4::7) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS6PR11MB087165:EE_|MN6PR11MB8219:EE_ X-MS-Office365-Filtering-Correlation-Id: 1dd4a066-68ed-4831-0c22-08df4efa5d8a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|1800799024|366016|376014|11063799006|4143699003|261009223027099003|22082099003|18002099003|10067099003|56012099006|261102123227099003|261026121527099003|261026140227099003|261028144727099003|261022105027099003|261022075727099003|261021123027099003|261021121427099003; X-Microsoft-Antispam-Message-Info: WsL0HpGO7Mo42x+UlvUD960+UuKcAGYPI4OVxipwwC06HJLmo2Ty3HE9Z7vIWw7J8woAt3qbmB6TMW2AFzrXgl94zEqaEuEekZmk+GZYdepmrX/jxwkYawcSWo7fRLQlTZ6ucEDllt61xMoIKXne0yQCqhVUdSBXWRZI0iQc5lhbOpVr4ChvkXSAQ2ErdKpKH5c/eSwQRy8wlfPBF72y9CGLbeWe8cFAY8CiVmZTr8D3M8hLgX0xd0s8AqEmDW1Yb/3GaBgy/pMP9tLJP81EdCOeiyZWaaGUSF5mJtF6iozbrjE1RcHBi9RuX9OZ0spw4XaKVVJTt3ftpSPo4hkLE/gKbDuA921AMDHxCDgZ6cC5jJ4/2L4NSM8lAdDTK9djk+b0rKg7FpJQqoVEDrDwE3Y/5xoCzNTShEuoQ5Qz6QOBYQxybOyxp8YK66P4EDehcV6HncjzgjHaWTZcy2JEQIcqK+viV7z3qUq+YV6h8o9OSaDAp0QQ51B8wVotyt6DvERU4NVMoXauxF6nvl8I6KBFSvv+cWJG08FP2wCqFejBvwbLc2oUhj+0o5gND5ZAm13zBlKZsjKo8UasTFoa9Iflwv4wO2AKwTBaeYX10pu+gU/PMAbQaAOYzbJWURr/e+fEFOtveg/vCvozPblewgYcghpHZo92VDZYspMFmLg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS6PR11MB087165.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(23010399003)(1800799024)(366016)(376014)(11063799006)(4143699003)(261009223027099003)(22082099003)(18002099003)(10067099003)(56012099006)(261102123227099003)(261026121527099003)(261026140227099003)(261028144727099003)(261022105027099003)(261022075727099003)(261021123027099003)(261021121427099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Wk1Zdjd4eHJaRlVtUlJXT0tMTHczWkZZTmNZemI1UWFsaXNaSkdVNVptSFdw?= =?utf-8?B?QXdXanVCMU1wTWtCZEowdUtnTHRJMmswTUgzNDg2aHc0QzZpR3pXMVBub0ow?= =?utf-8?B?UjFNcGJsQS90aVFNV1IvdFMvWnBQQi9SQnNnRm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6WFBNK2dGNUprNVArcGU2WUpwc2ptL25CbVp6ZytUQ0ExdW5aRGdr?= =?utf-8?B?VkZKcnhaUUFRZ0Vwd05TWkRpbHl2L3o4T0M2Ti9MMEtoaDI3QVh6Z1c0S3E0?= =?utf-8?B?cnNsWExsSXp3QTBPRjNCQnF0MmtJQ01DYVpPTlh3Nkh3aDEzNDJ2bGVGZHhh?= =?utf-8?B?TncrV2cybkIrQjJreGZZb09QZXFhZjFmN2pKbXlIcWFGRlcwSUw5OHIvcXl5?= =?utf-8?B?SGhUTXliNVpPamVDMThvZW5BUXF3dCttOTdKS1A3L3NhMEFTeENKOGtodkV0?= =?utf-8?B?M0JnTWNVcHlTU3hsTzVvWkF1WHpSQjRXcXU3dXE1czJ1M3k2K1dmN2FHWGNu?= =?utf-8?B?a0l4eFdnVkNtM203VGtLY3YwTUpZNkVMZTNkNlpDcFBqL1lLQTlzSnJLcmpF?= =?utf-8?Q?S5Ykag5IjjbsNoVE=3D?= X-Exchange-RoutingPolicyChecked: djTzYzaJ2dxlbRDkGvRej0zjBsLH6yMR/pwEDT4heVnu4QgpH8ZRXtrlKIPEaC01ycqCtCtzOvX1c/9GIK3k6Odmi4tQDMdyWUAKnOuMHGao3DK2C2DKEQgF0Th0vx6uyAyyclfz4DJCVBoEOHrmCgt5wbs05HkNZd8iWYRI+oFx53LDo6YrhGjYh3CF4ix7VDt1PILsp34tsLD6sw3hvCBJrLnsDkdmPXGnlHUDqewGkc9fBscUMRN4rSXX3wzrOehUo9ksDpLzMUB8ubnoQoTZz1P7ooBinYcs3R5YWAkYAb9OyHy3nEogZiyaBuq1x1Apuiw2KB0UjB+MmDxyRA== X-MS-Exchange-CrossTenant-Network-Message-Id: 1dd4a066-68ed-4831-0c22-08df4efa5d8a X-MS-Exchange-CrossTenant-AuthSource: DS6PR11MB087165.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 15:55:32.9603 (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: uR5eZ8KDaHDnaipg7y9oh3CcnE76xEmtQ60X4EGO40eh4JydkmlUVnBHSWi6kzmgrPQslMLAznLMwKZoU9A+/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN6PR11MB8219 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=-17.3 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,USER_AGENT_SANE_1 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 Hi Karthik, On 28-11-2026 11:29, Karthik Poosa wrote: > Refresh cached stock fan tables and maximum RPM for registered fans after > fan-control firmware loads. > > Serialize the refresh with hwmon registration and teardown. Flush > late-bind work before releasing hwmon state, and protect fanN_max reads > against concurrent max_rps updates. > > v2: > - Compare lbfw->id with XE_LB_FW_FAN_CONTROL. (Soham) > - Use xe already in scope. (Soham) > - Spell out "late binding" in warnings. (Soham) > - Return an error from xe_hwmon_get_fan_enable_mask() and keep the > old mask if the read fails. > - Start fans enabled after late binding in automatic mode. > > v3: > - Serialize the refresh with hwmon registration and teardown. Flush > late-bind work before releasing hwmon state, and protect fanN_max reads > against concurrent max_rps updates. > > Signed-off-by: Karthik Poosa > --- > drivers/gpu/drm/xe/xe_hwmon.c | 71 +++++++++++++++++++++++++--- > drivers/gpu/drm/xe/xe_hwmon.h | 2 + > drivers/gpu/drm/xe/xe_late_bind_fw.c | 3 ++ > 3 files changed, 70 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c > index 3e82a9236b10..92eb0aba6d4a 100644 > --- a/drivers/gpu/drm/xe/xe_hwmon.c > +++ b/drivers/gpu/drm/xe/xe_hwmon.c > @@ -16,6 +16,7 @@ > #include "regs/xe_pcode_regs.h" > #include "xe_device.h" > #include "xe_hwmon.h" > +#include "xe_late_bind_fw.h" > #include "xe_log.h" > #include "xe_mmio.h" > #include "xe_pcode.h" > @@ -259,6 +260,8 @@ struct xe_hwmon { > struct device *hwmon_dev; > /** @xe: Xe device */ > struct xe_device *xe; > + /** @registration_lock: serialize registration with late-binding updates */ "late-binding", "late-bind", "late binding" and "lb" are all used in this patch. Could one term be used throughout? > + struct mutex registration_lock; > /** @hwmon_lock: lock for rw attributes*/ > struct mutex hwmon_lock; > /** @scl_shift_power: pkg power unit */ > @@ -293,6 +296,13 @@ struct xe_hwmon { > const struct attribute_group *groups[3]; > }; > > +static void xe_hwmon_flush_late_bind(void *arg) > +{ > + struct xe_device *xe = arg; > + > + xe_late_bind_pm_suspend(&xe->late_bind); > +} > + > static inline int prepare_power_limit_param2(const struct xe_hwmon *hwmon, int channel) > { > if (hwmon->read_power_limit_from_pcode[channel]) { > @@ -1808,7 +1818,6 @@ static int xe_hwmon_read_fan_control_info(struct xe_hwmon *hwmon) > if (!IS_FAN_ENABLED(hwmon, fan)) > continue; > > - fi->pwm_enable_mode = XE_FAN_PWM_UNINITIALIZED; > fi->fan_table[STOCK_FAN_TABLE].point_count = 0; > > ret = xe_hwmon_pcode_read_fan_control(hwmon, FSC_READ_MAX_FAN_RPS, fan, > @@ -2480,7 +2489,9 @@ xe_hwmon_fan_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val) > case hwmon_fan_input: > return xe_hwmon_fan_input_read(hwmon, channel, val); > case hwmon_fan_max: > + mutex_lock(&hwmon->hwmon_lock); > *val = mul_u32_u32(hwmon->fi[channel].max_rps, 60); > + mutex_unlock(&hwmon->hwmon_lock); Could scoped_guard(mutex, ...) be used here? > return 0; > default: > return -EOPNOTSUPP; > @@ -2948,9 +2959,21 @@ int xe_hwmon_register(struct xe_device *xe) > if (ret) > return ret; > > + ret = devm_mutex_init(dev, &hwmon->registration_lock); > + if (ret) > + return ret; > + > + /* Flush late-bind work before devm releases the hwmon state it may use. */ > + ret = devm_add_action_or_reset(dev, xe_hwmon_flush_late_bind, xe); > + if (ret) > + return ret; > + > + guard(mutex)(&hwmon->registration_lock); > + > /* There's only one instance of hwmon per device */ > hwmon->xe = xe; > - xe->hwmon = hwmon; > + /* Pair with the acquire load in xe_hwmon_fan_update_post_lb(). */ > + smp_store_release(&xe->hwmon, hwmon); > > ret = xe_hwmon_get_preregistration_info(hwmon); > if (ret) > @@ -2977,7 +3000,7 @@ int xe_hwmon_register(struct xe_device *xe) > return 0; > > err_null_hwmon: > - xe->hwmon = NULL; > + WRITE_ONCE(xe->hwmon, NULL); > return ret; > } > > @@ -2990,11 +3013,21 @@ int xe_hwmon_register(struct xe_device *xe) > */ > void xe_hwmon_unregister(struct xe_device *xe) > { > - if (!xe->hwmon) > + struct xe_hwmon *hwmon; > + > + /* Stop updates before unregistering hwmon or unplugging the device. */ > + xe_late_bind_pm_suspend(&xe->late_bind); > + > + hwmon = READ_ONCE(xe->hwmon); > + if (!hwmon) > return; > > - hwmon_device_unregister(xe->hwmon->hwmon_dev); > - xe->hwmon = NULL; > + mutex_lock(&hwmon->registration_lock); > + if (READ_ONCE(xe->hwmon) == hwmon) { > + hwmon_device_unregister(hwmon->hwmon_dev); > + WRITE_ONCE(xe->hwmon, NULL); > + } > + mutex_unlock(&hwmon->registration_lock); > } > > /** > @@ -3103,4 +3136,30 @@ void xe_hwmon_resume(struct xe_device *xe, bool runtime) > mutex_unlock(&hwmon->hwmon_lock); > } > > +/** > + * xe_hwmon_fan_update_post_lb - Update fan info after late binding > + * @xe: xe device instance > + * > + * This function reads the number of fans and their stock table after late binding. > + */ > +void xe_hwmon_fan_update_post_lb(struct xe_device *xe) > +{ > + /* Pair with the release store in xe_hwmon_register(). */ > + struct xe_hwmon *hwmon = smp_load_acquire(&xe->hwmon); > + > + if (!hwmon || !xe->info.has_fan_control) > + return; > + > + guard(mutex)(&hwmon->registration_lock); > + if (READ_ONCE(xe->hwmon) != hwmon) > + return; > + > + mutex_lock(&hwmon->hwmon_lock); > + > + if (xe_hwmon_read_fan_control_info(hwmon)) > + xe_warn(hwmon->xe, "failed to read stock fan tables after late binding\n"); > + > + mutex_unlock(&hwmon->hwmon_lock); Could scoped_guard(mutex, ...) be used here? Regards, Soham > +} > + > 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 50874b6b6527..4d46290e7a9d 100644 > --- a/drivers/gpu/drm/xe/xe_hwmon.h > +++ b/drivers/gpu/drm/xe/xe_hwmon.h > @@ -15,11 +15,13 @@ 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); > +void xe_hwmon_fan_update_post_lb(struct xe_device *xe); > #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) {} > +static inline void xe_hwmon_fan_update_post_lb(struct xe_device *xe) {} > #endif > > #endif /* _XE_HWMON_H_ */ > diff --git a/drivers/gpu/drm/xe/xe_late_bind_fw.c b/drivers/gpu/drm/xe/xe_late_bind_fw.c > index c577e2d51620..6fe154ea01c3 100644 > --- a/drivers/gpu/drm/xe/xe_late_bind_fw.c > +++ b/drivers/gpu/drm/xe/xe_late_bind_fw.c > @@ -14,6 +14,7 @@ > > #include "xe_configfs.h" > #include "xe_device.h" > +#include "xe_hwmon.h" > #include "xe_late_bind_fw.h" > #include "xe_pcode.h" > #include "xe_pcode_api.h" > @@ -298,6 +299,8 @@ static void xe_late_bind_work(struct work_struct *work) > if (!ret) { > drm_dbg(&xe->drm, "Load %s firmware successful\n", > fw_id_to_name[lbfw->id]); > + if (lbfw->id == XE_LB_FW_FAN_CONTROL) > + xe_hwmon_fan_update_post_lb(xe); > goto out; > } >