atkbd: Reduce polling rate from 10Hz to ~1Hz.

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
This commit is contained in:
Alexander Motin 2022-01-05 11:32:44 -05:00
parent 4558c11f1b
commit 9e007a88d6

View file

@ -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>
@ -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);
@ -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 */