From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web10.5143.1662537284474823427 for ; Wed, 07 Sep 2022 00:54:45 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sw8L8M5k; spf=pass (domain: kernel.org, ip: 145.40.68.75, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 23528B81B8B for ; Wed, 7 Sep 2022 07:54:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1672C433D7 for ; Wed, 7 Sep 2022 07:54:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662537280; bh=ajp/0YEw6gAW9rA57DCHfwWhl6GVWg2OF20iS02OKWs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=sw8L8M5k2AP5tsqwDR5yzzCZggUS/HbcU0fVhE3EblXM/oqFy4khslf5rJSwxdesi KE2Keua2o23qKxQrdXtKUovVr111gH2WoN/S6UXYym+ajJ2Conks2fGEZ6DFyYc9To jflbHpJw/Ex+zJJXF94qiTbh2vSHUsdVXslDeR2bO6s+B8NZHKuAe+b2YI7PGo0Z/4 3trG7qi1knxcfoPaljOtlZYX/p5aXVgKeqklTe1eurklqh8cgV6BS5AAmdBH1A3m3M ZHqw3sKzEVixYfbJ0lxbkihLgW+C8D0xOdr40UjQ8Ukwar1oqQWJ6mahkSXMZdEp6i DVhFeeeORTGrQ== Received: by mail-lj1-f178.google.com with SMTP id p5so1948621ljc.13 for ; Wed, 07 Sep 2022 00:54:40 -0700 (PDT) X-Gm-Message-State: ACgBeo2O8NXqKUMJmGiGGTE0yVBgeOH1L7Yj6TdORWckrey56y3NY2c+ 9oiTPWMtRUQYjTf2Y4TzXjyMkdak+nQ5H4w8cTc= X-Google-Smtp-Source: AA6agR6m6Vtf4p8qixxG4zPNPKhf39XggDyf7KDVuV/pJYYzeyNP468SIvvx+bO4sRJhhJ+KqpBoxvsbN4MsSvHJgf8= X-Received: by 2002:a2e:3006:0:b0:266:6677:5125 with SMTP id w6-20020a2e3006000000b0026666775125mr661281ljw.352.1662537278906; Wed, 07 Sep 2022 00:54:38 -0700 (PDT) MIME-Version: 1.0 References: <20220907051658.2884354-1-kraxel@redhat.com> In-Reply-To: <20220907051658.2884354-1-kraxel@redhat.com> From: "Ard Biesheuvel" Date: Wed, 7 Sep 2022 09:54:27 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/1] OvmfPkg/QemuVideoDxe: fix bochs mode init To: Gerd Hoffmann , Leif Lindholm Cc: devel@edk2.groups.io, Jordan Justen , Pawel Polawski , Jiewen Yao , Oliver Steffen Content-Type: text/plain; charset="UTF-8" On Wed, 7 Sept 2022 at 07:17, Gerd Hoffmann wrote: > > Add VgaInb() helper function to read vga registers. With that in place > fix the unblanking. We need to put the ATT_ADDRESS_REGISTER flip flop > into a known state, which is done by reading the > INPUT_STATUS_1_REGISTER. Reading the INPUT_STATUS_1_REGISTER only works > when the device is in color mode, so make sure that bit (0x01) is set in > MISC_OUTPUT_REGISTER. > > Currently the mode setting works more by luck because > ATT_ADDRESS_REGISTER flip flip happens to be in the state we need. > flip flip > Signed-off-by: Gerd Hoffmann Unfortunately, it appears your patch is terminally flawed, and needs the following change applied to fix it: Files with formatting errors: Formatting errors in QemuVideoDxe\Driver.c --- D:\a\1\s\OvmfPkg\QemuVideoDxe\Driver.c +++ D:\a\1\s\OvmfPkg\QemuVideoDxe\Driver.c.uncrustify_plugin @@ -991,7 +991,7 @@ ) { EFI_STATUS Status; - UINT8 Data = 0; + UINT8 Data = 0; if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO) { Status = Private->PciIo->Mem.Read ( @@ -1006,6 +1006,7 @@ } else { Data = inb (Private, Reg); } + return Data; } Interestingly, uncrustify happily accepts the = 0 initializer for Data, even though the coding style does not permit this, so you might hit a EccCheck error as well. > --- > OvmfPkg/QemuVideoDxe/Driver.c | 31 ++++++++++++++++++++++++++++++- > 1 file changed, 30 insertions(+), 1 deletion(-) > > diff --git a/OvmfPkg/QemuVideoDxe/Driver.c b/OvmfPkg/QemuVideoDxe/Driver.c > index b91909a14e59..a15e54d38fd2 100644 > --- a/OvmfPkg/QemuVideoDxe/Driver.c > +++ b/OvmfPkg/QemuVideoDxe/Driver.c > @@ -984,6 +984,31 @@ VgaOutb ( > } > } > > +UINT8 > +VgaInb ( > + QEMU_VIDEO_PRIVATE_DATA *Private, > + UINTN Reg > + ) > +{ > + EFI_STATUS Status; > + UINT8 Data = 0; > + > + if (Private->Variant == QEMU_VIDEO_BOCHS_MMIO) { > + Status = Private->PciIo->Mem.Read ( > + Private->PciIo, > + EfiPciIoWidthUint8, > + PCI_BAR_IDX2, > + 0x400 - 0x3c0 + Reg, > + 1, > + &Data > + ); > + ASSERT_EFI_ERROR (Status); > + } else { > + Data = inb (Private, Reg); > + } > + return Data; > +} > + > VOID > InitializeBochsGraphicsMode ( > QEMU_VIDEO_PRIVATE_DATA *Private, > @@ -998,7 +1023,11 @@ InitializeBochsGraphicsMode ( > ModeData->ColorDepth > )); > > - /* unblank */ > + /* set color mode */ > + VgaOutb (Private, MISC_OUTPUT_REGISTER, 0x01); > + > + /* reset flip flop + unblank */ > + VgaInb (Private, INPUT_STATUS_1_REGISTER); > VgaOutb (Private, ATT_ADDRESS_REGISTER, 0x20); > > BochsWrite (Private, VBE_DISPI_INDEX_ENABLE, 0); > -- > 2.37.3 >