From: Quanyang Wang <quanyang.w...@windriver.com>

The functions "siul2_gpio_dir_in" and "siul2_gpio_free" have been
registered to be callbacks as "gc->direction_input" and "gc->free".
When the callbacks "irq_chip->irq_set_type/irq_unmask/irq_mask"
are called, the caller should guarantee that it will call
gc->direction_input and gc->free explicitly instead of counting on
irq_set_type/irq_unmask/irq_mask to do this. So let's remove calling
of the callbacks from callbacks to avoid calling them multiple times.

This patch fixes the calltrace as below:

[ 904.363150] BUG: sleeping function called from invalid context at 
kernel/locking/rtmutex_api.c:510
[ 904.363174] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 1246, 
name: gpiomon
[ 904.363181] preempt_count: 1, expected: 0
[ 904.363186] RCU nest depth: 0, expected: 0
[ 904.363190] 2 locks held by gpiomon/1246:
[ 904.363195] #0: ffffff8812162ac8 (request_class){..}-{3:3}, at: 
__setup_irq+0xbc/0x754
[ 904.363232] #1: ffffff8812162900 (lock_class){....}-{2:2}, at: 
_raw_spin_lock_irqsave+0x1c/0x30
[ 904.363256] irq event stamp: 23554
[ 904.363259] hardirqs last enabled at (23553): [<ffffffc008ff4ae8>] 
_raw_spin_unlock_irqrestore+0xb8/0xe0
[ 904.363270] hardirqs last disabled at (23554): [<ffffffc0080cf878>] 
__raw_spin_lock_irqsave+0x114/0x15c
[ 904.363283] softirqs last enabled at (15992): [<ffffffc008051a04>] 
__local_bh_enable_ip+0xa4/0x2a0
[ 904.363297] softirqs last disabled at (15980): [<ffffffc008d1e93c>] 
release_sock+0xc/0x100
[ 904.363311] Preemption disabled at:
[ 904.363314] [<ffffffc0080cf7a0>] __raw_spin_lock_irqsave+0x3c/0x15c
[ 904.363329] CPU: 2 PID: 1246 Comm: gpiomon Not tainted 
5.15.58-rt48-yocto-preempt-rt #1
[ 904.363339] Hardware name: Aptiv S32G274 CVC (DT)
[ 904.363343] Call trace:
[ 904.363346] dump_backtrace+0x0/0x1b4
[ 904.363354] show_stack+0x24/0x30
[ 904.363361] dump_stack_lvl+0xb0/0xf4
[ 904.363371] dump_stack+0x18/0x34
[ 904.363378] __might_resched+0x18c/0x22c
[ 904.363389] __might_sleep+0x54/0x90
[ 904.363396] mutex_lock_nested+0x5c/0xd0
[ 904.363406] pinctrl_get_device_gpio_range+0x48/0x120
[ 904.363418] pinctrl_gpio_direction+0x40/0xd0
[ 904.363426] pinctrl_gpio_direction_input+0x20/0x30
[ 904.363434] siul2_gpio_dir_in+0x34/0x90
[ 904.363443] siul2_gpio_irq_set_type+0x40/0x1a4
[ 904.363450] __irq_set_trigger+0x6c/0x190
[ 904.363456] __setup_irq+0x2b8/0x754
[ 904.363462] request_threaded_irq+0xf8/0x1bc
[ 904.363469] lineevent_create+0x294/0x3e0
[ 904.363480] gpio_ioctl+0x31c/0x3a0
[ 904.363489] __arm64_sys_ioctl+0xb4/0xfc
[ 904.363500] invoke_syscall+0x5c/0x130
[ 904.363511] el0_svc_common.constprop.0+0x68/0x124
[ 904.363520] do_el0_svc+0x50/0xbc
[ 904.363529] el0_svc+0x54/0x130
[ 904.363536] el0t_64_sync_handler+0xa4/0x130
[ 904.363544] el0t_64_sync+0x1a0/0x1a4

Upstream-Status: Pending

Signed-off-by: Quanyang Wang <quanyang.w...@windriver.com>
---
 drivers/gpio/gpio-siul2-s32cc.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/drivers/gpio/gpio-siul2-s32cc.c b/drivers/gpio/gpio-siul2-s32cc.c
index a903a29776199..241d75cbe9149 100644
--- a/drivers/gpio/gpio-siul2-s32cc.c
+++ b/drivers/gpio/gpio-siul2-s32cc.c
@@ -358,13 +358,6 @@ static int siul2_gpio_irq_set_type(struct irq_data *d, 
unsigned int type)
        int ret = 0;
        u32 mask;
 
-       ret = siul2_gpio_dir_in(gc, gpio);
-       if (ret) {
-               dev_err(gc->parent, "Failed to configure GPIO %d as input\n",
-                       gpio);
-               return ret;
-       }
-
        /* SIUL2 GPIO doesn't support level triggering */
        if ((irq_type & IRQ_TYPE_LEVEL_HIGH)
            || (irq_type & IRQ_TYPE_LEVEL_LOW)) {
@@ -455,7 +448,6 @@ static void siul2_gpio_irq_unmask(struct irq_data *data)
        int index = siul2_irq_gpio_index(platdata, gpio);
        unsigned long flags;
        u32 mask;
-       int ret;
 
        if (index < 0)
                return;
@@ -484,13 +476,6 @@ static void siul2_gpio_irq_unmask(struct irq_data *data)
        regmap_write(gpio_dev->eirqimcrsmap,
                     SIUL2_EIRQ_REG(platdata->irqs[index].eirq),
                     platdata->irqs[index].imscr_conf);
-
-       /* Configure GPIO as input */
-       ret = siul2_gpio_dir_in(gc, gpio);
-       if (ret) {
-               dev_err(gc->parent, "Failed to configure GPIO %d as input\n",
-                       ret);
-       }
 }
 
 static void siul2_gpio_irq_mask(struct irq_data *data)
@@ -527,8 +512,6 @@ static void siul2_gpio_irq_mask(struct irq_data *data)
        regmap_write(gpio_dev->eirqimcrsmap,
                     SIUL2_EIRQ_REG(platdata->irqs[index].eirq),
                     0);
-
-       siul2_gpio_free(gc, gpio);
 }
 
 static const struct regmap_config siul2_regmap_conf = {
-- 
2.36.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#11575): 
https://lists.yoctoproject.org/g/linux-yocto/message/11575
Mute This Topic: https://lists.yoctoproject.org/mt/93099871/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to