Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 May 2025 19:45:01 GMT
From:      Christos Margiolis <christos@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 77521692f4c7 - stable/14 - snd_hda: Add shutdown method
Message-ID:  <202505211945.54LJj1ZK000608@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=77521692f4c71213c5419268657e696532c28325

commit 77521692f4c71213c5419268657e696532c28325
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2025-05-18 13:38:02 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-05-21 19:43:52 +0000

    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)
---
 sys/dev/sound/pci/hda/hdac.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c
index 9a7958449f91..be143ccd54c3 100644
--- a/sys/dev/sound/pci/hda/hdac.c
+++ b/sys/dev/sound/pci/hda/hdac.c
@@ -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)
  *
@@ -2157,6 +2186,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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202505211945.54LJj1ZK000608>