From patchwork Thu Aug 31 09:32:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371165 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 B86B9C83F10 for ; Thu, 31 Aug 2023 09:34:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593571.926581 (Exim 4.92) (envelope-from ) id 1qbe3Q-00067y-JU; Thu, 31 Aug 2023 09:33:32 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593571.926581; Thu, 31 Aug 2023 09:33:32 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3Q-00067r-G0; Thu, 31 Aug 2023 09:33:32 +0000 Received: by outflank-mailman (input) for mailman id 593571; Thu, 31 Aug 2023 09:33:31 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3P-0005pR-7c for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:33:31 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20605.outbound.protection.outlook.com [2a01:111:f400:7eab::605]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 721481a7-47e1-11ee-8783-cb3800f73035; Thu, 31 Aug 2023 11:33:30 +0200 (CEST) Received: from MW4PR04CA0282.namprd04.prod.outlook.com (2603:10b6:303:89::17) by MN0PR12MB5761.namprd12.prod.outlook.com (2603:10b6:208:374::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 09:33:25 +0000 Received: from MWH0EPF000989EA.namprd02.prod.outlook.com (2603:10b6:303:89:cafe::d) by MW4PR04CA0282.outlook.office365.com (2603:10b6:303:89::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.22 via Frontend Transport; Thu, 31 Aug 2023 09:33:24 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EA.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 09:33:24 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:33:16 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 721481a7-47e1-11ee-8783-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XmGKbokJE3I/LvawAsKudOotQKS6vaWaPKJj0ZTkYviyjVl/h7l/JmU+NLV1ye6GuZVswNvl8uidVPgiAb4PtWiPHzuFP9dA6fzlwL8oL7v8HZlvA3gUNZiinl9Qd46F8Z8aoVmJMTOIBXv1L1aF9u/fJfWkjCq2DmqfzFwVK7xaoEFBccU9pKUuFUhXhIZnNrFcqPeKlbO4y3e2Czgdv/GlUsChCUvL6EJFDxAOdDKGcjorG7f9Q1Mt6NEBwFLommS8yIcCHEHnm20X7hxXtdgNZhBI+W0LZzZq7+au9V5YxD/nmhf+rD+jNUJRar7xrE+f1p4HzGPWtW7hC+zRbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ZGX5Hj5sdF72tVBTXUh0R/Xrx3cM3xMJ6mAZRIdjtqc=; b=j3QXOsVo/ACt+8iLMkJl0iCAFr8peMS5SwFByj8MNbH+f7kgjITiocAyDVwWP8I8MQzYsgmZ+zZLKq/3LV2rzvT67wdHxby3tKQ1wdgQ8KzYhMwjCabx0Fx1+3qvvDRgJgPoB33JfpBVY9tXKiyuZy7iNKUGBR/YX4NvehOXbu3lbbGBja69pZUyzm9yHWBuj/gde55MVbaH8NJwdcVy7ySeLTsLoZvvZIjkQYh7VuRN17xFpWH0VMgOHGhftkJoK5rUiQXL/g1lAbhjsX1lTwCgEpLkZBPM6aRMNyKTtj+gEvXFFAtyvY4QiLEKcphIYtAJqfe7wTT4NSSRHD4PTw== 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 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=ZGX5Hj5sdF72tVBTXUh0R/Xrx3cM3xMJ6mAZRIdjtqc=; b=YwB6nf1L8l/1352pdfJp0dFTsUvmZePO9JK10zfwXu8ZUD5/xgYacVPEHyLOJaQOGDmxGkYH6mgfnyuL0HDpEnoPR83bQ/dfbS/5sCv21Yn2ratqQar+UPjcvdATCwmyobVICHXROUkqMu4AZDSO3hmpT2Zv+SOJiOdWORtJhgc= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 01/13] virtio: Add shared memory capability Date: Thu, 31 Aug 2023 17:32:40 +0800 Message-ID: <20230831093252.2461282-2-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EA:EE_|MN0PR12MB5761:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f1e4510-23d3-42e9-bc73-08dbaa0552e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4obXY5+hFRwRqvExNyC5HwgCjx0eSObM6qV/CZ7GchSa8bNK6BGodp8X5m1r360kw6F9in3PSqmae2ndUZqlGOostOfbSWYSIkvHk5MFZrOqXr7wp+9jt2fKS6GsIAmX2tI0PSvK0MWVtBy0DEgBR/mbA93LNPYwJioP8ryt4g/fdGMqJxJG5JTz5VL86McgQ5Bw8AdH38DUg0cYF6k9RBJvDaN6DKl/QXnLR2AkkwXgH4qbslZOcN1qQ01XXjsoezt7V7CJZaboSwP1fYQzJgPTGHtGnlPUqnwzMo0lxU1tCw7UE/2NltFlVbhmofOfKRhZLOiPDnm7dDrs1TwNuSIc2V147oi8FrG9RAbX2uYfnlKXXDZ2qsdtPEzVp/38470mQ9/0CtckgD4PJ0vXn3Ld+4vWA5r/kYGBqd+qMTXMOYkyvQIa3pLPyBKMi/DsnJFCBndopO13VjStUetrvavkoDnlgJAAn/SH9nFu5jn0VS5AGReO9lNs/R/lZjY02M2asZ88TNA1A12Pos+UCFdp2WS9naGIPdj8P73MRXbCwOAsDhzSSs1vxWDeM48XES0wpMMLhTRoPcWWvWcyaq4EcG+hFTsvD734HMLsZGIXs1+XXCwDXdMoh4UESZBEWUaONWINdp5Fv1btY2JQFbTSma2Ufe/3ji5AL3iUmpja89yUWR4GSndLZKncbM4A2QyX4/U/4N2TFHaSxqM+yZP3/Al6MXRoCoXeM7XIHA8r5GozC5VYbQxdp9Qo3LFq3/QJvTFAR/Up88wrTzohg7IHccdpNjyCQyG5WcIfmSFSIC5Glahmq/CvT0PHm+OoLFKCqsNx7UCeY2R9qvmKXg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(346002)(396003)(136003)(186009)(82310400011)(1800799009)(451199024)(46966006)(40470700004)(36840700001)(70206006)(41300700001)(8936002)(40480700001)(47076005)(36860700001)(336012)(8676002)(4326008)(478600001)(6666004)(110136005)(70586007)(316002)(16526019)(2616005)(426003)(1076003)(54906003)(7696005)(26005)(2906002)(82740400003)(356005)(81166007)(921005)(5660300002)(40460700003)(7416002)(36756003)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:33:24.3865 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8f1e4510-23d3-42e9-bc73-08dbaa0552e3 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5761 From: "Dr. David Alan Gilbert" Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG' to allow defining shared memory regions with sizes and offsets of 2^32 and more. Multiple instances of the capability are allowed and distinguished by a device-specific 'id'. Signed-off-by: Dr. David Alan Gilbert Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Huang Rui Tested-by: Akihiko Odaki Acked-by: Huang Rui Reviewed-by: Gurchetan Singh Reviewed-by: Akihiko Odaki Signed-off-by: Huang Rui --- This patch is already under review as part of the "rutabaga_gfx + gfxstream" series (already in v13) and has been included here because of dependency. hw/virtio/virtio-pci.c | 18 ++++++++++++++++++ include/hw/virtio/virtio-pci.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index edbc0daa18..da8c9ea12d 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1435,6 +1435,24 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy, return offset; } +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, + uint8_t bar, uint64_t offset, uint64_t length, + uint8_t id) +{ + struct virtio_pci_cap64 cap = { + .cap.cap_len = sizeof cap, + .cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, + }; + + cap.cap.bar = bar; + cap.cap.length = cpu_to_le32(length); + cap.length_hi = cpu_to_le32(length >> 32); + cap.cap.offset = cpu_to_le32(offset); + cap.offset_hi = cpu_to_le32(offset >> 32); + cap.cap.id = id; + return virtio_pci_add_mem_cap(proxy, &cap.cap); +} + static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr, unsigned size) { diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index ab2051b64b..5a3f182f99 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -264,4 +264,8 @@ unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues); void virtio_pci_set_guest_notifier_fd_handler(VirtIODevice *vdev, VirtQueue *vq, int n, bool assign, bool with_irqfd); + +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy, uint8_t bar, uint64_t offset, + uint64_t length, uint8_t id); + #endif From patchwork Thu Aug 31 09:32:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371166 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 A0C26C83F01 for ; Thu, 31 Aug 2023 09:34:05 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593572.926591 (Exim 4.92) (envelope-from ) id 1qbe3V-0006R7-Rd; Thu, 31 Aug 2023 09:33:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593572.926591; Thu, 31 Aug 2023 09:33:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3V-0006Qw-OX; Thu, 31 Aug 2023 09:33:37 +0000 Received: by outflank-mailman (input) for mailman id 593572; Thu, 31 Aug 2023 09:33:36 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3U-0005pR-HH for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:33:36 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2060c.outbound.protection.outlook.com [2a01:111:f400:7e8d::60c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 74d680fd-47e1-11ee-8783-cb3800f73035; Thu, 31 Aug 2023 11:33:35 +0200 (CEST) Received: from MW4PR04CA0272.namprd04.prod.outlook.com (2603:10b6:303:89::7) by LV2PR12MB5797.namprd12.prod.outlook.com (2603:10b6:408:17b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 09:33:32 +0000 Received: from MWH0EPF000989EA.namprd02.prod.outlook.com (2603:10b6:303:89:cafe::c3) by MW4PR04CA0272.outlook.office365.com (2603:10b6:303:89::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20 via Frontend Transport; Thu, 31 Aug 2023 09:33:32 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EA.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 09:33:31 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:33:24 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 74d680fd-47e1-11ee-8783-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LTf4S2tyeAJ1wv5Ja9xR7ec3dCfywWgvKygmrtdUhjs9lWEkJvSfSWwj/2AMuQwOWEVXtHf1BxbAGuOk7/I/QEZXo1tAkcO5NzTOgvMNs2WnHsb6w5w5nzYsHZyJiJ7VT/DXrNongn/Tjy+8WZ72f1MJZBJos+dxoMcde7rFsJWsuVwMudWbtYwntejOK9t/iv5qoaTxOqtqkUP9u6Q5I6/ip+X5VUx8sB0lkatjqMXikiZhrw+MaFbWorV1iuK0zuz7tjN4y5B1N2z9oIgwpM8DM26ccRpfpx+tjiVahxUunsyQIzJ8p2f8OiYcxx5vKLU71uxdtJpvRNsGSqIvmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=OkbJyyl2hKRMbUZDjv2bheTdRoyRBB1f2ttFfpngVoY=; b=SSzdBf7bKl3y4gN3QrJ2wttXi0U5qgHql/tB/32Iu/YjEzeOhKPyn2unjVamRum5KbID7WCuS5Dc7pNFeqRiOwNx5knYJDaZxMz96j8BfTH8MFMYFDZohsARY8iR/COViZBc65e0N35l/Sb/tSb5dW/zKkvy6hJM9yMQ9TjfrRTI0c+2bSGSsoDmmxObPmM3ePDkrL3iQJFBbdNt95K1y3pFtJYSLjT50quMenVvNjqtIWR2333Cwv5e/wWGU9cFTDDMz495pBZK4Ua4Wqwiy0jO7CJrZ0uhY37Pp/L/eNUcN8w94Ehf3fZWpFwBN/TWcd84vSqizXJ3ZCQYH+u/WA== 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 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=OkbJyyl2hKRMbUZDjv2bheTdRoyRBB1f2ttFfpngVoY=; b=GHWHQ297prRGui7LiTWWSZXw9ZGGy40qsgIui3WZJskBxWNyfK+lvdeAzoQ7uDr7FCwRLkn4FESh2DpiJKvFDB7Tzo8gDwEdjgN131wbGKx1ko13R3bTmPrxYh9w8NxlE0ZBjf8Qd4jj2L0xDL9xv4zCIzhRRzG4kt9AXUpXQ7c= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Huang Rui Subject: [QEMU PATCH v4 02/13] virtio-gpu: CONTEXT_INIT feature Date: Thu, 31 Aug 2023 17:32:41 +0800 Message-ID: <20230831093252.2461282-3-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EA:EE_|LV2PR12MB5797:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e76fc58-6ac3-4538-88ec-08dbaa05575e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wiH4UvJx8dN6O7byKREbV7UWWhKCNrvESLRrIxlKzanbDnuu+AByYxnN7rJTvNApNYMIU0tb4wzAvxf9fPDLtcyMwCKEpbQxu+WnPGA1TyvXzwlX8fhex1N2xonFzgusMIgvzU0S5nRyewCg9CeIkt7dMmrq6GBy9g9LNPI5k+oLv+6aUlAoo+lZOrk8nN+XQ2W7XSFNuNbfHgtueLHxqS+MZ8mLSvtRLyppRxJHTmmcrquyxEAuVlHsSR9GYW/w97eTGmydhy48NgKivNjK19s8MDYVfqVdQlFvoy42+V+EIec8RgaEVb6AkRdLy1ygVQvxDFFXlmI15oaoQSYNTKFN8KninnsUSE12AB6VNx0QRSeQUqElPeF88vXcoEGLdRbGRX40NbINOZyNT1uTcGBjdA74PPjqSfFlGqtQrQ+zhVuKWNt07y40EOvrjywwbgZYn1dsCXVVBS6z8GuSIoDmD1aYP9Eut8Zm0XxAYb14/KzN+rwQTyxFhHdZJN9DCa1xuwCdZMRizpw0KpnBjSMu1E3ZSsEfxfvJlSnchQeLO9M/mEi/VUWO5HxrystLEyhzxKft1ucptEXEFzBTmyMRyLSD3VMKo2hpKXnRWdBjy2KN1gBR1edtUmDvptz4AupjVxBjawqQfwFwuPej5hpJ4IYw38Lx+DovzWOxiPObppaKvg3SV0OGQhmRdmHUbdyTuNS6ntlUbnJFyWCeOQCP8s/o+PXzUzOpeVmgIL8UkESrPaDzO8dLfTFpJRszmXTjRIlDN7sulwPHV8jDUkb1EsSJ5pV1SPrzSO8SQUs= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(136003)(376002)(346002)(39860400002)(1800799009)(82310400011)(451199024)(186009)(46966006)(40470700004)(36840700001)(36756003)(7416002)(40460700003)(40480700001)(41300700001)(86362001)(4326008)(7696005)(5660300002)(8936002)(8676002)(26005)(1076003)(16526019)(426003)(6666004)(36860700001)(47076005)(2616005)(336012)(82740400003)(110136005)(81166007)(356005)(478600001)(2906002)(70586007)(54906003)(316002)(70206006)(921005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:33:31.8866 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e76fc58-6ac3-4538-88ec-08dbaa05575e 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5797 From: Antonio Caggiano The feature can be enabled when a backend wants it. Signed-off-by: Antonio Caggiano Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Reviewed-by: Marc-André Lureau Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Akihiko Odaki Signed-off-by: Huang Rui --- This patch is already under review as part of the "rutabaga_gfx + gfxstream" series (already in v13) and has been included here because of dependency. hw/display/virtio-gpu-base.c | 3 +++ include/hw/virtio/virtio-gpu.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index ca1fb7b16f..4f2b0ba1f3 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -232,6 +232,9 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, if (virtio_gpu_blob_enabled(g->conf)) { features |= (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } + if (virtio_gpu_context_init_enabled(g->conf)) { + features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); + } return features; } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 390c4642b8..8377c365ef 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -93,6 +93,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_EDID_ENABLED, VIRTIO_GPU_FLAG_DMABUF_ENABLED, VIRTIO_GPU_FLAG_BLOB_ENABLED, + VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -105,6 +106,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_DMABUF_ENABLED)) #define virtio_gpu_blob_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) +#define virtio_gpu_context_init_enabled(_cfg) \ + (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; From patchwork Thu Aug 31 09:32:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371167 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 A2A26C83F01 for ; Thu, 31 Aug 2023 09:34:10 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593574.926600 (Exim 4.92) (envelope-from ) id 1qbe3i-0006wy-9F; Thu, 31 Aug 2023 09:33:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593574.926600; Thu, 31 Aug 2023 09:33:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3i-0006wo-66; Thu, 31 Aug 2023 09:33:50 +0000 Received: by outflank-mailman (input) for mailman id 593574; Thu, 31 Aug 2023 09:33:48 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3g-0006tw-Et for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:33:48 +0000 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2060b.outbound.protection.outlook.com [2a01:111:f400:7e8a::60b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7a465ee2-47e1-11ee-9b0d-b553b5be7939; Thu, 31 Aug 2023 11:33:45 +0200 (CEST) Received: from MW4PR03CA0342.namprd03.prod.outlook.com (2603:10b6:303:dc::17) by MW5PR12MB5649.namprd12.prod.outlook.com (2603:10b6:303:19d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 09:33:39 +0000 Received: from MWH0EPF000989EC.namprd02.prod.outlook.com (2603:10b6:303:dc:cafe::58) by MW4PR03CA0342.outlook.office365.com (2603:10b6:303:dc::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21 via Frontend Transport; Thu, 31 Aug 2023 09:33:39 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EC.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.16 via Frontend Transport; Thu, 31 Aug 2023 09:33:39 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:33:31 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7a465ee2-47e1-11ee-9b0d-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N8xIynprutMEn5MAtCwoQkUCKbA5fvmB7FULIYJLqInGzKjRL14bXZZQyUi3VPiw7QREw2GF0cX2Dpq04dix0aTox3zz20S2x8XNHMRl0dGwbMIzL7IhBmIdrJDFwFAvUMfnLs8Uhmuqej4JJ/lpLCsu24SDLVSd8x8oNGUWg4hDugoKr3BSB0yW+YG4v32HyDvD4FIJ3ywaDI6yX+awybQ+u0s+Q1CbvBvKiN/FkuQ+LbBoBnDMA/kCC10SDlzxRXtxDqwGxJQ4hBsbzPZmM0jq9ZRkSGJfwLZNcTtRT+tBL5v8KDeOa4EgyAE8rx3irBLbT3C9Zy99trzLib006Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=BbWnAkGTDkIuiyxFJjQRvGBwHS6OgVoyaJjKb6dSr5M=; b=ZqfTgLbHr4FdbHfAY6Z0NYcABB0IkcVL9FzQckPhduBC97GUuWl7RVgyJ6ZWkbCIAw7pfqKQB4eUo4A6zrjZVLgktJx0+xkdcqIXBnWwL95wJPWIjvNn9Y3DiJWYbOoL5Hd7N473UzalFaU442rYmvQoHWo4qQEi64xddVvUKyI/assWNU6Ht84466b0gjtcBWWgBsFUwlA0FMqv/Wu/BDrVPiPVrezC5om4UUOEZm3ZU4kTrO8hG52ooSPlODvYBLaON7NkBaUBLamKuMm2ikQ3OzZpD4WXbpkxu4HeX2hoeM5bpLrn59u4z9bdB954bybBxTO4VL/1B6VigaaxCQ== 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 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=BbWnAkGTDkIuiyxFJjQRvGBwHS6OgVoyaJjKb6dSr5M=; b=oD307W5QKTyu90ZGdMYv+Uy39SdUAStwnX5ilhPt5b9rEtH55wSJakI7jShkjxznCESHtpc01EOJtiQ8aOy3SEy6peRYRRqA/uUuSXGOEaIOigPXZyWk+FsVDO/3nidcNb81+BGh2CdG2zN2zdtHe0GjcR/3Qh0DyXEJnvja2G4= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 03/13] virtio-gpu: hostmem Date: Thu, 31 Aug 2023 17:32:42 +0800 Message-ID: <20230831093252.2461282-4-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EC:EE_|MW5PR12MB5649:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e62684b-ddd7-4c79-5b1d-08dbaa055bea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9eeY67tes1/Myu7fpK8tPRbZHeo1HLTkuhLdhATXE/KhXw+uJ2E7vlaBn6zaJ3bTyyox4Auzi3vzEzKX9rB2v3wM4a0+5vpHzB/D6u8VKpFd41kiskoguO5uoFc7DcfNEPwTL0o9ivS/u5w4LgPigFeXwM7Tk3EbB46OcKF3JbqZgf/8OGQ2V9mDdAvp4Fp/8NAFfdG4MYFIpxzFt0sXkvYOoRwIZbO7p1Xn7vBRB9pkRDRoPitqQv/TQhEnj3iDL5eF4TTqUYTpXgEFPe7LxT8gp0Pd8Z2HjiQsUEe2cd5TtBh1Vbt8cs9D7YCWWZabskuLKLv8IwVXce95AkNsQ9Dhd6uybqGyaXCoIls72uqbe7tCD6HhupkC/J3WGkJwxh0nDdZELQ1Ya/BGgWvZlnjeCRmwrUmBuSxWZkk905D3QXVvyQslIHz5EloDX/6ZYdf9sxvNrIY/FK2pdHhQ2UYYRRI3RSAvfiPDhp/29/lXkZBddysHtvOdoFaQzOthyZWg0FE3cBRytCRsZvoX8jZan2RolNgY/nrdVYK/nqWTWFwpJHLC3+Lnh2YfmRkmY9ULg5KbKL1dNmF0oMD7bXMYf5ompUzc8CkzxhV2JJiptpn+hvpqBZ08MhmVaIeXsOytYOoiqgTNb3mlS1K1ofqcNojOE8oGhWKhlJ+m3ohqosu1HdtHuzJOfR9tzGGOje2JtFcpGQwoKztLbDDI7C6jxOP+bMCMuDbYEPG4IAf94tWqJf0dS+OdrCkNj+AqDccP9Xs1KoGVNHr2thMaJSA7cpC0/WUEM7ja0hgxVoE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(136003)(376002)(396003)(39860400002)(1800799009)(451199024)(82310400011)(186009)(40470700004)(46966006)(36840700001)(36756003)(40460700003)(7416002)(40480700001)(2616005)(83380400001)(8676002)(86362001)(41300700001)(4326008)(8936002)(5660300002)(6666004)(336012)(7696005)(1076003)(426003)(16526019)(26005)(36860700001)(47076005)(81166007)(921005)(110136005)(478600001)(82740400003)(356005)(70586007)(54906003)(70206006)(316002)(2906002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:33:39.4982 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e62684b-ddd7-4c79-5b1d-08dbaa055bea 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EC.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5649 From: Gerd Hoffmann Use VIRTIO_GPU_SHM_ID_HOST_VISIBLE as id for virtio-gpu. Signed-off-by: Antonio Caggiano Tested-by: Alyssa Ross Tested-by: Akihiko Odaki Acked-by: Michael S. Tsirkin Reviewed-by: Akihiko Odaki Signed-off-by: Huang Rui --- This patch is already under review as part of the "rutabaga_gfx + gfxstream" series (already in v13) and has been included here because of dependency. hw/display/virtio-gpu-pci.c | 14 ++++++++++++++ hw/display/virtio-gpu.c | 1 + hw/display/virtio-vga.c | 33 ++++++++++++++++++++++++--------- include/hw/virtio/virtio-gpu.h | 5 +++++ 4 files changed, 44 insertions(+), 9 deletions(-) diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c index 93f214ff58..da6a99f038 100644 --- a/hw/display/virtio-gpu-pci.c +++ b/hw/display/virtio-gpu-pci.c @@ -33,6 +33,20 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) DeviceState *vdev = DEVICE(g); int i; + if (virtio_gpu_hostmem_enabled(g->conf)) { + vpci_dev->msix_bar_idx = 1; + vpci_dev->modern_mem_bar_idx = 2; + memory_region_init(&g->hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); + pci_register_bar(&vpci_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + &g->hostmem); + virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); + } + virtio_pci_force_virtio_1(vpci_dev); if (!qdev_realize(vdev, BUS(&vpci_dev->bus), errp)) { return; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index bbd5c6561a..48ef0d9fad 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1509,6 +1509,7 @@ static Property virtio_gpu_properties[] = { 256 * MiB), DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), + DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index e6fb0aa876..c8552ff760 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -115,17 +115,32 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpci_dev, Error **errp) pci_register_bar(&vpci_dev->pci_dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &vga->vram); - /* - * Configure virtio bar and regions - * - * We use bar #2 for the mmio regions, to be compatible with stdvga. - * virtio regions are moved to the end of bar #2, to make room for - * the stdvga mmio registers at the start of bar #2. - */ - vpci_dev->modern_mem_bar_idx = 2; - vpci_dev->msix_bar_idx = 4; vpci_dev->modern_io_bar_idx = 5; + if (!virtio_gpu_hostmem_enabled(g->conf)) { + /* + * Configure virtio bar and regions + * + * We use bar #2 for the mmio regions, to be compatible with stdvga. + * virtio regions are moved to the end of bar #2, to make room for + * the stdvga mmio registers at the start of bar #2. + */ + vpci_dev->modern_mem_bar_idx = 2; + vpci_dev->msix_bar_idx = 4; + } else { + vpci_dev->msix_bar_idx = 1; + vpci_dev->modern_mem_bar_idx = 2; + memory_region_init(&g->hostmem, OBJECT(g), "virtio-gpu-hostmem", + g->conf.hostmem); + pci_register_bar(&vpci_dev->pci_dev, 4, + PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_PREFETCH | + PCI_BASE_ADDRESS_MEM_TYPE_64, + &g->hostmem); + virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, + VIRTIO_GPU_SHM_ID_HOST_VISIBLE); + } + if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) { /* * with page-per-vq=off there is no padding space we can use diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 8377c365ef..de4f624e94 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -108,12 +108,15 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_BLOB_ENABLED)) #define virtio_gpu_context_init_enabled(_cfg) \ (_cfg.flags & (1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED)) +#define virtio_gpu_hostmem_enabled(_cfg) \ + (_cfg.hostmem > 0) struct virtio_gpu_base_conf { uint32_t max_outputs; uint32_t flags; uint32_t xres; uint32_t yres; + uint64_t hostmem; }; struct virtio_gpu_ctrl_command { @@ -137,6 +140,8 @@ struct VirtIOGPUBase { int renderer_blocked; int enable; + MemoryRegion hostmem; + struct virtio_gpu_scanout scanout[VIRTIO_GPU_MAX_SCANOUTS]; int enabled_output_bitmask; From patchwork Thu Aug 31 09:32:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371168 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 8B024C83F35 for ; Thu, 31 Aug 2023 09:34:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593576.926611 (Exim 4.92) (envelope-from ) id 1qbe3m-0007IJ-JQ; Thu, 31 Aug 2023 09:33:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593576.926611; Thu, 31 Aug 2023 09:33:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3m-0007I4-Dk; Thu, 31 Aug 2023 09:33:54 +0000 Received: by outflank-mailman (input) for mailman id 593576; Thu, 31 Aug 2023 09:33:52 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3k-0006tw-SX for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:33:52 +0000 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20600.outbound.protection.outlook.com [2a01:111:f400:fe5b::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 7db0374d-47e1-11ee-9b0d-b553b5be7939; Thu, 31 Aug 2023 11:33:51 +0200 (CEST) Received: from MW4PR04CA0300.namprd04.prod.outlook.com (2603:10b6:303:89::35) by MW3PR12MB4362.namprd12.prod.outlook.com (2603:10b6:303:5d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21; Thu, 31 Aug 2023 09:33:46 +0000 Received: from MWH0EPF000989EA.namprd02.prod.outlook.com (2603:10b6:303:89:cafe::1a) by MW4PR04CA0300.outlook.office365.com (2603:10b6:303:89::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.23 via Frontend Transport; Thu, 31 Aug 2023 09:33:46 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989EA.mail.protection.outlook.com (10.167.241.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 09:33:46 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:33:39 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7db0374d-47e1-11ee-9b0d-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QwdBHpikxg+u6vtMqlUrgQsxp7wZqkQYDGekSDzmr78zxQk/+QJt/dI+jcGuGIz6ubdvy3KaktWHUUGDJUvAQ/zFiEtzCj+uZXzSaRBIDNtIkQheWJWyjPXUJ6+BPPsLR722zthgbx4S899YW6Rue1fi9ackUt1gzZugLUoYsdjQuojF1sxGGl0UgY9uRw85Jq/gbB+Lqxg2t0lfJA+A3DKGmqTt+VtshlwI2qKuE+Bu3wk7vMjvdOv13I5Wk9TbspwkxIoUDXDZA7mmUUT8b8JVl6zM6LdW6+T8urtkeWjomnKQDabz6PoU6l+19MoMjibPPe9VWtGCh2L/pka9Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=rHy1UnKuYteMitn9Vk2LwqyNhuJGyfSsajh1mjfyeBw=; b=Tgy+UduxNkkARnYG6rDOZ+gEVXVpWfjqMZmE83Xi2KEhRiloZDaxv9yZ/8bWymQM92Uz3fb8sEQUD/ah7e+an4htlwCW/ySCUfJvK/frq0OSXTJ5aEJV2yheVQpy961wWQtDcohZHgakK9jr9ofbNgsBYKEJgUv+EZXHvqqxjaRyhrp05GdtwEH9VS31qXILq6r3lge+YcMcm4Jgzi6M/8T7aROhrFXOJYfFk3qeSNlBLm5fgoQZ8gy0YN8thHrnFeOggiETGW3ZxKm7i0h4s9V85GMhUfvkufHNhVjEWW4oBcKtTptFAZ6nxlOYhzrMhRaLsOfbIXeeUjLpuSPAqA== 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 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=rHy1UnKuYteMitn9Vk2LwqyNhuJGyfSsajh1mjfyeBw=; b=39yVksiDQviA5sHuwbueLZmZYBQMvgRcUxrCQkbjcA17QmOdpFDY+bdiWTQtuph7RjAMvRyovAHCr5NRKEzwypA8LKjiULqS6gLZuDv6d3dPkSlKs5Ny5zGoPzX18c2FsEOnszJxWg5QQ/0ZAmUJrEMvYgfBesJ87gtglgXO+L4= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Emmanouil Pitsidianakis , Huang Rui Subject: [QEMU PATCH v4 04/13] virtio-gpu: blob prep Date: Thu, 31 Aug 2023 17:32:43 +0800 Message-ID: <20230831093252.2461282-5-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989EA:EE_|MW3PR12MB4362:EE_ X-MS-Office365-Filtering-Correlation-Id: 37def332-56e8-4a92-8515-08dbaa056037 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ypX+zPPIP7BDXemVD5Igaq8W6nOq03cx/+RqbqaF8EtCLjlqHZFmsA/VC5RJWNSlBFZh9fY6Lki+8ZcJ7Q3741BH7FW5Wrcq26SlO7Ttd8fAYtdgxwVr+O+9Jx0pS9qp1vAWuNYGtknsiLoPT+rLxzzJOQ8cX6SSq6kaLVQ2cb8fiRx0gj8YV7m83b1QZwG43Y2eiwBwjMzvBOGXKfdLUwGwDAkNyxOhi8523YuGqd0zLCCDRDwab+He7WsRGfy+tJPn++cpxIT/CS1N9nWnBxt7y0REmy9XXkB84J/MGQZ/F2NDOxbgEd1nN8P7x9JM1+oEk/hs/PSw8IkBqHLYoEW0HFeAm+dPSYiPN4ks/e+qpP4bGlI/7VmzhBGFIHdYoAQFXgCSQEEKiPOqH1v+RKvD4oFJhJjQUs2sYTfRY2pXzm/6g+ec+3b8WMw2NZAdSfsgq9VGeinH1fPcvrFhzUdBLqqHu1zE80UElPu2ZCQjzkdxTFkcccdH//ksVmdbidIprodVByFsNyiYACPpm4tI2imolXLggRj+uo/mirSu7OxVQzSJ3RgCjo0XfSYeIjJg95PpTC7MTUSxd9OzY2yYwmgoMjbRl/2P1seobBkO+8DqBUbv0GkTV6molg74WQBK/NX875ZeIiiKXNQkrmwtntCtRvSHUebg8grvge3+pjNhMVX/CSyXq+aHKrwGd9v7q5YlmJITGmrJKE4lGtGsUVSZMGg7iM2tMSJRWzuQBUkGfSMr7qEVZVUK9xw5AxWDFB0fRfpyADoktiky7O3v/DW/8L/2Ua3coSr3ABE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(39860400002)(346002)(396003)(1800799009)(82310400011)(451199024)(186009)(36840700001)(40470700004)(46966006)(356005)(921005)(81166007)(7696005)(82740400003)(6666004)(40460700003)(36756003)(86362001)(36860700001)(40480700001)(47076005)(1076003)(2616005)(2906002)(336012)(426003)(26005)(16526019)(83380400001)(478600001)(41300700001)(110136005)(70586007)(70206006)(4326008)(8936002)(5660300002)(8676002)(7416002)(54906003)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:33:46.7304 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37def332-56e8-4a92-8515-08dbaa056037 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989EA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4362 From: Antonio Caggiano This adds preparatory functions needed to: - decode blob cmds - tracking iovecs Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Gurchetan Singh Tested-by: Alyssa Ross Tested-by: Emmanouil Pitsidianakis Tested-by: Akihiko Odaki Reviewed-by: Emmanouil Pitsidianakis Reviewed-by: Akihiko Odaki Signed-off-by: Huang Rui --- This patch is already under review as part of the "rutabaga_gfx + gfxstream" series (already in v13) and has been included here because of dependency. hw/display/virtio-gpu.c | 10 +++------- include/hw/virtio/virtio-gpu-bswap.h | 15 +++++++++++++++ include/hw/virtio/virtio-gpu.h | 5 +++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 48ef0d9fad..3e658f1fef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,15 +33,11 @@ #define VIRTIO_GPU_VM_VERSION 1 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, const char *caller, uint32_t *error); -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); static void virtio_gpu_reset_bh(void *opaque); void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, g_free(iov); } -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res) +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov = NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-gpu-bswap.h index 637a0585d0..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -70,6 +70,21 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob *cblob) le64_to_cpus(&cblob->size); } +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ + virtio_gpu_ctrl_hdr_bswap(&mblob->hdr); + le32_to_cpus(&mblob->resource_id); + le64_to_cpus(&mblob->offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ + virtio_gpu_ctrl_hdr_bswap(&ublob->hdr); + le32_to_cpus(&ublob->resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index de4f624e94..55973e112f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); From patchwork Thu Aug 31 09:32:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371169 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 A2150C83F10 for ; Thu, 31 Aug 2023 09:34:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593585.926622 (Exim 4.92) (envelope-from ) id 1qbe3t-0007pz-R8; Thu, 31 Aug 2023 09:34:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593585.926622; Thu, 31 Aug 2023 09:34:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3t-0007ps-Lp; Thu, 31 Aug 2023 09:34:01 +0000 Received: by outflank-mailman (input) for mailman id 593585; Thu, 31 Aug 2023 09:34:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3t-0006tw-03 for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:34:01 +0000 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [2a01:111:f400:7eae::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 82e3cc4d-47e1-11ee-9b0d-b553b5be7939; Thu, 31 Aug 2023 11:33:59 +0200 (CEST) Received: from BYAPR05CA0008.namprd05.prod.outlook.com (2603:10b6:a03:c0::21) by IA1PR12MB8357.namprd12.prod.outlook.com (2603:10b6:208:3ff::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 09:33:55 +0000 Received: from MWH0EPF000989E5.namprd02.prod.outlook.com (2603:10b6:a03:c0:cafe::52) by BYAPR05CA0008.outlook.office365.com (2603:10b6:a03:c0::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.14 via Frontend Transport; Thu, 31 Aug 2023 09:33:54 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E5.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.16 via Frontend Transport; Thu, 31 Aug 2023 09:33:54 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:33:46 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 82e3cc4d-47e1-11ee-9b0d-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lhAMVfFYfWHgnoCmKyczvnTv91FxW8pSSHplnlvFpJt516eIQyyuvGoCTcxqBN+DshBvxOoMi28wkdwCYxMKKaafkOAcbhuu5U7xpGvyRxZKJy64vFPjhjlGuAx2RnWMCnC7Zizv5tAVL10aHBtwqYQ8/053CviGapdC4mhYAPHbnxQmmHGP6tzP3TVNWi3XIC7Ak36cryqREHJvgnLQFKIcblRzfB0t43XoJCoruzs2PQRH6wL4Yvgbo/lD+4HpSPqWTMMSbeLGBSY2ttYrLCCNdz7tVExXl8/qqJqz74eYuTVepGb91GZu9QIeSUMUNxDi5f010Vh5rrvvb5CGNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=FRQ1qUyvUZQnKdi9DaXDIHpX3dEnpLy+x0X55ktio60=; b=RLQX8DX7jdtdSi2zAfPU4M282BBEwtMlARueetYyW05EPj73d1yn76cXb7BWKcEq63xLBELaOxW7/phRMSdz5kPvcK9CZ3PuEYm4vLHOHcAQpFv5VUGkyQOVAazn3BFHoL1tHmO1+7204UPhhgi1ydj6gX4cNJApI4Mdx6zGWJ57TzuUc0B2elp+NTyc1Uj1WMEBTfVQFtDIHrfn3Oi/iazaSkwlG61pSaJGBuomIXpRcliKVMswDggxYoV91HmgdQay4crogrcM5rA0CFgNOhXgHBerwZOMW9YGuNUAd/+aClX9ZczAYzOoo4qnQiK8XhkpF3NFDbRkSGCO1g8xvA== 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 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=FRQ1qUyvUZQnKdi9DaXDIHpX3dEnpLy+x0X55ktio60=; b=dU5H2AkhpbH7kR7PDWUm0+WyvFE4QNRUZjSYjhCIUPmNouDyCfk+5yTL7CUf990tbisyqwUWESgOYJQhZvFRyxiMUuBaLcgp4/p2c/9DiGTTzovM821zl5lPblPaxr9L+zwZ8gUR87dPdCXaL4uK2Y8yo7LCoqcynjcE+9NCxQs= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 05/13] virtio-gpu: Support context init feature with virglrenderer Date: Thu, 31 Aug 2023 17:32:44 +0800 Message-ID: <20230831093252.2461282-6-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E5:EE_|IA1PR12MB8357:EE_ X-MS-Office365-Filtering-Correlation-Id: f607c5d3-3400-407b-ec9b-08dbaa0564cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8ejNdyq5NksTMzk+vaYTabHky77ur3qk4Re1+zmd2EkAc4KZBvnnG9TKEJgE29nj4+9vrnil+ZzsL4yG8/cK1mADiSFDMHFDiVnQ0YX0MHi6ENyNuZmKAyuuTg08kTYh+XOyvhpv4tBB6PjZEHF/1Bva+qUxvGlNfGVAT5odhhu4iKEVwVDsO6Nkurde0Cgih070nR2cprnXoSrv8jtTRrAGQtYWc5f0nC/tfbX1Qrrslo/xunempOh9+EGTHC8GY8Qwo+5v5rkGbxFTc/aojtXJG2SP3NpiXFR1xF0PtlW8zoIgy1uZN2uCzrQedJgOkrXAp0oTNpvPSN8Gnz+2uxihjd2uY6JWtuXeRyyiLNJJBBt/N4p+XzL6FEpMwa1n1cDYygsrPhQ0wpxMV7LCT4CxKyEpx2tSpThrvWGkqNAWpKesA7mPCVeNEqB4aY/baAtZ83k4/U8Y03z7sj+T993+tQFsskoYVlAuNQmbgBDMTr7w7noRWnh/C7Cf2J8sH5woXr+dVYZ2vGYMT9wMDXiWcRtR7JeVqr8dkuT2hlDCydrOoMc/Y0EnlNz9zeEGV+dgjbmhlapTtfpd1SKG4u5oist6P5Tb571r/uxfnHe11z3vbKho/Rr8tVpRGeuxl9eU0CPRvaEYTg6C3SpLwyYcfmFhSdVlfqJhjqTqn2v7wJw1jG9npBpdreXqgvmszyMfCAq2V+ZvCuV1+Gv3TB/9OF97f2L5eoBrqRpkAdyAGOxAXCmhCm/ejX4XfJ0Um/VD9BHvH1kJsKTCZYFCcJ3a7QSEOoXlu8e/Ez6vQuE= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(376002)(346002)(396003)(136003)(186009)(82310400011)(1800799009)(451199024)(46966006)(40470700004)(36840700001)(70206006)(41300700001)(8936002)(83380400001)(40480700001)(47076005)(36860700001)(336012)(8676002)(4326008)(478600001)(110136005)(70586007)(316002)(16526019)(2616005)(426003)(1076003)(54906003)(7696005)(26005)(2906002)(82740400003)(356005)(81166007)(921005)(5660300002)(40460700003)(7416002)(36756003)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:33:54.4426 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f607c5d3-3400-407b-ec9b-08dbaa0564cd 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8357 Patch "virtio-gpu: CONTEXT_INIT feature" has added the context_init feature flags. We would like to enable the feature with virglrenderer, so add to create virgl renderer context with flags using context_id when valid. Originally-by: Antonio Caggiano Signed-off-by: Huang Rui --- New patch, result of splitting [RFC QEMU PATCH 04/18] virtio-gpu: CONTEXT_INIT feature hw/display/virtio-gpu-virgl.c | 13 +++++++++++-- hw/display/virtio-gpu.c | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 8bb7a2c21f..312953ec16 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -106,8 +106,17 @@ static void virgl_cmd_context_create(VirtIOGPU *g, trace_virtio_gpu_cmd_ctx_create(cc.hdr.ctx_id, cc.debug_name); - virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen, - cc.debug_name); + if (cc.context_init) { +#ifdef HAVE_VIRGL_CONTEXT_INIT + virgl_renderer_context_create_with_flags(cc.hdr.ctx_id, + cc.context_init, + cc.nlen, + cc.debug_name); + return; +#endif + } + + virgl_renderer_context_create(cc.hdr.ctx_id, cc.nlen, cc.debug_name); } static void virgl_cmd_context_destroy(VirtIOGPU *g, diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 3e658f1fef..a66cbd9930 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1506,6 +1506,8 @@ static Property virtio_gpu_properties[] = { DEFINE_PROP_BIT("blob", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_BLOB_ENABLED, false), DEFINE_PROP_SIZE("hostmem", VirtIOGPU, parent_obj.conf.hostmem, 0), + DEFINE_PROP_BIT("context_init", VirtIOGPU, parent_obj.conf.flags, + VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, false), DEFINE_PROP_END_OF_LIST(), }; From patchwork Thu Aug 31 09:32:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371170 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 A00C6C83F32 for ; Thu, 31 Aug 2023 09:34:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593588.926631 (Exim 4.92) (envelope-from ) id 1qbe41-0008N3-6N; Thu, 31 Aug 2023 09:34:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593588.926631; Thu, 31 Aug 2023 09:34:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe41-0008Mp-2S; Thu, 31 Aug 2023 09:34:09 +0000 Received: by outflank-mailman (input) for mailman id 593588; Thu, 31 Aug 2023 09:34:07 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe3z-0006tw-NO for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:34:07 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20600.outbound.protection.outlook.com [2a01:111:f400:fe59::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 86c150e7-47e1-11ee-9b0d-b553b5be7939; Thu, 31 Aug 2023 11:34:06 +0200 (CEST) Received: from BYAPR07CA0055.namprd07.prod.outlook.com (2603:10b6:a03:60::32) by DS0PR12MB6653.namprd12.prod.outlook.com (2603:10b6:8:cf::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 09:34:02 +0000 Received: from CO1PEPF000042A9.namprd03.prod.outlook.com (2603:10b6:a03:60:cafe::df) by BYAPR07CA0055.outlook.office365.com (2603:10b6:a03:60::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.22 via Frontend Transport; Thu, 31 Aug 2023 09:34:02 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042A9.mail.protection.outlook.com (10.167.243.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 09:34:02 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:33:53 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 86c150e7-47e1-11ee-9b0d-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m5rfcn8oBGGqtRZdXq+8HGlnOWxEenXH1uhgKvfPZO9ya+B6TvmbWb3oG1AFVStZJgWFcG1ApPavH3H3CUUaN56e+RpvBT/DSeaya/G4rcg2YqxCM24vcfFCDba/VhRdVkLtCX7AUqVLQzcXZr30G7RUMFZYqaSsos9yjtQlMeV+JFs/nEl7ULR84bF9aWv5LRaZJqv3G6AtEPUkuguB4XsfrhUs2+xIeYbXLRnNBN8cT6O1mNCI9DK1O38OWdXs12QpSyKFr8OnPC9u9aW0ElGtDBnib66awzkM5zSjf/OKtducLycldkjMI9/sUvPtVqqvg+W5sTpTTHhQ5e52/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=EChvqjBjhTXvURngM3ftgLfddBzxcirKgDs3+nIkeVY=; b=V+IxMdxeQNGFd/DUu3zeic00i1ja+zFUoj9G00pt74+wedolXWmmqNnC0YOhUHMIo17FZpNDZB/PisKiKvOZzNJ9Luv+MLyyOMcNcN8JU9gHnBK7K3xvuON4qHzi8inZMTr2sRbuiCE86uw4QkrvF4EJi75d/FUtV71N9j2CakVSbIsNYemRG5woM3RK13nZUJdWa1qa+9EzcYrIYZqBXg1jUDVieYLVlnFIE/CBpWHswAjIfLBrYVr9PIU47ZWUl/qX9/o3oAR9KF5RQGhEfLWRof3Ae1k+hE0DzeGxdFKy7BHCVb3l0faTuVsZv0qKzY14NCo86+f5nixZUk+xKg== 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 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=EChvqjBjhTXvURngM3ftgLfddBzxcirKgDs3+nIkeVY=; b=JhF4ZSu4+/z5dqUV07qtBD7ItTWY+u6G4OleybYKNShDquRHmStXVJVc9o3EyguC+/w44aDhucLlpQmwB4FAeINmvtI8QNeI50PQF/bcJk3gVC+1NfHUIoR+qCEsHsOtZgdb9waboPy+zYAJGA70vURlKCWVfS0oXvU4IEdr/xw= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 06/13] virtio-gpu: Configure context init for virglrenderer Date: Thu, 31 Aug 2023 17:32:45 +0800 Message-ID: <20230831093252.2461282-7-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042A9:EE_|DS0PR12MB6653:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c63b30b-12e2-48c6-2de0-08dbaa05695d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pcGdAYgEtb2TyyoQQWg3lcJW4c1rV2Qd3TrXaXTBcwiWUejwLjf0xlNIYx6+jHwLpHp7dpHIMgTC87VPALuacBGF5uMgEZcv29qcQqqRilrswpv6WMcm2aWgK+BC5TTD3e38/u5ON+OYhSYp0iFCH91s1IfyhTFNCcxHf9QJVF/aBvWUgLUeeQ/k0jmWWly3bC65JKWpVnCZN5vfCmDdH6pIToc9elIv1mBohf27bPRuf7koD0lp+2wDat83t554LSATPEju8CpdF2CoOoeZThanlP5FUMG0MoY6eQJCCSZHCICrCzrFTQWVp4M0F9Zycu3Dz40jMCMX2bOcTcYvpWMGTp/IeKzaBktf8rGUlwqIRS/TjPMF2tr9r88kdc0hmbgEWzdxqWNl4LRCEy9H0E5WWl/OLKNUhDN8FofpXGQktdL/eokKjXQFlweHJ76pgj/12KJ+UWQzzcXyQvpY574GTuUgYLgfZfw7D1lfMSY2vpsqmBF96Eozg1cfrKOnyUXjyN38VjOoi5YkzxtIqi0QTw0/05yyA5pepu0T53l8IyK7z1TpAj3wglVhLpD2ysMp8zhwjCXanLc5XpmXw/5IDMpQWtC/0tS16kngcu04K6+KYtSCs4Zx/0ZETKhIwfiLfBldLFvsSR4oaBvXaisiPcI0SbFHSq/AkytZuBw5Y9CODayMr+8HCE13yD/fgALOHUJtrw8f+jlECsnRwAaEuuIbH/RlRn25R1bQ+ZA2BscKOjfWysAy2fbsypsjWi/UhqUxnCSnRQs5pKFgrhYNTxYRaTlnoLL8cd0XvE4= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(396003)(376002)(39860400002)(136003)(186009)(82310400011)(451199024)(1800799009)(36840700001)(46966006)(40470700004)(36756003)(40460700003)(40480700001)(83380400001)(4326008)(41300700001)(86362001)(8936002)(5660300002)(7416002)(8676002)(1076003)(26005)(336012)(6666004)(16526019)(426003)(7696005)(2616005)(36860700001)(47076005)(82740400003)(110136005)(356005)(921005)(478600001)(4744005)(81166007)(2906002)(70206006)(70586007)(54906003)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:34:02.0767 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6c63b30b-12e2-48c6-2de0-08dbaa05695d 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042A9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6653 Configure context init feature flag for virglrenderer. Originally-by: Antonio Caggiano Signed-off-by: Huang Rui --- New patch, result of splitting [RFC QEMU PATCH 04/18] virtio-gpu: CONTEXT_INIT feature meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index 98e68ef0b1..ff20d3c249 100644 --- a/meson.build +++ b/meson.build @@ -1068,6 +1068,10 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu prefix: '#include ', dependencies: virgl)) endif + config_host_data.set('HAVE_VIRGL_CONTEXT_INIT', + cc.has_function('virgl_renderer_context_create_with_flags', + prefix: '#include ', + dependencies: virgl)) endif blkio = not_found if not get_option('blkio').auto() or have_block From patchwork Thu Aug 31 09:32:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371171 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 D670DC83F10 for ; Thu, 31 Aug 2023 09:34:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593598.926641 (Exim 4.92) (envelope-from ) id 1qbe4A-0000bt-EO; Thu, 31 Aug 2023 09:34:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593598.926641; Thu, 31 Aug 2023 09:34:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe4A-0000bi-BM; Thu, 31 Aug 2023 09:34:18 +0000 Received: by outflank-mailman (input) for mailman id 593598; Thu, 31 Aug 2023 09:34:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe49-0006tw-57 for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:34:17 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20617.outbound.protection.outlook.com [2a01:111:f400:7eab::617]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8c2f5240-47e1-11ee-9b0d-b553b5be7939; Thu, 31 Aug 2023 11:34:15 +0200 (CEST) Received: from BYAPR07CA0055.namprd07.prod.outlook.com (2603:10b6:a03:60::32) by CH2PR12MB5003.namprd12.prod.outlook.com (2603:10b6:610:68::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Thu, 31 Aug 2023 09:34:09 +0000 Received: from CO1PEPF000042A9.namprd03.prod.outlook.com (2603:10b6:a03:60:cafe::a1) by BYAPR07CA0055.outlook.office365.com (2603:10b6:a03:60::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.22 via Frontend Transport; Thu, 31 Aug 2023 09:34:08 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042A9.mail.protection.outlook.com (10.167.243.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 09:34:08 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:34:01 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8c2f5240-47e1-11ee-9b0d-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d8HoCiSbJyYGxsfCesVKkpuUe78FZoESbRoKIC9YXh2hXiTvt1SwB70lQaK9LxlQy7gJvB3euw/FDczW/fMVLbpdNBss1L48F3WpW7v+dKm49Y+/MuE/YpkOqKt3sm32zRINJ417JlEFqPhAyDHxEwsBI85FbRrZp1Wcynt339OK1uiJdhWKEo9YGoBFqSkC3gyRHpZzWFOehtznCQkMFWCw/ttqv/13koeMjhLME67C6CdGNURz/QszAebeKJWwhuZKHx7mnHRhOXlKYj87ThmnfQNEfKBx+YwgCvzdR+pa+02USIDIlgnWzWMIPaTq1AtJFkr3vANi5YxDiCL+Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=AeYT00pmQm0gqierfTJ00hW3jq9idCkamPMS44rd90M=; b=bK0hSVRXFVcec2NebqQ4yn1zC5FplsV+YSQT2f89jgTBgoGyJi+FH/UvQKcwmZ5bE4Ug2mHQO4BOQmu3q/PxAuAW1pU4av3ZwFQjHg3ja+aSJ2Qd3CZAcB2FEyX+uMOJwqaQUoEJ1gzofdF9wJRZ4I1UtbDV1hT1ECM7x2M+NG07ItTnaePXyOOpVHT2spE1OP5uUkZ+7+nXMIgsJ0bMNOz665EpAfVPv2bEGgAcNtPpn19zzEmbCDsimPO6QDcbn2rA63+/kd/lrGLQ7Ev1b9URiuQ/XePf7Ls4G2ezwYAFrA9qsQ/hIxipbmAiZ1HQcMqKfyFJjWnLaZEJE9InEA== 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 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=AeYT00pmQm0gqierfTJ00hW3jq9idCkamPMS44rd90M=; b=de4aJkrX5U/AgGo0ZeMp+bj4gG8ZB6fJe0XexMwqQ+eKIy6q1yQBlzjTTlmNBmuYxQQpYcJoRnieSk6JZIAggZtOC7DPl/2WAWsl2iI969YuMw3PsXRi6ZqeBiD3VmiLD3uA/gUP6XgvF2Apb9/qykYKs978V0UUtb8JwbWse6Q= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 07/13] softmmu/memory: enable automatic deallocation of memory regions Date: Thu, 31 Aug 2023 17:32:46 +0800 Message-ID: <20230831093252.2461282-8-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042A9:EE_|CH2PR12MB5003:EE_ X-MS-Office365-Filtering-Correlation-Id: d5915b9c-0019-4dfb-a24f-08dbaa056d3a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oRVVcJJ13RUqImpr8NEIQ2dAkp54ZfX4roNhXnyLp1TcM9W3UMKEnmqDn2Pcwb3bOXv9cujpRX1CUwQ8tAOLVpbbfYeTzCQLNCu6mIZyi7Atxp5AoUm3o20iEeuWDE6BvG3PnW+FWrRXF0kYC8jiFl1W+sds1+WGoygaR74zc2DkK6MnKAsbTz2sfwjqCUgVuITtfUoZyk2+uweTPyrWCq7Mh9xKpdNVSTCh/yLn11hD2SNsYqqmVkVY99BTCJq12Rd3Kj4sXLL312LS48I2B4hilUypkQ6HZTbfSelbtk0tuYhlq7F1kFbQ8/JXwBnt33t8tbsUIoCglrXTlBtW/j6c1wOw1cWYM+AmCy2WYZ9xvEDXCj048gyVIvi/dc+fhVV+F0SJtvj2mrCeBsauNPL0XLFbtkxOiZUflOEa5OEhgW92NWcoPQkcXP+6NebFZK7EDUO0NM2WwwRa9GB5bs1/AMsEpp5jomveQiDJUtQUmd5SskX7jXAJKe7JEhh2m/uWeQEGksHnie5//jsm8RwXczN2dVuOKF5Aupw14LqDF8X9S87Q67zJZN22QsD79e5eig9m+j0ocI1uqTNJzuziYpdL2U22JhXwK4zjOmO1FPWWeyWu78GB/EsgVvxTT/53J1Pt0NhjEYenWE+tFwpzKiDNJ+RF7M7gQhFWQs8bJXgIgfOzZ5twlexCzY0nlviYAvKIhEzpI0wRC7z1dpJLh85/R5zqoOdY3UYHQwBNg1iY6KpSQq4r+a5ZpitlY91CmSDIdzzFdH60TUst5rQN8D2zfxN/srAV80gG73Q= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(396003)(39860400002)(346002)(1800799009)(451199024)(186009)(82310400011)(40470700004)(36840700001)(46966006)(82740400003)(66899024)(6666004)(7696005)(40480700001)(1076003)(86362001)(36756003)(40460700003)(47076005)(921005)(36860700001)(81166007)(2616005)(356005)(426003)(478600001)(336012)(16526019)(110136005)(83380400001)(26005)(5660300002)(54906003)(4326008)(8936002)(70206006)(70586007)(2906002)(7416002)(316002)(41300700001)(8676002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:34:08.5768 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d5915b9c-0019-4dfb-a24f-08dbaa056d3a 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042A9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB5003 From: Xenia Ragiadakou When the memory region has a different life-cycle from that of her parent, could be automatically released, once has been unparent and once all of her references have gone away, via the object's free callback. However, currently, references to the memory region are held by its owner without first incrementing the memory region object's reference count. As a result, the automatic deallocation of the object, not taking into account those references, results in use-after-free memory corruption. This patch increases the reference count of the memory region object on each memory_region_ref() and decreases it on each memory_region_unref(). Signed-off-by: Xenia Ragiadakou Signed-off-by: Huang Rui --- New patch softmmu/memory.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/softmmu/memory.c b/softmmu/memory.c index 7d9494ce70..0fdd5eebf9 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -1797,6 +1797,15 @@ Object *memory_region_owner(MemoryRegion *mr) void memory_region_ref(MemoryRegion *mr) { + if (!mr) { + return; + } + + /* Obtain a reference to prevent the memory region object + * from being released under our feet. + */ + object_ref(OBJECT(mr)); + /* MMIO callbacks most likely will access data that belongs * to the owner, hence the need to ref/unref the owner whenever * the memory region is in use. @@ -1807,16 +1816,22 @@ void memory_region_ref(MemoryRegion *mr) * Memory regions without an owner are supposed to never go away; * we do not ref/unref them because it slows down DMA sensibly. */ - if (mr && mr->owner) { + if (mr->owner) { object_ref(mr->owner); } } void memory_region_unref(MemoryRegion *mr) { - if (mr && mr->owner) { + if (!mr) { + return; + } + + if (mr->owner) { object_unref(mr->owner); } + + object_unref(OBJECT(mr)); } uint64_t memory_region_size(MemoryRegion *mr) From patchwork Thu Aug 31 09:32:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371172 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 1B62BC83F10 for ; Thu, 31 Aug 2023 09:34:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593599.926652 (Exim 4.92) (envelope-from ) id 1qbe4F-00012Y-P6; Thu, 31 Aug 2023 09:34:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593599.926652; Thu, 31 Aug 2023 09:34:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe4F-00012M-JP; Thu, 31 Aug 2023 09:34:23 +0000 Received: by outflank-mailman (input) for mailman id 593599; Thu, 31 Aug 2023 09:34:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe4D-0006tw-Qd for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:34:21 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on20605.outbound.protection.outlook.com [2a01:111:f400:7eb2::605]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8f143fdb-47e1-11ee-9b0d-b553b5be7939; Thu, 31 Aug 2023 11:34:20 +0200 (CEST) Received: from BYAPR07CA0049.namprd07.prod.outlook.com (2603:10b6:a03:60::26) by CY5PR12MB6348.namprd12.prod.outlook.com (2603:10b6:930:f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21; Thu, 31 Aug 2023 09:34:16 +0000 Received: from CO1PEPF000042A9.namprd03.prod.outlook.com (2603:10b6:a03:60:cafe::7b) by BYAPR07CA0049.outlook.office365.com (2603:10b6:a03:60::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20 via Frontend Transport; Thu, 31 Aug 2023 09:34:16 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042A9.mail.protection.outlook.com (10.167.243.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 09:34:16 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:34:08 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8f143fdb-47e1-11ee-9b0d-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G06Hc0ANkjTHf1KfDwuIZ76eQLjwJvv65krvi00iHGBg+QojPRAgWVzrE+bvyPKfw3px8wYhpXKDLDnuLNYaDEsr47uX3+CuxTZgFEYDW11FCY50K4Y/fnbwAsWecS98Q9oh1KdV2LLhuuPPkGcWrEaft/6ZJMvZ+BTSRYHHpiy8505gCjr+bU3xdq2p9SjKamtCKjMbCsWXrUDi3oAVNrAO/BCvrMh/Us6Z4Km8bwX/3IEjn1BJHGsgGXfnsIe/gAEhUWMkuPSorAieusKAdFRQOwtaeQRwQ7CimrWqchru8XwnG6CvhZzzJOyHf8HTyLWakIQfTNtTHYEFTkp/DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=1+X5ZatVHqnfPO5JcziK+a+lIS1VDYzYwjEVUrRs1ww=; b=kx7NnMsj3jrq6ZkgVcFstBlGfVsfpCUpDAcIptKAwUPpMMFp+EO12Wc18hCK0NuBGehFS7FOg9FJ+eIqyn9OLts4Wwt2jzaq5pAcDPxCYDlt1wgr9rmQ2HV9jgtHtiy6s3N6YNUA2YlpoKCa8P07IoVM0U5nnQLNVy3JiC11Ah7SkgNflpsxoXbjMMmxHRRByG9KQlZZc0I5V96ixu/aBxDu9ftr1LIpDDZyHKLgb/yKyOtoRVcNNk2prpxnbQ2QIw3sHQOM1YusdHrc25ZYH9ZyPKDRCqXYUsScLenC50gir5wWTyXSJwOC0oxRS0sCHqCZCRD/s3erRIdDIcYmPw== 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 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=1+X5ZatVHqnfPO5JcziK+a+lIS1VDYzYwjEVUrRs1ww=; b=tMffFEefbmerBgeWmWDt+M4JbUDbY6mNxyraRA0dU94BL+V8HL0FutIU5kf6IntVVPn2mhogY2B+YMLh0+wz6/zD5ggT5LHFQThhB3SsRNV0AQQJ8mYUOU51KT2xmp/D/3Vw2AMOHwbu0HCDb3FnoStAZZ0P+lLM8Z0wliFRGvA= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 08/13] virtio-gpu: Don't require udmabuf when blobs and virgl are enabled Date: Thu, 31 Aug 2023 17:32:47 +0800 Message-ID: <20230831093252.2461282-9-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042A9:EE_|CY5PR12MB6348:EE_ X-MS-Office365-Filtering-Correlation-Id: c886956b-e0cd-479f-c094-08dbaa0571c3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4r2es5Rgb85nUtf4YzkQ3HSVYYvhKASodBRoTDxX2sr+BRELK0XFk5YFoazM9roAV7NY7mBQ8G3Sle8GAS3gGBGH2U5CPhRIzUCicauXN8GIkxo1EBEAding1w/BytYEH1FZ2gWqxrUf1jdUrNhTVIX6bHKevahpDOFi8H9w28OykpFmkwTfqdMA133YW29gSmYpCQwF7TeXlSrKZSa7t6dGellFIodQoXhchy+4WYUhztiS5wEv8LR/A2we0bOP+croL4CdkH1x2RA4z1w4MIxoBd//88wKpvNTLzT9TMxKRH6t2qa251SXkTT6YH5LIPEU59Gakq92qPZGenRhqKG169VYKxAFtqqlN3Cs+aeZoWnqDiDvF5e9wFSa8LVEmaHYp9ibwILld8CX2MV245bqhenLg2j84jRQHWy6OSrc0MeegThQgHKPLKutNK/U9lUrFtKojDm8208iAcRN3i92ND/ccwF3PhLRK2bvImKcovkAI43O7/jwwq12Yqn9Z2Msf1mHwrh95wz0m/kTkkQTTUkp6NecidPHzHIaVRLs+oxYo7c1doz9TJ3TKtS3pqQ9aRHvlmMnSKvWedwneXlFn/Z7N9LqzOpjlL9k/b96IkDsZz00yblOTQvcmFm5o4xpmm5acH+WX0G1Q7o6PRZrkggOERIAfUPiDLuGSBoWElMQc7XzowLSJ2XoJaem2mdhT6I89EAkdtkVxp9YYYrYORsrYIVeAqkQQTZZopKLgjEPd8dkaCKZJ6vApvzQm4GtYbSrJTw/YHtyUdVyxU7HSpKZSgqtAdGSM+PUT/Q= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(376002)(136003)(346002)(396003)(39860400002)(82310400011)(451199024)(1800799009)(186009)(36840700001)(46966006)(40470700004)(6666004)(7696005)(478600001)(83380400001)(1076003)(2616005)(2906002)(336012)(426003)(26005)(16526019)(7416002)(316002)(54906003)(41300700001)(70206006)(70586007)(110136005)(5660300002)(8676002)(4326008)(8936002)(40460700003)(36756003)(40480700001)(47076005)(86362001)(36860700001)(81166007)(356005)(82740400003)(921005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:34:16.1863 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c886956b-e0cd-479f-c094-08dbaa0571c3 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042A9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6348 From: Dmitry Osipenko The udmabuf usage is mandatory when virgl is disabled and blobs feature enabled in the Qemu machine configuration. If virgl and blobs are enabled, then udmabuf requirement is optional. Since udmabuf isn't widely supported by a popular Linux distros today, let's relax the udmabuf requirement for blobs=on,virgl=on. Now, a full-featured virtio-gpu acceleration is available to Qemu users without a need to have udmabuf available in the system. Reviewed-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Huang Rui --- New patch hw/display/virtio-gpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index a66cbd9930..5b7a7eab4f 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1361,7 +1361,8 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) VirtIOGPU *g = VIRTIO_GPU(qdev); if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { - if (!virtio_gpu_have_udmabuf()) { + if (!virtio_gpu_virgl_enabled(g->parent_obj.conf) && + !virtio_gpu_have_udmabuf()) { error_setg(errp, "cannot enable blob resources without udmabuf"); return; } From patchwork Thu Aug 31 09:32:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371179 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 49AFEC83F10 for ; Thu, 31 Aug 2023 09:44:46 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593667.926711 (Exim 4.92) (envelope-from ) id 1qbeE7-0007TL-56; Thu, 31 Aug 2023 09:44:35 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593667.926711; Thu, 31 Aug 2023 09:44:35 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbeE7-0007TE-2Z; Thu, 31 Aug 2023 09:44:35 +0000 Received: by outflank-mailman (input) for mailman id 593667; Thu, 31 Aug 2023 09:44:34 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe4M-0005pR-0u for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:34:30 +0000 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20607.outbound.protection.outlook.com [2a01:111:f400:fe5a::607]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 93f1b051-47e1-11ee-8783-cb3800f73035; Thu, 31 Aug 2023 11:34:28 +0200 (CEST) Received: from MW4PR03CA0307.namprd03.prod.outlook.com (2603:10b6:303:dd::12) by PH8PR12MB6794.namprd12.prod.outlook.com (2603:10b6:510:1c5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Thu, 31 Aug 2023 09:34:24 +0000 Received: from CO1PEPF000042AA.namprd03.prod.outlook.com (2603:10b6:303:dd:cafe::c2) by MW4PR03CA0307.outlook.office365.com (2603:10b6:303:dd::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21 via Frontend Transport; Thu, 31 Aug 2023 09:34:23 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042AA.mail.protection.outlook.com (10.167.243.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.16 via Frontend Transport; Thu, 31 Aug 2023 09:34:23 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:34:15 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 93f1b051-47e1-11ee-8783-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B/ZQUTplMbdK/Qnzhj+Mwaluv/s+ph7M6AUw8GWvKECepIIUR+/z9xH//0dCnek7i8pcddxB9X5IWre2hffTGaCa+CFI2IJAf1LtSpwx9RrEYNFozV8t5Vl+k5tiMpJozIFx82kPZoPagtTrzLNcdxJoR5GP39gYnJm7V5gAcKhr8bQtYWX66VtxcHW98Hpt4jpbgRmLbOxLF9rkioicgdJnQV/roGYdMGlIERCZb91QUKvRenV/arXqlcHJ1/6rByfGwYZLu9gThbAVRqIYynZmZJbYWyT5lD7drYpNGlNWRt1aLPeazictYUTaq6EyDIK1mrLN8cLUeC4O4mBnoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=vlX5KH0Nob6MtW1WHMcMYsv6Nyb/7dx++kxZ3zavhUc=; b=euoUT/HAEqlxERXXqYWXivccnuuDdLUzRw0T/ZiTLZCbUvgexsPnuiEB88bpZyVJ0CZ5FIRDr3Lacv1M6KecJlw1PVi3EhQcZGBVA6jdfSw7j+P5BD433Opx3oshkucSRNVe1IrJRmgluY64EXmIoxGfLGoeZWN3EaRvosg2xzWDubAqIsS2zdiuUXCAhKNBFZvhkQXJengNX++Wk6f3u8qH5rk9CdEhcsJdQaoDPTJgHTl+jQoTzXi8dWCIZtECafdLUMv4ygokBiyYnRN6RVJj6ffXN1Q6euorVb7a6EDM/YKlCpZFWQk3ttMb5yFws9lLMIIghUIGHn66xKiDsA== 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 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=vlX5KH0Nob6MtW1WHMcMYsv6Nyb/7dx++kxZ3zavhUc=; b=nQYr6GokErfb+r1vdRCSnagBVGyI81Dsv0upDnCfF4RilPTKx2yv+Hx88K8rqXXQUP/+1ryc8r6VOOdbaCJLcMiwi8n2yPOEQCXj44Dl7yZD71eDWl4HAzs4Qm0JpD6tNbmGOJLOyAwky9IAtHYZqq7vS2Kx9L52Suai0DKq7VA= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 09/13] virtio-gpu: Handle resource blob commands Date: Thu, 31 Aug 2023 17:32:48 +0800 Message-ID: <20230831093252.2461282-10-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AA:EE_|PH8PR12MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e55a5e7-c5ba-4dc3-5c73-08dbaa057646 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RM15CUw7CIpAD8sdpRNmA0lqtZbVQVqbpXCnrS0A5tSJB1DhU9CFVeiFjeIa0K1b/MAgJeZtB2awow4wfSIAuY3Ajyi4E1/PgRiothED75z9LVx2PJ2En4EWqg5QeAlZ0bYoZCBilIBVm/4+m/9ewwBMsYqOe7maiKzMuv6eD3L9xRMeAxp5OMtPkdJpeffDdlmNMZBh9gu7WruepIM0cs+gJFIvKt3okp2VdthmCCrivctknv3jzB9oRCVYU1toXdizYIBg0Wm9N3qCDukDwS/p2lwZzYuaRngeS8J5ChE7yVImHwAdit2Vzhe5LFOj/9fTKarx8Cb1v6g1uio90ybcdlXMmySO0lvpRgy7ab/GuQyJrxP5jkPMCDcA5r6R92IA2z5wL6jRwZ35a0KVvmmtqJ4K0Eld4sdZifmf+77L94vjbO9W4v1i031VEITf2BZ+CLgiaJIT4o715DHnGiQRUuiQK+nTWE4/EN9rm+v6zk+IpPtCfYDm8g7HEvYO2dgUp7jZ4M60c3lpwxKB3JfmSXVPSPg1F+BgmLnVKLhcMKpPzjqfjoZCoLqiJ45yxpx200eM45Aq1ZrhP+B/xDg9nJ2oCVHOu5m3McoagWwckaAM/Z9Y80+zNA/asPEIMqul9asIiNg0PyauiOvpLedZdVt626YIwbb37g4nR98nLxlZqIkid4bPNWpKVyqbAzrUBf/rw89bFzhdObl5VNc903kH87Ge28nk8n+Dh4DCxNCN5tUMdQrbk2LVC/lokQ7me2Q2Mu1uNaMiXe7M3XKinAEuVJRUEr9WYnxPNVg= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(346002)(376002)(396003)(136003)(451199024)(1800799009)(186009)(82310400011)(46966006)(36840700001)(40470700004)(4326008)(7696005)(6666004)(41300700001)(478600001)(110136005)(83380400001)(1076003)(26005)(336012)(8676002)(30864003)(54906003)(16526019)(7416002)(2616005)(70206006)(316002)(70586007)(5660300002)(40460700003)(36756003)(40480700001)(47076005)(356005)(2906002)(36860700001)(426003)(81166007)(86362001)(921005)(8936002)(82740400003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:34:23.7531 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e55a5e7-c5ba-4dc3-5c73-08dbaa057646 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6794 From: Antonio Caggiano Support BLOB resources creation, mapping and unmapping by calling the new stable virglrenderer 0.10 interface. Only enabled when available and via the blob config. E.g. -device virtio-vga-gl,blob=true Signed-off-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Signed-off-by: Xenia Ragiadakou Signed-off-by: Huang Rui --- v1->v2: - Remove unused #include "hw/virtio/virtio-iommu.h" - Add a local function, called virgl_resource_destroy(), that is used to release a vgpu resource on error paths and in resource_unref. - Remove virtio_gpu_virgl_resource_unmap from virtio_gpu_cleanup_mapping(), since this function won't be called on blob resources and also because blob resources are unmapped via virgl_cmd_resource_unmap_blob(). - In virgl_cmd_resource_create_blob(), do proper cleanup in error paths and move QTAILQ_INSERT_HEAD(&g->reslist, res, next) after the resource has been fully initialized. - Memory region has a different life-cycle from virtio gpu resources i.e. cannot be released synchronously along with the vgpu resource. So, here the field "region" was changed to a pointer that will be released automatically once the memory region is unparented and all of its references have been released. Also, since the pointer can be used to indicate whether the blob is mapped, the explicit field "mapped" was removed. - In virgl_cmd_resource_map_blob(), add check on the value of res->region, to prevent beeing called twice on the same resource. - Remove direct references to parent_obj. - Separate declarations from code. hw/display/virtio-gpu-virgl.c | 213 +++++++++++++++++++++++++++++++++ hw/display/virtio-gpu.c | 4 +- include/hw/virtio/virtio-gpu.h | 5 + meson.build | 4 + 4 files changed, 225 insertions(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 312953ec16..17b634d4ee 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -17,6 +17,7 @@ #include "trace.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-gpu.h" +#include "hw/virtio/virtio-gpu-bswap.h" #include "ui/egl-helpers.h" @@ -78,9 +79,24 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g, virgl_renderer_resource_create(&args, NULL, 0); } +static void virgl_resource_destroy(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) +{ + if (!res) + return; + + QTAILQ_REMOVE(&g->reslist, res, next); + + virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); + g_free(res->addrs); + + g_free(res); +} + static void virgl_cmd_resource_unref(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { + struct virtio_gpu_simple_resource *res; struct virtio_gpu_resource_unref unref; struct iovec *res_iovs = NULL; int num_iovs = 0; @@ -88,13 +104,22 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g, VIRTIO_GPU_FILL_CMD(unref); trace_virtio_gpu_cmd_res_unref(unref.resource_id); + res = virtio_gpu_find_resource(g, unref.resource_id); + virgl_renderer_resource_detach_iov(unref.resource_id, &res_iovs, &num_iovs); if (res_iovs != NULL && num_iovs != 0) { virtio_gpu_cleanup_mapping_iov(g, res_iovs, num_iovs); + if (res) { + res->iov = NULL; + res->iov_cnt = 0; + } } + virgl_renderer_resource_unref(unref.resource_id); + + virgl_resource_destroy(g, res); } static void virgl_cmd_context_create(VirtIOGPU *g, @@ -426,6 +451,183 @@ static void virgl_cmd_get_capset(VirtIOGPU *g, g_free(resp); } +#ifdef HAVE_VIRGL_RESOURCE_BLOB + +static void virgl_cmd_resource_create_blob(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd) +{ + struct virtio_gpu_simple_resource *res; + struct virtio_gpu_resource_create_blob cblob; + struct virgl_renderer_resource_create_blob_args virgl_args = { 0 }; + int ret; + + VIRTIO_GPU_FILL_CMD(cblob); + virtio_gpu_create_blob_bswap(&cblob); + trace_virtio_gpu_cmd_res_create_blob(cblob.resource_id, cblob.size); + + if (cblob.resource_id == 0) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n", + __func__); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res = virtio_gpu_find_resource(g, cblob.resource_id); + if (res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n", + __func__, cblob.resource_id); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res = g_new0(struct virtio_gpu_simple_resource, 1); + if (!res) { + cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY; + return; + } + + res->resource_id = cblob.resource_id; + res->blob_size = cblob.size; + + if (cblob.blob_mem != VIRTIO_GPU_BLOB_MEM_HOST3D) { + ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(cblob), + cmd, &res->addrs, &res->iov, + &res->iov_cnt); + if (!ret) { + g_free(res); + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + } + + QTAILQ_INSERT_HEAD(&g->reslist, res, next); + + virgl_args.res_handle = cblob.resource_id; + virgl_args.ctx_id = cblob.hdr.ctx_id; + virgl_args.blob_mem = cblob.blob_mem; + virgl_args.blob_id = cblob.blob_id; + virgl_args.blob_flags = cblob.blob_flags; + virgl_args.size = cblob.size; + virgl_args.iovecs = res->iov; + virgl_args.num_iovs = res->iov_cnt; + + ret = virgl_renderer_resource_create_blob(&virgl_args); + if (ret) { + virgl_resource_destroy(g, res); + qemu_log_mask(LOG_GUEST_ERROR, "%s: virgl blob create error: %s\n", + __func__, strerror(-ret)); + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + } +} + +static void virgl_cmd_resource_map_blob(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd) +{ + struct virtio_gpu_simple_resource *res; + struct virtio_gpu_resource_map_blob mblob; + int ret; + void *data; + uint64_t size; + struct virtio_gpu_resp_map_info resp; + VirtIOGPUBase *b = VIRTIO_GPU_BASE(g); + + VIRTIO_GPU_FILL_CMD(mblob); + virtio_gpu_map_blob_bswap(&mblob); + + if (mblob.resource_id == 0) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n", + __func__); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res = virtio_gpu_find_resource(g, mblob.resource_id); + if (!res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource does not exist %d\n", + __func__, mblob.resource_id); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + if (res->region) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already mapped %d\n", + __func__, mblob.resource_id); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + ret = virgl_renderer_resource_map(res->resource_id, &data, &size); + if (ret) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource map error: %s\n", + __func__, strerror(-ret)); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res->region = g_new0(MemoryRegion, 1); + if (!res->region) { + virgl_renderer_resource_unmap(res->resource_id); + cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY; + return; + } + memory_region_init_ram_device_ptr(res->region, OBJECT(g), NULL, size, data); + OBJECT(res->region)->free = g_free; + memory_region_add_subregion(&b->hostmem, mblob.offset, res->region); + memory_region_set_enabled(res->region, true); + + memset(&resp, 0, sizeof(resp)); + resp.hdr.type = VIRTIO_GPU_RESP_OK_MAP_INFO; + virgl_renderer_resource_get_map_info(mblob.resource_id, &resp.map_info); + virtio_gpu_ctrl_response(g, cmd, &resp.hdr, sizeof(resp)); +} + +static int virtio_gpu_virgl_resource_unmap(VirtIOGPU *g, + struct virtio_gpu_simple_resource + *res) +{ + VirtIOGPUBase *b = VIRTIO_GPU_BASE(g); + + if (!res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already unmapped %d\n", + __func__, res->resource_id); + return VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + } + + memory_region_set_enabled(res->region, false); + memory_region_del_subregion(&b->hostmem, res->region); + object_unparent(OBJECT(res->region)); + res->region = NULL; + + return virgl_renderer_resource_unmap(res->resource_id); +} + +static void virgl_cmd_resource_unmap_blob(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd) +{ + struct virtio_gpu_simple_resource *res; + struct virtio_gpu_resource_unmap_blob ublob; + VIRTIO_GPU_FILL_CMD(ublob); + virtio_gpu_unmap_blob_bswap(&ublob); + + if (ublob.resource_id == 0) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource id 0 is not allowed\n", + __func__); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res = virtio_gpu_find_resource(g, ublob.resource_id); + if (!res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource does not exist %d\n", + __func__, ublob.resource_id); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + virtio_gpu_virgl_resource_unmap(g, res); +} + +#endif /* HAVE_VIRGL_RESOURCE_BLOB */ + void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { @@ -492,6 +694,17 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, case VIRTIO_GPU_CMD_GET_EDID: virtio_gpu_get_edid(g, cmd); break; +#ifdef HAVE_VIRGL_RESOURCE_BLOB + case VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB: + virgl_cmd_resource_create_blob(g, cmd); + break; + case VIRTIO_GPU_CMD_RESOURCE_MAP_BLOB: + virgl_cmd_resource_map_blob(g, cmd); + break; + case VIRTIO_GPU_CMD_RESOURCE_UNMAP_BLOB: + virgl_cmd_resource_unmap_blob(g, cmd); + break; +#endif /* HAVE_VIRGL_RESOURCE_BLOB */ default: cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; break; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5b7a7eab4f..cc4c1f81bb 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1367,10 +1367,12 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) return; } +#ifndef HAVE_VIRGL_RESOURCE_BLOB if (virtio_gpu_virgl_enabled(g->parent_obj.conf)) { - error_setg(errp, "blobs and virgl are not compatible (yet)"); + error_setg(errp, "Linked virglrenderer does not support blob resources"); return; } +#endif } if (!virtio_gpu_base_device_realize(qdev, diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 55973e112f..b9adc28071 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -58,6 +58,11 @@ struct virtio_gpu_simple_resource { int dmabuf_fd; uint8_t *remapped; +#ifdef HAVE_VIRGL_RESOURCE_BLOB + /* only blob resource needs this region to be mapped as guest mmio */ + MemoryRegion *region; +#endif + QTAILQ_ENTRY(virtio_gpu_simple_resource) next; }; diff --git a/meson.build b/meson.build index ff20d3c249..f7b744ab82 100644 --- a/meson.build +++ b/meson.build @@ -1072,6 +1072,10 @@ if not get_option('virglrenderer').auto() or have_system or have_vhost_user_gpu cc.has_function('virgl_renderer_context_create_with_flags', prefix: '#include ', dependencies: virgl)) + config_host_data.set('HAVE_VIRGL_RESOURCE_BLOB', + cc.has_function('virgl_renderer_resource_create_blob', + prefix: '#include ', + dependencies: virgl)) endif blkio = not_found if not get_option('blkio').auto() or have_block From patchwork Thu Aug 31 09:32:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371178 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 78C7EC83F10 for ; Thu, 31 Aug 2023 09:44:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593660.926701 (Exim 4.92) (envelope-from ) id 1qbeDb-0006n2-UR; Thu, 31 Aug 2023 09:44:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593660.926701; Thu, 31 Aug 2023 09:44:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbeDb-0006mv-Qu; Thu, 31 Aug 2023 09:44:03 +0000 Received: by outflank-mailman (input) for mailman id 593660; Thu, 31 Aug 2023 09:44:03 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe4W-0006tw-BN for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:34:40 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20621.outbound.protection.outlook.com [2a01:111:f400:7e88::621]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 99e3ba4d-47e1-11ee-9b0d-b553b5be7939; Thu, 31 Aug 2023 11:34:38 +0200 (CEST) Received: from SJ0PR03CA0026.namprd03.prod.outlook.com (2603:10b6:a03:33a::31) by CY5PR12MB6551.namprd12.prod.outlook.com (2603:10b6:930:41::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Thu, 31 Aug 2023 09:34:34 +0000 Received: from CO1PEPF000042AC.namprd03.prod.outlook.com (2603:10b6:a03:33a:cafe::95) by SJ0PR03CA0026.outlook.office365.com (2603:10b6:a03:33a::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.36 via Frontend Transport; Thu, 31 Aug 2023 09:34:34 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042AC.mail.protection.outlook.com (10.167.243.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 09:34:34 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:34:23 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 99e3ba4d-47e1-11ee-9b0d-b553b5be7939 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k92cN5PlgipFyRJ32ahis5g4FYAMVqHXpau5Rf+U10mpc/+1qDu/Gis0JXdJ8UZ/NHlMeFdVdpy5Q6MjeKsB6UFW/Sfk1yVFQeh9w4dkQTR9266YRkT3LN9LNoL4/ENBeAohQ8uSoKUVAYZaGO0R8Dfmqnv9dxxw+h9Hcs0zrwf0KDf1OlpRhQ/KgTUonSfwJF4KsKK9V4q8jJnhwptkyo65GzUXrBJ6yolYQM7gSjqosblwPfDmpfCYfapt+A9ogbbEXQE44sBbyzjMv/S3lwavN5M4x7LKhZNbg6V9G9iB+lD5optv/R5/lUQNnBYFOkaPwjAYx9M1Bc2mwijs6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=DbK7uQJAi4F+V8q90U5xPcs4Q6zHnO90JXJwecm4cY8=; b=NBayjyZc3qG6hcnE5YOdQFmKrXfIIPtz0qT3DOwg9pqJtksKzDzp/XB1KC231hqI6NxEnWUMdbV4qyrlpeXB15FsyivneVmgu1kLrYtGUhmkuXlGUNpM3WxAXpiMpUeZCwzZIZ1DB7zERjou+D98xgCDeYQWyKSxgZJsDlDix6b+0jo4vrG+XIi6zebStsbe3ZE5tYRkq/b6cpSFthVozMQoH6x4BW4TgrYJTBipABbjV+6NloVTb3CjBngYJ6IVq7zEZabYpSswLHi4p5ZiZVqB8NuyUMx0bWTFh7reRk/lb7xBkrHxF8KUrPfdptzAGm/x3CUS5mPziF62mFW2oQ== 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 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=DbK7uQJAi4F+V8q90U5xPcs4Q6zHnO90JXJwecm4cY8=; b=5UuETFR46bJz8B28pSr3U9SeIQ4MIketeFXIuObAoeyrQKKpcu5B7ixhjjDlcv08xL6QjrLsUOgIBO/tWOkXUxkrHfKTnwvSf8PoAOM3XHQUfPByXLaOIQUbHBLpHoZfjm0n07fdyf6Sf5U5LZWdM/QsdyWJ/6QUtfI2twpwTg4= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 10/13] virtio-gpu: Resource UUID Date: Thu, 31 Aug 2023 17:32:49 +0800 Message-ID: <20230831093252.2461282-11-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AC:EE_|CY5PR12MB6551:EE_ X-MS-Office365-Filtering-Correlation-Id: e28bab9a-91f4-4dba-e765-08dbaa057ca0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cz/qFE0StWNbTwTbEQxauRg6cFi5JjH4Q3ZwLu14kiY2f/XzLEYC2uiDMcuRq4x4AoDwz/Kd1VjO/ssbQeijuQBciffUQ4SNTpLawnMnL9XAuRFHmx10y+tat0Id2PZuzZpoqFuSNeWkjrbLtSIEFXrPx1ubACRNkS3acgJjwvIUWMfdZct2vmMeqD/CvEb/bl4J4vNGgfQSiSBEwnzeDJQr6LSCEerOj1txi1fLxnd2oc9j6M1FzhfRa8/m37lWNMvdWLXdFwJt/AwxVJ0kIRLZs+Br70kxny2T9BMrKiPPa82L9XXtz/FT2KfFHm65ErTAMoJQG5yq0hdvuZl6FfdXhtpD4HAUQuQ97n4SL41NEcVD2Z0Omj+Gk0KK+CQCwn220XIntVqX6XY4pV3bYm5uKxZJzxQJCbqRk7j8q/eNZtggzrQrUM+rM5cWMRy7w943xOcOdx8bbybTCTpBsMOJdZiCMUXwSrHs6DW4h04hqJWMRdYivspuvEJ65FoMG/bC0OdrZDQmpRcQRFgfO0O+CvJvFIBJ3HH1TUld7mzVZh0eb+QGy7QRAbfqCYUPWhgZ0K9zeTQsRbV3euANaLyZQ4GTWBDCrdg3rj1psYy1o+69C4iMw0yKMGw10iGIgqQ6M32ckb5xXwqpbtBbUBV3bFa+HsdKMsKb9rcMHFI0J+yCEiO+r36KlqHtSskebBETG/kzpGsCqm70tPRNHyvFkouBgBIa7jNRBExxkUE9KGLuZoPQtSq6T1ACTdHcMPvAFSh3JxBbBbVaSvwyA8j2Kwz3YTI65B5GYw/PRhA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(346002)(396003)(376002)(136003)(82310400011)(451199024)(1800799009)(186009)(40470700004)(36840700001)(46966006)(426003)(40460700003)(316002)(41300700001)(5660300002)(336012)(4326008)(7416002)(8676002)(47076005)(16526019)(83380400001)(2616005)(86362001)(26005)(36756003)(1076003)(36860700001)(2906002)(40480700001)(8936002)(6666004)(356005)(82740400003)(81166007)(921005)(7696005)(54906003)(70206006)(70586007)(478600001)(110136005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:34:34.4129 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e28bab9a-91f4-4dba-e765-08dbaa057ca0 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6551 From: Antonio Caggiano Enable resource UUID feature and implement command resource assign UUID. This is done by introducing a hash table to map resource IDs to their UUIDs. Signed-off-by: Antonio Caggiano Signed-off-by: Huang Rui --- v1->v2: - Separate declarations from code. hw/display/trace-events | 1 + hw/display/virtio-gpu-base.c | 2 ++ hw/display/virtio-gpu-virgl.c | 21 +++++++++++++++++ hw/display/virtio-gpu.c | 41 ++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-gpu.h | 4 ++++ 5 files changed, 69 insertions(+) diff --git a/hw/display/trace-events b/hw/display/trace-events index 2336a0ca15..54d6894c59 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -41,6 +41,7 @@ virtio_gpu_cmd_res_create_blob(uint32_t res, uint64_t size) "res 0x%x, size %" P virtio_gpu_cmd_res_unref(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_back_attach(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_back_detach(uint32_t res) "res 0x%x" +virtio_gpu_cmd_res_assign_uuid(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_xfer_toh_2d(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_xfer_toh_3d(uint32_t res) "res 0x%x" virtio_gpu_cmd_res_xfer_fromh_3d(uint32_t res) "res 0x%x" diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 4f2b0ba1f3..f44388715c 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -236,6 +236,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64_t features, features |= (1 << VIRTIO_GPU_F_CONTEXT_INIT); } + features |= (1 << VIRTIO_GPU_F_RESOURCE_UUID); + return features; } diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 17b634d4ee..1a996a08fc 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -36,6 +36,7 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g, { struct virtio_gpu_resource_create_2d c2d; struct virgl_renderer_resource_create_args args; + struct virtio_gpu_simple_resource *res; VIRTIO_GPU_FILL_CMD(c2d); trace_virtio_gpu_cmd_res_create_2d(c2d.resource_id, c2d.format, @@ -53,6 +54,14 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g, args.nr_samples = 0; args.flags = VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP; virgl_renderer_resource_create(&args, NULL, 0); + + res = g_new0(struct virtio_gpu_simple_resource, 1); + if (!res) { + cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY; + return; + } + res->resource_id = c2d.resource_id; + QTAILQ_INSERT_HEAD(&g->reslist, res, next); } static void virgl_cmd_create_resource_3d(VirtIOGPU *g, @@ -60,6 +69,7 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g, { struct virtio_gpu_resource_create_3d c3d; struct virgl_renderer_resource_create_args args; + struct virtio_gpu_simple_resource *res; VIRTIO_GPU_FILL_CMD(c3d); trace_virtio_gpu_cmd_res_create_3d(c3d.resource_id, c3d.format, @@ -77,6 +87,14 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g, args.nr_samples = c3d.nr_samples; args.flags = c3d.flags; virgl_renderer_resource_create(&args, NULL, 0); + + res = g_new0(struct virtio_gpu_simple_resource, 1); + if (!res) { + cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY; + return; + } + res->resource_id = c3d.resource_id; + QTAILQ_INSERT_HEAD(&g->reslist, res, next); } static void virgl_resource_destroy(VirtIOGPU *g, @@ -682,6 +700,9 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, /* TODO add security */ virgl_cmd_ctx_detach_resource(g, cmd); break; + case VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID: + virtio_gpu_resource_assign_uuid(g, cmd); + break; case VIRTIO_GPU_CMD_GET_CAPSET_INFO: virgl_cmd_get_capset_info(g, cmd); break; diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index cc4c1f81bb..770e4747e3 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -966,6 +966,37 @@ virtio_gpu_resource_detach_backing(VirtIOGPU *g, virtio_gpu_cleanup_mapping(g, res); } +void virtio_gpu_resource_assign_uuid(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd) +{ + struct virtio_gpu_simple_resource *res; + struct virtio_gpu_resource_assign_uuid assign; + struct virtio_gpu_resp_resource_uuid resp; + QemuUUID *uuid = NULL; + + VIRTIO_GPU_FILL_CMD(assign); + virtio_gpu_bswap_32(&assign, sizeof(assign)); + trace_virtio_gpu_cmd_res_assign_uuid(assign.resource_id); + + res = virtio_gpu_find_check_resource(g, assign.resource_id, false, __func__, &cmd->error); + if (!res) { + return; + } + + memset(&resp, 0, sizeof(resp)); + resp.hdr.type = VIRTIO_GPU_RESP_OK_RESOURCE_UUID; + + uuid = g_hash_table_lookup(g->resource_uuids, GUINT_TO_POINTER(assign.resource_id)); + if (!uuid) { + uuid = g_new(QemuUUID, 1); + qemu_uuid_generate(uuid); + g_hash_table_insert(g->resource_uuids, GUINT_TO_POINTER(assign.resource_id), uuid); + } + + memcpy(resp.uuid, uuid, sizeof(QemuUUID)); + virtio_gpu_ctrl_response(g, cmd, &resp.hdr, sizeof(resp)); +} + void virtio_gpu_simple_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { @@ -1014,6 +1045,9 @@ void virtio_gpu_simple_process_cmd(VirtIOGPU *g, case VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING: virtio_gpu_resource_detach_backing(g, cmd); break; + case VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID: + virtio_gpu_resource_assign_uuid(g, cmd); + break; default: cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; break; @@ -1393,12 +1427,15 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) QTAILQ_INIT(&g->reslist); QTAILQ_INIT(&g->cmdq); QTAILQ_INIT(&g->fenceq); + + g->resource_uuids = g_hash_table_new_full(NULL, NULL, NULL, g_free); } static void virtio_gpu_device_unrealize(DeviceState *qdev) { VirtIOGPU *g = VIRTIO_GPU(qdev); + g_hash_table_destroy(g->resource_uuids); g_clear_pointer(&g->ctrl_bh, qemu_bh_delete); g_clear_pointer(&g->cursor_bh, qemu_bh_delete); g_clear_pointer(&g->reset_bh, qemu_bh_delete); @@ -1452,6 +1489,10 @@ void virtio_gpu_reset(VirtIODevice *vdev) g_free(cmd); } + if (g->resource_uuids) { + g_hash_table_remove_all(g->resource_uuids); + } + virtio_gpu_base_reset(VIRTIO_GPU_BASE(vdev)); } diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index b9adc28071..aa94b1b697 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -208,6 +208,8 @@ struct VirtIOGPU { QTAILQ_HEAD(, VGPUDMABuf) bufs; VGPUDMABuf *primary[VIRTIO_GPU_MAX_SCANOUTS]; } dmabuf; + + GHashTable *resource_uuids; }; struct VirtIOGPUClass { @@ -285,6 +287,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); void virtio_gpu_cleanup_mapping(VirtIOGPU *g, struct virtio_gpu_simple_resource *res); +void virtio_gpu_resource_assign_uuid(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev); From patchwork Thu Aug 31 09:32:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371173 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 F241EC83F10 for ; Thu, 31 Aug 2023 09:41:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593626.926671 (Exim 4.92) (envelope-from ) id 1qbeAS-0004F9-S8; Thu, 31 Aug 2023 09:40:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593626.926671; Thu, 31 Aug 2023 09:40:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbeAS-0004F2-P2; Thu, 31 Aug 2023 09:40:48 +0000 Received: by outflank-mailman (input) for mailman id 593626; Thu, 31 Aug 2023 09:40:47 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe4d-0005pR-2v for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:34:47 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20614.outbound.protection.outlook.com [2a01:111:f400:7eab::614]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 9e974a5b-47e1-11ee-8783-cb3800f73035; Thu, 31 Aug 2023 11:34:46 +0200 (CEST) Received: from SJ0PR13CA0105.namprd13.prod.outlook.com (2603:10b6:a03:2c5::20) by SN7PR12MB7419.namprd12.prod.outlook.com (2603:10b6:806:2a6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Thu, 31 Aug 2023 09:34:42 +0000 Received: from CO1PEPF000042AE.namprd03.prod.outlook.com (2603:10b6:a03:2c5:cafe::79) by SJ0PR13CA0105.outlook.office365.com (2603:10b6:a03:2c5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18 via Frontend Transport; Thu, 31 Aug 2023 09:34:41 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042AE.mail.protection.outlook.com (10.167.243.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 09:34:41 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:34:33 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 9e974a5b-47e1-11ee-8783-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UGjl2NGlswrqBZCj7671tYCOZpD2NuDesuEVau5Sp5XsAc0NcP9HYISnfeztfSmU+z3r65mEdPA540hly1Qlp3UP2MoXH7+mlOOPfX/ssbh1JgCkbMQ5rlDQaJz+SpD3VsBlAlkbtT1C7omLTy+SMa/HK1Ja8p1OqNJlbAbDK1ha1HJZYQg0dCJYAUpxdNw/47JB00CPWiVNrRGJd4c0oL9vm68yFLwaPwU1SrART6LGKH39CGWYZKIJCLvWkTTC5Ph1IkQ/gcP7WIGPYJX5+I69LdT72kicrJYRiiVXOQlEjVBJmdEtsU2riRot3/nII+4SO3ftSFcrSfIW3qDHtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=7jKl0Cln6cyhAJBoLYKE6z9NzKJbaZOSW+kOo6d5qjw=; b=oB++OdzYAxAOLWwAQckIGiNZ9GA6SQM1L1YkwShr0FtJQn3kr0EtrnOR2/CFjdyhcnemxUMbrdZI2cwkj5iLX7Pu9GqIBhUatJhPz8ZXMOrhpJcR8whBqhUeB6BLp02LJjv8PjCdNS9r/M5xolYJ5yu4ge5XV2SyAfzgxJaUXdgmGq8qB4mzFRRwer3QFyqBqfE+78mDTirFLssYRgukuBSkcKQZ5KFlfcog+RdS67hSK5wiQCNwV2HoRyD+R4s5ZfVprb3WvXCsQ3d41mEIT4dx4D2wO5R13cqONO1V0UWxlC/e7m1cDTKjgvBnb4oQ0VT2nzp/dCukOt2GUCO9Sw== 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 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=7jKl0Cln6cyhAJBoLYKE6z9NzKJbaZOSW+kOo6d5qjw=; b=mXF1xyXyPcKY9wWTofBEF3Tq3dRF03jDbPyyRRbf1hM322av227XY8oC2BF/emjr+omJAfcGTdMUnVugLF8mPg3SV8jTO0AccznJGOc61Fpjf1M9U/h3MnrVg3i73PWax8mO/MPkWrU94YFENxBDQoSDYnl0P1pCfOZuwpgSPD4= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 11/13] virtio-gpu: Support Venus capset Date: Thu, 31 Aug 2023 17:32:50 +0800 Message-ID: <20230831093252.2461282-12-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AE:EE_|SN7PR12MB7419:EE_ X-MS-Office365-Filtering-Correlation-Id: ec34e4a0-b066-4d47-1f4d-08dbaa0580e1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PD6SdGS+R700jXDVgrH0gg2uCJrEQY+Wy07I6QwbVMDEyuDFsXSg5sWCgm+zonTHCd6kxAFcfKDujVf2dwftmLVdon1v+/KX8aP8nhlIbR4eVmK8A7RNkgAaNfo7xTDUNMrF2WjlbYpQBQjA5PXHgaUdY8tKZ9VjYjv2FdNV1Ep206TN17rqz4xh+6oaHvUWdRjuGL/0Mo+cKG+YmSv/nDgayWnHR0LWEPZ67+0C2oOHHeRmkAJ7KY1wtlcyZjxq8xm6+jEj5SLoOyfyMdwT/iLrkii+QHcFQfLJFzIJGfIsC7v+tvW1IHyJHOA8PEftyjmCdFzDHjQhmreTT6ETmMuYV60BiZapTZxnvB1nZGsa/y6VMwuJTpWx9gQXI1hf9qiNCuKMdJf7cljUvV6O7bzaJA75jzHfp5vZ+jtVtQ8asZj0bU9QwOYrqhYfImUmY/nbo5dJnTuZne3RnRf5rOVQOWFKDuaNMGe+LhfPZBalfyO7kQUeywTHgFsnYWBWIXnO9bA/sKvbie5JV3mP9MfmY73IO6WPE6+GtoMpRdIWH0AkfA9zmhoYAtZdYWNVFs+4RFM7mFtSlQedAOwBBDpCy03vArAvGjoWsmAqvtBDRYL/iGcZGN6J50me2J7/TxJ46eHE36KQTHKlZvvECZLzl01rem2NJ6UGd+tGJDA0qm5jFd/juXlo1xrbNoDVv/IgoCxkWfKSvIR5rxIdWzt6svxWRlUE6cU5Wq7QJDmX/I6BVUXISIm1j5sNlTIicIZzsI2jYM7B5b1N/ysUKlLoayLxyxZVudanCbYogEM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(376002)(396003)(346002)(39860400002)(186009)(1800799009)(82310400011)(451199024)(40470700004)(36840700001)(46966006)(356005)(921005)(81166007)(82740400003)(8936002)(6666004)(478600001)(70206006)(110136005)(7696005)(70586007)(54906003)(316002)(41300700001)(40460700003)(26005)(2616005)(16526019)(36756003)(8676002)(2906002)(86362001)(5660300002)(83380400001)(36860700001)(40480700001)(1076003)(426003)(336012)(47076005)(4326008)(7416002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:34:41.5290 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ec34e4a0-b066-4d47-1f4d-08dbaa0580e1 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AE.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7419 From: Antonio Caggiano Add support for the Venus capset, which enables Vulkan support through the Venus Vulkan driver for virtio-gpu. Signed-off-by: Antonio Caggiano Signed-off-by: Huang Rui --- hw/display/virtio-gpu-virgl.c | 21 +++++++++++++++++---- include/standard-headers/linux/virtio_gpu.h | 2 ++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 1a996a08fc..83cd8c8fd0 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -437,6 +437,11 @@ static void virgl_cmd_get_capset_info(VirtIOGPU *g, virgl_renderer_get_cap_set(resp.capset_id, &resp.capset_max_version, &resp.capset_max_size); + } else if (info.capset_index == 2) { + resp.capset_id = VIRTIO_GPU_CAPSET_VENUS; + virgl_renderer_get_cap_set(resp.capset_id, + &resp.capset_max_version, + &resp.capset_max_size); } else { resp.capset_max_version = 0; resp.capset_max_size = 0; @@ -901,10 +906,18 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) int virtio_gpu_virgl_get_num_capsets(VirtIOGPU *g) { - uint32_t capset2_max_ver, capset2_max_size; + uint32_t capset2_max_ver, capset2_max_size, num_capsets; + num_capsets = 1; + virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_VIRGL2, - &capset2_max_ver, - &capset2_max_size); + &capset2_max_ver, + &capset2_max_size); + num_capsets += capset2_max_ver ? 1 : 0; + + virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_VENUS, + &capset2_max_ver, + &capset2_max_size); + num_capsets += capset2_max_size ? 1 : 0; - return capset2_max_ver ? 2 : 1; + return num_capsets; } diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard-headers/linux/virtio_gpu.h index 2da48d3d4c..2db643ed8f 100644 --- a/include/standard-headers/linux/virtio_gpu.h +++ b/include/standard-headers/linux/virtio_gpu.h @@ -309,6 +309,8 @@ struct virtio_gpu_cmd_submit { #define VIRTIO_GPU_CAPSET_VIRGL 1 #define VIRTIO_GPU_CAPSET_VIRGL2 2 +/* 3 is reserved for gfxstream */ +#define VIRTIO_GPU_CAPSET_VENUS 4 /* VIRTIO_GPU_CMD_GET_CAPSET_INFO */ struct virtio_gpu_get_capset_info { From patchwork Thu Aug 31 09:32:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371180 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 4CCA4C83F10 for ; Thu, 31 Aug 2023 09:45:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593671.926721 (Exim 4.92) (envelope-from ) id 1qbeEQ-00080G-GG; Thu, 31 Aug 2023 09:44:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593671.926721; Thu, 31 Aug 2023 09:44:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbeEQ-000809-Di; Thu, 31 Aug 2023 09:44:54 +0000 Received: by outflank-mailman (input) for mailman id 593671; Thu, 31 Aug 2023 09:44:53 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe4i-0005pR-QF for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:34:52 +0000 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20630.outbound.protection.outlook.com [2a01:111:f400:7e8d::630]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a25253b6-47e1-11ee-8783-cb3800f73035; Thu, 31 Aug 2023 11:34:52 +0200 (CEST) Received: from BYAPR07CA0042.namprd07.prod.outlook.com (2603:10b6:a03:60::19) by DM4PR12MB5216.namprd12.prod.outlook.com (2603:10b6:5:398::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 09:34:48 +0000 Received: from CO1PEPF000042A9.namprd03.prod.outlook.com (2603:10b6:a03:60:cafe::5e) by BYAPR07CA0042.outlook.office365.com (2603:10b6:a03:60::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21 via Frontend Transport; Thu, 31 Aug 2023 09:34:48 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042A9.mail.protection.outlook.com (10.167.243.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 09:34:48 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:34:41 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a25253b6-47e1-11ee-8783-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YepS+TXID+Z+ZHNMAD1kNfGCDvWlVCtu/J5o3lYJZO9dlg3fTr8Mn8t4N3KZTB/0Xc3fnKmqrkPDbZMJGNIjTc+JdtOK3DRCv9hGGDkQpoyLXTuplBoxp6MAgN3heUFW0ifr2DUxBhAYHXtavn793ttZnUf+ymXj8r7LKjeCL7nn9TwXsqELSOxgwlqk1zA2qRBSYbcX14ftoomVXItGSuXBkAa8/JxYHxqHBQYNngWsjMKikweJ9/dXSizIwHQh+AtE+ToR6/VrJjl9+IFBQeIwlgMO0YdJ51qC5a73hQyRoy/Oq+XhctESu6VWvTnAGDf83NbNhOZo5lfxDqnZIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=DK5ukbAvzb0hia2JZcQd7uC3Wb/ok/DT6B60FOX8X3E=; b=nhmL7S7g8iXZbnUtz3Uqfs+AXAPoPe4z4ECOQvrzt8hw+Dev2iCsfdZaXH1LkUDseFf31EWHhOPLHgOka6RzZfrl12gh9Rypg8gotutOQsHhvqQyqTaIejsHfElhxGyLnfNu5MO9UmSTF/1u3UiDBUYSUfl+A4LUze5cqJjLVakoOL4HtEKI/W/GjXL/g+RrNKbI+u48dKPeRF++fu9kOiMRCph4GCpaQjXSdQIEqe+TcQL44J56Iuc8RrLnjEUfioDflzfXNAGCiQ5k6ZG/yz/PztLYZwXJUnfpx1CfP+yE61QzFd9OU5dgn5/6PyeoZyf5dAeEVSetn2aPrsOtTA== 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 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=DK5ukbAvzb0hia2JZcQd7uC3Wb/ok/DT6B60FOX8X3E=; b=SYhuz/qKpKW8uVbWcsxB15kjfTXawcsT1c66/BCFDutDN6bvt4vyyKsuOCpoiDg/epBTAqBcC1FdJz+U9dS7Vf5urMfvFCJtRd/2eqMDah7yfhoIO/vDjrz/XVi+gGlO0Qov8PBQ1NFykaxkOYTuNCCtvctDyCZmGTPNZe/o9IA= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 12/13] virtio-gpu: Initialize Venus Date: Thu, 31 Aug 2023 17:32:51 +0800 Message-ID: <20230831093252.2461282-13-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042A9:EE_|DM4PR12MB5216:EE_ X-MS-Office365-Filtering-Correlation-Id: 975ef433-94de-4d6b-2e37-08dbaa0584ff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ImOCzu6+/kEHOzXZGZYrt7abyqr8nqwzXQuC1Za7cvBlTQF4s/Hq1iqker4JBvJkYehLs8E7d2npiBzuHKpASwTpfrb8PDizHTHlfCDBNtqprTvS96Kf4E1Aa1nDsOzrbRNxBH974xBt+zjUGGuhP0XDJyKoslV71Do+MV9/6eBz7jdBOXpBn4fsd6OzNBegRygmaz47dVagVYbSoRVFVxxUI8/oQlS7epTvgROgxzH+RexHGVPaoSpD4Ikyp0g8IXTh/aAhQHtof7TBqOl2CL91ALmoivsXbd9JDUpzftXBMuYqWw/Fg8SllUVTbuN2tp7evKKlsoMxyhJlbdGYHoQWIS+VjSeVSXkm6kDTyaP0RHxSADtQPeDtr9vEXNZZdk5lielelsz5Z/spjhI1RdzYbprIKHOBcatY5coz+DGc0fwfw9VA3hON++tLJWaD2NKsCZg33pIkesmfiFJCX9kPL9OVLV5lNpawctMewuS5Ccy5b5kUw9KguJj3/1fBeiwy1b9GoqZnFGZqCfsa8GCj0IJiMxJKF0CUkO1hfzm5npE0qgSwPiYNmKOUW3NGrAuycouy+Gnfo5PaX1yWGm9q+YEFl3fih/tm/ZGzHu/si/9QrbqgjsPsHD30/jPDL749pXGSt+ajOiVsHPpfTAhjuubq99KduVaAi3nKZqXUzNRy7sLmnP/MjTXk4X6maSkGGjRaEx0ArQ2BPxgA+7AS0kyGVQbM7jLnVP3mznlQ+da86qiOEhtaEXe5DdOH1BqFwqgrK8D7RIER4ZtUvSVPxF6U/larb0JQ+Wozpls= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(396003)(376002)(39860400002)(136003)(186009)(82310400011)(451199024)(1800799009)(36840700001)(46966006)(40470700004)(36756003)(40460700003)(40480700001)(83380400001)(4326008)(41300700001)(86362001)(8936002)(5660300002)(7416002)(8676002)(1076003)(26005)(336012)(6666004)(16526019)(426003)(7696005)(2616005)(36860700001)(47076005)(82740400003)(110136005)(356005)(921005)(478600001)(4744005)(81166007)(2906002)(70206006)(70586007)(54906003)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:34:48.4525 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 975ef433-94de-4d6b-2e37-08dbaa0584ff 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042A9.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5216 From: Antonio Caggiano Request Venus when initializing VirGL. Signed-off-by: Antonio Caggiano Signed-off-by: Huang Rui --- v1->v2: - Rebase to latest version hw/display/virtio-gpu-virgl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 83cd8c8fd0..c5a62665bd 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -887,6 +887,8 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) } #endif + flags |= VIRGL_RENDERER_VENUS; + ret = virgl_renderer_init(g, flags, &virtio_gpu_3d_cbs); if (ret != 0) { error_report("virgl could not be initialized: %d", ret); From patchwork Thu Aug 31 09:32:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Rui X-Patchwork-Id: 13371174 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 0B5ACC83F01 for ; Thu, 31 Aug 2023 09:41:04 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.593629.926681 (Exim 4.92) (envelope-from ) id 1qbeAU-0004UV-3h; Thu, 31 Aug 2023 09:40:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 593629.926681; Thu, 31 Aug 2023 09:40:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbeAU-0004UM-0n; Thu, 31 Aug 2023 09:40:50 +0000 Received: by outflank-mailman (input) for mailman id 593629; Thu, 31 Aug 2023 09:40:48 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qbe4t-0005pR-Jo for xen-devel@lists.xenproject.org; Thu, 31 Aug 2023 09:35:03 +0000 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on20603.outbound.protection.outlook.com [2a01:111:f400:7eb2::603]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a8c5482f-47e1-11ee-8783-cb3800f73035; Thu, 31 Aug 2023 11:35:02 +0200 (CEST) Received: from MW4PR03CA0326.namprd03.prod.outlook.com (2603:10b6:303:dd::31) by LV8PR12MB9232.namprd12.prod.outlook.com (2603:10b6:408:182::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 09:34:58 +0000 Received: from CO1PEPF000042AA.namprd03.prod.outlook.com (2603:10b6:303:dd:cafe::83) by MW4PR03CA0326.outlook.office365.com (2603:10b6:303:dd::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.23 via Frontend Transport; Thu, 31 Aug 2023 09:34:58 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000042AA.mail.protection.outlook.com (10.167.243.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.16 via Frontend Transport; Thu, 31 Aug 2023 09:34:58 +0000 Received: from hr-amd.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 31 Aug 2023 04:34:47 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a8c5482f-47e1-11ee-8783-cb3800f73035 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l0F/TSCq02pTe4wuSpSwJ/o872tStH5tjsI7bbMQgcEpbIg8WmgCK/pDq5iVAil8KB9Uddj7paraFEO20yWj1s6yTdaOaG7+QQc4XkrpANr07nBoRIeeaZQINq+bRE8D4lRlG0GohPeYPUgeZBY/JIRkpZs5ekreXx9YAe7L23uza1OOUOfg0Z1bBL8XUY376/+Wj0KCep34rsKpFZCErlu4YwIYuZX5aX9BqE6PouHcAxOjinc6q9mVcMTY2W68MwpRU+jrGlYwQ/0Gwb8cqSUnwS4BsCYfhuKb4qT7X+70XuNv9x+yiqBVIrvvEoGLPzfKU+qYkmtNmJQ56mAouQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=A4whcxvah1WNdrkYpCcvCkFOjLQI+i6Mv2VIKDJHLJ8=; b=gX97QL9BfYFUspxzJWU3Nnhjkuriy+IuT3xgFYu5xvid1RZuh1cBHGIPbQYdNW1fpJgvVmqT5dRewFyQFdhLahS/vKTjcTP1BeBzjMXW9OQxom6B3IkuKIif6olwPGYEL9VzG9rbPPP4pbxX3u4soI2bfg/NikEWMiyARxa330gkEmx/WRUMvfIKmykQAKcbytU4hFYlpXG8dluyPjhBfZxLME9pmT8HbIObvIY4P692M/trYurg9vUA6v74AJRuOV0uGEbSHQlu5BDY00cb3o+5vAlY594vPKWqvXyCJ2bVwhd1HmM5+6lRQdLu/3SvlHdIyEqAiK/4eVZa3oVNIg== 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 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=A4whcxvah1WNdrkYpCcvCkFOjLQI+i6Mv2VIKDJHLJ8=; b=YgcB3AfY5Bsr1h2I7aCuKGEdpVCwW5D1PpiFPcYiKuBbg1uf1vqmNPALpPeC1jAtI/s0e9LzTjNG1eqgiuk1xPc/f5DLOgysALCdAjWgLt1GHdpq0Cuilgjx7ALIFguVZphRw1yICy+IsNd3PXr+TXs/QXDZL9mOVy7R/ZguC+w= 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=SATLEXMB04.amd.com; pr=C From: Huang Rui To: Gerd Hoffmann , "Michael S . Tsirkin" , Stefano Stabellini , Anthony PERARD , Antonio Caggiano , "Dr . David Alan Gilbert" , Robert Beckett , "Dmitry Osipenko" , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , CC: , Gurchetan Singh , , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Akihiko Odaki , Alyssa Ross , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xenia Ragiadakou , Pierre-Eric Pelloux-Prayer , "Honglei Huang" , Julia Zhang , "Chen Jiqian" , Huang Rui Subject: [QEMU PATCH v4 13/13] virtio-gpu: Enable virglrenderer render server flag for venus Date: Thu, 31 Aug 2023 17:32:52 +0800 Message-ID: <20230831093252.2461282-14-ray.huang@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230831093252.2461282-1-ray.huang@amd.com> References: <20230831093252.2461282-1-ray.huang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000042AA:EE_|LV8PR12MB9232:EE_ X-MS-Office365-Filtering-Correlation-Id: f9c50f6f-8198-46a0-e949-08dbaa058ac5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dBidW6jv6RWFnhTcFds4EOIGSsBaVzzcWeA0MlWcvFkkGb12aSaqQAEeUv6UVbddR4Js5U0JAoteZ8u+8isMOXeCUzIXQ36b8uJJt4OWp0gbjE8h4TUzAy2iCwbhoFr9jlevLTBDYKb6DN2WMPg1ag4VN+xXdzaUoobRFxY4tI0wPM4OMgSsIfmko9fCdGDtZ617ZDdlSmgR75fG8CZIDpcHC3+b2xnGieKXqBtKRb3Q+j46TpEiSEnkEt8WCCj9KVjIc/3L56HcIZfS+Xu0Zz/vX/0oStolXr4BvZvDidcSy3P1T3/yKZ6z0+p/RV/5mjKA6YLEXSKbBeG6S4Z6LFZMtQxW1TCgUjMMelnUVxnBLTKsSomGvG7mqsGKEy0QTRt5fAtHSmu7oFm/nHqO0Fqd0so+HA9oYMDbVr3Qt6gerob2V5LT1fE8eV1MiKpwRm4lyjZ0H0I3kr2FzEKeMvTy5G5RZqdhGXwVGDWWIDV1lx1yUeu8RDk3MqiKC8Lj/9gNc67VmzUgNDWeqMn8HrDj5jjspgEkXhdUPUIF6Ol9AdF+jj6P8LmOl1YgHdkKBhWRsf70OM21ixHlFxqVxMEm5tBJHYD9oTgB2ccQjr6S1h453p0FpPFLK1XNGmxn2b980kwrVxGQ8UJvIiHrDh5fW6Sf2ljytxROS7dqSNQ7Yrxsm7XrUyhbvhhfz9USgvV6aTNyAN5XWBPTwK/H796I9+XI9J53VQFTIGBokA3GthMGVsawjehKPwt63I8hQnPMe6j9V2rvM3noU7SjCp1jahLq3aZj9J5SuxQXPOA= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(396003)(376002)(346002)(136003)(186009)(1800799009)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(40480700001)(40460700003)(83380400001)(54906003)(70206006)(70586007)(316002)(921005)(356005)(478600001)(2906002)(4744005)(81166007)(82740400003)(86362001)(41300700001)(8676002)(8936002)(4326008)(5660300002)(26005)(7696005)(47076005)(336012)(1076003)(6666004)(426003)(36860700001)(7416002)(2616005)(16526019)(110136005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 09:34:58.1435 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9c50f6f-8198-46a0-e949-08dbaa058ac5 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000042AA.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9232 Venus in virglrenderer has required render server support. Signed-off-by: Huang Rui --- New patch hw/display/virtio-gpu-virgl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index c5a62665bd..1ae3e458e2 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -887,7 +887,7 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) } #endif - flags |= VIRGL_RENDERER_VENUS; + flags |= VIRGL_RENDERER_VENUS | VIRGL_RENDERER_RENDER_SERVER; ret = virgl_renderer_init(g, flags, &virtio_gpu_3d_cbs); if (ret != 0) {