[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v3 2/2] x86: detect PIT aliasing on ports other than 0x4[0-3]
On 22.05.2024 15:57, Jason Andryuk wrote: > On 2024-05-22 08:59, Jan Beulich wrote: >> --- a/xen/arch/x86/time.c >> +++ b/xen/arch/x86/time.c >> @@ -427,6 +427,74 @@ static struct platform_timesource __init >> .resume = resume_pit, >> }; >> >> +unsigned int __initdata pit_alias_mask; >> + >> +static void __init probe_pit_alias(void) >> +{ >> + unsigned int mask = 0x1c; >> + uint8_t val = 0; >> + >> + if ( !opt_probe_port_aliases ) >> + return; >> + >> + /* >> + * Use channel 2 in mode 0 for probing. In this mode even a non-initial >> + * count is loaded independent of counting being / becoming enabled. >> Thus >> + * we have a 16-bit value fully under our control, to write and then >> check >> + * whether we can also read it back unaltered. >> + */ >> + >> + /* Turn off speaker output and disable channel 2 counting. */ >> + outb(inb(0x61) & 0x0c, 0x61); >> + >> + outb(PIT_LTCH_CH(2) | PIT_RW_LSB_MSB | PIT_MODE_EOC | PIT_BINARY, >> + PIT_MODE); >> + >> + do { >> + uint8_t val2; >> + unsigned int offs; >> + >> + outb(val, PIT_CH2); >> + outb(val ^ 0xff, PIT_CH2); >> + >> + /* Wait for the Null Count bit to clear. */ >> + do { >> + /* Latch status. */ >> + outb(PIT_RDB | PIT_RDB_NO_COUNT | PIT_RDB_CH2, PIT_MODE); >> + >> + /* Try to make sure we're actually having a PIT here. */ >> + val2 = inb(PIT_CH2); >> + if ( (val2 & ~(PIT_STATUS_OUT_PIN | PIT_STATUS_NULL_COUNT)) != >> + (PIT_RW_LSB_MSB | PIT_MODE_EOC | PIT_BINARY) ) >> + return; >> + } while ( val2 & (1 << 6) ); > > You can use PIT_STATUS_NULL_COUNT here. Indeed, and I meant to but then forgot. Thanks for noticing. > With that: > Reviewed-by: Jason Andryuk <jason.andryuk@xxxxxxx> Thanks. Jan
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |