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 AC232606A320 for ; Mon, 30 Nov 2026 14:29:58 +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=Y0Wd9u9T Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 74B9C10F0FD; Mon, 30 Nov 2026 14:29:53 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by gabe.freedesktop.org (Postfix) with ESMTPS id 22D9810F0F2 for ; Mon, 30 Nov 2026 14:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796048988; x=1827584988; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=risX8pk3miQC3ianY+VrPds6fzo2YCXVFIM/lA1e71Y=; b=Y0Wd9u9Tv8RvRDElwvkQqDoObyvQcLEmZq9UWq/saEObcM7Oma83iK2i HdRhmT95PtPl30xv1J84fwj6wCzk8psnxP4iDIjLaRkUMUOKeAoXThLUI MQc5BfjRmx9w+S4LEOBmydsbrQfaxgPDoRXWt+arIbEe/lCMrKHuQbmrL 6S+nDED8pKx6N+fhYRfN3BtED2g5EILFq6bZZjgjEQzfbDfRIuVJvhE8L 5iTrXjSzBpc0Y0OddA+Bmvs0Pjm1BGUWHGnJZNpmFRhG/lAbNOKp3maIr HKPvHP8Cc4j/VP0YSKYXax00P5tex6PUI4twA4mH6nfqvohE7b6qFMnEY g==; X-CSE-ConnectionGUID: QlO6xzOMTAWhfovo2zpUeQ== X-CSE-MsgGUID: FyryEtBaSUGZU35sh+F7XA== X-IronPort-AV: E=McAfee;i="6800,10657,11982"; a="4725595" X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4725595" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 06:29:45 -0800 X-CSE-ConnectionGUID: /bWbxBSJRoag4YvMUORS1Q== X-CSE-MsgGUID: 4ZFMCa7WRdSIU+HR0nyCgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,242,1787036400"; d="scan'208";a="4452645" Received: from fmsmsx901.amr.corp.intel.com ([10.18.126.90]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2026 06:29:45 -0800 Received: from FMSMSX903.amr.corp.intel.com (10.18.126.92) 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; Mon, 30 Nov 2026 06:29:43 -0800 Received: from fmsedg902.ED.cps.intel.com (10.1.192.144) by FMSMSX903.amr.corp.intel.com (10.18.126.92) 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 06:29:43 -0800 Received: from SJ2PR03CU001.outbound.protection.outlook.com (52.101.43.39) 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; Mon, 30 Nov 2026 06:29:43 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lZVzDPWrhqRefYUeiiHwQSuh8AD5CD2aCgQsEE8bZ+9W4xj+UBbvVkpWbbdEEDmehUXCY/0MZU3M15glPhBmrVYVC/wAzOKbXl6JhaoX8/LHdr7Lm08e9K8ASaiW73B1TWJDJH1O/sHmYJkWsmUQMglf74nbdez7dtwZcePF9mGNjwSq2wGArcJaF7aR/P1PH5iE3PlQsPe72E/IPQ/574d2sSNtRzIxiI44dIwVQpyoqa4JNj3RID+FTIGJHXnfb06TAlt56c1e79jRKVnCHy/5RGmM/BAfFGYseysaJhMIK+XsNfe6wwpPqhDQZS322nS3sPIdcog5hx+Hrrg4VQ== 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=risX8pk3miQC3ianY+VrPds6fzo2YCXVFIM/lA1e71Y=; b=KJ/VR8r5FUiG+taUPAi54wFHq5kaZByER9T5cmeC3PVw0juMpcxoovbm1w7bsOwBjanfYCKynrr24HKpkmMM/se0wVdskr7oOWM5Od1/unCNhXiJnbFxy4Izk2nOfc6HEBx7YMvUUbIWQnHeQBZNBXENinrRUOr6zcpTy4mOhVPei5wM/56Ct3Xrq7m1uKA8LbaQfgnQEfdlqauD28uPB+PaShigTyahdqUjLlce+zPuJCSqGNpcmOcsisrJXcblba8/O7QwadkIFS/JlnAqbTcpwIRAFzqfS1d4SNSsln5MGuRjRiTaWv1xjQk6UzHvOxwdLjKjkedDvuh7QqHaig== 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 LV2PR11MB6022.namprd11.prod.outlook.com (2603:10b6:408:17c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.662.11; Mon, 30 Nov 2026 14:29:41 +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 14:29:41 +0000 Message-ID: Date: Mon, 30 Nov 2026 19:59:31 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 05/10] drm/xe/hwmon: Expose pwm[1-3]_enable To: Karthik Poosa , CC: , , , , , , , References: <20261128055923.3316956-1-karthik.poosa@intel.com> <20261128055923.3316956-6-karthik.poosa@intel.com> Content-Language: en-US From: "Purkait, Soham" In-Reply-To: <20261128055923.3316956-6-karthik.poosa@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: MA5P287CA0191.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:1b6::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: DS6PR11MB087165:EE_|LV2PR11MB6022:EE_ X-MS-Office365-Filtering-Correlation-Id: 8a4ccd39-0ca0-49d8-fd43-08df4eee5ed8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|366016|1800799024|376014|56012099006|10067099003|261021130227099003|261026121527099003|261026130827099003|261026135527099003|261028144727099003|261021133027099003|261022075727099003|261022105027099003|261022115727099003|261026140227099003|261021135927099003|261022113327099003|261021121427099003|261021123027099003|261102123227099003|261009223027099003|18002099003|22082099003|5023799004|11063799006|4143699003|6133799003; X-Microsoft-Antispam-Message-Info: JrBcHFMk5CFMAr3IzyCK4Ul0YD1EZK/XE8Jaz+fCqx158UhwXwMwqLU9DPK/xjtnlqq2qETsGtNzZ0F72KKjFpl0ml85zXV3BWVYAPp4wqbzV0goCGt6F7cQNmJOPdWXNtHvGig9ZHiw4sq8GeYT/ZMzBv1Y8/1MbeIDiqU7nJQgcbEvIyFuHatYDf6VTiIkkzOb9MVjG529/f1AuAhsOyNQx9NSUPa1s26P7qWs8rlc74AH2HR8r/VbDNW63OCGj+6MMHpHD7YR7JdzsiwV0cw/jA0tow8VaxmwKD2e0fJf5biNWTm3vF61pImr65Jqj8Tz5n8oj3foLPubDu0m/mONSI/SK0QjG12g+1ivUWxeRGjIya76xzYedWuJYxT5bYDzwytKTvCIZCQA/Y1Bz8ZGrx5VVJGWbCaJcxsivuNpBz6Jb+lCMfwCc0N9VJroy6EuSJA23Fz4q/JyxwHwqYDA+5kEfnudI9OiZNJgDEYfrOTV0ULz0YL9uMsXLC9qYQ8GD2J5L7E9Y/xbV7qP5rTmMPURpx0g1dqb5smqpI8f3hmXXxglaTmtnS4Ugik8i9T6xUgDmusjj/5GaRX41iGoBKegx3iX4MhRXv7qksIXPEO+OTA8ukIzi4eVaoDUC+Bb1ujOR4yczjIIFsDy9gud/7msof7i++DFZP8hnBc= 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)(23010399003)(366016)(1800799024)(376014)(56012099006)(10067099003)(261021130227099003)(261026121527099003)(261026130827099003)(261026135527099003)(261028144727099003)(261021133027099003)(261022075727099003)(261022105027099003)(261022115727099003)(261026140227099003)(261021135927099003)(261022113327099003)(261021121427099003)(261021123027099003)(261102123227099003)(261009223027099003)(18002099003)(22082099003)(5023799004)(11063799006)(4143699003)(6133799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d0hIbkhWMTFYUXFtWGZIdTdNZ001MXRLUUNaaTk1VDJqbVFzTitKUDFicD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Id: 8a4ccd39-0ca0-49d8-fd43-08df4eee5ed8 X-MS-Exchange-CrossTenant-AuthSource: DS6PR11MB087165.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2026 14:29:41.1774 (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: f3/hi2Krbtuw7nIAyAxHHyy0CioJ7PQUs4vy889I+gURj1dQY504cf1rm1I2lyh3ZEQxF29wQ6ZKCBGgrkS1Pw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR11MB6022 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: > 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. > > Document pwm[1-3]_enable in the Xe hwmon ABI. > > 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. > - Verify user point counts after table activation and auto-mode writes. > - Fall back to the stock table if firmware does not accept a table. > > Signed-off-by: Karthik Poosa > --- > .../ABI/testing/sysfs-driver-intel-xe-hwmon | 15 ++ > drivers/gpu/drm/xe/xe_hwmon.c | 201 +++++++++++++++++- > 2 files changed, 207 insertions(+), 9 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon b/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon > index 24e9eb595746..be1c325fcc9b 100644 > --- a/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon > +++ b/Documentation/ABI/testing/sysfs-driver-intel-xe-hwmon > @@ -354,4 +354,19 @@ 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: November 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. > + > 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 1e375613fe18..f62a60e99140 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: force all user table points to full speed */ > + XE_FAN_PWM_FULL_SPEED = 0, > + /** @XE_FAN_PWM_MANUAL_USER_TABLE: use the driver-managed user table */ > + XE_FAN_PWM_MANUAL_USER_TABLE = 1, > + /** @XE_FAN_PWM_AUTO_STOCK_TABLE: use the firmware stock table */ The wording still differs from the ABI doc ("full speed", "user table control", "firmware default behavior"). Could it be aligned ? > + 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,10 @@ 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; > + /** @is_full_speed: flag indicating if fan is in full speed */ > + bool is_full_speed; Does it only store the value of  (pwm_enable_mode == XE_FAN_PWM_FULL_SPEED) ? > }; > > /** > @@ -926,7 +944,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 > }; > > @@ -1176,6 +1196,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 : > @@ -1211,9 +1232,88 @@ 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->fan_table[USER_FAN_TABLE].point_count = 0; > + fi->pwm_enable_mode = XE_FAN_PWM_AUTO_STOCK_TABLE; > + fi->is_full_speed = false; > + return 0; > + > +fail: > + fi->pwm_enable_mode = XE_FAN_PWM_UNINITIALIZED; > + fi->is_full_speed = false; > + 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_hwmon_fan_info *fi = &hwmon->fi[fan]; > + struct xe_pcode_write writes[MAX_FAN_CONTROL_POINTS + 1]; > + u32 expected_count, point_count; > + int ret, write_ret, verify_ret; > + int point; Could point be u32, to match point_count? > + struct fan_table *source_table = &fi->fan_table[table_source]; Reverse xmas tree order is still not followed, as noted in v3. > + > + 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", Nit: point_count is u32, so should %u be used? > + 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); The write/verify/fallback sequence is still repeated in xe_hwmon_set_user_fan_pwm() and xe_hwmon_commit_user_fan_table() as noted in v3. A shared helper might be helpful ? > + if (write_ret || verify_ret || point_count != expected_count) { > + int failure_ret = write_ret ?: verify_ret ?: -EIO; > + > + fi->fan_table[USER_FAN_TABLE].point_count = 0; > + if (verify_ret || point_count != expected_count) > + xe_err(hwmon->xe, > + "fan %d user table count misatch: ret=%d, expected=%u, got=%u\n", Typo: "misatch" should be "mismatch". > + fan, verify_ret, expected_count, point_count); > + 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; > + } > + > + 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 = > + is_full_speed ? 100 : min_t(u8, source_table->fcp[point].speed, > + 100); > + } > + } > + > + fi->fan_table[USER_FAN_TABLE].point_count = point_count; > + fi->pwm_enable_mode = is_full_speed ? XE_FAN_PWM_FULL_SPEED : > + XE_FAN_PWM_MANUAL_USER_TABLE; > + fi->is_full_speed = is_full_speed; > > return 0; > } > @@ -1221,7 +1321,7 @@ static int xe_hwmon_fan_set_auto(struct xe_hwmon *hwmon, u8 fan) > /* 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) > +static int xe_hwmon_set_user_fan_pwm(struct xe_hwmon *hwmon, u8 fan, u8 pwm, bool full_speed) In v3 it was agreed to use is_full_speed, but full_speed is still used here. > { > struct xe_pcode_write writes[MIN_FAN_CONTROL_POINTS + 1]; > struct xe_hwmon_fan_info *fi = &hwmon->fi[fan]; > @@ -1229,6 +1329,11 @@ static int xe_hwmon_set_user_fan_pwm(struct xe_hwmon *hwmon, u8 fan, u8 pwm) > u32 point_count = 0; > u8 speed; > > + if (!full_speed && 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; > + } The default mode after probe is AUTO, so pwmN writes that worked before are now rejected until pwmN_enable=1. Is this ABI change intended? If so, could it be noted in the commit message? > + > /* Fan table speed are in percent. */ > speed = DIV_ROUND_CLOSEST(pwm * 100, U8_MAX); > speed = min_t(u32, speed, 100); > @@ -1280,6 +1385,9 @@ static int xe_hwmon_set_user_fan_pwm(struct xe_hwmon *hwmon, u8 fan, u8 pwm) > } > fi->fan_table[USER_FAN_TABLE].point_count = MIN_FAN_CONTROL_POINTS; > > + fi->pwm_enable_mode = full_speed ? XE_FAN_PWM_FULL_SPEED : > + XE_FAN_PWM_MANUAL_USER_TABLE; Mode 0 overwrites the user table cache with 2 points at 100%. When mode 1 is selected after that, USER_FAN_TABLE is used as the source, so the fan seems to stay at full speed and the earlier user curve is lost. Is this intended? > + fi->is_full_speed = full_speed; > return 0; > } > > @@ -1299,6 +1407,9 @@ static int xe_hwmon_read_fan_control_info(struct xe_hwmon *hwmon) > if (!IS_FAN_ENABLED(hwmon, fan)) > continue; > > + fi->pwm_enable_mode = XE_FAN_PWM_UNINITIALIZED; > + fi->fan_table[STOCK_FAN_TABLE].point_count = 0; > + > ret = xe_hwmon_pcode_read_fan_control(hwmon, FSC_READ_MAX_FAN_RPS, fan, > &fi->max_rps); > if (ret) { > @@ -1352,6 +1463,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 err; > } > @@ -1913,6 +2026,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; > @@ -2018,7 +2132,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: active pwm value from stock table cache: %ld\n", channel, pwm); > return 0; > } > > @@ -2064,12 +2178,20 @@ 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; > } > > +static enum fan_table_type xe_hwmon_get_active_fan_table(struct xe_hwmon *hwmon, u8 fan) > +{ > + if (hwmon->fi[fan].pwm_enable_mode == XE_FAN_PWM_AUTO_STOCK_TABLE) > + return STOCK_FAN_TABLE; > + else Nit: the else after return is not needed. > + return USER_FAN_TABLE; > +} > + > static int > xe_hwmon_pwm_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val) > { > @@ -2084,8 +2206,9 @@ 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); > + if (xe_hwmon_get_active_fan_table(hwmon, channel) == STOCK_FAN_TABLE) { > + xe_dbg(hwmon->xe, "getting active pwm for fan %d from stock table\n", > + channel); > switch (hwmon->xe->info.platform) { > case XE_BATTLEMAGE: > ret = xe_hwmon_get_pwm_from_pmt(hwmon, channel, &pwm); > @@ -2094,13 +2217,18 @@ xe_hwmon_pwm_read(struct xe_hwmon *hwmon, u32 attr, int channel, long *val) > ret = xe_hwmon_get_stock_table_pwm(hwmon, channel, &pwm); > break; > } > - if (ret) > + if (ret) { > + xe_err(hwmon->xe, "failed to get active pwm for fan %d, ret=%d\n", > + channel, 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. > */ > + xe_dbg(hwmon->xe, "getting active pwm for fan %d from user table cache\n", > + channel); > pwm = fi->fan_table[USER_FAN_TABLE].fcp[0].speed; > } > if (pwm < 0 || pwm > 100) { > @@ -2112,6 +2240,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->is_full_speed ? XE_FAN_PWM_FULL_SPEED : fi->pwm_enable_mode; > + break; > default: > ret = -EOPNOTSUPP; > break; > @@ -2125,8 +2260,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) { > @@ -2135,7 +2273,48 @@ xe_hwmon_pwm_write(struct xe_hwmon *hwmon, u32 attr, int channel, long val) > ret = -EINVAL; > break; > } > - ret = xe_hwmon_set_user_fan_pwm(hwmon, channel, (u8)val); > + ret = xe_hwmon_set_user_fan_pwm(hwmon, channel, (u8)val, false); > + break; > + case hwmon_pwm_enable: > + if (val == XE_FAN_PWM_FULL_SPEED) { > + ret = xe_hwmon_set_user_fan_pwm(hwmon, channel, U8_MAX, true); > + if (ret) { > + xe_warn(hwmon->xe, > + "full speed enable for fan %d failed, ret=%d\n", > + channel, ret); > + break; > + } > + } else if (val == XE_FAN_PWM_MANUAL_USER_TABLE) { > + enum fan_table_type source = fi->fan_table[USER_FAN_TABLE].point_count ? > + USER_FAN_TABLE : STOCK_FAN_TABLE; > + > + /* > + * Manual fan speed control using user fan table. > + * If user fan table is not programmed, it would be initialized with > + * clamped stock points which allows manual control with some > + * default points. > + */ > + ret = xe_hwmon_activate_user_fan_table(hwmon, channel, false, source); > + if (ret) { > + xe_warn(hwmon->xe, > + "failed to activate user fan table for fan %d, ret=%d\n", > + channel, ret); > + break; > + } > + } 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 { > + ret = -EINVAL; Rejected silently. Add a xe_dbg/xe_warn before these -EINVAL returns for clarity. Regards, Soham > + } > break; > default: > ret = -EOPNOTSUPP; > @@ -2350,6 +2529,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 */ > @@ -2364,6 +2544,9 @@ int xe_hwmon_register(struct xe_device *xe) > if (!hwmon) > return -ENOMEM; > > + 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;