Skip to content

Commit

Permalink
atkbd: Reduce polling rate from 10Hz to ~1Hz.
Browse files Browse the repository at this point in the history
In my understanding this is only needed to workaround lost interrupts.
I was thinking to remove it completely, but the comment about edge-
triggered interrupt may be true and needs deeper investigation.  ~1Hz
should be often enough to handle the supposedly rare loss cases, but
rare enough to not appear in top.  Add sysctl hw.atkbd.hz to tune it.

MFC after:	1 month

(cherry picked from commit 9e007a8)
  • Loading branch information
amotin committed Feb 4, 2022
1 parent f6e755d commit 35f0bf2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions sys/dev/atkbdc/atkbd.c
Expand Up @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/sysctl.h>

#include <machine/bus.h>
#include <machine/resource.h>
Expand Down Expand Up @@ -73,6 +74,13 @@ typedef struct atkbd_state {
#endif
} atkbd_state_t;

static SYSCTL_NODE(_hw, OID_AUTO, atkbd, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"AT keyboard");

static int atkbdhz = 1;
SYSCTL_INT(_hw_atkbd, OID_AUTO, hz, CTLFLAG_RWTUN, &atkbdhz, 0,
"Polling frequency (in hz)");

static void atkbd_timeout(void *arg);
static int atkbd_reset(KBDC kbdc, int flags, int c);

Expand Down Expand Up @@ -198,8 +206,11 @@ atkbd_timeout(void *arg)
kbdd_intr(kbd, NULL);
}
splx(s);
state = (atkbd_state_t *)kbd->kb_data;
callout_reset(&state->ks_timer, hz / 10, atkbd_timeout, arg);
if (atkbdhz > 0) {
state = (atkbd_state_t *)kbd->kb_data;
callout_reset_sbt(&state->ks_timer, SBT_1S / atkbdhz, 0,
atkbd_timeout, arg, C_PREL(1));
}
}

/* LOW-LEVEL */
Expand Down

0 comments on commit 35f0bf2

Please sign in to comment.