lkml.org 
[lkml]   [2023]   [Aug]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 3/4] pwm: imx27: verify decreasing PWM FIFO av value
Date
Avoid unnecessary sleeps as adviced[0], if the FIFO cannot be emptied.

[0] https://lore.kernel.org/lkml/20230310174517.rb7xxrougkse2lrc@pengutronix.de/T/#ec9560c1f613d9c0d7b77d72ad9051768812f80db

Signed-off-by: Leif Middelschulte <Leif.Middelschulte@gmail.com>
---
drivers/pwm/pwm-imx27.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-imx27.c b/drivers/pwm/pwm-imx27.c
index c2a1e2030072..9673e809d212 100644
--- a/drivers/pwm/pwm-imx27.c
+++ b/drivers/pwm/pwm-imx27.c
@@ -126,7 +126,7 @@ static int pwm_imx27_wait_fifo_empty(struct pwm_chip *chip,
struct device *dev = chip->dev;
unsigned int period_ms = DIV_ROUND_UP_ULL(pwm->state.period, NSEC_PER_MSEC);
int tries = MX3_PWM_FIFOAV_EMPTY_LOOP;
- int fifoav;
+ int fifoav, previous_fifoav = INT_MAX;
u32 sr;

while (tries--) {
@@ -134,6 +134,10 @@ static int pwm_imx27_wait_fifo_empty(struct pwm_chip *chip,
fifoav = FIELD_GET(MX3_PWMSR_FIFOAV, sr);
if (fifoav == MX3_PWMSR_FIFOAV_EMPTY)
return;
+ /* if the FIFO value does not decrease, there is another problem */
+ if (previous_fifoav == fifoav)
+ break;
+ previous_fifoav = fifoav;
msleep(period_ms);
}
dev_warn(dev, "FIFO has been refilled concurrently\n");
--
2.39.2 (Apple Git-143)
\
 
 \ /
  Last update: 2023-08-15 12:45    [W:0.250 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site