[linux-yocto][v5.15/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g][PATCH 2/3] gpio: s32: switch the spinlock of siul2_gpio_dev to raw spinlock

2023-04-08 Thread quanyang.wang
From: Quanyang Wang 

The irq functions "siul2_gpio_irq_unmask" and "siul2_gpio_irq_mask"
use spin_lock in preempt-rt kernel, it will cause the error that
calling a sleeping function in an atomic context.

Use raw spinlock to fix this issue.

Signed-off-by: Quanyang Wang 
---
 drivers/gpio/gpio-siul2-s32cc.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-siul2-s32cc.c b/drivers/gpio/gpio-siul2-s32cc.c
index d93704af3eefa..3011ff5ab662b 100644
--- a/drivers/gpio/gpio-siul2-s32cc.c
+++ b/drivers/gpio/gpio-siul2-s32cc.c
@@ -156,7 +156,7 @@ struct siul2_gpio_dev {
struct irq_chip irq;
 
/* Mutual access to SIUL2 registers. */
-   spinlock_t lock;
+   raw_spinlock_t lock;
 };
 
 /* We will use the following variable names:
@@ -208,14 +208,14 @@ static inline void gpio_set_direction(struct 
siul2_gpio_dev *dev, int gpio,
 {
unsigned long flags;
 
-   spin_lock_irqsave(&dev->lock, flags);
+   raw_spin_lock_irqsave(&dev->lock, flags);
 
if (dir == IN)
bitmap_clear(dev->pin_dir_bitmap, gpio, 1);
else
bitmap_set(dev->pin_dir_bitmap, gpio, 1);
 
-   spin_unlock_irqrestore(&dev->lock, flags);
+   raw_spin_unlock_irqrestore(&dev->lock, flags);
 }
 
 static inline enum gpio_dir gpio_get_direction(struct siul2_gpio_dev *dev,
@@ -490,9 +490,9 @@ static void siul2_gpio_irq_unmask(struct irq_data *data)
/* Enable Interrupt */
regmap_update_bits(gpio_dev->irqmap, SIUL2_DIRER0, mask, mask);
 
-   spin_lock_irqsave(&gpio_dev->lock, flags);
+   raw_spin_lock_irqsave(&gpio_dev->lock, flags);
bitmap_set(&gpio_dev->eirqs_bitmap, platdata->irqs[index].eirq, 1);
-   spin_unlock_irqrestore(&gpio_dev->lock, flags);
+   raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
 
/* Set IMCR */
regmap_write(gpio_dev->eirqimcrsmap,
@@ -534,9 +534,9 @@ static void siul2_gpio_irq_mask(struct irq_data *data)
/* Clean status flag */
regmap_update_bits(gpio_dev->irqmap, SIUL2_DISR0, mask, mask);
 
-   spin_lock_irqsave(&gpio_dev->lock, flags);
+   raw_spin_lock_irqsave(&gpio_dev->lock, flags);
bitmap_clear(&gpio_dev->eirqs_bitmap, platdata->irqs[index].eirq, 1);
-   spin_unlock_irqrestore(&gpio_dev->lock, flags);
+   raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
 
regmap_write(gpio_dev->eirqimcrsmap,
 SIUL2_EIRQ_REG(platdata->irqs[index].eirq),
@@ -1154,7 +1154,7 @@ static int siul2_gpio_probe(struct platform_device *pdev)
 
platform_set_drvdata(pdev, gpio_dev);
 
-   spin_lock_init(&gpio_dev->lock);
+   raw_spin_lock_init(&gpio_dev->lock);
 
for (i = 0; i < ARRAY_SIZE(gpio_dev->siul2); ++i) {
err = siul2_get_gpio_pinspec(pdev, &pinspec, i);
-- 
2.36.1


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



[linux-yocto][v5.15/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g][PATCH 3/3] gpio: s32: don't run callbacks in some callbacks

2023-04-08 Thread quanyang.wang
From: Quanyang Wang 

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: ff8812162ac8 (request_class){..}-{3:3}, at: 
__setup_irq+0xbc/0x754
[ 904.363232] #1: ff8812162900 (lock_class){}-{2:2}, at: 
_raw_spin_lock_irqsave+0x1c/0x30
[ 904.363256] irq event stamp: 23554
[ 904.363259] hardirqs last enabled at (23553): [] 
_raw_spin_unlock_irqrestore+0xb8/0xe0
[ 904.363270] hardirqs last disabled at (23554): [] 
__raw_spin_lock_irqsave+0x114/0x15c
[ 904.363283] softirqs last enabled at (15992): [] 
__local_bh_enable_ip+0xa4/0x2a0
[ 904.363297] softirqs last disabled at (15980): [] 
release_sock+0xc/0x100
[ 904.363311] Preemption disabled at:
[ 904.363314] [] __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

Signed-off-by: Quanyang Wang 
---
 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 3011ff5ab662b..668eab91859f2 100644
--- a/drivers/gpio/gpio-siul2-s32cc.c
+++ b/drivers/gpio/gpio-siul2-s32cc.c
@@ -372,13 +372,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 %lu 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)) {
@@ -469,7 +462,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;
@@ -498,13 +490,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)
@@ -541,8 +526,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 (#12359): 
https://lists.yoctoproject.org/g/linux-yocto/message/12359
Mute This Topic: https://lists.yoctoproject.org/mt/98152529/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=

[linux-yocto][v5.15/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g][PATCH 0/3]

2023-04-08 Thread quanyang.wang
From: Quanyang Wang 

Hi Bruce,
Would you please help merge these 3 patches to the branches:
v5.15/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g
v5.15/standard/nxp-sdk-5.15/nxp-s32g
Thanks,
Quanyang

Quanyang Wang (3):
  gpio: s32: force regmap use raw spinlock
  gpio: s32: switch the spinlock of siul2_gpio_dev to raw spinlock
  gpio: s32: don't run callbacks in some callbacks

 drivers/gpio/gpio-siul2-s32cc.c | 34 +
 1 file changed, 9 insertions(+), 25 deletions(-)

-- 
2.36.1


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



[linux-yocto][v5.15/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g][PATCH 1/3] gpio: s32: force regmap use raw spinlock

2023-04-08 Thread quanyang.wang
From: Quanyang Wang 

The regmap subsystem use mutex lock as its default lock but this will
cause the error that calling sleeping functions in an atomic context
since the irq callbacks "irq_set_type/irq_mask/irq_unmask" for
siul2-s32cc are all using regmap_update_bits.

Add use_raw_spinlock flag to the regmap_config structure siul2_regmap_conf
can switch mutex lock to raw spinlock.

Signed-off-by: Quanyang Wang 
---
 drivers/gpio/gpio-siul2-s32cc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpio-siul2-s32cc.c b/drivers/gpio/gpio-siul2-s32cc.c
index e41bc337921ab..d93704af3eefa 100644
--- a/drivers/gpio/gpio-siul2-s32cc.c
+++ b/drivers/gpio/gpio-siul2-s32cc.c
@@ -550,6 +550,7 @@ static const struct regmap_config siul2_regmap_conf = {
.reg_bits = 32,
.reg_stride = 4,
.cache_type = REGCACHE_FLAT,
+   .use_raw_spinlock = true,
 };
 
 static struct regmap *common_regmap_init(struct platform_device *pdev,
-- 
2.36.1


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



[linux-yocto] Reading file would overwrite reserved memory. Failed to load 'hello_world.bin - imx7d-pico - Uboot 2022.04 #address-cells

2023-04-08 Thread Neuber Sousa
https://stackoverflow.com/questions/71073386/reading-file-would-overwrite-reserved-memory-failed-to-load-hello-world-bin

Hi,

I had this issue last year and I solved it via device tree. However, I used 
Yocto hardknott and uboot 2021.04 and Ubuntu 20.04. Now I use Yocto kirkstone 
and uboot 2022.04 and Ubuntu 22.04

I've been trying to resolve this issue for seven days now. I've already made 
several changes to the uboot and yocto/device tree configurations without 
success.

Every help is welcome

Note:

https://dantechrb.com/blog/how-to-build-and-debug-freertos-applications-for-cortexm4-on-mx6sx

https://whycan.com/t_5474.html

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