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 DD610FF8867 for ; Wed, 29 Apr 2026 04:10:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2224C10EE3A; Wed, 29 Apr 2026 04:10:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="YDlt/v/i"; dkim-atps=neutral Received: from SN4PR0501CU005.outbound.protection.outlook.com (mail-southcentralusazon11011063.outbound.protection.outlook.com [40.93.194.63]) by gabe.freedesktop.org (Postfix) with ESMTPS id 844E910ED27; Wed, 29 Apr 2026 04:10:47 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=br4K8JFxP5SHGcGQ7idSG7QHDxVu8IFa3xGE5uop3UOmJxbDdeAUNIxFN6elxRnYStnA74jIy9RcrH3rHEVYLJG0VhoU+ikGDEQvD6Gvj4cqvhWUpxN5+I9QXth/vPkmGDFVzPymhl9ENPk4rOBdxNxgwA6Td7XnahfuXbM+vFAL1TLXOXzAw18RQM0pRIuMTmK07KATUMs92TPZ7sjqS1CA9CdEanidLm2l+MubXrzLjn20PKM193GEZA4p6pu8/NG5yR3GjSBvUa+hoKvHgppZw2dNhp6GJqGztPWraRjJrA6X55WBnO3JxWO8U4HLXFB10Jxv15/aFsjf6mtwvw== 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=4+yToM0AwG4Xc8k15YUIeL0/DzcSz0SIRiF/gQAEo+M=; b=Tk8P3pQ1e7eXnZ10F3zP/RJCGmSEWJNQXdYhoEPa8th99U9ItB6eW4vmzRkLAi0Km+BpxI89PY12faGdXOqCc3N5S+oS9Fk3Q30KClSEM92aALTWE3IYKI3us/Yy9MG8AiB+2az7RAtpolj3kvJJMpS3tgBXdT5GIFQ3eCrr087+sgH/04I67oiDkiFc13iZrT6mI4Me11sGACVykMc5YIeJFsx7fFGLFhHoI/YZ5od3Mdm4ACpko/Ice+jd6DWi8Lm4+MLD58zk0mT64hdBK7EOxIi1hJvNpr+ybCcMKzdeRZdNUHs4+9iM2JxR0v3DyWZ32kTo8HcHwLxUQxdiAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=ffwll.ch 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=4+yToM0AwG4Xc8k15YUIeL0/DzcSz0SIRiF/gQAEo+M=; b=YDlt/v/ioNvq+VObt8LbG5xzIuHCia+XKNCKigqjya5rqH4P6sP8kXf2oRAyMD5v9TY4/VCqxjZbQBZxZfIUjPI77N01Bp4aSsy7UatVrFPQu7F/mbvTuAN2qCZJnCVBSdVgCkPEWOERJCum7npcdZqLeekI5IWp3q2nzjBqvOk= Received: from SA9P223CA0027.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::32) by DM4PR12MB5985.namprd12.prod.outlook.com (2603:10b6:8:68::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9870.18; Wed, 29 Apr 2026 04:10:41 +0000 Received: from SN1PEPF00026367.namprd02.prod.outlook.com (2603:10b6:806:26:cafe::36) by SA9P223CA0027.outlook.office365.com (2603:10b6:806:26::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9846.28 via Frontend Transport; Wed, 29 Apr 2026 04:10:41 +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 SN1PEPF00026367.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.18 via Frontend Transport; Wed, 29 Apr 2026 04:10:41 +0000 Received: from Satlexmb09.amd.com (10.181.42.218) 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.17; Tue, 28 Apr 2026 23:10:35 -0500 Received: from honglei-remote.amd.com (10.180.168.240) by satlexmb09.amd.com (10.181.42.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 28 Apr 2026 21:06:51 -0700 From: Honglei Huang To: , , , , , , , , , , , , , , , CC: , , Subject: [RFC V4 01/12] drm/amdgpu: define SVM UAPI for GPU shared virtual memory Date: Wed, 29 Apr 2026 12:06:17 +0800 Message-ID: <20260429040628.853079-2-honglei1.huang@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260429040628.853079-1-honglei1.huang@amd.com> References: <20260429040628.853079-1-honglei1.huang@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb09.amd.com (10.181.42.218) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026367:EE_|DM4PR12MB5985:EE_ X-MS-Office365-Filtering-Correlation-Id: 15195ff2-8e0f-4d62-15ef-08dea5a5473d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700016|1800799024|82310400026|56012099003|22082099003|18002099003|921020; X-Microsoft-Antispam-Message-Info: bZ3U3wevtt3m7+kG3K1BjU3JFwCqdo9TrVN33HsB3vl71V4JFBfVyf8QCOwu3lAa1GWwJypfT25IDLGc5AM4zwAKB7O1/FqAxnKTc5ydgPL77Bh/vwWp+dzea66T1rmKhyF1NXdM1PuxHuuKNa0grL+uGLa+78Agu5YHgINzP0uYStDnkfMJR6ndddqFqoUeyqYIwWUbFasivYDykcGQGgbxXnrFV9Mc3PwIhKK2w9MUfirqF+vNo7M+WF4WW6SBHd0OW2PRNfyLapCt+oYE2mqWQDg5zIFs4v8a4I8+G4Hmo6GKHY88566FBOfBG3Grbi84r+QcpXWSrqApbpbyPRjE5c6zf/Jd2bKVtECpv3DOAEjTap/r8na2SjfWLQEHBshJC3sDOKpvy1Xx1lU4lxyN/rxx8GQq6G2ckKTRm27YTAvTDNuMgwJtHVwGZtg2QAq8iI999YwtGLedoWJ5sB0UiLLKcNxHLzz7w55+EskiyOMeYq5DwsmZ0ELMT9N5YASnSwEZUkADhSePvXTSwHn27QrT2T7iDpYmKyVS/rBy/jMo39IlExM+tNXap6tWESqt173IpcwKbZvQNhp2spbmtRlbsK/scWvnHS9PVjH+cSIX9OUMhv54bR1KCdV4Onus7Ohz9Kg+J4UhSxhHqBcj6ig0ygZTDV4I/1CThIx7Czy8ODdQqplDWItj5HZGYCAibL27hsKsHUJxT8CnOm1ExRsB2vao2md2Vub7Y0lJt9gqygXxyIsS0/Uh86U3KLBST/FuG/vUaX2tby6XX0nbl+uZ0WKLyViwayzmF+gci+IwAfY3CpFrsBDFTaEp 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)(376014)(36860700016)(1800799024)(82310400026)(56012099003)(22082099003)(18002099003)(921020); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0U5/485IxGipys2IpF8BKdUi/z65S7LwK/NypuMrfinmgxbqlmXkAcLRGw+7WA0KXKXTqZl0twTbPFk6GYX/2t0T0vP/VKXiWivBPBbo2r9IV4iECIMus41+uXwt9oDKOk66feXzx5i9+DlJhNpjGy9fnY3NGla1JYZhe+pUPjwDjFFNIt38sUbZyHcwc9PwQ+5PGEphy6RbuTKvo7EqeEb2SBnWPg41sTJN+RuSy/dvHjI5MlVOtv+TLO0myP+CWDBS8ylWBkuGSMqHZVyAJnNAEhNtkI/dylLpJPWh2tX4tMwAFMeAAs+4Tsm653vN1Ep4DpwKSzP/7adD9XP+RS/4wIgLlsAYVpOFX6CLxfG7afTyY9GyRzFQO1xzoEg/3BMrKrEnt02ZnGgfp/ww3ww3LyFgH0lo2RS8dQlTQJVbYrNp0nlGLdBVGcXk08Es X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2026 04:10:41.5731 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 15195ff2-8e0f-4d62-15ef-08dea5a5473d 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: SN1PEPF00026367.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5985 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: Honglei Huang Add UAPI definitions: ioctl DRM_AMDGPU_GEM_SVM, attribute flags (AMDGPU_SVM_FLAG_*), operations SET_ATTR/GET_ATTR, attribute types, location constants, and payload structs. Signed-off-by: Honglei Huang --- include/uapi/drm/amdgpu_drm.h | 106 ++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/include/uapi/drm/amdgpu_drm.h b/include/uapi/drm/amdgpu_drm.h index 9f3090db2..62fc519dc 100644 --- a/include/uapi/drm/amdgpu_drm.h +++ b/include/uapi/drm/amdgpu_drm.h @@ -58,6 +58,7 @@ extern "C" { #define DRM_AMDGPU_USERQ_SIGNAL 0x17 #define DRM_AMDGPU_USERQ_WAIT 0x18 #define DRM_AMDGPU_GEM_LIST_HANDLES 0x19 +#define DRM_AMDGPU_GEM_SVM 0x1a #define DRM_IOCTL_AMDGPU_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_CREATE, union drm_amdgpu_gem_create) #define DRM_IOCTL_AMDGPU_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_MMAP, union drm_amdgpu_gem_mmap) @@ -79,6 +80,7 @@ extern "C" { #define DRM_IOCTL_AMDGPU_USERQ_SIGNAL DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_SIGNAL, struct drm_amdgpu_userq_signal) #define DRM_IOCTL_AMDGPU_USERQ_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_USERQ_WAIT, struct drm_amdgpu_userq_wait) #define DRM_IOCTL_AMDGPU_GEM_LIST_HANDLES DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_LIST_HANDLES, struct drm_amdgpu_gem_list_handles) +#define DRM_IOCTL_AMDGPU_GEM_SVM DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_SVM, struct drm_amdgpu_gem_svm) /** * DOC: memory domains @@ -1673,6 +1675,110 @@ struct drm_amdgpu_info_uq_metadata { #define AMDGPU_FAMILY_GC_11_5_4 154 /* GC 11.5.4 */ #define AMDGPU_FAMILY_GC_12_0_0 152 /* GC 12.0.0 */ +/** + * enum amdgpu_ioctl_svm_op - operation selector for DRM_IOCTL_AMDGPU_GEM_SVM. + * @AMDGPU_SVM_OP_SET_ATTR: apply the attributes in @attrs_ptr to the VA range. + * @AMDGPU_SVM_OP_GET_ATTR: read back the current value of each attribute + * listed in @attrs_ptr for the given VA range. + */ +enum amdgpu_ioctl_svm_op { + AMDGPU_SVM_OP_SET_ATTR = 0, + AMDGPU_SVM_OP_GET_ATTR = 1, +}; + +/** + * enum amdgpu_ioctl_svm_access - values for AMDGPU_SVM_ATTR_ACCESS. + * @AMDGPU_SVM_ACCESS_INACCESSIBLE: GPU must not access the range; any access + * is a fault. + * @AMDGPU_SVM_ACCESS_IN_PLACE: GPU may access the range only at its + * current backing store; the driver will + * never migrate pages to local VRAM. + * @AMDGPU_SVM_ACCESS_ALLOW_MIGRATE: GPU may access the range and the driver + * is allowed (but not required) to migrate + * pages between system memory and local + * VRAM to satisfy the preferred/prefetch + * location. + */ +enum amdgpu_ioctl_svm_access { + AMDGPU_SVM_ACCESS_INACCESSIBLE = 0, + AMDGPU_SVM_ACCESS_IN_PLACE = 1, + AMDGPU_SVM_ACCESS_ALLOW_MIGRATE = 2, +}; + +/** + * enum amdgpu_svm_location - values for AMDGPU_SVM_ATTR_PREFERRED_LOC / + * AMDGPU_SVM_ATTR_PREFETCH_LOC. + * @AMDGPU_SVM_LOCATION_SYSMEM: back the range with system memory. + * @AMDGPU_SVM_LOCATION_UNDEFINED: no preference; the driver chooses. + */ +enum amdgpu_ioctl_svm_location { + AMDGPU_SVM_LOCATION_SYSMEM = 0, + AMDGPU_SVM_LOCATION_UNDEFINED = 0xffffffffU, +}; + +/** + * enum amdgpu_ioctl_svm_attr_type - attribute selector for + * &drm_amdgpu_svm_attribute.type. + * + * @AMDGPU_SVM_ATTR_PREFERRED_LOC: Preferred backing location for the range. + * Value is one of &enum amdgpu_ioctl_svm_location. + * @AMDGPU_SVM_ATTR_PREFETCH_LOC: Prefetch target for the range. Value is + * one of &enum amdgpu_ioctl_svm_location. + * @AMDGPU_SVM_ATTR_ACCESS: GPU access policy for the range. Value is one + * of &enum amdgpu_ioctl_svm_access. + * @AMDGPU_SVM_ATTR_GRANULARITY: log2 of the migration granularity in pages. + * @AMDGPU_SVM_ATTR_HOST_ACCESS: Guarantee host access to memory. + * @AMDGPU_SVM_ATTR_COHERENT: Fine-grained coherency between all devices + * with access. + * @AMDGPU_SVM_ATTR_EXT_COHERENT: Fine-grained coherency between all devices + * using device-scope atomics. + * @AMDGPU_SVM_ATTR_HIVE_LOCAL: Use any GPU in the same XGMI hive as the + * preferred device. + * @AMDGPU_SVM_ATTR_GPU_RO: GPUs only read the range, allowing replication. + * @AMDGPU_SVM_ATTR_GPU_EXEC: Allow execution on GPU. + * @AMDGPU_SVM_ATTR_GPU_READ_MOSTLY: GPUs mostly read the range; may allow + * optimizations similar to GPU_RO, but writes still fault. + * @AMDGPU_SVM_ATTR_GPU_ALWAYS_MAPPED: Keep the GPU memory mapping always + * valid. + */ +enum amdgpu_ioctl_svm_attr_type { + AMDGPU_SVM_ATTR_PREFERRED_LOC = 0, + AMDGPU_SVM_ATTR_PREFETCH_LOC = 1, + AMDGPU_SVM_ATTR_ACCESS = 2, + AMDGPU_SVM_ATTR_GRANULARITY = 3, + /* Boolean attributes below: value must be 0 or 1. */ + AMDGPU_SVM_ATTR_HOST_ACCESS = 4, + AMDGPU_SVM_ATTR_COHERENT = 5, + AMDGPU_SVM_ATTR_EXT_COHERENT = 6, + AMDGPU_SVM_ATTR_HIVE_LOCAL = 7, + AMDGPU_SVM_ATTR_GPU_RO = 8, + AMDGPU_SVM_ATTR_GPU_EXEC = 9, + AMDGPU_SVM_ATTR_GPU_READ_MOSTLY = 10, + AMDGPU_SVM_ATTR_GPU_ALWAYS_MAPPED = 11, +}; + +/* One (type, value) pair carried by DRM_IOCTL_AMDGPU_GEM_SVM. */ +struct drm_amdgpu_svm_attribute { + /** AMDGPU_SVM_ATTR_* */ + __u32 type; + /** Attribute value; interpretation depends on @type */ + __u32 value; +}; + +/* Argument for DRM_IOCTL_AMDGPU_GEM_SVM. */ +struct drm_amdgpu_gem_svm { + /** Start of the virtual address range */ + __u64 start_addr; + /** Size of the range in bytes */ + __u64 size; + /** AMDGPU_SVM_OP_* */ + __u32 operation; + /** Number of struct drm_amdgpu_svm_attribute entries in @attrs_ptr */ + __u32 nattr; + /** User pointer to an array of @nattr struct drm_amdgpu_svm_attribute */ + __u64 attrs_ptr; +}; + #if defined(__cplusplus) } #endif -- 2.34.1