Re: first console unusable due to usb mouse shenanigans

2017-09-17 Thread Bryan Steele
On Sun, Sep 17, 2017 at 08:33:03AM -0400, Bryan Steele wrote:
> I think this is a bug in ohci(4), I reported it last year.. the
> splasserts were fixed briefly for me by mpi@

Whoops, meant last May, not last year. :-)



Re: first console unusable due to usb mouse shenanigans

2017-09-17 Thread Martin Pieuchot
On 17/09/17(Sun) 08:33, Bryan Steele wrote:
> On Sun, Sep 17, 2017 at 12:14:06PM +0200, Marc Espie wrote:
> > This is on current, I get this on repeat very regularly.
> > 
> > wsmouse0 detached
> > ums0 detached
> > uhidev0 detached
> > splassert: usb_transfer_complete: want 5 have 6
> > splassert: usb_transfer_complete: want 5 have 6
> > splassert: usb_transfer_complete: want 5 have 6

Could you post a trace?  You'll need a kernel with the diff below.

Index: kern/subr_prf.c
===
RCS file: /cvs/src/sys/kern/subr_prf.c,v
retrieving revision 1.91
diff -u -p -r1.91 subr_prf.c
--- kern/subr_prf.c 30 Apr 2017 16:45:46 -  1.91
+++ kern/subr_prf.c 17 Sep 2017 14:59:34 -
@@ -128,7 +128,7 @@ int db_is_active;
 /*
  * panic on spl assertion failure?
  */
-int splassert_ctl = 1;
+int splassert_ctl = 2;
 
 /*
  * v_putc: routine to putc on virtual console



Re: write.2: caveats: write(2) returns zero?

2017-09-17 Thread Scott Cheloha
> On Sep 17, 2017, at 4:53 AM, Marc Espie  wrote:
> 
> On Sat, Sep 16, 2017 at 10:25:19PM -0500, Scott Cheloha wrote:
>> Hi,
>> 
>> [...]
>> 
>> --
>> Scott Cheloha
>> 
>> Index: lib/libc/sys/write.2
>> ===
>> RCS file: /cvs/src/lib/libc/sys/write.2,v
>> retrieving revision 1.39
>> diff -u -p -r1.39 write.2
>> --- lib/libc/sys/write.2 5 Feb 2015 02:33:09 -   1.39
>> +++ lib/libc/sys/write.2 17 Sep 2017 03:02:57 -
>> @@ -311,7 +311,7 @@ function call appeared in
>> Error checks should explicitly test for \-1.
>> Code such as
>> .Bd -literal -offset indent
>> -while ((nr = write(fd, buf, sizeof(buf))) > 0)
>> +while ((nw = write(fd, buf, sizeof(buf))) > 0)
>> .Ed
>> .Pp
>> is not maximally portable, as some platforms allow for
>> @@ -325,5 +325,5 @@ and
>> may appear as a negative number distinct from \-1.
>> Proper loops should use
>> .Bd -literal -offset indent
>> -while ((nr = write(fd, buf, sizeof(buf))) != -1 && nr != 0)
>> +while ((nw = write(fd, buf, sizeof(buf))) != -1 && nw == sizeof(buf))
>> .Ed
> 
> Well, that's not okay either, because nw == sizeof(buf) will only make
> sense for file-based fds.

Ah, okay.  So my third question was about partial writes.

I left it out because I figured that we could just say explicitly
that the examples did not cover partial writes if need be.

At least, I think that's what you mean when you say that '== sizeof(buf)'
only makes sense for file-based fds.

> I'm for either scraping the example altogether or writing a proper
> one, which would mean embedding any version of safe_write in the
> man page.

Could you point to an example of safe_write in the tree that covers
what you're looking for?  Is it akin to writeall() in signify(1) or
atomicio() for nc(1)?

--
Scott Cheloha



Re: first console unusable due to usb mouse shenanigans

2017-09-17 Thread Kenneth R Westerback
On Sun, Sep 17, 2017 at 10:14:06AM +, Marc Espie wrote:
> This is on current, I get this on repeat very regularly.
> 
> wsmouse0 detached
> ums0 detached
> uhidev0 detached
> splassert: usb_transfer_complete: want 5 have 6
> splassert: usb_transfer_complete: want 5 have 6
> splassert: usb_transfer_complete: want 5 have 6
> uhidev0 at uhub2 port 1 configuration 1 interface 0 "Logitech USB Optical 
> Mouse" rev 2.00/72.00 addr 2
> uhidev0: iclass 3/1
> ums0 at uhidev0: 3 buttons, Z dir
> wsmouse0 at ums0 mux 0
> 
> The splassert, in particular, hint to a bug in the kernel.
> 
> When the mouse is attached to X, this is not a problem,
> but the first console is basically unusable in text mode,
> so if there are significant console messages I'm not going to see them.
> 
> Running current:
> 
> OpenBSD 6.2-beta (GENERIC.MP) #101: Sat Sep 16 23:23:03 MDT 2017
> dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> real mem = 8522469376 (8127MB)
> avail mem = 8257171456 (7874MB)
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xeb600 (49 entries)
> bios0: vendor American Megatrends Inc. version "0601" date 12/25/2012
> bios0: ASUSTeK COMPUTER INC. CM1435
> acpi0 at bios0: rev 2
> acpi0: sleep states S0 S3 S4 S5
> acpi0: tables DSDT FACP APIC FPDT MCFG HPET MSDM SSDT SSDT IVRS BGRT
> acpi0: wakeup devices SBAZ(S4) PS2K(S4) OHC1(S4) EHC1(S4) OHC2(S4) EHC2(S4) 
> OHC3(S4) EHC3(S4) OHC4(S4) XHC0(S4) XHC1(S4) PE21(S4) RLAN(S4) PE22(S4) 
> PE23(S4) PCE2(S4) [...]
> acpitimer0 at acpi0: 3579545 Hz, 32 bits
> acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
> cpu0 at mainbus0: apid 16 (boot processor)
> cpu0: AMD A10-5700 APU with Radeon(tm) HD Graphics, 3417.47 MHz
> 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,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TBM,TOPEXT,ITSC,BMI1
> cpu0: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 
> 16-way L2 cache
> cpu0: ITLB 48 4KB entries fully associative, 24 4MB entries fully associative
> cpu0: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
> cpu0: TSC frequency 3417470380 Hz
> cpu0: smt 0, core 0, package 0
> mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
> cpu0: apic clock running at 100MHz
> cpu0: mwait min=64, max=64, IBE
> cpu1 at mainbus0: apid 17 (application processor)
> cpu1: AMD A10-5700 APU with Radeon(tm) HD Graphics, 3417.00 MHz
> 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,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TBM,TOPEXT,ITSC,BMI1
> cpu1: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 
> 16-way L2 cache
> cpu1: ITLB 48 4KB entries fully associative, 24 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 18 (application processor)
> cpu2: AMD A10-5700 APU with Radeon(tm) HD Graphics, 3417.00 MHz
> cpu2: 
> 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,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TBM,TOPEXT,ITSC,BMI1
> cpu2: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 
> 16-way L2 cache
> cpu2: ITLB 48 4KB entries fully associative, 24 4MB entries fully associative
> cpu2: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
> cpu2: smt 0, core 2, package 0
> cpu3 at mainbus0: apid 19 (application processor)
> cpu3: AMD A10-5700 APU with Radeon(tm) HD Graphics, 3417.00 MHz
> cpu3: 
> 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,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TBM,TOPEXT,ITSC,BMI1
> cpu3: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 
> 16-way L2 cache
> cpu3: ITLB 48 4KB entries fully associative, 24 4MB entries fully associative
> cpu3: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
> cpu3: smt 0, core 3, package 0
> ioapic0 at mainbus0: apid 5 pa 0xfec0, version 21, 24 pins
> acpimcfg0 at acpi0 addr 0xe000, bus 0-255
> acpihpet0 at acpi0: 14318180 Hz
> acpiprt0 at acpi0: bus 0 (PCI0)
> acpiprt1 at acpi0: bus -1 (PE21)
> 

first console unusable due to usb mouse shenanigans

2017-09-17 Thread Marc Espie
This is on current, I get this on repeat very regularly.

wsmouse0 detached
ums0 detached
uhidev0 detached
splassert: usb_transfer_complete: want 5 have 6
splassert: usb_transfer_complete: want 5 have 6
splassert: usb_transfer_complete: want 5 have 6
uhidev0 at uhub2 port 1 configuration 1 interface 0 "Logitech USB Optical 
Mouse" rev 2.00/72.00 addr 2
uhidev0: iclass 3/1
ums0 at uhidev0: 3 buttons, Z dir
wsmouse0 at ums0 mux 0

The splassert, in particular, hint to a bug in the kernel.

When the mouse is attached to X, this is not a problem,
but the first console is basically unusable in text mode,
so if there are significant console messages I'm not going to see them.

Running current:

OpenBSD 6.2-beta (GENERIC.MP) #101: Sat Sep 16 23:23:03 MDT 2017
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 8522469376 (8127MB)
avail mem = 8257171456 (7874MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xeb600 (49 entries)
bios0: vendor American Megatrends Inc. version "0601" date 12/25/2012
bios0: ASUSTeK COMPUTER INC. CM1435
acpi0 at bios0: rev 2
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP APIC FPDT MCFG HPET MSDM SSDT SSDT IVRS BGRT
acpi0: wakeup devices SBAZ(S4) PS2K(S4) OHC1(S4) EHC1(S4) OHC2(S4) EHC2(S4) 
OHC3(S4) EHC3(S4) OHC4(S4) XHC0(S4) XHC1(S4) PE21(S4) RLAN(S4) PE22(S4) 
PE23(S4) PCE2(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 16 (boot processor)
cpu0: AMD A10-5700 APU with Radeon(tm) HD Graphics, 3417.47 MHz
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,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TBM,TOPEXT,ITSC,BMI1
cpu0: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 
16-way L2 cache
cpu0: ITLB 48 4KB entries fully associative, 24 4MB entries fully associative
cpu0: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu0: TSC frequency 3417470380 Hz
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 100MHz
cpu0: mwait min=64, max=64, IBE
cpu1 at mainbus0: apid 17 (application processor)
cpu1: AMD A10-5700 APU with Radeon(tm) HD Graphics, 3417.00 MHz
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,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TBM,TOPEXT,ITSC,BMI1
cpu1: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 
16-way L2 cache
cpu1: ITLB 48 4KB entries fully associative, 24 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 18 (application processor)
cpu2: AMD A10-5700 APU with Radeon(tm) HD Graphics, 3417.00 MHz
cpu2: 
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,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TBM,TOPEXT,ITSC,BMI1
cpu2: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 
16-way L2 cache
cpu2: ITLB 48 4KB entries fully associative, 24 4MB entries fully associative
cpu2: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu2: smt 0, core 2, package 0
cpu3 at mainbus0: apid 19 (application processor)
cpu3: AMD A10-5700 APU with Radeon(tm) HD Graphics, 3417.00 MHz
cpu3: 
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,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TBM,TOPEXT,ITSC,BMI1
cpu3: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 
16-way L2 cache
cpu3: ITLB 48 4KB entries fully associative, 24 4MB entries fully associative
cpu3: DTLB 64 4KB entries fully associative, 64 4MB entries fully associative
cpu3: smt 0, core 3, package 0
ioapic0 at mainbus0: apid 5 pa 0xfec0, version 21, 24 pins
acpimcfg0 at acpi0 addr 0xe000, bus 0-255
acpihpet0 at acpi0: 14318180 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PE21)
acpiprt2 at acpi0: bus 4 (PE22)
acpiprt3 at acpi0: bus 5 (PE23)
acpiprt4 at acpi0: bus 1 (PCE2)
acpiprt5 at acpi0: bus -1 (PCE3)
acpiprt6 at acpi0: bus -1 (PCE4)
acpiprt7 at acpi0: bus -1 (PCE5)
acpiprt8 at acpi0: bus -1 (PCE6)

Re: write.2: caveats: write(2) returns zero?

2017-09-17 Thread Marc Espie
On Sat, Sep 16, 2017 at 10:25:19PM -0500, Scott Cheloha wrote:
> Hi,
> 
> The second example in the write(2) CAVEATS section is identical to
> the corresponding example in the read(2) page:
> 
>   while ((nr = write(fd, buf, sizeof(buf))) != -1 && nr != 0)
> 
> read(2) returns 0 on EOF, but that logic is inapplicable to write(2).
> 
> I'm not totally sure what the correct code should be but attached is
> my best guess.
> 
> Also, if "nr" is for "Number Read", because this is the write(2)
> page, would "nw" be better?
> 
> --
> Scott Cheloha
> 
> Index: lib/libc/sys/write.2
> ===
> RCS file: /cvs/src/lib/libc/sys/write.2,v
> retrieving revision 1.39
> diff -u -p -r1.39 write.2
> --- lib/libc/sys/write.2  5 Feb 2015 02:33:09 -   1.39
> +++ lib/libc/sys/write.2  17 Sep 2017 03:02:57 -
> @@ -311,7 +311,7 @@ function call appeared in
>  Error checks should explicitly test for \-1.
>  Code such as
>  .Bd -literal -offset indent
> -while ((nr = write(fd, buf, sizeof(buf))) > 0)
> +while ((nw = write(fd, buf, sizeof(buf))) > 0)
>  .Ed
>  .Pp
>  is not maximally portable, as some platforms allow for
> @@ -325,5 +325,5 @@ and
>  may appear as a negative number distinct from \-1.
>  Proper loops should use
>  .Bd -literal -offset indent
> -while ((nr = write(fd, buf, sizeof(buf))) != -1 && nr != 0)
> +while ((nw = write(fd, buf, sizeof(buf))) != -1 && nw == sizeof(buf))
>  .Ed

Well, that's not okay either, because nw == sizeof(buf) will only make
sense for file-based fds.

I'm for either scraping the example altogether or writing a proper
one, which would mean embedding any version of safe_write in the
man page.