Re: uvm_fault on Framework 12th Gen Intel

2022-08-02 Thread Anton Lindqvist
On Tue, Aug 02, 2022 at 10:35:18PM +0100, Laurence Tratt wrote:
> On Tue, Aug 02, 2022 at 07:00:52PM +, Miod Vallat wrote:
> 
> Hello Miod,
> 
> > Do the uvm_fault errors disappear if you `boot -c' and `disable ucc'?
> 
> `disable ucc` has no effect (it doesn't attach normally, so I guess that's
> not surprising?) -- I still get a kernel panic.

ucc does attach according to your dmesg. However, while ucc attaches it
sets it's own layout to `KB_US | KB_NOENCODING', meaning that
wskbd_load_keymap() requests are ignored since only one map is provided.



Re: uvm_fault on Framework 12th Gen Intel

2022-08-02 Thread Laurence Tratt
On Tue, Aug 02, 2022 at 07:00:52PM +, Miod Vallat wrote:

Hello Miod,

> Do the uvm_fault errors disappear if you `boot -c' and `disable ucc'?

`disable ucc` has no effect (it doesn't attach normally, so I guess that's
not surprising?) -- I still get a kernel panic.

> Or if you `disable pckbd'?

`disable pckbd` causes lines in dmesg like:

  pms1: disable error
  ...
  pckbc: command timeout
  pms1: disable error

and so on. The keyboard is non-operational at that point and, since I
(temporarily at least) don't have another machine, I don't have any way of
executing wsconsctl to see if it panics. I can try tomorrow if it would be
helpful?

The patch you provided works (thanks!):

  $ doas wsconsctl keyboard.encoding
  keyboard.encoding=unknown_0
  $ doas wsconsctl keyboard.encoding=uk
  wsconsctl: WSKBDIO_SETENCODING: Bad address
  $ doas wsconsctl keyboard.encoding=gb
  wsconsctl: gb: not a valid encoding

I realise as I type the above that I've never had a need to configure a
keyboard encoding before. I guess the "unknown_0" is unexpected? It may also
be significant that "uk" (which I *guess* is the keyboard's encoding) borks
in a different way than "gb"?


Laurie



Audio output blocked

2022-08-02 Thread dettus
>Synopsis:  azalia: Audio output blocked
>Category:  Audio
>Environment:
System  : OpenBSD 7.1
Details : OpenBSD 7.1 (GENERIC.MP) #465: Mon Apr 11 18:03:57 MDT 
2022
 
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP

Architecture: OpenBSD.amd64
Machine : amd64
>Description:
Hello. So, I encountered a problem with the audio output. My current
workaround was to treat myself to a small USB Audio device. However,
with the installed hardware, the audio output froze every once in
a while.
Unfortunately, I was not able to pinpoint the exact moment this happens,
however it mostly happend when I wanted to watch youtube with firefox.
And once it happend, when I was doing some experiments with the 
libout123 library. So my apologizes for the How-To-Repeat being rather
short

More details about my machine can be found here:
https://dmesgd.nycbug.org/index.cgi?do=view=6627
https://bsd-hardware.info/?probe=77acc9f5cf

Hopefully it helps. As I said: With the USB Audio device it works, 
which is a perfectly fine solution for me.

Thomas

>How-To-Repeat:
Using firefox, watching youtube videos. At some point, the audio 
output simply stopped. Running mplayer stopped at 0.00. Logging out/
logging back in did not work. Running anything as root did not work.
running cat /dev/urandom >/dev/audio0 produced noise, but looping
noise. (The same noise over and over again, as if it was reading from
the same buffer.)

>Fix:
JUST GUESSING HERE: Maybe making sure that the correct amount of
bytes is being forwarded to the audio device? (Unaligned writes?)



dmesg:
OpenBSD 7.1 (GENERIC.MP) #465: Mon Apr 11 18:03:57 MDT 2022
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 137294327808 (130934MB)
avail mem = 133116096512 (126949MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.3 @ 0xcb9f (77 entries)
bios0: vendor American Megatrends Inc. version "2803" date 04/27/2022
bios0: ASUS TUF GAMING B550-PLUS
acpi0 at bios0: ACPI 6.0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP SSDT SSDT SSDT FIDT FPDT MCFG HPET IVRS BGRT WPBT TPM2 
PCCT SSDT CRAT CDIT SSDT SSDT WSMT APIC SSDT SSDT
acpi0: wakeup devices GP12(S4) GP13(S4) XHC0(S4) GP30(S4) GP31(S4) X161(S4) 
X162(S4) PTXH(S4) X1_1(S4) X1_2(S4) X1_3(S4) WIFI(S4) RLAN(S4) X162(S4) M2_2(S4)
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimcfg0 at acpi0
acpimcfg0: addr 0xf000, bus 0-127
acpihpet0 at acpi0: 14318180 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Ryzen 9 5950X 16-Core Processor, 3394.07 MHz, 19-21-02
cpu0: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TCE,TOPEXT,CPCTR,DBKP,PCTRL3,MWAITX,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,PQM,RDSEED,ADX,SMAP,CLFLUSHOPT,CLWB,SHA,UMIP,PKU,IBPB,IBRS,STIBP,SSBD,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu0: 32KB 64b/line 8-way I-cache, 32KB 64b/line 8-way D-cache, 512KB 64b/line 
8-way L2 cache
cpu0: ITLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu0: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, C-substates=1.1, IBE
cpu1 at mainbus0: apid 2 (application processor)
cpu1: AMD Ryzen 9 5950X 16-Core Processor, 3393.61 MHz, 19-21-02
cpu1: 
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,FMA3,CX16,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,RDRAND,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TCE,TOPEXT,CPCTR,DBKP,PCTRL3,MWAITX,ITSC,FSGSBASE,BMI1,AVX2,SMEP,BMI2,ERMS,INVPCID,PQM,RDSEED,ADX,SMAP,CLFLUSHOPT,CLWB,SHA,UMIP,PKU,IBPB,IBRS,STIBP,SSBD,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu1: 32KB 64b/line 8-way I-cache, 32KB 64b/line 8-way D-cache, 512KB 64b/line 
8-way L2 cache
cpu1: ITLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu1: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 4 (application processor)
cpu2: AMD Ryzen 9 5950X 16-Core Processor, 3393.61 MHz, 19-21-02
cpu2: 

Re: uvm_fault on Framework 12th Gen Intel

2022-08-02 Thread Laurence Tratt
On Tue, Aug 02, 2022 at 08:56:09PM +1000, Jonathan Gray wrote:

Hello Jonathan,

>> I'm also starting to understand a bit more about some of the random panics:
>> they seem to happen very soon after X starts. Sometimes the mouse appears as
>> a two inch square of weird colours (!) -- things only last for a few seconds
>> after that. Only once have I got a visible panic out of this which said
>> solely:
>> 
>>   uvm_fault(0x822f0400, 0xfff80001660014, 0, 1) -> e
>>   drm: Global state not read locked
>>   drm: Global state not read locked
>> 
>> That particular panic was on my custom compiled kernel, not the most recent
>> snapshot.
> I don't see panics on a thinkpad with the same i7-1260P cpu
> 
> Does this change help?
> 
> drm/i915/adlp: Fix register corruption after DDI clock enabling
> 
> From Imre Deak
> 59207e63801fbcd39ca68df6e2ba5ae90f76c0c3 in mainline linux
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=59207e63801fbcd39ca68df6e2ba5ae90f76c0c3

A kernel with this patch has now survived 10 reboots (previously I was
getting a panic perhaps 1 time in 3), so I think it's quite likely that the
effect is real. Thanks!


Laurie



Re: uvm_fault on Framework 12th Gen Intel

2022-08-02 Thread Miod Vallat
The following diff ought to fix the problem, although there is no reason
it should have occurred in the first place.

Do the uvm_fault errors disappear if you `boot -c' and `disable ucc'? Or
if you `disable pckbd'?

Index: wskbdutil.c
===
RCS file: /OpenBSD/src/sys/dev/wscons/wskbdutil.c,v
retrieving revision 1.19
diff -u -p -r1.19 wskbdutil.c
--- wskbdutil.c 30 Dec 2021 06:55:11 -  1.19
+++ wskbdutil.c 2 Aug 2022 19:00:40 -
@@ -405,6 +405,8 @@ wskbd_load_keymap(const struct wskbd_map
for (cur = layout & ~KB_HANDLEDBYWSKBD, stack_ptr = 0;
 cur != 0; stack_ptr++) {
mp = mapdata->keydesc;
+   if (mp == NULL)
+   return(EFAULT); /* XXX */
while (mp->map_size > 0) {
if (cur == 0 || mp->name == cur) {
break;



Re: uvm_fault on Framework 12th Gen Intel

2022-08-02 Thread Jonathan Gray
On Tue, Aug 02, 2022 at 10:44:00AM +0100, Laurence Tratt wrote:
> I'm also starting to understand a bit more about some of the random panics:
> they seem to happen very soon after X starts. Sometimes the mouse appears as
> a two inch square of weird colours (!) -- things only last for a few seconds
> after that. Only once have I got a visible panic out of this which said
> solely:
> 
>   uvm_fault(0x822f0400, 0xfff80001660014, 0, 1) -> e
>   drm: Global state not read locked
>   drm: Global state not read locked
> 
> That particular panic was on my custom compiled kernel, not the most recent
> snapshot.

I don't see panics on a thinkpad with the same i7-1260P cpu

Does this change help?

drm/i915/adlp: Fix register corruption after DDI clock enabling

>From Imre Deak
59207e63801fbcd39ca68df6e2ba5ae90f76c0c3 in mainline linux

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=59207e63801fbcd39ca68df6e2ba5ae90f76c0c3

I also wonder if it is somehow possible the "XXX on T14 Gen 3 resume"
in sys/dev/pci/drm/i915/display/intel_bios.c intel_bios_is_port_edp()
may be involved, but that is a stretch.

Index: sys/dev/pci/drm/i915/i915_reg.h
===
RCS file: /cvs/src/sys/dev/pci/drm/i915/i915_reg.h,v
retrieving revision 1.29
diff -u -p -r1.29 i915_reg.h
--- sys/dev/pci/drm/i915/i915_reg.h 21 Jun 2022 09:46:33 -  1.29
+++ sys/dev/pci/drm/i915/i915_reg.h 2 Aug 2022 10:16:01 -
@@ -8308,6 +8308,7 @@ enum {
 #define   ICL_DELAY_PMRSP  REG_BIT(22)
 #define   DISABLE_FLR_SRC  REG_BIT(15)
 #define   MASK_WAKEMEM REG_BIT(13)
+#define   DDI_CLOCK_REG_ACCESS REG_BIT(7)
 
 #define GEN11_CHICKEN_DCPR_2   _MMIO(0x46434)
 #define   DCPR_MASK_MAXLATENCY_MEMUP_CLR   REG_BIT(27)
Index: sys/dev/pci/drm/i915/intel_pm.c
===
RCS file: /cvs/src/sys/dev/pci/drm/i915/intel_pm.c,v
retrieving revision 1.63
diff -u -p -r1.63 intel_pm.c
--- sys/dev/pci/drm/i915/intel_pm.c 6 Jun 2022 07:10:15 -   1.63
+++ sys/dev/pci/drm/i915/intel_pm.c 2 Aug 2022 10:15:13 -
@@ -7606,6 +7606,9 @@ static void adlp_init_clock_gating(struc
 
/* Wa_22011091694:adlp */
intel_de_rmw(dev_priv, GEN9_CLKGATE_DIS_5, 0, DPCE_GATING_DIS);
+
+   /* Bspec/49189 Initialize Sequence */
+   intel_de_rmw(dev_priv, GEN8_CHICKEN_DCPR_1, DDI_CLOCK_REG_ACCESS, 0);
 }
 
 static void dg1_init_clock_gating(struct drm_i915_private *dev_priv)



Re: uvm_fault on Framework 12th Gen Intel

2022-08-02 Thread Laurence Tratt
On Tue, Aug 02, 2022 at 11:54:48AM +1000, Jonathan Gray wrote:

Hello Jonathan,

>> I've just got my sticky mits on a Framework 12th Gen Intel laptop. It
>> somewhat works, but regularly hits kernel panics and other oddities on
>> -current. I haven't worked out why yet, but uvm_faults seem to be frequent.
>> For example setting the keyboard encoding causes a uvm_fault.
>> 
>>   $ doas wsconsctl keyboard.encoding=uk
>>   uvm_fault(0xfd87b4e6a780, 0x8, 0, 1) -> e
>> 
>> Screenshot of this particular panic at https://postimg.cc/nM5rLGY6
> wskbd_load_keymap+0x33: movl 0x8(%rax),%ecx
> wskbd_displayioctl_sc+0x76c
> wskbd_do_ioctl_sc+0xbb
> wskbd_ioctl+0x4a
> VOP_IOCTL+0x5c
> vn_ioctl+0x75
> sys_ioctl+0x2c4
> 
>0x81017abe <+46>:je 0x81017b3e 
> 
>0x81017ac0 <+48>:mov(%rdi),%rax
>0x81017ac3 <+51>:mov0x8(%rax),%ecx
>0x81017ac6 <+54>:xor%r13d,%r13d
>0x81017ac9 <+57>:mov$0x16,%r15d
>0x81017acf <+63>:test   %ecx,%ecx
>0x81017ad1 <+65>:jle0x81017bba 
> 
> 
> info line *0x81017ac3
> Line 405 of "/sys/dev/wscons/wskbdutil.c"
>starts at address 0x81017abe 
>and ends at 0x81017ad1 .
> 
>395  int
>396  wskbd_load_keymap(const struct wskbd_mapdata *mapdata, kbd_t layout,
>397  struct wscons_keymap **map, int *maplen)
>398  {
>399  int i, s, kc, stack_ptr;
>400  const keysym_t *kp;
>401  const struct wscons_keydesc *mp, *stack[10];
>402  kbd_t cur;
>403  keysym_t ksg;
>404  
>405  for (cur = layout & ~KB_HANDLEDBYWSKBD, stack_ptr = 0;
>406   cur != 0; stack_ptr++) {
>407  mp = mapdata->keydesc;
>408  while (mp->map_size > 0) {
>409  if (cur == 0 || mp->name == cur) {
>410  break;
>411  }
>412  mp++;
>413  }
>414  
>415  if (stack_ptr == nitems(stack))
>416  panic("wskbd_load_keymap: %d: recursion too 
> deep",
>417mapdata->layout);
>418  if (mp->map_size <= 0)
>419  return(EINVAL);
>420  
>421  stack[stack_ptr] = mp;
>422  cur = mp->base;
>423  }

Thanks for expanding this (and duly noted!).

I also noted your commit to add some devices. The salient part of the dmesg
diff (ignoring all the CPU frequencies changing) is:

  --- dmesg1Tue Aug  2 10:26:22 2022
  +++ dmesg2Tue Aug  2 10:34:02 2022
  @@ -1,7 +1,7 @@
  -OpenBSD 7.2-beta (GENERIC.MP) #658: Mon Aug  1 10:06:39 MDT 2022
  -dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
  +OpenBSD 7.2-beta (GENERIC.MP) #0: Tue Aug  2 10:16:12 BST 2022
  +ltr...@phase.tratt.net:/usr/src/sys/arch/amd64/compile/GENERIC.MP
   real mem = 34006142976 (32430MB)
  -avail mem = 32958144512 (31431MB)
  +avail mem = 32958132224 (31431MB)
   random: good seed from bootblocks
   mpath0 at root
   scsibus0 at mpath0: 256 targets
  @@ -251,18 +251,18 @@
   "Intel Core 12G DTT" rev 0x02 at pci0 dev 4 function 0 not configured
   ppb0 at pci0 dev 6 function 0 "Intel Core 12G PCIE" rev 0x02: msi
   pci1 at ppb0 bus 1
  -nvme0 at pci1 dev 0 function 0 vendor "SanDisk", unknown product 0x5011 rev 
0x01: msix, NVMe 1.4
  +nvme0 at pci1 dev 0 function 0 "SanDisk SN850" rev 0x01: msix, NVMe 1.4
   nvme0: WDS100T1X0E-00AFY0, firmware 614900WD, serial XYZ
   scsibus1 at nvme0: 2 targets, initiator 0
   sd0 at scsibus1 targ 1 lun 0: 
   sd0: 953869MB, 512 bytes/sector, 1953525168 sectors
   ppb1 at pci0 dev 7 function 0 "Intel Core 12G PCIE" rev 0x02: msi
   pci2 at ppb1 bus 2
  -ppb2 at pci0 dev 7 function 1 vendor "Intel", unknown product 0x463f rev 
0x02: msi
  +ppb2 at pci0 dev 7 function 1 "Intel Core 12G PCIE" rev 0x02: msi
   pci3 at ppb2 bus 43
   ppb3 at pci0 dev 7 function 2 "Intel Core 12G PCIE" rev 0x02: msi
   pci4 at ppb3 bus 84
  -ppb4 at pci0 dev 7 function 3 vendor "Intel", unknown product 0x461f rev 
0x02: msi
  +ppb4 at pci0 dev 7 function 3 "Intel Core 12G PCIE" rev 0x02: msi
   pci5 at ppb4 bus 125
   "Intel Core 12G GNA" rev 0x02 at pci0 dev 8 function 0 not configured
   "Intel Core 12G CL" rev 0x01 at pci0 dev 10 function 0 not configured
  @@ -288,7 +288,7 @@
   iic2 at dwiic2
   ihidev1 at iic2 addr 0x2c gpio 3, vendor 0x93a product 0x274, PIXA3854
   ihidev1: 67 report ids
  -imt0 at ihidev1: clickpad, 5 contacts
  +imt0 at ihidev1: touchpad, 5 contacts
   wsmouse0 at imt0 mux 0
   ims0 at ihidev1 reportid 2: 2 buttons
   wsmouse1 at ims0 mux 0
  @@ -300,8 +300,9 @@
   hid at ihidev1 reportid 66 not configured
   hid at ihidev1 reportid 67 not configured
   "Intel 600 Series HECI" rev