Skip to contentSkip to conversation

soc/tegra: pmc: Fail to allocate more than one wake IRQ

PATCH Superseded Thierry Reding 3 participants 6 messages May 29, 2019 – Jun 3, 2019 Tegra architecture support

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 soc/tegra: pmc: Fail to allocate more than one wake IRQ

From: Thierry Reding <[email protected]>

The code currently doesn't support allocating more than one wake IRQ at a time. Detect this situation and error out. Also make sure to output a warning when that happens to help track down callers.

---
 drivers/soc/tegra/pmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/soc/tegra/pmc.c +3 -0
index 5648e5c09ef5..653fe2c466f6 100644
@@ -1863,6 +1863,9 @@ static int tegra_pmc_irq_alloc(struct irq_domain *domain, unsigned int virq,
 	unsigned int i;
 	int err = 0;
 
+	if (WARN_ON(num_irqs > 1))
+		return -EINVAL;
+
 	for (i = 0; i < soc->num_wake_events; i++) {
 		const struct tegra_wake_event *event = &soc->wake_events[i];
 
Signature · 1 line
2.21.0
#1 lore raw

PATCH 2/2 soc/tegra: pmc: Avoid crash for non-wake IRQs

From: Thierry Reding <[email protected]>

For interrupts that are not wakeup sources but that may end up getting mapped through the PMC as interrupt parent (this can happen for GPIOs), return early in order to avoid a subsequent crash from an out-of-bounds access to the register region.

---
 drivers/soc/tegra/pmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/soc/tegra/pmc.c +3 -0
index 653fe2c466f6..6e66b5e293be 100644
@@ -1924,6 +1924,9 @@ static int tegra_pmc_irq_set_wake(struct irq_data *data, unsigned int on)
 	unsigned int offset, bit;
 	u32 value;
 
+	if (WARN_ON(data->hwirq == ULONG_MAX))
+		return 0;
+
 	offset = data->hwirq / 32;
 	bit = data->hwirq % 32;
 
Signature · 1 line
2.21.0
maintainer Acked-by on v1 1/2
#5 lore raw
In reply to Thierry Reding
Quoted 16 lines · Thierry Reding

From: Thierry Reding <[email protected]>

The code currently doesn't support allocating more than one wake IRQ at a time. Detect this situation and error out. Also make sure to output a warning when that happens to help track down callers.

---
 drivers/soc/tegra/pmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/soc/tegra/pmc.c +0 -0
index 5648e5c09ef5..653fe2c466f6 100644

drivers/soc/tegra/pmc.c static int tegra_pmc_irq_alloc(struct irq_domain *domain, unsigned int virq, · line 1870

Quoted 8 lines
drivers/soc/tegra/pmc.c +3 -0
@@ -1863,6 +1863,9 @@ static int tegra_pmc_irq_alloc(struct irq_domain *domain, unsigned int virq,
 	unsigned int i;
 	int err = 0;
 
+	if (WARN_ON(num_irqs > 1))
+		return -EINVAL;
+
 	for (i = 0; i < soc->num_wake_events; i++) {
 		const struct tegra_wake_event *event = &soc->wake_events[i];

Cheers
Jon

Signature · 1 line
nvpublic
maintainer Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] soc/tegra: pmc: Avoid crash for non-wake IRQs

In reply to Thierry Reding
Quoted 6 lines · Thierry Reding

From: Thierry Reding <[email protected]>

For interrupts that are not wakeup sources but that may end up getting mapped through the PMC as interrupt parent (this can happen for GPIOs), return early in order to avoid a subsequent crash from an out-of-bounds access to the register region.

Maybe worth clarifying here what you mean by 'not wakeup sources' because the Tegra GPIO driver does have a set_wake() API to enable wakeup at the LIC IIRC. So maybe GPIOs that are not wakeup sources for what level of suspend?

Quoted 11 lines
---
 drivers/soc/tegra/pmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/soc/tegra/pmc.c +0 -0
index 653fe2c466f6..6e66b5e293be 100644

drivers/soc/tegra/pmc.c static int tegra_pmc_irq_set_wake(struct irq_data *data, unsigned int on) · line 1931

Quoted 8 lines
drivers/soc/tegra/pmc.c +3 -0
@@ -1924,6 +1924,9 @@ static int tegra_pmc_irq_set_wake(struct irq_data *data, unsigned int on)
 	unsigned int offset, bit;
 	u32 value;
 
+	if (WARN_ON(data->hwirq == ULONG_MAX))
+		return 0;
+
 	offset = data->hwirq / 32;
 	bit = data->hwirq % 32;

Otherwise ...

Cheers
Jon

Signature · 1 line
nvpublic
#3 lore raw

Re: [PATCH 2/2] soc/tegra: pmc: Avoid crash for non-wake IRQs

Quoted 10 lines · Jon Hunter
Quoted 6 lines · Thierry Reding

From: Thierry Reding <[email protected]>

For interrupts that are not wakeup sources but that may end up getting mapped through the PMC as interrupt parent (this can happen for GPIOs), return early in order to avoid a subsequent crash from an out-of-bounds access to the register region.

Quoted 4 lines

Maybe worth clarifying here what you mean by 'not wakeup sources' because the Tegra GPIO driver does have a set_wake() API to enable wakeup at the LIC IIRC. So maybe GPIOs that are not wakeup sources for what level of suspend?

Wakeup sources in the context of PMC is always LP0 wakeup sources. At that point I don't think LIC is enabled anymore. So LIC is to wake up from LP1 (and perhaps LP2), while PMC wakeup sources need to be configured in order to wake up from LP0.

Adding Peter to confirm, I think he's more familiar with the power states on earlier chips than I am.

Thierry

Quoted 23 lines
Quoted 12 lines
---
 drivers/soc/tegra/pmc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/soc/tegra/pmc.c +0 -0
index 653fe2c466f6..6e66b5e293be 100644

drivers/soc/tegra/pmc.c static int tegra_pmc_irq_set_wake(struct irq_data *data, unsigned int on) · line 1931

Quoted 8 lines
drivers/soc/tegra/pmc.c +3 -0
@@ -1924,6 +1924,9 @@ static int tegra_pmc_irq_set_wake(struct irq_data *data, unsigned int on)
 	unsigned int offset, bit;
 	u32 value;
 
+	if (WARN_ON(data->hwirq == ULONG_MAX))
+		return 0;
+
 	offset = data->hwirq / 32;
 	bit = data->hwirq % 32;

Otherwise ...

Quoted 8 lines

Cheers
Jon

Signature · 1 line
nvpublic

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#4 lore raw

Re: [PATCH 2/2] soc/tegra: pmc: Avoid crash for non-wake IRQs

Quoted 16 lines · Thierry Reding
Quoted 10 lines · Jon Hunter
Quoted 6 lines · Thierry Reding

From: Thierry Reding <[email protected]>

For interrupts that are not wakeup sources but that may end up getting mapped through the PMC as interrupt parent (this can happen for GPIOs), return early in order to avoid a subsequent crash from an out-of-bounds access to the register region.

Quoted 4 lines

Maybe worth clarifying here what you mean by 'not wakeup sources' because the Tegra GPIO driver does have a set_wake() API to enable wakeup at the LIC IIRC. So maybe GPIOs that are not wakeup sources for what level of suspend?

Quoted 7 lines

Wakeup sources in the context of PMC is always LP0 wakeup sources. At that point I don't think LIC is enabled anymore. So LIC is to wake up from LP1 (and perhaps LP2), while PMC wakeup sources need to be configured in order to wake up from LP0.

Adding Peter to confirm, I think he's more familiar with the power states on earlier chips than I am.

Yes. LIC is in a domain which is off during SC7 so it can't trigger a wakeup.

Peter.