mpi3mr: Move creation of watchdog to interupt config hook

Move creation of watchdog process from just before we configure the
interrupt config hook to into the config hook itself. This prevents it
from racing the config intr hook and doing an extra reset of the
card. This extra reset is usually harmless, but sometimes it can prevent
discovery of devices if done at just the wrong time. This can lead to no
disks being registered in a box full of disks, for example. Starting it
later eliminates this race, making discovery reliable.

Reviewed by: imp
This commit is contained in:
Sumit Saxena 2023-10-19 15:06:29 -06:00 committed by Warner Losh
parent f300335d9a
commit 7e02c7074c

View file

@ -307,6 +307,7 @@ static void
mpi3mr_ich_startup(void *arg)
{
struct mpi3mr_softc *sc;
int error;
sc = (struct mpi3mr_softc *)arg;
mpi3mr_dprint(sc, MPI3MR_XINFO, "%s entry\n", __func__);
@ -314,8 +315,16 @@ mpi3mr_ich_startup(void *arg)
mtx_lock(&sc->mpi3mr_mtx);
mpi3mr_startup(sc);
mtx_unlock(&sc->mpi3mr_mtx);
error = mpi3mr_kproc_create(mpi3mr_watchdog_thread, sc,
&sc->watchdog_thread, 0, 0, "mpi3mr_watchdog%d",
device_get_unit(sc->mpi3mr_dev));
if (error)
device_printf(sc->mpi3mr_dev, "Error %d starting OCR thread\n", error);
mpi3mr_dprint(sc, MPI3MR_XINFO, "disestablish config intrhook\n");
config_intrhook_disestablish(&sc->mpi3mr_ich);
sc->mpi3mr_ich.ich_arg = NULL;
@ -443,14 +452,6 @@ mpi3mr_pci_attach(device_t dev)
goto load_failed;
}
error = mpi3mr_kproc_create(mpi3mr_watchdog_thread, sc,
&sc->watchdog_thread, 0, 0, "mpi3mr_watchdog%d",
device_get_unit(sc->mpi3mr_dev));
if (error) {
device_printf(sc->mpi3mr_dev, "Error %d starting OCR thread\n", error);
goto load_failed;
}
sc->mpi3mr_ich.ich_func = mpi3mr_ich_startup;
sc->mpi3mr_ich.ich_arg = sc;
if (config_intrhook_establish(&sc->mpi3mr_ich) != 0) {