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 4FEB5606A322 for ; Wed, 2 Dec 2026 18:58:36 +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=fIXZB1KJ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 193CB112458; Wed, 2 Dec 2026 18:58:31 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3385E112459 for ; Wed, 2 Dec 2026 18:58:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796237905; x=1827773905; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D3zHjcRQCKB38VsssD1ugUrL0OH/A/0lBnicxnNTyiE=; b=fIXZB1KJ85R4fX7DfLkGzN4fHDQ0EvytFU/1tM/CBCkFLT84qtq7nE7p KVUFH7rm60+4dWU7Mfq6E1bSppRZtRI55x+JpfzOsrrZ9zB+o9/mmghPQ AOMXf3IgNTFszWraK5MHcfAZTauDVLtx/C4sA7quOMdXtELXdbB7eWBzi MOi9QzLXKzIxMCcy5FlJ/D8+14sOmCTD2AoJoTpiYu9W3LaNXLHukMxIn exDhWHFl62U7sUnDQ4eqX1JcVcXJByT4MDfN5SfLf5CxIlUu6/TlQh2G8 FrYEa8H/M59AtlEM6ZGmAar9/S/miglHGxbZxtL83SZ9eGa+LOAx2mi7H g==; X-CSE-ConnectionGUID: 96WhZdq0StiyvnSx8Sg15g== X-CSE-MsgGUID: 4YAa0NRPT9W1TukubjZeVA== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5071178" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5071178" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 10:58:25 -0800 X-CSE-ConnectionGUID: 4ld2SXl1RxK6mXvs6jmK7g== X-CSE-MsgGUID: VMw9CLL6QQG1V4UWlRWCkQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13615339" Received: from sinjan-super-server.iind.intel.com ([10.190.239.39]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 10:58:22 -0800 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, ravi.kishore.koppuravuri@intel.com, Karthik Poosa Subject: [PATCH v8 08/11] drm/xe: Expose tjmax_fan_control_enable device sysfs Date: Thu, 3 Dec 2026 00:29:38 +0530 Message-Id: <20261202185941.1774272-9-karthik.poosa@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261202185941.1774272-1-karthik.poosa@intel.com> References: <20261202185941.1774272-1-karthik.poosa@intel.com> X-Archived-By: 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-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-18.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,USER_AGENT_GIT 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 Add a device attribute to read and configure firmware TjMax fan control, which forces maximum fan PWM as SoC temperature approaches TjMax or GDDR/VR temperature approaches its thermal maximum. Reviewed-by: Rodrigo Vivi Signed-off-by: Karthik Poosa --- v2: - Expose this attribute only if CONFIG_HWMON is defined.(sashiko) - Change month to December in sysfs ABI documentation. - Remove wrong comment for fan_control_attr_group. Tjmax fan control support cannot be enable with late binding. .../ABI/testing/sysfs-driver-intel-xe-gpu | 20 ++++++ drivers/gpu/drm/xe/xe_device_sysfs.c | 63 +++++++++++++++++++ drivers/gpu/drm/xe/xe_pcode_api.h | 3 + 3 files changed, 86 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-driver-intel-xe-gpu b/Documentation/ABI/testing/sysfs-driver-intel-xe-gpu index b563b7e8a9d9..2ff5939af249 100644 --- a/Documentation/ABI/testing/sysfs-driver-intel-xe-gpu +++ b/Documentation/ABI/testing/sysfs-driver-intel-xe-gpu @@ -21,6 +21,26 @@ Description: This sysfs file is present only on Crescent Island devices. It is readable by all users. +What: /sys/bus/pci/drivers/xe/.../tjmax_fan_control_enable +Date: December 2026 +KernelVersion: 7.5 +Contact: intel-xe@lists.freedesktop.org +Description: + RW. Firmware TjMax fan control. + + Write 1 to enable or 0 to disable firmware TjMax fan control, + which forces maximum fan PWM as SoC temperature approaches + TjMax or GDDR/VR temperature approaches its thermal maximum. + Reads return 1 if enabled and 0 otherwise. + + This mode is applied by firmware on top of the hwmon + pwm[1-3]_enable selection; hwmon pwm[1-3] and + pwm[1-3]_enable do not reflect the override. + + This sysfs file is present only on devices with fan control + support, except SR-IOV VFs. Accesses fail with the firmware + error if the command is not supported. + What: /sys/bus/pci/drivers/xe/.../tile/memory/max_freq Date: October 2026 KernelVersion: 7.5 diff --git a/drivers/gpu/drm/xe/xe_device_sysfs.c b/drivers/gpu/drm/xe/xe_device_sysfs.c index 9b734aeefd33..29bdb6f08ae7 100644 --- a/drivers/gpu/drm/xe/xe_device_sysfs.c +++ b/drivers/gpu/drm/xe/xe_device_sysfs.c @@ -35,6 +35,11 @@ * lb_voltage_regulator_version - Voltage regulator version provisioned by late * binding. Exposed only if supported by the device. * + * tjmax_fan_control_enable - Report/change firmware TjMax fan control, which + * forces maximum fan PWM as SoC temperature approaches TjMax or GDDR/VR + * temperature approaches its thermal maximum. Exposed on devices with fan + * control support, except SR-IOV VFs. + * * shrinker_non_purgeable_seeks - Report/change the cost, relative to * purgeable buffer objects, of recreating non-purgeable buffer objects * reclaimed by the shrinker. Higher values reduce reclaim pressure on @@ -209,6 +214,58 @@ static const struct attribute_group late_bind_attr_group = { .is_visible = late_bind_attr_is_visible, }; +static ssize_t +tjmax_fan_control_enable_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev)); + u32 val = 0; + int ret; + + guard(xe_pm_runtime)(xe); + ret = xe_pcode_read(xe_device_get_root_tile(xe), + PCODE_MBOX(FAN_SPEED_CONTROL, FSC_READ_TJMAX_FAN_CONTROL_MODE, 0), + &val, NULL); + drm_dbg(&xe->drm, "pcode READ_TJMAX_FAN_CONTROL_MODE: val %#x, ret %d\n", + ret ? 0 : val, ret); + + return ret ?: sysfs_emit(buf, "%u\n", !!(val & TJMAX_FAN_CONTROL_ENABLE)); +} + +static ssize_t +tjmax_fan_control_enable_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct xe_device *xe = pdev_to_xe_device(to_pci_dev(dev)); + u32 val; + int ret; + + ret = kstrtou32(buf, 0, &val); + if (ret) + return ret; + if (val > 1) + return -EINVAL; + + guard(xe_pm_runtime)(xe); + ret = xe_pcode_write(xe_device_get_root_tile(xe), + PCODE_MBOX(FAN_SPEED_CONTROL, FSC_WRITE_TJMAX_FAN_CONTROL_MODE, 0), + val); + drm_dbg(&xe->drm, "pcode WRITE_TJMAX_FAN_CONTROL_MODE: val %u, ret %d\n", val, ret); + + return ret ?: count; +} +static DEVICE_ATTR_RW(tjmax_fan_control_enable); + +static struct attribute *fan_control_attrs[] = { +#if IS_REACHABLE(CONFIG_HWMON) + &dev_attr_tjmax_fan_control_enable.attr, +#endif + NULL +}; + +static const struct attribute_group fan_control_attr_group = { + .attrs = fan_control_attrs, +}; + /** * DOC: PCIe Gen5 Limitations * @@ -463,5 +520,11 @@ int xe_device_sysfs_init(struct xe_device *xe) return ret; } + if (xe->info.has_fan_control && !IS_SRIOV_VF(xe)) { + ret = devm_device_add_group(dev, &fan_control_attr_group); + if (ret) + return ret; + } + return 0; } diff --git a/drivers/gpu/drm/xe/xe_pcode_api.h b/drivers/gpu/drm/xe/xe_pcode_api.h index bf321ed19251..a217256f9e9d 100644 --- a/drivers/gpu/drm/xe/xe_pcode_api.h +++ b/drivers/gpu/drm/xe/xe_pcode_api.h @@ -95,6 +95,9 @@ #define FSC_READ_FAN_TABLE 0x7 #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 */ -- 2.34.1