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 EE5EC606A334 for ; Wed, 2 Dec 2026 19:54:12 +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=JHLP2GYH Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B361011249E; Wed, 2 Dec 2026 19:54:07 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6076910EA11 for ; Wed, 2 Dec 2026 19:54:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796241242; x=1827777242; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=ogG75wII720lYDZmubmSwByyPMGh2A8kq1i62h0NzaI=; b=JHLP2GYHpYXwxnYCEXsf/SRXlXHyTggJv10PepyTjs6vX3WTSLvC0iL5 EaByiDb+01j1o2amvCyZITOyiowoItQRHmc+bZEVA/ZaPA2hPCPOCBXMh E4KTLk7PAZhN/ZAdj/1CQlqyisDkdjUe06M4EU6K0Osui4CKNevk49z5h bB3OhdpxY0pcfQ2xbjKunHnzN5E7DPGIdQ5uZjPNvWod08iALWRku7GMs L2o3IroWBp/oswIq15uaUmbL4mvRKRU/iQWn/FfZChJzTZjm/IUxtf4NI z/fT+/09mUyJVQbgpNq47G5M9zGieXg4SNm+ddvA4l9u6W+OuFPzUSB0R g==; X-CSE-ConnectionGUID: TrfsmeFjRNetN1pb2m4DgQ== X-CSE-MsgGUID: HxUBglBoQQ2JDLy9/qoBUw== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5076115" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5076115" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 11:54:02 -0800 X-CSE-ConnectionGUID: Zn5UOVYeSt+G7midd86DNw== X-CSE-MsgGUID: 6Dnng2xSSaayhJ2D5hlc0Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13713414" Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25]) by fmviesa005.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 11:54:01 -0800 Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 11:54:00 -0800 Received: from ORSEDG903.ED.cps.intel.com (10.7.248.13) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Wed, 2 Dec 2026 11:54:00 -0800 Received: from BL0PR03CU003.outbound.protection.outlook.com (52.101.53.20) by edgegateway.intel.com (134.134.137.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 11:54:00 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TZFQQvF6fpeWh3UQx80bMjdEFYGY/sF3ZwsunvU6lQOuj0IJ17gSXJ8i2kLTbOFMNGxP/M63a+UgJ9KsbrkdYhSLS18HOH2iYwkm/uafYj3H7+QNZfoVvoC0BWnQb4Jsh4uLwoXOj3zIj8IPbmL1yyZ3bniYqDCdJ52zNzzmszYOzifhDF6EWaKSWTFgie43AuWer530+4cCy9V2nZaIX6rc3tI5mz+WflxUPa2fEFdhq0d1PmBlxLqEN0dY3sbyulU+xWzA54x0CYYa3xgyLaayYEGFkIUvbg3L2i3y0JFY2v6+pPizQAlKxbERAySod9PYBcT6iy3rXkgpj6EopA== 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=ogG75wII720lYDZmubmSwByyPMGh2A8kq1i62h0NzaI=; b=ZANk18WEIuCMyqbi0G4X6vp2jJp8LXdlcJcwseHKkf0Lw5QqLva6LGe8iBaxMQNv+n33jDq/T1eDnzCVlzyzowL0NcKRXnLFKR3oanaTlU3lt2pTw/SVh+pvmsdEn0Smb4zQ8pN7p1Wez2Wk41AJJycdaIG0xjRx4aYoX8+qq3UV0HMXPrdEiQiK3rGuY5T9hqqrbfC2YHjTuJSTain5uMmACoaJ58BDgor8okoGQCumuRr7wVhtrQ91JLCGiEX7CWJkx/jPNezvIdvbFRLSKlbQPDvsP9Sq45U82LZOdSrBfl0/RfWHJRR5KGCTeU87/b1TwJA5d47QUb2PuRVmYw== 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 DS6PR11MB087165.namprd11.prod.outlook.com (2603:10b6:8:4c4::7) by SJ2PR11MB8587.namprd11.prod.outlook.com (2603:10b6:a03:568::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.11; Wed, 2 Dec 2026 19:53:57 +0000 Received: from DS6PR11MB087165.namprd11.prod.outlook.com ([fe80::4223:7b03:1329:265f]) by DS6PR11MB087165.namprd11.prod.outlook.com ([fe80::4223:7b03:1329:265f%6]) with mapi id 15.21.0688.009; Wed, 2 Dec 2026 19:53:57 +0000 Message-ID: <7eb39a04-09ed-4e8f-82a0-184894bb1b26@intel.com> Date: Thu, 3 Dec 2026 01:23:48 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 06/11] drm/xe/hwmon: Expose pwm[1-3]_enable To: Karthik Poosa , CC: , , , References: <20261202195221.1862825-1-karthik.poosa@intel.com> <20261202195221.1862825-7-karthik.poosa@intel.com> Content-Language: en-US From: "Purkait, Soham" In-Reply-To: <20261202195221.1862825-7-karthik.poosa@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MA5PR01CA0206.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:1b0::10) 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: DS6PR11MB087165:EE_|SJ2PR11MB8587:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f5183f1-ae0c-4336-a830-08df50ae0016 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|23010399003|366016|4143699003|6133799003|18002099003|22082099003|3023799007|56012099006|11063799006|10067099003|261021123027099003|261021121427099003|261022105027099003|261026121527099003|261022115727099003|261102123227099003|261022113327099003|261022075727099003|261026140227099003|261009223027099003|261028144727099003; X-Microsoft-Antispam-Message-Info: mfhVwttBVpb9qBNDC48UqXOOx4U/VNG7au04bDFs9gmfrj63didwYIMg8a/1shAkEPMbi2wHBkg6fN5Tg0o1537ykbGIsCzqegYG2tAd7f+Nzg9l/XsAclK3McWd576f1fszDIBSwY34BPZ/ACy5s/kpQVknRGmvhqWI7W43Uo6lKE2EXnRPdMEQbdAsbOwL1NTc/AIv+JIQ599wbq2jfle4GUIKgSR1WCN8+KLh5/ozTj0jG3jCWqU/vp74BmyhLbG87o1mCpR2b0li7gHKkFio/2UFIe8NQDdDPHD8V74QUP1zRZX/j1/N8RH1hYyLyeVPYdJUlSnTy+Q45E/0d44dg3IqWcSYOIrkC3DCxAqrjuQ+nTX4ZLZof8j4QJlEkqlEY9wGtTtJr+x2m0y4TzV0MwM+C405ydLOK30w8bJrwlMN83IKYpaj2yN2dgQ/xzVjBnJDU4uz137z7wMKd71qa/sTXqBBaHn7lm4ZTIutmt3Mo24QStQTiu0uxtkp8qc/eclbws5DJ1nNROYmnfeAOPiQyc6YZhfJB03l6568j7aPVUFPtw9vpacjWTsEQEsxkp1hS8qX09nJbM97GGYu3ikjG+cwoxz/S2D9zf7mo/GjxQr3EUQLisA56KqdghJrWvvho4e7RsJOj4MJN3j7Q92VcV3s/eapVeLs/k8= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS6PR11MB087165.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(376014)(23010399003)(366016)(4143699003)(6133799003)(18002099003)(22082099003)(3023799007)(56012099006)(11063799006)(10067099003)(261021123027099003)(261021121427099003)(261022105027099003)(261026121527099003)(261022115727099003)(261102123227099003)(261022113327099003)(261022075727099003)(261026140227099003)(261009223027099003)(261028144727099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QS9hSjVEVDdFL0N2aHJDSFEzNEJPUVVENCt4T1BDcmprZDduMDFVbjFBTTlq?= =?utf-8?B?QW5NeEVtVUVMYmNvRnNQN2JCNUh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utf-8?B?N1VLbm1SM1ZOY3FKZjcxWUluTVJ0Mm1GZnpEK3dZWEdQcWFLSm92RVJGL25v?= =?utf-8?B?NmJXWDJwOVNMRHEwTzB0RHhvcjZRT0xuY1UrM0JSRW02NXdzWDFXc01heTJk?= =?utf-8?B?c3pGY2ZTSVVvK2k0U1ExeVh1bDRIUkwwdm01dnVwV0NTYzI0c3R5akFpSGV2?= =?utf-8?B?b1ZlckVLY0llWjBpWDZqYS9RQ2srMDVvZEZmZnIya09OcmdOWWl0d3BLMHVR?= =?utf-8?B?aURUVW1qb0E0YkNoMU9DQzlSYzdMOXM2WmJzd2g4bGFtK3JmSFVxd3dVR2k0?= =?utf-8?B?b0ZKdWczNnFxZVRUS3MrWEt3My90YXdPNVZSSW9iZEJNZHhuZzQxSWNGVStV?= =?utf-8?B?MkNpUm1DbVRWbzZRT2JhYy9mUU8rRFE4SkRrUTJjZEowRzFFVC9ES2h2a3dJ?= =?utf-8?B?QVY3c29JWGpQbWd3VWRPSGpOMUN0akk4OHR1cFpsakNlV1BiUjlndz09?= X-Exchange-RoutingPolicyChecked: R8o/fzKfqjhgZj8ZARekWnqlT6jLDg4dmoNGAJFLqj71J6U47W7QK8oPQm1DxAlgEVIFH5HwHstDNO+wAfrBO65e5mJZrofQ4oOHTk9UK1Z+ZUAWazOMsuDsrlAFde1v6ABcWPsQqAiUBfwRSOV7R/zvF3Kh+QjDDjAmkD7f7MKEyekolX+h1mpYLzz6e5SyWIMUv02zeQa/AWZyTlG8RVLsouGGN9lAxuyQ4Tq6byZJwJkKEVPzrm3bTUvPuOxAgGE5VNVc/1mkM0T2DgSrhuRkaQ/5tFmE34+2Wa0i9ALaWGfrI5l+IPvBdCqdL8e3eY7xKw2YEwOhOxNIeqe7SQ== X-MS-Exchange-CrossTenant-Network-Message-Id: 9f5183f1-ae0c-4336-a830-08df50ae0016 X-MS-Exchange-CrossTenant-AuthSource: DS6PR11MB087165.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 19:53:56.9073 (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: rMPDadSITj0uTMBBKS641PbKQpbiO3apAuFvt45s2TjFNb47hqlHnUVjLjofENZnYY/L5JBpB5RgXM77FzKUrQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR11MB8587 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 03-12-2026 01:22, 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. > > Reviewed-by: Rodrigo Vivi > 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) > > v7: > - Use xe_hwmon_commit_user_fan_table() helper in > xe_hwmon_activate_user_fan_table() for table update. (Badal) > - Return -ENODATA from pwm[1-3] reads on BMG too while the fan control > mode is not established. (sashiko) > - Add debug log if fan control mode is uninitialized. (Rodrigo) > - Made source_table const in xe_hwmon_commit_user_fan_table(). > - Added a user_table pointer for stock-table cache updates. > - Avoided redundant cache updates when the source is already > USER_FAN_TABLE. > > .../ABI/testing/sysfs-driver-intel-xe-hwmon | 19 ++ > drivers/gpu/drm/xe/xe_hwmon.c | 196 +++++++++++++++--- > 2 files changed, 187 insertions(+), 28 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 e77ab0685bb7..3561e3d271eb 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 > }; > > @@ -1211,11 +1229,14 @@ 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; > - > - fi->fan_table[USER_FAN_TABLE].point_count = 0; > + 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_commit_user_fan_table(struct xe_hwmon *hwmon, u8 fan, > @@ -1291,6 +1312,56 @@ static int xe_hwmon_commit_user_fan_table(struct xe_hwmon *hwmon, u8 fan, > return 0; > } > > +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_hwmon_fan_info *fi = &hwmon->fi[fan]; > + struct fan_control_point points[MAX_FAN_CONTROL_POINTS]; > + const struct fan_table *source_table; > + u32 point_count, point; > + int ret; > + > + 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 %u is invalid, cannot activate user table\n", > + fan, (table_source == USER_FAN_TABLE) ? "user" : "stock", point_count); > + return -EINVAL; > + } > + > + for (point = 0; point < point_count; point++) { > + points[point].temp = source_table->fcp[point].temp; > + points[point].speed = is_full_speed ? 100 : > + min_t(u8, source_table->fcp[point].speed, 100); > + } > + > + ret = xe_hwmon_commit_user_fan_table(hwmon, fan, points, point_count); > + if (ret) > + return ret; > + > + /* Full speed only overrides firmware; the cache keeps the manual curve. */ > + if (table_source == STOCK_FAN_TABLE) { > + struct fan_table *user_table = &fi->fan_table[USER_FAN_TABLE]; > + > + for (point = 0; point < point_count; point++) { > + user_table->fcp[point].temp = source_table->fcp[point].temp; > + user_table->fcp[point].speed = > + min_t(u8, source_table->fcp[point].speed, 100); > + } > + user_table->point_count = point_count; > + } > + > + fi->pwm_enable_mode = is_full_speed ? XE_FAN_PWM_FULL_SPEED : > + XE_FAN_PWM_MANUAL_USER_TABLE; > + > + return 0; > +} > + > /* Temperature to set when setting the fan PWM with pwm[1-3]. */ > #define FIXED_PWM_TEMP 1 > > @@ -1302,6 +1373,11 @@ static int xe_hwmon_set_user_fan_pwm(struct xe_hwmon *hwmon, u8 fan, u8 pwm) > int ret, i; > 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 = min_t(u32, DIV_ROUND_CLOSEST(pwm * 100, U8_MAX), 100); > > @@ -1401,6 +1477,8 @@ static int xe_hwmon_read_fan_control_info(struct xe_hwmon *hwmon) > stock_fcp_count * sizeof(stock_fcp[0])); > fi->fan_table[STOCK_FAN_TABLE].point_count = stock_fcp_count; > found = true; > + if (fi->pwm_enable_mode == XE_FAN_PWM_UNINITIALIZED) > + fi->pwm_enable_mode = XE_FAN_PWM_AUTO_STOCK_TABLE; > } > > /* Succeed if any enabled fan's stock table was read. */ > @@ -1965,6 +2043,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; > @@ -2024,25 +2103,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; > > @@ -2070,7 +2167,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; > } > > @@ -2139,25 +2236,25 @@ 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: > + switch (hwmon->xe->info.platform) { > + case XE_BATTLEMAGE: > + if (fi->pwm_enable_mode == XE_FAN_PWM_UNINITIALIZED) > + ret = -ENODATA; > + else > 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; > + 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_dbg(hwmon->xe, "invalid PWM value %ld read for fan %d\n", pwm, channel); > @@ -2168,6 +2265,14 @@ 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) { > + xe_dbg(hwmon->xe, "fan %d control mode is not initialized\n", channel); > + ret = -ENODATA; > + goto unlock; > + } > + *val = fi->pwm_enable_mode; > + break; > default: > ret = -EOPNOTSUPP; > break; > @@ -2181,8 +2286,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) { > @@ -2194,6 +2302,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; > @@ -2407,6 +2542,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 */ > @@ -2421,6 +2557,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