Skip to contentSkip to conversation

pinctrl: qcom: spmi-gpio: make the irqchip immutable

PATCH In review Robert Marko 4 participants 17 messages Jun 24, 2022 – Aug 19, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: qcom: spmi-gpio: make the irqchip immutable

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +12 -10
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
 	struct regmap	*map;
 	struct pinctrl_dev *ctrl;
 	struct gpio_chip chip;
-	struct irq_chip irq;
 	u8 usid;
 	u8 pid_base;
 };
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
 	return fwspec;
 }
 
+static const struct irq_chip spmi_gpio_irq_chip = {
+	.name		= "spmi-gpio",
+	.irq_ack	= irq_chip_ack_parent,
+	.irq_mask	= irq_chip_mask_parent,
+	.irq_unmask	= irq_chip_unmask_parent,
+	.irq_set_type	= irq_chip_set_type_parent,
+	.irq_set_wake	= irq_chip_set_wake_parent,
+	.flags		= IRQCHIP_IMMUTABLE | IRQCHIP_MASK_ON_SUSPEND,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
 static int pmic_gpio_probe(struct platform_device *pdev)
 {
 	struct irq_domain *parent_domain;
@@ -1081,16 +1091,8 @@ static int pmic_gpio_probe(struct platform_device *pdev)
 	if (!parent_domain)
 		return -ENXIO;
 
-	state->irq.name = "spmi-gpio",
-	state->irq.irq_ack = irq_chip_ack_parent,
-	state->irq.irq_mask = irq_chip_mask_parent,
-	state->irq.irq_unmask = irq_chip_unmask_parent,
-	state->irq.irq_set_type = irq_chip_set_type_parent,
-	state->irq.irq_set_wake = irq_chip_set_wake_parent,
-	state->irq.flags = IRQCHIP_MASK_ON_SUSPEND,
-
 	girq = &state->chip.irq;
-	girq->chip = &state->irq;
+	gpio_irq_chip_set_chip(girq, &spmi_gpio_irq_chip);
 	girq->default_type = IRQ_TYPE_NONE;
 	girq->handler = handle_level_irq;
 	girq->fwnode = of_node_to_fwnode(state->dev->of_node);
Signature · 1 line
2.36.1
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

I've also tested this patch on Lenovo X13s, so

Thanks,
Mani

Quoted 55 lines
---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +12 -10
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
 	struct regmap	*map;
 	struct pinctrl_dev *ctrl;
 	struct gpio_chip chip;
-	struct irq_chip irq;
 	u8 usid;
 	u8 pid_base;
 };
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
 	return fwspec;
 }
 
+static const struct irq_chip spmi_gpio_irq_chip = {
+	.name		= "spmi-gpio",
+	.irq_ack	= irq_chip_ack_parent,
+	.irq_mask	= irq_chip_mask_parent,
+	.irq_unmask	= irq_chip_unmask_parent,
+	.irq_set_type	= irq_chip_set_type_parent,
+	.irq_set_wake	= irq_chip_set_wake_parent,
+	.flags		= IRQCHIP_IMMUTABLE | IRQCHIP_MASK_ON_SUSPEND,
+	GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
 static int pmic_gpio_probe(struct platform_device *pdev)
 {
 	struct irq_domain *parent_domain;
@@ -1081,16 +1091,8 @@ static int pmic_gpio_probe(struct platform_device *pdev)
 	if (!parent_domain)
 		return -ENXIO;
 
-	state->irq.name = "spmi-gpio",
-	state->irq.irq_ack = irq_chip_ack_parent,
-	state->irq.irq_mask = irq_chip_mask_parent,
-	state->irq.irq_unmask = irq_chip_unmask_parent,
-	state->irq.irq_set_type = irq_chip_set_type_parent,
-	state->irq.irq_set_wake = irq_chip_set_wake_parent,
-	state->irq.flags = IRQCHIP_MASK_ON_SUSPEND,
-
 	girq = &state->chip.irq;
-	girq->chip = &state->irq;
+	gpio_irq_chip_set_chip(girq, &spmi_gpio_irq_chip);
 	girq->default_type = IRQ_TYPE_NONE;
 	girq->handler = handle_level_irq;
 	girq->fwnode = of_node_to_fwnode(state->dev->of_node);
Signature · 1 line
2.36.1
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#2 lore raw
In reply to Robert Marko
Quoted 11 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

Patch applied!

Yours,
Linus Walleij

#3 lore raw
Quoted 10 lines · Linus Walleij
Quoted 8 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Quoted 5 lines
Quoted 3 lines

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

Patch applied!

Jumping the gun too quick.

Reverted the patch following Marc's feedback.

Yours,
Linus Walleij

#4 lore raw
Quoted 14 lines · Linus Walleij
Quoted 12 lines · Linus Walleij
Quoted 10 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Patch applied!

Jumping the gun too quick.

Reverted the patch following Marc's feedback.

Thanks for doing this, I was planning to send a revert patch.

Regards,
Robert

Quoted 3 lines

Yours,
Linus Walleij

#5 lore raw
In reply to Robert Marko
Quoted 29 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +0 -1
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
 	struct regmap	*map;
 	struct pinctrl_dev *ctrl;
 	struct gpio_chip chip;
-	struct irq_chip irq;
 	u8 usid;
 	u8 pid_base;
 };

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, · line 994

Quoted 8 lines
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +5 -0
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
 	return fwspec;
 }
 
+static const struct irq_chip spmi_gpio_irq_chip = {
+	.name		= "spmi-gpio",
+	.irq_ack	= irq_chip_ack_parent,
+	.irq_mask	= irq_chip_mask_parent,
+	.irq_unmask	= irq_chip_unmask_parent,

No, this is wrong. Please look at the documentation to see how you must now directly call into the gpiolib helpers for these two callbacks.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#6 lore raw
Quoted 34 lines · Marc Zyngier
Quoted 32 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +0 -1
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
 	struct regmap	*map;
 	struct pinctrl_dev *ctrl;
 	struct gpio_chip chip;
-	struct irq_chip irq;
 	u8 usid;
 	u8 pid_base;
 };
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
 	return fwspec;
 }
 
Quoted 10 lines

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, · line 994

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +5 -0
+static const struct irq_chip spmi_gpio_irq_chip = {
+	.name		= "spmi-gpio",
+	.irq_ack	= irq_chip_ack_parent,
+	.irq_mask	= irq_chip_mask_parent,
+	.irq_unmask	= irq_chip_unmask_parent,

No, this is wrong. Please look at the documentation to see how you must now directly call into the gpiolib helpers for these two callbacks.

IIUC, you are referring to gpiochip_disable_irq() and gpiochip_enable_irq() APIs. These APIs are supposed to let the gpiolib know about that the IRQ usage of these GPIOs. But for the case of hierarchial IRQ domain, isn't the parent is going to do that?

Please correct me if I'm wrong.

Thanks,
Mani

Quoted 6 lines

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#7 lore raw
Quoted 47 lines · Manivannan Sadhasivam
Quoted 34 lines · Marc Zyngier
Quoted 32 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +0 -1
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
 	struct regmap	*map;
 	struct pinctrl_dev *ctrl;
 	struct gpio_chip chip;
-	struct irq_chip irq;
 	u8 usid;
 	u8 pid_base;
 };
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
 	return fwspec;
 }
 
Quoted 10 lines

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, · line 994

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +5 -0
+static const struct irq_chip spmi_gpio_irq_chip = {
+	.name		= "spmi-gpio",
+	.irq_ack	= irq_chip_ack_parent,
+	.irq_mask	= irq_chip_mask_parent,
+	.irq_unmask	= irq_chip_unmask_parent,

No, this is wrong. Please look at the documentation to see how you must now directly call into the gpiolib helpers for these two callbacks.

Quoted 2 lines

IIUC, you are referring to gpiochip_disable_irq() and gpiochip_enable_irq() APIs.

I am indeed.

Quoted 3 lines

These APIs are supposed to let the gpiolib know about that the IRQ usage of these GPIOs. But for the case of hierarchial IRQ domain, isn't the parent is going to do that?

Why would it? The parent has no clue about what sits above it. In a hierarchical configuration, each level is responsible for its own level, and the GPIO layer should be responsible for its own management.

Quoted 1 line

Please correct me if I'm wrong.

I'm afraid you are, and this patch is a fairly obvious change in behaviour, as the callbacks you mention above are not called anymore, while they were before.

If they are not necessary (for reasons I can't fathom), then this should be clearly explained.

Thanks,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#8 lore raw
Quoted 64 lines · Marc Zyngier
Quoted 47 lines · Manivannan Sadhasivam
Quoted 34 lines · Marc Zyngier
Quoted 32 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +0 -1
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
  struct regmap   *map;
  struct pinctrl_dev *ctrl;
  struct gpio_chip chip;
- struct irq_chip irq;
  u8 usid;
  u8 pid_base;
 };
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
  return fwspec;
 }
 
Quoted 10 lines

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, · line 994

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +5 -0
+static const struct irq_chip spmi_gpio_irq_chip = {
+ .name           = "spmi-gpio",
+ .irq_ack        = irq_chip_ack_parent,
+ .irq_mask       = irq_chip_mask_parent,
+ .irq_unmask     = irq_chip_unmask_parent,

No, this is wrong. Please look at the documentation to see how you must now directly call into the gpiolib helpers for these two callbacks.

Quoted 2 lines

IIUC, you are referring to gpiochip_disable_irq() and gpiochip_enable_irq() APIs.

I am indeed.

Quoted 3 lines

These APIs are supposed to let the gpiolib know about that the IRQ usage of these GPIOs. But for the case of hierarchial IRQ domain, isn't the parent is going to do that?

Why would it? The parent has no clue about what sits above it. In a hierarchical configuration, each level is responsible for its own level, and the GPIO layer should be responsible for its own management.

Quoted 8 lines
Quoted 1 line

Please correct me if I'm wrong.

I'm afraid you are, and this patch is a fairly obvious change in behaviour, as the callbacks you mention above are not called anymore, while they were before.

If they are not necessary (for reasons I can't fathom), then this should be clearly explained.

Hi Marc,
I will look at IRQ GPIO docs, but in this case, then we have more conversions that
are not correct.

Regards,
Robert

Quoted 7 lines

Thanks,

        M.

--
Without deviation from the norm, progress is not possible.

#9 lore raw
Quoted 71 lines · Robert Marko
Quoted 70 lines · Marc Zyngier
Quoted 47 lines · Manivannan Sadhasivam
Quoted 34 lines · Marc Zyngier
Quoted 32 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +0 -1
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
  struct regmap   *map;
  struct pinctrl_dev *ctrl;
  struct gpio_chip chip;
- struct irq_chip irq;
  u8 usid;
  u8 pid_base;
 };
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
  return fwspec;
 }
 
Quoted 10 lines

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, · line 994

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +5 -0
+static const struct irq_chip spmi_gpio_irq_chip = {
+ .name           = "spmi-gpio",
+ .irq_ack        = irq_chip_ack_parent,
+ .irq_mask       = irq_chip_mask_parent,
+ .irq_unmask     = irq_chip_unmask_parent,

No, this is wrong. Please look at the documentation to see how you must now directly call into the gpiolib helpers for these two callbacks.

Quoted 2 lines

IIUC, you are referring to gpiochip_disable_irq() and gpiochip_enable_irq() APIs.

I am indeed.

Quoted 3 lines

These APIs are supposed to let the gpiolib know about that the IRQ usage of these GPIOs. But for the case of hierarchial IRQ domain, isn't the parent is going to do that?

Why would it? The parent has no clue about what sits above it. In a hierarchical configuration, each level is responsible for its own level, and the GPIO layer should be responsible for its own management.

Quoted 1 line

Please correct me if I'm wrong.

I'm afraid you are, and this patch is a fairly obvious change in behaviour, as the callbacks you mention above are not called anymore, while they were before.

Quoted 7 lines
Quoted 2 lines

If they are not necessary (for reasons I can't fathom), then this should be clearly explained.

Hi Marc,
I will look at IRQ GPIO docs, but in this case, then we have more conversions that
are not correct.

Then please point them out.

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#10 lore raw
Quoted 76 lines · Marc Zyngier
Quoted 74 lines · Robert Marko
Quoted 72 lines · Marc Zyngier
Quoted 47 lines · Manivannan Sadhasivam
Quoted 34 lines · Marc Zyngier
Quoted 32 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +0 -1
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
  struct regmap   *map;
  struct pinctrl_dev *ctrl;
  struct gpio_chip chip;
- struct irq_chip irq;
  u8 usid;
  u8 pid_base;
 };
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
  return fwspec;
 }
 
Quoted 10 lines

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, · line 994

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +5 -0
+static const struct irq_chip spmi_gpio_irq_chip = {
+ .name           = "spmi-gpio",
+ .irq_ack        = irq_chip_ack_parent,
+ .irq_mask       = irq_chip_mask_parent,
+ .irq_unmask     = irq_chip_unmask_parent,

No, this is wrong. Please look at the documentation to see how you must now directly call into the gpiolib helpers for these two callbacks.

Quoted 2 lines

IIUC, you are referring to gpiochip_disable_irq() and gpiochip_enable_irq() APIs.

I am indeed.

Quoted 3 lines

These APIs are supposed to let the gpiolib know about that the IRQ usage of these GPIOs. But for the case of hierarchial IRQ domain, isn't the parent is going to do that?

Why would it? The parent has no clue about what sits above it. In a hierarchical configuration, each level is responsible for its own level, and the GPIO layer should be responsible for its own management.

Quoted 1 line

Please correct me if I'm wrong.

I'm afraid you are, and this patch is a fairly obvious change in behaviour, as the callbacks you mention above are not called anymore, while they were before.

If they are not necessary (for reasons I can't fathom), then this should be clearly explained.

Quoted 6 lines
Quoted 4 lines

Hi Marc,
I will look at IRQ GPIO docs, but in this case, then we have more conversions that
are not correct.

Then please point them out.

Oh, now I get the issue, I was misunderstanding it completely. gpiochip_enable_irq and gpiochip_disable_irq are not being called at all.

However, I dont see them being called before the conversion as well. I am not really familiar with the PMIC IRQ-s, looked like an easy conversion to get rid of the warning.

Manivannan can you shed some light on this?

Regards,
Robert

Quoted 4 lines
         M.

--
Jazz is not dead. It just smells funny...

#11 lore raw
Quoted 10 lines · Robert Marko
Quoted 7 lines · Marc Zyngier
Quoted 3 lines · Robert Marko

I will look at IRQ GPIO docs, but in this case, then we have more conversions that
are not correct.

Then please point them out.

Quoted 7 lines

Oh, now I get the issue, I was misunderstanding it completely. gpiochip_enable_irq and gpiochip_disable_irq are not being called at all.

However, I dont see them being called before the conversion as well. I am not really familiar with the PMIC IRQ-s, looked like an easy conversion to get rid of the warning.

They definitely were. Look at how gpiochip_add_data() eventually ends up calling gpiochip_set_irq_hooks((), which hijacks the irq_chip function pointers to insert the calls to these helpers.

This is what this conversion process is all about, and you absolutely need to understand that code before blindly changing drivers to squash a run-time warning.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#12 lore raw
Quoted 17 lines · Marc Zyngier
Quoted 14 lines · Robert Marko
Quoted 7 lines · Marc Zyngier
Quoted 3 lines · Robert Marko

I will look at IRQ GPIO docs, but in this case, then we have more conversions that
are not correct.

Then please point them out.

Oh, now I get the issue, I was misunderstanding it completely. gpiochip_enable_irq and gpiochip_disable_irq are not being called at all.

Quoted 7 lines
Quoted 3 lines

However, I dont see them being called before the conversion as well. I am not really familiar with the PMIC IRQ-s, looked like an easy conversion to get rid of the warning.

They definitely were. Look at how gpiochip_add_data() eventually ends up calling gpiochip_set_irq_hooks((), which hijacks the irq_chip function pointers to insert the calls to these helpers.

Well, that is the thing, since irqchip->irq_enable and irqchip->irq_disable were never
populated in the SPMI GPIO driver, gpiochip_set_irq_hooks then does not insert them.
During runtime, gpiochip_irq_enable and gpiochip_irq_disable are never used even before
the conversion, that is what I am trying to convey.

Quoted 4 lines

This is what this conversion process is all about, and you absolutely need to understand that code before blindly changing drivers to squash a run-time warning.

Yeah, I agree, hopefully, I am not annoying.

Regards,
Robert

Quoted 5 lines
        M.

--
Without deviation from the norm, progress is not possible.

#13 lore raw
Quoted 27 lines · Robert Marko
Quoted 17 lines · Marc Zyngier
Quoted 14 lines · Robert Marko
Quoted 7 lines · Marc Zyngier
Quoted 3 lines · Robert Marko

I will look at IRQ GPIO docs, but in this case, then we have more conversions that
are not correct.

Then please point them out.

Oh, now I get the issue, I was misunderstanding it completely. gpiochip_enable_irq and gpiochip_disable_irq are not being called at all.

Quoted 7 lines
Quoted 3 lines

However, I dont see them being called before the conversion as well. I am not really familiar with the PMIC IRQ-s, looked like an easy conversion to get rid of the warning.

They definitely were. Look at how gpiochip_add_data() eventually ends up calling gpiochip_set_irq_hooks((), which hijacks the irq_chip function pointers to insert the calls to these helpers.

Quoted 6 lines

Well, that is the thing, since irqchip->irq_enable and irqchip->irq_disable were never populated in the SPMI GPIO driver, gpiochip_set_irq_hooks then does not insert them. During runtime, gpiochip_irq_enable and gpiochip_irq_disable are never used even before the conversion, that is what I am trying to convey.

It is the mask/unmask versions that would be used, with similar effects.

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.
#14 lore raw
In reply to Robert Marko
Quoted 88 lines · Robert Marko
Quoted 76 lines · Marc Zyngier
Quoted 74 lines · Robert Marko
Quoted 72 lines · Marc Zyngier
Quoted 47 lines · Manivannan Sadhasivam
Quoted 34 lines · Marc Zyngier
Quoted 32 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +0 -1
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
  struct regmap   *map;
  struct pinctrl_dev *ctrl;
  struct gpio_chip chip;
- struct irq_chip irq;
  u8 usid;
  u8 pid_base;
 };
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
  return fwspec;
 }
 
Quoted 10 lines

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, · line 994

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +5 -0
+static const struct irq_chip spmi_gpio_irq_chip = {
+ .name           = "spmi-gpio",
+ .irq_ack        = irq_chip_ack_parent,
+ .irq_mask       = irq_chip_mask_parent,
+ .irq_unmask     = irq_chip_unmask_parent,

No, this is wrong. Please look at the documentation to see how you must now directly call into the gpiolib helpers for these two callbacks.

Quoted 2 lines

IIUC, you are referring to gpiochip_disable_irq() and gpiochip_enable_irq() APIs.

I am indeed.

Quoted 3 lines

These APIs are supposed to let the gpiolib know about that the IRQ usage of these GPIOs. But for the case of hierarchial IRQ domain, isn't the parent is going to do that?

Why would it? The parent has no clue about what sits above it. In a hierarchical configuration, each level is responsible for its own level, and the GPIO layer should be responsible for its own management.

Quoted 1 line

Please correct me if I'm wrong.

I'm afraid you are, and this patch is a fairly obvious change in behaviour, as the callbacks you mention above are not called anymore, while they were before.

If they are not necessary (for reasons I can't fathom), then this should be clearly explained.

Quoted 6 lines
Quoted 4 lines

Hi Marc,
I will look at IRQ GPIO docs, but in this case, then we have more conversions that
are not correct.

Then please point them out.

Oh, now I get the issue, I was misunderstanding it completely. gpiochip_enable_irq and gpiochip_disable_irq are not being called at all.

Quoted 6 lines

However, I dont see them being called before the conversion as well. I am not really familiar with the PMIC IRQ-s, looked like an easy conversion to get rid of the warning.

Manivannan can you shed some light on this?

I hope you got the answer by now. When I looked into the conversion I saw that there were missing calls to gpiochip_{enable/disable}_irq APIs. But at that time I blindly assumed (yeah very bad of myself) that the parent irqchip will handle that :(

Anyway, you should call these helpers from the mask/unmask callbacks as a part of the conversion patch. Let me know if you are onto it or not!

Thanks,
Mani

Quoted 11 lines

Regards,
Robert

Quoted 4 lines
         M.

--
Jazz is not dead. It just smells funny...

Signature · 1 line
மணிவண்ணன் சதாசிவம்
#15 lore raw
Quoted 97 lines · Manivannan Sadhasivam
Quoted 88 lines · Robert Marko
Quoted 76 lines · Marc Zyngier
Quoted 74 lines · Robert Marko
Quoted 72 lines · Marc Zyngier
Quoted 47 lines · Manivannan Sadhasivam
Quoted 34 lines · Marc Zyngier
Quoted 32 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +0 -1
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
  struct regmap   *map;
  struct pinctrl_dev *ctrl;
  struct gpio_chip chip;
- struct irq_chip irq;
  u8 usid;
  u8 pid_base;
 };
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
  return fwspec;
 }
 
Quoted 10 lines

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, · line 994

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +5 -0
+static const struct irq_chip spmi_gpio_irq_chip = {
+ .name           = "spmi-gpio",
+ .irq_ack        = irq_chip_ack_parent,
+ .irq_mask       = irq_chip_mask_parent,
+ .irq_unmask     = irq_chip_unmask_parent,

No, this is wrong. Please look at the documentation to see how you must now directly call into the gpiolib helpers for these two callbacks.

Quoted 2 lines

IIUC, you are referring to gpiochip_disable_irq() and gpiochip_enable_irq() APIs.

I am indeed.

Quoted 3 lines

These APIs are supposed to let the gpiolib know about that the IRQ usage of these GPIOs. But for the case of hierarchial IRQ domain, isn't the parent is going to do that?

Why would it? The parent has no clue about what sits above it. In a hierarchical configuration, each level is responsible for its own level, and the GPIO layer should be responsible for its own management.

Quoted 1 line

Please correct me if I'm wrong.

I'm afraid you are, and this patch is a fairly obvious change in behaviour, as the callbacks you mention above are not called anymore, while they were before.

If they are not necessary (for reasons I can't fathom), then this should be clearly explained.

Quoted 6 lines
Quoted 4 lines

Hi Marc,
I will look at IRQ GPIO docs, but in this case, then we have more conversions that
are not correct.

Then please point them out.

Oh, now I get the issue, I was misunderstanding it completely. gpiochip_enable_irq and gpiochip_disable_irq are not being called at all.

Quoted 6 lines

However, I dont see them being called before the conversion as well. I am not really familiar with the PMIC IRQ-s, looked like an easy conversion to get rid of the warning.

Manivannan can you shed some light on this?

Quoted 7 lines

I hope you got the answer by now. When I looked into the conversion I saw that there were missing calls to gpiochip_{enable/disable}_irq APIs. But at that time I blindly assumed (yeah very bad of myself) that the parent irqchip will handle that :(

Anyway, you should call these helpers from the mask/unmask callbacks as a part of the conversion patch. Let me know if you are onto it or not!

Hi, I completely missed your reply.
Currently, I am pretty swamped with other work so I dont know when will I be able
to look into this again.

Regards,
Robert

Quoted 18 lines

Thanks,
Mani

Quoted 11 lines

Regards,
Robert

Quoted 4 lines
         M.

--
Jazz is not dead. It just smells funny...

--
மணிவண்ணன் சதாசிவம்

#16 lore raw
Quoted 104 lines · Robert Marko
Quoted 102 lines · Manivannan Sadhasivam
Quoted 88 lines · Robert Marko
Quoted 76 lines · Marc Zyngier
Quoted 74 lines · Robert Marko
Quoted 72 lines · Marc Zyngier
Quoted 47 lines · Manivannan Sadhasivam
Quoted 34 lines · Marc Zyngier
Quoted 32 lines · Robert Marko

Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as immutable") added a warning to indicate if the gpiolib is altering the internals of irqchips.

Following this change the following warning is now observed for the SPMI
PMIC pinctrl driver:
gpio gpiochip1: (200f000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Fix this by making the irqchip in the SPMI PMIC pinctrl driver immutable.

---
 drivers/pinctrl/qcom/pinctrl-spmi-gpio.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +0 -1
index c3255b0bece4..406ee0933d0b 100644
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
  struct regmap   *map;
  struct pinctrl_dev *ctrl;
  struct gpio_chip chip;
- struct irq_chip irq;
  u8 usid;
  u8 pid_base;
 };
@@ -988,6 +987,17 @@ static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
  return fwspec;
 }
 
Quoted 10 lines

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c static void *pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip, · line 994

Quoted 5 lines
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c +5 -0
+static const struct irq_chip spmi_gpio_irq_chip = {
+ .name           = "spmi-gpio",
+ .irq_ack        = irq_chip_ack_parent,
+ .irq_mask       = irq_chip_mask_parent,
+ .irq_unmask     = irq_chip_unmask_parent,

No, this is wrong. Please look at the documentation to see how you must now directly call into the gpiolib helpers for these two callbacks.

Quoted 2 lines

IIUC, you are referring to gpiochip_disable_irq() and gpiochip_enable_irq() APIs.

I am indeed.

Quoted 3 lines

These APIs are supposed to let the gpiolib know about that the IRQ usage of these GPIOs. But for the case of hierarchial IRQ domain, isn't the parent is going to do that?

Why would it? The parent has no clue about what sits above it. In a hierarchical configuration, each level is responsible for its own level, and the GPIO layer should be responsible for its own management.

Quoted 1 line

Please correct me if I'm wrong.

I'm afraid you are, and this patch is a fairly obvious change in behaviour, as the callbacks you mention above are not called anymore, while they were before.

If they are not necessary (for reasons I can't fathom), then this should be clearly explained.

Quoted 6 lines
Quoted 4 lines

Hi Marc,
I will look at IRQ GPIO docs, but in this case, then we have more conversions that
are not correct.

Then please point them out.

Oh, now I get the issue, I was misunderstanding it completely. gpiochip_enable_irq and gpiochip_disable_irq are not being called at all.

Quoted 6 lines

However, I dont see them being called before the conversion as well. I am not really familiar with the PMIC IRQ-s, looked like an easy conversion to get rid of the warning.

Manivannan can you shed some light on this?

I hope you got the answer by now. When I looked into the conversion I saw that there were missing calls to gpiochip_{enable/disable}_irq APIs. But at that time I blindly assumed (yeah very bad of myself) that the parent irqchip will handle that :(

Quoted 8 lines
Quoted 2 lines

Anyway, you should call these helpers from the mask/unmask callbacks as a part of the conversion patch. Let me know if you are onto it or not!

Hi, I completely missed your reply.
Currently, I am pretty swamped with other work so I dont know when will I be able
to look into this again.

No worries! I will handle it.

Thanks,
Mani

Quoted 20 lines

Regards,
Robert

Quoted 18 lines

Thanks,
Mani

Quoted 11 lines

Regards,
Robert

Quoted 4 lines
         M.

--
Jazz is not dead. It just smells funny...

--
மணிவண்ணன் சதாசிவம்

Signature · 1 line
மணிவண்ணன் சதாசிவம்