Skip to content

Commit 329675a

Browse files
tmlemankartben
authored andcommitted
dma: intel_adsp_hda: Refactor power management and correct power domains
This patch addresses several issues with the Intel ADSP HDA DMA driver: 1. Refactors the HDA DMA power management initialization. The previous use of `pm_device_runtime_enable` was incorrect. The updated approach relies on enabling runtime power management through the device tree using the `zephyr,pm-device-runtime-auto` property. Additionally, the patch removes redundant device initialization steps as these are already handled by `pm_device_driver_init` when the device is under a power domain. 2. Corrects the power domain assignment for the HDA link. The HDA link was previously assigned to the io0 power domain based on a misinterpretation of the documentation. The correct power domain assignment is now based on updated documentation for LNL, ensuring that the HDA link is associated with the appropriate power domain. These changes ensure that the HDA DMA driver properly manages power states, reducing power consumption and improving system stability, while ensuring the correct power domains are used. Signed-off-by: Tomasz Leman <[email protected]>
1 parent fd4a4bf commit 329675a

File tree

5 files changed

+44
-38
lines changed

5 files changed

+44
-38
lines changed

drivers/dma/dma_intel_adsp_hda.c

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,23 @@ static void intel_adsp_hda_channels_init(const struct device *dev)
383383
#endif
384384
}
385385

386+
int intel_adsp_hda_dma_pm_action(const struct device *dev, enum pm_device_action action)
387+
{
388+
switch (action) {
389+
case PM_DEVICE_ACTION_RESUME:
390+
intel_adsp_hda_channels_init(dev);
391+
break;
392+
case PM_DEVICE_ACTION_SUSPEND:
393+
case PM_DEVICE_ACTION_TURN_ON:
394+
case PM_DEVICE_ACTION_TURN_OFF:
395+
break;
396+
default:
397+
return -ENOTSUP;
398+
}
399+
400+
return 0;
401+
}
402+
386403
int intel_adsp_hda_dma_init(const struct device *dev)
387404
{
388405
struct intel_adsp_hda_dma_data *data = dev->data;
@@ -391,19 +408,7 @@ int intel_adsp_hda_dma_init(const struct device *dev)
391408
data->ctx.dma_channels = cfg->dma_channels;
392409
data->ctx.atomic = data->channels_atomic;
393410
data->ctx.magic = DMA_MAGIC;
394-
#ifdef CONFIG_PM_DEVICE_RUNTIME
395-
if (pm_device_on_power_domain(dev)) {
396-
pm_device_init_off(dev);
397-
} else {
398-
intel_adsp_hda_channels_init(dev);
399-
pm_device_init_suspended(dev);
400-
}
401-
402-
return pm_device_runtime_enable(dev);
403-
#else
404-
intel_adsp_hda_channels_init(dev);
405-
return 0;
406-
#endif
411+
return pm_device_driver_init(dev, intel_adsp_hda_dma_pm_action);
407412
}
408413

409414
int intel_adsp_hda_dma_get_attribute(const struct device *dev, uint32_t type, uint32_t *value)
@@ -430,25 +435,6 @@ int intel_adsp_hda_dma_get_attribute(const struct device *dev, uint32_t type, ui
430435
return 0;
431436
}
432437

433-
#ifdef CONFIG_PM_DEVICE
434-
int intel_adsp_hda_dma_pm_action(const struct device *dev, enum pm_device_action action)
435-
{
436-
switch (action) {
437-
case PM_DEVICE_ACTION_RESUME:
438-
intel_adsp_hda_channels_init(dev);
439-
break;
440-
case PM_DEVICE_ACTION_SUSPEND:
441-
case PM_DEVICE_ACTION_TURN_ON:
442-
case PM_DEVICE_ACTION_TURN_OFF:
443-
break;
444-
default:
445-
return -ENOTSUP;
446-
}
447-
448-
return 0;
449-
}
450-
#endif
451-
452438
#define DEVICE_DT_GET_AND_COMMA(node_id) DEVICE_DT_GET(node_id),
453439

454440
void intel_adsp_hda_dma_isr(void)

dts/xtensa/intel/intel_adsp_ace15_mtpm.dtsi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@
478478
dma-buf-addr-alignment = <128>;
479479
dma-buf-size-alignment = <32>;
480480
dma-copy-alignment = <16>;
481-
power-domains = <&io0_domain>;
481+
power-domains = <&hub_ulp_domain>;
482+
zephyr,pm-device-runtime-auto;
482483
status = "okay";
483484
};
484485

@@ -490,7 +491,8 @@
490491
dma-buf-addr-alignment = <128>;
491492
dma-buf-size-alignment = <32>;
492493
dma-copy-alignment = <16>;
493-
power-domains = <&io0_domain>;
494+
power-domains = <&hub_ulp_domain>;
495+
zephyr,pm-device-runtime-auto;
494496
status = "okay";
495497
};
496498

@@ -503,6 +505,7 @@
503505
dma-buf-size-alignment = <32>;
504506
dma-copy-alignment = <16>;
505507
power-domains = <&hst_domain>;
508+
zephyr,pm-device-runtime-auto;
506509
interrupts = <13 0 0>;
507510
interrupt-parent = <&ace_intc>;
508511
status = "okay";
@@ -517,6 +520,7 @@
517520
dma-buf-size-alignment = <32>;
518521
dma-copy-alignment = <16>;
519522
power-domains = <&hst_domain>;
523+
zephyr,pm-device-runtime-auto;
520524
interrupts = <12 0 0>;
521525
interrupt-parent = <&ace_intc>;
522526
status = "okay";

dts/xtensa/intel/intel_adsp_ace20_lnl.dtsi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@
383383
dma-buf-addr-alignment = <128>;
384384
dma-buf-size-alignment = <32>;
385385
dma-copy-alignment = <16>;
386+
power-domains = <&hst_domain>;
387+
zephyr,pm-device-runtime-auto;
386388
interrupts = <13 0 0>;
387389
interrupt-parent = <&ace_intc>;
388390
status = "okay";
@@ -396,6 +398,8 @@
396398
dma-buf-addr-alignment = <128>;
397399
dma-buf-size-alignment = <32>;
398400
dma-copy-alignment = <16>;
401+
power-domains = <&hst_domain>;
402+
zephyr,pm-device-runtime-auto;
399403
interrupts = <12 0 0>;
400404
interrupt-parent = <&ace_intc>;
401405
status = "okay";
@@ -417,6 +421,8 @@
417421
dma-buf-addr-alignment = <128>;
418422
dma-buf-size-alignment = <32>;
419423
dma-copy-alignment = <16>;
424+
power-domains = <&hub_ulp_domain>;
425+
zephyr,pm-device-runtime-auto;
420426
status = "okay";
421427
};
422428

@@ -428,6 +434,8 @@
428434
dma-buf-addr-alignment = <128>;
429435
dma-buf-size-alignment = <32>;
430436
dma-copy-alignment = <16>;
437+
power-domains = <&hub_ulp_domain>;
438+
zephyr,pm-device-runtime-auto;
431439
status = "okay";
432440
};
433441

dts/xtensa/intel/intel_adsp_ace30.dtsi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@
505505
dma-buf-size-alignment = <32>;
506506
dma-copy-alignment = <32>;
507507
power-domains = <&hst_domain>;
508+
zephyr,pm-device-runtime-auto;
508509
interrupts = <13 0 0>;
509510
interrupt-parent = <&ace_intc>;
510511
status = "okay";
@@ -519,6 +520,7 @@
519520
dma-buf-size-alignment = <32>;
520521
dma-copy-alignment = <32>;
521522
power-domains = <&hst_domain>;
523+
zephyr,pm-device-runtime-auto;
522524
interrupts = <12 0 0>;
523525
interrupt-parent = <&ace_intc>;
524526
status = "okay";
@@ -540,7 +542,8 @@
540542
dma-buf-addr-alignment = <128>;
541543
dma-buf-size-alignment = <32>;
542544
dma-copy-alignment = <32>;
543-
power-domains = <&io0_domain>;
545+
power-domains = <&hub_ulp_domain>;
546+
zephyr,pm-device-runtime-auto;
544547
status = "okay";
545548
};
546549

@@ -552,7 +555,8 @@
552555
dma-buf-addr-alignment = <128>;
553556
dma-buf-size-alignment = <32>;
554557
dma-copy-alignment = <32>;
555-
power-domains = <&io0_domain>;
558+
power-domains = <&hub_ulp_domain>;
559+
zephyr,pm-device-runtime-auto;
556560
status = "okay";
557561
};
558562

dts/xtensa/intel/intel_adsp_ace30_ptl.dtsi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@
510510
dma-buf-size-alignment = <32>;
511511
dma-copy-alignment = <32>;
512512
power-domains = <&hst_domain>;
513+
zephyr,pm-device-runtime-auto;
513514
interrupts = <13 0 0>;
514515
interrupt-parent = <&ace_intc>;
515516
status = "okay";
@@ -524,6 +525,7 @@
524525
dma-buf-size-alignment = <32>;
525526
dma-copy-alignment = <32>;
526527
power-domains = <&hst_domain>;
528+
zephyr,pm-device-runtime-auto;
527529
interrupts = <12 0 0>;
528530
interrupt-parent = <&ace_intc>;
529531
status = "okay";
@@ -545,7 +547,8 @@
545547
dma-buf-addr-alignment = <128>;
546548
dma-buf-size-alignment = <32>;
547549
dma-copy-alignment = <32>;
548-
power-domains = <&io0_domain>;
550+
power-domains = <&hub_ulp_domain>;
551+
zephyr,pm-device-runtime-auto;
549552
status = "okay";
550553
};
551554

@@ -557,7 +560,8 @@
557560
dma-buf-addr-alignment = <128>;
558561
dma-buf-size-alignment = <32>;
559562
dma-copy-alignment = <32>;
560-
power-domains = <&io0_domain>;
563+
power-domains = <&hub_ulp_domain>;
564+
zephyr,pm-device-runtime-auto;
561565
status = "okay";
562566
};
563567

0 commit comments

Comments
 (0)