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 DC0A9606A31A for ; Tue, 1 Dec 2026 13:39:01 +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=P07r+6md Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A19BC10F8DA; Tue, 1 Dec 2026 13:38:56 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1B4F310F8DB for ; Tue, 1 Dec 2026 13:38:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796132331; x=1827668331; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=4KEkBL1BOy89lZfUgGt53LuS69kkF6n2cn4ewdQcozQ=; b=P07r+6mdZtHpa/Xx0GuzM8eDqhxjlclkKIe3oFfrXmhiuCmoHaIOsHUN 33iVUYf/Pdn+NLSF5o1m/fd4d2jD2c3CO+l9t1HHCZQLTFeFPLHb6U5od /wQVM2dXGHCYU7FDD362k1a5SfUDemwyHYaMXMyTtlHLFjtqjvqqxN+Oi kY8HCZ3hKOyvMsSk64qGxqQOZKiRW+v/0uOiiHrIovHFg3LkhJu6m39Jt AT1J/rFp6xCgNZ9Z1uImLEoEu1EzK7jAYzMEDV/JpAIvkmpzOdtN8Ktlk meYBp5F07AXjF6eCdOf8y9h7xdvEeCB/g2BwJ6doh247SiRTXZDuvm38g g==; X-CSE-ConnectionGUID: EIzUjYcaT5GUSokToxYRgw== X-CSE-MsgGUID: VQKpZXXsRuiBiHhLZqjMDg== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="4861889" X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="4861889" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 05:38:50 -0800 X-CSE-ConnectionGUID: pe9hgtbTTyO/cDmfMFtlWA== X-CSE-MsgGUID: tysAQSo8QxCQJgXTm1D0vg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,244,1787036400"; d="scan'208";a="13185219" Received: from fmsmsx902.amr.corp.intel.com ([10.18.126.91]) by fmviesa004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 05:38:50 -0800 Received: from FMSMSX901.amr.corp.intel.com (10.18.126.90) by fmsmsx902.amr.corp.intel.com (10.18.126.91) 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 05:38:47 -0800 Received: from fmsedg902.ED.cps.intel.com (10.1.192.144) by FMSMSX901.amr.corp.intel.com (10.18.126.90) 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 05:38:47 -0800 Received: from MW6PR02CU001.outbound.protection.outlook.com (52.101.48.32) by edgegateway.intel.com (192.55.55.82) 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 05:38:47 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l8smy/9RfxblpouDNbamhok/aeDRRKw1I3QFAYf/nmm4MKnHOt+1yINRDEFFWxtuEIlgPcBkt81TP2cGO1O3nws+4eYPPwz9RD6u4+qI0+WuiGqZfsx5XKfIlPFzRfoiQLJ2S96ddM5f/b0T9cg2OWRRX4d3GZZFGmiui1kLPaBNmDwMWEKYixGb9hmeKERIComcVPq2os2axZcVJf0vR81ASdBYf5sHGPkMEA6lA4G2mM6qViOH2RAUwcCO9Hn9bVvdF4Pm8GprhPWDO+qDdKowq9cB3oqi+en3ibyE0hCnr3CiL8VFWDe06e5tdoILWUBeIqBE+H9VvUQVrXZ0xA== 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=4KEkBL1BOy89lZfUgGt53LuS69kkF6n2cn4ewdQcozQ=; b=QgIeIY8WPYXNls4A3DF8mvrPMAgf7MJpPSI7dwDK67WzTctjhrXXEb5+lIENUXpQp2Pvh40yCRT8r/pPUq/JFbiElfRaU/RAjtad0F9GVb+fARXFeq7ST8KQnLPdtZ7IzkVh0nWO5/uHtYKhWH5DaUeg9PUaFN03+vp5SqRYzYCGP5R1ngDbKVX25MyadWrC0MD3DnMRlEUVUf8Pa8eBs6YBlrEk7JhK2vqmiI6LC3RS/xCavF5T9TWdMJFn4Ik6tq6FRO/Y5kQ/q547D265vvKxVR1+Z47QQ7aTrYxYHCCqNUYCjf86BTpcHz/16xaQy6nk11dF+1TmtV4OcPk5pg== 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 LV2PR11MB155101.namprd11.prod.outlook.com (2603:10b6:408:417::6) by SAWPR11MB9736.namprd11.prod.outlook.com (2603:10b6:806:4cb::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Tue, 1 Dec 2026 13:38:43 +0000 Received: from LV2PR11MB155101.namprd11.prod.outlook.com ([fe80::4f5c:66d9:5ed2:d263]) by LV2PR11MB155101.namprd11.prod.outlook.com ([fe80::4f5c:66d9:5ed2:d263%5]) with mapi id 15.21.0688.009; Tue, 1 Dec 2026 13:38:43 +0000 Message-ID: <6503f6f7-7cdf-4e65-bb4b-838a9ec6595d@intel.com> Date: Tue, 1 Dec 2026 19:08:19 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 05/10] drm/xe/hwmon: Expose pwm[1-3]_enable To: Karthik Poosa , CC: , , , , , , , References: <20261130185050.36979-1-karthik.poosa@intel.com> <20261130185050.36979-6-karthik.poosa@intel.com> Content-Language: en-US From: "Purkait, Soham" In-Reply-To: <20261130185050.36979-6-karthik.poosa@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MA5PR01CA0018.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:177::7) 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: LV2PR11MB155101:EE_|SAWPR11MB9736:EE_ X-MS-Office365-Filtering-Correlation-Id: e8b10357-cbb2-40ea-4447-08df4fb0623b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|23010399003|366016|1800799024|11063799006|56012099006|10067099003|261021130227099003|261021123027099003|261021135927099003|261021121427099003|261021133027099003|261022075727099003|261026140227099003|261026130827099003|261022115727099003|261026135527099003|261026121527099003|261022113327099003|261009223027099003|261022105027099003|261102123227099003|261028144727099003|18002099003|22082099003|4143699003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: m6NUU+xHzMZ2KjX/JVr5xn7PjVdPGSeBNzHK1NmRBqXPeKquv90wVwfKpHMkfUx3cGzFsICjq+cC+n6tZ1/hJklXXcxom6UuW++iJinmXFz2vnW2qgK3zSNnw6ySHodlnzDWt7IfsBHDeuLxV0LomF+g7mnvSrO+wQoXAFc6/8X9GF8fPDdYwYYlRVXav/Py8DOA856Lm99Bwslf2sU2tMq5n57nEgU7/3V/LfPHRgc/z3YawB/cgs209MnIGgejGPDHv3KeF6IgG4cNFUswSaZac8XjfDA8O8ykvvQXyT3XcO/YjfVODLMvjo1N1mFFE46HhMkE0z4AZFC55wRB1vWptZGpFhXO8f0/9ZfwZhLqUKJTrcLaSlCANIfMSaUD/sCuDpONAC4dqpf8C+4Ve+yhp3kLyopBDRwnRQC3md2i4huDPBjWLeW/zjFWEPFYthl1sqDaE6ITjtC9nXhyG4Egh3Cyoi9RSQKp8xbC6b0mIdYs0PZasE8vnFfjYQ3FeajiAsz+WonHms9T9k9vQpGdprAxsP4J5hrwY5s+hEmYSma2P9dLjr6WnUdFNS/Vt5GzphS3f9u/Nf/0/y6Zbj4kEjDZg759CjKr5d4piKDrwC2FdrYVOIikvnX9zVeaghXaJG09QQ2gmcASFghqNzE8I6622FPQkav+WlTPu/0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:LV2PR11MB155101.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(23010399003)(366016)(1800799024)(11063799006)(56012099006)(10067099003)(261021130227099003)(261021123027099003)(261021135927099003)(261021121427099003)(261021133027099003)(261022075727099003)(261026140227099003)(261026130827099003)(261022115727099003)(261026135527099003)(261026121527099003)(261022113327099003)(261009223027099003)(261022105027099003)(261102123227099003)(261028144727099003)(18002099003)(22082099003)(4143699003)(6133799003)(3023799007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-M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Tenant-Network-Message-Id: e8b10357-cbb2-40ea-4447-08df4fb0623b X-MS-Exchange-CrossTenant-AuthSource: DS6PR11MB087165.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2026 13:38:43.7203 (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: 9hLp2x1QCybPQcmvwAjOXkTA3ujrztBTo5KGAiwz164nIwHWOg4SF7LIJOdRz3RYSJBDkViCraTftLWIkWGf8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SAWPR11MB9736 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 00:20, Karthik Poosa wrote: > Expose pwm[1-3]_enable to control the fan operating mode through > the hwmon interface. > > Mode 0 forces the fan to run at full speed. > Mode 1 enables user fan-table control. > Mode 2 restores firmware-controlled fan management. > > pwm[1-3] writes now require pwm[1-3]_enable to be 1 first. Since fans > start in mode 2 after probe, a pwm[1-3] write without selecting manual > mode is rejected with -EINVAL. > > Document pwm[1-3]_enable in the Xe hwmon ABI. > > Signed-off-by: Karthik Poosa > --- > > v2: > - Use xe helpers for dmesg logs. > - Update kernel version in Xe hwmon documentation. > - Correct level of some dmesg logs. > > v3: > - Each pwm_enable mode now sets its own state; drop the redundant > post-switch pwm_enable_mode/is_full_speed update. (Badal) > - Fix misindented dead assignment in the stock-table branch. > - Make error handling consistent across pwm_enable modes. (Badal) > - Document the pwm[1-3] manual-mode write precondition in the ABI. (Badal) > - Use xe_pcode_write() instead of the timeout variant api as it is not > needed. > > v4: > - Rebase on reworked pwm[1-3] patch. > - Clamp min PWM to 100% when activating the user table, since fan > table speed is in percent. > - Drop redundant channel range check in pwm write. > - Use tab indentation and update Date and KernelVersion to November > 2026 and 7.5 in the pwm[1-3]_enable ABI entry. > > v5: > - Address review comments from sashiko. > - Avoid returning pwm[1-3]_enable as XE_FAN_PWM_MANUAL_USER_TABLE, when > setting to full speed mode. (sashiko) > - Set default pwm[1-3]_enable to XE_FAN_PWM_AUTO_STOCK_TABLE after > probe. (sashiko) > - Make pwm[1-3]_enable visible only if stock fan table has valid point > count. > - Add flag XE_FAN_PWM_UNINITIALIZED. > - Fall back to the stock table if firmware does not accept a table. > > v6: > - Remove is_full_speed as it is redundant with pwm_enable_mode now. > - Rename xe_hwmon_get_stock_table_pwm() to xe_hwmon_get_active_table_pwm(). > - Avoid overwriting user table cache for full speed. > - Align pwm_enable mode kernel-doc with the ABI wording. (Soham) > - Add debug logs before -EINVAL returns. (Soham) > - Note the pwm[1-3] write precondition in the commit message. (Soham) > > .../ABI/testing/sysfs-driver-intel-xe-hwmon | 19 ++ > drivers/gpu/drm/xe/xe_hwmon.c | 229 +++++++++++++++--- > 2 files changed, 214 insertions(+), 34 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon b/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon > index 34c50f13f0b4..dbf2c6d01376 100644 > --- a/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon > +++ b/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon > @@ -354,4 +354,23 @@ Contact: intel-xe@lists.freedesktop.org > Description: RW. Target fan PWM duty value in the range 0..255, where 255 > is 100% fan speed. > > + Writing requires the corresponding pwm[1-3]_enable to be set to > + 1 (manual user-table mode) first; otherwise the write is > + rejected with -EINVAL. > + > + Only supported for particular Intel Xe graphics platforms. > + > +What: /sys/bus/pci/drivers/xe/.../hwmon/hwmon/pwm[1-3]_enable > +Date: December 2026 > +KernelVersion: 7.5 > +Contact: intel-xe@lists.freedesktop.org > +Description: RW. Fan control mode selector. > + > + Use value 0 to run fans at full speed. Use value 1 to enable > + user table control and value 2 to use firmware default behavior. > + > + The user fan curve is kept across modes 0 and 2, and re-applied > + when switching back to 1. Without a user curve, mode 1 starts > + from the firmware stock curve. > + > Only supported for particular Intel Xe graphics platforms. > diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c > index 9932003e12b6..1ef9c12b7110 100644 > --- a/drivers/gpu/drm/xe/xe_hwmon.c > +++ b/drivers/gpu/drm/xe/xe_hwmon.c > @@ -139,6 +139,20 @@ struct xe_hwmon_energy_info { > long accum_energy; > }; > > +/** > + * enum xe_fan_pwm_enable_mode - fan PWM enable modes > + */ > +enum xe_fan_pwm_enable_mode { > + /** @XE_FAN_PWM_FULL_SPEED: run the fan at full speed */ > + XE_FAN_PWM_FULL_SPEED = 0, > + /** @XE_FAN_PWM_MANUAL_USER_TABLE: user table control */ > + XE_FAN_PWM_MANUAL_USER_TABLE = 1, > + /** @XE_FAN_PWM_AUTO_STOCK_TABLE: firmware default behavior using the stock table */ > + XE_FAN_PWM_AUTO_STOCK_TABLE = 2, > + /** @XE_FAN_PWM_UNINITIALIZED: fan control mode is not established */ > + XE_FAN_PWM_UNINITIALIZED = 0xff, > +}; > + > /** > * enum fan_table_type - fan table types tracked per fan > */ > @@ -190,6 +204,8 @@ struct xe_hwmon_fan_info { > } fan_table[FAN_TABLE_MAX]; > /** @max_rps: maximum fan RPS */ > u32 max_rps; > + /** @pwm_enable_mode: current xe_fan_pwm_enable_mode */ > + u8 pwm_enable_mode; > }; > > /** > @@ -926,7 +942,9 @@ static const struct hwmon_channel_info * const hwmon_info[] = { > HWMON_CHANNEL_INFO(energy, HWMON_E_INPUT | HWMON_E_LABEL, HWMON_E_INPUT | HWMON_E_LABEL), > HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_MAX, HWMON_F_INPUT | HWMON_F_MAX, > HWMON_F_INPUT | HWMON_F_MAX), > - HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT, HWMON_PWM_INPUT, HWMON_PWM_INPUT), > + HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT | HWMON_PWM_ENABLE, > + HWMON_PWM_INPUT | HWMON_PWM_ENABLE, > + HWMON_PWM_INPUT | HWMON_PWM_ENABLE), > NULL > }; > > @@ -1175,6 +1193,7 @@ static int xe_hwmon_get_fan_point_count(struct xe_hwmon *hwmon, u8 fan, u32 *poi > { > int ret; > > + *point_count = 0; > ret = xe_hwmon_pcode_read_fan_control(hwmon, > (table_type == USER_FAN_TABLE) ? > FSC_READ_USER_FAN_CONTROL_POINTS : > @@ -1198,8 +1217,9 @@ static int xe_hwmon_get_fan_point_count(struct xe_hwmon *hwmon, u8 fan, u32 *poi > } > > /* > - * Set the fan to automatic mode by clearing the user fan table. > - * This will make the firmware run the stock fan table. > + * Set the fan to automatic mode by clearing the firmware user fan table. > + * This will make the firmware run the stock fan table. The cached user table is > + * kept so that manual mode can re-apply it. > */ > static int xe_hwmon_fan_set_auto(struct xe_hwmon *hwmon, u8 fan) > { > @@ -1210,9 +1230,86 @@ static int xe_hwmon_fan_set_auto(struct xe_hwmon *hwmon, u8 fan) > PCODE_MBOX(FAN_SPEED_CONTROL, FSC_WRITE_NUM_FAN_CONTROL_POINTS, fan), > 0); > if (ret) > - return ret; > + goto fail; > + > + fi->pwm_enable_mode = XE_FAN_PWM_AUTO_STOCK_TABLE; > + return 0; > + > +fail: > + fi->pwm_enable_mode = XE_FAN_PWM_UNINITIALIZED; > + return ret; > +} > + > +static int xe_hwmon_activate_user_fan_table(struct xe_hwmon *hwmon, u8 fan, > + bool is_full_speed, enum fan_table_type table_source) > +{ > + struct xe_pcode_write writes[MAX_FAN_CONTROL_POINTS + 1]; > + struct xe_hwmon_fan_info *fi = &hwmon->fi[fan]; > + struct fan_table *source_table; > + u32 expected_count, point_count; > + int ret, write_ret, verify_ret; > + u32 point; > + > + source_table = &fi->fan_table[table_source]; > + > + xe_dbg(hwmon->xe, "activating fan %d user table from %s table\n", fan, > + (table_source == USER_FAN_TABLE) ? "user" : "stock"); > + > + point_count = source_table->point_count; > + if (!point_count || point_count > MAX_FAN_CONTROL_POINTS) { > + xe_err(hwmon->xe, > + "fan %d %s table point count %d is invalid, cannot activate user table\n", > + fan, (table_source == USER_FAN_TABLE) ? "user" : "stock", point_count); > + return -EINVAL; > + } > + expected_count = point_count; > + > + for (point = 0; point < point_count; point++) { > + u8 temp = source_table->fcp[point].temp; > + u8 speed = is_full_speed ? 100 : min_t(u8, source_table->fcp[point].speed, 100); > + > + writes[point].mbox = PCODE_MBOX(FAN_SPEED_CONTROL, FSC_WRITE_FAN_TABLE, fan); > + writes[point].data = FIELD_PREP(FAN_CONTROL_POINT_TEMP_MASK, temp) | > + FIELD_PREP(FAN_CONTROL_POINT_SPEED_MASK, speed); > + } > + > + writes[point_count].mbox = PCODE_MBOX(FAN_SPEED_CONTROL, FSC_WRITE_NUM_FAN_CONTROL_POINTS, > + fan); > + writes[point_count].data = point_count; > + write_ret = xe_pcode_write_batch(xe_device_get_root_tile(hwmon->xe), writes, > + point_count + 1); > + if (write_ret) > + xe_dbg(hwmon->xe, "failed to write fan %d user table, ret=%d\n", fan, write_ret); > + > + verify_ret = xe_hwmon_get_fan_point_count(hwmon, fan, &point_count, USER_FAN_TABLE); > + if (write_ret || verify_ret || point_count != expected_count) { > + int failure_ret = write_ret ?: verify_ret ?: -EIO; > + > + if (verify_ret || point_count != expected_count) > + xe_err(hwmon->xe, > + "fan %d user table count mismatch: ret=%d, expected=%u, got=%u\n", > + fan, verify_ret, expected_count, point_count); > + /* Firmware may have accepted only part of the table; fall back to stock. */ > + ret = xe_hwmon_fan_set_auto(hwmon, fan); > + if (ret) > + xe_err(hwmon->xe, "failed to restore fan %d to stock mode, ret=%d\n", fan, > + ret); > + return failure_ret; > + } > + > + /* Full speed only overrides firmware; the cache keeps the manual curve. */ > + if (table_source == STOCK_FAN_TABLE) { > + for (point = 0; point < point_count; point++) { > + fi->fan_table[USER_FAN_TABLE].fcp[point].temp = > + source_table->fcp[point].temp; > + fi->fan_table[USER_FAN_TABLE].fcp[point].speed = > + min_t(u8, source_table->fcp[point].speed, 100); > + } > + fi->fan_table[USER_FAN_TABLE].point_count = point_count; > + } > > - fi->fan_table[USER_FAN_TABLE].point_count = 0; > + fi->pwm_enable_mode = is_full_speed ? XE_FAN_PWM_FULL_SPEED : > + XE_FAN_PWM_MANUAL_USER_TABLE; > > return 0; > } > @@ -1228,6 +1325,11 @@ static int xe_hwmon_set_user_fan_pwm(struct xe_hwmon *hwmon, u8 fan, u8 pwm) > u32 point_count = 0; > u8 speed; > > + if (fi->pwm_enable_mode != XE_FAN_PWM_MANUAL_USER_TABLE) { > + xe_dbg(hwmon->xe, "fan %d manual mode is not active, cannot set pwm\n", fan); > + return -EINVAL; > + } > + > /* Fan table speed are in percent. */ > speed = DIV_ROUND_CLOSEST(pwm * 100, U8_MAX); > speed = min_t(u32, speed, 100); > @@ -1256,15 +1358,14 @@ static int xe_hwmon_set_user_fan_pwm(struct xe_hwmon *hwmon, u8 fan, u8 pwm) > if (write_ret || verify_ret || point_count != MIN_FAN_CONTROL_POINTS) { > int failure_ret = write_ret ?: verify_ret ?: -EIO; > > - /* Firmware may have accepted only part of the user table. */ > - fi->fan_table[USER_FAN_TABLE].point_count = 0; > if (verify_ret || point_count != MIN_FAN_CONTROL_POINTS) > xe_err(hwmon->xe, > "fan %d PWM table count verification failed: ret=%d, count=%u\n", > fan, verify_ret, point_count); > + /* Firmware may have accepted only part of the table; fall back to stock. */ > ret = xe_hwmon_fan_set_auto(hwmon, fan); > if (ret) > - xe_err(hwmon->xe, "failed to restore fan %d to auto mode ret=%d\n", > + xe_err(hwmon->xe, "failed to restore fan %d to auto mode ret=%d\n", > fan, ret); > return failure_ret; > } > @@ -1351,6 +1452,8 @@ static int xe_hwmon_read_fan_control_info(struct xe_hwmon *hwmon) > memcpy(fi->fan_table[STOCK_FAN_TABLE].fcp, stock_fcp, > stock_fcp_count * sizeof(stock_fcp[0])); > fi->fan_table[STOCK_FAN_TABLE].point_count = stock_fcp_count; > + if (fi->pwm_enable_mode == XE_FAN_PWM_UNINITIALIZED) > + fi->pwm_enable_mode = XE_FAN_PWM_AUTO_STOCK_TABLE; > } > return ret; > } > @@ -1912,6 +2015,7 @@ xe_hwmon_pwm_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel) > > switch (attr) { > case hwmon_pwm_input: > + case hwmon_pwm_enable: > return 0644; > default: > return 0; > @@ -1971,25 +2075,43 @@ xe_hwmon_fan_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val) > } > } > > +static enum fan_table_type xe_hwmon_get_active_fan_table(struct xe_hwmon *hwmon, u8 fan) > +{ > + return (hwmon->fi[fan].pwm_enable_mode == XE_FAN_PWM_AUTO_STOCK_TABLE) ? STOCK_FAN_TABLE : > + USER_FAN_TABLE; > +} > + > /** > - * xe_hwmon_get_stock_table_pwm - Calculate PWM from the stock fan curve > + * xe_hwmon_get_active_table_pwm - Calculate PWM from the active fan curve > * @hwmon: hwmon instance, with hwmon_lock held and runtime PM active > * @channel: fan channel > * @val: calculated PWM percentage > * > - * Read package temperature and linearly interpolate the stock table. Temperatures > - * outside the table range use the speed at the nearest endpoint. > + * Read package temperature and linearly interpolate the fan table selected by > + * pwm_enable. Temperatures outside the table range use the nearest endpoint. > * > * Return: 0 on success, or a negative error code. > */ > -static int xe_hwmon_get_stock_table_pwm(struct xe_hwmon *hwmon, int channel, long *val) > +static int xe_hwmon_get_active_table_pwm(struct xe_hwmon *hwmon, int channel, long *val) > { > - const struct fan_table *table = &hwmon->fi[channel].fan_table[STOCK_FAN_TABLE]; > + const struct fan_table *table; > long temperature, pwm; > int point, ret; > > lockdep_assert_held(&hwmon->hwmon_lock); > > + switch (hwmon->fi[channel].pwm_enable_mode) { > + case XE_FAN_PWM_UNINITIALIZED: > + return -ENODATA; > + case XE_FAN_PWM_FULL_SPEED: > + *val = 100; > + return 0; > + default: > + break; > + } > + > + table = &hwmon->fi[channel].fan_table[xe_hwmon_get_active_fan_table(hwmon, channel)]; > + > if (!table->point_count) > return -ENODATA; > > @@ -2017,7 +2139,7 @@ static int xe_hwmon_get_stock_table_pwm(struct xe_hwmon *hwmon, int channel, lon > } > > *val = pwm; > - xe_dbg(hwmon->xe, "fan %d stock table active PWM value: %ld\n", channel, pwm); > + xe_dbg(hwmon->xe, "fan %d: pwm value from active table cache: %ld\n", channel, pwm); > return 0; > } > > @@ -2067,7 +2189,7 @@ static int xe_hwmon_get_pwm_from_pmt(struct xe_hwmon *hwmon, int channel, long * > return -EOPNOTSUPP; > } > > - xe_dbg(hwmon->xe, "fan %d PMT active PWM value: %u\n", channel, pwm); > + xe_dbg(hwmon->xe, "fan %d: active pwm from PMT: %u\n", channel, pwm); > > *val = pwm; > return 0; > @@ -2086,25 +2208,22 @@ xe_hwmon_pwm_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val) > > switch (attr) { > case hwmon_pwm_input: > - /* If the user fan table is not populated, get active stock pwm */ > - if (!fi->fan_table[USER_FAN_TABLE].point_count) { > - xe_dbg(hwmon->xe, "user fan table not active for fan %d\n", channel); > - switch (hwmon->xe->info.platform) { > - case XE_BATTLEMAGE: > - ret = xe_hwmon_get_pwm_from_pmt(hwmon, channel, &pwm); > - break; > - default: > - ret = xe_hwmon_get_stock_table_pwm(hwmon, channel, &pwm); > - break; > - } > - if (ret) > - goto unlock; > - } else { > - /* > - * pwmN writes set every user-table point to the same speed, > - * so the first point gives the cached manual PWM percentage. > - */ > - pwm = fi->fan_table[USER_FAN_TABLE].fcp[0].speed; > + switch (hwmon->xe->info.platform) { > + case XE_BATTLEMAGE: > + ret = xe_hwmon_get_pwm_from_pmt(hwmon, channel, &pwm); > + break; > + default: > + ret = xe_hwmon_get_active_table_pwm(hwmon, channel, &pwm); > + break; > + } > + if (ret == -ENODATA) { > + xe_dbg(hwmon->xe, "fan %d control mode not established\n", channel); > + goto unlock; > + } > + if (ret) { > + xe_err(hwmon->xe, "failed to get active pwm for fan %d, ret=%d\n", > + channel, ret); > + goto unlock; > } > if (pwm < 0 || pwm > 100) { > xe_err(hwmon->xe, "invalid PWM value %ld read for fan %d\n", pwm, channel); > @@ -2115,6 +2234,13 @@ xe_hwmon_pwm_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val) > *val = DIV_ROUND_CLOSEST(pwm * U8_MAX, 100); > xe_dbg(hwmon->xe, "pwm read for fan %d: %ld\n", channel, *val); > break; > + case hwmon_pwm_enable: > + if (fi->pwm_enable_mode == XE_FAN_PWM_UNINITIALIZED) { > + ret = -ENODATA; > + break; > + } > + *val = fi->pwm_enable_mode; > + break; > default: > ret = -EOPNOTSUPP; > break; > @@ -2128,8 +2254,11 @@ xe_hwmon_pwm_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val) > static int > xe_hwmon_pwm_write(struct xe_hwmon *hwmon, u32 attr, int channel, long val) > { > + struct xe_hwmon_fan_info *fi; > int ret = 0; > > + fi = &hwmon->fi[channel]; > + > mutex_lock(&hwmon->hwmon_lock); > > switch (attr) { > @@ -2141,6 +2270,33 @@ xe_hwmon_pwm_write(struct xe_hwmon *hwmon, u32 attr, int channel, long val) > } > ret = xe_hwmon_set_user_fan_pwm(hwmon, channel, (u8)val); > break; > + case hwmon_pwm_enable: > + if (val == XE_FAN_PWM_FULL_SPEED || val == XE_FAN_PWM_MANUAL_USER_TABLE) { > + bool full_speed = val == XE_FAN_PWM_FULL_SPEED; > + /* Without a user curve, start from the clamped stock table. */ > + enum fan_table_type source = fi->fan_table[USER_FAN_TABLE].point_count ? > + USER_FAN_TABLE : STOCK_FAN_TABLE; > + > + ret = xe_hwmon_activate_user_fan_table(hwmon, channel, full_speed, source); > + if (ret) > + xe_warn(hwmon->xe, "failed to set fan %d pwm_enable %ld, ret=%d\n", > + channel, val, ret); > + } else if (val == XE_FAN_PWM_AUTO_STOCK_TABLE) { > + ret = xe_hwmon_fan_set_auto(hwmon, channel); > + if (ret) { > + xe_warn(hwmon->xe, > + "failed to switch fan %d to automatic stock control, ret=%d\n", > + channel, ret); > + break; > + } > + xe_dbg(hwmon->xe, > + "automatic control enabled for fan %d using stock table\n", > + channel); > + } else { > + xe_dbg(hwmon->xe, "invalid pwm%d_enable value %ld\n", channel + 1, val); > + ret = -EINVAL; > + } > + break; > default: > ret = -EOPNOTSUPP; > break; > @@ -2354,6 +2510,7 @@ int xe_hwmon_register(struct xe_device *xe) > { > struct device *dev = xe->drm.dev; > struct xe_hwmon *hwmon; > + int fan; > int ret; > > /* hwmon is available only for dGfx */ > @@ -2368,6 +2525,10 @@ int xe_hwmon_register(struct xe_device *xe) > if (!hwmon) > return -ENOMEM; > > + /* Zero is XE_FAN_PWM_FULL_SPEED; stay unset until the stock table is read. */ > + for (fan = 0; fan < FAN_MAX; fan++) > + hwmon->fi[fan].pwm_enable_mode = XE_FAN_PWM_UNINITIALIZED; > + > ret = devm_mutex_init(dev, &hwmon->hwmon_lock); > if (ret) > return ret; LGTM: Reviewed-by: Soham Purkait