From nobody Sun Feb 8 22:21:19 2026 Received: from DM5PR21CU001.outbound.protection.outlook.com (mail-centralusazon11011047.outbound.protection.outlook.com [52.101.62.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5C80299922 for ; Thu, 15 Jan 2026 07:59:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.62.47 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768463964; cv=fail; b=l3LxxRov3ap1YvWQ2KIjgrAHJ25oPvlB1aoEZ2mpk4f6REbUKVJ1zatuhz6Waq6aqg6ygSuotaszc92lx9j7yaEztsWfX7XCarTjS00pxy8LZmdA7no2Av9kp7mOQ7rL7k6izQJKSi/PEA8v3uz5AkQDk0gDs82bQ+CjwwM5Mbg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768463964; c=relaxed/simple; bh=wLp83sv159Hg+9oxvdlfvrAMiV2eUvTeOCwNwZ299yY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GBqUkuYhCnNtXenPs0paRfokK4kiImMt0rXnuboYjwS1O6kMQYNH7kNgx7izuqYxvfIzzSZe7mCmB7RhnhILzI2hfu3xuv1cKcMtua5dH+O8jDTTUKr5/3gumQUPZIbSr5qMD7NKv3Q4VvpS4fSrgdGFGGkgsbQKbWNZOB7ozu0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=2BG+vRc2; arc=fail smtp.client-ip=52.101.62.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="2BG+vRc2" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DnOo37jWHeKCTHWxwsyRfH3xM++sZ4x+xBof4HvETxaK57KkNnHWN/IDdVQRPrBVWI6yb6O702x+1zqFkizSAt3QuUPkQh8YfxdA+ChVQ73ylKZgBJnoJj+fq8bB92xInfWTMN+vCfGGWa5SjxXjwYM0pvqeVywaE2pOK67fdZ/Ddnqm/mgChqMY4+kemBhprC4MUFhMqum3ndFHiTvf4EImk+Q2lvfHV5j+N49SQ7hbQb5WV6dbnuvZQrU4QKSHX8w2/cHWnJ0QW0JnEwtWVt8pVM8bIPBxYMcveH62yI0i6GYugbbDWWwNMHlT/z+3hl/0qBP5uNVIgmoth6cTZw== 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=vIoHtz/iYAtbodNNogBL9NxXmDhehLIpLmN/K874AaE=; b=liDkQna+jvBHTWmfyJEtRLpLd6JDiHWUllHLzHbZmwymESvjhsuDYw4MpicphH19UwF9YTx9wbsLVMhGbNrRsqxT3xPSpOgyg+N4PrmoHx2MC2s2g0rZXnYlRGe4BfH6YC3Wf5R5MHsbeXtssyiElAd7NGIEE/c3XxDJ9ln1adke0ZqX7lfR++KJo34ifprFcrBpH7sdtA+KxaierLd3VV1VaUs/qhfv2A/+MuVkBWZsSENmODDmmQysyg99gMdYguTu+NT2RnePIPbymfun1CTKes0R/gck+GWhiSMPm96/jrnAUEVSafzEDXDEW6s0fg4QjCpxqmbuUXayVUNOqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=vIoHtz/iYAtbodNNogBL9NxXmDhehLIpLmN/K874AaE=; b=2BG+vRc2u1/2V8U0KzDx1i5ny6Je46DF27lWh24ZAkE+aS4qWzwpplVj5stWYt4vaNwq+Xcq4wVY6KxoQ40B+cbBuprFKSrS8mwkygswsPRM5bydJxglD12ys6I9ti+LBIi+vEZZ7dZEyLzzdUkjLXjw9TTzCHQ6M/r+T7wlZm8= Received: from MN2PR01CA0064.prod.exchangelabs.com (2603:10b6:208:23f::33) by SN7PR12MB7321.namprd12.prod.outlook.com (2603:10b6:806:298::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9499.7; Thu, 15 Jan 2026 07:59:18 +0000 Received: from MN1PEPF0000F0E5.namprd04.prod.outlook.com (2603:10b6:208:23f:cafe::6f) by MN2PR01CA0064.outlook.office365.com (2603:10b6:208:23f::33) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Thu, 15 Jan 2026 07:59:13 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by MN1PEPF0000F0E5.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Thu, 15 Jan 2026 07:59:18 +0000 Received: from honglei-remote.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 15 Jan 2026 01:59:14 -0600 From: Honglei Huang To: David Airlie , Gerd Hoffmann , Dmitry Osipenko , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , CC: Gurchetan Singh , , Chia-I Wu , , , , Honglei Huang Subject: [PATCH v4 1/5] drm/virtio-gpu: Add VIRTIO_GPU_CAPSET_ROCM capability Date: Thu, 15 Jan 2026 15:58:47 +0800 Message-ID: <20260115075851.173318-2-honglei1.huang@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260115075851.173318-1-honglei1.huang@amd.com> References: <20260115075851.173318-1-honglei1.huang@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E5:EE_|SN7PR12MB7321:EE_ X-MS-Office365-Filtering-Correlation-Id: 34761198-7311-4e31-128a-08de540bfc17 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|7416014|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?EoyCFRgSnQerll87b/mY8koL07riuw/n4cACGdxjHZmXf1wp+wqnsui1SwH7?= =?us-ascii?Q?ZBim7TxYz11cn/4rwRfq8he7EW2XjWEdylTwbZ5YNWK+nXtFPJt5oc7WSmkb?= =?us-ascii?Q?cpPMvg+dlo48c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?us-ascii?Q?WXdYWDLlc5WlT8GEIMEOUblfDubabRYhV7yUos9WYABQWmYCMZaA+a0aneNt?= =?us-ascii?Q?NV9z0VDHIGlRuTxB79HR93qbI0InxO3aK6wXh5me+PwUVcjIAcec7+dsq4S5?= =?us-ascii?Q?7Mmhru971gqOeUf9wh26W+ylA0VWwdtX77fDRFfi22WRdwiXi6G77YYDRUju?= =?us-ascii?Q?SESq883YbzDLvbZ/Pet9BuXGWdt9e9++uxFG95+3XWNQuQK8jzz8Cz1wD2A4?= =?us-ascii?Q?YWnAThKK4yZha8FfAifO6CZMNyHL67KbW5P3D+/7MT6mQnHaSdeY71ASrcSI?= =?us-ascii?Q?l3LNf+lt4uQ+3xkDvDizJEhrgoS6PGi7FN8Fv5ERiNxf0ND8OTSSe0cEVKP8?= =?us-ascii?Q?xH+CiapEMGS561kQ8oiacSOyL12W0HNl83Eas/D4WmcUTv3cD4LM1jk9aViy?= =?us-ascii?Q?7AXklYqgJPnGyAfRsZc1ALUsz3tLPI7gplegqYv3gyJ82hThU5EM3KqfuxdW?= =?us-ascii?Q?t3ZZzXh4afIaRQvPrqbeyoGVKp5MxRWPE6tmo3BS4YHSEhg2rqlYNIbsNz8x?= =?us-ascii?Q?eKGuSNH0hehldpqFQlc/5LOrWnfN00wb+8Djkr7XvbfmWahE+huhdPcfexWg?= =?us-ascii?Q?ZCT6liCyKgfhuV8jLda6C38ddkpyFwJoQc14H68nisNjY4WfIPDU5eq8KTpe?= =?us-ascii?Q?GGhXHA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(36860700013)(82310400026)(7416014)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2026 07:59:18.3490 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34761198-7311-4e31-128a-08de540bfc17 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7321 Content-Type: text/plain; charset="utf-8" From: Honglei Huang Add a new GPU capability set VIRTIO_GPU_CAPSET_ROCM to support ROCm compute workloads in virtualized environments. ROCm (Radeon Open Compute) is AMD's open-source software platform for GPU compute and HPC workloads. Signed-off-by: Honglei Huang --- include/uapi/linux/virtio_gpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gp= u.h index be109777d..fbd1838d6 100644 --- a/include/uapi/linux/virtio_gpu.h +++ b/include/uapi/linux/virtio_gpu.h @@ -313,6 +313,7 @@ struct virtio_gpu_cmd_submit { #define VIRTIO_GPU_CAPSET_VENUS 4 #define VIRTIO_GPU_CAPSET_CROSS_DOMAIN 5 #define VIRTIO_GPU_CAPSET_DRM 6 +#define VIRTIO_GPU_CAPSET_ROCM 8 =20 /* VIRTIO_GPU_CMD_GET_CAPSET_INFO */ struct virtio_gpu_get_capset_info { --=20 2.34.1 From nobody Sun Feb 8 22:21:19 2026 Received: from BL2PR02CU003.outbound.protection.outlook.com (mail-eastusazon11011011.outbound.protection.outlook.com [52.101.52.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45ED232BF22 for ; Thu, 15 Jan 2026 07:59:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.52.11 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768463968; cv=fail; b=rUOcdoaaQ4jM8QcKmL20gtI5fsJyD4pYTcrhFnkZx/3ab4+6z29XDzH5pvlnkSLOHJIN5KQZQYEz/ytoghDG+bJONFNWxpyuauUK47TTOmq+FK8kVaXv+E3BMW9zcmnq+5GE7lXZbfxB2WIJz99CMzXNAwKs7gAq7D53OWHVGS4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768463968; c=relaxed/simple; bh=eIZNbHKzdWe5ixL+DGImky6pURvMqDj+uJpbwLQh45o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OpQVRTguk5h9puwpKAgJ1G1TMhhJA4bR70h/BchiJDT4PbYCDKNtF3UApNSkumqk4YaCRu52pQFO76J/V4dVCYPB9h3JQaOogOdjqmYHLmTDDwXifjckjXDnxyZm7WWdU16KEu3+hK3hfJ72r+kVGKLikva4rCqhui4R4DJNvvg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=SvmY4m8V; arc=fail smtp.client-ip=52.101.52.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="SvmY4m8V" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ulserG/Dj+g4OjSpblf1Gwgojk/DnTyB5wYdH1RqJpCS4JgQ98L6XaRr3D3/p+W+QThokANr4yngqXuZFM2REA/bD4FteuYFfZG9t+f7aRa5mMEMEUAQQRxTyNi0I9jW6bVcJXmN8C1mZ/Zbnf2qb3IsEpg4wzFv0CZRnMRQpVJhJ4JgRIrA4z8Dtk2rQC/+zsX8FMEufRfz47Zz6RuFFiYuIVZb9nhdRzq9swEUbM5YeoxW9S0OlBHwWXUBEy/lsnApVv9stxe6kge3jaoAJqV2xDtdTJoyiHJeKRR1RHG0ZeW/58UxfKK+RPHLvTCXuM7CzvTcifbEVmPFQQ7d+A== 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=/dwV2w9sFE0emkS7L6VUev6yvDCBIAm6qFnKR9wh+kI=; b=K3VogNOCSx0WtCO/6o2FBmNoUjYgxFNd+3vZwOPjtfUuCS7megZodlzFWIdRhnikePfxjC53a7Tv4XmF2riUsG1gz9lJr4JPJ66gOz1NvluReXb77qsmrEu3Y8YlMfzI5baLVm0z1FqBSnWD3K2EC0nmnh0zvjDls6+V24eBNkf01xT/ReG5yHy3gTvD8xbV6xyafr7zTosYECdmFKI+dXnL8x+TW+qECOboLsV0QuyxiwymZ1Maxs/8gQjYvuq3t/t/5Y89FzVWn4xt+pNLUbEOS0g2c1qeRy2+7DPg6JVh1CQ+FTA4+jmG2xBpV1I3EWVnlm+wIil8U5CNGp+1pg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=/dwV2w9sFE0emkS7L6VUev6yvDCBIAm6qFnKR9wh+kI=; b=SvmY4m8VYUEA7McD3mhGmeIhgIfSRlpOT4na9Nft+jC2JPsqaS1QsH8o4jTXVDrENFU767G4RyVFfaaSud6f29iFMJD5eKVddbyxNzfV7iBrKFG3GVtM0TPjaMR0szcMyVmuhmR8Mc/S5BhfO+MjxMEBUSVYU+PdAfjgWZocNcE= Received: from IA4P221CA0011.NAMP221.PROD.OUTLOOK.COM (2603:10b6:208:559::14) by SA1PR12MB8644.namprd12.prod.outlook.com (2603:10b6:806:384::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.4; Thu, 15 Jan 2026 07:59:22 +0000 Received: from MN1PEPF0000F0E4.namprd04.prod.outlook.com (2603:10b6:208:559:cafe::df) by IA4P221CA0011.outlook.office365.com (2603:10b6:208:559::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.6 via Frontend Transport; Thu, 15 Jan 2026 07:59:25 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by MN1PEPF0000F0E4.mail.protection.outlook.com (10.167.242.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Thu, 15 Jan 2026 07:59:21 +0000 Received: from honglei-remote.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 15 Jan 2026 01:59:18 -0600 From: Honglei Huang To: David Airlie , Gerd Hoffmann , Dmitry Osipenko , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , CC: Gurchetan Singh , , Chia-I Wu , , , , Honglei Huang Subject: [PATCH v4 2/5] virtio-gpu api: add blob userptr resource Date: Thu, 15 Jan 2026 15:58:48 +0800 Message-ID: <20260115075851.173318-3-honglei1.huang@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260115075851.173318-1-honglei1.huang@amd.com> References: <20260115075851.173318-1-honglei1.huang@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E4:EE_|SA1PR12MB8644:EE_ X-MS-Office365-Filtering-Correlation-Id: a85baf6d-b245-4378-4791-08de540bfe42 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|36860700013|1800799024|7416014|376014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Y/BtdjgUWk9aAysrhKbT5c8mPxB2p5HzokzRsiiJZxQGcEyzSnn5ZlxhH3kQ?= =?us-ascii?Q?c3vonKg+QQmnpw+5XVjD6kLYsyQcUpT1Ku8IaJ5qNH3Xu4pxoT+5s+vI2KSQ?= =?us-ascii?Q?0GQWlOJECcQti9tLIWj6XBqECiaABG8IHGM9mLrFgSkGDd2fG4NS+IGSXaGX?= =?us-ascii?Q?FEHd73KfUbjxQdhvVtmBmRiDaDjTAsrBb/XRVhIlQSCkoM3mWExxhdQwr0OJ?= =?us-ascii?Q?MBK5hgIq6pNvpXqDK/3K9PF/CgObCYwqfZVU4BTZABkd+tFKDjQKOTQHcVeJ?= =?us-ascii?Q?I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W/3pBg?= =?us-ascii?Q?oWRHrcRLpW1Z4Q5md6lKPkcFzO3F9UH1kRSG0PJV7hjensl1lBign/7JtjIW?= =?us-ascii?Q?HTZIebwGZSm9Ho8tD2P9U6Hy/8GD5LO3/DDPuEF8DSgvvfS999SIj2AoKSax?= =?us-ascii?Q?HSWsq8+ooIXx1sQOWBSrUSUCi4tOeOcU5V8rWVMEdvcBDyb+hMyi/lcphcBa?= =?us-ascii?Q?fQLg7Nlgm0Xw3qUSotOVTAirgc8P66r3uik0idjSEVUBSbC2P4R1xzKfxGnc?= =?us-ascii?Q?pUksOjQxBSU0TsA403Mh+Ow2ZDJXYqQI3IgIybVStj2rmarE/bSgjFmNJDh+?= =?us-ascii?Q?ii4ebDm95AApLzpW+le1tcUVOksmd1qr+9Xma6Y4/y6B663TPsMewDSVabED?= =?us-ascii?Q?+44Zmia18K/Q2baRaUNOQ2fqSlBVpCZ7jhww/ZiDiF3GWXtyRP8sAwRn0adH?= =?us-ascii?Q?9mN90d1ZhS4elSVXCJmfwXTnweKqJ1pcDe8wyauGPpnuJw0BMPWf0gnbLhkP?= =?us-ascii?Q?BmEOcw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(82310400026)(36860700013)(1800799024)(7416014)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2026 07:59:21.9889 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a85baf6d-b245-4378-4791-08de540bfe42 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8644 Content-Type: text/plain; charset="utf-8" From: Honglei Huang Add a new resource for blob resource, called userptr, used for let host access guest user space memory, to acquire buffer based userptr feature in virtio GPU. - New flag VIRTIO_GPU_BLOB_FLAG_USE_USERPTR used in blob create to indicate the blob create ioctl is used for create a userptr blob resource. - New resource type VIRTIO_GPU_F_RESOURCE_USERPTR is for feature check and probe. Signed-off-by: Honglei Huang --- include/uapi/linux/virtio_gpu.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gp= u.h index fbd1838d6..bf2d5f137 100644 --- a/include/uapi/linux/virtio_gpu.h +++ b/include/uapi/linux/virtio_gpu.h @@ -65,6 +65,11 @@ */ #define VIRTIO_GPU_F_CONTEXT_INIT 4 =20 +/* + * VIRTGPU_BLOB_FLAG_USE_USERPTR + */ +#define VIRTIO_GPU_F_RESOURCE_USERPTR 5 + enum virtio_gpu_ctrl_type { VIRTIO_GPU_UNDEFINED =3D 0, =20 @@ -406,6 +411,7 @@ struct virtio_gpu_resource_create_blob { #define VIRTIO_GPU_BLOB_FLAG_USE_MAPPABLE 0x0001 #define VIRTIO_GPU_BLOB_FLAG_USE_SHAREABLE 0x0002 #define VIRTIO_GPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004 +#define VIRTIO_GPU_BLOB_FLAG_USE_USERPTR 0x0008 /* zero is invalid blob mem */ __le32 blob_mem; __le32 blob_flags; --=20 2.34.1 From nobody Sun Feb 8 22:21:19 2026 Received: from MW6PR02CU001.outbound.protection.outlook.com (mail-westus2azon11012002.outbound.protection.outlook.com [52.101.48.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38A262BDC0C for ; Thu, 15 Jan 2026 07:59:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.48.2 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768463974; cv=fail; b=YALCMdx6ProYDEKzgqXrkNtUN4m3ci2ACuGcBoEce1OtMf0QX786LOM5dI4gDtmeLb+jQ6wnBtcsVQux4XbKVnVlzCwS2U/X8BcqclNUUVKf2uoKzbKee3ZQTbunbXlHwUgWLC8wPM1OvVDKvGoYdq4XWE16722wkTFf6O/bbpk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768463974; c=relaxed/simple; bh=E5aWJSLQDioOYHxZPzTzvzLeJ/BbXOxNilKQ6XEBrmU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=q3x9MXh5fKCk20P9fHJXSlQWcF+TgM4fEV5aUojuh7fL/dakSAyjnG1G7z2dMUK3+SwvUgU+QZfGY9mCmTLkv1WvGRza9X8NwQOph2akUaGR4dDXXdResd2wr5IC8tRLKRIhDqwfg23pSnvr+32uIz8LmlqOgMhsxaI09ODzTBk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=0mrsvXK6; arc=fail smtp.client-ip=52.101.48.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="0mrsvXK6" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=hUfGut88S18oXfyNACt1zcxvHXIYqNNVxTSFjQYZ2701C6NG88dsRwMe+eRt67MK1EjPq6Gb2HiZiYMLkI83u8fenTjVRmwyVBytxHh6YvqLPtw5VhTYTdPy/U9TLg2iGETBcfmu5wY1O2/y1m/vlM/Wzpv3mvHB0+u63hHv7+m168c3ahh7apHB87Z9QSvkzAIrv1xb+0uSgJ9o8y2nxQ7r4BjVppfx4OSgFWvCGSUPerCzdWWIa9bhtUoviftVBjHEKOwVS021D/pR9xjBdmT10VevXn9R32fxKAXUTjd5Rzfv8vHu8JRF9cXWSO3qJWXSuuQxR6PTLpp8jwI80A== 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=wqnVLMNuY1jYUU8e4cyzf+geGe1unRRVP9RYvnLkKW8=; b=lnmjqs291HYzA/iKJiIqmk8G/0g0dDfR1KGFUo0pok44MbEKHxxQUAlIGfNAQ3WHWItIjW9xWgxLtk3jXBeog9IAfcjx9gHLFFyWrBx9vI6dOf58LDC3jY/mVZBGMMMVQZoaYonndCl2po5o4FKWkl8QnnKMquou29gztjj49EujwcEautDW7xSKiDCG2mzgR+TevursG+AbeDoLm/T1qR9HR5ePnSjcAHNPnEPKyh+vEC2CYIOSKT7FAlDkgVXghlyv9Ah036lBvXhD2qfJoJsjYMm80siCs9FYoeFNrb+ghkkhg+TUJX2wxiQgRBzc7ckV+TFuBp1Id4s5P1FnFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=wqnVLMNuY1jYUU8e4cyzf+geGe1unRRVP9RYvnLkKW8=; b=0mrsvXK6G1N8usFjq2OYXnrcwxUPaePFtv/jYHDquLdUcaIy2XkccK74FPZ9fswntIxMD3SylgU48aHu/wy3zDJWEqnQ9AfmS2iKYQ5jVToQ7ZK59ItKNcNBRca0lrxgz7iOUpVYFb9ydMKjwtb7lk4p2DygoYpTBxw9VejqjlU= Received: from BL1PR13CA0100.namprd13.prod.outlook.com (2603:10b6:208:2b9::15) by CY3PR12MB9580.namprd12.prod.outlook.com (2603:10b6:930:10a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.6; Thu, 15 Jan 2026 07:59:26 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:208:2b9:cafe::ed) by BL1PR13CA0100.outlook.office365.com (2603:10b6:208:2b9::15) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.2 via Frontend Transport; Thu, 15 Jan 2026 07:59:23 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by MN1PEPF0000F0E2.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Thu, 15 Jan 2026 07:59:25 +0000 Received: from honglei-remote.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 15 Jan 2026 01:59:21 -0600 From: Honglei Huang To: David Airlie , Gerd Hoffmann , Dmitry Osipenko , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , CC: Gurchetan Singh , , Chia-I Wu , , , , Honglei Huang Subject: [PATCH v4 3/5] drm/virtgpu api: add blob userptr resource Date: Thu, 15 Jan 2026 15:58:49 +0800 Message-ID: <20260115075851.173318-4-honglei1.huang@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260115075851.173318-1-honglei1.huang@amd.com> References: <20260115075851.173318-1-honglei1.huang@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E2:EE_|CY3PR12MB9580:EE_ X-MS-Office365-Filtering-Correlation-Id: f24fe14d-9587-437c-1587-08de540c005d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|7416014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?WGFGd8dLV/lMhX1ZuqrW/cJn82BdzBcO3qmr/egtU04nkSRs7dS6ag+lKF7N?= =?us-ascii?Q?7rMHTzu+883IE4QhlvMfKmLsHzF6WjMeTs2dolw4OlySfSBCOvrk08mosdht?= =?us-ascii?Q?JLM22wAeWLGlv3EYSbQ3G4HwjNFzQJQ2SyKCIPPLMbhsXSpgACLPtMREhoXi?= =?us-ascii?Q?JEBwm0TOtkRvx4wpzNDzC61uDNwJZu3jiCm5rD4Ypq/zRY43bfMeDqVi3EdM?= =?us-ascii?Q?86qutBgrInQmCM+hGyK0yc73XoEGFbXSsfZjamQltzjiHYTWkdGLTeC3q/AH?= =?us-ascii?Q?SjJJW6rqvJWyndzaetrqef2ViBnFhzvAi41grhgE0RTtaqHdNGBXYISGnulC?= =?us-ascii?Q?7WcAaJMHMji3cGgp4p2jZ8UDYQ/P2WGYo1Yffq3hjks/3ub+x53N1p/Dv7Sn?= =?us-ascii?Q?M1ApSot1iGu/5uIL3a4DDoWp0LuB8MSHj1o19U4Es2mrJm5wK1cxJZJSQ5pi?= =?us-ascii?Q?F2dqwu5A1zIJuQt4yooj5ZD68HNk68txR9+SrZh4LqunlQc4I/NNk5FThto9?= =?us-ascii?Q?hYn4t8dlartu5GBTzH71DQW0teV286c/gFVUmFHxdHUovOISnWvV2Bhrz9b3?= =?us-ascii?Q?XgPk95ig9PKsJ+38uQErw02kYNyOEQon5aB8Ihpv/IUu15APSS3rQzQSXIvK?= =?us-ascii?Q?cvhOVxIeWYAzYHOQk24W2N+SbrtVP+uWJIbMAK0rHhvVUGScGnpcF19yes2e?= =?us-ascii?Q?p+zjo2oVaibXD5ycuKxZ255kl4LI3jLf96qvkI7Hc04GfALtOfj85nuXKd39?= =?us-ascii?Q?b4yVZqWHrNlq0rjrQ4RKC6ow/frthW/AOotcQjBOeHmjiT/hj6TIWIiBH5mb?= =?us-ascii?Q?Eje0KykIOSQN9dLqTr/czmcMDk0vqJIDjmWGR1u58whEe7PtsVHY+uTx20vm?= =?us-ascii?Q?whANXCbVcNYZwFDZqXfNLjmdSU8eBcbm3JRMfe11q4JBARaJO2mW/8h/CLVv?= =?us-ascii?Q?uova8lknF95iAkOMJyNYUqeFqmSHZqRUu7Lpcq0Qz/J6VTATN5IhUO+m0nqb?= =?us-ascii?Q?ti0OOGQrju5yCfFoafwgXPEh84FzR0l83HcL6TECXccqkiCdahWXpjkixKw1?= =?us-ascii?Q?+4628zKw3QqY9Dd3TtY+/X0maMH9AfOACyswmvzeGMvh6bp9YMcyeIOaXU7I?= =?us-ascii?Q?43RtKuupwDC+k+1v3BrJPS37AJCDwUL4PStDcUX9M88I/iRegnCLiwOWLcTn?= =?us-ascii?Q?ftJnrJ9BvLYGLdWVSO842Jg5LxTAOvz4d5zXm4Kmp/LI5hZO/9IlPQCtxkpy?= =?us-ascii?Q?NZS4poCnEnk3YscE4BOE+IkS+GRv4FLyTuP/kGE+qulmmGSSh4VjaqsIp6QG?= =?us-ascii?Q?w8WVT68CfR0p/5qQEm6sqWDs1bScmFjj10PA+/Tj4dAnO8Z0/zgyDdDQX1t7?= =?us-ascii?Q?4hfspysA+3O0B0eiTGuYpPCN9cG3bYxw+3GXMrPccsG1QADewmAmAi2++0u1?= =?us-ascii?Q?XfyMSY/CvYIZ2ItkwEVs1s+wif8D12o8kK7muSLx6neCPu31VO54NKrd0qTA?= =?us-ascii?Q?8DyNfC1u3DHBw8ZcoVDPP6LiwVc/B9icpVw5VTgAJJYfAhN2EtKyPt0V10yF?= =?us-ascii?Q?C4oMOgOCd80vaCYljKAZRD4OYnZRpUsDzY5ktrIhTD/l0bFzOR/vRY5JxN5n?= =?us-ascii?Q?TA6bXQkiHWw9aRmfl4MdBOQcUB/44OVVwC93nKKDb0M0S0BymqV+E06fT3Vz?= =?us-ascii?Q?2WYXSg=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2026 07:59:25.5198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f24fe14d-9587-437c-1587-08de540c005d 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY3PR12MB9580 Content-Type: text/plain; charset="utf-8" From: Honglei Huang Extend the virtgpu UAPI to support userptr blob resources, enabling the host to directly access guest userspace memory without data copying. This is essential for compute workloads where memcpy overhead between host and guest is unacceptable. UAPI Changes: - Add VIRTGPU_BLOB_FLAG_USE_USERPTR flag to enable userptr mode - Add VIRTGPU_BLOB_FLAG_USERPTR_RDONLY flag for read-only access - Add 'userptr' field to drm_virtgpu_resource_create_blob structure to pass guest userspace virtual address The userptr field contains the guest userspace virtual address that will be pinned by the driver during resource creation and unpinned on destruction. The driver validates the address, pins the pages, and provides the physical addresses to the host via scatter-gather table. Signed-off-by: Honglei Huang --- include/uapi/drm/virtgpu_drm.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/uapi/drm/virtgpu_drm.h b/include/uapi/drm/virtgpu_drm.h index 9debb320c..fdae50e39 100644 --- a/include/uapi/drm/virtgpu_drm.h +++ b/include/uapi/drm/virtgpu_drm.h @@ -185,6 +185,8 @@ struct drm_virtgpu_resource_create_blob { #define VIRTGPU_BLOB_FLAG_USE_MAPPABLE 0x0001 #define VIRTGPU_BLOB_FLAG_USE_SHAREABLE 0x0002 #define VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE 0x0004 +#define VIRTGPU_BLOB_FLAG_USE_USERPTR 0x0008 +#define VIRTGPU_BLOB_FLAG_USERPTR_RDONLY 0x0010 /* zero is invalid blob_mem */ __u32 blob_mem; __u32 blob_flags; @@ -200,6 +202,13 @@ struct drm_virtgpu_resource_create_blob { __u32 cmd_size; __u64 cmd; __u64 blob_id; + + /* + * userptr: guest userspace memory address for VIRTGPU_BLOB_FLAG_USE_USER= PTR. + * Must be 0 if VIRTGPU_BLOB_FLAG_USE_USERPTR is not set. + * The driver will pin the user pages and allow the host to access them. + */ + __u64 userptr; }; =20 #define VIRTGPU_CONTEXT_PARAM_CAPSET_ID 0x0001 --=20 2.34.1 From nobody Sun Feb 8 22:21:19 2026 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012045.outbound.protection.outlook.com [52.101.43.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F3AA132C92E for ; Thu, 15 Jan 2026 07:59:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.45 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768463976; cv=fail; b=pWCKv814+neN8EDwwNJzFLm8Lzp7N+fQiK1dnoPyBRw6oLlj/HIXozXeHLWHEfLypWXRWZAVuTPEIFXKHmkcXJeHSYRdW0uEfzWk6H/UykblHShOeSb02/4rrjysIspw6Yj5k2xjad4hsUcrwpbiuAe3vVzq7U0bLpEzbkJu7hI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768463976; c=relaxed/simple; bh=JVr7MEBMImr7rtDAmmHLNHjW4yQYhFFCtbm2xkP+134=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=i/LYdSl/e8vY8iUlcwm8KOieuxMCabRRTBSYBISiJuxhkKxf1G67sNKY8roZTmdiUQWkfE0iBhV/FfES5TKiJleyP+7O6NMDUE7hV/AoSQGCv//pJiaIc5WlbcQOVunkYk3ET7F9F8JP74jWQKp5xNg1sOL+Z0ZeQnIBwoKdrFo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=AD6FQn+F; arc=fail smtp.client-ip=52.101.43.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AD6FQn+F" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GBVLJnxTDQmTKzssiWBPK+DPoxWzqumfvRB+IWNDVINIYPmnKiVobfHSgJRiNFlrY4UpN5AP2obUQ7i8f2tyjoXZCoX43zT6rJlLAw8T+e5MHknOq6EfC2jIXYTvGqv3GcWHgcj5Lpt048BABjWb6RrX4uAlsJJx+kSmO1qSd6N1O9Tu16kQLNAR5IKck0WUIDZOQ5hd5+PjWZ6HCsaunZePL3z/HMHP72rpTEuX4yJ5S+SpUPRqBka9cQtA3ban5QDR+dLLzKI9FGAhRQbF7q68CpmVEtCGKeR2InS8EUCvlXUrOqBrwbfTO4BUynVyGdJqiYr2odFe8BRUv7ELog== 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=1CrwIZeu2Ihd1KK2ix6wj5vBjQbiuLtY3VbPtWQ+r2E=; b=UgKryJuunpzvUISfyA5JVOtkII74Qtqs0lYlqG6PYXXp6A6yYHhMRcfQCaG05Fz4RdczpR9FUiFpd90GjVUX4HIumnBxmWfkgtOD2QTajfJXizJq1W9zCnPau90L+bPQUDEgdqOHXDj4guRRXfRfWYZrKvzNg56ttub9c4HDBFTB0un8ZlakhCGBPCRYKyRlnQwUrZoNEOkO2URVoc56fkccbHVu8lgaASlqmYODFB/V/WWNhB+Ysdjh+fGfvpk1vWsM3Oi0fNAymxEo43CA9ZC6Bi8TuXiwh1NSf0LLlShc7g4x0VpF2KkIDTit5ryEUQ0waALD/qTokTxleLo2+Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=1CrwIZeu2Ihd1KK2ix6wj5vBjQbiuLtY3VbPtWQ+r2E=; b=AD6FQn+FjUG/t1h9TtmEYyVI1boASb+GhnnCjwWzIixm0mwiy/bSdahkoUcU02rL185m7xCTDdPgzlTHg4Yrps6gozARJTBbKA8BD1Qj/S+jT+heWYRpNAuHwmJe0xwkQRtO1uHVsF28mUIIVPpYflOyLlK6dl9SA0eQ5jHTrOQ= Received: from BL1PR13CA0091.namprd13.prod.outlook.com (2603:10b6:208:2b9::6) by DS5PPFD22966BE3.namprd12.prod.outlook.com (2603:10b6:f:fc00::662) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.5; Thu, 15 Jan 2026 07:59:29 +0000 Received: from MN1PEPF0000F0E2.namprd04.prod.outlook.com (2603:10b6:208:2b9:cafe::59) by BL1PR13CA0091.outlook.office365.com (2603:10b6:208:2b9::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9520.5 via Frontend Transport; Thu, 15 Jan 2026 07:59:29 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by MN1PEPF0000F0E2.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.1 via Frontend Transport; Thu, 15 Jan 2026 07:59:29 +0000 Received: from honglei-remote.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 15 Jan 2026 01:59:25 -0600 From: Honglei Huang To: David Airlie , Gerd Hoffmann , Dmitry Osipenko , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , CC: Gurchetan Singh , , Chia-I Wu , , , , Honglei Huang Subject: [PATCH v4 4/5] drm/virtio: implement userptr support for zero-copy memory access Date: Thu, 15 Jan 2026 15:58:50 +0800 Message-ID: <20260115075851.173318-5-honglei1.huang@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260115075851.173318-1-honglei1.huang@amd.com> References: <20260115075851.173318-1-honglei1.huang@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E2:EE_|DS5PPFD22966BE3:EE_ X-MS-Office365-Filtering-Correlation-Id: 072b402e-0a61-4027-3c59-08de540c02a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|36860700013|7416014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?vprD8Xua35L3gaHLj0vqtRTsrsAY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ascii?Q?Nv9WXXtMqdBU9mtj4vM0kCAoKAXlof2EdOe7AB7hG5B5t8RvTG94HQTjl7Xz?= =?us-ascii?Q?m9CS3+xt7APXL9pTUqZk91fjcQMffnPr3auguQ6sKMaqHPgH9DoJUMB6kHIS?= =?us-ascii?Q?gTS2nAFwwHjjGrWbMcBuTNi6cGs9SDZ4LIK/9Bo3Ww2/AVdLujnjfofA7nIW?= =?us-ascii?Q?Mfkt7sRxokWJ79EMD7KwDk+P07Zu8q9m7lDYGcdF6IWWazT0IPhlvaT1FMmF?= =?us-ascii?Q?m5ajUAkYy7tKe2kDQ4CfpvceA4e9Mj/KdpmuropKxnTnOSLnvRhUbGcDhGPe?= =?us-ascii?Q?gpx+z209nv98T0M2s+lEmd9qaq+6Q+yLrbREZrXUUHG3dZDYBP0Rkul2uaBM?= =?us-ascii?Q?6uEEJAsWpy+yvat0y2h9XWQ+YLV6Ie6HtoKxSZmoBbYeU8/nHkNTM+myDMN+?= =?us-ascii?Q?vYIwG7nDcgTEDxk80HoUTKWPCVXp0BROPlk5xP6xzsbACSPONIeCW7c2WdUz?= =?us-ascii?Q?VrI3hwd6awgY4+0eujpd1agTKHCT7MwSOvj/o2ojCGrXtvuOuw+e234g+gfS?= =?us-ascii?Q?W27aUL7F2lg3IdpQ+4pDmouiBoEy53kn/RBqgKMD2xT1c9nDklKP59x2gWsW?= =?us-ascii?Q?Z8weSHn9czVPOqKVQ6R1ePmN7yhbw+3JCMsHJimwGDccL5ZOitHas8oOMH/r?= =?us-ascii?Q?k8aOM5ntiBXican+QwMgu/oBFrgnNpjXH6/y5mklyzFesPDEnRaXo0226zkU?= =?us-ascii?Q?BG5MJtauLAovADiHgZleM26+QMCaTvBMD5YIQlAl8b6qgcKSesQNIutzfwh8?= =?us-ascii?Q?VgVVYw=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(36860700013)(7416014)(82310400026)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2026 07:59:29.3422 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 072b402e-0a61-4027-3c59-08de540c02a3 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS5PPFD22966BE3 Content-Type: text/plain; charset="utf-8" From: Honglei Huang Add userptr support to enable host direct access to guest userspace memory, eliminating copy overhead for compute workloads. Implementation: - New virtio_gpu_object_userptr type for userptr resources - Pin pages with pin_user_pages_fast() and FOLL_LONGTERM - Build scatter-gather table for host access via blob resource - Support read-only mode (VIRTGPU_BLOB_FLAG_USERPTR_RDONLY) The pages are pinned at resource creation and unpinned at destruction. Follow-up patches will add ioctl integration and feature detection. Signed-off-by: Honglei Huang --- drivers/gpu/drm/virtio/Makefile | 3 +- drivers/gpu/drm/virtio/virtgpu_drv.h | 33 ++++ drivers/gpu/drm/virtio/virtgpu_object.c | 6 + drivers/gpu/drm/virtio/virtgpu_userptr.c | 231 +++++++++++++++++++++++ 4 files changed, 272 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/virtio/virtgpu_userptr.c diff --git a/drivers/gpu/drm/virtio/Makefile b/drivers/gpu/drm/virtio/Makef= ile index d2e1788a8..fe7332a62 100644 --- a/drivers/gpu/drm/virtio/Makefile +++ b/drivers/gpu/drm/virtio/Makefile @@ -6,6 +6,7 @@ virtio-gpu-y :=3D virtgpu_drv.o virtgpu_kms.o virtgpu_gem.o virtgpu_vram.o= \ virtgpu_display.o virtgpu_vq.o \ virtgpu_fence.o virtgpu_object.o virtgpu_debugfs.o virtgpu_plane.o \ - virtgpu_ioctl.o virtgpu_prime.o virtgpu_trace_points.o virtgpu_submit.o + virtgpu_ioctl.o virtgpu_prime.o virtgpu_trace_points.o virtgpu_submit.o \ + virtgpu_userptr.o =20 obj-$(CONFIG_DRM_VIRTIO_GPU) +=3D virtio-gpu.o diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.h b/drivers/gpu/drm/virtio/= virtgpu_drv.h index f17660a71..808a6e65b 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drv.h +++ b/drivers/gpu/drm/virtio/virtgpu_drv.h @@ -84,6 +84,7 @@ struct virtio_gpu_object_params { uint32_t blob_mem; uint32_t blob_flags; uint64_t blob_id; + uint64_t userptr; }; =20 struct virtio_gpu_object { @@ -113,12 +114,38 @@ struct virtio_gpu_object_vram { struct drm_mm_node vram_node; }; =20 +struct virtio_gpu_object_userptr; + +struct virtio_gpu_object_userptr_ops { + int (*get_pages)(struct virtio_gpu_object_userptr *userptr); + void (*put_pages)(struct virtio_gpu_object_userptr *userptr); + void (*release)(struct virtio_gpu_object_userptr *userptr); +}; +struct virtio_gpu_object_userptr { + struct virtio_gpu_object base; + const struct virtio_gpu_object_userptr_ops *ops; + struct mutex lock; + + uint64_t start; + uint32_t npages; + uint32_t bo_handle; + uint32_t flags; + + struct virtio_gpu_device *vgdev; + struct drm_file *file; + struct page **pages; + struct sg_table *sgt; +}; + #define to_virtio_gpu_shmem(virtio_gpu_object) \ container_of((virtio_gpu_object), struct virtio_gpu_object_shmem, base) =20 #define to_virtio_gpu_vram(virtio_gpu_object) \ container_of((virtio_gpu_object), struct virtio_gpu_object_vram, base) =20 +#define to_virtio_gpu_userptr(virtio_gpu_object) \ + container_of((virtio_gpu_object), struct virtio_gpu_object_userptr, base) + struct virtio_gpu_object_array { struct ww_acquire_ctx ticket; struct list_head next; @@ -512,4 +539,10 @@ void virtio_gpu_vram_unmap_dma_buf(struct device *dev, int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, struct drm_file *file); =20 +/* virtgpu_userptr.c */ +int virtio_gpu_userptr_create(struct virtio_gpu_device *vgdev, + struct drm_file *file, + struct virtio_gpu_object_params *params, + struct virtio_gpu_object **bo_ptr); +bool virtio_gpu_is_userptr(struct virtio_gpu_object *bo); #endif diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virt= io/virtgpu_object.c index e6363c887..da702301b 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -80,6 +80,12 @@ void virtio_gpu_cleanup_object(struct virtio_gpu_object = *bo) drm_gem_free_mmap_offset(&vram->base.base.base); drm_gem_object_release(&vram->base.base.base); kfree(vram); + } else if (virtio_gpu_is_userptr(bo)) { + struct virtio_gpu_object_userptr *userptr =3D + to_virtio_gpu_userptr(bo); + + drm_gem_object_release(&userptr->base.base.base); + kfree(userptr); } else { drm_gem_object_release(&bo->base.base); kfree(bo); diff --git a/drivers/gpu/drm/virtio/virtgpu_userptr.c b/drivers/gpu/drm/vir= tio/virtgpu_userptr.c new file mode 100644 index 000000000..f6c211e9d --- /dev/null +++ b/drivers/gpu/drm/virtio/virtgpu_userptr.c @@ -0,0 +1,231 @@ +// SPDX-License-Identifier: GPL-2.0 +#include +#include +#include +#include + +#include "virtgpu_drv.h" +#include "drm/drm_gem.h" + +static struct sg_table * +virtio_gpu_userptr_get_sg_table(struct drm_gem_object *obj); + +static void virtio_gpu_userptr_free(struct drm_gem_object *obj) +{ + struct virtio_gpu_object *bo =3D gem_to_virtio_gpu_obj(obj); + struct virtio_gpu_device *vgdev =3D obj->dev->dev_private; + struct virtio_gpu_object_userptr *userptr =3D to_virtio_gpu_userptr(bo); + + if (bo->created) { + userptr->ops->release(userptr); + + virtio_gpu_cmd_unref_resource(vgdev, bo); + virtio_gpu_notify(vgdev); + } + + mutex_destroy(&userptr->lock); +} + +static void virtio_gpu_userptr_object_close(struct drm_gem_object *obj, + struct drm_file *file) +{ + virtio_gpu_gem_object_close(obj, file); +} + +static const struct drm_gem_object_funcs virtio_gpu_userptr_funcs =3D { + .open =3D virtio_gpu_gem_object_open, + .close =3D virtio_gpu_userptr_object_close, + .free =3D virtio_gpu_userptr_free, + .get_sg_table =3D virtio_gpu_userptr_get_sg_table, +}; + +bool virtio_gpu_is_userptr(struct virtio_gpu_object *bo) +{ + return bo->base.base.funcs =3D=3D &virtio_gpu_userptr_funcs; +} + +static int +virtio_gpu_userptr_get_pages(struct virtio_gpu_object_userptr *userptr) +{ + unsigned int flag =3D FOLL_LONGTERM; + unsigned int num_pages, pinned =3D 0; + int ret =3D 0; + + if (userptr->pages) + return 0; + + userptr->pages =3D kvmalloc_array(userptr->npages, sizeof(struct page *), + GFP_KERNEL); + if (!userptr->pages) + return -ENOMEM; + + if (!(userptr->flags & VIRTGPU_BLOB_FLAG_USERPTR_RDONLY)) + flag |=3D FOLL_WRITE; + + do { + num_pages =3D userptr->npages - pinned; + + ret =3D pin_user_pages_fast(userptr->start + pinned * PAGE_SIZE, + num_pages, flag, + userptr->pages + pinned); + + if (ret < 0) { + if (pinned) + unpin_user_pages(userptr->pages, pinned); + kvfree(userptr->pages); + return ret; + } + + pinned +=3D ret; + + } while (pinned < userptr->npages); + + return 0; +} + +static void +virtio_gpu_userptr_put_pages(struct virtio_gpu_object_userptr *userptr) +{ + if (userptr->pages) { + unpin_user_pages(userptr->pages, userptr->npages); + kvfree(userptr->pages); + userptr->pages =3D NULL; + } + + if (userptr->sgt) { + sg_free_table(userptr->sgt); + kfree(userptr->sgt); + userptr->sgt =3D NULL; + } +} + +static void +virtio_gpu_userptr_release(struct virtio_gpu_object_userptr *userptr) +{ + mutex_lock(&userptr->lock); + userptr->ops->put_pages(userptr); + mutex_unlock(&userptr->lock); +} + +static struct sg_table * +virtio_gpu_userptr_get_sg_table(struct drm_gem_object *obj) +{ + struct virtio_gpu_object *bo =3D gem_to_virtio_gpu_obj(obj); + struct virtio_gpu_object_userptr *userptr =3D to_virtio_gpu_userptr(bo); + int ret; + + mutex_lock(&userptr->lock); + if (!userptr->pages) { + ret =3D userptr->ops->get_pages(userptr); + if (ret) { + mutex_unlock(&userptr->lock); + return ERR_PTR(ret); + } + } + + if (!userptr->sgt) + userptr->sgt =3D drm_prime_pages_to_sg(NULL, userptr->pages, + userptr->npages); + mutex_unlock(&userptr->lock); + + return userptr->sgt; +} + +static int +virtio_gpu_userptr_init(struct drm_device *dev, struct drm_file *file, + struct virtio_gpu_object_userptr *userptr, + struct virtio_gpu_object_params *params, + const struct virtio_gpu_object_userptr_ops *ops) +{ + uint32_t page_offset; + uint64_t aligned_size; + uint64_t aligned_addr; + int ret; + struct drm_gem_object *obj; + + page_offset =3D params->userptr & (PAGE_SIZE - 1UL); + aligned_addr =3D params->userptr - page_offset; + aligned_size =3D roundup(page_offset + params->size, PAGE_SIZE); + + userptr->start =3D aligned_addr; + userptr->npages =3D aligned_size >> PAGE_SHIFT; + userptr->flags =3D params->blob_flags; + + mutex_init(&userptr->lock); + userptr->vgdev =3D dev->dev_private; + userptr->file =3D file; + userptr->ops =3D ops; + + obj =3D &userptr->base.base.base; + obj->funcs =3D &virtio_gpu_userptr_funcs; + + drm_gem_private_object_init(dev, obj, aligned_size); + + ret =3D virtio_gpu_resource_id_get(userptr->vgdev, + &userptr->base.hw_res_handle); + + return ret; +} + +static const struct virtio_gpu_object_userptr_ops virtio_gpu_userptr_ops = =3D { + .get_pages =3D virtio_gpu_userptr_get_pages, + .put_pages =3D virtio_gpu_userptr_put_pages, + .release =3D virtio_gpu_userptr_release, +}; + +int virtio_gpu_userptr_create(struct virtio_gpu_device *vgdev, + struct drm_file *file, + struct virtio_gpu_object_params *params, + struct virtio_gpu_object **bo_ptr) +{ + struct virtio_gpu_object_userptr *userptr; + int ret, si; + struct sg_table *sgt; + struct scatterlist *sg; + struct virtio_gpu_mem_entry *ents; + + if (!params->size) + return -EINVAL; + + if (!access_ok((char __user *)(unsigned long)params->userptr, + params->size)) + return -EFAULT; + + userptr =3D kzalloc(sizeof(*userptr), GFP_KERNEL); + if (!userptr) + return -ENOMEM; + + ret =3D virtio_gpu_userptr_init(vgdev->ddev, file, userptr, params, + &virtio_gpu_userptr_ops); + if (ret) + goto failed_free; + + sgt =3D virtio_gpu_userptr_get_sg_table(&userptr->base.base.base); + if (IS_ERR(sgt)) { + ret =3D PTR_ERR(sgt); + goto failed_free; + } + + ents =3D kvmalloc_array(sgt->nents, sizeof(struct virtio_gpu_mem_entry), + GFP_KERNEL); + if (!ents) { + ret =3D -ENOMEM; + goto failed_free; + } + + for_each_sgtable_sg(sgt, sg, si) { + (ents)[si].addr =3D cpu_to_le64(sg_phys(sg)); + (ents)[si].length =3D cpu_to_le32(sg->length); + (ents)[si].padding =3D 0; + } + + virtio_gpu_cmd_resource_create_blob(vgdev, &userptr->base, params, ents, + sgt->nents); + + *bo_ptr =3D &userptr->base; + return 0; + +failed_free: + kfree(userptr); + return ret; +} --=20 2.34.1 From nobody Sun Feb 8 22:21:19 2026 Received: from SJ2PR03CU001.outbound.protection.outlook.com (mail-westusazon11012026.outbound.protection.outlook.com [52.101.43.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3997A32D431 for ; Thu, 15 Jan 2026 07:59:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.43.26 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768463987; cv=fail; b=Od3Jq75RQEwzi1/UwNqu8rjptHM1zS//5YUPCbYZh9cazYHX7L+n1H2tQqC68JZZq5uDcZbDQW/wwgtLI8AnNrP9AULOofYZxn9B9mCdEniOnYWHfcxE/9FAdLGfSHQVK1XZynMf/MMZ63syQz7iAcoYd6l1R9ZAo26v5kOy0G8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768463987; c=relaxed/simple; bh=HPqPupvyqU06FoPm6voDmQ1JCF68XraaPYLkYLTNsZg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pBnQCgNFpEhsaRE5YwrS2BZe47ZXDeuG3pewUd34iuDpMsavqeWPiMzrfOmNEIAWpmRXYq+xG7uDvnJPw4yDizjL+6DowkctKbTcY/SLT5wItEFX4pge8JPYpILCCGj2odz3ToZKIxSu80m1wPu7FjT02FSTsuNeu1HOLg7c06c= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=35Xti4CW; arc=fail smtp.client-ip=52.101.43.26 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="35Xti4CW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ypag3VfJ48D9DQXo6U3UvJ27BL9/daB9yeOKkSVYnuHLfi0Kj4utJoA9TzfVR5BCzPgzfetKAYPI0AEh+GzacdvI492uYUsa8eZ8vh9SiKg95l51cliszCRzVBc7q1sc1GTqMzPXuEKdlciP9d3XklSfCGRcMX0Go8idaK2xs0yWGcGu/xRtyHP5eRRne69qKBSFwL1kxd7B3jwZ+S6amwucSihqIzULQV2u9ChwmlNdbtetmfhwsp/KzPIzmy22uXuuHG7ZGmG7Mz8o75R+/QY9lMwZ7VXXFmexUCBsr/QTM0aQgIzFv3t4TY5F/oEvwF4gJpVD2j0g2uALWS/X4Q== 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=AsXdTSgqNmnPyGco6olO0bpQqz/wL/En26ePVSjE01w=; b=lYvKmwBE9OMynaNfsyk7zEjzaAb3t4g9cf8m4uLICdmKq3XQs4QFV7GD925AOnzXs0vB6q1Q9NlWDHu6WtFmkiijas+fk17px1YguycxlTxo8XJ7ukEVZebFOqdFQfDl1sat1953VloD+IbP7JgyUvNq/fZkH2r5Ke4W8D/7C5aXVIj6EITn6weXSGRk22V7n4SJUHmQrdXDRBfnLYKTwP+z9W+M6ZcrgBtf6mpB9dqqNl6EW1kIcZ7kQa4oONGSTKlV7nP+xEKkWCTQ69tUmgXgONVQLaWFksWXnKA1x9nl7mLu77844Cr1yAJBxUoYsKza6V72lH7JHuAUqf0ONQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com 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=AsXdTSgqNmnPyGco6olO0bpQqz/wL/En26ePVSjE01w=; b=35Xti4CWo5EJW2T4IEOOZhgJqBuCpp6gawFhGrz3ljhRWlLbgadM4xNSp0TNqXSxBYbxfbCZmC8L3FLZMGewOJCYIq/n4yODjKWhCwi+tKjAmx0nQdpI5a7o1l9jKu4mQL80Oh41tAaagFi9GMeIlJtjUdYH0JjQluziT4GAzFc= Received: from BL1PR13CA0164.namprd13.prod.outlook.com (2603:10b6:208:2bd::19) by CY5PR12MB6648.namprd12.prod.outlook.com (2603:10b6:930:3e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9456.14; Thu, 15 Jan 2026 07:59:33 +0000 Received: from MN1PEPF0000F0E1.namprd04.prod.outlook.com (2603:10b6:208:2bd:cafe::7b) by BL1PR13CA0164.outlook.office365.com (2603:10b6:208:2bd::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.2 via Frontend Transport; Thu, 15 Jan 2026 07:59:27 +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=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by MN1PEPF0000F0E1.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.20.9520.1 via Frontend Transport; Thu, 15 Jan 2026 07:59:33 +0000 Received: from honglei-remote.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Thu, 15 Jan 2026 01:59:29 -0600 From: Honglei Huang To: David Airlie , Gerd Hoffmann , Dmitry Osipenko , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Simona Vetter , CC: Gurchetan Singh , , Chia-I Wu , , , , Honglei Huang Subject: [PATCH v4 5/5] drm/virtio: advertise base userptr feature to userspace Date: Thu, 15 Jan 2026 15:58:51 +0800 Message-ID: <20260115075851.173318-6-honglei1.huang@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260115075851.173318-1-honglei1.huang@amd.com> References: <20260115075851.173318-1-honglei1.huang@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb08.amd.com (10.181.42.217) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E1:EE_|CY5PR12MB6648:EE_ X-MS-Office365-Filtering-Correlation-Id: 0986f37c-2bf7-426c-6a46-08de540c04d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|7416014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?JQtIH1JsFbSr25ewKZJTP/lyRv21FMqcSWYo4JShkw8wEQ74d6bIVdyIIWVj?= =?us-ascii?Q?T8Ft9+jqNCN+Yb+hjiCt2f3OvwzsOovWbHADWjbQ/PBf0XitW11eDpDtp3vb?= =?us-ascii?Q?Uf0uzQ9VT5eGviAtKw79A3ux1CfguoQ75gl2ykHJSsP+AqIRTe2qpVrex0ds?= =?us-ascii?Q?1UHD6UpNBhdI83Nahvab9vVUrkeOpVDHGyOG0vS2Mm0Ib/TOaFbUIhPEA45r?= =?us-ascii?Q?qY2WqrxLTiDUERnLob31kZy4IcXqvmEYGeirznKiiDy9sH4mqJ2tBx1eWy9D?= =?us-ascii?Q?8uc98XGkWGuVKwHanr/uYQFTXykPN203nuCoG1J19YqDrCeGyqCOOe9Wc3oz?= =?us-ascii?Q?C7/B84+wODs66RX96p8TE4zlQtpDK/qg/2hoq81NlkqkEy9Yis7GvB1AcjiK?= =?us-ascii?Q?ZscGOE4HAOS+qFlVzxDM0YeVwRFZXaOGUrnMQsog/OaZBUeeemlf2HGRQbyu?= =?us-ascii?Q?zjfZjnJqg7nX0CDladHfIKZ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?us-ascii?Q?qZ9HVkrKMVZ9twyQzPBiPKPXIvVm8ZlmvAkf/bDuGD7+BZuGf8XGBG71Jj9V?= =?us-ascii?Q?8xkmS2+JzeUIuEnCQ3Lci1SwDfq6YMRJytwjXBXLP297DlGRgOUezlkyCito?= =?us-ascii?Q?2E0Fw6ePJDf/mdWMqd+huEjUgSu9tWFs3D/i1u0iwAMO1ydUuhlhdz6Ab2Ld?= =?us-ascii?Q?xTZIsgxB4pmT9cxfI+4A97Ui4lH/EyfotrVE7pW9mDnbvc8boRFpTZJQcuYx?= =?us-ascii?Q?8F80jaRDOIpBs7R3cBiKWwo0oi/EBJ1mK7zFqIGtqIJF/7fBYwup4811Smhu?= =?us-ascii?Q?/p17VA=3D=3D?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(7416014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jan 2026 07:59:33.0250 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0986f37c-2bf7-426c-6a46-08de540c04d6 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=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E1.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6648 Content-Type: text/plain; charset="utf-8" From: Honglei Huang Integrate userptr functionality into the blob resource creation path: - Add userptr flags to VIRTGPU_BLOB_FLAG_USE_MASK for validation - Route userptr requests to virtio_gpu_userptr_create() - Pass userptr address from ioctl to params structure With this change, userspace can create userptr blob resources by setting VIRTGPU_BLOB_FLAG_USE_USERPTR flag and providing a valid userptr address. Signed-off-by: Honglei Huang --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virti= o/virtgpu_ioctl.c index c33c05736..e49f5c89b 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -36,7 +36,9 @@ =20 #define VIRTGPU_BLOB_FLAG_USE_MASK (VIRTGPU_BLOB_FLAG_USE_MAPPABLE | \ VIRTGPU_BLOB_FLAG_USE_SHAREABLE | \ - VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) + VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE | \ + VIRTGPU_BLOB_FLAG_USE_USERPTR | \ + VIRTGPU_BLOB_FLAG_USERPTR_RDONLY) =20 /* Must be called with &virtio_gpu_fpriv.struct_mutex held. */ static void virtio_gpu_create_context_locked(struct virtio_gpu_device *vgd= ev, @@ -489,6 +491,7 @@ static int verify_blob(struct virtio_gpu_device *vgdev, params->size =3D rc_blob->size; params->blob =3D true; params->blob_flags =3D rc_blob->blob_flags; + params->userptr =3D rc_blob->userptr; return 0; } =20 @@ -527,8 +530,10 @@ static int virtio_gpu_resource_create_blob_ioctl(struc= t drm_device *dev, vfpriv->ctx_id, NULL, NULL); } =20 - if (guest_blob) + if (guest_blob && !params.userptr) ret =3D virtio_gpu_object_create(vgdev, ¶ms, &bo, NULL); + else if (guest_blob && params.userptr) + ret =3D virtio_gpu_userptr_create(vgdev, file, ¶ms, &bo); else if (!guest_blob && host3d_blob) ret =3D virtio_gpu_vram_create(vgdev, ¶ms, &bo); else --=20 2.34.1