Skip to content

Commit ed53604

Browse files
Fabrice GasnierADESTM
authored andcommitted
iio: adc: stm32-adc: fix runtime autosuspend delay when slow polling
When the ADC is runtime suspended and starting a conversion, the stm32-adc driver calls pm_runtime_get_sync() that gets cascaded to the parent (e.g. runtime resume of stm32-adc-core driver). This also kicks the autosuspend delay (e.g. 2s) of the parent. Once the ADC is active, calling pm_runtime_get_sync() won't kick again the autosuspend delay for the parent (stm32-adc-core driver) as already active. Currently, this makes the stm32-adc-core driver go in suspend state every 2s when doing slow polling. As an example, cat in_voltageY_raw at 0.2s rate), the auto suspend delay for the parent isn't refreshed. Once it expires, the parent immediately falls into runtime suspended state, in between two captures. It switches off regulators and so on. They get switched back on again 0.2s later. So, add an explicit call to pm_runtime_mark_last_busy() for the parent driver (stm32-adc-core), synchronously with the child driver (stm32-adc). Fixes: 9bdbb11 ("iio: adc: stm32-adc: add power management support") Change-Id: I0bf0a9dafa58cea76f329372d5575ae02bc85888 Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/linux-stm32/+/155457 Reviewed-by: CITOOLS <smet-aci-reviews@lists.codex.cro.st.com> Reviewed-by: CIBUILD <smet-aci-builds@lists.codex.cro.st.com> Reviewed-by: Olivier MOYSAN <olivier.moysan@st.com>
1 parent 6c809e3 commit ed53604

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/iio/adc/stm32-adc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,7 @@ static int stm32_adc_single_conv(struct iio_dev *indio_dev,
16411641

16421642
stm32_adc_conv_irq_disable(adc);
16431643

1644+
pm_runtime_mark_last_busy(dev->parent);
16441645
pm_runtime_mark_last_busy(dev);
16451646
pm_runtime_put_autosuspend(dev);
16461647

@@ -1858,6 +1859,7 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
18581859
adc->num_conv = bitmap_weight(scan_mask, indio_dev->masklength);
18591860

18601861
ret = stm32_adc_conf_scan_seq(indio_dev, scan_mask);
1862+
pm_runtime_mark_last_busy(dev->parent);
18611863
pm_runtime_mark_last_busy(dev);
18621864
pm_runtime_put_autosuspend(dev);
18631865

@@ -2053,6 +2055,7 @@ static int stm32_adc_debugfs_reg_access(struct iio_dev *indio_dev,
20532055
else
20542056
*readval = stm32_adc_readl(adc, reg);
20552057

2058+
pm_runtime_mark_last_busy(dev->parent);
20562059
pm_runtime_mark_last_busy(dev);
20572060
pm_runtime_put_autosuspend(dev);
20582061

@@ -2210,6 +2213,7 @@ static int __stm32_adc_buffer_postenable(struct iio_dev *indio_dev)
22102213
err_clr_awd:
22112214
stm32_adc_awd_clear(adc);
22122215
err_pm_put:
2216+
pm_runtime_mark_last_busy(dev->parent);
22132217
pm_runtime_mark_last_busy(dev);
22142218
pm_runtime_put_autosuspend(dev);
22152219

@@ -2252,6 +2256,7 @@ static void __stm32_adc_buffer_predisable(struct iio_dev *indio_dev)
22522256

22532257
stm32_adc_awd_clear(adc);
22542258

2259+
pm_runtime_mark_last_busy(dev->parent);
22552260
pm_runtime_mark_last_busy(dev);
22562261
pm_runtime_put_autosuspend(dev);
22572262
}
@@ -2663,6 +2668,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
26632668
goto err_hw_stop;
26642669
}
26652670

2671+
pm_runtime_mark_last_busy(dev->parent);
26662672
pm_runtime_mark_last_busy(dev);
26672673
pm_runtime_put_autosuspend(dev);
26682674

0 commit comments

Comments
 (0)