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 103F7606A323 for ; Wed, 2 Dec 2026 06:24:40 +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=Pgu9Unnt Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CAB7410E9D1; Wed, 2 Dec 2026 06:24:34 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4E21B10E327 for ; Wed, 2 Dec 2026 06:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796192669; x=1827728669; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=43q991GK2vDFesOlKX5/Y8LlbR5wLpqHeYv4sbI903E=; b=Pgu9Unnt946/rSlK3/cfGBQdoAhh/ovmAn4BHAiMovMq8GXQyUwKnKRi 9XuXr7uiDYSW9WEDBjV3ClcvwJFEgjcuHAmvp5l/pkOMqCN4WYytJpGfS uTZbt8oCIvVp3pBvh1CvktSGGodRZbDVtrsYbB2e0mSpBOQeke1fGgLiq H766XQ6UMr7Mzuy1Q4THvuvKieiATFHDhHjMNUAZPfy1pe20qFIuYxd9o zaLkZ3Ia0FvlAyNZ3HnO97Fxm7lYnfYwismK0h7E7CvtgRUxzg9HA5dw6 H5eipkpMEho3ZbI5Ielzbjc0d+DSNlsHOVOvtYJHgoeoHsiUFvRUQLcS3 A==; X-CSE-ConnectionGUID: Zq4xUWEPSIux98MMRGUDaA== X-CSE-MsgGUID: cl6ynDANRKa6d1ja6jk2zg== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="4943637" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="4943637" Received: from fmviesa011.fm.intel.com ([10.60.135.151]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 22:24:27 -0800 X-CSE-ConnectionGUID: hpB0WAeqT6Gv7QWT/yxa6Q== X-CSE-MsgGUID: ZX7nYfdSToqL3I9h+JDNGg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="15193262" Received: from orsmsx901.amr.corp.intel.com ([10.22.229.23]) by fmviesa011.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 22:24:27 -0800 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) 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; Tue, 1 Dec 2026 22:24:25 -0800 Received: from ORSEDG901.ED.cps.intel.com (10.7.248.11) 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; Tue, 1 Dec 2026 22:24:25 -0800 Received: from MW6PR02CU001.outbound.protection.outlook.com (52.101.48.9) by edgegateway.intel.com (134.134.137.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 22:24:25 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=VkADkb8JkdKomyMYvoSuUdIkPOiamaD91WzA5/iPMHRIJuIwVVmp/1KGEbYau/DeTC67Hyf4CQ4pRKyrAxEqqh1XBJpWGPVnBXbWGm5Qe8ZX9RMgstYf8xwemfIpnVRlfJ9ewEL0z96y5mpTLjVCCs5vkOlZEPhqPD85Xgh4gWPhU27k4NC8RmRGKAh4QcJDhIKE6jyJytio18T1F1QTloIzGcds4KlnDB/Py1ZzRjII0GIvikouTlNicZK0RYb2A3GE0XPPZ8n1v30cVDBgXjJ3KZBwUo32glfc8+o8QTladPO9uDAL58taLZ8KeynRcnXm50l7yTiZjB0Zb/ukeQ== 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=43q991GK2vDFesOlKX5/Y8LlbR5wLpqHeYv4sbI903E=; b=QZ0XyeO78rG77QWXrtqgnNLr+7NHIUU3+mpDMaRMBMKEj75f7iN9aIRA3df30u1cbmJSX6gtSG53C+m5Ov6voc6aIaygTPxxyiOw3rFmcViydcSkCo5f5HS/2dQXS6nDOSwD5DORPx75kydLw8Z2BN+VEm3XGQh9M6F5x7vXlNPNUQKdw+Hwi3Dhdbftm7eP8K2QXAtzIV9NbKAoXhOHlTkBbEI5XdYrn+ChtHjrF6AopddJAR9/FJkzexyOGbRbV8YBMhwO0KKoqhha9+/x7fHRRGUTxQRU7hijRTCgpGg2a/btPQmz5xP8bsmmMjVb50epnfxBhn1glyMe6ZyyDQ== 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 LV0PR11MB9792.namprd11.prod.outlook.com (2603:10b6:408:385::5) by DS7PR11MB6224.namprd11.prod.outlook.com (2603:10b6:8:97::7) 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 06:24:23 +0000 Received: from LV0PR11MB9792.namprd11.prod.outlook.com ([fe80::1b1f:d9a8:ce76:e9d8]) by LV0PR11MB9792.namprd11.prod.outlook.com ([fe80::1b1f:d9a8:ce76:e9d8%5]) with mapi id 15.21.0688.010; Wed, 2 Dec 2026 06:24:23 +0000 Message-ID: <5b1a7587-bfbe-47b0-89f2-12ea37494591@intel.com> Date: Wed, 2 Dec 2026 11:54:13 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 08/10] drm/xe/hwmon: Refresh fan data after late binding To: "Poosa, Karthik" , CC: , , , , , , , References: <20261130185050.36979-1-karthik.poosa@intel.com> <20261130185050.36979-9-karthik.poosa@intel.com> <2d1b877f-601f-44c6-856b-51abfde22ed9@intel.com> <4c61f46b-ccce-4ec0-b115-0c845c724b88@intel.com> Content-Language: en-US From: "Nilawar, Badal" In-Reply-To: <4c61f46b-ccce-4ec0-b115-0c845c724b88@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MA5P287CA0263.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:1f1::11) To DS3PR11MB9796.namprd11.prod.outlook.com (2603:10b6:8:363::14) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV0PR11MB9792:EE_|DS7PR11MB6224:EE_ X-MS-Office365-Filtering-Correlation-Id: a3161359-8bf0-42f7-1007-08df503ce7c5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|366016|23010399003|10067099003|11063799006|56012099006|261021121427099003|261009223027099003|261021123027099003|261102123227099003|261026121527099003|261028144727099003|261022113327099003|261022075727099003|261022105027099003|261026140227099003|4143699003|22082099003|18002099003|6133799003; X-Microsoft-Antispam-Message-Info: BZXQ+2zMFni9Ks71yx9YI/9BE1iLPD64amSVZfo7rla5G0MqWnFDqRcNAZSytlGlYfB35CFmRs3kifQvzcH01y9L9QfFD8HbzZ43FR3Vij2vCIvZMAIDZ6dFGwhujBCESwv+SlHTO6XVKYltycuH1SPEjKcwCxqGSty1NoMpE5VrcFovS8fBBfF+qOYY8/TW5QAIpA0vGj7hxjZyDpoVLTUsYzi+Oh3lUe2wcyuoJiQaOcnm+DGW4q2pzUdiy5OO+w27ovagiXNscV5qTUNxS6rniqo1wyTK1z1Lnov4kACegnjQJdq3TNkRXqjJrVIp4t7zcVtPix2/PN5Hn3ZSZomExC0a//arQ7TdLeZEyP1VO6aKrEocdGSO+xfFjjVtArafjtiMfPXSW1lBfYUH9ns5tVyCd0dyNEnnFx0iTiMITTjM1jZej03ihSxWDWHEmJwirB+1wvMgmB/Cuqp69B6FWiSDw1cXs5QN5lwwd2ozgzGleQ8m36T2GnE5cgbALUnxUtdzavrFK6VivO72QThEs2UY83kAJOTcbgx15Yrcg1XUx9FBAl+5Lqee0hUq0xkjF2HLemedtTUzLZl7V/P3LbMAzDl0DHTNhdeYxqkVKOHoUxbL0MWgCylHU+d5J7VyY1MVMICf1kAw150+NVTJ70vPE7pkg3f5RlXeVp0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:LV0PR11MB9792.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016)(23010399003)(10067099003)(11063799006)(56012099006)(261021121427099003)(261009223027099003)(261021123027099003)(261102123227099003)(261026121527099003)(261028144727099003)(261022113327099003)(261022075727099003)(261022105027099003)(261026140227099003)(4143699003)(22082099003)(18002099003)(6133799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?R3lPOXU2bDN2NkhYVFp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S-Exchange-CrossTenant-AuthSource: DS3PR11MB9796.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 06:24:23.5485 (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: zkAjKzHIUBsnrRKkklDs0N/Ak/4nADUbwr0FUTcSixO3tbw+NeeFohk6JpsdMWomeEydXKMfN2AB7VQUqi3kyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR11MB6224 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 On 01-12-2026 22:11, Poosa, Karthik wrote: > > On 01-12-2026 11:02, Nilawar, Badal wrote: >> >> On 01-12-2026 00:20, Karthik Poosa wrote: >>> Refresh cached stock fan tables and maximum RPM for registered fans >>> after >>> fan-control firmware loads. The stock table can change with the late >>> bound firmware; keep the previous one if a complete table cannot be >>> read, and likewise keep the previous maximum RPM if its read fails. >>> Re-program the user table of fans in manual or full-speed mode. >>> >>> Serialize the refresh with hwmon registration and teardown. Flush >>> late binding work before releasing hwmon state, and protect fanN_max >>> reads >>> against concurrent max_rps updates. >>> >>> Signed-off-by: Karthik Poosa >>> --- >>> >>> v2: >>>   - Compare lbfw->id with XE_LB_FW_FAN_CONTROL. (Soham) >>>   - Use xe already in scope. (Soham) >>>   - Spell out "late binding" in warnings. (Soham) >>>   - Start fans enabled after late binding in automatic mode. >>> >>> v3: >>>   - Serialize the refresh with hwmon registration and teardown. Flush >>>     late binding work before releasing hwmon state, and protect >>>     fanN_max reads against concurrent max_rps updates. >>> >>> v4: >>>   - Keep the previous stock table if the refresh does not read a >>>     complete one. >>>   - Re-program user tables of fans in manual or full-speed mode after >>>     late binding. >>>   - Unregister the hwmon device outside registration_lock, so sysfs >>>     callbacks resuming the device cannot deadlock with late binding >>> work. >>>   - Keep the previous max RPM if the refresh read fails. >>> >>> v5: >>>   - Fix xe_hwmon_fan_late_binding_update() kernel-doc; it does not read >>>     the number of fans. (sashiko) >>>   - Drop a v2 note that does not belong to this patch. (sashiko) >>>   - Use "late binding" consistently and rename >>>     xe_hwmon_fan_update_post_lb() to >>> xe_hwmon_fan_late_binding_update(). >>>     (Soham) >>>   - Use guards for hwmon_lock. (Soham) >>> >>>   drivers/gpu/drm/xe/xe_hwmon.c        | 99 >>> +++++++++++++++++++++++++--- >>>   drivers/gpu/drm/xe/xe_hwmon.h        |  2 + >>>   drivers/gpu/drm/xe/xe_late_bind_fw.c |  3 + >>>   3 files changed, 96 insertions(+), 8 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c >>> b/drivers/gpu/drm/xe/xe_hwmon.c >>> index ea342f12a756..4ee51cfc9283 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" >>> @@ -257,6 +258,8 @@ struct xe_hwmon { >>>       struct device *hwmon_dev; >>>       /** @xe: Xe device */ >>>       struct xe_device *xe; >>> +    /** @registration_lock: serialize registration with late >>> binding updates */ >>> +    struct mutex registration_lock; >>>       /** @hwmon_lock: lock for rw attributes*/ >>>       struct mutex hwmon_lock; >>>       /** @scl_shift_power: pkg power unit */ >>> @@ -291,6 +294,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]) { >>> @@ -1735,16 +1745,17 @@ static int >>> xe_hwmon_read_fan_control_info(struct xe_hwmon *hwmon) >>>           struct fan_control_point stock_fcp[MAX_FAN_CONTROL_POINTS]; >>>           struct xe_hwmon_fan_info *fi = &hwmon->fi[fan]; >>>           u32 stock_fcp_count = 0; >>> +        u32 max_rps = 0; >>>             if (!IS_FAN_ENABLED(hwmon, fan)) >>>               continue; >>>             ret = xe_hwmon_pcode_read_fan_control(hwmon, >>> FSC_READ_MAX_FAN_RPS, fan, >>> -                              &fi->max_rps); >>> +                              &max_rps); >>>           if (ret) { >>> -            fi->max_rps = 0; >>>               xe_warn(hwmon->xe, "failed to read fan %d max RPS, >>> ret=%d\n", fan, ret); >>>           } else { >>> +            fi->max_rps = max_rps; >>>               xe_dbg(hwmon->xe, "fan %d max RPS %u\n", fan, >>> fi->max_rps); >>>           } >>>   @@ -2409,7 +2420,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: >>> -        *val = mul_u32_u32(hwmon->fi[channel].max_rps, 60); >>> +        scoped_guard(mutex, &hwmon->hwmon_lock) { >>> +            *val = mul_u32_u32(hwmon->fi[channel].max_rps, 60); >>> +        } >>>           return 0; >>>       default: >>>           return -EOPNOTSUPP; >>> @@ -2874,9 +2887,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 binding work before devm releases the hwmon state >>> it may use. */ >>> +    ret = devm_add_action_or_reset(dev, xe_hwmon_flush_late_bind, xe); >> Why is this needed here? I would prefer hwmon not to manage the >> lifetime or synchronization of late-binding work. > > This was needed only because hwmon state was devm-managed. > > With devm reverse cleanup, the late-bind worker could still use hwmon > after that state was released. > > Instead of this, we can use drmm-managed state, so it remains valid > until final DRM release. > >>> +    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_late_binding_update(). */ >>> +    smp_store_release(&xe->hwmon, hwmon); >>>         ret = xe_hwmon_get_preregistration_info(hwmon); >>>       if (ret) >>> @@ -2903,7 +2928,7 @@ int xe_hwmon_register(struct xe_device *xe) >>>       return 0; >>>     err_null_hwmon: >>> -    xe->hwmon = NULL; >>> +    WRITE_ONCE(xe->hwmon, NULL); >>>       return ret; >>>   } >>>   @@ -2916,11 +2941,25 @@ 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) { >>> +        mutex_unlock(&hwmon->registration_lock); >>> +        return; >>> +    } >>> +    WRITE_ONCE(xe->hwmon, NULL); >>> +    mutex_unlock(&hwmon->registration_lock); >>> + >>> +    /* Sysfs callbacks may resume and wait on late binding work >>> that takes registration_lock. */ >>> +    hwmon_device_unregister(hwmon->hwmon_dev); >>>   } >>>     /** >>> @@ -3021,4 +3060,48 @@ void xe_hwmon_resume(struct xe_device *xe, >>> bool runtime) >>>       mutex_unlock(&hwmon->hwmon_lock); >>>   } >>>   +/** >>> + * xe_hwmon_fan_late_binding_update - Update fan info after late >>> binding >>> + * @xe: xe device instance >>> + * >>> + * Re-read the maximum fan speed and stock fan tables after late >>> binding, and >>> + * re-program the user table of fans in manual or full-speed mode. >>> + */ >>> +void xe_hwmon_fan_late_binding_update(struct xe_device *xe) >>> +{ >>> +    /* Pair with the release store in xe_hwmon_register(). */ >>> +    struct xe_hwmon *hwmon = smp_load_acquire(&xe->hwmon); >>> +    int fan; >>> + >>> +    if (!hwmon || !xe->info.has_fan_control) >>> +        return; >>> + >>> +    guard(mutex)(&hwmon->registration_lock); >>> +    if (READ_ONCE(xe->hwmon) != hwmon) >>> +        return; >>> + >>> +    guard(mutex)(&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"); >>> + >>> +    for (fan = 0; fan < FAN_MAX; fan++) { >>> +        struct xe_hwmon_fan_info *fi = &hwmon->fi[fan]; >>> +        int ret; >>> + >>> +        if (!IS_FAN_ENABLED(hwmon, fan) || >>> +            (fi->pwm_enable_mode != XE_FAN_PWM_MANUAL_USER_TABLE && >>> +             fi->pwm_enable_mode != XE_FAN_PWM_FULL_SPEED)) >>> +            continue; >>> + >>> +        ret = xe_hwmon_activate_user_fan_table(hwmon, fan, >>> +                               fi->pwm_enable_mode == >>> XE_FAN_PWM_FULL_SPEED, >>> +                               USER_FAN_TABLE); >>> +        if (ret) >>> +            xe_warn(hwmon->xe, >>> +                "failed to restore fan %d user table after late >>> binding, ret=%d\n", >>> +                fan, ret); >>> +    } >>> +} >>> + >>>   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..ceb3cbe93a5d 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_late_binding_update(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_late_binding_update(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 ad39383a7e41..b76c18f91849 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_late_binding_update(xe); >> >> Instead of directly calling hwmon here, how about hwmon sync (in >> another worker) with LB and then update the table. >> >> Thanks, >> Badal > I don't think another worker is needed here, any issues with this > implementation. I would prefer to keep this worker limited to late binding. Since it handles different firmware types, including OCode, the consumer should synchronize with LB completion and handle its own post-LB update. For the fan late-binding status, lb_fan_control_version_show() can be leveraged. Flow can be. Check FAN control LB capability         |         +-- FAN LB already complete         |       |         |       +-- Refresh fan data         |         +-- FAN LB not complete                 |                 +-- Trigger LB worker                 |                 +-- Poll FAN LB status                 |                 +-- Refresh fan data once complete Thanks, Badal >> >>>           goto out; >>>       }