[linux-yocto][v5.15/standard/preempt-rt/sdkv5.15/xlnx-soc][PATCH 2/2] gpio: zynq: fix zynqmp_gpio not an immutable chip warning

2024-03-14 Thread quanyang.wang via lists.yoctoproject.org
From: Manikanta Guntupalli 

commit f5691439353783ef114876849c70d2a641e09498 upstream

Make the struct irq_chip const and flag it as IRQCHIP_IMMUTABLE,
call gpiochip_disable_irq() in the .irq_mask() callback and
gpiochip_enable_irq() in the .irq_unmask() callback to fix
"gpio gpiochip1: (zynqmp_gpio): not an immutable chip" warning.

Signed-off-by: Manikanta Guntupalli 
Reviewed-by: Linus Walleij 
Signed-off-by: Bartosz Golaszewski 
[Quanyang: drop GPIOCHIP_IRQ_RESOURCE_HELPERS and
gpio_irq_chip_set_chip.]
Signed-off-by: Quanyang Wang 
---
 drivers/gpio/gpio-zynq.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index 06c6401f02b89..ca808c8d2d15a 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -404,9 +404,12 @@ static int zynq_gpio_get_direction(struct gpio_chip *chip, 
unsigned int pin)
 static void zynq_gpio_irq_mask(struct irq_data *irq_data)
 {
unsigned int device_pin_num, bank_num, bank_pin_num;
+   const unsigned long offset = irqd_to_hwirq(irq_data);
+   struct gpio_chip *chip = irq_data_get_irq_chip_data(irq_data);
struct zynq_gpio *gpio =
gpiochip_get_data(irq_data_get_irq_chip_data(irq_data));
 
+   gpiochip_disable_irq(chip, offset);
device_pin_num = irq_data->hwirq;
zynq_gpio_get_bank_pin(device_pin_num, _num, _pin_num, gpio);
writel_relaxed(BIT(bank_pin_num),
@@ -425,9 +428,12 @@ static void zynq_gpio_irq_mask(struct irq_data *irq_data)
 static void zynq_gpio_irq_unmask(struct irq_data *irq_data)
 {
unsigned int device_pin_num, bank_num, bank_pin_num;
+   const unsigned long offset = irqd_to_hwirq(irq_data);
+   struct gpio_chip *chip = irq_data_get_irq_chip_data(irq_data);
struct zynq_gpio *gpio =
gpiochip_get_data(irq_data_get_irq_chip_data(irq_data));
 
+   gpiochip_enable_irq(chip, offset);
device_pin_num = irq_data->hwirq;
zynq_gpio_get_bank_pin(device_pin_num, _num, _pin_num, gpio);
writel_relaxed(BIT(bank_pin_num),
@@ -601,7 +607,7 @@ static struct irq_chip zynq_gpio_level_irqchip = {
.irq_request_resources = zynq_gpio_irq_reqres,
.irq_release_resources = zynq_gpio_irq_relres,
.flags  = IRQCHIP_EOI_THREADED | IRQCHIP_EOI_IF_HANDLED |
- IRQCHIP_MASK_ON_SUSPEND,
+ IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE,
 };
 
 static struct irq_chip zynq_gpio_edge_irqchip = {
@@ -614,7 +620,7 @@ static struct irq_chip zynq_gpio_edge_irqchip = {
.irq_set_wake   = zynq_gpio_set_wake,
.irq_request_resources = zynq_gpio_irq_reqres,
.irq_release_resources = zynq_gpio_irq_relres,
-   .flags  = IRQCHIP_MASK_ON_SUSPEND,
+   .flags  = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_IMMUTABLE,
 };
 
 static void zynq_gpio_handle_bank_irq(struct zynq_gpio *gpio,
@@ -962,7 +968,7 @@ static int zynq_gpio_probe(struct platform_device *pdev)
 
/* Set up the GPIO irqchip */
girq = >irq;
-   girq->chip = _gpio_edge_irqchip;
+   girq->chip = (struct irq_chip *)_gpio_edge_irqchip;
girq->parent_handler = zynq_gpio_irqhandler;
girq->num_parents = 1;
girq->parents = devm_kcalloc(>dev, 1,
-- 
2.36.1


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#13689): 
https://lists.yoctoproject.org/g/linux-yocto/message/13689
Mute This Topic: https://lists.yoctoproject.org/mt/104942023/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/sdkv5.15/xlnx-soc][PATCH 0/2]

2024-03-14 Thread quanyang.wang via lists.yoctoproject.org
From: Quanyang Wang 

Hi Bruce,
Would you please help merge these 2 patches to the branches:
v5.15/standard/preempt-rt/sdkv5.15/xlnx-soc
v5.15/standard/sdkv5.15/xlnx-soc
Thanks,
Quanyang


Manikanta Guntupalli (1):
  gpio: zynq: fix zynqmp_gpio not an immutable chip warning

Marc Zyngier (1):
  gpio: Don't fiddle with irqchips marked as immutable

 drivers/gpio/gpio-zynq.c | 12 +---
 drivers/gpio/gpiolib.c   |  7 ++-
 include/linux/irq.h  |  2 ++
 kernel/irq/debugfs.c |  1 +
 4 files changed, 18 insertions(+), 4 deletions(-)

-- 
2.36.1


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#13687): 
https://lists.yoctoproject.org/g/linux-yocto/message/13687
Mute This Topic: https://lists.yoctoproject.org/mt/104942021/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/sdkv5.15/xlnx-soc][PATCH 1/2] gpio: Don't fiddle with irqchips marked as immutable

2024-03-14 Thread quanyang.wang via lists.yoctoproject.org
From: Marc Zyngier 

commit 6c846d026d490b2383d395bc8e7b06336219667b upstream

In order to move away from gpiolib messing with the internals of
unsuspecting irqchips, add a flag by which irqchips advertise
that they are not to be messed with, and do solemnly swear that
they correctly call into the gpiolib helpers when required.

Also nudge the users into converting their drivers to the
new model.

Reviewed-by: Andy Shevchenko 
Reviewed-by: Bartosz Golaszewski 
Signed-off-by: Marc Zyngier 
Link: https://lore.kernel.org/r/20220419141846.598305-2-...@kernel.org
---
 drivers/gpio/gpiolib.c | 7 ++-
 include/linux/irq.h| 2 ++
 kernel/irq/debugfs.c   | 1 +
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 34a061b4becdb..bf77c3f5a4e56 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1483,6 +1483,11 @@ static void gpiochip_set_irq_hooks(struct gpio_chip *gc)
 {
struct irq_chip *irqchip = gc->irq.chip;
 
+   if (irqchip->flags & IRQCHIP_IMMUTABLE)
+   return;
+
+   chip_warn(gc, "not an immutable chip, please consider fixing it!\n");
+
if (!irqchip->irq_request_resources &&
!irqchip->irq_release_resources) {
irqchip->irq_request_resources = gpiochip_irq_reqres;
@@ -1650,7 +1655,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gc)
irq_domain_remove(gc->irq.domain);
}
 
-   if (irqchip) {
+   if (irqchip && !(irqchip->flags & IRQCHIP_IMMUTABLE)) {
if (irqchip->irq_request_resources == gpiochip_irq_reqres) {
irqchip->irq_request_resources = NULL;
irqchip->irq_release_resources = NULL;
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 83d2fd4dc876b..f52ccfad9b88b 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -570,6 +570,7 @@ struct irq_chip {
  * IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND:  Invokes __enable_irq()/__disable_irq() 
for wake irqs
  *in the suspend path if they are in 
disabled state
  * IRQCHIP_AFFINITY_PRE_STARTUP:  Default affinity update before startup
+ * IRQCHIP_IMMUTABLE:Don't ever change anything in this chip
  */
 enum {
IRQCHIP_SET_TYPE_MASKED = (1 <<  0),
@@ -583,6 +584,7 @@ enum {
IRQCHIP_SUPPORTS_NMI= (1 <<  8),
IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND= (1 <<  9),
IRQCHIP_AFFINITY_PRE_STARTUP= (1 << 10),
+   IRQCHIP_IMMUTABLE   = (1 << 11),
 };
 
 #include 
diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
index e4cff358b437e..7ff52d94b42c0 100644
--- a/kernel/irq/debugfs.c
+++ b/kernel/irq/debugfs.c
@@ -58,6 +58,7 @@ static const struct irq_bit_descr irqchip_flags[] = {
BIT_MASK_DESCR(IRQCHIP_SUPPORTS_LEVEL_MSI),
BIT_MASK_DESCR(IRQCHIP_SUPPORTS_NMI),
BIT_MASK_DESCR(IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND),
+   BIT_MASK_DESCR(IRQCHIP_IMMUTABLE),
 };
 
 static void
-- 
2.36.1


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