Re: [PATCH] clockevents/drivers/i8253: Do not zero timer counter in shutdown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2024-08-01 at 18:49 +0100, David Woodhouse wrote:
> On Thu, 2024-08-01 at 16:21 +0200, Thomas Gleixner wrote:
> > On Tue, Feb 07 2023 at 09:14, lirongqing@xxxxxxxxx wrote:
> > > @@ -117,11 +110,6 @@ static int pit_shutdown(struct clock_event_device *evt)
> > >  
> > >         outb_p(0x30, PIT_MODE);
> > >  
> > > -       if (i8253_clear_counter_on_shutdown) {
> > > -               outb_p(0, PIT_CH0);
> > > -               outb_p(0, PIT_CH0);
> > > -       }
> > > -
> > 
> > The stop sequence is wrong:
> > 
> >     When there is a count in progress, writing a new LSB before the
> >     counter has counted down to 0 and rolled over to FFFFh, WILL stop
> >     the counter.  However, if the LSB is loaded AFTER the counter has
> >     rolled over to FFFFh, so that an MSB now exists in the counter, then
> >     the counter WILL NOT stop.
> > 
> > The original i8253 datasheet says:
> > 
> >     1) Write 1st byte stops the current counting
> >     2) Write 2nd byte starts the new count
> 

It also prefixes that with "Rewriting a counter register during
counting results in the following:".

But after you write the MODE register, is it actually supposed to be
counting? Just a little further up, under 'Counter Loading', it says:

"The count register is not loaded until the count value is written (one
or two bytes, depending on the mode selected by the RL bits), followed
by a rising edge and a falling edge of the clock. Any read of the
counter prior to that falling clock edge may yield invalid data".

OK, but what *triggers* that invalid state? Given that it explicitly
says that a one-byte counter write ends that state, it isn't the first
of two bytes. Surely that means that from the time the MODE register is
written, any read of the counter may yield invalid data, until the
counter is written?

I suspect there are as many implementations (virt and hardware) as
there are reasonable interpretations of the spec... and then some.

Attachment: smime.p7s
Description: S/MIME cryptographic signature


[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux