Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 230C8CA9ED0 for ; Mon, 12 Oct 2026 13:05:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CCEAF10F09C; Mon, 12 Oct 2026 13:05:21 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id E1C0610F06F for ; Mon, 12 Oct 2026 13:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1791810313; x=1823346313; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JWwJdElCdKud8phzPw/mCSKoVsuS4QOZQVtcm7hyZ0A=; b=bQJuXucamR+HsYxXFzRtSq1tthYGZPQxHRE7EED3KEt83H0N4Q5MzHoe cOoUiLi9aJKMgWm2iEfJZANdu6V2VXTA81JAH+SjCsXBlR0m/Cw9hO0hX 5Fn81RaDmA7kk8kA2iqw4+hpK/hbQDXWZavh4mDy3iJqR7DFsQ2ZGtWWN sIZWLjI+XEEBHu+A2DwbZH/9F57cqX+6hpU+iQkv+h6kC0aRO/IclThVD kTeSnikbfuoKhEcIq3+am98YVmhm5+qR9Gfu+/ywXgUPLPvutsQ7JmstB t9ybhaQUPn9Yry3xRQlpJknSw1yGtdJBF44usOg33wqn+y5AzbVOr1OBF g==; X-CSE-ConnectionGUID: AI9SYD3eTJur2/ncnWWpeQ== X-CSE-MsgGUID: jBVgXHbvRI6dPiyqKlEbfQ== X-IronPort-AV: E=McAfee;i="6800,10657,11933"; a="527278" X-IronPort-AV: E=Sophos;i="6.27,153,1787036400"; d="scan'208";a="527278" Received: from fmviesa012.fm.intel.com ([10.60.135.152]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2026 06:05:13 -0700 X-CSE-ConnectionGUID: nW4oOhDFQwymurq5WNrjFQ== X-CSE-MsgGUID: nHr4mbU3SPWrTnkRaXH5JA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,153,1787036400"; d="scan'208";a="2681994" Received: from sinjan-super-server.iind.intel.com ([10.190.239.39]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Oct 2026 06:05:10 -0700 From: Karthik Poosa To: intel-xe@lists.freedesktop.org Cc: rodrigo.vivi@intel.com, anshuman.gupta@intel.com, badal.nilawar@intel.com, raag.jadav@intel.com, riana.tauro@intel.com, sk.anirban@intel.com, mallesh.koujalagi@intel.com, soham.purkait@intel.com, Karthik Poosa Subject: [PATCH v10 08/16] drm/xe/hwmon: Cache temperature availability to reduce probe time Date: Mon, 12 Oct 2026 18:33:54 +0530 Message-Id: <20261012130401.443473-9-karthik.poosa@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261012130401.443473-1-karthik.poosa@intel.com> References: <20261012130401.443473-1-karthik.poosa@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" Avoid probing temperature sensor availability from the hwmon is_visible() callback. For MCTRL and PCIe channels, that path can trigger repeated blocking mailbox reads while sysfs attributes are being created, increasing probe time and making attribute creation sensitive to transient failures. Probe temperature availability once during preregistration and cache the result for subsequent visibility checks. Signed-off-by: Karthik Poosa Assisted-by: LLM Reviewed-by: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_hwmon.c | 39 +++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c index 73af7bab1374..d3cf90cf874d 100644 --- a/drivers/gpu/drm/xe/xe_hwmon.c +++ b/drivers/gpu/drm/xe/xe_hwmon.c @@ -146,6 +146,8 @@ struct xe_hwmon_thermal_info { }; /** @count: no of temperature sensors available for the platform */ u8 count; + /** @available: temperature sensor availability cached at registration */ + bool available[CHANNEL_MAX]; union { /** @value: per-sensor raw mailbox temperature; bit7=sign, bits6:0=magnitude */ u8 value[U8_MAX + 1]; @@ -1011,7 +1013,7 @@ static void xe_hwmon_get_voltage(struct xe_hwmon *hwmon, int channel, long *valu *value = DIV_ROUND_CLOSEST(REG_FIELD_GET(VOLTAGE_MASK, reg_val) * 2500, SF_VOLTAGE); } -static bool is_temp_available(struct xe_hwmon *hwmon, int channel) +static bool xe_hwmon_temp_probe(struct xe_hwmon *hwmon, int channel) { struct xe_mmio *mmio = xe_root_tile_mmio(hwmon->xe); struct xe_reg reg; @@ -1032,10 +1034,6 @@ static bool is_temp_available(struct xe_hwmon *hwmon, int channel) return false; } - if (channel >= CHANNEL_VRAM_N) - sprintf(hwmon->temp.vram_label[channel - CHANNEL_VRAM_N], - "vram_ch_%d", channel - CHANNEL_VRAM_N); - return true; case CHANNEL_MCTRL: return hwmon->temp.count && !get_mc_temp(hwmon, NULL); @@ -1046,6 +1044,22 @@ static bool is_temp_available(struct xe_hwmon *hwmon, int channel) } } +static void xe_hwmon_init_temp_info(struct xe_hwmon *hwmon) +{ + int channel; + + if (hwmon->xe->info.has_mbx_thermal_info && xe_hwmon_pcode_read_thermal_info(hwmon)) + drm_warn(&hwmon->xe->drm, "Thermal mailbox not supported by card firmware\n"); + + for (channel = 0; channel < CHANNEL_MAX; channel++) { + hwmon->temp.available[channel] = xe_hwmon_temp_probe(hwmon, channel); + if (hwmon->temp.available[channel] && + in_range(channel, CHANNEL_VRAM_N, MAX_VRAM_CHANNELS)) + snprintf(hwmon->temp.vram_label[channel - CHANNEL_VRAM_N], MAX_LABEL_SIZE, + "vram_ch_%d", channel - CHANNEL_VRAM_N); + } +} + static umode_t xe_hwmon_temp_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel) { @@ -1055,11 +1069,11 @@ xe_hwmon_temp_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel) case CHANNEL_PKG: case CHANNEL_MCTRL: case CHANNEL_PCIE: - return (is_temp_available(hwmon, channel) && + return (hwmon->temp.available[channel] && hwmon->temp.limit[TEMP_LIMIT_PKG_SHUTDOWN]) ? 0444 : 0; case CHANNEL_VRAM: case CHANNEL_VRAM_N...CHANNEL_VRAM_N_MAX: - return (is_temp_available(hwmon, channel) && + return (hwmon->temp.available[channel] && hwmon->temp.limit[TEMP_LIMIT_MEM_SHUTDOWN]) ? 0444 : 0; default: return 0; @@ -1069,11 +1083,11 @@ xe_hwmon_temp_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel) case CHANNEL_PKG: case CHANNEL_MCTRL: case CHANNEL_PCIE: - return (is_temp_available(hwmon, channel) && + return (hwmon->temp.available[channel] && hwmon->temp.limit[TEMP_LIMIT_PKG_CRIT]) ? 0444 : 0; case CHANNEL_VRAM: case CHANNEL_VRAM_N...CHANNEL_VRAM_N_MAX: - return (is_temp_available(hwmon, channel) && + return (hwmon->temp.available[channel] && hwmon->temp.limit[TEMP_LIMIT_MEM_CRIT]) ? 0444 : 0; default: return 0; @@ -1081,7 +1095,7 @@ xe_hwmon_temp_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel) case hwmon_temp_max: switch (channel) { case CHANNEL_PKG: - return (is_temp_available(hwmon, channel) && + return (hwmon->temp.available[channel] && hwmon->temp.limit[TEMP_LIMIT_PKG_MAX]) ? 0444 : 0; default: return 0; @@ -1094,7 +1108,7 @@ xe_hwmon_temp_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel) case CHANNEL_MCTRL: case CHANNEL_PCIE: case CHANNEL_VRAM_N...CHANNEL_VRAM_N_MAX: - return is_temp_available(hwmon, channel) ? 0444 : 0; + return hwmon->temp.available[channel] ? 0444 : 0; default: return 0; } @@ -1636,8 +1650,7 @@ xe_hwmon_get_preregistration_info(struct xe_hwmon *hwmon) if (xe_hwmon_is_visible(hwmon, hwmon_fan, hwmon_fan_input, channel)) xe_hwmon_fan_input_read(hwmon, channel, &fan_speed); - if (hwmon->xe->info.has_mbx_thermal_info && xe_hwmon_pcode_read_thermal_info(hwmon)) - drm_warn(&hwmon->xe->drm, "Thermal mailbox not supported by card firmware\n"); + xe_hwmon_init_temp_info(hwmon); } int xe_hwmon_register(struct xe_device *xe) -- 2.25.1