bug-hurd
[Top][All Lists]
Advanced

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

Re: [PATCH 07/12] i386/pit: Tune delays


From: Samuel Thibault
Subject: Re: [PATCH 07/12] i386/pit: Tune delays
Date: Wed, 26 Oct 2022 00:15:08 +0200
User-agent: NeoMutt/20170609 (1.8.3)

Applied, thanks!

Damien Zammit, le mar. 25 oct. 2022 10:56:07 +0000, a ecrit:
> - Add half a clock tick for more accuracy
> - Start the pit countdown during pit_sleep
> - Add pit_mdelay and pit_udelay functions
> ---
>  i386/i386/pit.c | 24 ++++++++++++++++++++----
>  i386/i386/pit.h |  2 ++
>  2 files changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/i386/i386/pit.c b/i386/i386/pit.c
> index 0ead8c9b..7373a38e 100644
> --- a/i386/i386/pit.c
> +++ b/i386/i386/pit.c
> @@ -83,6 +83,12 @@ pit_prepare_sleep(int hz)
>      outb (PITCTR2_PORT, lsb);
>      val = inb(POST_PORT); /* ~1us i/o delay */
>      outb (PITCTR2_PORT, msb);
> +}
> +
> +void
> +pit_sleep(void)
> +{
> +    int val;
> 
>      /* Start counting down */
>      val = inb(PITAUX_PORT);
> @@ -90,13 +96,23 @@ pit_prepare_sleep(int hz)
>      outb (PITAUX_PORT, val); /* Gate low */
>      val |= PITAUX_GATE2;
>      outb (PITAUX_PORT, val); /* Gate high */
> +
> +    /* Wait until counter reaches zero */
> +    while ((inb(PITAUX_PORT) & PITAUX_VAL) == 0);
>  }
> 
>  void
> -pit_sleep(void)
> +pit_udelay(int usec)
>  {
> -    /* Wait until counter reaches zero */
> -    while ((inb(PITAUX_PORT) & PITAUX_VAL) == 0);
> +    pit_prepare_sleep(1000000 / usec);
> +    pit_sleep();
> +}
> +
> +void
> +pit_mdelay(int msec)
> +{
> +    pit_prepare_sleep(1000 / msec);
> +    pit_sleep();
>  }
> 
>  void
> @@ -115,7 +131,7 @@ clkstart(void)
>        * timers you do not use
>        */
>       outb(pitctl_port, pit0_mode);
> -     clknumb = CLKNUM/hz;
> +     clknumb = (CLKNUM + hz / 2) / hz;
>       byte = clknumb;
>       outb(pitctr0_port, byte);
>       byte = clknumb>>8;
> diff --git a/i386/i386/pit.h b/i386/i386/pit.h
> index bac4e985..51c4111d 100644
> --- a/i386/i386/pit.h
> +++ b/i386/i386/pit.h
> @@ -91,5 +91,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
>  extern void clkstart(void);
>  extern void pit_prepare_sleep(int hz);
>  extern void pit_sleep(void);
> +extern void pit_udelay(int usec);
> +extern void pit_mdelay(int msec);
> 
>  #endif /* _I386_PIT_H_ */
> --
> 2.34.1
> 
> 
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]