From nobody Wed Nov 27 02:21:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700920966137260.6883791475725; Sat, 25 Nov 2023 06:02:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6tEA-0004JC-Tu; Sat, 25 Nov 2023 09:01: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 1r6tE7-0004Ia-QE; Sat, 25 Nov 2023 09:01:43 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6tE6-00081y-2K; Sat, 25 Nov 2023 09:01:43 -0500 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id BACAB75A4C4; Sat, 25 Nov 2023 15:01:35 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id AF6A075A4C3; Sat, 25 Nov 2023 15:01:35 +0100 (CET) From: BALATON Zoltan Subject: [PATCH for-8.2] ide/via: Fix BAR4 value in legacy mode MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-block@nongnu.org Cc: John Snow , Kevin Wolf , philmd@linaro.org, Mark Cave-Ayland Message-Id: <20231125140135.AF6A075A4C3@zero.eik.bme.hu> Date: Sat, 25 Nov 2023 15:01:35 +0100 (CET) X-Virus-Scanned: ClamAV using ClamSMTP 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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-ZM-MESSAGEID: 1700920970559100003 Content-Type: text/plain; charset="utf-8" Return default value in legacy mode for BAR4 when unset. This can't be set in reset method because BARs are cleared on reset so we return it instead when BARs are read in legacy mode. Signed-off-by: BALATON Zoltan --- This fixes UDMA on amigaone with AmigaOS and I'd like to include for 8.2 release. hw/ide/via.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/ide/via.c b/hw/ide/via.c index 2d3124ebd7..3f3c484253 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -163,14 +163,19 @@ static uint32_t via_ide_cfg_read(PCIDevice *pd, uint3= 2_t addr, int len) uint32_t val =3D pci_default_read_config(pd, addr, len); uint8_t mode =3D pd->config[PCI_CLASS_PROG]; =20 - if ((mode & 0xf) =3D=3D 0xa && ranges_overlap(addr, len, - PCI_BASE_ADDRESS_0, 16)) { - /* BARs always read back zero in legacy mode */ - for (int i =3D addr; i < addr + len; i++) { - if (i >=3D PCI_BASE_ADDRESS_0 && i < PCI_BASE_ADDRESS_0 + 16) { - val &=3D ~(0xffULL << ((i - addr) << 3)); + if ((mode & 0xf) =3D=3D 0xa) { + if (ranges_overlap(addr, len, PCI_BASE_ADDRESS_0, 16)) { + /* BARs 0-3 always read back zero in legacy mode */ + for (int i =3D addr; i < addr + len; i++) { + if (i >=3D PCI_BASE_ADDRESS_0 && i < PCI_BASE_ADDRESS_0 + = 16) { + val &=3D ~(0xffULL << ((i - addr) << 3)); + } } } + if (addr =3D=3D PCI_BASE_ADDRESS_4 && val =3D=3D PCI_BASE_ADDRESS_= SPACE_IO) { + /* BAR4 default value if unset */ + val =3D 0xcc00 | PCI_BASE_ADDRESS_SPACE_IO; + } } =20 return val; --=20 2.30.9