Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Antonio Borneo <antonio.borneo@foss.st.com>
To: Ju Nan <junan76@163.com>, <linusw@kernel.org>,
	<mcoquelin.stm32@gmail.com>, <alexandre.torgue@foss.st.com>
Cc: <linux-gpio@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pinctrl: stm32: fix the unit of the hwspinlock timeout
Date: Fri, 21 Aug 2026 11:22:25 +0200	[thread overview]
Message-ID: <9b0f76a08a7c1dbaec4684b4bc013263e0149a4b.camel@foss.st.com> (raw)
In-Reply-To: <20260805032843.36961-2-junan76@163.com>

On Wed, 2026-08-05 at 11:28 +0800, Ju Nan wrote:
> HWSPNLCK_TIMEOUT is passed to hwspin_lock_timeout_in_atomic(), whose
> timeout argument is in milliseconds, not microseconds:
> 
>   atomic_delay += HWSPINLOCK_RETRY_DELAY_US;
>   if (atomic_delay > to * 1000)
>           return -ETIMEDOUT;
> 
> So the driver asks for a 1 second timeout where the comment next to the
> macro says it wants 1 millisecond.
> 
> The hwspinlock core documents this explicitly:
> 
>   If the mode is HWLOCK_IN_ATOMIC (called from an atomic context) the
>   timeout is handled with busy-waiting delays, hence shall not exceed
>   few msecs.
> 
> Pass the value the comment always described. The core retries every
> HWSPINLOCK_RETRY_DELAY_US (100 us), so the semaphore is still polled ten
> times before giving up, which is far longer than any plausible hold time
> on the coprocessor side. A timeout is reported with dev_err() and fails
> the pin configuration or the interrupt allocation, so shortening it
> degrades gracefully.
> 
> Signed-off-by: Ju Nan <junan76@163.com>

Please add
Fixes: 290a9f937e5a ("pinctrl: stm32: use the hwspin_lock_timeout_in_atomic() API")

> ---
>  drivers/pinctrl/stm32/pinctrl-stm32.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
> index 6a99708a5..dbc9143ec 100644
> --- a/drivers/pinctrl/stm32/pinctrl-stm32.c
> +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
> @@ -87,7 +87,7 @@
>  #define gpio_range_to_bank(chip) \
>                 container_of(chip, struct stm32_gpio_bank, range)
>  
> -#define HWSPNLCK_TIMEOUT       1000 /* usec */
> +#define HWSPNLCK_TIMEOUT       1 /* msec */

Please change the macro name as HWSPNLCK_TIMEOUT_MS to keep track of the time units

>  
>  static const char * const stm32_gpio_functions[] = {
>         "gpio", "af0", "af1",

Thanks!
Antonio

  reply	other threads:[~2026-08-21  9:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  3:28 [PATCH] pinctrl: stm32: fix the unit of the hwspinlock timeout Ju Nan
2026-08-21  9:22 ` Antonio Borneo [this message]
2026-08-27 14:11   ` [PATCH v2] " Ju Nan

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=9b0f76a08a7c1dbaec4684b4bc013263e0149a4b.camel@foss.st.com \
    --to=antonio.borneo@foss.st.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=junan76@163.com \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.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