From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D16CFC43460 for ; Tue, 27 Apr 2021 06:58:42 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5B59C61076 for ; Tue, 27 Apr 2021 06:58:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B59C61076 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=virtualization-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 19DCC6068B; Tue, 27 Apr 2021 06:58:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lqdG1j82eCa1; Tue, 27 Apr 2021 06:58:41 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTP id 6234D6065A; Tue, 27 Apr 2021 06:58:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 30824C000E; Tue, 27 Apr 2021 06:58:40 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 02D8AC000B for ; Tue, 27 Apr 2021 06:58:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id E54394043F for ; Tue, 27 Apr 2021 06:58:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ltn-YNjOyjyM for ; Tue, 27 Apr 2021 06:58:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by smtp2.osuosl.org (Postfix) with ESMTPS id 7AB1F4043A for ; Tue, 27 Apr 2021 06:58:37 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D3E9EAF9C; Tue, 27 Apr 2021 06:58:35 +0000 (UTC) Subject: Re: [PATCH v2] drm/bochs: Add screen blanking support To: Takashi Iwai References: <20210421080859.14869-1-tiwai@suse.de> From: Thomas Zimmermann Message-ID: Date: Tue, 27 Apr 2021 08:58:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============0594632573358065740==" Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============0594632573358065740== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="5VfHzjXGKY4Bp7DBCovbXHtLxQw2QFajo" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --5VfHzjXGKY4Bp7DBCovbXHtLxQw2QFajo Content-Type: multipart/mixed; boundary="NflIGcYDCC7PD56qc8Fs6aE2xzAEXhWUP"; protected-headers="v1" From: Thomas Zimmermann To: Takashi Iwai Cc: dri-devel@lists.freedesktop.org, Gerd Hoffmann , virtualization@lists.linux-foundation.org Message-ID: Subject: Re: [PATCH v2] drm/bochs: Add screen blanking support References: <20210421080859.14869-1-tiwai@suse.de> In-Reply-To: --NflIGcYDCC7PD56qc8Fs6aE2xzAEXhWUP Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi Am 27.04.21 um 08:18 schrieb Takashi Iwai: > On Mon, 26 Apr 2021 20:44:55 +0200, > Thomas Zimmermann wrote: >> >> Hi >> >> Am 21.04.21 um 10:08 schrieb Takashi Iwai: >>> On bochs DRM driver, the execution of "setterm --blank force" results= >>> in a frozen screen instead of a blank screen. It's due to the lack o= f >>> the screen blanking support in its code. >>> >>> Actually, the QEMU bochs vga side can switch to the blanking mode whe= n >>> the bit 0x20 is cleared on VGA_ATT_IW register (0x3c0), which updates= >>> ar_index in QEMU side. So, essentially, we'd just need to clear the >>> bit at pipe disable callback; that's what this patch does essentially= =2E >>> >>> However, a tricky part is that the access via VGA_ATT_IW is done in >>> "flip-flop"; the first write is for index and the second write is for= >>> the data like palette. Meanwhile, in the current bochs DRM driver, >>> the flip-flop wasn't considered, and it calls only the register updat= e >>> once with the value 0x20. >> >> I read up on the details of what the attribute registers do and what >> you're modifying is the PAS field in the attribute index register. It >> controls write access to the attribute fields. >> >> >> https://web.stanford.edu/class/cs140/projects/pintos/specs/freevga/vga= /attrreg.htm#3C0 >> >> It's located in the index register and cleared while >> attributes/palettes are updated. I guess that in this mode the stdvga >> disables the palette entirely (hence the screen turns dark). >> >> While it works, it feels wrong to do this. >> >> I to do blanking/unblanking with the SR field in SEQ0 >> >> >> https://web.stanford.edu/class/cs140/projects/pintos/specs/freevga/vga= /seqreg.htm#00 >> >> That's what drivers usually do AFAICT. I think the 'unblank' comment >> next to the existing code might be misleading. >=20 > Yeah, when you look at the existing vga16fb.c in kernel, we can find a > relatively complex blanking procedure. OTOH, what I changed is rather > based on the the actual behavior of bochs is more or less simplified. > QEMU hw/display/vga.c contains a code like: >=20 > static void vga_update_display(void *opaque) > { > VGACommonState *s =3D opaque; > DisplaySurface *surface =3D qemu_console_surface(s->con); > int full_update, graphic_mode; >=20 > qemu_flush_coalesced_mmio_buffer(); >=20 > if (surface_bits_per_pixel(surface) =3D=3D 0) { > /* nothing to do */ > } else { > full_update =3D 0; > if (!(s->ar_index & 0x20)) { > graphic_mode =3D GMODE_BLANK; > } else { > graphic_mode =3D s->gr[VGA_GFX_MISC] & VGA_GR06_GRAPHICS_M= ODE; > } > if (graphic_mode !=3D s->graphic_mode) { > s->graphic_mode =3D graphic_mode; > s->cursor_blink_time =3D qemu_clock_get_ms(QEMU_CLOCK_VIRT= UAL); > full_update =3D 1; > } > switch(graphic_mode) { > case GMODE_TEXT: > vga_draw_text(s, full_update); > break; > case GMODE_GRAPH: > vga_draw_graphic(s, full_update); > break; > case GMODE_BLANK: > default: > vga_draw_blank(s, full_update); > break; > } > } > } >=20 > So, it simply checks the ar_index () at each update and switches > from/to the blank mode depending on the bit 0x20. >=20 > I'm fine to change in any better way, of course, so feel free to > modify the patch. If no one objects, I'll merge it as-is. It's somewhat wrong wrt to VGA,=20 but apparently what qemu wants. Best regards Thomas >=20 >=20 > thanks, >=20 > Takashi >=20 >> >> Best regards >> Thomas >> >>> >>> The spec and the actual VGA implementation in QEMU suggests that the >>> flip flop flag is discarded by reading the CRTC index register >>> (VGA_IS1_RC, 0x3da). So, in this patch, we add the helper to read a >>> byte and the call to clear the flip flop flag before changing the >>> blank / unblank setup via VGA_ATT_IW register. >>> >>> v1->v2: >>> * discard ar_flip_flop by reading 0x3da, add bochs_vga_readb() >>> * include video/vga.h for VGA register definitions >>> * move the blank/unblank code to bochs_hw_blank() >>> >>> Signed-off-by: Takashi Iwai >>> --- >>> drivers/gpu/drm/bochs/bochs.h | 1 + >>> drivers/gpu/drm/bochs/bochs_hw.c | 25 ++++++++++++++++++++++++- >>> drivers/gpu/drm/bochs/bochs_kms.c | 8 ++++++++ >>> 3 files changed, 33 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bo= chs.h >>> index e5bd1d517a18..e9645c612aff 100644 >>> --- a/drivers/gpu/drm/bochs/bochs.h >>> +++ b/drivers/gpu/drm/bochs/bochs.h >>> @@ -78,6 +78,7 @@ struct bochs_device { >>> int bochs_hw_init(struct drm_device *dev); >>> void bochs_hw_fini(struct drm_device *dev); >>> +void bochs_hw_blank(struct bochs_device *bochs, bool blank); >>> void bochs_hw_setmode(struct bochs_device *bochs, >>> struct drm_display_mode *mode); >>> void bochs_hw_setformat(struct bochs_device *bochs, >>> diff --git a/drivers/gpu/drm/bochs/bochs_hw.c b/drivers/gpu/drm/bochs= /bochs_hw.c >>> index 2d7380a9890e..7d3426d8cc69 100644 >>> --- a/drivers/gpu/drm/bochs/bochs_hw.c >>> +++ b/drivers/gpu/drm/bochs/bochs_hw.c >>> @@ -7,6 +7,7 @@ >>> #include >>> #include >>> +#include