[PATCH 1/4] genirq: Add irq_chip_(startup/shutdown)_parent

Inochi Amaoto posted 4 patches 1 month, 4 weeks ago
There is a newer version of this series
[PATCH 1/4] genirq: Add irq_chip_(startup/shutdown)_parent
Posted by Inochi Amaoto 1 month, 4 weeks ago
Add helper irq_chip_startup_parent and irq_chip_shutdown_parent. The
helper implement the default behavior in case irq_startup or irq_shutdown
is not implemented for the parent interrupt chip, which will fallback
to irq_chip_enable_parent or irq_chip_disable_parent if not available.

Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Inochi Amaoto <inochiama@gmail.com>
---
 include/linux/irq.h |  2 ++
 kernel/irq/chip.c   | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 1d6b606a81ef..890e1371f5d4 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -669,6 +669,8 @@ extern int irq_chip_set_parent_state(struct irq_data *data,
 extern int irq_chip_get_parent_state(struct irq_data *data,
 				     enum irqchip_irq_state which,
 				     bool *state);
+extern void irq_chip_shutdown_parent(struct irq_data *data);
+extern unsigned int irq_chip_startup_parent(struct irq_data *data);
 extern void irq_chip_enable_parent(struct irq_data *data);
 extern void irq_chip_disable_parent(struct irq_data *data);
 extern void irq_chip_ack_parent(struct irq_data *data);
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 0d0276378c70..3ffa0d80ddd1 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -1259,6 +1259,43 @@ int irq_chip_get_parent_state(struct irq_data *data,
 }
 EXPORT_SYMBOL_GPL(irq_chip_get_parent_state);
 
+/**
+ * irq_chip_shutdown_parent - Shutdown the parent interrupt
+ * @data:	Pointer to interrupt specific data
+ *
+ * Invokes the irq_shutdown() callback of the parent if available or falls
+ * back to irq_chip_disable_parent().
+ */
+void irq_chip_shutdown_parent(struct irq_data *data)
+{
+	struct irq_data *parent = data->parent_data;
+
+	if (parent->chip->irq_shutdown)
+		parent->chip->irq_shutdown(parent);
+	else
+		irq_chip_disable_parent(data);
+}
+EXPORT_SYMBOL_GPL(irq_chip_shutdown_parent);
+
+/**
+ * irq_chip_startup_parent - Startup the parent interrupt
+ * @data:	Pointer to interrupt specific data
+ *
+ * Invokes the irq_startup() callback of the parent if available or falls
+ * back to irq_chip_enable_parent().
+ */
+unsigned int irq_chip_startup_parent(struct irq_data *data)
+{
+	struct irq_data *parent = data->parent_data;
+
+	if (parent->chip->irq_startup)
+		return parent->chip->irq_startup(parent);
+
+	irq_chip_enable_parent(data);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(irq_chip_startup_parent);
+
 /**
  * irq_chip_enable_parent - Enable the parent interrupt (defaults to unmask if
  * NULL)
-- 
2.50.1
Re: [PATCH 1/4] genirq: Add irq_chip_(startup/shutdown)_parent
Posted by Andy Shevchenko 1 month, 3 weeks ago
On Thu, Aug 07, 2025 at 07:23:22PM +0800, Inochi Amaoto wrote:
> Add helper irq_chip_startup_parent and irq_chip_shutdown_parent. The

irq_chip_startup_parent() and irq_chip_shutdown_parent()

> helper implement the default behavior in case irq_startup or irq_shutdown

In the same way...

> is not implemented for the parent interrupt chip, which will fallback
> to irq_chip_enable_parent or irq_chip_disable_parent if not available.

In the same way...


...

> +/**
> + * irq_chip_startup_parent - Startup the parent interrupt
> + * @data:	Pointer to interrupt specific data
> + *
> + * Invokes the irq_startup() callback of the parent if available or falls
> + * back to irq_chip_enable_parent().

kernel-doc validator is not happy: Missing Return section.

> + */

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH 1/4] genirq: Add irq_chip_(startup/shutdown)_parent
Posted by Thomas Gleixner 1 month, 3 weeks ago
On Thu, Aug 07 2025 at 19:23, Inochi Amaoto wrote:

Please use 'function()' notation for functions. See

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html

I'm sure I pointed you to this documented at least three times in the
past. Do you think this was written for entertainment?

> Add helper irq_chip_startup_parent and irq_chip_shutdown_parent. The
> helper implement the default behavior in case irq_startup or irq_shutdown
> is not implemented for the parent interrupt chip, which will fallback
> to irq_chip_enable_parent or irq_chip_disable_parent if not available.

Also please use the documented structure for change logs. Starting with
'Add' is just wrong. See Documentation.
Re: [PATCH 1/4] genirq: Add irq_chip_(startup/shutdown)_parent
Posted by Inochi Amaoto 1 month, 3 weeks ago
On Mon, Aug 11, 2025 at 04:37:30PM +0200, Thomas Gleixner wrote:
> On Thu, Aug 07 2025 at 19:23, Inochi Amaoto wrote:
> 
> Please use 'function()' notation for functions. See
> 
> https://www.kernel.org/doc/html/latest/process/maintainer-tip.html
> 
> I'm sure I pointed you to this documented at least three times in the
> past. Do you think this was written for entertainment?
> 

Yeah, I have remembered to add this brace for the function. It seems
like I have forgot to fix this when I do the rebase. I apology for it.

> > Add helper irq_chip_startup_parent and irq_chip_shutdown_parent. The
> > helper implement the default behavior in case irq_startup or irq_shutdown
> > is not implemented for the parent interrupt chip, which will fallback
> > to irq_chip_enable_parent or irq_chip_disable_parent if not available.
> 
> Also please use the documented structure for change logs. Starting with
> 'Add' is just wrong. See Documentation.
> 

OK, I will structure the changelog.

Regards,
Inochi.