Re: redmi laptop keyboard problem

2023-02-24 Thread Todd C . Miller
On Fri, 24 Feb 2023 12:25:51 -0700, "Theo de Raadt" wrote:

> The invention of interrupts was a bad idea.
>
> We should dedicate a core to polling. /sarc

big.little to the rescue!

 - todd



Re: redmi laptop keyboard problem

2023-02-24 Thread Theo de Raadt
Mark Kettenis  wrote:

> I really wonder how these things happen.  Cause presumably older
> versions of Windows didn't look at what the DSDT says about the
> polarity, which meant that vendors released DSDTs with the wrong
> polarity.  But now Windows does look at what the DSDT says?  Does that
> mean that running newer Windows versions on these older laptops
> doesn't work anymore?

The invention of interrupts was a bad idea.

We should dedicate a core to polling. /sarc



Re: redmi laptop keyboard problem

2023-02-24 Thread Mark Kettenis
> Date: Fri, 24 Feb 2023 21:38:50 +0300
> From: Mikhail 
> 
> On Thu, Feb 23, 2023 at 05:46:04PM +0300, Mikhail wrote:
> > On Thu, Feb 16, 2023 at 02:34:11PM +0300, Mikhail wrote:
> > > We have a redmi laptop where I want to install OpenBSD current, but
> > > the keyboard there is not functional, install image boots fine, but
> > > when I try to press any key, after a delay of 1-2 seconds, I see a
> > > repetitive echo on the screen. For example, I'd like to answer 'i' for
> > > the initial installer question, but instead of 'i' I get 'iii',
> > > pressing backspace removes all seven i's.
> > > 
> > > External USB keyboard works fine, also native keyboard works fine in
> > > boot> prompt.
> > > 
> > > Currently I have only webmail access, so I'd better include the dmesg
> > > as attachment, otherwise gmail will insert line breaks or fix it
> > > another way if I paste it directly.
> > 
> > I tried to use latest ubuntu on this laptop and keyboard didn't work
> > with it also, Kali linux worked fine though.
> > 
> > After some googling I came up with the following patch to linux kernel:
> > https://lore.kernel.org/all/20220712020058.90374-1-gch981...@gmail.com/
> > 
> > I compiled linux 6.1.12 on Kali with and without the patch and I can
> > confirm that without the patch my keyboard becomes non-functional.
> > 
> > The laptop is Redmi Book Pro 14 2022.
> 
> DSDT defines KBC0's (PNP0303, a keyboard) IRQ as
> 
> IRQ (Edge, ActiveLow, Shared, )
> 
> and pckbc_isa_attach defaults to ActiveHigh. As the link in my previous
> email says:
> 
> > There's an active low keyboard IRQ on AMD Ryzen 6000 and it will stay
> > this way on newer platforms.

It's not a PeeCee!

> 
> With the inlined patch I'm able to use native laptop keyboard, but I'm
> sure it will break other keyboards.

Yes, and it doesn't even make sense.  The interrupt is edge triggered
not level triggered.  It's just that the signal has the wrong
polarity.

> Does anyone has an idea how to improve it?

pckbc@acpi may be part of the solution.  At least there we'll be able
to look at what the DSDT says about this interrupt and configure it
accordingly.  But apparently on older hardware the DSDT is full of
lies.

I really wonder how these things happen.  Cause presumably older
versions of Windows didn't look at what the DSDT says about the
polarity, which meant that vendors released DSDTs with the wrong
polarity.  But now Windows does look at what the DSDT says?  Does that
mean that running newer Windows versions on these older laptops
doesn't work anymore?


> diff --git a/sys/dev/isa/pckbc_isa.c b/sys/dev/isa/pckbc_isa.c
> index e94fd7e52..ca7ec6c9f 100644
> --- a/sys/dev/isa/pckbc_isa.c
> +++ b/sys/dev/isa/pckbc_isa.c
> @@ -140,7 +140,7 @@ pckbc_isa_attach(struct device *parent, struct device 
> *self, void *aux)
>  
>   for (slot = 0; slot < PCKBC_NSLOTS; slot++) {
>   rv = isa_intr_establish(ia->ia_ic, ia->ipa_irq[slot].num,
> - IST_EDGE, IPL_TTY, pckbcintr, sc, sc->sc_dv.dv_xname);
> + IST_LEVEL, IPL_TTY, pckbcintr, sc, sc->sc_dv.dv_xname);
>   if (rv == NULL) {
>   printf("%s: unable to establish interrupt for irq %d\n",
>   sc->sc_dv.dv_xname, ia->ipa_irq[slot].num);
> 
> 



Re: redmi laptop keyboard problem

2023-02-24 Thread Mikhail
On Thu, Feb 23, 2023 at 05:46:04PM +0300, Mikhail wrote:
> On Thu, Feb 16, 2023 at 02:34:11PM +0300, Mikhail wrote:
> > We have a redmi laptop where I want to install OpenBSD current, but
> > the keyboard there is not functional, install image boots fine, but
> > when I try to press any key, after a delay of 1-2 seconds, I see a
> > repetitive echo on the screen. For example, I'd like to answer 'i' for
> > the initial installer question, but instead of 'i' I get 'iii',
> > pressing backspace removes all seven i's.
> > 
> > External USB keyboard works fine, also native keyboard works fine in
> > boot> prompt.
> > 
> > Currently I have only webmail access, so I'd better include the dmesg
> > as attachment, otherwise gmail will insert line breaks or fix it
> > another way if I paste it directly.
> 
> I tried to use latest ubuntu on this laptop and keyboard didn't work
> with it also, Kali linux worked fine though.
> 
> After some googling I came up with the following patch to linux kernel:
> https://lore.kernel.org/all/20220712020058.90374-1-gch981...@gmail.com/
> 
> I compiled linux 6.1.12 on Kali with and without the patch and I can
> confirm that without the patch my keyboard becomes non-functional.
> 
> The laptop is Redmi Book Pro 14 2022.

DSDT defines KBC0's (PNP0303, a keyboard) IRQ as

IRQ (Edge, ActiveLow, Shared, )

and pckbc_isa_attach defaults to ActiveHigh. As the link in my previous
email says:

> There's an active low keyboard IRQ on AMD Ryzen 6000 and it will stay
> this way on newer platforms.

With the inlined patch I'm able to use native laptop keyboard, but I'm
sure it will break other keyboards.

Does anyone has an idea how to improve it?

diff --git a/sys/dev/isa/pckbc_isa.c b/sys/dev/isa/pckbc_isa.c
index e94fd7e52..ca7ec6c9f 100644
--- a/sys/dev/isa/pckbc_isa.c
+++ b/sys/dev/isa/pckbc_isa.c
@@ -140,7 +140,7 @@ pckbc_isa_attach(struct device *parent, struct device 
*self, void *aux)
 
for (slot = 0; slot < PCKBC_NSLOTS; slot++) {
rv = isa_intr_establish(ia->ia_ic, ia->ipa_irq[slot].num,
-   IST_EDGE, IPL_TTY, pckbcintr, sc, sc->sc_dv.dv_xname);
+   IST_LEVEL, IPL_TTY, pckbcintr, sc, sc->sc_dv.dv_xname);
if (rv == NULL) {
printf("%s: unable to establish interrupt for irq %d\n",
sc->sc_dv.dv_xname, ia->ipa_irq[slot].num);



redmi laptop keyboard problem

2023-02-16 Thread Mikhail
We have a redmi laptop where I want to install OpenBSD current, but
the keyboard there is not functional, install image boots fine, but
when I try to press any key, after a delay of 1-2 seconds, I see a
repetitive echo on the screen. For example, I'd like to answer 'i' for
the initial installer question, but instead of 'i' I get 'iii',
pressing backspace removes all seven i's.

External USB keyboard works fine, also native keyboard works fine in
boot> prompt.

Currently I have only webmail access, so I'd better include the dmesg
as attachment, otherwise gmail will insert line breaks or fix it
another way if I paste it directly.
OpenBSD 7.2-current (GENERIC.MP) #1051: Wed Feb 15 23:08:12 MST 2023
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 16295174144 (15540MB)
avail mem = 15781908480 (15050MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.3 @ 0x71661000 (53 entries)
bios0: vendor TIMI version "RMARB4B0P0B0B" date 07/10/2022
bios0: TIMI Redmi Book Pro 14 2022
efi0 at bios0: UEFI 2.8
efi0: INSYDE Corp. rev 0x7105410b
acpi0 at bios0: ACPI 5.0
acpi0: sleep states S0 S4 S5
acpi0: tables DSDT FACP UEFI SSDT SSDT IVRS SSDT SSDT SSDT SSDT TPM2 MSDM ASF! 
BOOT HPET APIC MCFG SLIC $H2O SSDT VFCT SSDT SSDT CRAT CDIT SSDT SSDT SSDT SSDT 
FPDT WSMT SSDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT BGRT
acpi0: wakeup devices GPP0(S4) GPP1(S4) GPP2(S4) GPP5(S4) GPP6(S4) GPP7(S4)
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpihpet0 at acpi0: 14318180 Hz
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD Ryzen 7 6800H with Radeon Graphics, 3200.01 MHz, 19-44-01
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,INVPCID,PQM,RDSEED,ADX,SMAP,CLFLUSHOPT,CLWB,SHA,UMIP,PKU,WAITPKG,IBPB,IBRS,STIBP,SSBD,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu0: 32KB 64b/line 8-way D-cache, 32KB 64b/line 8-way I-cache, 512KB 64b/line 
8-way L2 cache, 16MB 64b/line 16-way L3 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 24MHz
cpu0: mwait min=64, max=64, C-substates=1.1, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: AMD Ryzen 7 6800H with Radeon Graphics, 3200.00 MHz, 19-44-01
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,INVPCID,PQM,RDSEED,ADX,SMAP,CLFLUSHOPT,CLWB,SHA,UMIP,PKU,IBPB,IBRS,STIBP,SSBD,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu1: 32KB 64b/line 8-way D-cache, 32KB 64b/line 8-way I-cache, 512KB 64b/line 
8-way L2 cache, 16MB 64b/line 16-way L3 cache
cpu1: smt 1, core 0, package 0
cpu2 at mainbus0: apid 2 (application processor)
cpu2: AMD Ryzen 7 6800H with Radeon Graphics, 3200.00 MHz, 19-44-01
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,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,INVPCID,PQM,RDSEED,ADX,SMAP,CLFLUSHOPT,CLWB,SHA,UMIP,PKU,IBPB,IBRS,STIBP,SSBD,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu2: 32KB 64b/line 8-way D-cache, 32KB 64b/line 8-way I-cache, 512KB 64b/line 
8-way L2 cache, 16MB 64b/line 16-way L3 cache
cpu2: smt 0, core 1, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: AMD Ryzen 7 6800H with Radeon Graphics, 3200.00 MHz, 19-44-01
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,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,INVPCID,PQM,RDSEED,ADX,SMAP,CLFLUSHOPT,CLWB,SHA,UMIP,PKU,IBPB,IBRS,STIBP,SSBD,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu3: 32KB 64b/line 8-way D-cache, 32KB 64b/line 8-way I-cache, 512KB 64b/line 
8-way L2 cache, 16MB 64b/line 16-way L3 cache
cpu3: smt 1, core 1, package 0
cpu4 at mainbus0: apid 4 (application processor)
cpu4: AMD Ryzen 7 6800H with Radeon Graphics, 3200.00 MHz, 19-44-01
cpu4: