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 B6A3A606A322 for ; Wed, 2 Dec 2026 19:53:40 +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=S7R3GccC Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74EEF11249E; Wed, 2 Dec 2026 19:53:35 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3BEC81124AD for ; Wed, 2 Dec 2026 19:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796241210; x=1827777210; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=92h7RRohudTppZY0BUZJcYaaFYuldOuI22mBuRPdGrM=; b=S7R3GccCG5XzujjHVjWvvfMv50VpAX5efCiHbNKHvvsEU1olXXLVoUBf pznmqZYvvbJ052W5BaY2TYL1RTkChMn1mGrkz6O1YQK6XGQ43Cz+gKrcm dSVDervbAos1nyVfARo56/wHjycT5lnoo49ZqdFyH0F7JkfkLBzNM9NUU v+aGWfDzVVE241vC8anEEVzfIYJVkcZ8iqIfx3bLhq8CCPEQMh1zQD1fa Bjb/TAvySS1Q1dyOXkSqaIjD+RgCXm8ep4Sg02+I+WJLBTFzjyUwYvwv3 At5eyWRUFNt1sr7rAf4eI1zrFOMl//5rN3RCIEJeKEzhYZd3NlKZJ9kDX w==; X-CSE-ConnectionGUID: BmNFnYLKT3GXAbY9eJlMVw== X-CSE-MsgGUID: 8+flydirQ3Kaa2z6LCMCDQ== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5076053" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5076053" 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:53:27 -0800 X-CSE-ConnectionGUID: p24Vcqo9Q/uWWbqzhZNTBw== X-CSE-MsgGUID: oNyAjpBhTbCA/7dk3R6PEA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13713260" 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:53:25 -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:53:23 -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:53:23 -0800 Received: from BL0PR03CU003.outbound.protection.outlook.com (52.101.53.64) 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:53:23 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=a+5iOgsTByLkP+ChizK0H3maAhmP9kQyZXqWXqM08+rBk8ENPm0iqk8s2jbQBdURnDk/JpfM+ZijqF66mgaCysv7F9hn2LbFPtXPiIKFrGYlKoQ7GPufDx24pPrCmJFd1bQvRMRqy9oGZOQDnbZClZUb6p/D1DVG4a+QeMj4EWjFbkzxGe5ARja67kdnYkugbhbCJvsvpbTsXNnTF1BrhF4OmhBuTFmRy3U4VzvJtFDlis5L74FJmXiV9fdRI1NQU2UhDGVh1TQY48Llcsh/Ps8hGZJgvkPuvrLABdaTTlq5qTehgRTjxAE4ANQtrySmrU9QO3pb/QhzNgcMNp0cig== 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=92h7RRohudTppZY0BUZJcYaaFYuldOuI22mBuRPdGrM=; b=LIPVMphwTJw+2122xAJKklakTLvPRW0HapMBBxSVGY6mcYCKGgXUxvxO4zX08xnQSuOgeuRx70Hf8ZFeq/jZPXLHdDRAUwW2UTpj87BLRP27m7p77hRB4bTMQnKcorysOCr6oBwdp2hr2i3b6LXYbZrKW52wuCoR1M6ZCgRLJJ9+BVg+87FBEBdaCbff7lox4xk204FUooHR2A5+2mXrvbBtv59bb1/3Vu2Om5EEqxA5qZFhD8ludW2TulSSfcFQiRagL+kkBOux+Wb/N9gKV/IVHfmsRUbqfVf2VyHVaahM0g5JNzoCU1c8cT2A0LeXFQAVmnYmFPgSg2IvjhaPbQ== 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:17 +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:17 +0000 Message-ID: <6ce477cc-06af-4b27-85e2-564adb441eff@intel.com> Date: Thu, 3 Dec 2026 01:23:08 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 05/11] drm/xe/hwmon: Expose pwm[1-3] To: Karthik Poosa , CC: , , , References: <20261202195221.1862825-1-karthik.poosa@intel.com> <20261202195221.1862825-6-karthik.poosa@intel.com> Content-Language: en-US From: "Purkait, Soham" In-Reply-To: <20261202195221.1862825-6-karthik.poosa@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MA5PR01CA0211.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:1b0::12) 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: bd192084-6096-4bcf-44b1-08df50ade892 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|56012099006|11063799006|10067099003|261021135927099003|261021130227099003|261021123027099003|261021133027099003|261021121427099003|261022105027099003|261026121527099003|261022115727099003|261102123227099003|261022113327099003|261026130827099003|261022075727099003|261026135527099003|261026140227099003|261009223027099003|261028144727099003; X-Microsoft-Antispam-Message-Info: IEoKVFqFRTE8j2Olb0bZgeYAjMDB3Vaw0dNKEr01pONAL7yhUlYxOBo0q6Xwn6SUKu/cB715NN4TUFHNvhG2vLUNp7bh2LaR33K7bGfIEyNjVD1u9TronVE5TgbufSAj/KqjYhhFgxyGHsIGeId+BoVNaZ2zCVL2M3hdAJ798xkpc1bBB4oMG9/VUuksy9SrN3VHYAT8PCw0ocA3YUmmuPctqoYSFaGEQakLTQPXPohUFZuAAPfdSJEhJ6oPSs8q2GYytw7wVWwKz4ma9yrzSuZHdFh2FnqzxzasNQQeBwbU9NmFRvmBvhOAdUrTQNQCxs3wsRaL/xlToImgLK64Q9HThe1vpZU8Bwju1uOLxLsZcH+/WSKoA8viiI3hTt5MOI/CBtEyt0bFeqRKb6S9fU2DkHeMp+aCFior6IBqjPVjj7dt//3GzYnX0wm94c2MGq3qXYWvFGQQAi3FN5/86PnzUmHSYFqyWTv6pAbcJdP0HsmnWovkySnALoe5eDDwAKVyXp4CH08gfWrggFH8Z722YMoru80D9syE4X/YvmxvQ+Q+iOdn+R1SStPN8hJih+ekuYezwEH/fFfRs/u0aD9yCtM1lDiS7iOA7+0R8UVLMvk3L46c50SrUpVMqURdVU2J3Ta+YD0uojE+YtcY1DW0TrEDjf+vS68lg2aI0x8= 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)(56012099006)(11063799006)(10067099003)(261021135927099003)(261021130227099003)(261021123027099003)(261021133027099003)(261021121427099003)(261022105027099003)(261026121527099003)(261022115727099003)(261102123227099003)(261022113327099003)(261026130827099003)(261022075727099003)(261026135527099003)(261026140227099003)(261009223027099003)(261028144727099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?WFZzb0M4MGxvT3NzT2IvL0hj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ossTenant-AuthSource: DS6PR11MB087165.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 19:53:17.2686 (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: 9bPwrYlQpLprub3jiS+KF/tt441GLw1FO8OcIXQzIT8qzstmZPbNSNy8GTrHBoitfNH/G+Lh2gAkg3Du1bsXXw== 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] hwmon attributes for each available fan. Userspace can > read PWM values in the range 0..255 and set a manual fan speed > independently of the fan curve. Switching back to the stock curve is > added by a later patch. > > Read active PWM from PMT on BMG. On other platforms, derive PWM from the > stock curve when no user table is active. > > After writing the user table, read back its point count to verify > firmware accepted it. If verification fails, restore stock fan control. > > Document pwm[1-3] in the Xe hwmon ABI. > > Reviewed-by: Rodrigo Vivi > Signed-off-by: Karthik Poosa > --- > > v2: > - Use xe helpers for dmesg logs. > - Avoid using hwmon->num_fans to get fan count in > xe_hwmon_pwm_is_visible(). > > v3: > - Set PWM directly through the user table; avoid initializing it from the > stock table. (Soham) > - Move the unused xe_hwmon_activate_user_fan_table() to the subsequent > patch. > - Fail pwmN reads when no value has been written, rather than activating > the user table from the stock table. > - Define MIN_FAN_CONTROL_POINTS as 2. > - Use MIN_FAN_CONTROL_POINTS for PWM configuration. (Soham) > - Use batched writes for configuring fan control points when setting pwmN. > - Add and rephrase couple debug logs. > - Update the hwmon documentation. > > v4: > - Use tab indentation in ABI doc and MIN_FAN_CONTROL_POINTS. (Soham) > - Drop unused linux/delay.h include. (Soham) > - Clamp min PWM to 100% since fan table speed is in percent. (Soham) > - Log both the requested pwm and the applied percentage. (Soham) > - Fail the pwm write if pcode reports a user point count other than > MIN_FAN_CONTROL_POINTS after the write. (Soham) > - Drop redundant channel range checks in pwm read/write. (Soham) > - Fix misleading comments and debug log alignment. (Soham) > - Note that the 0..255 to percent round trip is lossy. (Soham) > - Update ABI Date and KernelVersion to November 2026 and 7.5. > - Document that pwm values below the fan minimum are raised to it. > - Return -ENODATA and log at debug level when pwm has not been set. > - Invalidate the cached user table when the pwm write or verify fails. > - Clear point count on pcode read failure. > - Drop unneeded parentheses in MIN_FAN_CONTROL_POINTS and FIXED_PWM_TEMP. > - Document pcode user table write ordering. > > v5: > - Expose pwm[1-3] node only if stock table is valid. > - Read current pwm from PMT for BMG and from stock table for other > platforms when user table is not active. > - Read back the user point count after every PWM table write and fall > back to stock table when the count is not accepted. > > v6: > - Add couple of warnings. (Soham) > > v7: > - Move user fan-table batch construction and verification into > new function xe_hwmon_commit_user_fan_table(). (Badal) > - Keep xe_hwmon_set_user_fan_pwm() responsible for preparing the > fixed two-point curve and updating the cached user table. (Badal) > - Log an out-of-range PWM read at debug level, as pollers reading pwmN > after resume flood dmesg. (Rodrigo) > - Drop Soham Reviewed-by as refactor occurred. > - Make pwm node visible only if stock points > MIN_FAN_CONTROL_POINTS. > > .../ABI/testing/sysfs-driver-intel-xe-hwmon | 9 + > drivers/gpu/drm/xe/regs/xe_pmt.h | 5 + > drivers/gpu/drm/xe/xe_hwmon.c | 362 ++++++++++++++++++ > drivers/gpu/drm/xe/xe_pcode_api.h | 3 + > 4 files changed, 379 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon b/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon > index ac9ccfd47eab..34c50f13f0b4 100644 > --- a/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon > +++ b/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon > @@ -346,3 +346,12 @@ Description: RW. Package burst power limit interval (Tau in PL2/Tau) in > milliseconds over which sustained power is averaged. > > Only supported for particular Intel Xe graphics platforms. > + > +What: /sys/bus/pci/drivers/xe/.../hwmon/hwmon/pwm[1-3] > +Date: December 2026 > +KernelVersion: 7.5 > +Contact: intel-xe@lists.freedesktop.org > +Description: RW. Target fan PWM duty value in the range 0..255, where 255 > + is 100% fan speed. > + > + Only supported for particular Intel Xe graphics platforms. > diff --git a/drivers/gpu/drm/xe/regs/xe_pmt.h b/drivers/gpu/drm/xe/regs/xe_pmt.h > index fb5b5a8648ba..4fec057b2dd6 100644 > --- a/drivers/gpu/drm/xe/regs/xe_pmt.h > +++ b/drivers/gpu/drm/xe/regs/xe_pmt.h > @@ -15,6 +15,11 @@ > #define ENERGY_PKG REG_GENMASK64(31, 0) > #define ENERGY_CARD REG_GENMASK64(63, 32) > > +#define BMG_FAN_PWM_PMT_OFFSET (0x58) > +#define BMG_FAN1_PWM REG_GENMASK64(15, 0) > +#define BMG_FAN2_PWM REG_GENMASK64(31, 16) > +#define BMG_FAN3_PWM REG_GENMASK64(47, 32) > + > #define PUNIT_VERSION_OFFSET 0xA0 > > #define XE_PMT_BASE_OFFSET 0xE0000 > diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c > index 1d7ba1149917..e77ab0685bb7 100644 > --- a/drivers/gpu/drm/xe/xe_hwmon.c > +++ b/drivers/gpu/drm/xe/xe_hwmon.c > @@ -157,6 +157,9 @@ enum fan_table_type { > /* Maximum number of fan control points supported by each fan. */ > #define MAX_FAN_CONTROL_POINTS 10 > > +/* Minimum number of points required for a user fan table. */ > +#define MIN_FAN_CONTROL_POINTS 2 > + > /* Fan control point index: bit31 selects fan table type; bits30:0 control point index. */ > #define FCP_INDEX(table_type, point_num) (((u32)(table_type) << 31) | \ > ((u32)(point_num) & GENMASK(30, 0))) > @@ -923,6 +926,7 @@ 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), > NULL > }; > > @@ -1166,6 +1170,162 @@ static int xe_hwmon_get_fan_enable_mask(struct xe_hwmon *hwmon) > return 0; > } > > +static int xe_hwmon_get_fan_point_count(struct xe_hwmon *hwmon, u8 fan, u32 *point_count, > + enum fan_table_type table_type) > +{ > + int ret; > + > + *point_count = 0; > + ret = xe_hwmon_pcode_read_fan_control(hwmon, > + (table_type == USER_FAN_TABLE) ? > + FSC_READ_USER_FAN_CONTROL_POINTS : > + FSC_READ_STOCK_FAN_CONTROL_POINTS, > + fan, point_count); > + if (ret) { > + *point_count = 0; > + xe_err(hwmon->xe, "failed to read fan %d %s point count, ret=%d\n", fan, > + (table_type == USER_FAN_TABLE) ? "user" : "stock", ret); > + return ret; > + } > + > + if (*point_count > MAX_FAN_CONTROL_POINTS) { > + xe_err(hwmon->xe, "fan %d %s point count %u exceeds max %u\n", fan, > + (table_type == USER_FAN_TABLE) ? "user" : "stock", *point_count, > + MAX_FAN_CONTROL_POINTS); > + return -EINVAL; > + } > + > + return 0; > +} > + > +/* > + * Set the fan to automatic mode by clearing the user fan table. > + * This will make the firmware run the stock fan table. > + */ > +static int xe_hwmon_fan_set_auto(struct xe_hwmon *hwmon, u8 fan) > +{ > + struct xe_hwmon_fan_info *fi = &hwmon->fi[fan]; > + int ret; > + > + ret = xe_pcode_write(xe_device_get_root_tile(hwmon->xe), > + 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; > + > + return 0; > +} > + > +static int xe_hwmon_commit_user_fan_table(struct xe_hwmon *hwmon, u8 fan, > + const struct fan_control_point *points, u32 point_count) > +{ > + /* The extra write is for the final write that sets the number of fan control points */ > + struct xe_pcode_write writes[MAX_FAN_CONTROL_POINTS + 1]; > + u32 accepted_count = 0; > + u32 point; > + int ret, write_ret, verify_ret; > + > + if (point_count < MIN_FAN_CONTROL_POINTS || > + point_count > MAX_FAN_CONTROL_POINTS) { > + xe_err(hwmon->xe, "fan %d table needs %d-%d points, got %u\n", fan, > + MIN_FAN_CONTROL_POINTS, MAX_FAN_CONTROL_POINTS, point_count); > + return -EINVAL; > + } > + > + for (point = 0; point < point_count; point++) { > + u8 temp = points[point].temp; > + u8 speed = points[point].speed; > + > + /* Firmware requires increasing temperature and non-decreasing speed. */ > + if (point > 0) { > + u8 prev_temp = points[point - 1].temp; > + u8 prev_speed = points[point - 1].speed; > + > + if (temp <= prev_temp || speed < prev_speed) { > + xe_dbg(hwmon->xe, > + "fan %d point %u not monotonic: %u/%u%% after %u/%u%%\n", > + fan, point, temp, speed, prev_temp, prev_speed); > + return -EINVAL; > + } > + } > + > + /* Prepare the write for this fan control point */ > + 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); > + } > + > + xe_dbg(hwmon->xe, "committing fan %d user table with %u points\n", fan, point_count); > + > + /* pcode fills the user table from point 0 in write order; the count write commits it. */ > + 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_err(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, &accepted_count, USER_FAN_TABLE); > + if (write_ret || verify_ret || accepted_count != point_count) { > + int failure_ret = write_ret ?: verify_ret ?: -EIO; > + > + if (verify_ret || accepted_count != point_count) > + xe_err(hwmon->xe, > + "fan %d table count verification failed: ret=%d, expected=%u, got=%u\n", > + fan, verify_ret, point_count, accepted_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; > + } > + > + xe_dbg(hwmon->xe, "fan %d user table committed successfully with %u points\n", fan, > + point_count); > + return 0; > +} > + > +/* Temperature to set when setting the fan PWM with pwm[1-3]. */ > +#define FIXED_PWM_TEMP 1 > + > +static int xe_hwmon_set_user_fan_pwm(struct xe_hwmon *hwmon, u8 fan, u8 pwm) > +{ > + struct xe_hwmon_fan_info *fi = &hwmon->fi[fan]; > + struct fan_table *user_table = &fi->fan_table[USER_FAN_TABLE]; > + struct fan_control_point points[MIN_FAN_CONTROL_POINTS]; > + int ret, i; > + u8 speed; > + > + /* Fan table speed are in percent. */ > + speed = min_t(u32, DIV_ROUND_CLOSEST(pwm * 100, U8_MAX), 100); > + > + /* Fan control needs at least two points; program them all at the same speed. */ > + for (i = 0; i < MIN_FAN_CONTROL_POINTS; i++) { > + points[i].temp = FIXED_PWM_TEMP + i; > + points[i].speed = speed; > + } > + > + ret = xe_hwmon_commit_user_fan_table(hwmon, fan, points, MIN_FAN_CONTROL_POINTS); > + if (ret) { > + xe_err(hwmon->xe, "failed to set pwm %u (%u%%) for fan %d, ret=%d\n", > + pwm, speed, fan, ret); > + return ret; > + } > + > + /* Update the user fan table cache. */ > + memcpy(user_table->fcp, points, sizeof(points)); > + user_table->point_count = MIN_FAN_CONTROL_POINTS; > + xe_dbg(hwmon->xe, "applied pwm %u (%u%%) for fan %d\n", pwm, speed, fan); > + > + return 0; > +} > + > static int xe_hwmon_read_fan_control_info(struct xe_hwmon *hwmon) > { > bool found = false; > @@ -1795,6 +1955,22 @@ xe_hwmon_fan_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel) > } > } > > +static umode_t > +xe_hwmon_pwm_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel) > +{ > + /* Manual control starts from the stock table, so it needs a usable curve. */ > + if (!hwmon->xe->info.has_fan_control || !IS_FAN_ENABLED(hwmon, channel) || > + hwmon->fi[channel].fan_table[STOCK_FAN_TABLE].point_count < MIN_FAN_CONTROL_POINTS) > + return 0; > + > + switch (attr) { > + case hwmon_pwm_input: > + return 0644; > + default: > + return 0; > + } > +} > + > static int > xe_hwmon_fan_input_read(struct xe_hwmon *hwmon, int channel, long *val) > { > @@ -1848,6 +2024,185 @@ xe_hwmon_fan_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val) > } > } > > +/** > + * xe_hwmon_get_stock_table_pwm - Calculate PWM from the stock 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. > + * > + * 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) > +{ > + const struct fan_table *table = &hwmon->fi[channel].fan_table[STOCK_FAN_TABLE]; > + long temperature, pwm; > + int point, ret; > + > + lockdep_assert_held(&hwmon->hwmon_lock); > + > + if (!table->point_count) > + return -ENODATA; > + > + ret = xe_hwmon_temp_read(hwmon, hwmon_temp_input, CHANNEL_PKG, &temperature); > + if (ret) > + return ret; > + > + pwm = table->fcp[0].speed; > + for (point = 1; point < table->point_count; point++) { > + const struct fan_control_point *lower = &table->fcp[point - 1]; > + const struct fan_control_point *upper = &table->fcp[point]; > + long lower_temp = lower->temp * MILLIDEGREE_PER_DEGREE; > + long upper_temp = upper->temp * MILLIDEGREE_PER_DEGREE; > + long pwm_delta = upper->speed - lower->speed; > + > + /* Find the bracketing points; temperatures outside the curve use endpoints. */ > + if (temperature <= lower_temp) > + break; > + if (temperature < upper_temp) { > + pwm += DIV_ROUND_CLOSEST(pwm_delta * (temperature - lower_temp), > + upper_temp - lower_temp); > + break; > + } > + pwm = upper->speed; > + } > + > + *val = pwm; > + xe_dbg(hwmon->xe, "fan %d stock table active PWM value: %ld\n", channel, pwm); > + return 0; > +} > + > +/** > + * xe_hwmon_get_pwm_from_pmt - Read active fan PWM from PMT telemetry > + * @hwmon: hwmon instance, with hwmon_lock held and runtime PM active > + * @channel: fan channel > + * @val: raw PWM percentage returned by PMT > + * > + * Return: 0 on success, or a negative error code. > + */ > +static int xe_hwmon_get_pwm_from_pmt(struct xe_hwmon *hwmon, int channel, long *val) > +{ > + u64 pmt_val; > + u32 guid, pwm; > + int ret; > + > + lockdep_assert_held(&hwmon->hwmon_lock); > + > + if (hwmon->xe->info.platform != XE_BATTLEMAGE) > + return -EOPNOTSUPP; > + > + ret = xe_vsec_get_guid(hwmon->xe, &guid); > + if (ret) { > + xe_warn(hwmon->xe, "failed to read pwm, PMT unavailable: %d\n", ret); > + return ret; > + } > + > + ret = xe_pmt_telem_read(hwmon->xe->drm.dev, guid, &pmt_val, > + BMG_FAN_PWM_PMT_OFFSET, sizeof(pmt_val)); > + if (ret != sizeof(pmt_val)) { > + xe_warn(hwmon->xe, "pwm read from PMT failed: %d\n", ret); > + return ret < 0 ? ret : -EIO; > + } > + > + switch (channel) { > + case FAN_1: > + pwm = REG_FIELD_GET64(BMG_FAN1_PWM, pmt_val); > + break; > + case FAN_2: > + pwm = REG_FIELD_GET64(BMG_FAN2_PWM, pmt_val); > + break; > + case FAN_3: > + pwm = REG_FIELD_GET64(BMG_FAN3_PWM, pmt_val); > + break; > + default: > + return -EOPNOTSUPP; > + } > + > + xe_dbg(hwmon->xe, "fan %d: active pwm from PMT: %u\n", channel, pwm); > + > + *val = pwm; > + return 0; > +} > + > +static int > +xe_hwmon_pwm_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val) > +{ > + struct xe_hwmon_fan_info *fi; > + long pwm; > + int ret = 0; > + > + mutex_lock(&hwmon->hwmon_lock); > + > + fi = &hwmon->fi[channel]; > + > + 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; > + } > + if (pwm < 0 || pwm > 100) { > + xe_dbg(hwmon->xe, "invalid PWM value %ld read for fan %d\n", pwm, channel); > + ret = -ERANGE; > + goto unlock; > + } > + /* Speed is cached in percent, so the 0..255 round trip may be off by a step. */ > + *val = DIV_ROUND_CLOSEST(pwm * U8_MAX, 100); > + xe_dbg(hwmon->xe, "pwm read for fan %d: %ld\n", channel, *val); > + break; > + default: > + ret = -EOPNOTSUPP; > + break; > + } > + > +unlock: > + mutex_unlock(&hwmon->hwmon_lock); > + return ret; > +} > + > +static int > +xe_hwmon_pwm_write(struct xe_hwmon *hwmon, u32 attr, int channel, long val) > +{ > + int ret = 0; > + > + mutex_lock(&hwmon->hwmon_lock); > + > + switch (attr) { > + case hwmon_pwm_input: > + if (val < 0 || val > U8_MAX) { > + xe_dbg(hwmon->xe, "pwm %ld out of range for fan %d\n", val, channel); > + ret = -EINVAL; > + break; > + } > + ret = xe_hwmon_set_user_fan_pwm(hwmon, channel, (u8)val); > + break; > + default: > + ret = -EOPNOTSUPP; > + break; > + } > + mutex_unlock(&hwmon->hwmon_lock); > + > + return ret; > +} > + > static umode_t > xe_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_types type, > u32 attr, int channel) > @@ -1874,6 +2229,9 @@ xe_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_types type, > case hwmon_fan: > ret = xe_hwmon_fan_is_visible(hwmon, attr, channel); > break; > + case hwmon_pwm: > + ret = xe_hwmon_pwm_is_visible(hwmon, attr, channel); > + break; > default: > ret = 0; > break; > @@ -1903,6 +2261,8 @@ xe_hwmon_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, > return xe_hwmon_energy_read(hwmon, attr, channel, val); > case hwmon_fan: > return xe_hwmon_fan_read(hwmon, attr, channel, val); > + case hwmon_pwm: > + return xe_hwmon_pwm_read(hwmon, attr, channel, val); > default: > return -EOPNOTSUPP; > } > @@ -1921,6 +2281,8 @@ xe_hwmon_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, > return xe_hwmon_power_write(hwmon, attr, channel, val); > case hwmon_curr: > return xe_hwmon_curr_write(hwmon, attr, channel, val); > + case hwmon_pwm: > + return xe_hwmon_pwm_write(hwmon, attr, channel, val); > default: > return -EOPNOTSUPP; > } > diff --git a/drivers/gpu/drm/xe/xe_pcode_api.h b/drivers/gpu/drm/xe/xe_pcode_api.h > index 2308e5464082..bf321ed19251 100644 > --- a/drivers/gpu/drm/xe/xe_pcode_api.h > +++ b/drivers/gpu/drm/xe/xe_pcode_api.h > @@ -86,9 +86,12 @@ > #define MEMORY_CONFIG_SUBCOMMAND_READ_MAX_FREQUENCY 0x1 > > #define FAN_SPEED_CONTROL 0x7D > +#define FSC_WRITE_NUM_FAN_CONTROL_POINTS 0x0 > +#define FSC_WRITE_FAN_TABLE 0x1 > #define FSC_READ_MAX_FAN_RPS 0x3 > #define FSC_READ_NUM_FANS 0x4 > #define FSC_READ_STOCK_FAN_CONTROL_POINTS 0x5 > +#define FSC_READ_USER_FAN_CONTROL_POINTS 0x6 > #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) LGTM: Reviewed-by: Soham Purkait