From fa4a9db7a3ed38bec39112e0d2d977061803cd94 Mon Sep 17 00:00:00 2001 From: Tomasz Leman Date: Wed, 27 Nov 2024 13:31:08 +0100 Subject: [PATCH] dma: intel_adsp_hda: Fix invalid init sequence and register use This patch addresses the issue of invalid initialization sequence and the use of registers in `dma_config` before the device is fully initialized in the Intel ADSP HDA DMA driver. Changes include: 1. Moving the `intel_adsp_hda_channels_init` call to the `intel_adsp_hda_dma_init` function to ensure that channels are initialized during device initialization. 2. Removing the redundant call to `intel_adsp_hda_channels_init` from the `PM_DEVICE_ACTION_RESUME` case in the `intel_adsp_hda_dma_pm_action` function. These changes ensure that the device and its channels are properly initialized before any DMA configuration is performed, preventing access to hardware registers before the device is ready. **Note:** This is a proposed solution, and a different approach should be considered. Currently, we are accessing registers before the device and power domain are fully powered up. This solution likely works because the DMA is used to load firmware during the boot process, and the necessary power domains are already powered up. Further investigation and a more robust solution are recommended to ensure proper initialization and power management. Signed-off-by: Tomasz Leman --- drivers/dma/dma_intel_adsp_hda.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dma/dma_intel_adsp_hda.c b/drivers/dma/dma_intel_adsp_hda.c index 934a73d1269..de2b5b1c827 100644 --- a/drivers/dma/dma_intel_adsp_hda.c +++ b/drivers/dma/dma_intel_adsp_hda.c @@ -385,10 +385,9 @@ static void intel_adsp_hda_channels_init(const struct device *dev) int intel_adsp_hda_dma_pm_action(const struct device *dev, enum pm_device_action action) { + ARG_UNUSED(dev); switch (action) { case PM_DEVICE_ACTION_RESUME: - intel_adsp_hda_channels_init(dev); - break; case PM_DEVICE_ACTION_SUSPEND: case PM_DEVICE_ACTION_TURN_ON: case PM_DEVICE_ACTION_TURN_OFF: @@ -408,6 +407,7 @@ int intel_adsp_hda_dma_init(const struct device *dev) data->ctx.dma_channels = cfg->dma_channels; data->ctx.atomic = data->channels_atomic; data->ctx.magic = DMA_MAGIC; + intel_adsp_hda_channels_init(dev); return pm_device_driver_init(dev, intel_adsp_hda_dma_pm_action); }