tty: st-asc: switch to using devm_gpiod_get()
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 }regards,
dan carpenter
Dmitry Torokhov
Acked-by Peter GriffinHi Dan,
Quoted 19 lines · Dan Carpenter
Hello Dmitry Torokhov,
The patch
8c44f9b566a3: "tty: st-asc: switch to usingdevm_gpiod_get()" from Jan 4, 2020, leads to the following Smatch static checker warning:
drivers/gpio/gpiolib.c:3066gpiod_set_consumer_name()
warn: sleeping in atomic context
drivers/gpio/gpiolib.c3062 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()
Quoted 9 lines
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 <[email protected]> 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.
that added the problematic devm use under spinlock; I'll leave it to Lee and Greg to sort this out.
Thanks.
Signature · 1 line
Dmitry