linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] irq: generic-chip: resource management improvements
@ 2017-05-31 16:06 Bartosz Golaszewski
  2017-05-31 16:06 ` [PATCH 1/5] irq: generic-chip: provide irq_free_generic_chip() Bartosz Golaszewski
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2017-05-31 16:06 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier, Jonathan Corbet
  Cc: linux-kernel, linux-doc, 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()

 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(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/5] irq: generic-chip: provide irq_free_generic_chip()
  2017-05-31 16:06 [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
@ 2017-05-31 16:06 ` Bartosz Golaszewski
  2017-06-01 18:59   ` kbuild test robot
  2017-06-21 13:58   ` [tip:irq/core] irq/generic-chip: Provide irq_free_generic_chip() tip-bot for Bartosz Golaszewski
  2017-05-31 16:06 ` [PATCH 2/5] irq: generic-chip: provide irq_destroy_generic_chip() Bartosz Golaszewski
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2017-05-31 16:06 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier, Jonathan Corbet
  Cc: linux-kernel, linux-doc, Bartosz Golaszewski

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.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 include/linux/irq.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index f887351..cba41a4 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -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);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 2/5] irq: generic-chip: provide irq_destroy_generic_chip()
  2017-05-31 16:06 [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
  2017-05-31 16:06 ` [PATCH 1/5] irq: generic-chip: provide irq_free_generic_chip() Bartosz Golaszewski
@ 2017-05-31 16:06 ` Bartosz Golaszewski
  2017-06-21 13:59   ` [tip:irq/core] irq/generic-chip: Provide irq_destroy_generic_chip() tip-bot for Bartosz Golaszewski
  2017-05-31 16:06 ` [PATCH 3/5] irq: generic-chip: export irq_init_generic_chip() locally Bartosz Golaszewski
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2017-05-31 16:06 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier, Jonathan Corbet
  Cc: linux-kernel, linux-doc, 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.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 include/linux/irq.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index cba41a4..a5d298e 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -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);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 3/5] irq: generic-chip: export irq_init_generic_chip() locally
  2017-05-31 16:06 [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
  2017-05-31 16:06 ` [PATCH 1/5] irq: generic-chip: provide irq_free_generic_chip() Bartosz Golaszewski
  2017-05-31 16:06 ` [PATCH 2/5] irq: generic-chip: provide irq_destroy_generic_chip() Bartosz Golaszewski
@ 2017-05-31 16:06 ` Bartosz Golaszewski
  2017-06-21 13:59   ` [tip:irq/core] irq/generic-chip: Export " tip-bot for Bartosz Golaszewski
  2017-05-31 16:06 ` [PATCH 4/5] irq: generic-chip: provide devm_irq_alloc_generic_chip() Bartosz Golaszewski
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2017-05-31 16:06 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier, Jonathan Corbet
  Cc: linux-kernel, linux-doc, Bartosz Golaszewski

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

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 kernel/irq/generic-chip.c |  7 +++----
 kernel/irq/internals.h    | 11 +++++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index ee32870..f7086b7 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -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;
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index bc226e7..921a241 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -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 */
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 4/5] irq: generic-chip: provide devm_irq_alloc_generic_chip()
  2017-05-31 16:06 [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
                   ` (2 preceding siblings ...)
  2017-05-31 16:06 ` [PATCH 3/5] irq: generic-chip: export irq_init_generic_chip() locally Bartosz Golaszewski
@ 2017-05-31 16:06 ` Bartosz Golaszewski
  2017-06-21 14:00   ` [tip:irq/core] irq/generic-chip: Provide devm_irq_alloc_generic_chip() tip-bot for Bartosz Golaszewski
  2017-05-31 16:07 ` [PATCH 5/5] irq: generic-chip: provide devm_irq_setup_generic_chip() Bartosz Golaszewski
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2017-05-31 16:06 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier, Jonathan Corbet
  Cc: linux-kernel, linux-doc, Bartosz Golaszewski

Provide a resource managed variant of irq_alloc_generic_chip().

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 Documentation/driver-model/devres.txt |  1 +
 include/linux/irq.h                   |  5 +++++
 kernel/irq/devres.c                   | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index e72587f..d473be8 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -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()
diff --git a/include/linux/irq.h b/include/linux/irq.h
index a5d298e..c6e70e9 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -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,
diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
index 1613bfd..21ee0ae 100644
--- a/kernel/irq/devres.c
+++ b/kernel/irq/devres.c
@@ -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 */
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH 5/5] irq: generic-chip: provide devm_irq_setup_generic_chip()
  2017-05-31 16:06 [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
                   ` (3 preceding siblings ...)
  2017-05-31 16:06 ` [PATCH 4/5] irq: generic-chip: provide devm_irq_alloc_generic_chip() Bartosz Golaszewski
@ 2017-05-31 16:07 ` Bartosz Golaszewski
  2017-06-21 14:01   ` [tip:irq/core] irq/generic-chip: Provide devm_irq_setup_generic_chip() tip-bot for Bartosz Golaszewski
  2017-06-20 10:31 ` [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
  2017-06-21 10:42 ` Marc Zyngier
  6 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2017-05-31 16:07 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier, Jonathan Corbet
  Cc: linux-kernel, linux-doc, Bartosz Golaszewski

Provide a resource managed variant of irq_setup_generic_chip().

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
---
 Documentation/driver-model/devres.txt |  1 +
 include/linux/irq.h                   |  3 ++
 kernel/irq/devres.c                   | 52 +++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index d473be8..6a6618f 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -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()
diff --git a/include/linux/irq.h b/include/linux/irq.h
index c6e70e9..4006ba1 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -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);
 
diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
index 21ee0ae..194c506 100644
--- a/kernel/irq/devres.c
+++ b/kernel/irq/devres.c
@@ -231,4 +231,56 @@ devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct,
 	return gc;
 }
 EXPORT_SYMBOL_GPL(devm_irq_alloc_generic_chip);
+
+struct irq_generic_chip_devres {
+	struct irq_chip_generic *gc;
+	u32 msk;
+	unsigned int clr;
+	unsigned int set;
+};
+
+static void devm_irq_remove_generic_chip(struct device *dev, void *res)
+{
+	struct irq_generic_chip_devres *this = res;
+
+	irq_remove_generic_chip(this->gc, this->msk, this->clr, this->set);
+}
+
+/**
+ * devm_irq_setup_generic_chip - Setup a range of interrupts with a generic
+ *                               chip for a managed device
+ *
+ * @dev:	Device to setup the generic chip for
+ * @gc:		Generic irq chip holding all data
+ * @msk:	Bitmask holding the irqs to initialize relative to gc->irq_base
+ * @flags:	Flags for initialization
+ * @clr:	IRQ_* bits to clear
+ * @set:	IRQ_* bits to set
+ *
+ * Set up max. 32 interrupts starting from gc->irq_base. Note, this
+ * initializes all interrupts to the primary irq_chip_type and its
+ * associated 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_generic_chip_devres *dr;
+
+	dr = devres_alloc(devm_irq_remove_generic_chip,
+			  sizeof(*dr), GFP_KERNEL);
+	if (!dr)
+		return -ENOMEM;
+
+	irq_setup_generic_chip(gc, msk, flags, clr, set);
+
+	dr->gc = gc;
+	dr->msk = msk;
+	dr->clr = clr;
+	dr->set = set;
+	devres_add(dev, dr);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(devm_irq_setup_generic_chip);
 #endif /* CONFIG_GENERIC_IRQ_CHIP */
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/5] irq: generic-chip: provide irq_free_generic_chip()
  2017-05-31 16:06 ` [PATCH 1/5] irq: generic-chip: provide irq_free_generic_chip() Bartosz Golaszewski
@ 2017-06-01 18:59   ` kbuild test robot
  2017-06-21 13:58   ` [tip:irq/core] irq/generic-chip: Provide irq_free_generic_chip() tip-bot for Bartosz Golaszewski
  1 sibling, 0 replies; 18+ messages in thread
From: kbuild test robot @ 2017-06-01 18:59 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: kbuild-all, Thomas Gleixner, Marc Zyngier, Jonathan Corbet,
	linux-kernel, linux-doc, Bartosz Golaszewski

[-- Attachment #1: Type: text/plain, Size: 4805 bytes --]

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 <dave.hansen@linux.intel.com>
:::::: CC: Ingo Molnar <mingo@kernel.org>

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27106 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/5] irq: generic-chip: resource management improvements
  2017-05-31 16:06 [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
                   ` (4 preceding siblings ...)
  2017-05-31 16:07 ` [PATCH 5/5] irq: generic-chip: provide devm_irq_setup_generic_chip() Bartosz Golaszewski
@ 2017-06-20 10:31 ` Bartosz Golaszewski
  2017-06-20 10:41   ` Marc Zyngier
  2017-06-21 10:42 ` Marc Zyngier
  6 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2017-06-20 10:31 UTC (permalink / raw)
  To: Thomas Gleixner, Marc Zyngier, Jonathan Corbet
  Cc: linux-kernel, linux-doc, Bartosz Golaszewski

2017-05-31 18:06 GMT+02:00 Bartosz Golaszewski <brgl@bgdev.pl>:
> 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(-)
>
> --
> 2.9.3
>

Ping for v4.13.

Is there any reason not to merge it?

Thanks,
Bartosz

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/5] irq: generic-chip: resource management improvements
  2017-06-20 10:31 ` [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
@ 2017-06-20 10:41   ` Marc Zyngier
  2017-06-20 10:47     ` Bartosz Golaszewski
  0 siblings, 1 reply; 18+ messages in thread
From: Marc Zyngier @ 2017-06-20 10:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Thomas Gleixner, Jonathan Corbet
  Cc: linux-kernel, linux-doc

On 20/06/17 11:31, Bartosz Golaszewski wrote:
> 2017-05-31 18:06 GMT+02:00 Bartosz Golaszewski <brgl@bgdev.pl>:
>> 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(-)
>>
>> --
>> 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.
-- 
Jazz is not dead. It just smells funny...

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/5] irq: generic-chip: resource management improvements
  2017-06-20 10:41   ` Marc Zyngier
@ 2017-06-20 10:47     ` Bartosz Golaszewski
  2017-06-20 14:14       ` Thomas Gleixner
  0 siblings, 1 reply; 18+ messages in thread
From: Bartosz Golaszewski @ 2017-06-20 10:47 UTC (permalink / raw)
  To: Marc Zyngier; +Cc: Thomas Gleixner, Jonathan Corbet, linux-kernel, linux-doc

2017-06-20 12:41 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
> On 20/06/17 11:31, Bartosz Golaszewski wrote:
>> 2017-05-31 18:06 GMT+02:00 Bartosz Golaszewski <brgl@bgdev.pl>:
>>> 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(-)
>>>
>>> --
>>> 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.
> --
> 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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/5] irq: generic-chip: resource management improvements
  2017-06-20 10:47     ` Bartosz Golaszewski
@ 2017-06-20 14:14       ` Thomas Gleixner
  2017-06-21 10:35         ` Bartosz Golaszewski
  0 siblings, 1 reply; 18+ messages in thread
From: Thomas Gleixner @ 2017-06-20 14:14 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Marc Zyngier, Jonathan Corbet, linux-kernel, linux-doc

On Tue, 20 Jun 2017, Bartosz Golaszewski wrote:
> 2017-06-20 12:41 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
> > 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...
> 
> 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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/5] irq: generic-chip: resource management improvements
  2017-06-20 14:14       ` Thomas Gleixner
@ 2017-06-21 10:35         ` Bartosz Golaszewski
  0 siblings, 0 replies; 18+ messages in thread
From: Bartosz Golaszewski @ 2017-06-21 10:35 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Marc Zyngier, Jonathan Corbet, linux-kernel, linux-doc

2017-06-20 16:14 GMT+02:00 Thomas Gleixner <tglx@linutronix.de>:
> On Tue, 20 Jun 2017, Bartosz Golaszewski wrote:
>> 2017-06-20 12:41 GMT+02:00 Marc Zyngier <marc.zyngier@arm.com>:
>> > 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...
>>
>> 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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 0/5] irq: generic-chip: resource management improvements
  2017-05-31 16:06 [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
                   ` (5 preceding siblings ...)
  2017-06-20 10:31 ` [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
@ 2017-06-21 10:42 ` Marc Zyngier
  6 siblings, 0 replies; 18+ messages in thread
From: Marc Zyngier @ 2017-06-21 10:42 UTC (permalink / raw)
  To: Bartosz Golaszewski, Thomas Gleixner, Jonathan Corbet
  Cc: linux-kernel, linux-doc

On 31/05/17 17:06, Bartosz Golaszewski wrote:
> 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(-)
> 

Looks OK to me. For the series:

Acked-by: Marc Zyngier <marc.zyngier@arm.com>

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

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [tip:irq/core] irq/generic-chip: Provide irq_free_generic_chip()
  2017-05-31 16:06 ` [PATCH 1/5] irq: generic-chip: provide irq_free_generic_chip() Bartosz Golaszewski
  2017-06-01 18:59   ` kbuild test robot
@ 2017-06-21 13:58   ` tip-bot for Bartosz Golaszewski
  1 sibling, 0 replies; 18+ messages in thread
From: tip-bot for Bartosz Golaszewski @ 2017-06-21 13:58 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: marc.zyngier, mingo, linux-kernel, tglx, corbet, hpa, brgl

Commit-ID:  707188f5f2421a304324e6ef3aaf4413cfab0f3d
Gitweb:     http://git.kernel.org/tip/707188f5f2421a304324e6ef3aaf4413cfab0f3d
Author:     Bartosz Golaszewski <brgl@bgdev.pl>
AuthorDate: Wed, 31 May 2017 18:06:56 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-doc@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Link: http://lkml.kernel.org/r/1496246820-13250-2-git-send-email-brgl@bgdev.pl

---
 include/linux/irq.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 94d1ad6..2c957fe 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -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);

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [tip:irq/core] irq/generic-chip: Provide irq_destroy_generic_chip()
  2017-05-31 16:06 ` [PATCH 2/5] irq: generic-chip: provide irq_destroy_generic_chip() Bartosz Golaszewski
@ 2017-06-21 13:59   ` tip-bot for Bartosz Golaszewski
  0 siblings, 0 replies; 18+ messages in thread
From: tip-bot for Bartosz Golaszewski @ 2017-06-21 13:59 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: brgl, hpa, linux-kernel, marc.zyngier, corbet, tglx, mingo

Commit-ID:  32bb6cbb3b4ea5ca24e3fa13e11772c192616e04
Gitweb:     http://git.kernel.org/tip/32bb6cbb3b4ea5ca24e3fa13e11772c192616e04
Author:     Bartosz Golaszewski <brgl@bgdev.pl>
AuthorDate: Wed, 31 May 2017 18:06:57 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-doc@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Link: http://lkml.kernel.org/r/1496246820-13250-3-git-send-email-brgl@bgdev.pl

---
 include/linux/irq.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/irq.h b/include/linux/irq.h
index 2c957fe..dc63aa1 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -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);

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [tip:irq/core] irq/generic-chip: Export irq_init_generic_chip() locally
  2017-05-31 16:06 ` [PATCH 3/5] irq: generic-chip: export irq_init_generic_chip() locally Bartosz Golaszewski
@ 2017-06-21 13:59   ` tip-bot for Bartosz Golaszewski
  0 siblings, 0 replies; 18+ messages in thread
From: tip-bot for Bartosz Golaszewski @ 2017-06-21 13:59 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, mingo, marc.zyngier, corbet, brgl, hpa, tglx

Commit-ID:  f160203986a6ad23ab8077c4a25b260fe55d6e26
Gitweb:     http://git.kernel.org/tip/f160203986a6ad23ab8077c4a25b260fe55d6e26
Author:     Bartosz Golaszewski <brgl@bgdev.pl>
AuthorDate: Wed, 31 May 2017 18:06:58 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
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().

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-doc@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Link: http://lkml.kernel.org/r/1496246820-13250-4-git-send-email-brgl@bgdev.pl

---
 kernel/irq/generic-chip.c |  7 +++----
 kernel/irq/internals.h    | 11 +++++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/kernel/irq/generic-chip.c b/kernel/irq/generic-chip.c
index ee32870..f7086b7 100644
--- a/kernel/irq/generic-chip.c
+++ b/kernel/irq/generic-chip.c
@@ -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;
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index bc226e7..921a241 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -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 */

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [tip:irq/core] irq/generic-chip: Provide devm_irq_alloc_generic_chip()
  2017-05-31 16:06 ` [PATCH 4/5] irq: generic-chip: provide devm_irq_alloc_generic_chip() Bartosz Golaszewski
@ 2017-06-21 14:00   ` tip-bot for Bartosz Golaszewski
  0 siblings, 0 replies; 18+ messages in thread
From: tip-bot for Bartosz Golaszewski @ 2017-06-21 14:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: marc.zyngier, mingo, corbet, brgl, linux-kernel, tglx, hpa

Commit-ID:  1c3e36309fe2e94b8a889fa32cb5c871434f8ed6
Gitweb:     http://git.kernel.org/tip/1c3e36309fe2e94b8a889fa32cb5c871434f8ed6
Author:     Bartosz Golaszewski <brgl@bgdev.pl>
AuthorDate: Wed, 31 May 2017 18:06:59 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
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().

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-doc@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Link: http://lkml.kernel.org/r/1496246820-13250-5-git-send-email-brgl@bgdev.pl

---
 Documentation/driver-model/devres.txt |  1 +
 include/linux/irq.h                   |  5 +++++
 kernel/irq/devres.c                   | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index e72587f..d473be8 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -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()
diff --git a/include/linux/irq.h b/include/linux/irq.h
index dc63aa1..64ae546 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -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,
diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
index 1613bfd..21ee0ae 100644
--- a/kernel/irq/devres.c
+++ b/kernel/irq/devres.c
@@ -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 */

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [tip:irq/core] irq/generic-chip: Provide devm_irq_setup_generic_chip()
  2017-05-31 16:07 ` [PATCH 5/5] irq: generic-chip: provide devm_irq_setup_generic_chip() Bartosz Golaszewski
@ 2017-06-21 14:01   ` tip-bot for Bartosz Golaszewski
  0 siblings, 0 replies; 18+ messages in thread
From: tip-bot for Bartosz Golaszewski @ 2017-06-21 14:01 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, marc.zyngier, linux-kernel, corbet, mingo, brgl, hpa

Commit-ID:  30fd8fc5c91973485705f83c7efe9588b8e6f371
Gitweb:     http://git.kernel.org/tip/30fd8fc5c91973485705f83c7efe9588b8e6f371
Author:     Bartosz Golaszewski <brgl@bgdev.pl>
AuthorDate: Wed, 31 May 2017 18:07:00 +0200
Committer:  Thomas Gleixner <tglx@linutronix.de>
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().

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: linux-doc@vger.kernel.org
Cc: Jonathan Corbet <corbet@lwn.net>
Link: http://lkml.kernel.org/r/1496246820-13250-6-git-send-email-brgl@bgdev.pl

---
 Documentation/driver-model/devres.txt |  1 +
 include/linux/irq.h                   |  3 ++
 kernel/irq/devres.c                   | 52 +++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)

diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index d473be8..6a6618f 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -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()
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 64ae546..d996314 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -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);
 
diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
index 21ee0ae..194c506 100644
--- a/kernel/irq/devres.c
+++ b/kernel/irq/devres.c
@@ -231,4 +231,56 @@ devm_irq_alloc_generic_chip(struct device *dev, const char *name, int num_ct,
 	return gc;
 }
 EXPORT_SYMBOL_GPL(devm_irq_alloc_generic_chip);
+
+struct irq_generic_chip_devres {
+	struct irq_chip_generic *gc;
+	u32 msk;
+	unsigned int clr;
+	unsigned int set;
+};
+
+static void devm_irq_remove_generic_chip(struct device *dev, void *res)
+{
+	struct irq_generic_chip_devres *this = res;
+
+	irq_remove_generic_chip(this->gc, this->msk, this->clr, this->set);
+}
+
+/**
+ * devm_irq_setup_generic_chip - Setup a range of interrupts with a generic
+ *                               chip for a managed device
+ *
+ * @dev:	Device to setup the generic chip for
+ * @gc:		Generic irq chip holding all data
+ * @msk:	Bitmask holding the irqs to initialize relative to gc->irq_base
+ * @flags:	Flags for initialization
+ * @clr:	IRQ_* bits to clear
+ * @set:	IRQ_* bits to set
+ *
+ * Set up max. 32 interrupts starting from gc->irq_base. Note, this
+ * initializes all interrupts to the primary irq_chip_type and its
+ * associated 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_generic_chip_devres *dr;
+
+	dr = devres_alloc(devm_irq_remove_generic_chip,
+			  sizeof(*dr), GFP_KERNEL);
+	if (!dr)
+		return -ENOMEM;
+
+	irq_setup_generic_chip(gc, msk, flags, clr, set);
+
+	dr->gc = gc;
+	dr->msk = msk;
+	dr->clr = clr;
+	dr->set = set;
+	devres_add(dev, dr);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(devm_irq_setup_generic_chip);
 #endif /* CONFIG_GENERIC_IRQ_CHIP */

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-06-21 14:04 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-31 16:06 [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
2017-05-31 16:06 ` [PATCH 1/5] irq: generic-chip: provide irq_free_generic_chip() Bartosz Golaszewski
2017-06-01 18:59   ` kbuild test robot
2017-06-21 13:58   ` [tip:irq/core] irq/generic-chip: Provide irq_free_generic_chip() tip-bot for Bartosz Golaszewski
2017-05-31 16:06 ` [PATCH 2/5] irq: generic-chip: provide irq_destroy_generic_chip() Bartosz Golaszewski
2017-06-21 13:59   ` [tip:irq/core] irq/generic-chip: Provide irq_destroy_generic_chip() tip-bot for Bartosz Golaszewski
2017-05-31 16:06 ` [PATCH 3/5] irq: generic-chip: export irq_init_generic_chip() locally Bartosz Golaszewski
2017-06-21 13:59   ` [tip:irq/core] irq/generic-chip: Export " tip-bot for Bartosz Golaszewski
2017-05-31 16:06 ` [PATCH 4/5] irq: generic-chip: provide devm_irq_alloc_generic_chip() Bartosz Golaszewski
2017-06-21 14:00   ` [tip:irq/core] irq/generic-chip: Provide devm_irq_alloc_generic_chip() tip-bot for Bartosz Golaszewski
2017-05-31 16:07 ` [PATCH 5/5] irq: generic-chip: provide devm_irq_setup_generic_chip() Bartosz Golaszewski
2017-06-21 14:01   ` [tip:irq/core] irq/generic-chip: Provide devm_irq_setup_generic_chip() tip-bot for Bartosz Golaszewski
2017-06-20 10:31 ` [PATCH 0/5] irq: generic-chip: resource management improvements Bartosz Golaszewski
2017-06-20 10:41   ` Marc Zyngier
2017-06-20 10:47     ` Bartosz Golaszewski
2017-06-20 14:14       ` Thomas Gleixner
2017-06-21 10:35         ` Bartosz Golaszewski
2017-06-21 10:42 ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).