From patchwork Tue Oct 29 12:10:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839326 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp328789wrb; Tue, 29 Oct 2024 05:11:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVUrD7Fk+5Y5fJNng606DKwoGmukMfVWP+gVgi9VRgQdp7w1XK+P+Z/JHF7eyIcPG+I1VW4tQ==@linaro.org X-Google-Smtp-Source: AGHT+IHtomEkNxkfpv3oKmqL0CbIyQjSnpAwYItC+JZO2fsSxcbJxeYAFD9oXybDLEGzqiqJeeaf X-Received: by 2002:a05:620a:461f:b0:7b1:55ae:a9bb with SMTP id af79cd13be357-7b193edab57mr1747683285a.13.1730203902326; Tue, 29 Oct 2024 05:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203902; cv=none; d=google.com; s=arc-20240605; b=btDT1EsU3E9LjCfp2RjtZfs/+YfluCAEvXFYfQdx9ux1XvqGq2821y/hSraZhY25lc XybuuNr9oxP/gHn6QremLEQr4+Ge7BsJCaO6NfLQ7fCWisjhO+g1gkEvppQ+Rkj5Id2y /eNpSzwqFRic45CiIDd7A3+J6E7wNntMTu8iTII1uwl4M3IynQBv30Wg0rYaHiLqOkGO NzthHJUCCkfoO53CwLkgpWOR8S13ALHeQrvrgqMd0FPltdNZwC9B0Ra+rOFJ0jVTRyyp lb7P+oJgI8mni1ygZ1sQHGYxMvexuOX2X0lM6E1jR1penpfb7KjfF60zzT/GMHKOlMIa 8PcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yA1TnKmdYIVh4QgM+44m/kYyl/YIszs+Fc2n46GOLvM=; fh=neY4i4HjNm3aaff/l51E4aNzDBGl9HUSvRIOdANTcoo=; b=f4p7ezVq2UTqERvGlvq4H+eYZ5UyWvcKUSPIgxHSH7NXH7HWHrT4hYpEP6Ak9e50s6 7xm6Hnk3flRD8ywNgTV+NKWBge9JZlhla+o4bRoRq2gSG2tZ5N+xRMpCz+KpD/lIJ0eN t5AUi/drq809gm1a/2wzWwzpfYaiqvIcIOhALkPdj8yBXCDQ5HbErS5IDJTFrCH0om9r z2p3XnhUC9KZCmtQW4wObdyPlORzx2C3fgcMRt6nq51s+UE46XazPgEz3J82lfYnvm/d luno1p8A0P+IbwxQIegZo0dr2t3fWLlClN/D3gc6MBP7NGcXH0Kwny0wWgNGapjW8r6E Jjwg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JFdMRnP4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7b18d3443adsi1104026785a.464.2024.10.29.05.11.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:11:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JFdMRnP4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3X-0004Zs-9t; Tue, 29 Oct 2024 08:10:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3V-0004ZE-A8 for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:37 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3T-0007S3-GB for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:36 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-539f7606199so5777677e87.0 for ; Tue, 29 Oct 2024 05:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203833; x=1730808633; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yA1TnKmdYIVh4QgM+44m/kYyl/YIszs+Fc2n46GOLvM=; b=JFdMRnP4EOj7RewedcCvJSGsmxqwqa669Nbbs9pBeCeqhB+OrfEk0YVJj+gsmgIj6C 4CaSSY6r6RBtY5Td3PvTUplr6d/Sx/xRPB80ODOHKm1+aTPNE6A1fGK3xIhA0WYBwMEC hwk6ynAXf0YkvdagSCC55WU8MorKmWY48b0E9dYqs+gxFj+8GUN07Org9hmBnts+H+eP WS3JgKqj6G6WrKY2da1Dxef6as2aTetGInKoxh3N3FtAv0lmiG7kojza+qM4zOndrdDo v85vv1x+lGN0i2GZxhyFK9n3TQkjVSWdgtonFyyXLhDgPoj5mdSno8+Ka7EUJur3QgI7 wReQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203833; x=1730808633; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yA1TnKmdYIVh4QgM+44m/kYyl/YIszs+Fc2n46GOLvM=; b=rNoL0IpSI6Y6fgs4SuUAfPGkmdjw+uVR+UUkRWGlkohlwvvoINcRVtsxA+nbRLJBNU eGqKSzMnwz0VEZMg3C6GgoigF1b8Al1vvUksA3YchJKZmKiI20svL1Vhiuf8MURhRtzY eB5vy0dtOuqfJzG7yuP1tfbeE9oitO8J1qg3EX718rHqARd/ARR6vwsd90e0c+RUfm+f 2YJ2NAItrCPJhoniYJzG0mkJI5ayAFTqs5hC4hhTbSK5upsTFIAqkGO+V36SAItSsEMp k9s99L+4fz3Tg0Jrh0tZpjxo22aAXLQ6bv6TjYwh/JcZwLsRFTXKm/G9rL0v3y24751k gRKg== X-Gm-Message-State: AOJu0Yxky2diYqc/HXbls8NbfZMowVwUKB7WJLTuEk2tGRG6ZOmBsQkK DmrFrQ4IvpphHeCRv3M4x5GLKq/OVQOjkTEHzpOXEQbct9gwhZka8cpMlGv/bCE= X-Received: by 2002:a05:6512:3404:b0:53b:27ba:2d11 with SMTP id 2adb3069b0e04-53b348cb2cbmr6486997e87.16.1730203832896; Tue, 29 Oct 2024 05:10:32 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43193572932sm145210695e9.1.2024.10.29.05.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:31 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 910F95F929; Tue, 29 Oct 2024 12:10:30 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 01/13] virtio-gpu: Use trace events for tracking number of in-flight fences Date: Tue, 29 Oct 2024 12:10:18 +0000 Message-Id: <20241029121030.4007014-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x134.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Dmitry Osipenko Replace printf's used for tracking of in-flight fence inc/dec events with tracing, for consistency with the rest of virtio-gpu code that uses tracing. Suggested-by: Marc-André Lureau Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-2-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 9f34d0e661..14091b191e 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -525,7 +525,7 @@ static void virgl_write_fence(void *opaque, uint32_t fence) g_free(cmd); g->inflight--; if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { - fprintf(stderr, "inflight: %3d (-)\r", g->inflight); + trace_virtio_gpu_dec_inflight_fences(g->inflight); } } } diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 49fd803393..3fcc434732 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1046,7 +1046,7 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g) if (g->stats.max_inflight < g->inflight) { g->stats.max_inflight = g->inflight; } - fprintf(stderr, "inflight: %3d (+)\r", g->inflight); + trace_virtio_gpu_inc_inflight_fences(g->inflight); } } else { g_free(cmd); @@ -1066,7 +1066,7 @@ static void virtio_gpu_process_fenceq(VirtIOGPU *g) g_free(cmd); g->inflight--; if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { - fprintf(stderr, "inflight: %3d (-)\r", g->inflight); + trace_virtio_gpu_dec_inflight_fences(g->inflight); } } } diff --git a/hw/display/trace-events b/hw/display/trace-events index 781f8a3320..e212710284 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -53,6 +53,8 @@ virtio_gpu_cmd_ctx_submit(uint32_t ctx, uint32_t size) "ctx 0x%x, size %d" virtio_gpu_update_cursor(uint32_t scanout, uint32_t x, uint32_t y, const char *type, uint32_t res) "scanout %d, x %d, y %d, %s, res 0x%x" virtio_gpu_fence_ctrl(uint64_t fence, uint32_t type) "fence 0x%" PRIx64 ", type 0x%x" virtio_gpu_fence_resp(uint64_t fence) "fence 0x%" PRIx64 +virtio_gpu_inc_inflight_fences(uint32_t inflight) "in-flight+ %u" +virtio_gpu_dec_inflight_fences(uint32_t inflight) "in-flight- %u" # qxl.c disable qxl_io_write_vga(int qid, const char *mode, uint32_t addr, uint32_t val) "%d %s addr=%u val=%u" From patchwork Tue Oct 29 12:10:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839330 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp329225wrb; Tue, 29 Oct 2024 05:12:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWZ+Hd+bInqGHvipAUz/v6Zkd1OyMBTGNVM8nkWl2xcyUYkSFsRypLRTJW+VnifZ47XhnG7JQ==@linaro.org X-Google-Smtp-Source: AGHT+IF3sMfRol2eEUq7zlp4RJKgpXD/Rv6w6gJNCYKR/e90VfD19DqqSejeAC8WXfgeegdBBVMD X-Received: by 2002:a05:6102:54a8:b0:4a3:ad47:58df with SMTP id ada2fe7eead31-4a8cfb453a3mr8860807137.10.1730203954674; Tue, 29 Oct 2024 05:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203954; cv=none; d=google.com; s=arc-20240605; b=Hr+1/tAeCtbZDMKTKtzq7sOVZ5cy3Ks3lPXFLtSb0hCpqzf5Eg9IS3ENnk+YHp408/ ScCwwPo30QbCN/xt5t4InUJTIXlFZ7yKZ1c5GED4f9V6z8IvI0f8jLNkZ1TCR1opowC0 qA2ypnSFFAr2smDpCmHZZS9yrNmsCtmXNBI09O1GpRMXBSiXbX8B5PCa2OBFx0INTQH4 8o8eWzqLH8EJe62fUuRF7Klj9d36ymzejuJRNJviuc224iri39ImFfx89JUqLz/I/Qbr lvVRojp8OI9Z3glSQRtgpVQfpy/rbX5dua2tshaarb8pBmGPjkc4k2YOTdxSDPWeejCL XjCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pUPdzr3axCBtNpWLG3/6d3bv+WC8e9tr/zVd9fr5GLY=; fh=VyoImqtNGezAyRveop7jJLIY1GvuLKHjGRNqLnjiHgY=; b=dKnQD18PyEV0UxOxqrhSYzOWDf3wQEpSTlPjMp5OTK5s3Ey88flivsyQozGfqSf+qG fymYJSHzu4ulEfqWBPI9wm6jt77GtTEZ6oupH777dyD8b44h0nlC3xwl6QCetCRl6TMa zyTOl2EoIEOwYMehWXPXE6rIwK/NGIXfd8gZJiDkFJuEXH34QgX7fnuz4SNdDD/6YtNH 9b2kOtyjdujrYH6PA3lVZ4PBxRNhF3nw5f6Gi24L6WkOTJ6S4g90MiIIleN5+HCwI3rv xsb4cTg5EzR/2nyd/OdLMranyRRcXjR/8ZZ+YMiON+XM/HtUQarD866jnqib0pIPvvse Bsug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Re6vA2H9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4a8c51d2e41si1950073137.14.2024.10.29.05.12.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:12:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Re6vA2H9; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3Y-0004a0-HS; Tue, 29 Oct 2024 08:10:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3U-0004Yz-VF for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:36 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3S-0007Rl-3r for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:36 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4314f38d274so70709375e9.1 for ; Tue, 29 Oct 2024 05:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203832; x=1730808632; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pUPdzr3axCBtNpWLG3/6d3bv+WC8e9tr/zVd9fr5GLY=; b=Re6vA2H9Vm+RXwhXvWRSzB+j5lGhtNddfsDFhvwFbPueJx4TbQH6RvV6YwtEMThUdv 5K5OYlxP6Ps7l9TfrVoGXl31MBHPZYgZpqkvL7eAVAoxX9Ii8IXlF7xFIFVv/sxqYKXF xgKVwdLmkFcQnfr/4hQBVyNryvgtNu3msb1My32ALOIhxf3WIKSiv86UOhAxl1tGWwtj Y1jdy4RT1v+Hauhk2YiMFnN3YCAmt623SKg51ubDyZDwTlv547KFhHQieJSJJkhgCJqg pq1D+fUZj0ud0l1J3vRfpI/mgiiVAVrhlYfqoOsayKecN2vR4K5QmhQsOMuGI9g/w3e7 7zEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203832; x=1730808632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pUPdzr3axCBtNpWLG3/6d3bv+WC8e9tr/zVd9fr5GLY=; b=PNpxk2e0b5KTa4eCTDxGTvzror8H1uYHNHrlbvrreCSy9lot44E0Eozbiy1iXTX9tp 0AU09YBijM765uON/XKkYBlxSpk/syiPaxp1mOEa4n/pCp7mf5iS4IzM4On2xOG7pgux x9h6W4aRxGdCwIWCt2TemwFrgCxYNI9QpHOtvTmAbHrLGTWj5qDSCivkjMFv+sHjcNRQ 1scxGpBnGqrwgKf3j3iSYjV0BYUV0DR/PKdO4zaXklQLfLU+k+/mjqe4sPa5kpsM4wrm jx1Hj6Buae00V4IK8U+Z1oZsk4f9G7JupoEnr3vehSiJ95UEaUHrfJ8+/ITlyHoywdgL v7Ug== X-Gm-Message-State: AOJu0YyHx0WLFWFFiL7DQLDmgAsq578u0bxwfzz9ZWsytpziMAien6K9 QkQiPnDJUbHQHOcnX7Jy9KPBBZeWd2PYg/uSYjO7OtMrxFG9tKHiZpYuIRC0Ezs= X-Received: by 2002:a05:600c:1910:b0:431:5c3d:1700 with SMTP id 5b1f17b1804b1-4319acadd83mr130824285e9.21.1730203832051; Tue, 29 Oct 2024 05:10:32 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b5797c3sm172938845e9.40.2024.10.29.05.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:31 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A704F5FA99; Tue, 29 Oct 2024 12:10:30 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 02/13] virtio-gpu: Move fence_poll timer to VirtIOGPUGL Date: Tue, 29 Oct 2024 12:10:19 +0000 Message-Id: <20241029121030.4007014-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x333.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Dmitry Osipenko Move fence_poll timer to VirtIOGPUGL for consistency with cmdq_resume_bh that are used only by GL device. Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-3-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index e343110e23..48a67d662d 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -194,7 +194,6 @@ struct VirtIOGPU { uint64_t hostmem; bool processing_cmdq; - QEMUTimer *fence_poll; QEMUTimer *print_stats; uint32_t inflight; @@ -229,6 +228,8 @@ struct VirtIOGPUGL { bool renderer_inited; bool renderer_reset; + + QEMUTimer *fence_poll; }; struct VhostUserGPU { diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 14091b191e..91dce90f91 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -594,11 +594,12 @@ static void virtio_gpu_print_stats(void *opaque) static void virtio_gpu_fence_poll(void *opaque) { VirtIOGPU *g = opaque; + VirtIOGPUGL *gl = VIRTIO_GPU_GL(g); virgl_renderer_poll(); virtio_gpu_process_cmdq(g); if (!QTAILQ_EMPTY(&g->cmdq) || !QTAILQ_EMPTY(&g->fenceq)) { - timer_mod(g->fence_poll, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 10); + timer_mod(gl->fence_poll, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 10); } } @@ -626,6 +627,7 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) { int ret; uint32_t flags = 0; + VirtIOGPUGL *gl = VIRTIO_GPU_GL(g); #if VIRGL_RENDERER_CALLBACKS_VERSION >= 4 if (qemu_egl_display) { @@ -645,8 +647,8 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) return ret; } - g->fence_poll = timer_new_ms(QEMU_CLOCK_VIRTUAL, - virtio_gpu_fence_poll, g); + gl->fence_poll = timer_new_ms(QEMU_CLOCK_VIRTUAL, + virtio_gpu_fence_poll, g); if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { g->print_stats = timer_new_ms(QEMU_CLOCK_VIRTUAL, From patchwork Tue Oct 29 12:10:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839334 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp329367wrb; Tue, 29 Oct 2024 05:12:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVEyXffSwP0yjEzZg/Z3u4oepSEEt9OVXGc1AgF6Q8OZ0wQbQReAdxfUiR+V8LMKvQ3WTrlUw==@linaro.org X-Google-Smtp-Source: AGHT+IHnzwyqrir1Zd+SWIoUnAQr/pz7aJQvyUGPPSycfJwjyg7zHTPvKqxo+2Gb7WEoSuCst1UE X-Received: by 2002:a05:6122:31a3:b0:510:185:5d9c with SMTP id 71dfb90a1353d-51015126708mr10142666e0c.11.1730203970039; Tue, 29 Oct 2024 05:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203970; cv=none; d=google.com; s=arc-20240605; b=DE6eHTzo7bGGw4LfP0MAbSqs5BjhPaq+975mVKpTd86W75+3pstHW6m3/gpYa0lSIB SHwbcczBDE+04IhzIRNJMSklRMoULv0LF/kDlA4BcW9Z5/OKXeQQR7FEpJyhM1PjC7ws HTnppfZaaHY+s6Dhq1xxY5KI1VrQLxhiqCcX4dDDG/0lJeZVoUfPrne71FfnJ+utWVEG lhmUfiZg7eiAv3DmTqTKh+S3BgRU7hBR2GX0fSUp/o1UWozUxv6MFY505Dwe/JTz+PV0 wVI+a2pOtfnybwCg4RcNExAiVLO+8qwQH3jLwXQmBKbFBKjwfnRCOPBDQnDqT/O8E52K FNLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=P5phWhGoDCJYI2vf4vKZn7wKxwIMi3ZojG0/RvNfBVE=; fh=VyoImqtNGezAyRveop7jJLIY1GvuLKHjGRNqLnjiHgY=; b=A9+OUXi3XSNGmnksuEJBNolVhx5BZlP/dt3VSMhDO33+KadAHi5xAanp8RuG/eaGIh ZiPeTOa7kbjsWA3DWHgFNn4XoI4B6OaPv5fn70yLicgRpuDzX4eBXynB3afivaiEHJs5 WzUsZKWQ5ruZM7k9aLUj/RfF1fQR2Qy72mzLm0aLCqEJ7ZlJIf4Lv229ktrmcAlUZ27n isWh5/IU2kXMwJXyibQOhASpArgUgopobdzPwrAsxUt2W6RNKyRLyA4EgGGFs6sTyP7/ YfAVeP61loAJfspHDB3dYx92d+bZEZZXzF8nljSUOCHI/x7+KM7Y5RkupWAHW8Nb8sVu gueQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hC4TpEVZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-510047a22acsi2253333e0c.251.2024.10.29.05.12.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hC4TpEVZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3m-0004el-Kh; Tue, 29 Oct 2024 08:10:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3W-0004Ze-JH for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:38 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3U-0007SF-ND for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:38 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-431688d5127so52139115e9.0 for ; Tue, 29 Oct 2024 05:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203835; x=1730808635; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P5phWhGoDCJYI2vf4vKZn7wKxwIMi3ZojG0/RvNfBVE=; b=hC4TpEVZkf//MdfuJ+KojrnG+rwK+TsCl+mklPCa4TrlXwqt+CbjwswiwENosw1sRJ 0QKXofIrUdsU2n9ymc3PGPt58QOGOFwzKRpfBqvwUuyA4zDd9aWgdY5kh56BWgiteRb6 psZ7qBno+o3pmeOqBW42ASXB7r9pxCELHr3E8y8DRqMin/Is3U59MYAG9tQvebc5F4sd j96BjJ8SUCf84IwZRmRrkEMhm8qclH4j3n2L9dguBJEscKxyYMQjhIRnrFVd6THCkyQw eFoLI/MoiQ+JrPImDt9g2Zf62RUHRsljfq7seVfkedwu6A8WlKPZtsDsqzUybUJdaBmQ XApQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203835; x=1730808635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P5phWhGoDCJYI2vf4vKZn7wKxwIMi3ZojG0/RvNfBVE=; b=cvZuPNwSz+qrt8w3Apvy6j53tWcjpqe3vJCLeE9ZDOOXDTsj2hbwH+xwSGOVr9aRQP yBjkPPCOivQKykTmBYWvxvFZJaKiAVhXCEBN4aFelfJ/GIx9C6cQPhfznRc02pRZXFC7 LHLWZCYpa9sGvtCfplZ9XTqMJubRDHsepVCOG8ItzrmguWGzHslMDFH/uBccGJ462iJt 5LDSJmPjIwfVyfuew5xSfmM6145Ap5dmSFt5zs0AvaYxOfbmimn563CzDS/WL8mGo/m3 Fyx+pq94hPOGmzgiOScYaS9ax5YXAXnNkWa8moSpdEN9dzTM9IskVp8iaLamiWompL6O ZGAg== X-Gm-Message-State: AOJu0YxcmnDQCA9R+xXtNglt2EHHKEC7/vsLmGA+RoKIizKdQPx59PTJ Pj+Zb0ZO9WNHdrM+ZjuGpg4N9evc5vjEz+uPOJNYxitqh48scq7TlTyH02oYtps= X-Received: by 2002:a05:600c:5118:b0:42c:de2f:da27 with SMTP id 5b1f17b1804b1-4319ac6f848mr110887835e9.2.1730203834715; Tue, 29 Oct 2024 05:10:34 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431935a4ad8sm142617555e9.23.2024.10.29.05.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:31 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id BBD1E5FAA0; Tue, 29 Oct 2024 12:10:30 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 03/13] virtio-gpu: Move print_stats timer to VirtIOGPUGL Date: Tue, 29 Oct 2024 12:10:20 +0000 Message-Id: <20241029121030.4007014-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Dmitry Osipenko Move print_stats timer to VirtIOGPUGL for consistency with cmdq_resume_bh and fence_poll that are used only by GL device. Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-4-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 48a67d662d..18b6c3b3a2 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -194,7 +194,6 @@ struct VirtIOGPU { uint64_t hostmem; bool processing_cmdq; - QEMUTimer *print_stats; uint32_t inflight; struct { @@ -230,6 +229,7 @@ struct VirtIOGPUGL { bool renderer_reset; QEMUTimer *fence_poll; + QEMUTimer *print_stats; }; struct VhostUserGPU { diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 91dce90f91..a63d1f540f 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -574,6 +574,7 @@ static struct virgl_renderer_callbacks virtio_gpu_3d_cbs = { static void virtio_gpu_print_stats(void *opaque) { VirtIOGPU *g = opaque; + VirtIOGPUGL *gl = VIRTIO_GPU_GL(g); if (g->stats.requests) { fprintf(stderr, "stats: vq req %4d, %3d -- 3D %4d (%5d)\n", @@ -588,7 +589,7 @@ static void virtio_gpu_print_stats(void *opaque) } else { fprintf(stderr, "stats: idle\r"); } - timer_mod(g->print_stats, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 1000); + timer_mod(gl->print_stats, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 1000); } static void virtio_gpu_fence_poll(void *opaque) @@ -651,9 +652,10 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) virtio_gpu_fence_poll, g); if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { - g->print_stats = timer_new_ms(QEMU_CLOCK_VIRTUAL, - virtio_gpu_print_stats, g); - timer_mod(g->print_stats, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 1000); + gl->print_stats = timer_new_ms(QEMU_CLOCK_VIRTUAL, + virtio_gpu_print_stats, g); + timer_mod(gl->print_stats, + qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 1000); } return 0; } From patchwork Tue Oct 29 12:10:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839327 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp328791wrb; Tue, 29 Oct 2024 05:11:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXy+2taX+uq28LM3alfHcFIreGlKwbIIQIBpMqmt/D0BVt48Kp6oIoVCLRrX4mfKV1dmRzj2g==@linaro.org X-Google-Smtp-Source: AGHT+IFwKvcP4IsiFqbML4HRB6DwKeUBquTJPrCDO2mRbnLUeoUOQieJedI5LYOgRn+9a6A2XL9o X-Received: by 2002:a05:6808:1787:b0:3e5:f9dc:dbee with SMTP id 5614622812f47-3e63848404emr10513769b6e.27.1730203902873; Tue, 29 Oct 2024 05:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203902; cv=none; d=google.com; s=arc-20240605; b=OnAaj7sDxlf+J47f2QnHumbmk3JqAS/uu7LJBAlHVdepP/jeKzZBYbc0+kwELDfQJY Lm4eoSe0+RNS69BIZygcG0EdiO1kn+F3nmV5gsiugEHHu5JTt5hXHMOnvmunoJta3Ou5 H4oXDQRUVq6Obj4+IokV8sSGWbt8XpZXWQbAX4BI0GnYzWTY7NS5M9Njm3LtjWOhqKU8 QynPH444zB7rqFHm6F8yjCSUWARsb8QH2sAb7pw+2JO/LJZbIKpWl0WjbJjLp0+5wAR3 9JAmNhOAT6wALwytOnkO5wGhFjgogMUtS7tvwyXN25YHjh2IcmoWHEUfqNxqj9NjFMG5 qQNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hV9bRORlikllwDGAZFR9/+PU9WimawpPGHP7OfCvCPA=; fh=VyoImqtNGezAyRveop7jJLIY1GvuLKHjGRNqLnjiHgY=; b=j3XU/lfsgowq4NTBdYYTWudsPiDXOq63sNRrB09LXPShWQPNpsjSxC70YjyioNyDkZ O0wuLnXwJpEV471DhjbKbl4h0BYyUZbcoSaWDGkX+iAiN8RS3eWnnfPBTiT2eV4g8LEy iI0ums7yMSU98A3Eyox17tZ6VYTBSaMhpO1Wjh2Srunk1oaimaOhclESbiZYZcETtM0/ tdYj5cGnfwpDXGoiAYhOMKy1GUOY0bzWs8D+A2TEPWVW6H6YJJZTgTPCzrWlWZZ3R9mT KVABxXkcU0XDx1I6hZ+qPbpuC3rOi3+33v1TVQo5qFz9bOgm+iPsAuLN21CP/xr2m/Xy R/Qg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ElYp8Khd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1e0cc1a2514c-85580b1250dsi1931819241.136.2024.10.29.05.11.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:11:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ElYp8Khd; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3V-0004Z0-39; Tue, 29 Oct 2024 08:10:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3T-0004Yn-Q8 for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:35 -0400 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3S-0007Rt-59 for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:35 -0400 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-37ed3bd6114so3453531f8f.2 for ; Tue, 29 Oct 2024 05:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203832; x=1730808632; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hV9bRORlikllwDGAZFR9/+PU9WimawpPGHP7OfCvCPA=; b=ElYp8KhdKz3DWg+8lsZsvpMmGg8Mdhdjym8tLBHzzl2//u6ef+HloMumst3EqHRPaS ZoMAzxDfjhy5PQ8B4jjYQCiwcT3BqSs+gp4F/3smLpI8XPtM0g6W3KReQyGaqIIB2el3 5tJYNLICcDLzYKvWWg+nHmSm/yY7hqUxxkcbdImeripI5GAK4JKm1zrKQtxfgXCYP55P OOIQDt5EhRPrk/ILBePqnnN0Eu/BuMzofbfhoV0pLf0ecn7ZOA/X8ndwGZ+r0U4TBzEe mZNVLj0hGnPHPPBw/bqP07vihDv9ot/gq8VI0fUzL+NE6KRnvG97h6U82XrAS9WNl94T KElw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203832; x=1730808632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hV9bRORlikllwDGAZFR9/+PU9WimawpPGHP7OfCvCPA=; b=XfyE9LNWpoOA9FROts5lrVO9JMyo8UDNCulvzQ5K8NoZ8n4CEbPnAqddpe8DgWmDF0 AQxoqvM8PgUeToPnmA+JkCrJn5/jZ/UrAu352eSS0vbdtSroTeS1L4XhXWZc3G1WuW59 6yI7OjV+dMq/DhL9ELJYZO7KLrJ3bg2/MuGEVQo6IEsJ8uYRjPSVDpf5nSgxKWwpVGfA kzUw7JdnFn+WVErthtLh4MBLFqe8fJWAQtFS1PJl5S7HZScMn4tqdjXNV5cbqKmx5eAE l7uPzGJMYeoNkxc07I2suDyen+Z95gdnL3gTmqG7W/fXV+UajlsJoNL9vhmEfccRGQ0T D7tw== X-Gm-Message-State: AOJu0YzwafIIxMq5YJWg6Gbqpf0AjsGc1Y74gvNTQacMAG9ZmJS8w2Sr nH4nA+eItgnYc6AlHb1Q/nodm+W7tLyUl9LNMymk+VkR9+78LNCD/FosrUQnlkA= X-Received: by 2002:adf:e543:0:b0:37d:54d0:1f20 with SMTP id ffacd0b85a97d-38061158e30mr8505650f8f.24.1730203832597; Tue, 29 Oct 2024 05:10:32 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b712bfsm12319579f8f.79.2024.10.29.05.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:31 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id D2D8B5FAA9; Tue, 29 Oct 2024 12:10:30 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 04/13] virtio-gpu: Handle virtio_gpu_virgl_init() failure Date: Tue, 29 Oct 2024 12:10:21 +0000 Message-Id: <20241029121030.4007014-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x42e.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Dmitry Osipenko virtio_gpu_virgl_init() may fail, leading to a further Qemu crash because Qemu assumes it never fails. Check virtio_gpu_virgl_init() return code and don't execute virtio commands on error. Failed virtio_gpu_virgl_init() will result in a timed out virtio commands for a guest OS. Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-5-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 18b6c3b3a2..71775243e9 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -222,11 +222,18 @@ struct VirtIOGPUClass { Error **errp); }; +/* VirtIOGPUGL renderer states */ +typedef enum { + RS_START, /* starting state */ + RS_INIT_FAILED, /* failed initialisation */ + RS_INITED, /* initialised and working */ + RS_RESET, /* inited and reset pending, moves to start after reset */ +} RenderState; + struct VirtIOGPUGL { struct VirtIOGPU parent_obj; - bool renderer_inited; - bool renderer_reset; + RenderState renderer_state; QEMUTimer *fence_poll; QEMUTimer *print_stats; diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index 29d20b0132..ea3413aa56 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -29,9 +29,14 @@ static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g, struct virtio_gpu_scanout *s, uint32_t resource_id) { + VirtIOGPUGL *gl = VIRTIO_GPU_GL(g); uint32_t width, height; uint32_t pixels, *data; + if (gl->renderer_state != RS_INITED) { + return; + } + data = virgl_renderer_get_cursor_data(resource_id, &width, &height); if (!data) { return; @@ -65,13 +70,22 @@ static void virtio_gpu_gl_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq) return; } - if (!gl->renderer_inited) { - virtio_gpu_virgl_init(g); - gl->renderer_inited = true; - } - if (gl->renderer_reset) { - gl->renderer_reset = false; + switch (gl->renderer_state) { + case RS_RESET: virtio_gpu_virgl_reset(g); + /* fallthrough */ + case RS_START: + if (virtio_gpu_virgl_init(g)) { + gl->renderer_state = RS_INIT_FAILED; + return; + } + + gl->renderer_state = RS_INITED; + break; + case RS_INIT_FAILED: + return; + case RS_INITED: + break; } cmd = virtqueue_pop(vq, sizeof(struct virtio_gpu_ctrl_command)); @@ -98,9 +112,9 @@ static void virtio_gpu_gl_reset(VirtIODevice *vdev) * GL functions must be called with the associated GL context in main * thread, and when the renderer is unblocked. */ - if (gl->renderer_inited && !gl->renderer_reset) { + if (gl->renderer_state == RS_INITED) { virtio_gpu_virgl_reset_scanout(g); - gl->renderer_reset = true; + gl->renderer_state = RS_RESET; } } From patchwork Tue Oct 29 12:10:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839323 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp328596wrb; Tue, 29 Oct 2024 05:11:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWHVPX9I5atvDgMdWaNGWNnVMsJI53FBKCp1tEhLwQc8OF5hmJcwNaqBHL/M3gTWbpA5SfRUw==@linaro.org X-Google-Smtp-Source: AGHT+IEVXf3O6olPZXCTKWfPlSSGTU3nTb3i4/Rh0Boxy/ypI9oiUrJGdIjRHCmrYmOWi51HeWNP X-Received: by 2002:a05:6102:2ac6:b0:4a3:ce63:dac1 with SMTP id ada2fe7eead31-4a8cfd59e11mr9284799137.28.1730203881140; Tue, 29 Oct 2024 05:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203881; cv=none; d=google.com; s=arc-20240605; b=BKOCeW+05ZgzfST8RVc4lUaBZrSo16qhqpFTZuqujHVq5/Te1R9+D1QNWa2MTgjeQY d5UEwYz2jqKcIRHuSVLTQRpUaEwY1Wby4/aJACSJhKyoRMD3SR8YZ2oCpkMBEYYWr0rb Hn6C6TXPHQtkvGitj7kL9cgVnduVggLBktG98b/foDtl7lpxx6Kin1m9FW7QJ+VtdBNo RXwFZyeEwjQDtO0kMs87fkjEkrlBqHaTvoisYJhGNwRm369wEi/HwueEoAFvlyK1mrRz YgC7dZ2RC+b3ZVpj7AcH9m2h/v0LHhuSQaC65+P5+bA67awLrHN+mEH02NQy46FBXIN5 N+qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XPzMIRyHHPYrwvugSrdgfTS150qXNc9bgO1rDL0GqR8=; fh=VyoImqtNGezAyRveop7jJLIY1GvuLKHjGRNqLnjiHgY=; b=WpDc1JjyQY7WvZVggwvo78TRyHrM7V0MD3nMS04KXRDZpXMS8Xg1Yrz0A9UbxDDVUJ qZWnxzlS7YbQD7+eFN7LSqwwykNM/IavaJhkvKX/GPlPzZimRo4otkHgAd+brkrPkZ4M +SGDAKtvEMl6yQXE9zw2VpePkflyXEsB4F81AuvUqmcNPNK7JlGvy6ma3GAC0JIRlP4S I+7j9gPKYW3b62JaVjKUKWO4H+YUm49oojsw9Ud4Mjor6cmSC7cuXpkZPmnYAr34WUb+ VeJ74FKdCabupnlrxRNk7CoZYRMyMQHkOon3bgWmBMUP16joX2tNG1tMZfmbqD260zME /QNA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R5Tk4LwS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4a8c51bab4fsi2473381137.5.2024.10.29.05.11.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:11:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R5Tk4LwS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3a-0004as-23; Tue, 29 Oct 2024 08:10:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3W-0004Zd-Iw for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:38 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3V-0007SQ-28 for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:38 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4315abed18aso51218855e9.2 for ; Tue, 29 Oct 2024 05:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203835; x=1730808635; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XPzMIRyHHPYrwvugSrdgfTS150qXNc9bgO1rDL0GqR8=; b=R5Tk4LwSLjn1ujGeBKBzeq4YEmiLnPfzPFYKOJPl7g9RmRTpKALF5e2dg5E3IRPBsE YlR9EP0f0dXjvcowZbgDyPWIBcEkV8jDbdYKzMZk7DBbjdOz5yv/PGmThqEmn7SjaiXF cOprKLYktWGOJ2FSxZ83E6clkP2dmLhqU7twpNXWwgcp69hYzofuQcW71Xi63d2AhEd/ GQSx5Wit+v68Tj1twWnTlZOrmE6izOMuvK3uKq6f/9msLxiz4ECynfiZJ6OYKf3yD2G+ N0AU7sMqUeOy5lvEfLlnUwHh7NPLoNIGDvYxuAXnq9BOh/75uZ7iYWmyaIfnZpFfQrS1 LP0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203835; x=1730808635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XPzMIRyHHPYrwvugSrdgfTS150qXNc9bgO1rDL0GqR8=; b=GmY4hs6rUBNmAcnAX85LferH70E4SvejyRkk9ivLQvuuUUXl6BQXyv+DzFeuV7eKV5 a0Q1/BAEaiEieJGu3/Qed3jXF+MVKkLow49OZFXrWq9wfiU4VKfptf+ad3PFEqr+XGRM OFDAhZl1Murw5gEfc3QYFVCFHSdlxE56uQRY0CEONgvv95BvBmQiahhjMUSNmPIM6PG1 Rt6Or1Nj0tRnryelcsvJ+P18J6tyNZxtw1BWRFn8hHHJPOM+VdBOYgCrjYxHjhozSwhv GH9YXLnhzz1NZq2afGWcyakkwR349HpcJz2YIdhr8EGUQv+GhtcpsdiIjiGFnetpGvoD i4RQ== X-Gm-Message-State: AOJu0Yx8Jk6+DRd5fPcdWkNwuxYgVNkzS6zC/YqZef7u8MNFQoAKjHLQ UrxWcveggbbpAJ12XRWarcTi0lctqAkZkA4rypj7eMOLbZ9aHDwTHPk9Wyf53gqNRI+ZhkgPfqt R X-Received: by 2002:adf:e0c2:0:b0:37d:940c:7391 with SMTP id ffacd0b85a97d-380611e75b9mr9050584f8f.41.1730203835415; Tue, 29 Oct 2024 05:10:35 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b47a86sm12344746f8f.53.2024.10.29.05.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id E6E8D5FABB; Tue, 29 Oct 2024 12:10:30 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 05/13] virtio-gpu: Unrealize GL device Date: Tue, 29 Oct 2024 12:10:22 +0000 Message-Id: <20241029121030.4007014-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Dmitry Osipenko Even though GL GPU doesn't support hotplugging today, free virgl resources when GL device is unrealized. For consistency. Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-6-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index ea3413aa56..753b35ed69 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -156,6 +156,22 @@ static Property virtio_gpu_gl_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static void virtio_gpu_gl_device_unrealize(DeviceState *qdev) +{ + VirtIOGPU *g = VIRTIO_GPU(qdev); + VirtIOGPUGL *gl = VIRTIO_GPU_GL(qdev); + + if (gl->renderer_state >= RS_INITED) { + if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { + timer_free(gl->print_stats); + } + timer_free(gl->fence_poll); + virgl_renderer_cleanup(NULL); + } + + gl->renderer_state = RS_START; +} + static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -169,6 +185,7 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data) vgc->update_cursor_data = virtio_gpu_gl_update_cursor_data; vdc->realize = virtio_gpu_gl_device_realize; + vdc->unrealize = virtio_gpu_gl_device_unrealize; vdc->reset = virtio_gpu_gl_reset; device_class_set_props(dc, virtio_gpu_gl_properties); } From patchwork Tue Oct 29 12:10:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839331 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp329249wrb; Tue, 29 Oct 2024 05:12:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWVb3obOBpY/JWf+HhgcPVOg7ghuNBEIGkqlVVspeHxUoV7WPJD8A1c4z7Eq0giVgXW1ghLQg==@linaro.org X-Google-Smtp-Source: AGHT+IHnYRJtf2QT65DKjc0233QBZOhT5U9SbEYLy3UKX25b1BqSM/vqLVqX2TQEcZ95JOkE+I4B X-Received: by 2002:a05:6122:1697:b0:50d:3ec1:1534 with SMTP id 71dfb90a1353d-51015071471mr8533700e0c.7.1730203956639; Tue, 29 Oct 2024 05:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203956; cv=none; d=google.com; s=arc-20240605; b=euwb68X2KMSrt+wlBIxvKCkpNxD1RAvKGdkOlidjrOnjg0hudLqkaoDbiaikmdZQpj pRJdR3S3NscmkrmpLcz27ILR8AEEftVZoDiX7jMoZ7nmFCmiitCdrt3OjaJLJc+zEnZt l2vV5mYYEcRakrXW6RVRsyPLb80fKex52kz6U1xCtoMecdlejNKvjh2nOAxUlTWtoa8e Jdp54dAXFn1yAeWGs+h9vx0qLHxdcaFFNISac2nK4NAaPimMSmfK6x1rszhYbzNIl5uM YB3aDn6iMv8h5azgPeDCjA07TDblIXX87JFfOxoU92N6KfHZSNEJ6GOmL4jzGg7cI4BT Dj7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TcXCjHXJMHI5YxkHU4VEpqalzCQd34FPSXySjBFHomU=; fh=HkS3dZuNkhC4vC6jGG25nmZ+vRS2KhOuvY23O507sQ8=; b=RUDlSSNVi7LbmNUEXzfOxAq7qEXBTViLkr8eHt4/huzpJqnZs31UFkAvjURH8U6wxA 9FldInANc1uwiZ3H5/4Ci02wy19Iv/VCmfLF5aDGkjRkiXpzdUUlkLjBJATMAM8RTeMg 4D2CXT7Qer2UPwUlbW4fqjyNQr4USJI+dFI8yDeyrrG9pMvhTKYwkZwMUhr3aGZSudNM 3+lE7Upuwr98skI0N0IjhcanTYx+xg6yq9nRe+8KI20CCqLbD7uW0o0Wle0AVMz2W1C7 hpkdZLcNtrCyCu+/0YEtFDb4vIsdXFeyuZjUy99xqmoxhX28IWk+ZwygGSFV6c6Qa3OA fZEQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OsRZdESB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 71dfb90a1353d-5100430d019si2342661e0c.40.2024.10.29.05.12.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:12:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OsRZdESB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3n-0004f6-9Y; Tue, 29 Oct 2024 08:10:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3Y-0004aJ-6M for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:40 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3W-0007Sr-HM for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:39 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4314fa33a35so51562255e9.1 for ; Tue, 29 Oct 2024 05:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203837; x=1730808637; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TcXCjHXJMHI5YxkHU4VEpqalzCQd34FPSXySjBFHomU=; b=OsRZdESB1ZV8N7vlZGYCtqrNL0japx/T/JeCoviMDoF7UeHiEJWSo18qrvaeTJ4TW5 8hyW2gdJ6Ih0d2VnarTAFeRlvZSkcY7cekpceYMOexH1KmLOi/4TjKGVyGA8IF/RElPj ykqADmTtSRCoBhXfF0FB6LAJ5OffJAh1KdNT4oEBuWypVUvShXbxpmt7oNkLRb1DRox7 imu0MY2uJbmlZCZbndRjlIiqu+CsnBg+0WrBqFkibm7UytsXtNwIn7yo+q8Poyx1vwXy JpT0mejofDF1+0DW5GV01fN5qCfefUXXZAMuF46AjiHoCVI0VG/1BsLNQMQhaYECHDu1 jFBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203837; x=1730808637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TcXCjHXJMHI5YxkHU4VEpqalzCQd34FPSXySjBFHomU=; b=Z/tQ28cMz352bE0PGCUsPoy+H/aqoZWwtzye6Ak/17YBxlMqNIaJTvBw2ynblnPKgu tqbB/sXuh18JjSl2v834Ue1QXiTv6cu9pEilwqApcsEIjhM1pGklbL8OU6V84wXZbkxg 1Oi0I5QyfkuKMctOuQKf5LckSb39JiaRBUUA0VXZBvqrMda+K+DzX+g42He/W61vZLzo IuGDjpYu8tOwq/O5HUQb/oLLpBqd7/7trptA5V7czU/A1Vd6uI8oIdGvgC0DN8S1qAYC b06RTzB9AQs30fN6DFccwWCloZJUxclDRm6zQpLDRtTHLh76r1IWOyMKO1U6/mJJyxDG Bzsw== X-Gm-Message-State: AOJu0Yw5bze9gYEerG+hUlRleROju49tK9JhVDUNK8iZl/pQtGEzV313 2dR5ONSB1HJsPQmOZNQ4bmdFj9GLsefw3bOEQ5rdZc0qX+fTguD+FyWAIpyc7Gw= X-Received: by 2002:a05:600c:3512:b0:431:588a:4498 with SMTP id 5b1f17b1804b1-4319ac9ad1bmr114123305e9.14.1730203836823; Tue, 29 Oct 2024 05:10:36 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b567fe8sm171774435e9.28.2024.10.29.05.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 0B3245FABF; Tue, 29 Oct 2024 12:10:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , "Michael S. Tsirkin" , Paolo Bonzini , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Phil?= =?utf-8?q?ippe_Mathieu-Daud=C3=A9?= Subject: [PULL 06/13] virtio-gpu: Use pkgconfig version to decide which virgl features are available Date: Tue, 29 Oct 2024 12:10:23 +0000 Message-Id: <20241029121030.4007014-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Dmitry Osipenko New virglrerenderer features were stabilized with release of v1.0.0. Presence of symbols in virglrenderer.h doesn't guarantee ABI compatibility with pre-release development versions of libvirglerender. Use virglrenderer version to decide reliably which virgl features are available. Reviewed-by: Alex Bennée Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-7-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/meson.build b/meson.build index 85594fd3f1..8dc53c12fb 100644 --- a/meson.build +++ b/meson.build @@ -2437,10 +2437,7 @@ config_host_data.set('CONFIG_VNC', vnc.found()) config_host_data.set('CONFIG_VNC_JPEG', jpeg.found()) config_host_data.set('CONFIG_VNC_SASL', sasl.found()) if virgl.found() - config_host_data.set('HAVE_VIRGL_D3D_INFO_EXT', - cc.has_member('struct virgl_renderer_resource_info_ext', 'd3d_tex2d', - prefix: '#include ', - dependencies: virgl)) + config_host_data.set('VIRGL_VERSION_MAJOR', virgl.version().split('.')[0]) endif config_host_data.set('CONFIG_VIRTFS', have_virtfs) config_host_data.set('CONFIG_VTE', vte.found()) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index a63d1f540f..ca6f4d6cbb 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -171,7 +171,7 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, struct virgl_renderer_resource_info info; void *d3d_tex2d = NULL; -#ifdef HAVE_VIRGL_D3D_INFO_EXT +#if VIRGL_VERSION_MAJOR >= 1 struct virgl_renderer_resource_info_ext ext; memset(&ext, 0, sizeof(ext)); ret = virgl_renderer_resource_get_info_ext(ss.resource_id, &ext); From patchwork Tue Oct 29 12:10:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839321 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp328534wrb; Tue, 29 Oct 2024 05:11:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/p5BhOsQMrgdr2LqSyAV2wXtB4w4DdpkK8URSo633O+OPrhlTDNqjv2s1U9MARWk+AlVIOQ==@linaro.org X-Google-Smtp-Source: AGHT+IFDMmZhqJOngxskHcLTNLLGptp5zTSGFuAM34XmHZZHCU7szo1TrsdL7JuuCOALvTtF4Hnc X-Received: by 2002:a05:6102:b09:b0:4a3:b0d9:938 with SMTP id ada2fe7eead31-4a8cfd6d883mr9203541137.24.1730203873144; Tue, 29 Oct 2024 05:11:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203873; cv=none; d=google.com; s=arc-20240605; b=hCuTl5HOf/+WxtkE1kVCJAXbOHejk4xxYZphHHhFGF5aXdR40mplMFgOzyqQQVxEPX ck+uyYXZF5/UXZRqhdNVtX8ipwR8g33U+RYn4UcEdNtnlM3nV5CNbJhofUgtKD3GGkfv aVgXT4BhYcUxrpUGoWBm0lIR/PaoD8Oehi4aH5KsD85VoCgYyi201IyjntktS0jn/BK/ gj0loRn/2LLZTQyskuH8NQW01D6RxfjEMJXllbQdsgGnl7rOeJxt4bPOg+vXxSHKwYaf /4oC95BRfhhbnkBJ+0hbSP/8NY/UimgyQ701if5G9jPVdxnX/wVt1TfzpJtp+JpyhnA/ Nhwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Lowm4YyV2GElWtVAlyi9nUtaFHXu7/ajO637WhpLQKM=; fh=YyRRh1ltzeKfnsRgE68PUrKHmX4gqaTMFatU6ae1hWg=; b=Koo/fNiPG+Ts4dHP6W4SR4SF+Bldv0ugSa9ijXDLjbReJNIDTxEtITfllcbvRXBvHa eKDGY+7AVnKU1MWB4k/AwhXYu/p21OGt8R+WG9hCUtetXWqHWho81VxbIiR+z+wz19tM CBdS3BDLi1Xu0Aqo2KlYBj5CJXyQNxuiVEuQXWataQGk77PLX175NZd2K9Mgl+uHeHdA lCedT3ht0H4vjyV6CPxsAdQs2NXI1u0AUrktsFEHgi/S+nQdPq9z3Q+ip0Zf35gfQEKP PF36/Lu2ppxznLrVlNH29k3usBfMOV0BaqzqhCQ3098IZAsU4fBXl/u96pMsJCJrwgKR RzYw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xYVnIbC1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4a8c534aa3fsi2406396137.551.2024.10.29.05.11.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:11:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xYVnIbC1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3k-0004dp-VZ; Tue, 29 Oct 2024 08:10:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3Z-0004at-HY for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:41 -0400 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3X-0007Sz-Ai for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:41 -0400 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-539f1292a9bso6285352e87.2 for ; Tue, 29 Oct 2024 05:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203837; x=1730808637; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lowm4YyV2GElWtVAlyi9nUtaFHXu7/ajO637WhpLQKM=; b=xYVnIbC1ac2tJEgnUEHNJ5uDPzfWmZOspdwbWTOJZeSK7W1KaszhF8Tv1JuSlWW12Y xoqvrHwtSn3F7RO5dEr+WN2VgBW3mALQRrjUtkukKk389p6gg/ajflX3Ers02zwzYyk1 Yxhk/yQkET3vSy2exjA99tc+rWOC9fSgQ8Zdc1Ojl0BEgGi27bLqeCF/E3PRfO175GZt NBnfoNDiveSzVzhytri2CpDCVlY6ig6yCXZo+/NyLSplIpw3L+sAl1tes0qnKIig+tzM PG4Ax5qkC2a/efXz/0Dvn0vW3LsqJJvNCJsCSbbHntVYDxlKeTJ/+tnZaTT6R6meRvzs R2Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203837; x=1730808637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lowm4YyV2GElWtVAlyi9nUtaFHXu7/ajO637WhpLQKM=; b=nl+IMkaj4CEBtM/KzVerhAz1J7DuRvGIwoQOePe5tRNC5Av+LMeEVlVAYzIKnqzj37 GIxGi2SYMvAovPMMmYN3XOw7KG2ezOwZYvhcdSvjUBoZ+mITUAxBPr6qmtCFfLvxVdh/ s0k9lBCVfQH8s9u/pI3QP5wNi77Fko9hGek0bNqtjvTyloot2LZ0e4PmZaqKpXPN+GFR p0gXpC7cEFsAVGO29Wzl6ZMSQBlYoiQ/U6xJFlqiRDa6LQUn11GV0wL7dGuhbqKJlMRf 8yO5XFu6Up8vkHw+JQekudQvd6GDGREUG01xUtV/H4mFfDYTzx09f9rQoSoYea2WNKYb uuGQ== X-Gm-Message-State: AOJu0YyDC46IDAyu18SjKEtcRig/XD+Jh5itfexF9WgI5BR+XNjimpaq zKM/YyYXRO6TDLdrJXnvG+EcBTr0wL9rNWAYux5KdYfx6rF2nQM6dEsT3yUYJio= X-Received: by 2002:a05:6512:32c7:b0:539:a353:279c with SMTP id 2adb3069b0e04-53b348d8f6cmr6306914e87.28.1730203837419; Tue, 29 Oct 2024 05:10:37 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058bb1bc3sm12200227f8f.110.2024.10.29.05.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 2676B5FACF; Tue, 29 Oct 2024 12:10:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Huang Rui , Antonio Caggiano , Antonio Caggiano , Dmitry Osipenko , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 07/13] virtio-gpu: Support context-init feature with virglrenderer Date: Tue, 29 Oct 2024 12:10:24 +0000 Message-Id: <20241029121030.4007014-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::133; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x133.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Huang Rui Patch "virtio-gpu: CONTEXT_INIT feature" has added the context_init feature flags. Expose this feature and support creating virglrenderer context with flags using context_id if libvirglrenderer is new enough. Originally-by: Antonio Caggiano Signed-off-by: Huang Rui Reviewed-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-8-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index 753b35ed69..bf87ba4232 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -147,6 +147,10 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp) VIRTIO_GPU_BASE(g)->virtio_config.num_capsets = virtio_gpu_virgl_get_num_capsets(g); +#if VIRGL_VERSION_MAJOR >= 1 + g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED; +#endif + virtio_gpu_device_realize(qdev, errp); } diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index ca6f4d6cbb..b3aa444bcf 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -106,8 +106,24 @@ 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) { + if (!virtio_gpu_context_init_enabled(g->parent_obj.conf)) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: context_init disabled", + __func__); + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + +#if VIRGL_VERSION_MAJOR >= 1 + 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, From patchwork Tue Oct 29 12:10:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839329 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp329174wrb; Tue, 29 Oct 2024 05:12:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVlqqeEB4I+D08mdNomvUevszo3np43aaPpPHLoEMlUPvFTHbwqGaRLVuaaXoVR5/Kpo45Hqg==@linaro.org X-Google-Smtp-Source: AGHT+IH2+TKaAk09Vz9iNEhXvX1u6Gzr9uWXUgXemTX9h9caY+9uaAgbSrKX9bNL/+jTnkrGWMIr X-Received: by 2002:a05:6808:1886:b0:3e4:d3e6:7269 with SMTP id 5614622812f47-3e6382485ebmr9778467b6e.17.1730203947907; Tue, 29 Oct 2024 05:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203947; cv=none; d=google.com; s=arc-20240605; b=fOev8Lqh2JC+aqckc18+jzbqkfeu6hKA/Jj9HUCdQbJuUWm4LGfYoXIZ4SWJhXHECw z94JEOjUHM2ot3ceTCq+gMa+7SoyCJFCMGG7lLyWaZZrE4Oj7VnEfGWGnuYIkXN4uSc4 z7s9vCzrYkNAKmxOHosowtdShbiky8xxkzm9UtFjLe7J47+QYTBwUkHLoR8fhfm448dj 3xCAZR5rFEuHgOzm9EmiRg8uGIQa5k9vYKGmmQFTd9cndJdnQST38z37bPGWNueygsnL rHEIBXgXQSIymF/JJv+LwnfsDl0BiEXGLP49GrBUzf6O+zTBJJodVuWJbF+bpOdHnk3N U1Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/BNiYYwKg/cSvehabs3gJ4EqBVuo2qMpFiEegCIxlqY=; fh=e52DzqoCGQsndoHy+FCTVMOSIYSVinunqfNVIbzL1G8=; b=AUsY07w47SkNWsCgvNc58TSs92gzzBr4mYHkFIet7PsegtW6d2jJJsFMSQnYyJS/Vd V1LNdeWCL2lEZHCwXcTE5CnbUioEXW1SfEw9DFXbCmS0rGbZen5G1XxSeCwnfHB2wrRS bP+cxE5Lr20RAPYBPgAe/bBlIOIeVbyk3bZmxpC96+mtxXE8//ET+3Us+paJNBTBsXqe Y5aJo94Vb6V3/usoRx7BzP/ccv8cLGGTNalwFlrMe5EXHdltOHcgOA2kUpmqHbdmUS7w rvgUl+BsH8hHVEJLXRBoVKk3P1/MbqpOlpuGJVfbUSBUwaOh3h4/vHpl1fjwe3RzijNx oiaw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t8z4IMOO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4a8c5399b86si2186697137.664.2024.10.29.05.12.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:12:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t8z4IMOO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3m-0004ea-2x; Tue, 29 Oct 2024 08:10:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3a-0004bc-HI for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:45 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3Y-0007TW-UN for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:42 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-431616c23b5so38269945e9.0 for ; Tue, 29 Oct 2024 05:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203839; x=1730808639; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/BNiYYwKg/cSvehabs3gJ4EqBVuo2qMpFiEegCIxlqY=; b=t8z4IMOOm1p9Z8ZJ4QclBKp7vJEIB/1rFbnS7Azlw/NzJLyYphsaAAXbQcnqjD2zIh uqo6dSdr3AV8nsJaiZNkIDgKDhmqbKr1ornStlsXmjcEAn+wftkIZhWJbew35P2ZyRd4 rowjyw6rSRRt0aQQdRLmeqGHS9HYaB9/UlL9A8utvtBMAKj0LTQMMPKx7LklgqZF/FI/ wg0aXbF4Svx9DIQNF2tyVizxNsca7IqdTXPKMa9VwwGaImQPCycWFXihiimKzzL7sHxY Q9rntDNSY0I8bO1XcatPX+tOiD43GX7n/TMVVPyIIkcVbdJKBvtX5PWH6c/zS8Ro0DSH YKSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203839; x=1730808639; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/BNiYYwKg/cSvehabs3gJ4EqBVuo2qMpFiEegCIxlqY=; b=CiU1ujAXsgUCdS9Dt/ApLHyjDMyCRj/co+bd+VfIe342jqj4F7WIF/en0+22hLQemj R+J8dC/6R+EUgNVBy6UCINFzSWTYCOxTTamUG/Ky/GiF6kZoy+Yi0evN3Bs09OYXujgf QAVHV6g/qbeLei1v5PMR+QQnYkvCXgKhzAaMq1ilaSRHrettLJadx2CKvGquwL5AH8Dd Puiw4RDvCwXvWuJPvKDtAMBHUsFqW/BuPA+lok4RYah6583BXa3NuWnZgwAtxQ/hwPyn XmrkUXoia24w7401zo6lkCThQ/9si4e5ZuTaNT1tsiHyUT9zqNqgHg/1pMKEItzhwBmO 9VZw== X-Gm-Message-State: AOJu0YyQsxL1lEire/DLZmgfCNCMaWtnMqn1FkSGq4rLp34NoFt6JCnN I43wCmVyPHYGP9uN2uFMKv8zxpmGGAfy0JHqe9w8w4IAzzqOoMfUIbt/YJLhBq0= X-Received: by 2002:a05:600c:3042:b0:426:5e32:4857 with SMTP id 5b1f17b1804b1-431b564f547mr15996905e9.0.1730203839549; Tue, 29 Oct 2024 05:10:39 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4319360eb09sm142290695e9.48.2024.10.29.05.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 3C50D5FB2E; Tue, 29 Oct 2024 12:10:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Antonio Caggiano , Huang Rui , Antonio Caggiano , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 08/13] virtio-gpu: Don't require udmabuf when blobs and virgl are enabled Date: Tue, 29 Oct 2024 12:10:25 +0000 Message-Id: <20241029121030.4007014-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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: Huang Rui Reviewed-by: Antonio Caggiano Reviewed-by: Marc-André Lureau Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-9-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 3fcc434732..3d9679c1ef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1455,6 +1455,7 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { if (!virtio_gpu_rutabaga_enabled(g->parent_obj.conf) && + !virtio_gpu_virgl_enabled(g->parent_obj.conf) && !virtio_gpu_have_udmabuf()) { error_setg(errp, "need rutabaga or udmabuf for blob resources"); return; From patchwork Tue Oct 29 12:10:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839325 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp328702wrb; Tue, 29 Oct 2024 05:11:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV6eYocux6j43ufx2QDUfBzJdujxiSA8XpOzT4VJWVtegwazD55FvucagqkvCcrYZTI8ntXSQ==@linaro.org X-Google-Smtp-Source: AGHT+IEbDfPcEBzZ5rucYWLEm033AmaxvyX4OaPb05S7c4Ffgx5VLZ0Ju53JUBCPSnaIThSMNGFu X-Received: by 2002:a05:6214:5881:b0:6d1:848b:a8ce with SMTP id 6a1803df08f44-6d1856fc80amr185499496d6.28.1730203892489; Tue, 29 Oct 2024 05:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203892; cv=none; d=google.com; s=arc-20240605; b=BK8b+fXE+XKAj+u2tQ/Lnkzrl8ywaUoMw4la4sr6/2Wv6uzq3ekJ5BocKaZm8Ol6pF 5UNKNujEl93xk/BcrN+E6EbtJzKb1mquu6b8f8Y7hr/3SOJZLe9shsw22LyyhTFGu/81 TxBEsn5au6OQDOy3drgOiz4kTHyff35RpsP9JMqH6ow+/ORwnu2gU3cCsnJkxqDL/wS9 +8GSttqfFJ0omAuj8j/tlzvWI052QCdlyeIVdJ+Ezl3rX4plJXTpOOk/WPvfdqHmFq50 TzwTVGb2JEcqWLTYY5BxBI6q1zglEVWPCTnCSOqUjSQo1f9DcTMEl2rHz0h61VK+yljG PY9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ncfRO59zfqeBy20d7wY0nXZGIrmnZICFoanN5hMrK1U=; fh=x26e1KkROJK7CqR9C3GvbwHXxX3mljOhD7odcEM+PX4=; b=JLfR119fs+HoXJNd3susU15srrUEH2UAgdH+Naw41DHilPeXcCrQ7GZksIbk6107mE lH78cVghxZu8tevneVfIprjh98laVPohkcj4hUaFYWjgGxYr2Y4VaIYf3GIJaU6QiIAq tdLe07luqIBolbAjhLdgUf6EnZwp62fFJK8bkLyNeTBxdRcYA4MUghZ6xRh5TnG4yN+S +SgFMeBKJBoI9Tad/dp5hyeIqCeIc6HJDyWybymKx9+EDQCkUHyR14vV2+qXcnho0oNd pTRWugc99YcuMMGQjfqTgudKXqWomrclhvxSSFyPLYnfJOqoSHeNDJYKglBBvriLiztf 0H8w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TUEaODpZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6d17986e4adsi111519376d6.111.2024.10.29.05.11.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:11:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TUEaODpZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3f-0004cp-1X; Tue, 29 Oct 2024 08:10:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3Y-0004aV-F8 for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:40 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3W-0007St-OT for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:40 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-431548bd1b4so51195055e9.3 for ; Tue, 29 Oct 2024 05:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203837; x=1730808637; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ncfRO59zfqeBy20d7wY0nXZGIrmnZICFoanN5hMrK1U=; b=TUEaODpZd+jrpnGNyYckJRERmp1SBeQRmC/Z1PKx3ZkkQxxkjFSIK1SAozp4fj+lqq n+BejvGWsjamC+dtMB8lTEt4txmNvLQr/VcTFtWETvC7qMgMoBy2z/0qY7yzVRmH1r/7 gycRPvJLPSXjpnAOF9MIur367Kxh8FD8eySjSZY+4vUHjiNDCyb9jBjTdC8w55rVxwIa 2MloUceFOzZTDOJN1KjTv5sRYVEE2IPryolAuCv7XIKEtxJPrTD7w0J5fMa+h/6/tSR0 thILGQfwUR3FOOA3FdPOJrebu3dRucyLqQ771NI8uq9qW7Bz0iljyJ8hthWPuF0WsZBX 15vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203837; x=1730808637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ncfRO59zfqeBy20d7wY0nXZGIrmnZICFoanN5hMrK1U=; b=QkqtY3A76fenlNF3wmDc+nhsMkZvuB1jcogdkV5giuRcNAzrOSUNinwXzBbNxJQ+Es /hbyAnK7k3DoGqVOMMCnVuDT1v0mPa19rlHaCQmPCkU2A0B1LIxSU9cEcfoo617R4v5k 8c9jHeujzulUHCsJg3EBB3AjW6DzRyOfRA0Pu9Z0vV0xXWyvF8a5FiHe88MVaRJbOZ9K QNKfbi5D7y050TU3sSzY+Ts+gCYmIw6W9ZVDCKk+fo+VCzVbCCkL375JmgpXwXfQxJfQ XXBdPrvQgc43HxHAgQlXTLKJYDxxs/49iIkiOGzY76AWqP5i/YWThfzU1XWWPNzLQGZ7 Uu+w== X-Gm-Message-State: AOJu0YxcZ+1rU3QACgbJ1Jp7QWp9SjRN0xnTzUsP7bKjcuznxzmlbVAj 2uVh9BkJWvmKsp0O4AgwHR6Km+8+YK98mJxF0B7nWDSr7d0IveIkGztGvqDE0HA= X-Received: by 2002:a05:600c:35d3:b0:42c:c401:6d8b with SMTP id 5b1f17b1804b1-4319ac7832dmr102306955e9.7.1730203837128; Tue, 29 Oct 2024 05:10:37 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b1c8a9sm12375250f8f.12.2024.10.29.05.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 51F735FB43; Tue, 29 Oct 2024 12:10:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Huang Rui , Antonio Caggiano , Dmitry Osipenko , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 09/13] virtio-gpu: Add virgl resource management Date: Tue, 29 Oct 2024 12:10:26 +0000 Message-Id: <20241029121030.4007014-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x330.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Huang Rui In a preparation to adding host blobs support to virtio-gpu, add virgl resource management that allows to retrieve resource based on its ID and virgl resource wrapper on top of simple resource that will be contain fields specific to virgl. Signed-off-by: Huang Rui Reviewed-by: Antonio Caggiano Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-10-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index b3aa444bcf..3ffea478e7 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -22,6 +22,23 @@ #include +struct virtio_gpu_virgl_resource { + struct virtio_gpu_simple_resource base; +}; + +static struct virtio_gpu_virgl_resource * +virtio_gpu_virgl_find_resource(VirtIOGPU *g, uint32_t resource_id) +{ + struct virtio_gpu_simple_resource *res; + + res = virtio_gpu_find_resource(g, resource_id); + if (!res) { + return NULL; + } + + return container_of(res, struct virtio_gpu_virgl_resource, base); +} + #if VIRGL_RENDERER_CALLBACKS_VERSION >= 4 static void * virgl_get_egl_display(G_GNUC_UNUSED void *cookie) @@ -35,11 +52,34 @@ 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_virgl_resource *res; VIRTIO_GPU_FILL_CMD(c2d); trace_virtio_gpu_cmd_res_create_2d(c2d.resource_id, c2d.format, c2d.width, c2d.height); + if (c2d.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_virgl_find_resource(g, c2d.resource_id); + if (res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n", + __func__, c2d.resource_id); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res = g_new0(struct virtio_gpu_virgl_resource, 1); + res->base.width = c2d.width; + res->base.height = c2d.height; + res->base.format = c2d.format; + res->base.resource_id = c2d.resource_id; + QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); + args.handle = c2d.resource_id; args.target = 2; args.format = c2d.format; @@ -59,11 +99,34 @@ 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_virgl_resource *res; VIRTIO_GPU_FILL_CMD(c3d); trace_virtio_gpu_cmd_res_create_3d(c3d.resource_id, c3d.format, c3d.width, c3d.height, c3d.depth); + if (c3d.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_virgl_find_resource(g, c3d.resource_id); + if (res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource already exists %d\n", + __func__, c3d.resource_id); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + + res = g_new0(struct virtio_gpu_virgl_resource, 1); + res->base.width = c3d.width; + res->base.height = c3d.height; + res->base.format = c3d.format; + res->base.resource_id = c3d.resource_id; + QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); + args.handle = c3d.resource_id; args.target = c3d.target; args.format = c3d.format; @@ -82,12 +145,21 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_resource_unref unref; + struct virtio_gpu_virgl_resource *res; struct iovec *res_iovs = NULL; int num_iovs = 0; VIRTIO_GPU_FILL_CMD(unref); trace_virtio_gpu_cmd_res_unref(unref.resource_id); + res = virtio_gpu_virgl_find_resource(g, unref.resource_id); + if (!res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource does not exist %d\n", + __func__, unref.resource_id); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + virgl_renderer_resource_detach_iov(unref.resource_id, &res_iovs, &num_iovs); @@ -95,6 +167,10 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g, virtio_gpu_cleanup_mapping_iov(g, res_iovs, num_iovs); } virgl_renderer_resource_unref(unref.resource_id); + + QTAILQ_REMOVE(&g->reslist, &res->base, next); + + g_free(res); } static void virgl_cmd_context_create(VirtIOGPU *g, From patchwork Tue Oct 29 12:10:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839332 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp329285wrb; Tue, 29 Oct 2024 05:12:42 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX5AnJDUtF174DwyeJVd3jVBk+jDkr2v8dyY/dpAFI2aP79/t9EdclnlsrNRgzvgQAmw1hXTg==@linaro.org X-Google-Smtp-Source: AGHT+IFFRsyN3RswcyatjlQUinDYPbpKHk1qZnjGdWB6Zf6SK6KIPq6puvZuLVf1pPwL/au29/tC X-Received: by 2002:a05:6102:c86:b0:4a4:8928:7181 with SMTP id ada2fe7eead31-4a8cfd69b87mr8754061137.29.1730203961986; Tue, 29 Oct 2024 05:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203961; cv=none; d=google.com; s=arc-20240605; b=RiarTUOz6l2Ja5v7kE3vMLiZQvlVtR4sAp+8HFuDF4XMlYdMgVdelniY6P2pxi+3Tj 41jQGebxKPWo0RSVhHXoqEW5wp22AWikGleU3cuyuZL6SKeQlyfAJEaTqpqaZtE5uXuA XFGWocuagniAI35Chuxbc4n0dG77R1K4OZNujGltea65ovrgZ4JLmat9vo/KO+Wuo0xA yVKg5HAn0p8KBqliLVxOe5jfMI114yOAdirJcDZqq25ymYtD1kzOOLbWLIzL3Xa4rJn1 N7Znqg42Iu1ihQSWtSk8badzWOm/OUzItaoZcuyck5lBOi+/GigXaQEC8/VwtrF9bFFF Lw/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lAiNUZHWMY8UPn2mHH/EVqrwGLL5X/il2luCyizrIjs=; fh=w99Yap7FLIJRLhFiWnRHkpNnh3wm8CJGv7ueKT6PKxg=; b=COiA/xtgXiBfN0zRsi0mcul2mtnvC7KGVmnDHShoZQFseN8d5MM+C/g6SINmD5Myv2 YAUnyKd5Xslmdww0M1hHFvyvbC45D5hprxZUESoAKcnmkOpoip/rrHzXwEvq77W/j4ht TgBC9KBB96R5FzgEjDfY3qoJgm2jnUVS75I6r4v191tEvRK6gw7/rlwUdd/hGF7Wh5Hj ccjm8EMidFqjEvS3MvYq8VDHJTUzIfHxjMG96H7QWdTAWSQEQljufH0ACHb3fiERZiex aywWbNm4maRQYJ+di80o8zhVCghDJLAxYGQg6UJWmE9lttnXMyD9fTsjmlNzUqnlby2x MF1Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FK6JgtKQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4a8c539ad2bsi2280786137.707.2024.10.29.05.12.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:12:41 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FK6JgtKQ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3l-0004dy-8M; Tue, 29 Oct 2024 08:10:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3a-0004bN-6n for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:45 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3Y-0007TL-Go for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:41 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4314c452180so43846415e9.0 for ; Tue, 29 Oct 2024 05:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203839; x=1730808639; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lAiNUZHWMY8UPn2mHH/EVqrwGLL5X/il2luCyizrIjs=; b=FK6JgtKQsYObCyuXCrI080FboH2GbVw/cI6lr8P+SaJdB8kJNs/iBbOuPd2ZCgiYEP E0IWFfJTbnsQdvuqyvQN54ztitsNk7svIpwYcFa6muaRrZo+oUdaq1t+8GhPGhnP0onv 4lmSFCedeweDAvKdCHgDpcyegwCglKwfZoI25rcfunqIXaC8kF/kg82dkuWomimtiFBH J9YQjcZkCqlgzdyQYSJe1V4gph7L2Wmg6JM/fxgz+/HoN0DxNjtMMEpshZ18GbwNvVI2 LMeS6v/JGr0A/j+5dh6sQLW7hH8vHEciGQKVruc/70rBMwkyyoxYo23HvCtWiPzv3bdU 88zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203839; x=1730808639; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lAiNUZHWMY8UPn2mHH/EVqrwGLL5X/il2luCyizrIjs=; b=OFY0ph0Sj7q2HHyhlNc+fGPfqLPZEdQCDoeTpMoGnywAzA1qbU7bKJXXF1zkh5Bs67 swxsDC8/IzK/PArO6NhogLROAQrYrYaMjj+gVH7ja9XYru8X//Luj++fbk+RYHaENPjH yoX/DM6dnX+MPyPNOEyzXbKysQDLikmA4pw3FkDPdZ+QgwIaF2KqwtlB1+Iq2wxDwNHj /kptpgPKcMtd29aBq8pViGqrHxZx0ZQClSBkqPXZnXDZdNTVB7N1voOnV+bYmHFyL3tt BiBleMdpyYPTrPKNo/P37rCeQL66a60VNWffmcF65C4n0DFQDIJdaO5+VuQF8I+rGzu/ h76g== X-Gm-Message-State: AOJu0YzrgwK+aCjkiZ379UruQTO0GC3dgvG3JlH08ODSOGtqdazJgIte bEtGAlcwZ+QyYPAaoZe4EbN/a22//uINb3Hi5SCwvNe+ePbT21Pn/D5Bvtl0uIo= X-Received: by 2002:adf:fc83:0:b0:374:adf1:9232 with SMTP id ffacd0b85a97d-3817d636aecmr1454300f8f.19.1730203838951; Tue, 29 Oct 2024 05:10:38 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b3bde6sm12349602f8f.40.2024.10.29.05.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 6B09C5FB4D; Tue, 29 Oct 2024 12:10:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Dmitry Osipenko , Akihiko Odaki , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 10/13] virtio-gpu: Support suspension of commands processing Date: Tue, 29 Oct 2024 12:10:27 +0000 Message-Id: <20241029121030.4007014-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Dmitry Osipenko Check whether command processing has been finished; otherwise, stop processing commands and retry the command again next time. This allows us to support asynchronous execution of non-fenced commands needed for unmapping host blobs safely. Suggested-by: Akihiko Odaki Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-11-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 3d9679c1ef..180d882f0a 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1034,6 +1034,12 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g) /* process command */ vgc->process_cmd(g, cmd); + /* command suspended */ + if (!cmd->finished && !(cmd->cmd_hdr.flags & VIRTIO_GPU_FLAG_FENCE)) { + trace_virtio_gpu_cmd_suspended(cmd->cmd_hdr.type); + break; + } + QTAILQ_REMOVE(&g->cmdq, cmd, next); if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { g->stats.requests++; diff --git a/hw/display/trace-events b/hw/display/trace-events index e212710284..d26d663f96 100644 --- a/hw/display/trace-events +++ b/hw/display/trace-events @@ -55,6 +55,7 @@ virtio_gpu_fence_ctrl(uint64_t fence, uint32_t type) "fence 0x%" PRIx64 ", type virtio_gpu_fence_resp(uint64_t fence) "fence 0x%" PRIx64 virtio_gpu_inc_inflight_fences(uint32_t inflight) "in-flight+ %u" virtio_gpu_dec_inflight_fences(uint32_t inflight) "in-flight- %u" +virtio_gpu_cmd_suspended(uint32_t cmd) "cmd 0x%x" # qxl.c disable qxl_io_write_vga(int qid, const char *mode, uint32_t addr, uint32_t val) "%d %s addr=%u val=%u" From patchwork Tue Oct 29 12:10:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839324 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp328671wrb; Tue, 29 Oct 2024 05:11:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWFB8c4KjrgPJbmJgOQsw+X/cRv1WjpsoXY3PdLrn+FgB75uywA3lanumCGbJocBjJy2F9IJw==@linaro.org X-Google-Smtp-Source: AGHT+IGjcwPevpU1MEZjeU9TL0i/vSolGUi0LoCmEIj1hjWJ+RRJVsCUSqIRCWB+WMnoFU7zneVr X-Received: by 2002:a05:6808:1994:b0:3e5:f894:b29b with SMTP id 5614622812f47-3e6384be802mr8862958b6e.31.1730203890174; Tue, 29 Oct 2024 05:11:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203890; cv=none; d=google.com; s=arc-20240605; b=G2fpv2reGxcGmr/LoL6rydOJVaLlacK3PEJrNf8HgcJ3iHVatgsr/TvqqWjh5g+iiD ri3RvsdKRQXsNqpaRZsOaBzclDAoNFK6zkmKcgEu+DftKr63FGmLB2kh09xv9vST3CVc 5WJK5X0H/Zs7ThAiDZ/W2CB4LnSZncRxy3jWXq0tmxtXHAHrhyqAfyYV9yV83A44P3gP vqgVT7yHaGN5/p9NkNtE6KYwLPlg7yLuTtTLK4A24bxUKZN1BA/Z5I7KltBEUBk7aYM8 pPL/6wF77/XCu7a48izRgbvQY7i+bHHlj5ilkivuTVibSErOG/JLjh05c9x+JVvodBne +Yiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eiF4We6U1bIBZNQjR2pbzHUxPZUiAb1h+dbUtjDVgno=; fh=tgdtdVHyDYOr3OvTK8Ezqzvzx62W0vUQFlsWmp5ZI9Q=; b=TJJJ4Ud0+SMkRFMlF9DOHpoTH88TH+GTyogSqZkyr9sgtV/NgHa+/o/o5msO5GyA2+ UNtEJ3evXfO+whtEdF4WAKX7BQwoGuvQkG8mVisSfO2L+cOsI0u5gyi7tNgSH+MJTNqN oWFx+HnnwQMvIHeiZ0FuGtgRN4+ueX5LlIgLcKPiZ7Lagoga4eWbbEBh18lRwdn1ERxk s3bhp9tJ7DU3pY5T91Bnb6uK7vEDmdzffz3qV+N5uN18UZK3T81TJr9WTFdiKeHieN6B rEORk0yX92TVLD7V+vCtGERdf+RU/ElmBSKK2TGSNM82Rp/k6naNJaMj7AQ+OdYzsyil TunA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RJf6E70R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4a8c51bab37si2326226137.80.2024.10.29.05.11.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:11:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RJf6E70R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3o-0004fX-T3; Tue, 29 Oct 2024 08:10:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3d-0004co-Ox for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:46 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3b-0007U4-1e for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:45 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-431695fa98bso51937085e9.3 for ; Tue, 29 Oct 2024 05:10:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203841; x=1730808641; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eiF4We6U1bIBZNQjR2pbzHUxPZUiAb1h+dbUtjDVgno=; b=RJf6E70Raw/+XMo+Imm1XWlDpTOU2tF6Ku8/j4F9loDMiXFBUmEaxBSde3kwSNtwP8 ssjRcLyLnPlbi7ux1wDhdN+yYB8KOzpDvwJ4ElWQ4s9R7OFwv7L8X5cCtKvb47xK6aGc zdH5/Gpy+M7PFmb56xJqJe11isjvuIwfoJfszaVQjG61Zp5+AXeBriclQldbCvc085Ew HZ9sXrR5QcbCDhU2u8w6aDVaYdRQ7BAmE4rqKcH2rU4P8nZSYrLr76NRAZEnJa8cJ5Jn yvzF2wyC5z352zaxcYXUs//Z/r2r655zzSoFynjlQZ4uqbGzVvGunAzR446xHhpCSymT 2Seg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203841; x=1730808641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eiF4We6U1bIBZNQjR2pbzHUxPZUiAb1h+dbUtjDVgno=; b=e8drDyGjSgqkC/7dSnTfwJDJ64fOFE/5DcrP2F24hpkwMisZvqGrs7AUdy10GJESt1 IeHXy7k7WvWC16n4Is8scnEqc8GpGQ6ksRApQAcjPE+tX9bsoZax79ZcZzYGMHaKcLSw bqzMZ9/jPt4HJZxhwNAi110CMNtwra3LVTSzUwKH+JcpALmjyjKugoW1hU9TFVnMCew6 0g1UhjpEqoE5GJfzSdSkK5kReN+hITo9sPiygbqB5gCr5BsKa7mNBwn2baRW4L/Vim39 qX2on3MErnnjmBIS7s62mF4aMU7cnceLaWACLZw4HqjA5Z3yuh362iK5NG7wtiwGa0jc H3pg== X-Gm-Message-State: AOJu0YzXG/ggFw/Ucv06z7WxR39OTetG/CF64FbBb6rUI1tp51/Rx8yd uHrRPS/ZncOVg1Mfg3ZhbHVVezjZNARx/tbpaoq0+RJx6Y+yBJwGu/wWLhzgsQs= X-Received: by 2002:a05:600c:4fcb:b0:425:7bbf:fd07 with SMTP id 5b1f17b1804b1-4319ac6fb93mr105702185e9.5.1730203840954; Tue, 29 Oct 2024 05:10:40 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b56ef06sm173199245e9.30.2024.10.29.05.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 8772E5FB6B; Tue, 29 Oct 2024 12:10:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Robert Beckett , Antonio Caggiano , Xenia Ragiadakou , Huang Rui , Dmitry Osipenko , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 11/13] virtio-gpu: Handle resource blob commands Date: Tue, 29 Oct 2024 12:10:28 +0000 Message-Id: <20241029121030.4007014-12-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Robert Beckett Support BLOB resources creation, mapping, unmapping and set-scanout 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: Robert Beckett # added set_scanout_blob Signed-off-by: Xenia Ragiadakou Signed-off-by: Huang Rui Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-12-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 71775243e9..f9ed81071f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -237,6 +237,8 @@ struct VirtIOGPUGL { QEMUTimer *fence_poll; QEMUTimer *print_stats; + + QEMUBH *cmdq_resume_bh; }; struct VhostUserGPU { @@ -336,6 +338,13 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, struct virtio_gpu_framebuffer *fb, struct virtio_gpu_rect *r); +void virtio_gpu_update_scanout(VirtIOGPU *g, + uint32_t scanout_id, + struct virtio_gpu_simple_resource *res, + struct virtio_gpu_framebuffer *fb, + struct virtio_gpu_rect *r); +void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id); + /* virtio-gpu-3d.c */ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd); diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index bf87ba4232..f2555673a1 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -166,6 +166,9 @@ static void virtio_gpu_gl_device_unrealize(DeviceState *qdev) VirtIOGPUGL *gl = VIRTIO_GPU_GL(qdev); if (gl->renderer_state >= RS_INITED) { +#if VIRGL_VERSION_MAJOR >= 1 + qemu_bh_delete(gl->cmdq_resume_bh); +#endif if (virtio_gpu_stats_enabled(g->parent_obj.conf)) { timer_free(gl->print_stats); } diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 3ffea478e7..b2f4e215a7 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -17,6 +17,8 @@ #include "trace.h" #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-gpu.h" +#include "hw/virtio/virtio-gpu-bswap.h" +#include "hw/virtio/virtio-gpu-pixman.h" #include "ui/egl-helpers.h" @@ -24,6 +26,7 @@ struct virtio_gpu_virgl_resource { struct virtio_gpu_simple_resource base; + MemoryRegion *mr; }; static struct virtio_gpu_virgl_resource * @@ -47,6 +50,145 @@ virgl_get_egl_display(G_GNUC_UNUSED void *cookie) } #endif +#if VIRGL_VERSION_MAJOR >= 1 +struct virtio_gpu_virgl_hostmem_region { + MemoryRegion mr; + struct VirtIOGPU *g; + bool finish_unmapping; +}; + +static struct virtio_gpu_virgl_hostmem_region * +to_hostmem_region(MemoryRegion *mr) +{ + return container_of(mr, struct virtio_gpu_virgl_hostmem_region, mr); +} + +static void virtio_gpu_virgl_resume_cmdq_bh(void *opaque) +{ + VirtIOGPU *g = opaque; + + virtio_gpu_process_cmdq(g); +} + +static void virtio_gpu_virgl_hostmem_region_free(void *obj) +{ + MemoryRegion *mr = MEMORY_REGION(obj); + struct virtio_gpu_virgl_hostmem_region *vmr; + VirtIOGPUBase *b; + VirtIOGPUGL *gl; + + vmr = to_hostmem_region(mr); + vmr->finish_unmapping = true; + + b = VIRTIO_GPU_BASE(vmr->g); + b->renderer_blocked--; + + /* + * memory_region_unref() is executed from RCU thread context, while + * virglrenderer works only on the main-loop thread that's holding GL + * context. + */ + gl = VIRTIO_GPU_GL(vmr->g); + qemu_bh_schedule(gl->cmdq_resume_bh); +} + +static int +virtio_gpu_virgl_map_resource_blob(VirtIOGPU *g, + struct virtio_gpu_virgl_resource *res, + uint64_t offset) +{ + struct virtio_gpu_virgl_hostmem_region *vmr; + VirtIOGPUBase *b = VIRTIO_GPU_BASE(g); + MemoryRegion *mr; + uint64_t size; + void *data; + int ret; + + if (!virtio_gpu_hostmem_enabled(b->conf)) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: hostmem disabled\n", __func__); + return -EOPNOTSUPP; + } + + ret = virgl_renderer_resource_map(res->base.resource_id, &data, &size); + if (ret) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to map virgl resource: %s\n", + __func__, strerror(-ret)); + return ret; + } + + vmr = g_new0(struct virtio_gpu_virgl_hostmem_region, 1); + vmr->g = g; + + mr = &vmr->mr; + memory_region_init_ram_ptr(mr, OBJECT(mr), "blob", size, data); + memory_region_add_subregion(&b->hostmem, offset, mr); + memory_region_set_enabled(mr, true); + + /* + * MR could outlive the resource if MR's reference is held outside of + * virtio-gpu. In order to prevent unmapping resource while MR is alive, + * and thus, making the data pointer invalid, we will block virtio-gpu + * command processing until MR is fully unreferenced and freed. + */ + OBJECT(mr)->free = virtio_gpu_virgl_hostmem_region_free; + + res->mr = mr; + + return 0; +} + +static int +virtio_gpu_virgl_unmap_resource_blob(VirtIOGPU *g, + struct virtio_gpu_virgl_resource *res, + bool *cmd_suspended) +{ + struct virtio_gpu_virgl_hostmem_region *vmr; + VirtIOGPUBase *b = VIRTIO_GPU_BASE(g); + MemoryRegion *mr = res->mr; + int ret; + + if (!mr) { + return 0; + } + + vmr = to_hostmem_region(res->mr); + + /* + * Perform async unmapping in 3 steps: + * + * 1. Begin async unmapping with memory_region_del_subregion() + * and suspend/block cmd processing. + * 2. Wait for res->mr to be freed and cmd processing resumed + * asynchronously by virtio_gpu_virgl_hostmem_region_free(). + * 3. Finish the unmapping with final virgl_renderer_resource_unmap(). + */ + if (vmr->finish_unmapping) { + res->mr = NULL; + g_free(vmr); + + ret = virgl_renderer_resource_unmap(res->base.resource_id); + if (ret) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: failed to unmap virgl resource: %s\n", + __func__, strerror(-ret)); + return ret; + } + } else { + *cmd_suspended = true; + + /* render will be unblocked once MR is freed */ + b->renderer_blocked++; + + /* memory region owns self res->mr object and frees it by itself */ + memory_region_set_enabled(mr, false); + memory_region_del_subregion(&b->hostmem, mr); + object_unparent(OBJECT(mr)); + } + + return 0; +} +#endif + static void virgl_cmd_create_resource_2d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { @@ -78,6 +220,7 @@ static void virgl_cmd_create_resource_2d(VirtIOGPU *g, res->base.height = c2d.height; res->base.format = c2d.format; res->base.resource_id = c2d.resource_id; + res->base.dmabuf_fd = -1; QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); args.handle = c2d.resource_id; @@ -125,6 +268,7 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g, res->base.height = c3d.height; res->base.format = c3d.format; res->base.resource_id = c3d.resource_id; + res->base.dmabuf_fd = -1; QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); args.handle = c3d.resource_id; @@ -142,7 +286,8 @@ static void virgl_cmd_create_resource_3d(VirtIOGPU *g, } static void virgl_cmd_resource_unref(VirtIOGPU *g, - struct virtio_gpu_ctrl_command *cmd) + struct virtio_gpu_ctrl_command *cmd, + bool *cmd_suspended) { struct virtio_gpu_resource_unref unref; struct virtio_gpu_virgl_resource *res; @@ -160,6 +305,16 @@ static void virgl_cmd_resource_unref(VirtIOGPU *g, return; } +#if VIRGL_VERSION_MAJOR >= 1 + if (virtio_gpu_virgl_unmap_resource_blob(g, res, cmd_suspended)) { + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + if (*cmd_suspended) { + return; + } +#endif + virgl_renderer_resource_detach_iov(unref.resource_id, &res_iovs, &num_iovs); @@ -509,9 +664,241 @@ static void virgl_cmd_get_capset(VirtIOGPU *g, g_free(resp); } +#if VIRGL_VERSION_MAJOR >= 1 +static void virgl_cmd_resource_create_blob(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd) +{ + struct virgl_renderer_resource_create_blob_args virgl_args = { 0 }; + g_autofree struct virtio_gpu_virgl_resource *res = NULL; + struct virtio_gpu_resource_create_blob cblob; + struct virgl_renderer_resource_info info; + int ret; + + if (!virtio_gpu_blob_enabled(g->parent_obj.conf)) { + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; + return; + } + + 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_virgl_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_virgl_resource, 1); + res->base.resource_id = cblob.resource_id; + res->base.blob_size = cblob.size; + res->base.dmabuf_fd = -1; + + if (cblob.blob_mem != VIRTIO_GPU_BLOB_MEM_HOST3D) { + ret = virtio_gpu_create_mapping_iov(g, cblob.nr_entries, sizeof(cblob), + cmd, &res->base.addrs, + &res->base.iov, &res->base.iov_cnt); + if (!ret) { + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + } + + 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->base.iov; + virgl_args.num_iovs = res->base.iov_cnt; + + ret = virgl_renderer_resource_create_blob(&virgl_args); + if (ret) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: virgl blob create error: %s\n", + __func__, strerror(-ret)); + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + virtio_gpu_cleanup_mapping(g, &res->base); + return; + } + + ret = virgl_renderer_resource_get_info(cblob.resource_id, &info); + if (ret) { + qemu_log_mask(LOG_GUEST_ERROR, + "%s: resource does not have info %d: %s\n", + __func__, cblob.resource_id, strerror(-ret)); + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + virtio_gpu_cleanup_mapping(g, &res->base); + virgl_renderer_resource_unref(cblob.resource_id); + return; + } + + res->base.dmabuf_fd = info.fd; + + QTAILQ_INSERT_HEAD(&g->reslist, &res->base, next); + res = NULL; +} + +static void virgl_cmd_resource_map_blob(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd) +{ + struct virtio_gpu_resource_map_blob mblob; + struct virtio_gpu_virgl_resource *res; + struct virtio_gpu_resp_map_info resp; + int ret; + + VIRTIO_GPU_FILL_CMD(mblob); + virtio_gpu_map_blob_bswap(&mblob); + + res = virtio_gpu_virgl_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; + } + + ret = virtio_gpu_virgl_map_resource_blob(g, res, mblob.offset); + if (ret) { + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + + 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 void virgl_cmd_resource_unmap_blob(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd, + bool *cmd_suspended) +{ + struct virtio_gpu_resource_unmap_blob ublob; + struct virtio_gpu_virgl_resource *res; + int ret; + + VIRTIO_GPU_FILL_CMD(ublob); + virtio_gpu_unmap_blob_bswap(&ublob); + + res = virtio_gpu_virgl_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; + } + + ret = virtio_gpu_virgl_unmap_resource_blob(g, res, cmd_suspended); + if (ret) { + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } +} + +static void virgl_cmd_set_scanout_blob(VirtIOGPU *g, + struct virtio_gpu_ctrl_command *cmd) +{ + struct virtio_gpu_framebuffer fb = { 0 }; + struct virtio_gpu_virgl_resource *res; + struct virtio_gpu_set_scanout_blob ss; + uint64_t fbend; + + VIRTIO_GPU_FILL_CMD(ss); + virtio_gpu_scanout_blob_bswap(&ss); + trace_virtio_gpu_cmd_set_scanout_blob(ss.scanout_id, ss.resource_id, + ss.r.width, ss.r.height, ss.r.x, + ss.r.y); + + if (ss.scanout_id >= g->parent_obj.conf.max_outputs) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout id specified %d", + __func__, ss.scanout_id); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID; + return; + } + + if (ss.resource_id == 0) { + virtio_gpu_disable_scanout(g, ss.scanout_id); + return; + } + + if (ss.width < 16 || + ss.height < 16 || + ss.r.x + ss.r.width > ss.width || + ss.r.y + ss.r.height > ss.height) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout %d bounds for" + " resource %d, rect (%d,%d)+%d,%d, fb %d %d\n", + __func__, ss.scanout_id, ss.resource_id, + ss.r.x, ss.r.y, ss.r.width, ss.r.height, + ss.width, ss.height); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; + return; + } + + res = virtio_gpu_virgl_find_resource(g, ss.resource_id); + if (!res) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource does not exist %d\n", + __func__, ss.resource_id); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; + return; + } + if (res->base.dmabuf_fd < 0) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: resource not backed by dmabuf %d\n", + __func__, ss.resource_id); + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + + fb.format = virtio_gpu_get_pixman_format(ss.format); + if (!fb.format) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: pixel format not supported %d\n", + __func__, ss.format); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; + return; + } + + fb.bytes_pp = DIV_ROUND_UP(PIXMAN_FORMAT_BPP(fb.format), 8); + fb.width = ss.width; + fb.height = ss.height; + fb.stride = ss.strides[0]; + fb.offset = ss.offsets[0] + ss.r.x * fb.bytes_pp + ss.r.y * fb.stride; + + fbend = fb.offset; + fbend += fb.stride * (ss.r.height - 1); + fbend += fb.bytes_pp * ss.r.width; + if (fbend > res->base.blob_size) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: fb end out of range\n", + __func__); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; + return; + } + + g->parent_obj.enable = 1; + if (virtio_gpu_update_dmabuf(g, ss.scanout_id, &res->base, &fb, &ss.r)) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to update dmabuf\n", + __func__); + cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER; + return; + } + + virtio_gpu_update_scanout(g, ss.scanout_id, &res->base, &fb, &ss.r); +} +#endif + void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { + bool cmd_suspended = false; + VIRTIO_GPU_FILL_CMD(cmd->cmd_hdr); virgl_renderer_force_ctx_0(); @@ -553,7 +940,7 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, virgl_cmd_resource_flush(g, cmd); break; case VIRTIO_GPU_CMD_RESOURCE_UNREF: - virgl_cmd_resource_unref(g, cmd); + virgl_cmd_resource_unref(g, cmd, &cmd_suspended); break; case VIRTIO_GPU_CMD_CTX_ATTACH_RESOURCE: /* TODO add security */ @@ -575,12 +962,26 @@ void virtio_gpu_virgl_process_cmd(VirtIOGPU *g, case VIRTIO_GPU_CMD_GET_EDID: virtio_gpu_get_edid(g, cmd); break; +#if VIRGL_VERSION_MAJOR >= 1 + 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, &cmd_suspended); + break; + case VIRTIO_GPU_CMD_SET_SCANOUT_BLOB: + virgl_cmd_set_scanout_blob(g, cmd); + break; +#endif default: cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; break; } - if (cmd->finished) { + if (cmd_suspended || cmd->finished) { return; } if (cmd->error) { @@ -749,6 +1150,13 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) timer_mod(gl->print_stats, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 1000); } + +#if VIRGL_VERSION_MAJOR >= 1 + gl->cmdq_resume_bh = aio_bh_new(qemu_get_aio_context(), + virtio_gpu_virgl_resume_cmdq_bh, + g); +#endif + return 0; } diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 180d882f0a..b6cd9fe567 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -362,7 +362,7 @@ static void virtio_gpu_resource_create_blob(VirtIOGPU *g, QTAILQ_INSERT_HEAD(&g->reslist, res, next); } -static void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id) +void virtio_gpu_disable_scanout(VirtIOGPU *g, int scanout_id) { struct virtio_gpu_scanout *scanout = &g->parent_obj.scanout[scanout_id]; struct virtio_gpu_simple_resource *res; @@ -579,11 +579,11 @@ static void virtio_unref_resource(pixman_image_t *image, void *data) pixman_image_unref(data); } -static void virtio_gpu_update_scanout(VirtIOGPU *g, - uint32_t scanout_id, - struct virtio_gpu_simple_resource *res, - struct virtio_gpu_framebuffer *fb, - struct virtio_gpu_rect *r) +void virtio_gpu_update_scanout(VirtIOGPU *g, + uint32_t scanout_id, + struct virtio_gpu_simple_resource *res, + struct virtio_gpu_framebuffer *fb, + struct virtio_gpu_rect *r) { struct virtio_gpu_simple_resource *ores; struct virtio_gpu_scanout *scanout; @@ -1467,10 +1467,14 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) return; } +#ifdef VIRGL_VERSION_MAJOR + #if VIRGL_VERSION_MAJOR < 1 if (virtio_gpu_virgl_enabled(g->parent_obj.conf)) { - error_setg(errp, "blobs and virgl are not compatible (yet)"); + error_setg(errp, "old virglrenderer, blob resources unsupported"); return; } + #endif +#endif } if (!virtio_gpu_base_device_realize(qdev, From patchwork Tue Oct 29 12:10:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839333 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp329297wrb; Tue, 29 Oct 2024 05:12:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU9TT9qaZ16F58hNW5SSmBpFL8A1gYD6zN2isagJ8DrGyhV/a6LvDOR6yO7mhrv8yE+tSL2ZQ==@linaro.org X-Google-Smtp-Source: AGHT+IHKGscvE2iBzccbn2Wtre0ehVH/1sS7R+78KzoR3wbuXnhpUHzbYsxMY5DUesNuBawNOQlw X-Received: by 2002:a05:6102:3750:b0:4a4:87f8:f41e with SMTP id ada2fe7eead31-4a8cfb4cee3mr9785870137.9.1730203963379; Tue, 29 Oct 2024 05:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203963; cv=none; d=google.com; s=arc-20240605; b=MNPDTK5wSvT1fPmnbTmEg77ptNfTWdqr54w6ZRc80XEaEN978eJB+DYPkXtxRyHWBw reRWuuCCW0SgNgpNVDXzLFa0PxWlaftAX1HDjcDC+FdyN/WXnQylmWvDkAf56vDAy4OQ +3c57bF04MkqagBEtxgmTsxhHz5V34tsG+7SrwIe8lwTrxCNJ2gfoQ87cYNZOCMQ7OeS PZwkX/R0mUXB4vCkk03okzz0XKG3Eon283IuIazQyLzFjfLixRBNOLFjCYKkCCLutnBC ZsuZCuYnJr7oW2nC+uOZAfbEhrrILK1qAlmS6vXN/lrM5jqAEaS3iwcdcfJUCARsRRf8 Yu8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w7P2y8ojbRByNUhojZLYVixQKQid+9QX54I0osIQ9P8=; fh=x0dXtuJS9vTQSVYVmRdoF1OPNsn6GlTklGjaF5T2KrM=; b=XQp1g+/vtsvG05nFvUIFFkq9Ed9ubPQcWERYGAkRIz7TQYmQCfE9U7DhrCIBnZeERV i/HuB1xrKCmwBwD7vL5cJm1o01rK4IkG+qKqj/mv1qVP4i5zxMv4hEZBri3T71811Yao ilxgWyAcgD5QPp2GfSp/awQmUIqVmQD17APSxDUbvrr3OmXmYc6bvVdpdyUo2zRk6d0E HmIM/TZAl/Y5nI+gU1q2Ijc1lEEkogd5IJ0046RMTBPjmpubInfgT20Uvrj2qFOrWMpZ gyOkiXqtGP5pjrYp6lCoKaef0vbSaB/g0cZ3+BB+paUlwFZMsnBjXb263YRe8C+XniW/ J7GQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P60p0tBZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-4a8c530eb44si2348056137.342.2024.10.29.05.12.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P60p0tBZ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3n-0004f7-9T; Tue, 29 Oct 2024 08:10:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3a-0004be-UT for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:45 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3Y-0007TO-Uc for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:42 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-37d4fd00574so3459342f8f.0 for ; Tue, 29 Oct 2024 05:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203839; x=1730808639; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w7P2y8ojbRByNUhojZLYVixQKQid+9QX54I0osIQ9P8=; b=P60p0tBZiRC4R8Kv+3bkW9dAYzeFSVsPgUO+bPoSpNNRvg3ghEc4jevTQTdqMb5eYN UvcvH0x5+Rixf7W6X+Vo8mhXaqgJUYwDinYpHsXhF6nTr9heC/7Nx+el95BJQawnWf5D Kov8jUGifMkN9lN+XCaCYu+Ez3m6y4f8qR1xEkYskxsg/wCkJ2ZS6fSDmVKKCftf3UZU XSzlhf6KaZ9q5eBUqN/9w7ubneL7uvFWiNWeTAWOuVtA+lBVOOXZ6uiwrCE7oBll7tBJ RHqXxtahJUcI1r1h7v3rbkFzKLb3aDKCoEquFw3pXsXSker/7dSXAA3qDrpqnghiTH54 4VHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203839; x=1730808639; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w7P2y8ojbRByNUhojZLYVixQKQid+9QX54I0osIQ9P8=; b=VcbnUdiKyYf3Vw0FyaT/I8kcdDybPn/AuJgxw7T+tNzNgj3itIyz8BWwz3SQNIe+Gh hOy3YClF+g5fOvlDIAveZgAptgCIN77CtrRM7sswU5aOixjZLBUccj58ohbG96ain47v x4dazQ896ofC7QS7igB5J8xBYRyuzU2/1IZE8y6NmIy5vhQTlqzQBrZRh3BgK4+/TwwU w9U9onfiGk9B3Fi10W9GFgWL5DQKB0t6hKCi+c1fpSkDAsiDo0ohCJdkl7NhR8235xww huLctLUOr9gda2pcipWCvNcDMQTkUy4jN7gBXTfJ0ztfPkCbV3FmdTgnSL5eRJ/b10Ua /KEg== X-Gm-Message-State: AOJu0YwmZzEsW4G2l3qizETTv+4HX5PNfLpuPKq1Q2x2Bs7cgGvDWA9F /VyQmwQ4OcoMJbW1NEd+twa4BQEZOt2bMafGh9aPDgPQ5eARlSVMA3UVgHRgf9w= X-Received: by 2002:a5d:45c5:0:b0:374:bf6b:1021 with SMTP id ffacd0b85a97d-38162916869mr1701207f8f.27.1730203839263; Tue, 29 Oct 2024 05:10:39 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38058b3bec2sm12310048f8f.39.2024.10.29.05.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:34 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A0E595FB73; Tue, 29 Oct 2024 12:10:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierre-Eric Pelloux-Prayer , Manos Pitsidianakis , Dmitry Osipenko , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 12/13] virtio-gpu: Register capsets dynamically Date: Tue, 29 Oct 2024 12:10:29 +0000 Message-Id: <20241029121030.4007014-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Pierre-Eric Pelloux-Prayer virtio_gpu_virgl_get_num_capsets will return "num_capsets", but we can't assume that capset_index 1 is always VIRGL2 once we'll support more capsets, like Venus and DRM capsets. Register capsets dynamically to avoid that problem. Reviewed-by: Manos Pitsidianakis Signed-off-by: Pierre-Eric Pelloux-Prayer Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-13-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index f9ed81071f..07131d8eb9 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -207,6 +207,8 @@ struct VirtIOGPU { QTAILQ_HEAD(, VGPUDMABuf) bufs; VGPUDMABuf *primary[VIRTIO_GPU_MAX_SCANOUTS]; } dmabuf; + + GArray *capset_ids; }; struct VirtIOGPUClass { @@ -352,6 +354,6 @@ void virtio_gpu_virgl_fence_poll(VirtIOGPU *g); void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g); void virtio_gpu_virgl_reset(VirtIOGPU *g); int virtio_gpu_virgl_init(VirtIOGPU *g); -int virtio_gpu_virgl_get_num_capsets(VirtIOGPU *g); +GArray *virtio_gpu_virgl_get_capsets(VirtIOGPU *g); #endif diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index f2555673a1..e859c0dff0 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -144,8 +144,8 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp) } g->parent_obj.conf.flags |= (1 << VIRTIO_GPU_FLAG_VIRGL_ENABLED); - VIRTIO_GPU_BASE(g)->virtio_config.num_capsets = - virtio_gpu_virgl_get_num_capsets(g); + g->capset_ids = virtio_gpu_virgl_get_capsets(g); + VIRTIO_GPU_BASE(g)->virtio_config.num_capsets = g->capset_ids->len; #if VIRGL_VERSION_MAJOR >= 1 g->parent_obj.conf.flags |= 1 << VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED; @@ -177,6 +177,8 @@ static void virtio_gpu_gl_device_unrealize(DeviceState *qdev) } gl->renderer_state = RS_START; + + g_array_unref(g->capset_ids); } static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data) diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index b2f4e215a7..5a881c58a1 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -622,19 +622,13 @@ static void virgl_cmd_get_capset_info(VirtIOGPU *g, VIRTIO_GPU_FILL_CMD(info); memset(&resp, 0, sizeof(resp)); - if (info.capset_index == 0) { - resp.capset_id = VIRTIO_GPU_CAPSET_VIRGL; - virgl_renderer_get_cap_set(resp.capset_id, - &resp.capset_max_version, - &resp.capset_max_size); - } else if (info.capset_index == 1) { - resp.capset_id = VIRTIO_GPU_CAPSET_VIRGL2; + + if (info.capset_index < g->capset_ids->len) { + resp.capset_id = g_array_index(g->capset_ids, uint32_t, + info.capset_index); 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; } resp.hdr.type = VIRTIO_GPU_RESP_OK_CAPSET_INFO; virtio_gpu_ctrl_response(g, cmd, &resp.hdr, sizeof(resp)); @@ -1160,12 +1154,27 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) return 0; } -int virtio_gpu_virgl_get_num_capsets(VirtIOGPU *g) +static void virtio_gpu_virgl_add_capset(GArray *capset_ids, uint32_t capset_id) +{ + g_array_append_val(capset_ids, capset_id); +} + +GArray *virtio_gpu_virgl_get_capsets(VirtIOGPU *g) { uint32_t capset2_max_ver, capset2_max_size; + GArray *capset_ids; + + capset_ids = g_array_new(false, false, sizeof(uint32_t)); + + /* VIRGL is always supported. */ + virtio_gpu_virgl_add_capset(capset_ids, VIRTIO_GPU_CAPSET_VIRGL); + virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_VIRGL2, &capset2_max_ver, &capset2_max_size); + if (capset2_max_ver) { + virtio_gpu_virgl_add_capset(capset_ids, VIRTIO_GPU_CAPSET_VIRGL2); + } - return capset2_max_ver ? 2 : 1; + return capset_ids; } From patchwork Tue Oct 29 12:10:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 839328 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:4593:b0:37d:45d0:187 with SMTP id gb19csp328901wrb; Tue, 29 Oct 2024 05:11:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW79n+jh+bSUZtuAVn9E3ztuJYNuyCWaZczQRC7scyo96AJjVegiDo8AVvf9lHr8Kvw2owT3Q==@linaro.org X-Google-Smtp-Source: AGHT+IH9X8PQwH4Ga9/lzcrxgOxWfOHNWUScHRaMUUQV4kflcqw0RmBKG+KnJHuz01iegSaz7AC3 X-Received: by 2002:a05:6808:1984:b0:3e6:2700:ec82 with SMTP id 5614622812f47-3e63848dfddmr9542280b6e.29.1730203915822; Tue, 29 Oct 2024 05:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730203915; cv=none; d=google.com; s=arc-20240605; b=VwqagqCquc2bGWdO1Zf/Z55IC6BDQgTsoGrbGYrOicsB2bjbYOgYZUJorSxjDz7sm6 Cd4/VvZ1GIycJ5As57zoNpSvA9ouA46SiKBGTLyfy96/Rq7YJCP7ZoEvUUsKz0DP1WXh WppAubEOymy5VYDFdWyrMK+eM9R/WXYPzkBIdi52hYNEQAbEwewtQxCQ+P7NtZNP8cbV mDaDBBGEjoMhOOMNZT3WE9qUPv4LMNU955Wa2PbMTRQH6gMrgecA5R4jawvZ3gNHUy/M G08y8PIF4zEjtUKYtcE0UKUy7bwzIy2QJLCPTACaH91jxmps1fec9anFMhBZA2eeCAsM RBTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wmizK428eYdY2C9hOKe1a6rQdlv5YX/NKe3TrD6Y5Mk=; fh=i8lXGXuCPrZnD2fmO3Qz+xwNxTvYG41wr+ow3JiFVLM=; b=D7I9oRfnJguEOwZ0CfrOpsa8nyxgHCRwGZMZPSE7mw9UcEMPnJEq8eSJ/HY2lRiBTx zus59vV4D1CVFy4lrPTb4Abu4QDJNAPUlRNi7KvZIi70DodDYfcAy/rkT0YTG3kCGADr n+PaGVTFL94VSSFWtDQ2C9ZPhdU0peHsTOOVu5y9bwt3owthp6/Wd54tCAFclOkE4WV8 bb31HPb6JHu/jnRjS6S5C0zs0pD2GmmcSRi5r6Mwu/Ty5jYv2iv31nFutZdxCjEKtNmp ETczqfyp3sv5Wz6cUj6ypHuGtRSZsWftZaaDZNzXbdrveq7y8itUAUUhQBhXC7f2dtKn 64Ug==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BiZQP1It; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a1e0cc1a2514c-85580a83c82si1880236241.82.2024.10.29.05.11.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2024 05:11:55 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BiZQP1It; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5l3o-0004fW-T2; Tue, 29 Oct 2024 08:10:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5l3d-0004cX-Gv for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:45 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5l3b-0007U8-Il for qemu-devel@nongnu.org; Tue, 29 Oct 2024 08:10:45 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4319399a411so40512415e9.2 for ; Tue, 29 Oct 2024 05:10:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730203841; x=1730808641; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wmizK428eYdY2C9hOKe1a6rQdlv5YX/NKe3TrD6Y5Mk=; b=BiZQP1Itc/1R08uxpsY6g0hbNCwcJTPY7ju2KQJesTbTRD11V8320zC2vKUEWH//DI kjdCY1l1t+LF29m43M8f++/F0kQn3/DqZ7BThI9p3v5rBkN9Ln74ozFrlqP4zdVVtdB/ TyXlGvJKscn1uvfKnkCyL/NZ1Zo9guyJpQMqnyXYdHTfSq8/20dv/oGkr9Vg01R2A8Go KGJ90EnZC1nSawLr6prZtuAzwt49F5ER89JngbPXqUKZhDP0I+ykLVEFZtZVYgwXwZFa Rx38KJHBjddzh+VaecXrWvGFMi8o9sbo53PsAhrIodbB5n8OVIQ4mEo4vaYz/RVdNwCW NX3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730203841; x=1730808641; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wmizK428eYdY2C9hOKe1a6rQdlv5YX/NKe3TrD6Y5Mk=; b=YlfrxkP5nWCNwN4Norl2RUXPFeMf3Jzz5M8H7ZSW2XPQyD+Lf+uyqyM7P8VQ2MfQRw y9oCoZTsRRIjcbZMIrEkYvuw97UjgnB0V+KfQlTzIaANEMNeTdb5NiA9XoufRMIofKRK 1uc9kjKNu4stCD1DHEQajdc9bcFm1TSR4/7tKZOsmEzoJgfs1D/DUl7/uDB7bk6yIpVB ByB+9camPAxcSWpfNPwH/yKAES7H5oMr2YD+DFHZkiiTZ50Gc+tnfIIeKVlBhBLpJpyM yu6/bZEBW+l8y/V+cePSMKnI7N6c5NKD3CXt/p5jOMsEfI9uzzVC1k9fqtriJlv3JvSX VFOQ== X-Gm-Message-State: AOJu0Yy1jXyrRob1YYv+Bmd2ULMhEOepWET3IhxAjX5/4d960tIl00ud MVohQZ8i4J5URnA2eWvO5CZOL5oSX0ZjADaTkqp4nKN8YnMRiQtPh5exotJsn3I= X-Received: by 2002:a05:600c:138d:b0:431:5f1c:8362 with SMTP id 5b1f17b1804b1-4319ad4176cmr83909785e9.35.1730203841432; Tue, 29 Oct 2024 05:10:41 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4318b55f719sm170948565e9.15.2024.10.29.05.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 05:10:40 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id BDDFC5FBAC; Tue, 29 Oct 2024 12:10:31 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Antonio Caggiano , Huang Rui , Dmitry Osipenko , =?utf-8?q?Alex_Benn=C3=A9e?= , "Michael S. Tsirkin" Subject: [PULL 13/13] virtio-gpu: Support Venus context Date: Tue, 29 Oct 2024 12:10:30 +0000 Message-Id: <20241029121030.4007014-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241029121030.4007014-1-alex.bennee@linaro.org> References: <20241029121030.4007014-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.google.com 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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Antonio Caggiano Request Venus when initializing VirGL and if venus=true flag is set for virtio-gpu-gl device. Signed-off-by: Antonio Caggiano Signed-off-by: Huang Rui Signed-off-by: Dmitry Osipenko Message-Id: <20241024210311.118220-14-dmitry.osipenko@collabora.com> Signed-off-by: Alex Bennée diff --git a/docs/system/devices/virtio-gpu.rst b/docs/system/devices/virtio-gpu.rst index cb73dd7998..b7eb0fc0e7 100644 --- a/docs/system/devices/virtio-gpu.rst +++ b/docs/system/devices/virtio-gpu.rst @@ -71,6 +71,17 @@ representation back to OpenGL API calls. .. _Gallium3D: https://www.freedesktop.org/wiki/Software/gallium/ .. _virglrenderer: https://gitlab.freedesktop.org/virgl/virglrenderer/ +Translation of Vulkan API calls is supported since release of `virglrenderer`_ +v1.0.0 using `venus`_ protocol. ``Venus`` virtio-gpu capability set ("capset") +requires host blob support (``hostmem`` and ``blob`` fields) and should +be enabled using ``venus`` field. The ``hostmem`` field specifies the size +of virtio-gpu host memory window. This is typically between 256M and 8G. + +.. parsed-literal:: + -device virtio-gpu-gl,hostmem=8G,blob=true,venus=true + +.. _venus: https://gitlab.freedesktop.org/virgl/venus-protocol/ + virtio-gpu rutabaga ------------------- diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index 07131d8eb9..553799b8cc 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -97,6 +97,7 @@ enum virtio_gpu_base_conf_flags { VIRTIO_GPU_FLAG_BLOB_ENABLED, VIRTIO_GPU_FLAG_CONTEXT_INIT_ENABLED, VIRTIO_GPU_FLAG_RUTABAGA_ENABLED, + VIRTIO_GPU_FLAG_VENUS_ENABLED, }; #define virtio_gpu_virgl_enabled(_cfg) \ @@ -115,6 +116,8 @@ enum virtio_gpu_base_conf_flags { (_cfg.flags & (1 << VIRTIO_GPU_FLAG_RUTABAGA_ENABLED)) #define virtio_gpu_hostmem_enabled(_cfg) \ (_cfg.hostmem > 0) +#define virtio_gpu_venus_enabled(_cfg) \ + (_cfg.flags & (1 << VIRTIO_GPU_FLAG_VENUS_ENABLED)) struct virtio_gpu_base_conf { uint32_t max_outputs; diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c index e859c0dff0..7c0e448b46 100644 --- a/hw/display/virtio-gpu-gl.c +++ b/hw/display/virtio-gpu-gl.c @@ -157,6 +157,8 @@ static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp) static Property virtio_gpu_gl_properties[] = { DEFINE_PROP_BIT("stats", VirtIOGPU, parent_obj.conf.flags, VIRTIO_GPU_FLAG_STATS_ENABLED, false), + DEFINE_PROP_BIT("venus", VirtIOGPU, parent_obj.conf.flags, + VIRTIO_GPU_FLAG_VENUS_ENABLED, false), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index 5a881c58a1..eedae7357f 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -1128,6 +1128,11 @@ int virtio_gpu_virgl_init(VirtIOGPU *g) flags |= VIRGL_RENDERER_D3D11_SHARE_TEXTURE; } #endif +#if VIRGL_VERSION_MAJOR >= 1 + if (virtio_gpu_venus_enabled(g->parent_obj.conf)) { + flags |= VIRGL_RENDERER_VENUS | VIRGL_RENDERER_RENDER_SERVER; + } +#endif ret = virgl_renderer_init(g, flags, &virtio_gpu_3d_cbs); if (ret != 0) { @@ -1161,7 +1166,7 @@ static void virtio_gpu_virgl_add_capset(GArray *capset_ids, uint32_t capset_id) GArray *virtio_gpu_virgl_get_capsets(VirtIOGPU *g) { - uint32_t capset2_max_ver, capset2_max_size; + uint32_t capset_max_ver, capset_max_size; GArray *capset_ids; capset_ids = g_array_new(false, false, sizeof(uint32_t)); @@ -1170,11 +1175,20 @@ GArray *virtio_gpu_virgl_get_capsets(VirtIOGPU *g) virtio_gpu_virgl_add_capset(capset_ids, VIRTIO_GPU_CAPSET_VIRGL); virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_VIRGL2, - &capset2_max_ver, - &capset2_max_size); - if (capset2_max_ver) { + &capset_max_ver, + &capset_max_size); + if (capset_max_ver) { virtio_gpu_virgl_add_capset(capset_ids, VIRTIO_GPU_CAPSET_VIRGL2); } + if (virtio_gpu_venus_enabled(g->parent_obj.conf)) { + virgl_renderer_get_cap_set(VIRTIO_GPU_CAPSET_VENUS, + &capset_max_ver, + &capset_max_size); + if (capset_max_size) { + virtio_gpu_virgl_add_capset(capset_ids, VIRTIO_GPU_CAPSET_VENUS); + } + } + return capset_ids; } diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index b6cd9fe567..c0570ef856 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1477,6 +1477,21 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) #endif } + if (virtio_gpu_venus_enabled(g->parent_obj.conf)) { +#ifdef VIRGL_VERSION_MAJOR + #if VIRGL_VERSION_MAJOR >= 1 + if (!virtio_gpu_blob_enabled(g->parent_obj.conf) || + !virtio_gpu_hostmem_enabled(g->parent_obj.conf)) { + error_setg(errp, "venus requires enabled blob and hostmem options"); + return; + } + #else + error_setg(errp, "old virglrenderer, venus unsupported"); + return; + #endif +#endif + } + if (!virtio_gpu_base_device_realize(qdev, virtio_gpu_handle_ctrl_cb, virtio_gpu_handle_cursor_cb,