From nobody Wed Nov 27 10:34:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277686; cv=none; d=zohomail.com; s=zohoarc; b=mPYhAg5gXvJbfRfdtFO4jwX58aIAulkZ+BywU87t6Q/UlBWJnGGKi5UnO8J9lY4gTELwOzJSxjdGZTKveNuYKupR76eigwwfs/d05giDEIyOscXHJUKobPycq9uHkAuscn513iOEutp7M/Sw/6oEytenpcXeLG1I0B++GiTJ5fI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277686; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cYuUp10LJDHg0e5GrrLE1lgcNt3x8CO/RHbp1MrnHA0=; b=nfxrlKgrQEyYnIB5HsmGCckS2zAUJKmo/7XQP7vy/NoCN80/cEUwyOWfDYR3wJuAy+Q+imTsBbOp3NKdO5mPBcvvN1OXcl+SqLgl8oebGNyP890r6Vk2Ct22z8mnhEh2WL7GwpEtioDMLCsfDEY9dcqN5hpUJU24VApsy4vnaSk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699277686585695.972155963717; Mon, 6 Nov 2023 05:34:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzziX-0005cQ-1O; Mon, 06 Nov 2023 08:32:37 -0500 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 1qzziT-0005ab-Sn for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzziS-0003ig-Ca for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:33 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-oOnRr4exN8aAsHuGayqvrQ-1; Mon, 06 Nov 2023 08:32:28 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B1F193C0FC8E; Mon, 6 Nov 2023 13:32:27 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D4D6492BE0; Mon, 6 Nov 2023 13:32:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cYuUp10LJDHg0e5GrrLE1lgcNt3x8CO/RHbp1MrnHA0=; b=CJBsLCNWwmbuloB0WDWtRO4+/TC3e+cF28QZ7Uz416IuQyGinbywhMyY0CCCqPViGyxt8p +mgvFdIOiBvSkgXITuc5USLGR9QbSNMiSyWxQ/TcwoGWwalf3onKxjV95gKNIAvGTyPIaZ BkumD9ISBVUYbh+OYJSAL3K5VF37pgc= X-MC-Unique: oOnRr4exN8aAsHuGayqvrQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Cong Liu , "Michael S. Tsirkin" , Gerd Hoffmann Subject: [PULL 01/10] virtio-gpu-rutabaga: Add empty interface to fix arm64 crash Date: Mon, 6 Nov 2023 17:32:10 +0400 Message-ID: <20231106133219.2173660-2-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699277687544100007 From: Cong Liu Add an empty element to the interfaces array, which is consistent with the behavior of other devices in qemu and fixes the crash on arm64. 0 0x0000fffff5c18550 in () at /usr/lib64/libc.so.6 1 0x0000fffff6c9cd6c in g_strdup () at /usr/lib64/libglib-2.0.so.0 2 0x0000aaaaab4945d8 in g_strdup_inline (str=3D) at /usr/in= clude/glib-2.0/glib/gstrfuncs.h:321 3 type_new (info=3Dinfo@entry=3D0xaaaaabc1b2c8 ) at ../qom/object.c:133 4 0x0000aaaaab494f14 in type_register_internal (info=3D0xaaaaabc1b2c8 ) at ../qom/object.c:143 5 type_register (info=3D0xaaaaabc1b2c8 ) at = ../qom/object.c:152 6 type_register_static (info=3D0xaaaaabc1b2c8 ) at ../qom/object.c:157 7 type_register_static_array (infos=3D, nr_infos=3D) at ../qom/object.c:165 8 0x0000aaaaab6147e8 in module_call_init (type=3Dtype@entry=3DMODULE_INIT_= QOM) at ../util/module.c:109 9 0x0000aaaaab10a0ec in qemu_init_subsystems () at ../system/runstate.c:817 10 0x0000aaaaab10d334 in qemu_init (argc=3D13, argv=3D0xfffffffff198) at ..= /system/vl.c:2760 11 0x0000aaaaaae4da6c in main (argc=3D, argv=3D) at ../system/main.c:47 Signed-off-by: Cong Liu Reviewed-by: Gurchetan Singh Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20231031012515.15504-1-liucong2@kylinos.cn> --- hw/display/virtio-gpu-pci-rutabaga.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/display/virtio-gpu-pci-rutabaga.c b/hw/display/virtio-gpu-p= ci-rutabaga.c index c96729e198..abbb898c65 100644 --- a/hw/display/virtio-gpu-pci-rutabaga.c +++ b/hw/display/virtio-gpu-pci-rutabaga.c @@ -36,6 +36,7 @@ static const TypeInfo virtio_gpu_rutabaga_pci_info[] =3D { .instance_init =3D virtio_gpu_rutabaga_initfn, .interfaces =3D (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, } }, }; --=20 2.41.0 From nobody Wed Nov 27 10:34:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277598; cv=none; d=zohomail.com; s=zohoarc; b=ejl2eYAPuEVwgN1Uus6+k/hOxHzMbU+//WdiDlxS2adZkXvLu9vVVOw/Awo7e9eKTZ+1gMEHRVqdyzuLil4I/6jSHwDOaaLWzi2YmtxqdlM/kAJ0xvBQyGyl6HRaOFIt2qjdoagPH77PlHg5BD5hOpYqKqI4x874CDKcstzY7Zw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277598; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8JLXt3y25QXXkvUo2bcTmGhWuiwFD6poKz6ytX9hJb0=; b=PhPL0rU7z23t+XB1l9qGbxwOo2kNf97i2O2mYOagyNaUzVYVStRTI/NkCagEw+IAUUGbTZtu3xcyaHW80NUciMNC9IEbdpt/zxKaX60nyirFJfFy3IzhbRGHsJanQGSYLgrPBZuw7ZcKNfxBhIs2DjKH2oSEvadhsMPAhIXpCZA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699277598322521.8802469890287; Mon, 6 Nov 2023 05:33:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzzia-0005hL-4r; Mon, 06 Nov 2023 08:32:40 -0500 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 1qzziY-0005cg-3L for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzziW-0003kX-LG for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:37 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-452-54NB0XAYMyeNmi09ornZGw-1; Mon, 06 Nov 2023 08:32:32 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20F462815E25; Mon, 6 Nov 2023 13:32:32 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0014F40C6EB9; Mon, 6 Nov 2023 13:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277556; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8JLXt3y25QXXkvUo2bcTmGhWuiwFD6poKz6ytX9hJb0=; b=fcNewoSy8RO3wsDlqEZ/TS7oc1etzNU+KfpK5IutEmzeHmZv7wWo5Vds7To1z7PcWdc9Cj 0iB+FdIICJQEWRyTK1CyOYkajf0TlyNBT2RQZxNw727f1+T5+kLEMRN9af6fOHGa94lUEN 1NRD2R9QYXRPsMwc16ZrhEIJbyMzDuk= X-MC-Unique: 54NB0XAYMyeNmi09ornZGw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, BALATON Zoltan Subject: [PULL 02/10] ati-vga: Fix aperture sizes Date: Mon, 6 Nov 2023 17:32:11 +0400 Message-ID: <20231106133219.2173660-3-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699277599200100005 From: BALATON Zoltan Apparently these should be half the memory region sizes confirmed at least by Radeon FCocde ROM while Rage 128 Pro ROMs don't seem to use these. Linux r100 DRM driver also checks for a bit in HOST_PATH_CNTL so we also add that even though the FCode ROM does not seem to set it. Signed-off-by: BALATON Zoltan Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: --- hw/display/ati_regs.h | 1 + hw/display/ati.c | 7 +++++-- hw/display/ati_dbg.c | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/display/ati_regs.h b/hw/display/ati_regs.h index d6282b2ef2..c697b328da 100644 --- a/hw/display/ati_regs.h +++ b/hw/display/ati_regs.h @@ -56,6 +56,7 @@ #define CONFIG_APER_SIZE 0x0108 #define CONFIG_REG_1_BASE 0x010c #define CONFIG_REG_APER_SIZE 0x0110 +#define HOST_PATH_CNTL 0x0130 #define MEM_CNTL 0x0140 #define MC_FB_LOCATION 0x0148 #define MC_AGP_LOCATION 0x014C diff --git a/hw/display/ati.c b/hw/display/ati.c index 6e38e00502..9a9ea754bd 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -349,14 +349,17 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr= , unsigned int size) PCI_BASE_ADDRESS_0, size) & 0xffffff= f0; break; case CONFIG_APER_SIZE: - val =3D s->vga.vram_size; + val =3D s->vga.vram_size / 2; break; case CONFIG_REG_1_BASE: val =3D pci_default_read_config(&s->dev, PCI_BASE_ADDRESS_2, size) & 0xffffff= f0; break; case CONFIG_REG_APER_SIZE: - val =3D memory_region_size(&s->mm); + val =3D memory_region_size(&s->mm) / 2; + break; + case HOST_PATH_CNTL: + val =3D BIT(23); /* Radeon HDP_APER_CNTL */ break; case MC_STATUS: val =3D 5; diff --git a/hw/display/ati_dbg.c b/hw/display/ati_dbg.c index bd0ecd48c7..4aec1c383a 100644 --- a/hw/display/ati_dbg.c +++ b/hw/display/ati_dbg.c @@ -38,6 +38,7 @@ static struct ati_regdesc ati_reg_names[] =3D { {"CONFIG_APER_SIZE", 0x0108}, {"CONFIG_REG_1_BASE", 0x010c}, {"CONFIG_REG_APER_SIZE", 0x0110}, + {"HOST_PATH_CNTL", 0x0130}, {"MEM_CNTL", 0x0140}, {"MC_FB_LOCATION", 0x0148}, {"MC_AGP_LOCATION", 0x014C}, --=20 2.41.0 From nobody Wed Nov 27 10:34:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277598; cv=none; d=zohomail.com; s=zohoarc; b=HShJHOHGcY4sM5vrUwUg0+LCaOgXqxFZJNCceaXFk38vT/NH6uvvr7/+s4lw48D4DDiz6L4GLpWkV7P57M+nV2Szg0+nhbeWLv0hNsr0jNmbvmOrYTdikFl77ArQkEJjMAaJHS3nROGbH8JPUjAUjump2D/HeXTVBz4gLTruDl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277598; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5l06+SbSlvQrNpED/nkKOOn53nxrTicxHGor4Ux3drg=; b=SRi2G8uqIZnTOp8dU9ovXPqpAX49sVGFvVU8DL4L1dLEeim+O3vrS6h9qdf5KWwLG1897Uc8BqSmbx89g9jYDFgC9wz1FpqXiYB+BvzIcXH6IlsardVzQsvSQQ5jcOlL4XQZlYkGJDnvnaIcmq5VZrHyUBQ9pmhecqp3lVGUgaA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699277598205883.7774005722708; Mon, 6 Nov 2023 05:33:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzzic-0005jR-Km; Mon, 06 Nov 2023 08:32:42 -0500 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 1qzzib-0005j2-Gz for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzziZ-0003kh-Sz for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:41 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-252-c8D875A2NbiQvtNOZrx6jQ-1; Mon, 06 Nov 2023 08:32:36 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 287C889C662; Mon, 6 Nov 2023 13:32:36 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D8BD2026D66; Mon, 6 Nov 2023 13:32:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277558; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5l06+SbSlvQrNpED/nkKOOn53nxrTicxHGor4Ux3drg=; b=Mun8fsfeDlvOIJL4imgBaeV0xTsvU9sG6iwH+1nbqJmxu45UJGFyeMmaQ6NMoUPZ63Fzaz jsxOoAOYnjSfyl8hUFH6qavCRbrJFvijmvwvt5fJt0dh1s5UKbqi0s6cizfmnfBkQ/5gXm h/p/ZBEhRBbK/YmLaX7LclK9PEagUZg= X-MC-Unique: c8D875A2NbiQvtNOZrx6jQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, BALATON Zoltan Subject: [PULL 03/10] ati-vga: Support unaligned access to GPIO DDC registers Date: Mon, 6 Nov 2023 17:32:12 +0400 Message-ID: <20231106133219.2173660-4-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699277599123100001 From: BALATON Zoltan The GPIO_VGA_DDC and GPIO_DVI_DDC registers are used on Radeon for DDC access. Some drivers like the PPC Mac FCode ROM uses unaligned writes to these registers so implement this the same way as already done for GPIO_MONID which is used the same way for the Rage 128 Pro. Signed-off-by: BALATON Zoltan Acked-by: Marc-Andr=C3=A9 Lureau Message-ID: --- hw/display/ati.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index 9a9ea754bd..538651c233 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -319,11 +319,13 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr= , unsigned int size) case DAC_CNTL: val =3D s->regs.dac_cntl; break; - case GPIO_VGA_DDC: - val =3D s->regs.gpio_vga_ddc; + case GPIO_VGA_DDC ... GPIO_VGA_DDC + 3: + val =3D ati_reg_read_offs(s->regs.gpio_vga_ddc, + addr - GPIO_VGA_DDC, size); break; - case GPIO_DVI_DDC: - val =3D s->regs.gpio_dvi_ddc; + case GPIO_DVI_DDC ... GPIO_DVI_DDC + 3: + val =3D ati_reg_read_offs(s->regs.gpio_dvi_ddc, + addr - GPIO_DVI_DDC, size); break; case GPIO_MONID ... GPIO_MONID + 3: val =3D ati_reg_read_offs(s->regs.gpio_monid, @@ -615,29 +617,34 @@ static void ati_mm_write(void *opaque, hwaddr addr, s->regs.dac_cntl =3D data & 0xffffe3ff; s->vga.dac_8bit =3D !!(data & DAC_8BIT_EN); break; - case GPIO_VGA_DDC: + /* + * GPIO regs for DDC access. Because some drivers access these via + * multiple byte writes we have to be careful when we send bits to + * avoid spurious changes in bitbang_i2c state. Only do it when either + * the enable bits are changed or output bits changed while enabled. + */ + case GPIO_VGA_DDC ... GPIO_VGA_DDC + 3: if (s->dev_id !=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { /* FIXME: Maybe add a property to select VGA or DVI port? */ } break; - case GPIO_DVI_DDC: + case GPIO_DVI_DDC ... GPIO_DVI_DDC + 3: if (s->dev_id !=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { - s->regs.gpio_dvi_ddc =3D ati_i2c(&s->bbi2c, data, 0); + ati_reg_write_offs(&s->regs.gpio_dvi_ddc, + addr - GPIO_DVI_DDC, data, size); + if ((addr <=3D GPIO_DVI_DDC + 2 && addr + size > GPIO_DVI_DDC = + 2) || + (addr =3D=3D GPIO_DVI_DDC && (s->regs.gpio_dvi_ddc & 0x300= 00))) { + s->regs.gpio_dvi_ddc =3D ati_i2c(&s->bbi2c, + s->regs.gpio_dvi_ddc, 0); + } } break; case GPIO_MONID ... GPIO_MONID + 3: /* FIXME What does Radeon have here? */ if (s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF) { + /* Rage128p accesses DDC via MONID(1-2) with additional mask b= it */ ati_reg_write_offs(&s->regs.gpio_monid, addr - GPIO_MONID, data, size); - /* - * Rage128p accesses DDC used to get EDID via these bits. - * Because some drivers access this via multiple byte writes - * we have to be careful when we send bits to avoid spurious - * changes in bitbang_i2c state. So only do it when mask is set - * and either the enable bits are changed or output bits chang= ed - * while enabled. - */ if ((s->regs.gpio_monid & BIT(25)) && ((addr <=3D GPIO_MONID + 2 && addr + size > GPIO_MONID + 2= ) || (addr =3D=3D GPIO_MONID && (s->regs.gpio_monid & 0x60000)= ))) { --=20 2.41.0 From nobody Wed Nov 27 10:34:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277665; cv=none; d=zohomail.com; s=zohoarc; b=RWweKQkER7YdYRZFHlHp8NKIBh9YNZHfA1uvQuGoweogYfGP8zONtQUCzQ2XaDmgRlhLNK5CfDf8RGMZxZqQ9wrAiUESqNPTncrnfsMaENNs471KaCnK4lh7L8MtnCmDiOiYBZ307yOr+q2EqUWOC2+JFyKGltia7Cl6IBxQx6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277665; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Wrw1TLwcieyZj3PYYiGWOE6P3VGmBO15YjosPs/JHdI=; b=Sex45cbLgssPdFxW2Lm41PSeGaZIq1nlP20oET4H/1ZQk9UUwEVvE/LhaDojXynv4QgsP26UDUw0juj/fkFIT7lBoTE0gZzuAfBFsXsbBA0hDftwaxEzPj4XgBJ2MBX7DynwJw+SnuWjSyyleWwyyZdccr5sYMvvL4sA3drdAOU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169927766565436.04270282845505; Mon, 6 Nov 2023 05:34:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzzih-0005lT-MR; Mon, 06 Nov 2023 08:32:47 -0500 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 1qzzig-0005ka-BG for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzzie-0003ky-NT for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:46 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-403-YBxKm97oNOO2gF-rS6tcfg-1; Mon, 06 Nov 2023 08:32:40 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53450185A78F; Mon, 6 Nov 2023 13:32:40 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 79B83502B; Mon, 6 Nov 2023 13:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wrw1TLwcieyZj3PYYiGWOE6P3VGmBO15YjosPs/JHdI=; b=HxylOwhrk/IlPBEizu4EardlcBYh47Zwc6eC7RdhUv5kpEWu4qmb6IX2+8+LvVJJOnMH+d 8GlKvNeMlWcVCuaVQkmZ6aTSQElnKmWMWpMdYeExjyEq1Rwg5mR7NAGaGwCSXlIoYxGQXP AA03cWb4Re+re/4vQozEKu+R/PSAAxE= X-MC-Unique: YBxKm97oNOO2gF-rS6tcfg-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, BALATON Zoltan Subject: [PULL 04/10] ati-vga: Add 30 bit palette access register Date: Mon, 6 Nov 2023 17:32:13 +0400 Message-ID: <20231106133219.2173660-5-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699277669544100001 From: BALATON Zoltan Radeon cards have a 30 bit DAC and corresponding palette register to access it. We only use 8 bits but let the guests use 10 bit color values for those that access it through this register. Signed-off-by: BALATON Zoltan Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <9fa19eec95d1563cc65853cf26912f230c702b32.1698871239.git.balato= n@eik.bme.hu> --- hw/display/ati_int.h | 1 + hw/display/ati_regs.h | 1 + hw/display/ati.c | 9 +++++++++ hw/display/ati_dbg.c | 1 + 4 files changed, 12 insertions(+) diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index e8d3c7af75..8abb873f01 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -44,6 +44,7 @@ typedef struct ATIVGARegs { uint32_t gpio_dvi_ddc; uint32_t gpio_monid; uint32_t config_cntl; + uint32_t palette[256]; uint32_t crtc_h_total_disp; uint32_t crtc_h_sync_strt_wid; uint32_t crtc_v_total_disp; diff --git a/hw/display/ati_regs.h b/hw/display/ati_regs.h index c697b328da..d7127748ff 100644 --- a/hw/display/ati_regs.h +++ b/hw/display/ati_regs.h @@ -48,6 +48,7 @@ #define AMCGPIO_EN_MIR 0x00a8 #define PALETTE_INDEX 0x00b0 #define PALETTE_DATA 0x00b4 +#define PALETTE_30_DATA 0x00b8 #define CNFG_CNTL 0x00e0 #define GEN_RESET_CNTL 0x00f0 #define CNFG_MEMSIZE 0x00f8 diff --git a/hw/display/ati.c b/hw/display/ati.c index 538651c233..4868f95cf2 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -339,6 +339,9 @@ static uint64_t ati_mm_read(void *opaque, hwaddr addr, = unsigned int size) case PALETTE_DATA: val =3D vga_ioport_read(&s->vga, VGA_PEL_D); break; + case PALETTE_30_DATA: + val =3D s->regs.palette[vga_ioport_read(&s->vga, VGA_PEL_IR)]; + break; case CNFG_CNTL: val =3D s->regs.config_cntl; break; @@ -673,6 +676,12 @@ static void ati_mm_write(void *opaque, hwaddr addr, data >>=3D 8; vga_ioport_write(&s->vga, VGA_PEL_D, data & 0xff); break; + case PALETTE_30_DATA: + s->regs.palette[vga_ioport_read(&s->vga, VGA_PEL_IW)] =3D data; + vga_ioport_write(&s->vga, VGA_PEL_D, (data >> 22) & 0xff); + vga_ioport_write(&s->vga, VGA_PEL_D, (data >> 12) & 0xff); + vga_ioport_write(&s->vga, VGA_PEL_D, (data >> 2) & 0xff); + break; case CNFG_CNTL: s->regs.config_cntl =3D data; break; diff --git a/hw/display/ati_dbg.c b/hw/display/ati_dbg.c index 4aec1c383a..3ffa7f35df 100644 --- a/hw/display/ati_dbg.c +++ b/hw/display/ati_dbg.c @@ -30,6 +30,7 @@ static struct ati_regdesc ati_reg_names[] =3D { {"AMCGPIO_EN_MIR", 0x00a8}, {"PALETTE_INDEX", 0x00b0}, {"PALETTE_DATA", 0x00b4}, + {"PALETTE_30_DATA", 0x00b8}, {"CNFG_CNTL", 0x00e0}, {"GEN_RESET_CNTL", 0x00f0}, {"CNFG_MEMSIZE", 0x00f8}, --=20 2.41.0 From nobody Wed Nov 27 10:34:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277598; cv=none; d=zohomail.com; s=zohoarc; b=R/5xCtn3dX7vQINHxHo7+Ka8y6whTlZiIMk2lMApmYbSgcyAdONoq0Dlb/hWoA4rS2vd0SW4gCFOS83BtL7Njp52zuqV/BW7dpO67byObGKl81ncGHeiiM/gGUTD4GAhsRCfU53kPeaRkDHDPog2Zl9aQV21w32gLJO03NIfuhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277598; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Mywo8KICVCxbxzpY+mReJFJ1I78UFt3Y9PYuMgZIeBs=; b=bMttBXhTojcube5i9gSFPV0yPMCUTxWH9TcHN5ZGPKuik5mKXVYgvnj6qlLH1PgU81ChUIWZ5ogPXdq3MnQTeTOhK4M7XXNf4nlDam92qPxiRNc+yRxv5szT1esZQiIFSl+X9t2cEpRd847LhNuoZWVbk2lerm3p6x84wfOwmxA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699277598331744.2484887378263; Mon, 6 Nov 2023 05:33:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzzik-0005nA-7X; Mon, 06 Nov 2023 08:32:50 -0500 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 1qzzii-0005m7-NS for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzzig-0003lG-Ux for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:48 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-125-KYB8TDfGM1OurNTp5L4s9g-1; Mon, 06 Nov 2023 08:32:44 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55542185A788; Mon, 6 Nov 2023 13:32:44 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BC74492BE0; Mon, 6 Nov 2023 13:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277566; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mywo8KICVCxbxzpY+mReJFJ1I78UFt3Y9PYuMgZIeBs=; b=FzzjEPgGBIU+9wJUGs937AsL+IB+qk9vJpn5682i3sCy1pzTeVL03AhKgGkhMWVHpOJlFK 2wZzQlsrSh3w060Yk4ZN6JK/jca7X72/q8f+6ttFn4U4kKHS1PI/BALZFDbg2UIFL966YX CTVdax9FowigOiTlfZf+n8QmwrIO95k= X-MC-Unique: KYB8TDfGM1OurNTp5L4s9g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, BALATON Zoltan Subject: [PULL 05/10] ati-vga: Implement fallback for pixman routines Date: Mon, 6 Nov 2023 17:32:14 +0400 Message-ID: <20231106133219.2173660-6-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699277599140100002 From: BALATON Zoltan Pixman routines can fail if no implementation is available and it will become optional soon so add fallbacks when pixman does not work. Signed-off-by: BALATON Zoltan Acked-by: Marc-Andr=C3=A9 Lureau Message-ID: --- hw/display/ati_int.h | 1 + hw/display/ati.c | 8 +++++ hw/display/ati_2d.c | 75 +++++++++++++++++++++++++++++++------------- 3 files changed, 62 insertions(+), 22 deletions(-) diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index 8abb873f01..f5a47b82b0 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -90,6 +90,7 @@ struct ATIVGAState { char *model; uint16_t dev_id; uint8_t mode; + uint8_t use_pixman; bool cursor_guest_mode; uint16_t cursor_size; uint32_t cursor_offset; diff --git a/hw/display/ati.c b/hw/display/ati.c index 4868f95cf2..9a87a5504a 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -1033,6 +1033,7 @@ static Property ati_vga_properties[] =3D { DEFINE_PROP_UINT16("x-device-id", ATIVGAState, dev_id, PCI_DEVICE_ID_ATI_RAGE128_PF), DEFINE_PROP_BOOL("guest_hwcursor", ATIVGAState, cursor_guest_mode, fal= se), + DEFINE_PROP_UINT8("x-pixman", ATIVGAState, use_pixman, 3), DEFINE_PROP_END_OF_LIST() }; =20 @@ -1054,11 +1055,18 @@ static void ati_vga_class_init(ObjectClass *klass, = void *data) k->exit =3D ati_vga_exit; } =20 +static void ati_vga_init(Object *o) +{ + object_property_set_description(o, "x-pixman", "Use pixman for: " + "1: fill, 2: blit"); +} + static const TypeInfo ati_vga_info =3D { .name =3D TYPE_ATI_VGA, .parent =3D TYPE_PCI_DEVICE, .instance_size =3D sizeof(ATIVGAState), .class_init =3D ati_vga_class_init, + .instance_init =3D ati_vga_init, .interfaces =3D (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, { }, diff --git a/hw/display/ati_2d.c b/hw/display/ati_2d.c index 7d786653e8..0e6b8e4367 100644 --- a/hw/display/ati_2d.c +++ b/hw/display/ati_2d.c @@ -92,6 +92,7 @@ void ati_2d_blt(ATIVGAState *s) switch (s->regs.dp_mix & GMC_ROP3_MASK) { case ROP3_SRCCOPY: { + bool fallback =3D false; unsigned src_x =3D (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT ? s->regs.src_x : s->regs.src_x + 1 - s->regs.dst_wid= th); unsigned src_y =3D (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM ? @@ -122,27 +123,50 @@ void ati_2d_blt(ATIVGAState *s) src_bits, dst_bits, src_stride, dst_stride, bpp, bpp, src_x, src_y, dst_x, dst_y, s->regs.dst_width, s->regs.dst_height); - if (s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT && + if ((s->use_pixman & BIT(1)) && + s->regs.dp_cntl & DST_X_LEFT_TO_RIGHT && s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM) { - pixman_blt((uint32_t *)src_bits, (uint32_t *)dst_bits, - src_stride, dst_stride, bpp, bpp, - src_x, src_y, dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height); - } else { + fallback =3D !pixman_blt((uint32_t *)src_bits, (uint32_t *)dst= _bits, + src_stride, dst_stride, bpp, bpp, + src_x, src_y, dst_x, dst_y, + s->regs.dst_width, s->regs.dst_height); + } else if (s->use_pixman & BIT(1)) { /* FIXME: We only really need a temporary if src and dst overl= ap */ int llb =3D s->regs.dst_width * (bpp / 8); int tmp_stride =3D DIV_ROUND_UP(llb, sizeof(uint32_t)); uint32_t *tmp =3D g_malloc(tmp_stride * sizeof(uint32_t) * s->regs.dst_height); - pixman_blt((uint32_t *)src_bits, tmp, - src_stride, tmp_stride, bpp, bpp, - src_x, src_y, 0, 0, - s->regs.dst_width, s->regs.dst_height); - pixman_blt(tmp, (uint32_t *)dst_bits, - tmp_stride, dst_stride, bpp, bpp, - 0, 0, dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height); + fallback =3D !pixman_blt((uint32_t *)src_bits, tmp, + src_stride, tmp_stride, bpp, bpp, + src_x, src_y, 0, 0, + s->regs.dst_width, s->regs.dst_height); + if (!fallback) { + fallback =3D !pixman_blt(tmp, (uint32_t *)dst_bits, + tmp_stride, dst_stride, bpp, bpp, + 0, 0, dst_x, dst_y, + s->regs.dst_width, s->regs.dst_heig= ht); + } g_free(tmp); + } else { + fallback =3D true; + } + if (fallback) { + unsigned int y, i, j, bypp =3D bpp / 8; + unsigned int src_pitch =3D src_stride * sizeof(uint32_t); + unsigned int dst_pitch =3D dst_stride * sizeof(uint32_t); + + for (y =3D 0; y < s->regs.dst_height; y++) { + i =3D dst_x * bypp; + j =3D src_x * bypp; + if (s->regs.dp_cntl & DST_Y_TOP_TO_BOTTOM) { + i +=3D (dst_y + y) * dst_pitch; + j +=3D (src_y + y) * src_pitch; + } else { + i +=3D (dst_y + s->regs.dst_height - 1 - y) * dst_pitc= h; + j +=3D (src_y + s->regs.dst_height - 1 - y) * src_pitc= h; + } + memmove(&dst_bits[i], &src_bits[j], s->regs.dst_width * by= pp); + } } if (dst_bits >=3D s->vga.vram_ptr + s->vga.vbe_start_addr && dst_bits < s->vga.vram_ptr + s->vga.vbe_start_addr + @@ -180,14 +204,21 @@ void ati_2d_blt(ATIVGAState *s) =20 dst_stride /=3D sizeof(uint32_t); DPRINTF("pixman_fill(%p, %d, %d, %d, %d, %d, %d, %x)\n", - dst_bits, dst_stride, bpp, - dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height, - filler); - pixman_fill((uint32_t *)dst_bits, dst_stride, bpp, - dst_x, dst_y, - s->regs.dst_width, s->regs.dst_height, - filler); + dst_bits, dst_stride, bpp, dst_x, dst_y, + s->regs.dst_width, s->regs.dst_height, filler); + if (!(s->use_pixman & BIT(0)) || + !pixman_fill((uint32_t *)dst_bits, dst_stride, bpp, dst_x, dst= _y, + s->regs.dst_width, s->regs.dst_height, filler)) { + /* fallback when pixman failed or we don't want to call it */ + unsigned int x, y, i, bypp =3D bpp / 8; + unsigned int dst_pitch =3D dst_stride * sizeof(uint32_t); + for (y =3D 0; y < s->regs.dst_height; y++) { + i =3D dst_x * bypp + (dst_y + y) * dst_pitch; + for (x =3D 0; x < s->regs.dst_width; x++, i +=3D bypp) { + stn_he_p(&dst_bits[i], bypp, filler); + } + } + } if (dst_bits >=3D s->vga.vram_ptr + s->vga.vbe_start_addr && dst_bits < s->vga.vram_ptr + s->vga.vbe_start_addr + s->vga.vbe_regs[VBE_DISPI_INDEX_YRES] * s->vga.vbe_line_offset= ) { --=20 2.41.0 From nobody Wed Nov 27 10:34:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277676; cv=none; d=zohomail.com; s=zohoarc; b=d+DQm2X7ZwaUX8vY7pWb6K9RxaiA28vSft8W2PAflZz/CTiSaajzw3Nkj7g0GgD+3JPdqy7hIYLXj8gnEn4cTV5sQbhoHTVR2jhXjNwAoZiKOu4lAUedaJFFKJPQk1DKEQ22fzenzrCANkbzU45sk7QlOkTwBg0+MBAx7HIIofQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277676; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=X3pznm3QlOU/ZHLArGlalsrlHMHaEqY9m5mHFzJczgg=; b=R2cYuGzk5XE7qByJqQlbG7toPvJCh4efKMo6ayQBLHusRJc7n7JLSlcc5knFmaHJsluGtrJxZfOIHXM0gZrlCtInRISg1aYOEVem4Vxz5BYPlCMwpn2L5MbwJCtWALIW8KJw09e1kwo+XJ8qm+XQFFF4mTymwopJeJG4MalQ13M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699277676091482.1322161960635; Mon, 6 Nov 2023 05:34:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzzio-0005ps-2u; Mon, 06 Nov 2023 08:32:54 -0500 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 1qzzim-0005pG-IV for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzzik-0003lY-Rj for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:52 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638--qHk8jM8PnijWRIfJ7O29A-1; Mon, 06 Nov 2023 08:32:48 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 24DF42815E22 for ; Mon, 6 Nov 2023 13:32:48 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 684DE2166B26; Mon, 6 Nov 2023 13:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X3pznm3QlOU/ZHLArGlalsrlHMHaEqY9m5mHFzJczgg=; b=hgmJGfVm8opRgpHQRlZ/0iwh5/V02Namr73q57dvvVyaZXTsAUNMbBykixpVosqJ7yFaXX qEJuE/NrZDiUzzBrbB2XK0ScLtMXT63eqgah7R+i0QMcFIyh5vkQx/eJafG8GEYMlH50y8 VwGQoNZfI1SHP7VUWGC/h0joSFr9EBs= X-MC-Unique: -qHk8jM8PnijWRIfJ7O29A-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PULL 06/10] virtio-gpu: block migration of VMs with blob=true Date: Mon, 6 Nov 2023 17:32:15 +0400 Message-ID: <20231106133219.2173660-7-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699277677461100005 From: Marc-Andr=C3=A9 Lureau "blob" resources don't have an associated pixman image: #0 pixman_image_get_stride (image=3D0x0) at ../pixman/pixman-image.c:921 #1 0x0000562327c25236 in virtio_gpu_save (f=3D0x56232bb13b00, opaque=3D0x5= 6232b555a60, size=3D0, field=3D0x5623289ab6c8 <__compound_literal.3+104>, v= mdesc=3D0x56232ab59fe0) at ../hw/display/virtio-gpu.c:1225 Related to: https://bugzilla.redhat.com/show_bug.cgi?id=3D2236353 Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Peter Xu --- hw/display/virtio-gpu.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 4265316cbb..dd9965c2ef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -26,6 +26,7 @@ #include "hw/virtio/virtio-gpu-pixman.h" #include "hw/virtio/virtio-bus.h" #include "hw/qdev-properties.h" +#include "migration/blocker.h" #include "qemu/log.h" #include "qemu/module.h" #include "qapi/error.h" @@ -40,6 +41,8 @@ virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t res= ource_id, =20 static void virtio_gpu_reset_bh(void *opaque); =20 +static Error *blob_mig_blocker; + void virtio_gpu_update_cursor_data(VirtIOGPU *g, struct virtio_gpu_scanout *s, uint32_t resource_id) @@ -1373,6 +1376,14 @@ void virtio_gpu_device_realize(DeviceState *qdev, Er= ror **errp) error_setg(errp, "blobs and virgl are not compatible (yet)"); return; } + + if (!blob_mig_blocker) { + error_setg(&blob_mig_blocker, + "virtio-gpu blob VMs are currently not migratable."= ); + } + if (migrate_add_blocker(blob_mig_blocker, errp)) { + return; + } } =20 if (!virtio_gpu_base_device_realize(qdev, @@ -1399,6 +1410,9 @@ static void virtio_gpu_device_unrealize(DeviceState *= qdev) { VirtIOGPU *g =3D VIRTIO_GPU(qdev); =20 + if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { + migrate_del_blocker(blob_mig_blocker); + } g_clear_pointer(&g->ctrl_bh, qemu_bh_delete); g_clear_pointer(&g->cursor_bh, qemu_bh_delete); g_clear_pointer(&g->reset_bh, qemu_bh_delete); --=20 2.41.0 From nobody Wed Nov 27 10:34:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277614; cv=none; d=zohomail.com; s=zohoarc; b=HV8Du+opFI4baP9YESxabQSSgdM4n+xFQVEoIKP0zz8QaHWgapcJ9osAWPHomnfTNeya1DJqK3Kl0Ai2kbEaN6ibQnKpY5f3rPvp1mhfpetY6Z1tnwNi5Utp+E81D0onGLDOJ53sfL/lEjRqRSnPaxpA0VPE+o+asVDJHRz6zbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277614; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=A8UAkq1odSE9Wc7UJB+Fgiwz/bE8MqjvP5XpsReUFhI=; b=hWmjGQ7s5rxvy/1lBiOmSoKe5RkhC4thjzUSqL9YetCQgVvd3IXytnivV0J8X5tBf8aikYgvc1yTLwdv4ydAfLAEzLNgxT2ujotCzXDazzG1NKTPJBL7JVnBVlGPEzpYFQ4tnaHWDuK5B4vMYDIEVRYkfeGwVorO5Y5BDjU+IkA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169927761404052.601535996562916; Mon, 6 Nov 2023 05:33:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzzis-0005sF-TT; Mon, 06 Nov 2023 08:32:58 -0500 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 1qzzir-0005rR-4B for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzzip-0003ls-I6 for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:32:56 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-373-xQetAEX5Me6PnbhBHqG79g-1; Mon, 06 Nov 2023 08:32:52 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2179984B108 for ; Mon, 6 Nov 2023 13:32:52 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1123A502B; Mon, 6 Nov 2023 13:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277573; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A8UAkq1odSE9Wc7UJB+Fgiwz/bE8MqjvP5XpsReUFhI=; b=YP+MP6JS9xWyQijsVLRzJqVQiVU3qCOxUrUT+lk6Lu/mLlpRd4XqUlwHyNS61c87IzMxlM YPVDxKMH2JnbrP12+bF9bew57kmk4JbIqM7QVDyKe+7OJy0CdSkdi7s8k3c3tEX3C1KxVc i4H7Jb1J6jpACCxmp+Jq2BYBne/Qb4E= X-MC-Unique: xQetAEX5Me6PnbhBHqG79g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Gerd Hoffmann Subject: [PULL 07/10] virtio-gpu: factor out restore mapping Date: Mon, 6 Nov 2023 17:32:16 +0400 Message-ID: <20231106133219.2173660-8-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699277615004100001 From: Marc-Andr=C3=A9 Lureau The same function is going to be used next to restore "blob" resources. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Peter Xu --- hw/display/virtio-gpu.c | 60 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index dd9965c2ef..8efabae7ee 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1233,6 +1233,35 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque= , size_t size, return vmstate_save_state(f, &vmstate_virtio_gpu_scanouts, g, NULL); } =20 +static bool virtio_gpu_load_restore_mapping(VirtIOGPU *g, + struct virtio_gpu_simple_resou= rce *res) +{ + int i; + + for (i =3D 0; i < res->iov_cnt; i++) { + hwaddr len =3D res->iov[i].iov_len; + res->iov[i].iov_base =3D + dma_memory_map(VIRTIO_DEVICE(g)->dma_as, res->addrs[i], &len, + DMA_DIRECTION_TO_DEVICE, MEMTXATTRS_UNSPECIFIED= ); + + if (!res->iov[i].iov_base || len !=3D res->iov[i].iov_len) { + /* Clean up the half-a-mapping we just created... */ + if (res->iov[i].iov_base) { + dma_memory_unmap(VIRTIO_DEVICE(g)->dma_as, res->iov[i].iov= _base, + len, DMA_DIRECTION_TO_DEVICE, 0); + } + /* ...and the mappings for previous loop iterations */ + res->iov_cnt =3D i; + virtio_gpu_cleanup_mapping(g, res); + return false; + } + } + + QTAILQ_INSERT_HEAD(&g->reslist, res, next); + g->hostmem +=3D res->hostmem; + return true; +} + static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size, const VMStateField *field) { @@ -1297,35 +1326,12 @@ static int virtio_gpu_load(QEMUFile *f, void *opaqu= e, size_t size, qemu_get_buffer(f, (void *)pixman_image_get_data(res->image), pixman_image_get_stride(res->image) * res->height); =20 - /* restore mapping */ - for (i =3D 0; i < res->iov_cnt; i++) { - hwaddr len =3D res->iov[i].iov_len; - res->iov[i].iov_base =3D - dma_memory_map(VIRTIO_DEVICE(g)->dma_as, res->addrs[i], &l= en, - DMA_DIRECTION_TO_DEVICE, - MEMTXATTRS_UNSPECIFIED); - - if (!res->iov[i].iov_base || len !=3D res->iov[i].iov_len) { - /* Clean up the half-a-mapping we just created... */ - if (res->iov[i].iov_base) { - dma_memory_unmap(VIRTIO_DEVICE(g)->dma_as, - res->iov[i].iov_base, - len, - DMA_DIRECTION_TO_DEVICE, - 0); - } - /* ...and the mappings for previous loop iterations */ - res->iov_cnt =3D i; - virtio_gpu_cleanup_mapping(g, res); - pixman_image_unref(res->image); - g_free(res); - return -EINVAL; - } + if (!virtio_gpu_load_restore_mapping(g, res)) { + pixman_image_unref(res->image); + g_free(res); + return -EINVAL; } =20 - QTAILQ_INSERT_HEAD(&g->reslist, res, next); - g->hostmem +=3D res->hostmem; - resource_id =3D qemu_get_be32(f); } =20 --=20 2.41.0 From nobody Wed Nov 27 10:34:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277678; cv=none; d=zohomail.com; s=zohoarc; b=JLBnRsW/jaWPJlZtsZhHqrO8Fibx+wm9jm8tl1Z//GrYPmJBxEOneyfByba5f67uFEaLFRbNBYe3DcGskkE/rJ/UJsHCsWDi/fcHY9ul7esIzUFrTo97DR70k8lV7/r6LCf7kUO7lILUSQqmBjkC4YAdB7zFjEz+B7AM7aSs6lc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277678; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OXsr14z/1X1B5RZ0gb0GgVyyGQiIAYKmcIcbCGPQ5vA=; b=Xz50plFnboV2fviniAmaXGsPYI/n6m7G7CT2lMMD+7jqMegkoFT5d5vNDTTuGwOQFmQ6GV6ciN0jfjXiYPIqnle93QkPiFApXX1jrfxF9GZ8RFl4K0AgnzMkkmirxv60BC2ZvCoDpuC9KnMVHkD7LUWCV+OFOcBrzDLX/39Zftc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699277678415312.44801496396315; Mon, 6 Nov 2023 05:34:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzziy-0005sv-K5; Mon, 06 Nov 2023 08:33:04 -0500 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 1qzziw-0005sk-NR for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:33:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzziu-0003mE-LW for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:33:02 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-116-sjFLCEECPjWFRcYDlY1KpA-1; Mon, 06 Nov 2023 08:32:56 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 84C0889C662 for ; Mon, 6 Nov 2023 13:32:56 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73E632166B26; Mon, 6 Nov 2023 13:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277580; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OXsr14z/1X1B5RZ0gb0GgVyyGQiIAYKmcIcbCGPQ5vA=; b=IEHHV94u5tVn3KbBmuBKuvSvsKmvFeY6j4aJ8sBjpszWAj3lRkRF2hjORwLB/CrzpS3yJM 4hiRSJXfa0oOMHh0VGhuH6PCgImE7QP4/+LUx5ByECiP1aQ1Nngo5Z2idPc9UGoS4tGoIW CbDxSuvPKzZdirMExKzL9/kCr97FqlM= X-MC-Unique: sjFLCEECPjWFRcYDlY1KpA-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , "Michael S. Tsirkin" , Gerd Hoffmann Subject: [PULL 08/10] virtio-gpu: move scanout restoration to post_load Date: Mon, 6 Nov 2023 17:32:17 +0400 Message-ID: <20231106133219.2173660-9-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699277679314100007 From: Marc-Andr=C3=A9 Lureau As we are going to introduce an extra subsection for "blob" resources, scanout have to be restored after. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Peter Xu --- hw/display/virtio-gpu.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 8efabae7ee..26065c6466 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1267,7 +1267,6 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, { VirtIOGPU *g =3D opaque; struct virtio_gpu_simple_resource *res; - struct virtio_gpu_scanout *scanout; uint32_t resource_id, pformat; void *bits =3D NULL; int i; @@ -1337,6 +1336,17 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque= , size_t size, =20 /* load & apply scanout state */ vmstate_load_state(f, &vmstate_virtio_gpu_scanouts, g, 1); + + return 0; +} + +static int virtio_gpu_post_load(void *opaque, int version_id) +{ + VirtIOGPU *g =3D opaque; + struct virtio_gpu_scanout *scanout; + struct virtio_gpu_simple_resource *res; + int i; + for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { /* FIXME: should take scanout.r.{x,y} into account */ scanout =3D &g->parent_obj.scanout[i]; @@ -1520,6 +1530,7 @@ static const VMStateDescription vmstate_virtio_gpu = =3D { } /* device */, VMSTATE_END_OF_LIST() }, + .post_load =3D virtio_gpu_post_load, }; =20 static Property virtio_gpu_properties[] =3D { --=20 2.41.0 From nobody Wed Nov 27 10:34:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277629; cv=none; d=zohomail.com; s=zohoarc; b=MiPP4f8Vx/78zo9Gw4d5oSjq9dw2U8eMHrF7eJFTnV2UlWV86YxONAd1GoxjUefTsam7uzvOTuOX2w3xMl1JDZp1h3pzp07De+evJUIcNGJplhquWKzOk0HlIonS4A4ERBPwQJBqxlYsyDNTCN7vQcqVs8IRciNymX5j7J4OGjo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277629; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5o+XcPKRRjYB9IrY7Pzc8TYNltWXNcCojmQVdAXEGBg=; b=XNyJun1N3FUdSk89VALcTTvbY/W4dr43cRlWlTGtyd02+ahqi3ReQcEcMhwT1+q7h8RirzORvsPUzOUY5m/KVPtJo/dpnZNwCAppuRJt7iBNH63qRV4CyZ3MdiJ5IxSVwp/TylHZqsJ7xO8AaiWUKaQRpCF+PqS9xkzjy50E5Q4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699277629480552.9668871850073; Mon, 6 Nov 2023 05:33:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzzjB-0005zN-Q4; Mon, 06 Nov 2023 08:33:17 -0500 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 1qzzj9-0005uG-Ss for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:33:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzzj8-0003ml-7y for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:33:15 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-377-9oiJra_vOJ6W6vZyV5q92w-1; Mon, 06 Nov 2023 08:33:01 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E63593C0FC91 for ; Mon, 6 Nov 2023 13:33:00 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id A45F12166B26; Mon, 6 Nov 2023 13:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277593; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5o+XcPKRRjYB9IrY7Pzc8TYNltWXNcCojmQVdAXEGBg=; b=CJWDlo0N2Flt2Aig3IxeGLHYqcAgsOXY1UJoT7TKiJi2rknMVKvTVb3vY/dtM/c5J8X+DK +/3MlR9xElcm5HSRiCwh7WXaLApBR3LGbYZ8w5QzgSfuLJ/r8tUnvMaNz3KthKuUa2l3SQ 4skdLwzPiinl1RsqWUfoW0JqGlcPaLQ= X-MC-Unique: 9oiJra_vOJ6W6vZyV5q92w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PULL 09/10] virtio-gpu: add virtio-gpu/blob vmstate subsection Date: Mon, 6 Nov 2023 17:32:18 +0400 Message-ID: <20231106133219.2173660-10-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699277631055100003 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Peter Xu --- hw/display/virtio-gpu.c | 101 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 26065c6466..1ab662db72 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1216,6 +1216,9 @@ static int virtio_gpu_save(QEMUFile *f, void *opaque,= size_t size, assert(QTAILQ_EMPTY(&g->cmdq)); =20 QTAILQ_FOREACH(res, &g->reslist, next) { + if (res->blob_size) { + continue; + } qemu_put_be32(f, res->resource_id); qemu_put_be32(f, res->width); qemu_put_be32(f, res->height); @@ -1340,6 +1343,74 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque= , size_t size, return 0; } =20 +static int virtio_gpu_blob_save(QEMUFile *f, void *opaque, size_t size, + const VMStateField *field, JSONWriter *vmd= esc) +{ + VirtIOGPU *g =3D opaque; + struct virtio_gpu_simple_resource *res; + int i; + + /* in 2d mode we should never find unprocessed commands here */ + assert(QTAILQ_EMPTY(&g->cmdq)); + + QTAILQ_FOREACH(res, &g->reslist, next) { + if (!res->blob_size) { + continue; + } + qemu_put_be32(f, res->resource_id); + qemu_put_be32(f, res->blob_size); + qemu_put_be32(f, res->iov_cnt); + for (i =3D 0; i < res->iov_cnt; i++) { + qemu_put_be64(f, res->addrs[i]); + qemu_put_be32(f, res->iov[i].iov_len); + } + } + qemu_put_be32(f, 0); /* end of list */ + + return 0; +} + +static int virtio_gpu_blob_load(QEMUFile *f, void *opaque, size_t size, + const VMStateField *field) +{ + VirtIOGPU *g =3D opaque; + struct virtio_gpu_simple_resource *res; + uint32_t resource_id; + int i; + + resource_id =3D qemu_get_be32(f); + while (resource_id !=3D 0) { + res =3D virtio_gpu_find_resource(g, resource_id); + if (res) { + return -EINVAL; + } + + res =3D g_new0(struct virtio_gpu_simple_resource, 1); + res->resource_id =3D resource_id; + res->blob_size =3D qemu_get_be32(f); + res->iov_cnt =3D qemu_get_be32(f); + res->addrs =3D g_new(uint64_t, res->iov_cnt); + res->iov =3D g_new(struct iovec, res->iov_cnt); + + /* read data */ + for (i =3D 0; i < res->iov_cnt; i++) { + res->addrs[i] =3D qemu_get_be64(f); + res->iov[i].iov_len =3D qemu_get_be32(f); + } + + if (!virtio_gpu_load_restore_mapping(g, res)) { + g_free(res); + return -EINVAL; + } + + virtio_gpu_init_udmabuf(res); + + resource_id =3D qemu_get_be32(f); + } + + return 0; +} + static int virtio_gpu_post_load(void *opaque, int version_id) { VirtIOGPU *g =3D opaque; @@ -1505,6 +1576,32 @@ virtio_gpu_set_config(VirtIODevice *vdev, const uint= 8_t *config) } } =20 +static bool virtio_gpu_blob_state_needed(void *opaque) +{ + VirtIOGPU *g =3D VIRTIO_GPU(opaque); + + return virtio_gpu_blob_enabled(g->parent_obj.conf); +} + +const VMStateDescription vmstate_virtio_gpu_blob_state =3D { + .name =3D "virtio-gpu/blob", + .minimum_version_id =3D VIRTIO_GPU_VM_VERSION, + .version_id =3D VIRTIO_GPU_VM_VERSION, + .needed =3D virtio_gpu_blob_state_needed, + .fields =3D (const VMStateField[]){ + { + .name =3D "virtio-gpu/blob", + .info =3D &(const VMStateInfo) { + .name =3D "blob", + .get =3D virtio_gpu_blob_load, + .put =3D virtio_gpu_blob_save, + }, + .flags =3D VMS_SINGLE, + } /* device */, + VMSTATE_END_OF_LIST() + }, +}; + /* * For historical reasons virtio_gpu does not adhere to virtio migration * scheme as described in doc/virtio-migration.txt, in a sense that no @@ -1530,6 +1627,10 @@ static const VMStateDescription vmstate_virtio_gpu = =3D { } /* device */, VMSTATE_END_OF_LIST() }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_virtio_gpu_blob_state, + NULL + }, .post_load =3D virtio_gpu_post_load, }; =20 --=20 2.41.0 From nobody Wed Nov 27 10:34:56 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1699277683; cv=none; d=zohomail.com; s=zohoarc; b=Q2gC2f8yL9gClplt/tYt733S4sQF7elZCXAOVTrAC88Lw5W6NtO6GF1FL2LK18DGsyYfPqALo+zYvpfbXE9o+d1HUrPWEQg7z1a+gsVaJVC96y3Kxab8UksAJh2mmLuKgD4r/hH+sgrl0Y43XklA1cphJnwT5YHfNdgzb0/bK0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699277683; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wejLd0ksZslhsMWnUNkqRj7s1m2x0WcJ69rXE5PY0KI=; b=Qibe6Ws6sEFgqRH+b69uYkjPfB8IqG5IYSK7KMFbq009Eg4VNH/K7uLCsqPd8K7xewzx3VdH/YbJGGz9S2XdTZJlQQIrbTq1BF/ug9ECzpfZtTmcxyGJUCnNWkKO3usNLBSNsBqTNjctQEmf2dqBLKCe4SD/7upoVRoL8kA8L24= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1699277683217354.9731304474344; Mon, 6 Nov 2023 05:34:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzzj7-0005ts-Jh; Mon, 06 Nov 2023 08:33:13 -0500 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 1qzzj5-0005tj-Nu for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:33:11 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qzzj4-0003mX-46 for qemu-devel@nongnu.org; Mon, 06 Nov 2023 08:33:11 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-vF0lLvjVPHGTJcZ6ULhAQQ-1; Mon, 06 Nov 2023 08:33:06 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 53A9B101B049 for ; Mon, 6 Nov 2023 13:33:05 +0000 (UTC) Received: from localhost (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 334FE1C060B1; Mon, 6 Nov 2023 13:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699277588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wejLd0ksZslhsMWnUNkqRj7s1m2x0WcJ69rXE5PY0KI=; b=Ff1Pr7ueqeJAHiox6ZFWhjckaGzLG+/LNxBlkAeVSATZpRGUcnLINnFNBpg/tQoanrlX/v 3Io7jqyq2me1Yg8oQhBp+NohqeD0Acjnc/+8kBbdSkvj8rpS9gDOZhPkRAjVqmvadZwKab Sms9gwRH95fGjnCpoA7TA67ErlIymGw= X-MC-Unique: vF0lLvjVPHGTJcZ6ULhAQQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , "Michael S. Tsirkin" Subject: [PULL 10/10] Revert "virtio-gpu: block migration of VMs with blob=true" Date: Mon, 6 Nov 2023 17:32:19 +0400 Message-ID: <20231106133219.2173660-11-marcandre.lureau@redhat.com> In-Reply-To: <20231106133219.2173660-1-marcandre.lureau@redhat.com> References: <20231106133219.2173660-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1699277685350100003 From: Marc-Andr=C3=A9 Lureau If we decide to apply this patch (for easier backporting reasons), we can now revert it. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Peter Xu --- hw/display/virtio-gpu.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 1ab662db72..2707bceea8 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -26,7 +26,6 @@ #include "hw/virtio/virtio-gpu-pixman.h" #include "hw/virtio/virtio-bus.h" #include "hw/qdev-properties.h" -#include "migration/blocker.h" #include "qemu/log.h" #include "qemu/module.h" #include "qapi/error.h" @@ -41,8 +40,6 @@ virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t res= ource_id, =20 static void virtio_gpu_reset_bh(void *opaque); =20 -static Error *blob_mig_blocker; - void virtio_gpu_update_cursor_data(VirtIOGPU *g, struct virtio_gpu_scanout *s, uint32_t resource_id) @@ -1463,14 +1460,6 @@ void virtio_gpu_device_realize(DeviceState *qdev, Er= ror **errp) error_setg(errp, "blobs and virgl are not compatible (yet)"); return; } - - if (!blob_mig_blocker) { - error_setg(&blob_mig_blocker, - "virtio-gpu blob VMs are currently not migratable."= ); - } - if (migrate_add_blocker(blob_mig_blocker, errp)) { - return; - } } =20 if (!virtio_gpu_base_device_realize(qdev, @@ -1497,9 +1486,6 @@ static void virtio_gpu_device_unrealize(DeviceState *= qdev) { VirtIOGPU *g =3D VIRTIO_GPU(qdev); =20 - if (virtio_gpu_blob_enabled(g->parent_obj.conf)) { - migrate_del_blocker(blob_mig_blocker); - } g_clear_pointer(&g->ctrl_bh, qemu_bh_delete); g_clear_pointer(&g->cursor_bh, qemu_bh_delete); g_clear_pointer(&g->reset_bh, qemu_bh_delete); --=20 2.41.0