From nobody Tue May 7 18:52:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1663940763; cv=none; d=zohomail.com; s=zohoarc; b=mkkrHcyf9BaQ5Nw647mZjnSg7NRtjSx43FdCQ6W78+DFX/NPI6slYqhuERg5gAv5srSKnykBsZxB+P8YSEYq/rfLchmMlZclWdL3hXM0HOOIAqEAc2y1HCB6VLP3D0OpKt1bJcbdmRTcFCgQudKi5HcG0LY3FWYmGRFENYDRxg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663940763; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X7cGD9Q1YPCE5bNYL22viDfdHpRx2CWgps5rKEuJYas=; b=hs+9QewZKbR2siEe8QmyBQuoxnVjGXWuZlM6usG2vdzHu39twDMHKNyu1j06ZbN5JQj9YICDpSq/0wVJfUoSEx8ouFtFmEXM+OWix4yJ5gAgR/tBtO/sgNeiyjUiWVYUC+EK1qPwDB6esHlKtdWMoCxuyvGyhAl+mrALqIDxLH4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1663940763475333.90395421238543; Fri, 23 Sep 2022 06:46:03 -0700 (PDT) Received: from localhost ([::1]:51906 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obj0D-0005cz-8H for importer@patchew.org; Fri, 23 Sep 2022 09:46:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obiyK-0003J1-LZ for qemu-devel@nongnu.org; Fri, 23 Sep 2022 09:44:04 -0400 Received: from madras.collabora.co.uk ([46.235.227.172]:51288) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obiyH-0001ZQ-GN for qemu-devel@nongnu.org; Fri, 23 Sep 2022 09:44:04 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id 8F0E16602249; Fri, 23 Sep 2022 14:43:58 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1663940638; bh=eH8FQd+aNxSvn7jw39RMwXieOu3FtgSPJYS4kD0AOkc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=drB8kcwUrgklcvNADN/s0XhUjXp9xUbF5eBUxopexhGN9EiI4jTEbsBUI2ybkBMd2 1gvolaPGHxvdk6TZ4ZQtkCYYzEGq0+R00FqvnQ+I8wcZgTHgdIlOPJFfqGxE5BOM58 mhvfS0jo5D9WEr+jD+D6r6L7z6++JAEhihZR83oxbZiyiGVVlASq6qUoHiR62iAlnq SZQazZ41CCcjYuNMbofVrShxRhloPjJKJYTmWLxc0LBf+47RehdbgWUIqI33Og9F6Y eztiTZw53SfebsXREInRj7+4aZAPFIb+c66y21eQk7gwgfk8bkjxcoXD8Qjch1KZds A/vBQBCGozeoA== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, "Michael S. Tsirkin" , Gerd Hoffmann Subject: [PATCH v2 1/2] virtio-gpu: Unrealize Date: Fri, 23 Sep 2022 15:43:49 +0200 Message-Id: <20220923134350.324402-2-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220923134350.324402-1-antonio.caggiano@collabora.com> References: <20220923134350.324402-1-antonio.caggiano@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=46.235.227.172; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1663940765911100003 Content-Type: text/plain; charset="utf-8" Implement an unrealize function for virtio gpu device. Signed-off-by: Antonio Caggiano --- hw/display/virtio-gpu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 20cc703dcc..412f0fb7ec 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1345,6 +1345,15 @@ void virtio_gpu_device_realize(DeviceState *qdev, Er= ror **errp) QTAILQ_INIT(&g->fenceq); } =20 +void virtio_gpu_device_unrealize(DeviceState *qdev) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(qdev); + VirtIOGPU *g =3D VIRTIO_GPU(qdev); + + qemu_bh_delete(g->cursor_bh); + qemu_bh_delete(g->ctrl_bh); +} + void virtio_gpu_reset(VirtIODevice *vdev) { VirtIOGPU *g =3D VIRTIO_GPU(vdev); @@ -1440,6 +1449,7 @@ static void virtio_gpu_class_init(ObjectClass *klass,= void *data) vgbc->gl_flushed =3D virtio_gpu_handle_gl_flushed; =20 vdc->realize =3D virtio_gpu_device_realize; + vdc->unrealize =3D virtio_gpu_device_unrealize; vdc->reset =3D virtio_gpu_reset; vdc->get_config =3D virtio_gpu_get_config; vdc->set_config =3D virtio_gpu_set_config; --=20 2.34.1 From nobody Tue May 7 18:52:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=collabora.com ARC-Seal: i=1; a=rsa-sha256; t=1663940763; cv=none; d=zohomail.com; s=zohoarc; b=J2gzoJZ9e+yZ40TepgUHQppKJtj1S+7Kg+ZVNEXnz5Chj7XcE5HakBFfXE525WwYYBue540CdJMw95zzPPsJGV+0cZS8WTpyA79Hum97i94xO07i0JbvummSZhm4Ac2zdXC57I4OwkNM/r5PaQ2blyWJmUjubeiNRDw5ptEwu2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1663940763; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BuvvibVryRRjEqw6LQsMolZRRkQwVwHk7dxroBMNyZ4=; b=BFb4BxboMjjYolfWq14b2MIZBdYe7odJvh10L+KhrwuMEFu3Jftn8ERBCv4GYyHyzdC7mLJjS7cq2yNmpXGWJGNrNrlo/AqiGdvhKZXuBxo8avk5ejZvl0pD4HxxABQmuJhg732T+qJWn5saEDMTmrMoCW9JwfXx6GRaIUWInHU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1663940763095685.1882283901311; Fri, 23 Sep 2022 06:46:03 -0700 (PDT) Received: from localhost ([::1]:51904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obj0D-0005cR-IQ for importer@patchew.org; Fri, 23 Sep 2022 09:46:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46656) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obiyJ-0003H0-Iz for qemu-devel@nongnu.org; Fri, 23 Sep 2022 09:44:03 -0400 Received: from madras.collabora.co.uk ([46.235.227.172]:51300) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obiyH-0001ZX-Ib for qemu-devel@nongnu.org; Fri, 23 Sep 2022 09:44:03 -0400 Received: from dellino.fritz.box (host-79-27-165-192.retail.telecomitalia.it [79.27.165.192]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: fahien) by madras.collabora.co.uk (Postfix) with ESMTPSA id 2C79F660224A; Fri, 23 Sep 2022 14:43:59 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1663940639; bh=F2YymFS4fuk33hLcXrm2wbzwXWZsfZQPWg/+4bknAaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XA6Q+Ag2Fo8Ifxigv1pNRfyW/axzgJto55hRblssiiXQL3FCd/DR+jWqablju0Pnu Pw4Zy+lAWAjsUahvb0BbkZIta45+2Lzvz4DGwFRdOZGcAmshf6aSnKwFhWz9chSqRp Z+6zmQ+1qqnxXwJ/VkfZoXN58LBIL60HM9wNglDWSZ+kLw5Zpx1QmVjRD1nMWOSW3K VhDo+IvMkOSh4FC1Vem+enufKhQMdOiR961gWE8oxvOlUZ6Nx3U97G5hit86yBx4By bIWJMBQuRNeU+ohyOOd2IkYbwYEflb2n5qLCmkungYB5DNtNbFyMVBnk7F0dKSJIZ7 3KYqw5T3DBd0w== From: Antonio Caggiano To: qemu-devel@nongnu.org Cc: gert.wollny@collabora.com, dmitry.osipenko@collabora.com, Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PATCH v2 2/2] virtio-gpu: Resource UUID Date: Fri, 23 Sep 2022 15:43:50 +0200 Message-Id: <20220923134350.324402-3-antonio.caggiano@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220923134350.324402-1-antonio.caggiano@collabora.com> References: <20220923134350.324402-1-antonio.caggiano@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=46.235.227.172; envelope-from=antonio.caggiano@collabora.com; helo=madras.collabora.co.uk X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @collabora.com) X-ZM-MESSAGEID: 1663940764449100001 Content-Type: text/plain; charset="utf-8" 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 --- v2: Destroy the hash table in the unrealize function hw/display/trace-events | 1 + hw/display/virtio-gpu-base.c | 2 ++ hw/display/virtio-gpu-virgl.c | 11 +++++++++ hw/display/virtio-gpu.c | 41 ++++++++++++++++++++++++++++++++++ include/hw/virtio/virtio-gpu.h | 4 ++++ 5 files changed, 59 insertions(+) diff --git a/hw/display/trace-events b/hw/display/trace-events index 0c0ffcbe42..6632344322 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 siz= e) "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 a29f191aa8..157d280b14 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -216,6 +216,8 @@ virtio_gpu_base_get_features(VirtIODevice *vdev, uint64= _t features, features |=3D (1 << VIRTIO_GPU_F_RESOURCE_BLOB); } =20 + features |=3D (1 << VIRTIO_GPU_F_RESOURCE_UUID); + return features; } =20 diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 73cb92c8d5..7adb6be993 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -43,6 +43,10 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g, args.nr_samples =3D 0; args.flags =3D VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP; virgl_renderer_resource_create(&args, NULL, 0); + + struct virtio_gpu_simple_resource *res =3D g_new0(struct virtio_gpu_si= mple_resource, 1); + res->resource_id =3D c2d.resource_id; + QTAILQ_INSERT_HEAD(&g->reslist, res, next); } =20 static void virgl_cmd_create_resource_3d(VirtIOGPU *g, @@ -67,6 +71,10 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g, args.nr_samples =3D c3d.nr_samples; args.flags =3D c3d.flags; virgl_renderer_resource_create(&args, NULL, 0); + + struct virtio_gpu_simple_resource *res =3D g_new0(struct virtio_gpu_si= mple_resource, 1); + res->resource_id =3D c3d.resource_id; + QTAILQ_INSERT_HEAD(&g->reslist, res, next); } =20 static void virgl_cmd_resource_unref(VirtIOGPU *g, @@ -452,6 +460,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 412f0fb7ec..61a8f8f54f 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -937,6 +937,37 @@ virtio_gpu_resource_detach_backing(VirtIOGPU *g, virtio_gpu_cleanup_mapping(g, res); } =20 +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 =3D NULL; + + VIRTIO_GPU_FILL_CMD(assign); + virtio_gpu_bswap_32(&assign, sizeof(assign)); + trace_virtio_gpu_cmd_res_assign_uuid(assign.resource_id); + + res =3D virtio_gpu_find_check_resource(g, assign.resource_id, false, _= _func__, &cmd->error); + if (!res) { + return; + } + + memset(&resp, 0, sizeof(resp)); + resp.hdr.type =3D VIRTIO_GPU_RESP_OK_RESOURCE_UUID; + + uuid =3D g_hash_table_lookup(g->resource_uuids, GUINT_TO_POINTER(assig= n.resource_id)); + if (!uuid) { + uuid =3D g_new(QemuUUID, 1); + qemu_uuid_generate(uuid); + g_hash_table_insert(g->resource_uuids, GUINT_TO_POINTER(assign.res= ource_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) { @@ -985,6 +1016,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 =3D VIRTIO_GPU_RESP_ERR_UNSPEC; break; @@ -1343,6 +1377,8 @@ void virtio_gpu_device_realize(DeviceState *qdev, Err= or **errp) QTAILQ_INIT(&g->reslist); QTAILQ_INIT(&g->cmdq); QTAILQ_INIT(&g->fenceq); + + g->resource_uuids =3D g_hash_table_new_full(NULL, NULL, NULL, g_free); } =20 void virtio_gpu_device_unrealize(DeviceState *qdev) @@ -1350,6 +1386,7 @@ void virtio_gpu_device_unrealize(DeviceState *qdev) VirtIODevice *vdev =3D VIRTIO_DEVICE(qdev); VirtIOGPU *g =3D VIRTIO_GPU(qdev); =20 + g_hash_table_destroy(g->resource_uuids); qemu_bh_delete(g->cursor_bh); qemu_bh_delete(g->ctrl_bh); } @@ -1377,6 +1414,10 @@ void virtio_gpu_reset(VirtIODevice *vdev) g_free(cmd); } =20 + if (g->resource_uuids) { + g_hash_table_remove_all(g->resource_uuids); + } + virtio_gpu_base_reset(VIRTIO_GPU_BASE(vdev)); } =20 diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 2e28507efe..41aed312f5 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -189,6 +189,8 @@ struct VirtIOGPU { QTAILQ_HEAD(, VGPUDMABuf) bufs; VGPUDMABuf *primary[VIRTIO_GPU_MAX_SCANOUTS]; } dmabuf; + + GHashTable *resource_uuids; }; =20 struct VirtIOGPUClass { @@ -258,6 +260,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_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); --=20 2.34.1