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 51DF8606A322 for ; Thu, 3 Dec 2026 09:05:55 +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=ejKIO3jw Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 117CB10E4F9; Thu, 3 Dec 2026 09:05:50 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2DD4E112166 for ; Thu, 3 Dec 2026 09:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796288744; x=1827824744; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D3zHjcRQCKB38VsssD1ugUrL0OH/A/0lBnicxnNTyiE=; b=ejKIO3jwOcsF1vPdowlRQig6ePFkQrWCf4uq3wsBcZ5QWIxSV/kNo80s sjROz6q1moBXGyS+XDvocXVg9KDLgHqVDRIxNUsHQe8QV2OxCpXbZA7H7 QbPKZ3v1G7s9IyAuJs13/mBF7rDVxymgENtoCl/awLUaf+mS8YsWoGuR8 i2v3jKU5LgyceFnv2ov44GCy7nFw5ZXJXTxIPx5amZTCyEHIWJPZIuo8c Od1NF7DffpEi/EYCn/+4/JEOi2/UPlNEWO6BeIjLnxPCnQNNOB9iDeFMv zHdX53xpvDg1UWLjlBO73U+Vt+CweZp7PqJ/oiEaxT5N5zWzi7NxmmGcy w==; X-CSE-ConnectionGUID: d32GU3kgS6aoD3r/YCMbug== X-CSE-MsgGUID: MazRlbDNSuCDSKbAevBP9w== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5254274" X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="5254274" Received: from fmviesa013.fm.intel.com ([10.60.135.153]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 01:05:43 -0800 X-CSE-ConnectionGUID: gpesr2TUTDGPWr+bWcjhjQ== X-CSE-MsgGUID: y1IRr2/5QrO6hLJItkEOEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="15730395" Received: from sinjan-super-server.iind.intel.com ([10.190.239.39]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 01:05:41 -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, soham.purkait@intel.com, riana.tauro@intel.com, Karthik Poosa Subject: [PATCH v11 08/11] drm/xe: Expose tjmax_fan_control_enable device sysfs Date: Thu, 3 Dec 2026 14:37:02 +0530 Message-Id: <20261203090705.2500610-9-karthik.poosa@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261203090705.2500610-1-karthik.poosa@intel.com> References: <20261203090705.2500610-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