snd_hda: Add shutdown method

Power down the device on shutdown similar to what is done in the case
of suspend. The device may fail to attach on next boot without this.

PR:		286385
Reviewed by:	christos, adrian
Differential Revision:	https://reviews.freebsd.org/D50306

(cherry picked from commit d9900b9ea2b27f7a0c2eda97841b9499e02e3ea7)
(cherry picked from commit 77521692f4c71213c5419268657e696532c28325)

Approved by:    re (cperciva)
This commit is contained in:
Tijl Coosemans 2025-05-18 15:38:02 +02:00 committed by Christos Margiolis
parent 747efc2aee
commit adf77cb48e

View file

@ -1638,6 +1638,35 @@ hdac_attach2(void *arg)
sizeof(sc->dev), sysctl_hdac_polling, "I", "Enable polling mode");
}
/****************************************************************************
* int hdac_shutdown(device_t)
*
* Power down HDA bus and codecs.
****************************************************************************/
static int
hdac_shutdown(device_t dev)
{
struct hdac_softc *sc = device_get_softc(dev);
HDA_BOOTHVERBOSE(
device_printf(dev, "Shutdown...\n");
);
callout_drain(&sc->poll_callout);
taskqueue_drain(taskqueue_thread, &sc->unsolq_task);
bus_generic_shutdown(dev);
hdac_lock(sc);
HDA_BOOTHVERBOSE(
device_printf(dev, "Reset controller...\n");
);
hdac_reset(sc, false);
hdac_unlock(sc);
HDA_BOOTHVERBOSE(
device_printf(dev, "Shutdown done\n");
);
return (0);
}
/****************************************************************************
* int hdac_suspend(device_t)
*
@ -2155,6 +2184,7 @@ static device_method_t hdac_methods[] = {
DEVMETHOD(device_probe, hdac_probe),
DEVMETHOD(device_attach, hdac_attach),
DEVMETHOD(device_detach, hdac_detach),
DEVMETHOD(device_shutdown, hdac_shutdown),
DEVMETHOD(device_suspend, hdac_suspend),
DEVMETHOD(device_resume, hdac_resume),
/* Bus interface */