Skip to content

Conversation

fimohame
Copy link
Contributor

This commit enables the pm device driver support for the dma_silabs_siwx91x driver.

@fimohame fimohame force-pushed the device_pm_silabs_siwx91x_dma branch 5 times, most recently from c73b89c to 620f008 Compare August 12, 2025 09:28
@fimohame fimohame marked this pull request as ready for review August 12, 2025 09:33
@zephyrbot zephyrbot added platform: Silabs Silicon Labs area: DMA Direct Memory Access labels Aug 12, 2025
@fimohame fimohame force-pushed the device_pm_silabs_siwx91x_dma branch from 620f008 to e603e6d Compare August 12, 2025 10:31
@fimohame fimohame force-pushed the device_pm_silabs_siwx91x_dma branch 3 times, most recently from 0a0e6e1 to 0ac614f Compare August 19, 2025 06:34
Copy link

@Martinhoff-maker
Copy link
Member

Martinhoff-maker commented Sep 5, 2025

As discussed, since we agree to use CONFIG_PM_DEVICE=y and having in mind that going to sleep will completely turn off the device without any register retention on siwx917 board.

return -EBUSY;
}
} else if (IS_ENABLED(CONFIG_PM_DEVICE) && (action == PM_DEVICE_ACTION_SUSPEND)) {
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As explained here: #94695 (comment)
You also need to turn off clocks as I understand for the future with pm device runtime mode. (Because you can suspend the device without sleeping)

Copy link
Contributor Author

@fimohame fimohame Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

}
if (action == PM_DEVICE_ACTION_RESUME) {
ret = clock_control_on(cfg->clock_dev, cfg->clock_subsys);
if (ret) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clock_control_on() may return -EALREADY which is not really an error (I know... this API is annoying).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

@fimohame fimohame marked this pull request as draft September 24, 2025 06:50
@fimohame fimohame force-pushed the device_pm_silabs_siwx91x_dma branch from 0ac614f to cc83786 Compare September 24, 2025 20:29
@fimohame fimohame force-pushed the device_pm_silabs_siwx91x_dma branch 2 times, most recently from 2701c32 to 569979a Compare September 24, 2025 20:42
@fimohame fimohame marked this pull request as ready for review September 25, 2025 07:23
@fimohame fimohame force-pushed the device_pm_silabs_siwx91x_dma branch from 569979a to 845009c Compare September 25, 2025 09:22
case PM_DEVICE_ACTION_SUSPEND:
break;
case PM_DEVICE_ACTION_TURN_ON:
ret = clock_control_on(cfg->clock_dev, cfg->clock_subsys);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to turn this clock in PM_DEVICE_ACTION_TURN_ON, or this can be done later in PM_DEVICE_ACTION_RESUME?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was discussed to place it here

Comment on lines +307 to +308
power-domains = <&siwx91x_soc_pd>;
zephyr,pm-device-runtime-auto;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't you think we can also apply it to ulpdma ? in ps4 sleep state, we will have have the same behavior than the HP uDMA (no register retention)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed


/* Connect the DMA interrupt */
cfg->irq_configure();
cfg->irq_configure();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to reconfigure the irq after each wake-up, are we ? this can be done only in the init function IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed

Copy link
Member

@Martinhoff-maker Martinhoff-maker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure that we got the same understanding (and it's between all the PM PR):

Since you got no runtime get and put inside of this uDMA driver, you consider that the device will always be suspended or turned off if the power domain is suspended ? Then since we are on the same power-domain than the peripheral that use the uDMA, when you will do a "get" inside of this peripheral, it will turn on the power domain and then put the uDMA from OFF to suspended (but that will be good since everything's is alive in our "suspended" mode) ?

@fimohame fimohame force-pushed the device_pm_silabs_siwx91x_dma branch from 845009c to b34cfa4 Compare October 17, 2025 10:48
@fimohame fimohame force-pushed the device_pm_silabs_siwx91x_dma branch 3 times, most recently from 3e0728e to b91c743 Compare October 17, 2025 11:08
@fimohame
Copy link
Contributor Author

I have updated with pm policy state lock get and put for the driver.

…driver

This commit enables the pm policy state lock support
for the dma_silabs_siwx91x driver.

Signed-off-by: S Mohamed Fiaz <[email protected]>
Copy link

@Martinhoff-maker
Copy link
Member

I don't think we want to use pm_policy because it's going back to System managed PM. Why don't you used pm_device_runtime_get() instead ?

@Martinhoff-maker
Copy link
Member

Edit: After discussing with @asmellby, I think that using pm_policy lock is mandatory. that's ok. how do you test that it works properly ?

*/
};

static void siwx91x_dma_pm_policy_state_lock_get(const struct device *dev)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the use of *dev in this function?

}

/* Get the power management policy state lock */
siwx91x_dma_pm_policy_state_lock_get(dev);
Copy link
Member

@Martinhoff-maker Martinhoff-maker Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually implement PM in GPDMA and see one source of error. In the DMA api definition in zephyr, the user can call dma_start on an already started transfer and it should return no error. Then you will get multiple lock and never going to sleep again. I think you need to take the look only if you didn't have an already running DMA on this channel. Btw, this is he same for dma_stop().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards/SoCs area: DMA Direct Memory Access platform: Silabs Silicon Labs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants