All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: bartosz.golaszewski@linaro.org, linux-wireless@vger.kernel.org,
	linux-input@vger.kernel.org
Subject: Re: [bug report] gpiolib: use a mutex to protect the list of GPIO devices
Date: Sat, 20 Jan 2024 13:06:03 -0800	[thread overview]
Message-ID: <Zaw1ux7eTogP-DQi@google.com> (raw)
In-Reply-To: <f7b5ff1e-8f34-4d98-a7be-b826cb897dc8@moroto.mountain>

On Mon, Jan 15, 2024 at 11:50:52AM +0300, Dan Carpenter wrote:
> Hello Bartosz Golaszewski,
> 
> The patch 65a828bab158: "gpiolib: use a mutex to protect the list of
> GPIO devices" from Dec 15, 2023 (linux-next), leads to the following
> Smatch static checker warning:
> 
> 	drivers/net/wireless/ath/ath9k/hw.c:2836 ath9k_hw_gpio_get()
> 	warn: sleeping in atomic context
> 
> drivers/net/wireless/ath/ath9k/hw.c
>     2826                         val = MS_REG_READ(AR9285, gpio);
>     2827                 else if (AR_SREV_9280(ah))
>     2828                         val = MS_REG_READ(AR928X, gpio);
>     2829                 else if (AR_DEVID_7010(ah))
>     2830                         val = REG_READ(ah, AR7010_GPIO_IN) & BIT(gpio);
>     2831                 else if (AR_SREV_9300_20_OR_LATER(ah))
>     2832                         val = REG_READ(ah, AR_GPIO_IN(ah)) & BIT(gpio);
>     2833                 else
>     2834                         val = MS_REG_READ(AR, gpio);
>     2835         } else if (BIT(gpio) & ah->caps.gpio_requested) {
> --> 2836                 val = gpio_get_value(gpio) & BIT(gpio);
>                                ^^^^^^^^^^^^^^
> 
>     2837         } else {
>     2838                 WARN_ON(1);
>     2839         }
>     2840 
>     2841         return !!val;
>     2842 }
> 
> Before gpio_get_value() took a spinlock but now it takes a mutex
> (actually a rw semaphor now).  The call tree where we are in atomic
> context is:
> 
> ath_btcoex_period_timer() <- disables preempt
> -> ath_detect_bt_priority()
>    -> ath9k_hw_gpio_get()
> 
> Another warning this change causes is:
> 
> drivers/input/keyboard/matrix_keypad.c:95 enable_row_irqs() warn: sleeping in atomic context
> matrix_keypad_scan() <- disables preempt
> -> enable_row_irqs()
> 
> drivers/input/keyboard/matrix_keypad.c:108 disable_row_irqs() warn: sleeping in atomic context
> matrix_keypad_interrupt() <- disables preempt
> -> disable_row_irqs()

Now that that operation becomes heavier we should convert row GPIOs into
interrupt numbers in probe() and then this issue will go away.

Thanks.

-- 
Dmitry

      parent reply	other threads:[~2024-01-20 21:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15  8:50 [bug report] gpiolib: use a mutex to protect the list of GPIO devices Dan Carpenter
2024-01-15  9:18 ` Bartosz Golaszewski
2024-01-20 21:06 ` Dmitry Torokhov [this message]

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=Zaw1ux7eTogP-DQi@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.