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 C1750606A32A for ; Mon, 30 Nov 2026 09:50:21 +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=hAr3w7Ld Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8B65F10ECE3; Mon, 30 Nov 2026 09:50:16 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id C8CA610E3DC for ; Mon, 30 Nov 2026 09:50:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796032210; x=1827568210; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=ul8y9M9r7/8GfRZKpCiCj+3X6YLNjwJq4IBB1hEoOrY=; b=hAr3w7Ldz05c65BjXUDWH/mLWRTyIgpz8Rp8Lj521ng819bKc+7TPI2a xETfRcVH6lhULFKGvHOw7WViLIaGpMeP6cPTsfgkmMHkAzx9jtcpn6vX7 OLCbtKtxMsVTFBwjyW6lE7OcW4EpRSb9L/aUvF1q51JcvJRlheL+k8oaG ctQpxy/t4cjJbSGi6FpwDt20SsSt2wh9JRUXVt7QQSALO6TheSigDMrit +lTafkWVIOWRr28MKduWQXB/7jA3fqOsxPWZ7Q5CVJE2r6cHpNupL51v9 45N9Oq/7WQqFYdma4nmkXcfjY8xExJ/UPcMGcLN7kKJfVvWIcBAlH9rI6 A==; X-CSE-ConnectionGUID: NRDpJ1eSTnm9GIVm+t2/pw== X-CSE-MsgGUID: mi5Q5SVZTImS9lyzGBp9UA== X-IronPort-AV: E=McAfee;i="6800,10657,11981"; a="4876515" X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4876515" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 01:50:09 -0800 X-CSE-ConnectionGUID: /a7jZFdrQqK6xcCCwfzcog== X-CSE-MsgGUID: k231b90uSbGUFnx1cDPy3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="13023180" Received: from orsmsx902.amr.corp.intel.com ([10.22.229.24]) by fmviesa005.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 01:50:10 -0800 Received: from ORSMSX903.amr.corp.intel.com (10.22.229.25) by ORSMSX902.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Mon, 30 Nov 2026 01:50:08 -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; Mon, 30 Nov 2026 01:50:08 -0800 Received: from BN1PR04CU002.outbound.protection.outlook.com (52.101.56.70) 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; Mon, 30 Nov 2026 01:50:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xcm/LfsqJ4AwWhNoFnRk1wZvbvTQVjchQuvxYsUSaH6wjkNATiS6BDalwzWIKmqJ9E8Bj5ZKwrWoBfchRS0wjrBA9bADjR1PRcbhyEqORyVUT/5jjsLRjl95V2hCR13D8rU9TYXHVIxaUI/jiva2RZ7Fv83VNveLoZTYkqufZr1yj50ukLvxen/w3sAUKbQl1q+tKBYU1uIOmeuUkteKWZ/EleC5CYic9bGy9cQTRDkSslKyo0mSXRjRA4/xc9B2OVIy436gdbSxRYGbR68T8pJTwCIkYg7Dj56h98R/fW1tcNU//qt4PocDX3S9ANQmXg/mkqswp6LqQVCHHIxUiQ== 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=ul8y9M9r7/8GfRZKpCiCj+3X6YLNjwJq4IBB1hEoOrY=; b=Il3XQeX862AkDnTLYaGSyQPXLECh80Z4dCKyC7ow8OXqPMwOOGOlZz7aUZrlUMK0l1qmXWfBK51OIp6UVm/+FDmvjQKGqDYe1utiR7genjRvExBoVsux1UIsQ3ELd7Ciue9gacuMiwAMozSZNhooVAi5O+Yf+HaWE58/q+BAnBmaCmRx0Nh3/Xz8TBSJ8RLBZK07rY4XCBEb8nd87v1adsCHzdQRhlO5QRhesqX2s+pHwnauSOqHdhaA4tm/zUblbhq8t0Sa0lMDFR56pl5MUD9pRO55WO930K5E3BnvaYw2aRHkEfTyW5kntqd5bsQ6RY/yrC/DIeVd6FTIc4IX1g== 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 CH3PR11MB8751.namprd11.prod.outlook.com (2603:10b6:610:1c1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.12; Mon, 30 Nov 2026 09:49:56 +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.0662.007; Mon, 30 Nov 2026 09:49:56 +0000 Message-ID: <977e3fd2-4fc8-4930-a5cc-de13ae8b3d32@intel.com> Date: Mon, 30 Nov 2026 15:19:47 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 01/10] drm/xe/hwmon: Initialize fan-control backend and table cache To: Karthik Poosa , CC: , , , , , , , References: <20261128055923.3316956-1-karthik.poosa@intel.com> <20261128055923.3316956-2-karthik.poosa@intel.com> Content-Language: en-US From: "Purkait, Soham" In-Reply-To: <20261128055923.3316956-2-karthik.poosa@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MA5PR01CA0107.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:1d1::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_|CH3PR11MB8751:EE_ X-MS-Office365-Filtering-Correlation-Id: 15fa7f54-b398-471d-8cf0-08df4ec74a86 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|23010399003|1800799024|376014|10067099003|56012099006|261028144727099003|261026135527099003|261026140227099003|261026130827099003|261026121527099003|261022115727099003|261021135927099003|261021133027099003|261021130227099003|261021123027099003|261021121427099003|261022113327099003|261022105027099003|261022075727099003|261102123227099003|261009223027099003|22082099003|18002099003|4143699003|11063799006|6133799003; X-Microsoft-Antispam-Message-Info: dc4+FUWPlSU2y8grnuU5RlZAje7lmWiduKYhCUGH1xanBE1REK89MpDHbzHTdAHiZ0MxKOw4lIggavgwdGcmbIjcO0bxI9QzpllwuE2Sk01CDqXNdBtL8Pkyx8dtgZvWitxfJbBrDJMj4PFOc8FqcuaGbZrP6iD74zHd/+GKrg5NHjaYZUoQp15bDKux2HfL6+628Ott05cui5zO1mLYPq/K4qbU4x3lFj022tjQR/E5lmQH1ZmRscOw50+rmzWb1zb4rTZxFOAMRGNJRIw/6qc40VhCS8Ur15zqxK16qpW+rrjQEeBpLk/0LTAF0yK5uUTGyW8vplVn1zHuu80kGEbEcaV0UD3e1uLHIQc36SW567hhd5CBt3ttIq2N6NAf0LtmhWD/z8dtQgrKUd9kzMkFrvWhce7zDvBtM/NAGJiFOpMTK/g5TNuWXZlnlSDgIiOCNtMCW5BQf8BTkUDEfxGMsdTPS7lgFQkgvL5W6Tv8m6CXRUJoBnogV5hdJGLEyFP99S4wYZsakLPDoLmbwfkXh83xJ4x2DVtHDm8I2as6fc1NgkDK1gd1MTTjJiQzGed2MCFHT1jGUlS/l6leRww7OipgT6jWmEAnGPsnXT89F9n0Yl2JVGkmhY7K5vg5YJ1C6nWvN7Nb4ra3/8zn4TSLji2lCe/xDZBLw0Ks5bw= 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)(366016)(23010399003)(1800799024)(376014)(10067099003)(56012099006)(261028144727099003)(261026135527099003)(261026140227099003)(261026130827099003)(261026121527099003)(261022115727099003)(261021135927099003)(261021133027099003)(261021130227099003)(261021123027099003)(261021121427099003)(261022113327099003)(261022105027099003)(261022075727099003)(261102123227099003)(261009223027099003)(22082099003)(18002099003)(4143699003)(11063799006)(6133799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =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NkZEdOZ1NVcURhVFJsMGRQVjF6?= =?utf-8?B?LzZlbzdHOWF0bUoxZ2pRbkl2b2czczdEYlpBOWNEaWdUZERaMjhaKzk3VHR3?= =?utf-8?B?OUM3L0c2ZXJPZFZtM3NhclZPenY0TnlVcWdYeHRyRG9uT2ViNjNGY1gxemRB?= =?utf-8?B?QXNLRGNLV2lBQ3dRb3NCaGhsUE11V0huQUtwdjgzcmlVczJvbHN2WTNmSXVt?= =?utf-8?B?QXRDSnlENkdQamdBa2NRMDJtQXhKUWZNYW43aDNkM1Q4WFlFb3dlbjJITmU4?= =?utf-8?B?NjFDdk9vRzhGbTNiNDRMaCtzb2VhNDNzUmNDL2YwZVp2YnVBdVdFWVpmYWEx?= =?utf-8?B?RlN0VFZlVmhjRmd2clBhYXVpelNmdDBFMytmOTJRSm5QTHU4YkpaV0VSY1JQ?= =?utf-8?B?RUZub1dickw1WXhydHlWYUgrWWxZeC9wMjhUbGhXN3lxNHhQQ1MyZkRwQ3dN?= =?utf-8?B?UkovQTBYRjdrUHpFUnFnMlgrQ1VxMHo4RzBpVGxDRCtjeGYwaS9yU3NRUEcr?= =?utf-8?B?WElFSHUwazN1TTB0eHBjZU84cS9ZQlc5clhISTM0Uk92aG9GUlZYQT09?= X-Exchange-RoutingPolicyChecked: ZZI9p134vBOL162mW8MViDalG+4SJCvnXALHZrYIxOutzHkOQiZ86OqrFF0TAxuyHhTEQnqi5LlD0dFg1cclLuP+PtKZFl9NmZaCTExcmF91JmBt4vd2pefWCLs48ro6x4vkyybYFJliisG2shje719Dc4YP8RZqflntOhKLEO27zohJM7A4W19k6eq1RWDi5fD97b619wcMcWuR3IP7WXHWc4anTdlYlRxbvuH29TFsiKHZfz2o263KMy9Rxm7nFyZfBYt+b0ku7qtV94L9xJiUZ6FKtGpWsOWi3By/gzwQTWPiFu9qs4xFZfdJJIaO1Z8jMarcqllzwPsejq4pSg== X-MS-Exchange-CrossTenant-Network-Message-Id: 15fa7f54-b398-471d-8cf0-08df4ec74a86 X-MS-Exchange-CrossTenant-AuthSource: DS6PR11MB087165.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 09:49:56.6654 (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: 4wjiAfCjs7m8vR63u5qAHt88piCGshmSS9V8v2otaVkO/6x1hRmzzB9pyzo6NwKHcuiAorCs62P1JeY+cTBNMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR11MB8751 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 Hi Karthik, On 28-11-2026 11:29, Karthik Poosa wrote: > Initialize Xe hwmon fan-control support by detecting enabled fans, > reading stock fan control points and min PWM. > > FSC_READ_NUM_FANS returns a bitmask of enabled fans, so use it as a mask > when exposing fanN_input. > > v2: > - Avoid user table initialization during probe. (Badal) > - Move unused code to appropriate patches. > - Use xe helpers for dmesg logs. > > v3: > - Rebase. > - Refine a few debug log messages and comments. > - Update xe_hwmon_read_fan_control_info() to return on any stock table > read failures. > - Avoid returning when num_fans is 0 in > xe_hwmon_get_preregistration_info(), ensuring thermal mailbox > initialization is not skipped. > - Remove XE_PCODE_FAN_CONTROL_TIMEOUT_MS which is unnecessary as default > timeout itself is now 10ms. > - Use xe_pcode_read() instead of xe_pcode_read_timeout(). > - Rename fan_control_point_count to point_count in struct fan_table. > - Resolve kernel-doc warnings. > - Add valid check for stock table fan point count. > - Use the fan-enable bitmap reported by FSC_READ_NUM_FANS when enumerating > fans. This avoids assuming contiguous fan indices and allows masks with > gaps to be represented correctly in the hwmon interface. > > v4: > - Clamp unsupported fan masks and oversized stock tables instead of > failing initialization. (Soham) > - On stock table read failure, mark that fan's table empty and continue > with the remaining fans; fan_input stays visible. (Soham) > - Clear fan enable mask and min PWM on pcode read failure. (Soham) > - Fix FCP_INDEX() type safety and clean up macro usage. (Soham) > - Use xe_hwmon_pcode_read_fan_control() for fan mailbox reads. (Soham) > - Fix kernel-doc for fan_table_type and nested fan_table members. > - Skip min PWM read for fans without a stock table. > - Make xe_hwmon_get_fan_enable_mask() return void. > > v5: > - Remove min_pwm as it is no longer supported by the hardware. > - Change xe_hwmon_get_fan_enable_mask() return type from void to int. > - Copy the stock table to the fan info only if all points are read > successfully. > > Signed-off-by: Karthik Poosa > --- > drivers/gpu/drm/xe/xe_hwmon.c | 162 +++++++++++++++++++++++++++--- > drivers/gpu/drm/xe/xe_pcode_api.h | 4 + > 2 files changed, 151 insertions(+), 15 deletions(-) > > diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c > index 717845b7e6a1..503f18625338 100644 > --- a/drivers/gpu/drm/xe/xe_hwmon.c > +++ b/drivers/gpu/drm/xe/xe_hwmon.c > @@ -22,6 +22,7 @@ > #include "xe_pcode_api.h" > #include "xe_sriov.h" > #include "xe_pm.h" > +#include "xe_printk.h" > #include "xe_vsec.h" > #include "regs/xe_pmt.h" Maintain the alphabetical order. > > @@ -139,13 +140,51 @@ struct xe_hwmon_energy_info { > }; > > /** > - * struct xe_hwmon_fan_info - to cache previous fan reading > + * enum fan_table_type - fan table types tracked per fan > + */ > +enum fan_table_type { > + /** @STOCK_FAN_TABLE: firmware-provided fan table */ > + STOCK_FAN_TABLE, > + /** @USER_FAN_TABLE: user fan table written through sysfs */ > + USER_FAN_TABLE, > + /** @FAN_TABLE_MAX: number of fan tables tracked per fan */ > + FAN_TABLE_MAX, > +}; > + > +/* Check if a fan is enabled based on the fan_enable_mask got from FSC_READ_NUM_FANS. */ > +#define IS_FAN_ENABLED(hwmon, fan) ((hwmon)->fan_enable_mask & BIT(fan)) > + > +/* Maximum number of fan control points supported by each fan. */ > +#define MAX_FAN_CONTROL_POINTS 10 > + > +/* 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) | \ Should this be moved to xe_pcode_api.h ? > + ((u32)(point_num) & GENMASK(30, 0))) > + > +/** > + * struct xe_hwmon_fan_info - cached fan telemetry and control state > + * > + * Each fan keeps the latest tachometer sampling state along with two fan > + * tables: the stock table discovered from firmware and the user table managed > + * by hwmon sysfs writes. > */ > struct xe_hwmon_fan_info { > /** @reg_val_prev: previous fan reg val */ > u32 reg_val_prev; > /** @time_prev: previous timestamp */ > u64 time_prev; > + /** @fan_table: fan control tables */ > + struct fan_table { > + /** @fan_table.point_count: number of fan control points */ > + u8 point_count; > + /** @fan_table.fcp: array of fan control points */ > + struct fan_control_point { > + /** @fan_table.fcp.temp: temperature in degree celsius */ > + u8 temp; > + /** @fan_table.fcp.speed: fan speed in percentage */ > + u8 speed; > + } fcp[MAX_FAN_CONTROL_POINTS]; > + } fan_table[FAN_TABLE_MAX]; > }; > > /** > @@ -194,6 +233,8 @@ struct xe_hwmon { > int scl_shift_time; > /** @ei: Energy info for energyN_input */ > struct xe_hwmon_energy_info ei[CHANNEL_MAX]; > + /** @fan_enable_mask: bitmask of available fans */ > + u32 fan_enable_mask; > /** @fi: Fan info for fanN_input */ > struct xe_hwmon_fan_info fi[FAN_MAX]; > /** @read_power_limit_from_pcode: pcode accepted power limits write for the channel */ > @@ -1084,17 +1125,106 @@ static int xe_hwmon_pcode_write_i1(const struct xe_hwmon *hwmon, u32 uval) > (uval & POWER_SETUP_I1_DATA_MASK)); > } > > -static int xe_hwmon_pcode_read_fan_control(const struct xe_hwmon *hwmon, u32 subcmd, u32 *uval) > +static int xe_hwmon_pcode_read_fan_control(const struct xe_hwmon *hwmon, u32 subcmd, u8 fan_num, > + u32 *uval) > { > struct xe_tile *root_tile = xe_device_get_root_tile(hwmon->xe); > > + return xe_pcode_read(root_tile, PCODE_MBOX(FAN_SPEED_CONTROL, subcmd, fan_num), > + uval, NULL); The continuation line is not aligned with the open parenthesis. > +} > + > +static int xe_hwmon_get_fan_enable_mask(struct xe_hwmon *hwmon) > +{ > + int ret; > + > /* Platforms that don't return correct value */ > - if (hwmon->xe->info.platform == XE_DG2 && subcmd == FSC_READ_NUM_FANS) { > - *uval = 2; > + if (hwmon->xe->info.platform == XE_DG2) { > + hwmon->fan_enable_mask = GENMASK(1, 0); > return 0; > } > > - return xe_pcode_read(root_tile, PCODE_MBOX(FAN_SPEED_CONTROL, subcmd, 0), uval, NULL); > + ret = xe_hwmon_pcode_read_fan_control(hwmon, FSC_READ_NUM_FANS, 0, > + &hwmon->fan_enable_mask); > + if (ret) { > + hwmon->fan_enable_mask = 0; > + xe_warn(hwmon->xe, "failed to read number of fans, ret=%d\n", ret); > + return ret; > + } > + > + /* Check if fan mask exceeds FAN_MAX and log a warning if it does */ > + if (hwmon->fan_enable_mask & ~GENMASK(FAN_MAX - 1, 0)) { > + xe_warn(hwmon->xe, "Fan enable mask exceeds %d supported fans, clamping\n", > + FAN_MAX); > + hwmon->fan_enable_mask &= GENMASK(FAN_MAX - 1, 0); > + } > + > + xe_info(hwmon->xe, "Number of fans detected: %u\n", hweight32(hwmon->fan_enable_mask)); > + > + return 0; > +} > + > +static int xe_hwmon_read_fan_control_info(struct xe_hwmon *hwmon) > +{ > + int err = 0; > + int point; > + int fan; > + int ret; > + > + for (fan = 0; fan < FAN_MAX; fan++) { > + struct fan_control_point stock_fcp[MAX_FAN_CONTROL_POINTS]; > + struct xe_hwmon_fan_info *fi = &hwmon->fi[fan]; > + u32 stock_fcp_count = 0; > + > + if (!IS_FAN_ENABLED(hwmon, fan)) > + continue; > + > + ret = xe_hwmon_pcode_read_fan_control(hwmon, > + FSC_READ_STOCK_FAN_CONTROL_POINTS, > + fan, &stock_fcp_count); > + if (ret || !stock_fcp_count) { > + xe_warn(hwmon->xe, > + "fan %d stock table unavailable, ret=%d, point count=%u\n", > + fan, ret, ret ? 0 : stock_fcp_count); > + err = ret ?: -ENODATA; Can't either of err or ret be discarded ? Regards, Soham > + continue; > + } > + > + if (stock_fcp_count > MAX_FAN_CONTROL_POINTS) { > + xe_warn(hwmon->xe, > + "fan %d stock table point count %u exceeds maximum %u, clamping\n", > + fan, stock_fcp_count, MAX_FAN_CONTROL_POINTS); > + stock_fcp_count = MAX_FAN_CONTROL_POINTS; > + } > + > + xe_dbg(hwmon->xe, "fan %d stock table point count is %u\n", fan, stock_fcp_count); > + > + /* Cache the stock fan table for later use. */ > + for (point = 0; point < stock_fcp_count; point++) { > + u32 fcp = FCP_INDEX(STOCK_FAN_TABLE, point); > + > + ret = xe_hwmon_pcode_read_fan_control(hwmon, FSC_READ_FAN_TABLE, fan, &fcp); > + if (ret) { > + xe_warn(hwmon->xe, "failed to read fan %d stock point %d, ret=%d\n", > + fan, point, ret); > + err = ret; > + break; > + } > + > + stock_fcp[point].temp = REG_FIELD_GET(FAN_CONTROL_POINT_TEMP_MASK, fcp); > + stock_fcp[point].speed = REG_FIELD_GET(FAN_CONTROL_POINT_SPEED_MASK, fcp); > + xe_dbg(hwmon->xe, "fan %d stock point %d: temp %u C, speed %u %%\n", > + fan, point, stock_fcp[point].temp, stock_fcp[point].speed); > + } > + > + if (point < stock_fcp_count) > + continue; > + > + 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; > + } > + return err; > } > > static int xe_hwmon_power_curr_crit_read(struct xe_hwmon *hwmon, int channel, > @@ -1632,17 +1762,12 @@ xe_hwmon_energy_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val) > static umode_t > xe_hwmon_fan_is_visible(struct xe_hwmon *hwmon, u32 attr, int channel) > { > - u32 uval = 0; > - > if (!hwmon->xe->info.has_fan_control) > return 0; > > switch (attr) { > case hwmon_fan_input: > - if (xe_hwmon_pcode_read_fan_control(hwmon, FSC_READ_NUM_FANS, &uval)) > - return 0; > - > - return channel < uval ? 0444 : 0; > + return IS_FAN_ENABLED(hwmon, channel) ? 0444 : 0; > default: > return 0; > } > @@ -1876,11 +2001,18 @@ xe_hwmon_get_preregistration_info(struct xe_hwmon *hwmon) > if (xe_hwmon_is_visible(hwmon, hwmon_energy, hwmon_energy_input, channel)) > xe_hwmon_energy_get(hwmon, channel, &energy); > > - /* Initialize 'struct xe_hwmon_fan_info' with initial fan register reading. */ > - for (channel = 0; channel < FAN_MAX; channel++) > - if (xe_hwmon_is_visible(hwmon, hwmon_fan, hwmon_fan_input, channel)) > - xe_hwmon_fan_input_read(hwmon, channel, &fan_speed); > + if (hwmon->xe->info.has_fan_control) { > + xe_hwmon_get_fan_enable_mask(hwmon); > + > + /* Initialize 'struct xe_hwmon_fan_info' with initial fan register reading. */ > + for (channel = 0; channel < FAN_MAX; channel++) > + if (IS_FAN_ENABLED(hwmon, channel)) > + xe_hwmon_fan_input_read(hwmon, channel, &fan_speed); > > + /* Fan control tables initialization */ > + if (xe_hwmon_read_fan_control_info(hwmon)) > + xe_warn(hwmon->xe, "Fan control tables are not available\n"); > + } > return xe_hwmon_init_temp_info(hwmon); > } > > diff --git a/drivers/gpu/drm/xe/xe_pcode_api.h b/drivers/gpu/drm/xe/xe_pcode_api.h > index f05846931059..387885760205 100644 > --- a/drivers/gpu/drm/xe/xe_pcode_api.h > +++ b/drivers/gpu/drm/xe/xe_pcode_api.h > @@ -87,6 +87,10 @@ > > #define FAN_SPEED_CONTROL 0x7D > #define FSC_READ_NUM_FANS 0x4 > +#define FSC_READ_STOCK_FAN_CONTROL_POINTS 0x5 > +#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 PCODE_SCRATCH(x) XE_REG(0x138320 + ((x) * 4)) > /* PCODE_SCRATCH0 */