Skip to contentSkip to conversation

irq: generic-chip: resource management improvements

PATCH In review Bartosz Golaszewski 5 participants 18 messages May 31, 2017 – Jun 21, 2017

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

cover irq: generic-chip: resource management improvements

This series is a follow-up to [1].

Some users of irq_alloc_generic_chip() are modules which can be removed (e.g. gpio-ml-ioh) but have no means of freeing the allocated generic chip.

Last time it was suggested to provide irq_destroy_generic_chip() which would undo both irq_remove_generic_chip() and irq_alloc_generic_chip().

This functionality is provided by patch 2/5 with 1/5 adding the option to only free the allocated memory.

Patch 3/5 exports a function that will be used in the devres variant of irq_alloc_generic_chip().

Patches 4/5 and 5/5 add resource managed versions of irq_alloc_generic_chip() & irq_setup_generic_chip(). They will be used in drivers where applicable. Device resources are released in reverse order so it's ok to call devm_irq_alloc_generic_chip() and then devm_irq_setup_generic_chip().

[1] https://lkml.org/lkml/2017/3/8/550

Bartosz Golaszewski (5):
irq: generic-chip: provide irq_free_generic_chip()
irq: generic-chip: provide irq_destroy_generic_chip()
irq: generic-chip: export irq_init_generic_chip() locally
irq: generic-chip: provide devm_irq_alloc_generic_chip()
irq: generic-chip: provide devm_irq_setup_generic_chip()

 Documentation/driver-model/devres.txt |  2 +
 include/linux/irq.h                   | 22 +++++++++
 kernel/irq/devres.c                   | 86 +++++++++++++++++++++++++++++++++++
 kernel/irq/generic-chip.c             |  7 ++-
 kernel/irq/internals.h                | 11 +++++
 5 files changed, 124 insertions(+), 4 deletions(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/5 irq: generic-chip: provide irq_free_generic_chip()

Currently there's no way for users of irq_alloc_generic_chip() to free the allocated memory other than calling kfree() manually on the returned pointer. This may lead to errors if the internals of irq_alloc_generic_chip() ever change. Provide a routine to free the generic chip.

---
 include/linux/irq.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/linux/irq.h +6 -0
index f887351..cba41a4 100644
@@ -22,6 +22,7 @@
 #include <linux/topology.h>
 #include <linux/wait.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 #include <asm/ptrace.h>
@@ -967,6 +968,11 @@ int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
 					 handler, clr, set, flags);	\
 })
 
+static inline void irq_free_generic_chip(struct irq_chip_generic *gc)
+{
+	kfree(gc);
+}
+
 static inline struct irq_chip_type *irq_data_get_chip_type(struct irq_data *d)
 {
 	return container_of(d->chip, struct irq_chip_type, chip);
Signature · 1 line
2.9.3
#2 lore raw

Re: [PATCH 1/5] irq: generic-chip: provide irq_free_generic_chip()

url: https://github.com/0day-ci/linux/commits/Bartosz-Golaszewski/irq-generic-chip-resource-management-improvements/20170601-055423 config: x86_64-randconfig-n0-06011738 (attached as .config)…

Hi Bartosz,

[auto build test WARNING on linus/master]
[also build test WARNING on v4.12-rc3 next-20170601]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Bartosz-Golaszewski/irq-generic-chip-resource-management-improvements/20170601-055423
config: x86_64-randconfig-n0-06011738 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

In file included from include/linux/kasan.h:16:0,

                    from include/linux/slab.h:120,
                    from include/linux/irq.h:25,
                    from arch/x86/include/asm/hardirq.h:5,
                    from include/linux/hardirq.h:8,
                    from include/linux/interrupt.h:12,
                    from arch/x86/include/asm/mshyperv.h:5,
                    from arch/x86/entry/vdso/vdso32/../vclock_gettime.c:20,
                    from arch/x86/entry/vdso/vdso32/vclock_gettime.c:32:
   arch/x86/include/asm/pgtable.h: In function 'pte_flags_pkey':
>> arch/x86/include/asm/pgtable.h:1182:2: warning: left shift count >= width of type [enabled by default]
     return (pte_flags & _PAGE_PKEY_MASK) >> _PAGE_BIT_PKEY_BIT0;
     ^
>> arch/x86/include/asm/pgtable.h:1182:2: warning: left shift count >= width of type [enabled by default]
>> arch/x86/include/asm/pgtable.h:1182:2: warning: left shift count >= width of type [enabled by default]
>> arch/x86/include/asm/pgtable.h:1182:2: warning: left shift count >= width of type [enabled by default]

arch/x86/include/asm/pgtable.h:1182:2: warning: right shift count >= width of type [enabled by default]

vim +1182 arch/x86/include/asm/pgtable.h

33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1166  }
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1167  
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1168  static inline bool __pkru_allows_write(u32 pkru, u16 pkey)
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1169  {
845942969 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1170  	int pkru_pkey_bits = pkey * PKRU_BITS_PER_PKEY;
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1171  	/*
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1172  	 * Access-disable disables writes too so we need to check
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1173  	 * both bits here.
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1174  	 */
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1175  	return !(pkru & ((PKRU_AD_BIT|PKRU_WD_BIT) << pkru_pkey_bits));
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1176  }
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1177  
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1178  static inline u16 pte_flags_pkey(unsigned long pte_flags)
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1179  {
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1180  #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1181  	/* ifdef to avoid doing 59-bit shift on 32-bit values */
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12 @1182  	return (pte_flags & _PAGE_PKEY_MASK) >> _PAGE_BIT_PKEY_BIT0;
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1183  #else
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1184  	return 0;
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1185  #endif
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1186  }
33a709b25 arch/x86/include/asm/pgtable.h Dave Hansen         2016-02-12  1187  
195466dc4 include/asm-x86/pgtable.h      Jeremy Fitzhardinge 2008-01-30  1188  #include <asm-generic/pgtable.h>
195466dc4 include/asm-x86/pgtable.h      Jeremy Fitzhardinge 2008-01-30  1189  #endif	/* __ASSEMBLY__ */
195466dc4 include/asm-x86/pgtable.h      Jeremy Fitzhardinge 2008-01-30  1190  

:::::: The code at line 1182 was first introduced by commit
:::::: 33a709b25a760b91184bb335cf7d7c32b8123013 mm/gup, x86/mm/pkeys: Check VMAs and PTEs for protection keys

:::::: TO: Dave Hansen <[email protected]> :::::: CC: Ingo Molnar <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

[tip:irq/core] irq/generic-chip: Provide irq_free_generic_chip()

In reply to Bartosz Golaszewski
irq/generic-chip: Provide irq_free_generic_chip()
Commit-ID:  707188f5f2421a304324e6ef3aaf4413cfab0f3d
Gitweb:     http://git.kernel.org/tip/707188f5f2421a304324e6ef3aaf4413cfab0f3d
Author:     Bartosz Golaszewski <[email protected]>
AuthorDate: Wed, 31 May 2017 18:06:56 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Wed, 21 Jun 2017 15:53:10 +0200

irq/generic-chip: Provide irq_free_generic_chip()

Currently there's no way for users of irq_alloc_generic_chip() to free the allocated memory other than calling kfree() manually on the returned pointer. This may lead to errors if the internals of irq_alloc_generic_chip() ever change. Provide a routine to free the generic chip.

---
 include/linux/irq.h | 6 ++++++
 1 file changed, 6 insertions(+)
include/linux/irq.h +6 -0
index 94d1ad6..2c957fe 100644
@@ -22,6 +22,7 @@
 #include <linux/topology.h>
 #include <linux/wait.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <asm/irq.h>
 #include <asm/ptrace.h>
@@ -973,6 +974,11 @@ int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
 					 handler, clr, set, flags);	\
 })
 
+static inline void irq_free_generic_chip(struct irq_chip_generic *gc)
+{
+	kfree(gc);
+}
+
 static inline struct irq_chip_type *irq_data_get_chip_type(struct irq_data *d)
 {
 	return container_of(d->chip, struct irq_chip_type, chip);
#4 lore raw

PATCH 2/5 irq: generic-chip: provide irq_destroy_generic_chip()

In reply to Bartosz Golaszewski

Most users of irq_alloc_generic_chip() call irq_setup_generic_chip() too. To simplify the cleanup provide a function that both removes a generic chip and frees its memory.

---
 include/linux/irq.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/irq.h +8 -0
index cba41a4..a5d298e 100644
@@ -973,6 +973,14 @@ static inline void irq_free_generic_chip(struct irq_chip_generic *gc)
 	kfree(gc);
 }
 
+static inline void irq_destroy_generic_chip(struct irq_chip_generic *gc,
+					    u32 msk, unsigned int clr,
+					    unsigned int set)
+{
+	irq_remove_generic_chip(gc, msk, clr, set);
+	irq_free_generic_chip(gc);
+}
+
 static inline struct irq_chip_type *irq_data_get_chip_type(struct irq_data *d)
 {
 	return container_of(d->chip, struct irq_chip_type, chip);
Signature · 1 line
2.9.3
#5 lore raw

[tip:irq/core] irq/generic-chip: Provide irq_destroy_generic_chip()

irq/generic-chip: Provide irq_destroy_generic_chip()
Commit-ID:  32bb6cbb3b4ea5ca24e3fa13e11772c192616e04
Gitweb:     http://git.kernel.org/tip/32bb6cbb3b4ea5ca24e3fa13e11772c192616e04
Author:     Bartosz Golaszewski <[email protected]>
AuthorDate: Wed, 31 May 2017 18:06:57 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Wed, 21 Jun 2017 15:53:10 +0200

irq/generic-chip: Provide irq_destroy_generic_chip()

Most users of irq_alloc_generic_chip() call irq_setup_generic_chip() too. To simplify the cleanup provide a function that both removes a generic chip and frees its memory.

---
 include/linux/irq.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/irq.h +8 -0
index 2c957fe..dc63aa1 100644
@@ -979,6 +979,14 @@ static inline void irq_free_generic_chip(struct irq_chip_generic *gc)
 	kfree(gc);
 }
 
+static inline void irq_destroy_generic_chip(struct irq_chip_generic *gc,
+					    u32 msk, unsigned int clr,
+					    unsigned int set)
+{
+	irq_remove_generic_chip(gc, msk, clr, set);
+	irq_free_generic_chip(gc);
+}
+
 static inline struct irq_chip_type *irq_data_get_chip_type(struct irq_data *d)
 {
 	return container_of(d->chip, struct irq_chip_type, chip);
#6 lore raw

PATCH 3/5 irq: generic-chip: export irq_init_generic_chip() locally

In reply to Bartosz Golaszewski

This function will be used in the devres variant of irq_alloc_generic_chip().

---
 kernel/irq/generic-chip.c |  7 +++----
 kernel/irq/internals.h    | 11 +++++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)
kernel/irq/generic-chip.c +3 -4
index ee32870..f7086b7 100644
@@ -201,10 +201,9 @@ static void irq_writel_be(u32 val, void __iomem *addr)
 	iowrite32be(val, addr);
 }
 
-static void
-irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
-		      int num_ct, unsigned int irq_base,
-		      void __iomem *reg_base, irq_flow_handler_t handler)
+void irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
+			   int num_ct, unsigned int irq_base,
+			   void __iomem *reg_base, irq_flow_handler_t handler)
 {
 	raw_spin_lock_init(&gc->lock);
 	gc->num_ct = num_ct;
kernel/irq/internals.h +11 -0
index bc226e7..921a241 100644
@@ -226,3 +226,14 @@ irq_pm_install_action(struct irq_desc *desc, struct irqaction *action) { }
 static inline void
 irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action) { }
 #endif
+
+#ifdef CONFIG_GENERIC_IRQ_CHIP
+void irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
+			   int num_ct, unsigned int irq_base,
+			   void __iomem *reg_base, irq_flow_handler_t handler);
+#else
+static inline void
+irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
+		      int num_ct, unsigned int irq_base,
+		      void __iomem *reg_base, irq_flow_handler_t handler) { }
+#endif /* CONFIG_GENERIC_IRQ_CHIP */
Signature · 1 line
2.9.3
#7 lore raw

[tip:irq/core] irq/generic-chip: Export irq_init_generic_chip() locally

irq/generic-chip: Export irq_init_generic_chip() locally
Commit-ID:  f160203986a6ad23ab8077c4a25b260fe55d6e26
Gitweb:     http://git.kernel.org/tip/f160203986a6ad23ab8077c4a25b260fe55d6e26
Author:     Bartosz Golaszewski <[email protected]>
AuthorDate: Wed, 31 May 2017 18:06:58 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Wed, 21 Jun 2017 15:53:11 +0200

irq/generic-chip: Export irq_init_generic_chip() locally

This function will be used in the devres variant of irq_alloc_generic_chip().

---
 kernel/irq/generic-chip.c |  7 +++----
 kernel/irq/internals.h    | 11 +++++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)
kernel/irq/generic-chip.c +3 -4
index ee32870..f7086b7 100644
@@ -201,10 +201,9 @@ static void irq_writel_be(u32 val, void __iomem *addr)
 	iowrite32be(val, addr);
 }
 
-static void
-irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
-		      int num_ct, unsigned int irq_base,
-		      void __iomem *reg_base, irq_flow_handler_t handler)
+void irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
+			   int num_ct, unsigned int irq_base,
+			   void __iomem *reg_base, irq_flow_handler_t handler)
 {
 	raw_spin_lock_init(&gc->lock);
 	gc->num_ct = num_ct;
kernel/irq/internals.h +11 -0
index bc226e7..921a241 100644
@@ -226,3 +226,14 @@ irq_pm_install_action(struct irq_desc *desc, struct irqaction *action) { }
 static inline void
 irq_pm_remove_action(struct irq_desc *desc, struct irqaction *action) { }
 #endif
+
+#ifdef CONFIG_GENERIC_IRQ_CHIP
+void irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
+			   int num_ct, unsigned int irq_base,
+			   void __iomem *reg_base, irq_flow_handler_t handler);
+#else
+static inline void
+irq_init_generic_chip(struct irq_chip_generic *gc, const char *name,
+		      int num_ct, unsigned int irq_base,
+		      void __iomem *reg_base, irq_flow_handler_t handler) { }
+#endif /* CONFIG_GENERIC_IRQ_CHIP */
#8 lore raw

PATCH 4/5 irq: generic-chip: provide devm_irq_alloc_generic_chip()

In reply to Bartosz Golaszewski

Provide a resource managed variant of irq_alloc_generic_chip().

---
 Documentation/driver-model/devres.txt |  1 +
 include/linux/irq.h                   |  5 +++++
 kernel/irq/devres.c                   | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+)
Documentation/driver-model/devres.txt +1 -0
index e72587f..d473be8 100644
@@ -311,6 +311,7 @@ IRQ
   devm_irq_alloc_desc_at()
   devm_irq_alloc_desc_from()
   devm_irq_alloc_descs_from()
+  devm_irq_alloc_generic_chip()
 
 LED
   devm_led_classdev_register()
include/linux/irq.h +5 -0
index a5d298e..c6e70e9 100644
@@ -952,6 +952,11 @@ int irq_setup_alt_chip(struct irq_data *d, unsigned int type);
 void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk,
 			     unsigned int clr, unsigned int set);
 
+struct irq_chip_generic *
+devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct,
+			    unsigned int irq_base, void __iomem *reg_base,
+			    irq_flow_handler_t handler);
+
 struct irq_chip_generic *irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq);
 
 int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
kernel/irq/devres.c +34 -0
index 1613bfd..21ee0ae 100644
@@ -4,6 +4,8 @@
 #include <linux/gfp.h>
 #include <linux/irq.h>
 
+#include "internals.h"
+
 /*
  * Device resource management aware IRQ request/free implementation.
  */
@@ -198,3 +200,35 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
 	return base;
 }
 EXPORT_SYMBOL_GPL(__devm_irq_alloc_descs);
+
+#ifdef CONFIG_GENERIC_IRQ_CHIP
+/**
+ * devm_irq_alloc_generic_chip - Allocate and initialize a generic chip
+ *                               for a managed device
+ * @dev:	Device to allocate the generic chip for
+ * @name:	Name of the irq chip
+ * @num_ct:	Number of irq_chip_type instances associated with this
+ * @irq_base:	Interrupt base nr for this chip
+ * @reg_base:	Register base address (virtual)
+ * @handler:	Default flow handler associated with this chip
+ *
+ * Returns an initialized irq_chip_generic structure. The chip defaults
+ * to the primary (index 0) irq_chip_type and @handler
+ */
+struct irq_chip_generic *
+devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct,
+			    unsigned int irq_base, void __iomem *reg_base,
+			    irq_flow_handler_t handler)
+{
+	struct irq_chip_generic *gc;
+	unsigned long sz = sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);
+
+	gc = devm_kzalloc(dev, sz, GFP_KERNEL);
+	if (gc)
+		irq_init_generic_chip(gc, name, num_ct,
+				      irq_base, reg_base, handler);
+
+	return gc;
+}
+EXPORT_SYMBOL_GPL(devm_irq_alloc_generic_chip);
+#endif /* CONFIG_GENERIC_IRQ_CHIP */
Signature · 1 line
2.9.3
#9 lore raw

[tip:irq/core] irq/generic-chip: Provide devm_irq_alloc_generic_chip()

irq/generic-chip: Provide devm_irq_alloc_generic_chip()
Commit-ID:  1c3e36309fe2e94b8a889fa32cb5c871434f8ed6
Gitweb:     http://git.kernel.org/tip/1c3e36309fe2e94b8a889fa32cb5c871434f8ed6
Author:     Bartosz Golaszewski <[email protected]>
AuthorDate: Wed, 31 May 2017 18:06:59 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Wed, 21 Jun 2017 15:53:11 +0200

irq/generic-chip: Provide devm_irq_alloc_generic_chip()

Provide a resource managed variant of irq_alloc_generic_chip().

---
 Documentation/driver-model/devres.txt |  1 +
 include/linux/irq.h                   |  5 +++++
 kernel/irq/devres.c                   | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+)
Documentation/driver-model/devres.txt +1 -0
index e72587f..d473be8 100644
@@ -311,6 +311,7 @@ IRQ
   devm_irq_alloc_desc_at()
   devm_irq_alloc_desc_from()
   devm_irq_alloc_descs_from()
+  devm_irq_alloc_generic_chip()
 
 LED
   devm_led_classdev_register()
include/linux/irq.h +5 -0
index dc63aa1..64ae546 100644
@@ -958,6 +958,11 @@ int irq_setup_alt_chip(struct irq_data *d, unsigned int type);
 void irq_remove_generic_chip(struct irq_chip_generic *gc, u32 msk,
 			     unsigned int clr, unsigned int set);
 
+struct irq_chip_generic *
+devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct,
+			    unsigned int irq_base, void __iomem *reg_base,
+			    irq_flow_handler_t handler);
+
 struct irq_chip_generic *irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq);
 
 int __irq_alloc_domain_generic_chips(struct irq_domain *d, int irqs_per_chip,
kernel/irq/devres.c +34 -0
index 1613bfd..21ee0ae 100644
@@ -4,6 +4,8 @@
 #include <linux/gfp.h>
 #include <linux/irq.h>
 
+#include "internals.h"
+
 /*
  * Device resource management aware IRQ request/free implementation.
  */
@@ -198,3 +200,35 @@ int __devm_irq_alloc_descs(struct device *dev, int irq, unsigned int from,
 	return base;
 }
 EXPORT_SYMBOL_GPL(__devm_irq_alloc_descs);
+
+#ifdef CONFIG_GENERIC_IRQ_CHIP
+/**
+ * devm_irq_alloc_generic_chip - Allocate and initialize a generic chip
+ *                               for a managed device
+ * @dev:	Device to allocate the generic chip for
+ * @name:	Name of the irq chip
+ * @num_ct:	Number of irq_chip_type instances associated with this
+ * @irq_base:	Interrupt base nr for this chip
+ * @reg_base:	Register base address (virtual)
+ * @handler:	Default flow handler associated with this chip
+ *
+ * Returns an initialized irq_chip_generic structure. The chip defaults
+ * to the primary (index 0) irq_chip_type and @handler
+ */
+struct irq_chip_generic *
+devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct,
+			    unsigned int irq_base, void __iomem *reg_base,
+			    irq_flow_handler_t handler)
+{
+	struct irq_chip_generic *gc;
+	unsigned long sz = sizeof(*gc) + num_ct * sizeof(struct irq_chip_type);
+
+	gc = devm_kzalloc(dev, sz, GFP_KERNEL);
+	if (gc)
+		irq_init_generic_chip(gc, name, num_ct,
+				      irq_base, reg_base, handler);
+
+	return gc;
+}
+EXPORT_SYMBOL_GPL(devm_irq_alloc_generic_chip);
+#endif /* CONFIG_GENERIC_IRQ_CHIP */
#10 lore raw

PATCH 5/5 irq: generic-chip: provide devm_irq_setup_generic_chip()

In reply to Bartosz Golaszewski

Provide a resource managed variant of irq_setup_generic_chip().

---
 Documentation/driver-model/devres.txt |  1 +
 include/linux/irq.h                   |  3 ++
 kernel/irq/devres.c                   | 52 +++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)
Documentation/driver-model/devres.txt +1 -0
index d473be8..6a6618f 100644
@@ -312,6 +312,7 @@ IRQ
   devm_irq_alloc_desc_from()
   devm_irq_alloc_descs_from()
   devm_irq_alloc_generic_chip()
+  devm_irq_setup_generic_chip()
 
 LED
   devm_led_classdev_register()
include/linux/irq.h +3 -0
index c6e70e9..4006ba1 100644
@@ -956,6 +956,9 @@ struct irq_chip_generic *
 devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct,
 			    unsigned int irq_base, void __iomem *reg_base,
 			    irq_flow_handler_t handler);
+int devm_irq_setup_generic_chip(struct device *dev, struct irq_chip_generic *gc,
+				u32 msk, enum irq_gc_flags flags,
+				unsigned int clr, unsigned int set);
 
 struct irq_chip_generic *irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq);
 
kernel/irq/devres.c +52 -0

56 lines not on this page · raw message

Signature · 1 line
2.9.3
#11 lore raw

[tip:irq/core] irq/generic-chip: Provide devm_irq_setup_generic_chip()

irq/generic-chip: Provide devm_irq_setup_generic_chip()
Commit-ID:  30fd8fc5c91973485705f83c7efe9588b8e6f371
Gitweb:     http://git.kernel.org/tip/30fd8fc5c91973485705f83c7efe9588b8e6f371
Author:     Bartosz Golaszewski <[email protected]>
AuthorDate: Wed, 31 May 2017 18:07:00 +0200
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Wed, 21 Jun 2017 15:53:11 +0200

irq/generic-chip: Provide devm_irq_setup_generic_chip()

Provide a resource managed variant of irq_setup_generic_chip().

---
 Documentation/driver-model/devres.txt |  1 +
 include/linux/irq.h                   |  3 ++
 kernel/irq/devres.c                   | 52 +++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)
Documentation/driver-model/devres.txt +1 -0
index d473be8..6a6618f 100644
@@ -312,6 +312,7 @@ IRQ
   devm_irq_alloc_desc_from()
   devm_irq_alloc_descs_from()
   devm_irq_alloc_generic_chip()
+  devm_irq_setup_generic_chip()
 
 LED
   devm_led_classdev_register()
include/linux/irq.h +3 -0
index 64ae546..d996314 100644
@@ -962,6 +962,9 @@ struct irq_chip_generic *
 devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct,
 			    unsigned int irq_base, void __iomem *reg_base,
 			    irq_flow_handler_t handler);
+int devm_irq_setup_generic_chip(struct device *dev, struct irq_chip_generic *gc,
+				u32 msk, enum irq_gc_flags flags,
+				unsigned int clr, unsigned int set);
 
 struct irq_chip_generic *irq_get_domain_generic_chip(struct irq_domain *d, unsigned int hw_irq);
 
kernel/irq/devres.c +52 -0

56 lines not on this page · raw message

#12 lore raw
In reply to Bartosz Golaszewski

2017-05-31 18:06 GMT+02:00 Bartosz Golaszewski <[email protected]>:

Quoted 37 lines

This series is a follow-up to [1].

Some users of irq_alloc_generic_chip() are modules which can be removed (e.g. gpio-ml-ioh) but have no means of freeing the allocated generic chip.

Last time it was suggested to provide irq_destroy_generic_chip() which would undo both irq_remove_generic_chip() and irq_alloc_generic_chip().

This functionality is provided by patch 2/5 with 1/5 adding the option to only free the allocated memory.

Patch 3/5 exports a function that will be used in the devres variant of irq_alloc_generic_chip().

Patches 4/5 and 5/5 add resource managed versions of irq_alloc_generic_chip() & irq_setup_generic_chip(). They will be used in drivers where applicable. Device resources are released in reverse order so it's ok to call devm_irq_alloc_generic_chip() and then devm_irq_setup_generic_chip().

[1] https://lkml.org/lkml/2017/3/8/550

Bartosz Golaszewski (5):
irq: generic-chip: provide irq_free_generic_chip()
irq: generic-chip: provide irq_destroy_generic_chip()
irq: generic-chip: export irq_init_generic_chip() locally
irq: generic-chip: provide devm_irq_alloc_generic_chip()
irq: generic-chip: provide devm_irq_setup_generic_chip()

 Documentation/driver-model/devres.txt |  2 +
 include/linux/irq.h                   | 22 +++++++++
 kernel/irq/devres.c                   | 86 +++++++++++++++++++++++++++++++++++
 kernel/irq/generic-chip.c             |  7 ++-
 kernel/irq/internals.h                | 11 +++++
 5 files changed, 124 insertions(+), 4 deletions(-)
Quoted 3 lines

--
2.9.3

Ping for v4.13.

Is there any reason not to merge it?

Thanks,
Bartosz

#13 lore raw
Quoted 38 lines · Bartosz Golaszewski

2017-05-31 18:06 GMT+02:00 Bartosz Golaszewski <[email protected]>:

Quoted 37 lines

This series is a follow-up to [1].

Some users of irq_alloc_generic_chip() are modules which can be removed (e.g. gpio-ml-ioh) but have no means of freeing the allocated generic chip.

Last time it was suggested to provide irq_destroy_generic_chip() which would undo both irq_remove_generic_chip() and irq_alloc_generic_chip().

This functionality is provided by patch 2/5 with 1/5 adding the option to only free the allocated memory.

Patch 3/5 exports a function that will be used in the devres variant of irq_alloc_generic_chip().

Patches 4/5 and 5/5 add resource managed versions of irq_alloc_generic_chip() & irq_setup_generic_chip(). They will be used in drivers where applicable. Device resources are released in reverse order so it's ok to call devm_irq_alloc_generic_chip() and then devm_irq_setup_generic_chip().

[1] https://lkml.org/lkml/2017/3/8/550

Bartosz Golaszewski (5):
irq: generic-chip: provide irq_free_generic_chip()
irq: generic-chip: provide irq_destroy_generic_chip()
irq: generic-chip: export irq_init_generic_chip() locally
irq: generic-chip: provide devm_irq_alloc_generic_chip()
irq: generic-chip: provide devm_irq_setup_generic_chip()

 Documentation/driver-model/devres.txt |  2 +
 include/linux/irq.h                   | 22 +++++++++
 kernel/irq/devres.c                   | 86 +++++++++++++++++++++++++++++++++++
 kernel/irq/generic-chip.c             |  7 ++-
 kernel/irq/internals.h                | 11 +++++
 5 files changed, 124 insertions(+), 4 deletions(-)
Quoted 7 lines
Quoted 3 lines

--
2.9.3

Ping for v4.13.

Is there any reason not to merge it?

There was a kbuild report from June 1st with worrying warnings on x86_64 (though I couldn't see how that was related to these patches). What's the status of that?

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#14 lore raw

2017-06-20 12:41 GMT+02:00 Marc Zyngier <[email protected]>:

Quoted 51 lines · Bartosz Golaszewski
Quoted 38 lines

2017-05-31 18:06 GMT+02:00 Bartosz Golaszewski <[email protected]>:

Quoted 37 lines

This series is a follow-up to [1].

Some users of irq_alloc_generic_chip() are modules which can be removed (e.g. gpio-ml-ioh) but have no means of freeing the allocated generic chip.

Last time it was suggested to provide irq_destroy_generic_chip() which would undo both irq_remove_generic_chip() and irq_alloc_generic_chip().

This functionality is provided by patch 2/5 with 1/5 adding the option to only free the allocated memory.

Patch 3/5 exports a function that will be used in the devres variant of irq_alloc_generic_chip().

Patches 4/5 and 5/5 add resource managed versions of irq_alloc_generic_chip() & irq_setup_generic_chip(). They will be used in drivers where applicable. Device resources are released in reverse order so it's ok to call devm_irq_alloc_generic_chip() and then devm_irq_setup_generic_chip().

[1] https://lkml.org/lkml/2017/3/8/550

Bartosz Golaszewski (5):
irq: generic-chip: provide irq_free_generic_chip()
irq: generic-chip: provide irq_destroy_generic_chip()
irq: generic-chip: export irq_init_generic_chip() locally
irq: generic-chip: provide devm_irq_alloc_generic_chip()
irq: generic-chip: provide devm_irq_setup_generic_chip()

 Documentation/driver-model/devres.txt |  2 +
 include/linux/irq.h                   | 22 +++++++++
 kernel/irq/devres.c                   | 86 +++++++++++++++++++++++++++++++++++
 kernel/irq/generic-chip.c             |  7 ++-
 kernel/irq/internals.h                | 11 +++++
 5 files changed, 124 insertions(+), 4 deletions(-)
Quoted 7 lines
Quoted 3 lines

--
2.9.3

Ping for v4.13.

Is there any reason not to merge it?

There was a kbuild report from June 1st with worrying warnings on x86_64 (though I couldn't see how that was related to these patches). What's the status of that?

Quoted 5 lines

Thanks,

        M.

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

Snap, I looked at it, determined that it was just a header included in include/linux/irq.h (unrelated to the patch) and forgot to comment about it.

I've never seen this warning on my setup and don't see it now with rc6.

Thanks,
Bartosz

#15 lore raw
Quoted 11 lines · Bartosz Golaszewski

2017-06-20 12:41 GMT+02:00 Marc Zyngier <[email protected]>:

Quoted 9 lines

There was a kbuild report from June 1st with worrying warnings on x86_64 (though I couldn't see how that was related to these patches). What's the status of that?

Thanks,

        M.

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

Quoted 5 lines

Snap, I looked at it, determined that it was just a header included in include/linux/irq.h (unrelated to the patch) and forgot to comment about it.

I've never seen this warning on my setup and don't see it now with rc6.

Yep, that's a genuine x86 snafu. No idea how that got attributed to your patch.

Thanks,

tglx

#16 lore raw

2017-06-20 16:14 GMT+02:00 Thomas Gleixner <[email protected]>:

Quoted 12 lines · Bartosz Golaszewski
Quoted 11 lines

2017-06-20 12:41 GMT+02:00 Marc Zyngier <[email protected]>:

Quoted 9 lines

There was a kbuild report from June 1st with worrying warnings on x86_64 (though I couldn't see how that was related to these patches). What's the status of that?

Thanks,

        M.

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

Quoted 8 lines
Quoted 5 lines

Snap, I looked at it, determined that it was just a header included in include/linux/irq.h (unrelated to the patch) and forgot to comment about it.

I've never seen this warning on my setup and don't see it now with rc6.

Yep, that's a genuine x86 snafu. No idea how that got attributed to your patch.

So are the patches ok and can be merged for 4.13?

Thanks,
Bartosz

Acked-by on the v1 series
#17 lore raw
In reply to Bartosz Golaszewski
Quoted 30 lines · Bartosz Golaszewski

This series is a follow-up to [1].

Some users of irq_alloc_generic_chip() are modules which can be removed (e.g. gpio-ml-ioh) but have no means of freeing the allocated generic chip.

Last time it was suggested to provide irq_destroy_generic_chip() which would undo both irq_remove_generic_chip() and irq_alloc_generic_chip().

This functionality is provided by patch 2/5 with 1/5 adding the option to only free the allocated memory.

Patch 3/5 exports a function that will be used in the devres variant of irq_alloc_generic_chip().

Patches 4/5 and 5/5 add resource managed versions of irq_alloc_generic_chip() & irq_setup_generic_chip(). They will be used in drivers where applicable. Device resources are released in reverse order so it's ok to call devm_irq_alloc_generic_chip() and then devm_irq_setup_generic_chip().

[1] https://lkml.org/lkml/2017/3/8/550

Bartosz Golaszewski (5):
irq: generic-chip: provide irq_free_generic_chip()
irq: generic-chip: provide irq_destroy_generic_chip()
irq: generic-chip: export irq_init_generic_chip() locally
irq: generic-chip: provide devm_irq_alloc_generic_chip()
irq: generic-chip: provide devm_irq_setup_generic_chip()

Quoted 7 lines
 Documentation/driver-model/devres.txt |  2 +
 include/linux/irq.h                   | 22 +++++++++
 kernel/irq/devres.c                   | 86 +++++++++++++++++++++++++++++++++++
 kernel/irq/generic-chip.c             |  7 ++-
 kernel/irq/internals.h                | 11 +++++
 5 files changed, 124 insertions(+), 4 deletions(-)

Looks OK to me. For the series:

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...