From nobody Fri Nov 14 19:45:16 2025 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=jablonski.xyz ARC-Seal: i=1; a=rsa-sha256; t=1760550001; cv=none; d=zohomail.com; s=zohoarc; b=bPK1pR18WGtN45HDTvuww5whar1m+WXOIVL/6rx6aXPzab8GsaAu7MpWHAuEBUz9gvRnBnp0W/9wjlISherJs17uvW8r2YmWg29IlS8v6lSOdjdlzNY3ojSIkVjmntGwyq7BkzDkzAXvqfIspAdrLXoHl71eCABHOWqaxqArASU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760550001; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RwPI2yPCbr0toTWpm1SItFJUF3sQIfFI43TqEZV2Bsg=; b=WVmMAnvYjZar7gmr1HqG9WTmnlwQlFktgqQRbylzjOcR1dvZUenc1iFqGXo4AgRS7dojTy0hZYZ8almBBKECPvbqhrPUXa235WyXgNUmnzmy81X9Bvhz/aQ6dMGkQeV7Y6/lp90dFdC4ym9DGhnHgrC0cT4BqJyNs82NsAwWF7k= 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 1760550001256573.6195654343082; Wed, 15 Oct 2025 10:40:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v95Sa-0001Uo-Bk; Wed, 15 Oct 2025 13:38:48 -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 1v95SW-0001U5-VF for qemu-devel@nongnu.org; Wed, 15 Oct 2025 13:38:45 -0400 Received: from fhigh-a3-smtp.messagingengine.com ([103.168.172.154]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v95SJ-0000hk-VQ for qemu-devel@nongnu.org; Wed, 15 Oct 2025 13:38:41 -0400 Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfhigh.phl.internal (Postfix) with ESMTP id 015C314001A4; Wed, 15 Oct 2025 13:38:30 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Wed, 15 Oct 2025 13:38:30 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 15 Oct 2025 13:38:28 -0400 (EDT) Received: from localhost (chomposaur [local]) by chomposaur (OpenSMTPD) with ESMTPA id 2224f0e7; Wed, 15 Oct 2025 17:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jablonski.xyz; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm1; t=1760549909; x=1760636309; bh=RwPI2yPCbr 0toTWpm1SItFJUF3sQIfFI43TqEZV2Bsg=; b=QZWoHoRlsbR57vqnCQOGggrQ/p JQok0xQ65P52/7/XP47sYQ1WSXXQb0alYlyvjryTAnA6V3sCRR9UAgopEeFX7GzO jqDp2AyujBIwAO6NPSQVDwCmcg7saOUzi3WHn1Gjv++zvqo8gWZdz6BOfgrpS51Q 9Z2MWFkNHo2Zu75qhP/irYKXSwKinY9iKUiVLxQ26ONoG1PQzvQv92c0SfU2F3TW AFkOvG9ptSTGTZFqOVnzOUGwZmkzQwl83SAm7bWenXrNy+lWa41OGI4Si/2HtE0i Q4kkqgAFrbaa0H1DpfCiZY4q51+f7W7pliq9rVtWz1aNupIuGwXQsxTxKKxQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1760549909; x=1760636309; bh=RwPI2yPCbr0toTWpm1SItFJUF3sQIfFI43T qEZV2Bsg=; b=aJJad23x6CrKE+xVx91GpYKlnjuUK3bxBwOiQII47S6yQJnwzjN /uDqI552nxefFckrIlIxyO+GBqpGdR4qkQCa0FK2tYQyBX+SVXxN1oKRt/D/gD/Y cCw+57dpbLWqX01vEdO1gO/WtC+Qjq0lhx6jWOkr5FBchuLQq5huk2fIwYj/mRC8 Q4jQaUsM8T625YhSh5Jq+ryLNLjCUvIPz0WkME3Ivyjsd2h3i/MQIHQaGedIzVrU kgFj3CKsNQwxPRfyHrDnnZGTe5AOa9TM/LdQYMO4v3jxMvzZTpnizsQgyYI4Rvi+ QRbmjQYroxi+VGFViS11Mw9zEPGzl2XIM8Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduvdegtdefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpefhvfevuf ffkffoggfgsedtkeertdertddtnecuhfhrohhmpeevhhgrugculfgrsghlohhnshhkihcu oegthhgrugesjhgrsghlohhnshhkihdrgiihiieqnecuggftrfgrthhtvghrnhephfetue fgueejleetgefgieegveejleeggedugfeuvdehgefhffduffeludekieevnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheptghhrggusehjrggslh honhhskhhirdighiiipdhnsggprhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdp rhgtphhtthhopegthhgrugesjhgrsghlohhnshhkihdrgiihiidprhgtphhtthhopehkrh grgigvlhesrhgvughhrghtrdgtohhmpdhrtghpthhtohepqhgvmhhuqdguvghvvghlsehn ohhnghhnuhdrohhrghdprhgtphhtthhopegsrghlrghtohhnsegvihhkrdgsmhgvrdhhuh dprhgtphhtthhopehmrghrtggrnhgurhgvrdhluhhrvggruhesrhgvughhrghtrdgtohhm X-ME-Proxy: Feedback-ID: ib26944c1:Fastmail From: Chad Jablonski To: qemu-devel@nongnu.org Cc: balaton@eik.bme.hu, kraxel@redhat.com, marcandre.lureau@redhat.com, Chad Jablonski Subject: [PATCH v2] ati-vga: Fix framebuffer mapping by using hardware-correct aperture sizes Date: Wed, 15 Oct 2025 13:37:16 -0400 Message-ID: <20251015173716.1764461-1-chad@jablonski.xyz> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.154; envelope-from=chad@jablonski.xyz; helo=fhigh-a3-smtp.messagingengine.com X-Spam_score_int: 17 X-Spam_score: 1.7 X-Spam_bar: + X-Spam_report: (1.7 / 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, FROM_SUSPICIOUS_NTLD=0.498, FROM_SUSPICIOUS_NTLD_FP=1.997, PDS_OTHER_BAD_TLD=1.997, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=no 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 @jablonski.xyz) X-ZM-MESSAGEID: 1760550008003158500 Content-Type: text/plain; charset="utf-8" Rage 128 cards always request 64MB for their linear (framebuffer) aperture. This is regardless of the amount of physical VRAM on the board. The following are results from real hardware tests: Card VRAM PCI BAR0 CONFIG_MEMSIZE CONFIG_APE= R_SIZE AGP_APER_OFFSET ----------------------- ---- -------- -------------- ----------= ------ --------------- Rage 128 Pro Ultra TF 32MB 64MB 0x02000000 0x0200000= 0 0x02000000 Rage 128 RF/SG AGP 16MB 64MB 0x01000000 0x0200000= 0 0x02000000 Radeon R100 QD [Radeon 7200] 64MB 128MB 0x04000000 0x0400000= 0 N/A Previously the linear aperture (BAR0) would match the VRAM size. This discrepancy caused issues with the X.org and XFree86 r128 drivers. These drivers apply a mask of 0xfc000000 (2^26 =3D 64MB) to the linear aperture address. If that address is not on a 64MB boundary the framebuffer points to an incorrect memory location. Testing shows that the Radeon R100 also has a BAR0 larger than VRAM (128MB in this case) and the X.org driver for Radeon also masks to 64MB. For Rage 128, CONFIG_APER_SIZE also differs from the previous value and the behavior stated in the documentation. The Rage 128 register guide states that it should contain the size of the VRAM + AGP memory. The cards tested above show that this isn't the case. These tests also included enabling/disabling AGP with 8MB of memory. It didn't change the contents of CONFIG_APER_SIZE. For Radeon R100, CONFIG_APER_SIZE behavior remains the same. There is some worry that changing it could cause issues for other cards. Especially given that I have only a single example here to test. Signed-off-by: Chad Jablonski --- hw/display/ati.c | 20 ++++++++++++++++++-- hw/display/ati_int.h | 4 ++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/hw/display/ati.c b/hw/display/ati.c index f7c0006a87..7af12777c8 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -30,6 +30,7 @@ #include "ui/console.h" #include "hw/display/i2c-ddc.h" #include "trace.h" +#include "qemu/units.h" =20 #define ATI_DEBUG_HW_CURSOR 0 =20 @@ -361,7 +362,8 @@ 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 / 2; + val =3D s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF ? + ATI_RAGE128_LINEAR_APER_SIZE / 2 : s->vga.vram_size / 2; break; case CONFIG_REG_1_BASE: val =3D pci_default_read_config(&s->dev, @@ -952,6 +954,7 @@ static void ati_vga_realize(PCIDevice *dev, Error **err= p) { ATIVGAState *s =3D ATI_VGA(dev); VGACommonState *vga =3D &s->vga; + uint64_t aper_size; =20 #ifndef CONFIG_PIXMAN if (s->use_pixman !=3D 0) { @@ -1011,7 +1014,20 @@ static void ati_vga_realize(PCIDevice *dev, Error **= errp) /* io space is alias to beginning of mmregs */ memory_region_init_alias(&s->io, OBJECT(s), "ati.io", &s->mm, 0, 0x100= ); =20 - pci_register_bar(dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &vga->vram); + /* + * Rage128: Framebuffer inhabits the bottom 32MB of the linear apertur= e. + * The top 32MB is reserved for AGP (not implemented). + * + * R100: Linear aperture layout differs from Rage 128. No + * AGP_APER_OFFSET register exists. + */ + aper_size =3D s->dev_id =3D=3D PCI_DEVICE_ID_ATI_RAGE128_PF ? + ATI_RAGE128_LINEAR_APER_SIZE : ATI_R100_LINEAR_APER_SIZE; + memory_region_init(&s->linear_aper, OBJECT(dev), "ati-linear-aperture0= ", + aper_size); + memory_region_add_subregion(&s->linear_aper, 0, &vga->vram); + + pci_register_bar(dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->linear_ape= r); pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->io); pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mm); =20 diff --git a/hw/display/ati_int.h b/hw/display/ati_int.h index f5a47b82b0..4f66d0df3f 100644 --- a/hw/display/ati_int.h +++ b/hw/display/ati_int.h @@ -29,6 +29,9 @@ /* Radeon RV100 (VE) */ #define PCI_DEVICE_ID_ATI_RADEON_QY 0x5159 =20 +#define ATI_RAGE128_LINEAR_APER_SIZE (64 * MiB) +#define ATI_R100_LINEAR_APER_SIZE (128 * MiB) + #define TYPE_ATI_VGA "ati-vga" OBJECT_DECLARE_SIMPLE_TYPE(ATIVGAState, ATI_VGA) =20 @@ -97,6 +100,7 @@ struct ATIVGAState { QEMUCursor *cursor; QEMUTimer vblank_timer; bitbang_i2c_interface bbi2c; + MemoryRegion linear_aper; MemoryRegion io; MemoryRegion mm; ATIVGARegs regs; --=20 2.51.0