Skip to content

Commit 8658ce5

Browse files
abonislawskicfriedt
authored andcommitted
drivers: dma: dw: Add power management state check in get_status
Add power management state validation in dw_dma_get_status() to ensure the device is in active state before attempting to read DMA status. Returns -EINVAL if device is not active, preventing potential issues when accessing hardware registers while device is suspended. Signed-off-by: Adrian Bonislawski <[email protected]>
1 parent 5db84c7 commit 8658ce5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/dma/dma_dw_common.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,11 +826,18 @@ int dw_dma_get_status(const struct device *dev, uint32_t channel,
826826
struct dw_dma_dev_data *const dev_data = dev->data;
827827
const struct dw_dma_dev_cfg *const dev_cfg = dev->config;
828828
struct dw_dma_chan_data *chan_data;
829+
enum pm_device_state pm_state;
830+
int ret;
829831

830832
if (channel >= DW_CHAN_COUNT) {
831833
return -EINVAL;
832834
}
833835

836+
ret = pm_device_state_get(dev, &pm_state);
837+
if (!ret && pm_state != PM_DEVICE_STATE_ACTIVE) {
838+
return -EINVAL;
839+
}
840+
834841
chan_data = &dev_data->chan[channel];
835842

836843
if (chan_data->direction == MEMORY_TO_MEMORY ||

0 commit comments

Comments
 (0)