From: Leif Middelschulte <leif.middelschulte@gmail.com>
To: "Thierry Reding" <thierry.reding@gmail.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Shawn Guo" <shawnguo@kernel.org>,
"Sascha Hauer" <s.hauer@pengutronix.de>,
"Pengutronix Kernel Team" <kernel@pengutronix.de>,
"Fabio Estevam" <festevam@gmail.com>,
"NXP Linux Team" <linux-imx@nxp.com>
Cc: Leif Middelschulte <Leif.Middelschulte@gmail.com>,
linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v3 3/4] pwm: imx27: verify decreasing PWM FIFO av value
Date: Tue, 15 Aug 2023 12:43:31 +0200 [thread overview]
Message-ID: <20230815104332.55044-3-Leif.Middelschulte@gmail.com> (raw)
In-Reply-To: <20230815104332.55044-1-Leif.Middelschulte@gmail.com>
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)
next prev parent reply other threads:[~2023-08-15 10:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 15:03 [PATCH v2] pwm: imx27: fix race condition .apply,.get_state Leif Middelschulte
2023-03-10 17:45 ` Uwe Kleine-König
2023-08-15 10:43 ` [PATCH v3 1/4] " Leif Middelschulte
2023-08-15 10:43 ` [PATCH v3 2/4] pwm: imx27: avoid PWM consumer API Leif Middelschulte
2023-09-06 15:36 ` Uwe Kleine-König
2023-08-15 10:43 ` Leif Middelschulte [this message]
2023-08-15 10:43 ` [PATCH v3 4/4] pwm: imx27: return error, if clean PWM setup fails Leif Middelschulte
2023-09-06 15:44 ` Uwe Kleine-König
2023-09-06 15:42 ` [PATCH v3 1/4] pwm: imx27: fix race condition .apply,.get_state Uwe Kleine-König
2024-02-24 11:00 ` Leif Middelschulte
2024-02-24 11:29 ` [PATCH v4 1/2] " Leif Middelschulte
2024-02-24 11:29 ` [PATCH v4 2/2] pwm: imx27: avoid PWM consumer API Leif Middelschulte
2024-02-26 8:37 ` Uwe Kleine-König
2024-02-26 8:24 ` [PATCH v4 1/2] pwm: imx27: fix race condition .apply,.get_state Uwe Kleine-König
2024-02-26 8:44 ` Uwe Kleine-König
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230815104332.55044-3-Leif.Middelschulte@gmail.com \
--to=leif.middelschulte@gmail.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox