NetBSD Problem Report #56562

From mlelstv@tazz.1st.de  Mon Dec 20 19:04:03 2021
Return-Path: <mlelstv@tazz.1st.de>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 166E61A9239
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 20 Dec 2021 19:04:03 +0000 (UTC)
Message-Id: <20211220190308.54DB8CCAE5@tazz.1st.de>
Date: Mon, 20 Dec 2021 20:03:08 +0100 (CET)
From: mlelstv@serpens.de
Reply-To: mlelstv@serpens.de
To: gnats-bugs@NetBSD.org
Subject: drm update breaks Sandy Bridge display
X-Send-Pr-Version: 3.95

>Number:         56562
>Notify-List:    david@gutteridge.ca
>Category:       kern
>Synopsis:       drm update breaks Sandy Bridge display
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 20 19:05:00 +0000 2021
>Last-Modified:  Wed Sep 14 22:35:01 +0000 2022
>Originator:     Michael van Elst
>Release:        NetBSD 9.99.92
>Organization:

>Environment:


System: NetBSD tazz 9.99.92 NetBSD 9.99.92 (GENERIC) #7: Thu Dec 16 19:44:34 UTC 2021 mlelstv@slowpoke:/scratch2/obj.amd64/scratch/netbsd-current/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:

On a Thinkpad T420:

i915drmkms0 at pci0 dev 2 function 0: Intel Sandy Bridge (mobile) GT2+ Integrated Graphics Device (rev. 0x09)

the updated kernel seems to work fine. But after a reboot, the display gets corrupted immediately, starting
with the BIOS messages. The resolution doesn't match the display, colors are wrong and even change and there
are display artefacts that show that the laptop TFT isn't driven correctly.

Example:

http://ftp.netbsd.org/pub/NetBSD/misc/mlelstv/newdrm.jpg

The bar in the lower left is a display artefact that starts dark and "bleeds" to white.

The issue persists if you reboot with a pre-update kernel.

I found two possibilites to recover:

1. interrupt boot process and change the "default boot display" in BIOS. This seems to reset the hardware.
2. Power off and on.

With the next reboot the issue comes back.

>How-To-Repeat:
Boot updated kernel on a Thinkpad T420.

>Fix:


>Release-Note:

>Audit-Trail:
From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/56562: drm update breaks Sandy Bridge display
Date: Tue, 21 Dec 2021 12:09:12 -0000 (UTC)

 mlelstv@serpens.de writes:

 >On a Thinkpad T420:
 >i915drmkms0 at pci0 dev 2 function 0: Intel Sandy Bridge (mobile) GT2+ Integrated Graphics Device (rev. 0x09)
 >the updated kernel seems to work fine. But after a reboot, the display gets corrupted immediately,

 The hardware gets misconfigured somewhere around that message.

 kern info: [drm] Initialized i915 1.6.0 20200114 for i915drmkms0 on minor 0

 Entering DDB before that and rebooting (reboot 4) still keeps a sane display.
 Entering DDB after that and rebooting already gets the corrupted display
 after reboot.

 Since that event happens after the kernel asks for a root device, I booted
 with 'boot -a' and entered 'reboot'.

 This was sufficient to clear the display corruption and the next boot
 went normally.

 The same effect has booting the pre-update kernel (with still corrupted
 display) and booting again.

 So something seems to put the hardware into a sane state, but this only
 gets effective after next reboot, and initializing drm with the post-update
 kernel corrupts the state again but this also becomes effective after
 a reboot.

From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/56562: drm update breaks Sandy Bridge display
Date: Tue, 21 Dec 2021 12:25:17 -0000 (UTC)

 mlelstv@serpens.de (Michael van Elst) writes:

 > The same effect has booting the pre-update kernel (with still corrupted
 > display) and booting again.

 Even going before that rebooting (ctrl-alt-del) while in the bootloader
 menu, is sufficient.

From: Taylor R Campbell <riastradh@NetBSD.org>
To: gnats-bugs@NetBSD.org
Cc: mlelstv@serpens.de
Subject: Re: kern/56562: drm update breaks Sandy Bridge display
Date: Fri, 24 Dec 2021 13:28:20 +0000

 This is a multi-part message in MIME format.
 --=_su1OON3HGWIM8fZuEZsawKeY4iHDSE1Z

 Can you try the attached patch and see if it makes a difference?

 --=_su1OON3HGWIM8fZuEZsawKeY4iHDSE1Z
 Content-Type: text/plain; charset="ISO-8859-1"; name="opregion"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment; filename="opregion.patch"

 From e484fe666999730543f490ce6084486f7d7ce524 Mon Sep 17 00:00:00 2001
 From: Taylor R Campbell <riastradh@NetBSD.org>
 Date: Fri, 24 Dec 2021 11:12:43 +0000
 Subject: [PATCH] i915: Use AcpiOsMapMemory, not bus_space_map, for opregion.

 Needed because this appears in firmware-type memory mappings, which
 are excluded from bus_space_map.

 XXX pullup-9 (via manual patch since the code has changed a bit)
 ---
  .../dist/drm/i915/display/intel_opregion.c    | 34 +++++--------------
  .../dist/drm/i915/display/intel_opregion.h    | 14 --------
  2 files changed, 8 insertions(+), 40 deletions(-)

 diff --git a/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.c b=
 /sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.c
 index 4b0412828d49..b2f986bd74c0 100644
 --- a/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.c
 +++ b/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.c
 @@ -952,15 +952,7 @@ int intel_opregion_setup(struct drm_i915_private *dev_=
 priv)
  	INIT_WORK(&opregion->asle_work, asle_work);
 =20
  #ifdef __NetBSD__
 -	opregion->bst =3D pdev->pd_pa.pa_memt;
 -	err =3D -bus_space_map(opregion->bst, asls, OPREGION_SIZE,
 -	    BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_CACHEABLE,
 -	    &opregion->asls_bsh);
 -	if (err) {
 -		DRM_DEBUG_DRIVER("Failed to map opregion: %d\n", err);
 -		return err;
 -	}
 -	base =3D bus_space_vaddr(opregion->bst, opregion->asls_bsh);
 +	base =3D AcpiOsMapMemory(asls, OPREGION_SIZE);
  #else
  	base =3D memremap(asls, OPREGION_SIZE, MEMREMAP_WB);
  #endif
 @@ -1035,14 +1027,7 @@ int intel_opregion_setup(struct drm_i915_private *de=
 v_priv)
  		}
 =20
  #ifdef __NetBSD__
 -		if (bus_space_map(opregion->bst, rvda,
 -			opregion->asle->rvds,
 -			BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_CACHEABLE,
 -			&opregion->rvda_bsh))
 -			opregion->rvda =3D NULL;
 -		else
 -			opregion->rvda =3D bus_space_vaddr(opregion->bst,
 -			    opregion->rvda_bsh);
 +		opregion->rvda =3D AcpiOsMapMemory(rvda, opregion->asle->rvds);
  #else
  		opregion->rvda =3D memremap(rvda, opregion->asle->rvds,
  					  MEMREMAP_WB);
 @@ -1058,11 +1043,8 @@ int intel_opregion_setup(struct drm_i915_private *de=
 v_priv)
  		} else {
  			DRM_DEBUG_KMS("Invalid VBT in ACPI OpRegion (RVDA)\n");
  #ifdef __NetBSD__
 -			if (opregion->rvda) {
 -				bus_space_unmap(opregion->bst,
 -				    opregion->rvda_bsh,
 -				    opregion->asle->rvds);
 -			}
 +			AcpiOsUnmapMemory(opregion->rvda,
 +			    opregion->asle->rvds);
  #else
  			memunmap(opregion->rvda);
  #endif
 @@ -1094,7 +1076,7 @@ out:
 =20
  err_out:
  #ifdef __NetBSD__
 -	bus_space_unmap(opregion->bst, opregion->asls_bsh, OPREGION_SIZE);
 +	AcpiOsUnmapMemory(base, OPREGION_SIZE);
  #else
  	memunmap(base);
  #endif
 @@ -1251,14 +1233,14 @@ void intel_opregion_unregister(struct drm_i915_priv=
 ate *i915)
 =20
  	/* just clear all opregion memory pointers now */
  #ifdef __NetBSD__
 -	bus_space_unmap(opregion->bst, opregion->asls_bsh, OPREGION_SIZE);
 +	size_t rvds =3D opregion->asle->rvds;
 +	AcpiOsUnmapMemory(opregion->header, OPREGION_SIZE);
  #else
  	memunmap(opregion->header);
  #endif
  	if (opregion->rvda) {
  #ifdef __NetBSD__
 -		bus_space_unmap(opregion->bst, opregion->rvda_bsh,
 -		    opregion->asle->rvds);
 +		AcpiOsUnmapMemory(opregion->rvda, rvds);
  #else
  		memunmap(opregion->rvda);
  #endif
 diff --git a/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h b=
 /sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h
 index a04f1c9d9f74..879c4135f670 100644
 --- a/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h
 +++ b/sys/external/bsd/drm2/dist/drm/i915/display/intel_opregion.h
 @@ -38,17 +38,7 @@ struct opregion_acpi;
  struct opregion_swsci;
  struct opregion_asle;
 =20
 -#ifdef __NetBSD__		/* XXX acpi iomem */
 -#  include <linux/acpi_io.h>
 -#  define	__iomem		__acpi_iomem
 -#endif
 -
  struct intel_opregion {
 -#ifdef __NetBSD__
 -	bus_space_tag_t bst;
 -	bus_space_handle_t asls_bsh;
 -	bus_space_handle_t rvda_bsh;
 -#endif
  	struct opregion_header *header;
  	struct opregion_acpi *acpi;
  	struct opregion_swsci *swsci;
 @@ -66,10 +56,6 @@ struct intel_opregion {
 =20
  #define OPREGION_SIZE            (8 * 1024)
 =20
 -#ifdef __NetBSD__		/* XXX acpi iomem */
 -#  undef	__iomem
 -#endif
 -
  #ifdef CONFIG_ACPI
 =20
  int intel_opregion_setup(struct drm_i915_private *dev_priv);

 --=_su1OON3HGWIM8fZuEZsawKeY4iHDSE1Z--

From: mlelstv@serpens.de (Michael van Elst)
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/56562: drm update breaks Sandy Bridge display
Date: Fri, 24 Dec 2021 18:07:00 -0000 (UTC)

 riastradh@NetBSD.org (Taylor R Campbell) writes:

 > Can you try the attached patch and see if it makes a difference?

 It can now find the VBT, but otherwise there is no change.

From: "David H. Gutteridge" <david@gutteridge.ca>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/56562: drm update breaks Sandy Bridge display
Date: Fri, 18 Feb 2022 16:07:09 -0500

 This issue is still reproducible for me on my T420 with sources as of
 an hour ago (Feb. 18, 2000hrs UTC).

 Dave

From: "David H. Gutteridge" <david@gutteridge.ca>
To: Gnats Bugs <gnats-bugs@netbsd.org>
Cc: 
Subject: Re: kern/56562: drm update breaks Sandy Bridge display
Date: Wed, 14 Sep 2022 18:33:18 -0400

 This seems fixed for me on my T420 with sources as of the evening of
 September 13th.

 Dave

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2022 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.