Skip to content

Conversation

@Martinhoff-maker
Copy link
Member

The goal of this PR is to have correlation between pm state of the cpu and the soc power domain.
It also correct the driver behavior that are on the power domain.

This patch is needed to block the pm_state "PM_STATE_SUSPEND_TO_IDLE"
when a device on the power domain (actually all the peripherals) is
active. Without this patch, cpu can decide to go to deep sleep while
a peripheral is active.

Signed-off-by: Martin Hoff <[email protected]>
}

/* Get the power management policy state lock */
if (!data->zephyr_channel_info[channel].channel_active) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also call pm_device_runtime_put() and pm_device_runtime_get() in DMA drivers to ensure that the user doesn’t have to explicitly manage this for memory-to-memory transfers?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder to add that like intel has done here: dma_intel_adsp_hda.c
I will try but I fear that we miss some cases that introduce some bugs.

Copy link
Member Author

Choose a reason for hiding this comment

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

that's done, seems to works

Added calls to pm_device_runtime_put() to ensure proper device runtime
management when configuration or DMA transceive operations fail.

Signed-off-by: Martin Hoff <[email protected]>
/* Perform DMA transceive */
ret = gspi_siwx91x_transceive_dma(dev, config);
if (ret < 0) {
pm_device_runtime_put(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 happens if asynchronous==false && dma=true && ret==0 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since this PR is mainly about PM, would do it in another PR.

if (ret < 0) {
pm_device_runtime_put(dev);
}
spi_context_release(&data->ctx, ret);
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, is the context released when asynchronous==true && dma=true && ret<0 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

same as above comment.

Removed unnecessary power management state lock calls since the DMA is
on a power domain that already handles state locking.
It will now managed directly pm_device which will active power_domain
and then block pm_state.

Signed-off-by: Martin Hoff <[email protected]>
This patch fix a reg write that needs to be done before calling the
callback. Since the user can start a new dma transfer in the callback,
it can miss the interrupt from the new transfer if the new transfer is
done before the interrupt bit is cleared.

Signed-off-by: Martin Hoff <[email protected]>
Removed conditional checks for device runtime put in DMA RX and
TX callbacks, ensuring that device runtime is always released
asynchronously.

Signed-off-by: Martin Hoff <[email protected]>
@Martinhoff-maker Martinhoff-maker marked this pull request as ready for review November 27, 2025 09:50
@sonarqubecloud
Copy link

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants