All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-gpio@vger.kernel.org, Lee Jones <lee.jones@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Peter Griffin <peter.griffin@linaro.org>
Subject: Re: [bug report] tty: st-asc: switch to using devm_gpiod_get()
Date: Sat, 14 Aug 2021 17:15:14 -0700	[thread overview]
Message-ID: <YRhckpqbyqQh1Jtc@google.com> (raw)
In-Reply-To: <20210813124155.GA7367@kili>

Hi Dan,

On Fri, Aug 13, 2021 at 03:41:55PM +0300, Dan Carpenter wrote:
> Hello Dmitry Torokhov,
> 
> The patch 8c44f9b566a3: "tty: st-asc: switch to using
> devm_gpiod_get()" from Jan 4, 2020, leads to the following
> Smatch static checker warning:
> 
> 	drivers/gpio/gpiolib.c:3066 gpiod_set_consumer_name()
> 	warn: sleeping in atomic context
> 
> drivers/gpio/gpiolib.c
>     3062 int gpiod_set_consumer_name(struct gpio_desc *desc, const char *name)
>     3063 {
>     3064 	VALIDATE_DESC(desc);
>     3065 	if (name) {
> --> 3066 		name = kstrdup_const(name, GFP_KERNEL);
> 
> asc_set_termios() <- disables preempt
> -> gpiod_set_consumer_name()
> 
>     3067 		if (!name)
>     3068 			return -ENOMEM;
>     3069 	}
>     3070 
>     3071 	kfree_const(desc->label);
>     3072 	desc_set_label(desc, name);
>     3073 
>     3074 	return 0;
>     3075 }

Thank you for the bug report, but that is not the offending commit, as
it simply swapped one devm_* call for another, and devres_alloc() that
is being used in almost all devm calls, including the ones in this
particular case, uses GFP_KERNEL allocation.

The problem originally comes from:

commit d7356256488c544b8fdc2c3a775ce069546d7933
Author: Lee Jones <lee.jones@linaro.org>
Date:   Fri Feb 3 10:23:13 2017 +0000

    serial: st-asc: (De)Register GPIOD and swap Pinctrl profiles

    When hardware flow-control is disabled, manual toggling of the UART's
    reset line (RTS) using userland applications (e.g. stty) is not
    possible, since the ASC IP does not provide this functionality in the
    same was as some other IPs do.  Thus, we have to do this manually.

    This patch ensures that when HW flow-control is disabled the RTS/CTS
    lines are free to be registered via the GPIO API.  It also ensures
    any registered GPIO lines are unregistered when HW flow-control is
    requested, allowing the IP to control them automatically.

    Acked-by: Peter Griffin <peter.griffin@linaro.org>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

that added the problematic devm use under spinlock; I'll leave it to Lee
and Greg to sort this out.

Thanks.

-- 
Dmitry

  reply	other threads:[~2021-08-15  0:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 12:41 [bug report] tty: st-asc: switch to using devm_gpiod_get() Dan Carpenter
2021-08-15  0:15 ` Dmitry Torokhov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-10-26 14:05 Dan Carpenter
2022-10-26 17:33 ` Dmitry Torokhov

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=YRhckpqbyqQh1Jtc@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=peter.griffin@linaro.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.