Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5C0B6C61DFD for ; Mon, 31 Aug 2026 18:28:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3094010E326; Mon, 31 Aug 2026 18:28:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="FmBcvp6U"; dkim-atps=neutral Received: from CY3PR05CU001.outbound.protection.outlook.com (mail-westcentralusazon11013005.outbound.protection.outlook.com [40.93.201.5]) by gabe.freedesktop.org (Postfix) with ESMTPS id B6CF710E654 for ; Mon, 31 Aug 2026 18:28:29 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iv6C259sZknqYraiEiF4xxz9DA8CVqXthXGXx8GuipdcQTLlhciyN/A7CfKXFENtaDglLUFdfPrAoAa+nJFieCI12jnNbEbi1KUqrzHqr67NY0GpPCVAVDQH36M3zdY95xdJWPqV6SWhKaQLusu+dxTXaohkSDVzfVqFw65I1to0jdnCi+bTBhfk8mwPOeQHnuFmxquxflUNppAjhZE5PGTtUcum+ysf5eRKC2MqEn3rT/UB5XXkmPojfzY9MchMaSC2X05hOW/ltgtbn5p4//MXeqoy1FxpEstCqQOBKyKUEm4i3e+XLhA7MefPt/R7xonUg0EcWmxNy24El0jLqA== 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=2a/zTZNGpkQHtSdkZVn8TQYo/JsLOmpgaH4c9mB+KWA=; b=T129Umy0sPh3BqSqPeeH7gNttpMqoaWzogOy5YoP72OAUPxdBxfLwa3PJiChnxQTMIeups7RR5wCPx+Xbi1f5UxJX1TMSr0PCYTX+kauH9RV1cPTOEWu0RalmkQ8ps1JU/WhzrmYB/HTu4NhdjaSBeiVEnRwOC7Pm/wqOuk7p1TK7wPz1g18n9S4XruCw5iWfyrC8r04BhoAO4nAqUg5qsHPl64l+kq9FWdvpPxYeIAEEj8qgJle5R4dyPYepayEIxv82M3A30okgckV2dP9+Qaux+0C9bNexGresn24dAntvQZK8ic5EmBt19O8KfKlQ05Md+sZmdkwbw4IKIGYrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.freedesktop.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2a/zTZNGpkQHtSdkZVn8TQYo/JsLOmpgaH4c9mB+KWA=; b=FmBcvp6UjTs7CEj4YADiq8Vs5QgNQgmkV82RmTk9hvPzjKbPnBD8a5zKex20vsnMtBnh/XX++Gogv0OjT6USyX7tazF4BfkeWcBuZY2K1S0MBpGGmpjRzUT+jOSCF0jZL2hEep6NcVCPqv4ntXmMTJQgal7Z24xseiyWZztSPwQ= Received: from PH1PEPF00013305.namprd07.prod.outlook.com (2603:10b6:518:1::17) by DM4PR12MB6616.namprd12.prod.outlook.com (2603:10b6:8:8e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.360.10; Mon, 31 Aug 2026 18:28:20 +0000 Received: from SA2PEPF00001507.namprd04.prod.outlook.com (2a01:111:f403:c801::2) by PH1PEPF00013305.outlook.office365.com (2603:1036:903:47::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.360.13 via Frontend Transport; Mon, 31 Aug 2026 18:28:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb08.amd.com; pr=C Received: from satlexmb08.amd.com (165.204.84.17) by SA2PEPF00001507.mail.protection.outlook.com (10.167.242.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.382.8 via Frontend Transport; Mon, 31 Aug 2026 18:28:20 +0000 Received: from satlexmb08.amd.com (10.181.42.217) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.46; Mon, 31 Aug 2026 13:28:10 -0500 Received: from p8.amd.com (10.180.168.240) by satlexmb08.amd.com (10.181.42.217) with Microsoft SMTP Server id 15.2.2562.46 via Frontend Transport; Mon, 31 Aug 2026 13:28:09 -0500 From: Alex Deucher To: CC: Felix Kuehling , Mukul Joshi , Alex Deucher Subject: [PATCH 06/95] drm/amdgpu: Add sysfs API for UALink station configuration Date: Mon, 31 Aug 2026 14:26:25 -0400 Message-ID: <20260831182754.1089811-7-alexander.deucher@amd.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831182754.1089811-1-alexander.deucher@amd.com> References: <20260831182754.1089811-1-alexander.deucher@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00001507:EE_|DM4PR12MB6616:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bb0472e-eeee-4f19-4d65-08df078da24a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|23010399003|1800799024|82310400026|376014|36860700016|22082099003|18002099003|56012099006|6133799003|11063799006|10067099003; X-Microsoft-Antispam-Message-Info: SNdJiwptR1IgsSylF38eXjfI9+gIeBb0JBnTV8WfpDGLI3asS2GO5sHIxfpC0fjK95w/MI3K8o+HgJyV1T8W07/UD/QgRSAqp0p3vhBwqAQOl/UJjw/4Vgq+kan1c+Q+wkcgIKcw9VQTGcR/bZkPgoIBRyTULZLRxAJFW2Mob5aIgrkLaKaJ5hnnAuOreZT/aLYjnfbW2ZT/pF4kIahdOS7vH+6ReFOZwhHu99830g2lEh0Pi1bGXmr0eWoTwJgTnyd3AB3wmcJXGJy5OCU5JHbxuVi8XthsDMNX6e2OYhiNucNvghc6v5W5zwy0V93JcbVsW0dUdDTAObDyUKklBktxOj8NKA9YORbWqSrOFoD+YjEXYY8cfdDVY7qLXCPBusIiDYdQltGhdeE+kUwgpbal63rnRPFLTH/T6EJGHVHy1GYyMvWEK1+NfeI1zRXNvGTPqBxHgtWupO21nsmrQ1+OOtqVISkhXOboJCKnEfRN15EEEoHffo9reI7fF8m2NNDdqg1Wzy9WuWl/tsDq59xhZPxJYPttp2b/CLCVNdIfbEfODAl8JzUvAcMppK57p4cCBYMViqqHOZet1x1KUzIlg36g8ci69FlCU8S4fRAxJwi5ekN1SZKyeoHee12uxYgLmVTBIX39syoRhMmY/eiUEzDlnyDQQdk+yncvT6hFfDCWWCcgjBW/fnj3n/Kt1EHdJWOv7mq42ogCQtx7mg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:satlexmb08.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(23010399003)(1800799024)(82310400026)(376014)(36860700016)(22082099003)(18002099003)(56012099006)(6133799003)(11063799006)(10067099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DGh7hjKxeUyRyi1dohuDXUWFUGpGSa9iWznThycx7nmU2W+yB+vZP4EQKKo2mjmSRm7i9uo4EqPR02Wa64NQxtNvUtMjRFG8ar9JDj+yh97ONTWFMbF6trAMuO1hW0fooDWo+HpeuoFbcgmoz8w8gbdpy8s9HA6v/JJRURhkvlEHbxLwmJwvJG/RSq3aNMukM2SWOootqnV7wit8FNx2y4L8yONp8u9Mh7W8KpdZq1bUW6nhKr0q1rpina39mSUg28lE2nwRQS2DhwSwcVjjflGDNJTebQaKB6in1dzYMpnfoQ7MMJii1Plny6PlENCRw8Rra0t8Ylav6fJ91VlYwE9/FxlNUfzaFtgulVbG4Qnf+8wR54rzPI3U99dwb1w0jVKUC76mJbOpSr2N7XAgvEiSMdasFxbLCr1Yyj7I6JV+M9XLQv8H6UjFFjiVjjPa X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2026 18:28:20.3841 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6bb0472e-eeee-4f19-4d65-08df078da24a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[satlexmb08.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00001507.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6616 X-BeenThere: amd-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces@lists.freedesktop.org Sender: "amd-gfx" From: Felix Kuehling /ualink/stations: Directory for staging UALink station/port configuration attributes: - station_flags (currently only sets the number of port per station) - lane_en_bitmap (hexadecimal bitmaps of lanes enabled per station) - write "true" to commit to apply settings Signed-off-by: Felix Kuehling Reviewed-by: Mukul Joshi Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c | 154 ++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.h | 16 +++ 2 files changed, 169 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c index d60cd997dd3c6..3bffb3cb21681 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.c @@ -739,8 +739,127 @@ static const struct kobj_type ualink_vpod_config_ktype = { .sysfs_ops = &kobj_sysfs_ops }; +#ifdef UALINK_ENABLE_DEPRECATED_CONFIG_SYSFS +UALINK_VALUE_SHOW(station_config, flags, flags, "0x%x"); + +UALINK_VALUE_STORE(station_config, flags, flags, u8, 16); + +static size_t lane_bitmap_to_string(char *str, + const struct amdgpu_ualink_station_config *stations) +{ + size_t i; + + for (i = 0; i < stations->n_stations; i++) + str[i] = stations->lane_en_bitmap[i] + + (stations->lane_en_bitmap[i] < 10 ? '0' : 'a' - 10); + str[i] = '\0'; + + return i; +} +static ssize_t +ualink_station_config_lane_en_bitmap_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buf) +{ + struct amdgpu_ualink_station_config *stations = to_ualink_station_config(kobj); + char str[AMDGPU_UALINK_STATIONS_MAX + 1]; + + lane_bitmap_to_string(str, stations); + return sysfs_emit(buf, "%s\n", str); +} +static ssize_t +ualink_station_config_lane_en_bitmap_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + struct amdgpu_ualink_station_config *stations = to_ualink_station_config(kobj); + u8 lane_en_bitmap[AMDGPU_UALINK_STATIONS_MAX]; + u32 n_stations = 0; + bool end = false; + size_t i; + + for (i = 0; i < count; i++) { + /* Accept any number of \n in the end */ + if (buf[i] == '\n') { + end = true; + continue; + } + /* Don't accept any more data after \n */ + if (end) + return -EINVAL; + /* Don't accept more data than the array size */ + if (i >= sizeof(lane_en_bitmap)) + return -ENOSPC; + /* Accept hex digits */ + if (buf[i] >= '0' && buf[i] <= '9') + lane_en_bitmap[n_stations++] = buf[i] - '0'; + else if (buf[i] >= 'a' && buf[i] <= 'f') + lane_en_bitmap[n_stations++] = buf[i] + 10 - 'a'; + else if (buf[i] >= 'A' && buf[i] <= 'F') + lane_en_bitmap[n_stations++] = buf[i] + 10 - 'A'; + else + return -EINVAL; + } + + memcpy(stations->lane_en_bitmap, lane_en_bitmap, sizeof(lane_en_bitmap)); + stations->n_stations = n_stations; + return i; +} + +static ssize_t ualink_station_config_commit_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + struct amdgpu_ualink_station_config *stations = to_ualink_station_config(kobj); + struct amdgpu_ualink_info *info = to_ualink_info(kobj->parent); + struct device *dev = kobj_to_dev(info->kobj.parent); + struct drm_device *ddev = dev_get_drvdata(dev); + struct amdgpu_device *adev = drm_to_adev(ddev); + + /* DF reconfiguration does not interact with accelerator state */ + + if (!sysfs_streq(buf, "true")) + return -EINVAL; + + /* TODO: Send configuration to ASP */ + (void)adev; + (void)stations; + + return count; +} + +#define UALINK_STATION_CONFIG_ATTR(name) __ATTR(name, 0600, \ + ualink_station_config_##name##_show, \ + ualink_station_config_##name##_store) +static struct kobj_attribute ualink_station_config_flags = UALINK_STATION_CONFIG_ATTR(flags); +static struct kobj_attribute ualink_station_config_lane_en_bitmap = + UALINK_STATION_CONFIG_ATTR(lane_en_bitmap); +static struct kobj_attribute ualink_station_config_commit = + __ATTR(commit, 0200, NULL, ualink_station_config_commit_store); + +static const struct attribute *ualink_station_config_attrs[] = { + &ualink_station_config_flags.attr, + &ualink_station_config_lane_en_bitmap.attr, + &ualink_station_config_commit.attr, + NULL +}; +#endif + +static void ualink_station_config_release(struct kobject *kobj) +{ + struct amdgpu_ualink_station_config *stations = to_ualink_station_config(kobj); + + kfree(stations); +} + +static const struct kobj_type ualink_station_config_ktype = { + .release = ualink_station_config_release, + .sysfs_ops = &kobj_sysfs_ops +}; + int amdgpu_ualink_sysfs_init(struct amdgpu_device *adev) { + struct amdgpu_ualink_station_config *stations = NULL; struct amdgpu_ualink_vpod_config *vpod_config = NULL; struct amdgpu_ualink_ppod_setup *ppod_setup = NULL; struct amdgpu_ualink_info *info = NULL; @@ -794,6 +913,22 @@ int amdgpu_ualink_sysfs_init(struct amdgpu_device *adev) goto err_del_vpod_config; #endif + stations = kzalloc(sizeof(*stations), GFP_KERNEL); + if (!stations) { + r = -ENOMEM; + goto err_remove_vpod_config_files; + } + r = kobject_init_and_add(&stations->kobj, &ualink_station_config_ktype, + &info->kobj, "stations"); + if (r) + goto err_put_stations; +#ifdef UALINK_ENABLE_DEPRECATED_CONFIG_SYSFS + r = sysfs_create_files(&stations->kobj, ualink_station_config_attrs); + if (r) + goto err_del_stations; +#endif + + adev->ualink.stations = stations; adev->ualink.config = vpod_config; adev->ualink.setup = ppod_setup; adev->ualink.info = info; @@ -801,9 +936,17 @@ int amdgpu_ualink_sysfs_init(struct amdgpu_device *adev) return r; #ifdef UALINK_ENABLE_DEPRECATED_CONFIG_SYSFS +err_del_stations: + kobject_del(&stations->kobj); +#endif +err_put_stations: + kobject_put(&stations->kobj); +err_remove_vpod_config_files: +#ifdef UALINK_ENABLE_DEPRECATED_CONFIG_SYSFS + sysfs_remove_files(&vpod_config->kobj, ualink_vpod_config_attrs); err_del_vpod_config: - kobject_del(&vpod_config->kobj); #endif + kobject_del(&vpod_config->kobj); err_put_vpod_config: kobject_put(&vpod_config->kobj); err_remove_ppod_setup_files: @@ -825,6 +968,15 @@ int amdgpu_ualink_sysfs_init(struct amdgpu_device *adev) void amdgpu_ualink_sysfs_fini(struct amdgpu_device *adev) { + if (adev->ualink.stations) { +#ifdef UALINK_ENABLE_DEPRECATED_CONFIG_SYSFS + sysfs_remove_files(&adev->ualink.stations->kobj, + ualink_station_config_attrs); +#endif + kobject_del(&adev->ualink.stations->kobj); + kobject_put(&adev->ualink.stations->kobj); + adev->ualink.stations = NULL; + } if (adev->ualink.config) { #ifdef UALINK_ENABLE_DEPRECATED_CONFIG_SYSFS sysfs_remove_files(&adev->ualink.config->kobj, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.h index 01a36b058ea08..2d685f6dd7e7d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ualink.h @@ -33,6 +33,7 @@ struct amdgpu_device; #define AMDGPU_UALINK_ACCEL_MAX 256 #define AMDGPU_UALINK_LOCAL_ACCELS_MAX 8 +#define AMDGPU_UALINK_STATIONS_MAX 64 enum amdgpu_ualink_type { AMDGPU_UALINK_TYPE_UALOE = 0, @@ -104,10 +105,25 @@ struct amdgpu_ualink_vpod_config { }; #define to_ualink_vpod_config(ko) container_of(ko, struct amdgpu_ualink_vpod_config, kobj) +/* UALink station configuration */ +struct amdgpu_ualink_station_config { + struct kobject kobj; + /* Station configuration flags + * bits [3:0]: PortPerStation (PPS) - 1, 2, or 4 + * bits [7:4]: Reserved + */ + u8 flags; + u8 n_stations; + /* bitmap or enabled lanes for each station in logical station order */ + u8 lane_en_bitmap[AMDGPU_UALINK_STATIONS_MAX]; +}; +#define to_ualink_station_config(ko) container_of(ko, struct amdgpu_ualink_station_config, kobj) + struct amdgpu_ualink_mgr { struct amdgpu_ualink_info *info; struct amdgpu_ualink_ppod_setup *setup; struct amdgpu_ualink_vpod_config *config; + struct amdgpu_ualink_station_config *stations; }; int amdgpu_ualink_sysfs_init(struct amdgpu_device *adev); -- 2.55.0