ASoC: Intel: avs: Implement PCI shutdown
authorAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Fri, 13 Jan 2023 19:03:08 +0000 (20:03 +0100)
committerMark Brown <broonie@kernel.org>
Fri, 13 Jan 2023 12:30:03 +0000 (12:30 +0000)
On shutdown reference to i915 driver needs to be released to not spam
logs with unnecessary warnings. While at it do some additional cleanup
to make sure DSP is powered down and interrupts from device are
disabled.

Fixes: 1affc44ea5dd ("ASoC: Intel: avs: PCI driver implementation")
Reported-by: Kornel Dulęba <korneld@google.com>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://lore.kernel.org/r/20230113190310.1451693-2-amadeuszx.slawinski@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/avs/core.c

index 2ca2427..6375018 100644 (file)
@@ -481,6 +481,29 @@ err_remap_bar0:
        return ret;
 }
 
+static void avs_pci_shutdown(struct pci_dev *pci)
+{
+       struct hdac_bus *bus = pci_get_drvdata(pci);
+       struct avs_dev *adev = hdac_to_avs(bus);
+
+       cancel_work_sync(&adev->probe_work);
+       avs_ipc_block(adev->ipc);
+
+       snd_hdac_stop_streams(bus);
+       avs_dsp_op(adev, int_control, false);
+       snd_hdac_ext_bus_ppcap_int_enable(bus, false);
+       snd_hdac_ext_bus_link_power_down_all(bus);
+
+       snd_hdac_bus_stop_chip(bus);
+       snd_hdac_display_power(bus, HDA_CODEC_IDX_CONTROLLER, false);
+
+       if (avs_platattr_test(adev, CLDMA))
+               pci_free_irq(pci, 0, &code_loader);
+       pci_free_irq(pci, 0, adev);
+       pci_free_irq(pci, 0, bus);
+       pci_free_irq_vectors(pci);
+}
+
 static void avs_pci_remove(struct pci_dev *pci)
 {
        struct hdac_device *hdev, *save;
@@ -739,6 +762,7 @@ static struct pci_driver avs_pci_driver = {
        .id_table = avs_ids,
        .probe = avs_pci_probe,
        .remove = avs_pci_remove,
+       .shutdown = avs_pci_shutdown,
        .driver = {
                .pm = &avs_dev_pm,
        },