From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Douglas Anderson <dianders@chromium.org>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
linux-arm-msm@vger.kernel.org,
"John Ogness" <john.ogness@linutronix.de>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Tony Lindgren" <tony@atomide.com>,
"Stephen Boyd" <swboyd@chromium.org>,
linux-serial@vger.kernel.org,
"Yicong Yang" <yangyicong@hisilicon.com>,
"Johan Hovold" <johan+linaro@kernel.org>,
linux-kernel@vger.kernel.org,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konrad.dybcio@linaro.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Vijaya Krishna Nivarthi" <quic_vnivarth@quicinc.com>
Subject: Re: [PATCH v2 2/7] serial: qcom-geni: Fix the timeout in qcom_geni_serial_poll_bit()
Date: Fri, 31 May 2024 11:34:03 +0300 [thread overview]
Message-ID: <ZlmLe4d10TrnoyjQ@smile.fi.intel.com> (raw)
In-Reply-To: <20240530154553.v2.2.I3e1968bbeee67e28fd4e15509950805b6665484a@changeid>
On Thu, May 30, 2024 at 03:45:54PM -0700, Douglas Anderson wrote:
> The qcom_geni_serial_poll_bit() is supposed to be able to be used to
> poll a bit that's will become set when a TX transfer finishes. Because
> of this it tries to set its timeout based on how long the UART will
> take to shift out all of the queued bytes. There are two problems
> here:
> 1. There appears to be a hidden extra word on the firmware side which
> is the word that the firmware has already taken out of the FIFO and
> is currently shifting out. We need to account for this.
> 2. The timeout calculation was assuming that it would only need 8 bits
> on the wire to shift out 1 byte. This isn't true. Typically 10 bits
> are used (8 data bits, 1 start and 1 stop bit), but as much as 13
> bits could be used (14 if we allowed 9 bits per byte, which we
> don't).
>
> The too-short timeout was seen causing problems in a future patch
> which more properly waited for bytes to transfer out of the UART
> before cancelling.
...
> + /*
> + * Add 1 to tx_fifo_depth to account for the hidden register
> + * on the firmware side that can hold a word.
> + */
> + max_queued_bytes =
> + DIV_ROUND_UP((port->tx_fifo_depth + 1) * port->tx_fifo_width,
> + BITS_PER_BYTE);
BITS_TO_BYTES()
...
> - timeout_us = ((fifo_bits * USEC_PER_SEC) / baud) + 500;
> + timeout_us = ((max_queued_bits * USEC_PER_SEC) / baud) + 500;
Too many parentheses. (The outer ones can be dropped.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2024-05-31 8:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-30 22:45 [PATCH v2 0/7] serial: qcom-geni: Overhaul TX handling to fix crashes/hangs Douglas Anderson
2024-05-30 22:45 ` [PATCH v2 1/7] soc: qcom: geni-se: Add GP_LENGTH/IRQ_EN_SET/IRQ_EN_CLEAR registers Douglas Anderson
2024-06-02 4:23 ` Bjorn Andersson
2024-05-30 22:45 ` [PATCH v2 2/7] serial: qcom-geni: Fix the timeout in qcom_geni_serial_poll_bit() Douglas Anderson
2024-05-31 8:34 ` Andy Shevchenko [this message]
2024-05-31 14:57 ` Ilpo Järvinen
2024-05-30 22:45 ` [PATCH v2 3/7] serial: qcom-geni: Fix arg types for qcom_geni_serial_poll_bit() Douglas Anderson
2024-05-30 22:45 ` [PATCH v2 4/7] serial: qcom-geni: Introduce qcom_geni_serial_poll_bitfield() Douglas Anderson
2024-05-30 22:45 ` [PATCH v2 5/7] serial: qcom-geni: Just set the watermark level once Douglas Anderson
2024-05-30 22:45 ` [PATCH v2 6/7] serial: qcom-geni: Fix suspend while active UART xfer Douglas Anderson
2024-05-31 8:36 ` Andy Shevchenko
2024-05-31 15:13 ` Ilpo Järvinen
2024-06-04 16:03 ` Doug Anderson
2024-05-30 22:45 ` [PATCH v2 7/7] serial: qcom-geni: Rework TX in FIFO mode to fix hangs/lockups Douglas Anderson
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=ZlmLe4d10TrnoyjQ@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=andersson@kernel.org \
--cc=dianders@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=johan+linaro@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=quic_vnivarth@quicinc.com \
--cc=swboyd@chromium.org \
--cc=tglx@linutronix.de \
--cc=tony@atomide.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=yangyicong@hisilicon.com \
/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