[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.
- [PATCH 0/12 - gnumach] SMP almost working!, Damien Zammit, 2022/10/25
- [PATCH 01/12] kdb: Fix TODO for multiprocessor, Damien Zammit, 2022/10/25
- [PATCH 03/12] bios32: Use phystokv() on low bios addresses, Damien Zammit, 2022/10/25
- [PATCH 02/12] kern/startup: Disable interrupts before starting APs, Damien Zammit, 2022/10/25
- [PATCH 04/12] acpi: Add lapic_addr, Damien Zammit, 2022/10/25
- [PATCH 07/12] i386/pit: Tune delays, Damien Zammit, 2022/10/25
- Re: [PATCH 07/12] i386/pit: Tune delays,
Samuel Thibault <=
- [PATCH 05/12] linux: Reduce worst case wait to 10 seconds for disks, Damien Zammit, 2022/10/25
- Re: [PATCH 05/12] linux: Reduce worst case wait to 10 seconds for disks, Guillem Jover, 2022/10/25
[PATCH 06/12] linux drivers: Don't depend on curr_pic_mask for APIC, Damien Zammit, 2022/10/25
[PATCH 08/12] i386: Add AP variants of descriptor tables, Damien Zammit, 2022/10/25