mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
@ 2016-02-27 23:59 kbuild test robot
  2016-02-28  9:32 ` Thomas Gleixner
  0 siblings, 1 reply; 12+ messages in thread
From: kbuild test robot @ 2016-02-27 23:59 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: kbuild-all, linux-kernel, Ingo Molnar

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

Hi Thomas,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   691429e13dfaf5b0994b07cc166db41bd608ee3d
commit: 3795de236d67a05994a1a12759db9d4dd9ffc42c genirq: Distangle kernel/irq/handle.c
date:   5 years ago
config: m68k-alldefconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 3795de236d67a05994a1a12759db9d4dd9ffc42c
        # save the attached .config to linux build tree
        make.cross ARCH=m68k 

All errors (new ones prefixed by >>):

   In file included from include/linux/irqnr.h:10:0,
                    from include/linux/irq.h:22,
                    from kernel/irq/irqdesc.c:10:
   arch/m68k/include/asm/irq.h:25:17: error: expected identifier or '(' before numeric constant
    #define NR_IRQS 0
                    ^
   include/linux/irqnr.h:15:19: note: in expansion of macro 'NR_IRQS'
    #define nr_irqs   NR_IRQS
                      ^
   kernel/irq/irqdesc.c:36:5: note: in expansion of macro 'nr_irqs'
    int nr_irqs = NR_IRQS;
        ^
>> kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
     [0 ... NR_IRQS-1] = {
     ^
   kernel/irq/irqdesc.c:206:2: error: (near initialization for 'irq_desc')
   kernel/irq/irqdesc.c:208:17: error: 'handle_bad_irq' undeclared here (not in a function)
      .handle_irq = handle_bad_irq,
                    ^
   kernel/irq/irqdesc.c:211:2: warning: excess elements in array initializer
     }
     ^
   kernel/irq/irqdesc.c:211:2: warning: (near initialization for 'irq_desc')
   kernel/irq/irqdesc.c: In function 'early_irq_init':
   kernel/irq/irqdesc.c:230:28: error: 'no_irq_chip' undeclared (first use in this function)
      desc[i].irq_data.chip = &no_irq_chip;
                               ^
   kernel/irq/irqdesc.c:230:28: note: each undeclared identifier is reported only once for each function it appears in
   In file included from include/linux/irq.h:22:0,
                    from kernel/irq/irqdesc.c:10:
   kernel/irq/irqdesc.c: At top level:
   include/linux/irqnr.h:16:27: error: expected identifier or '(' before '&' token
    #define irq_to_desc(irq) (&irq_desc[irq])
                              ^
   kernel/irq/irqdesc.c:238:18: note: in expansion of macro 'irq_to_desc'
    struct irq_desc *irq_to_desc(unsigned int irq)
                     ^
   kernel/irq/irqdesc.c:254:6: error: redefinition of 'early_init_irq_lock_class'
    void early_init_irq_lock_class(void)
         ^
   In file included from include/linux/hardirq.h:8:0,
                    from arch/m68k/include/asm/system_mm.h:69,
                    from arch/m68k/include/asm/system.h:4,
                    from include/linux/list.h:8,
                    from include/linux/smp.h:11,
                    from include/linux/irq.h:12,
                    from kernel/irq/irqdesc.c:10:
   include/linux/lockdep.h:430:20: note: previous definition of 'early_init_irq_lock_class' was here
    static inline void early_init_irq_lock_class(void)
                       ^
   kernel/irq/irqdesc.c: In function 'early_init_irq_lock_class':
   kernel/irq/irqdesc.c:256:19: warning: unused variable 'desc' [-Wunused-variable]
     struct irq_desc *desc;
                      ^
   kernel/irq/irqdesc.c: At top level:
   kernel/irq/irqdesc.c:264:14: error: redefinition of 'kstat_irqs_cpu'
    unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
                 ^
   In file included from kernel/irq/irqdesc.c:14:0:
   include/linux/kernel_stat.h:59:28: note: previous definition of 'kstat_irqs_cpu' was here
    static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
                               ^

vim +206 kernel/irq/irqdesc.c

    30	#else
    31	static void __init init_irq_default_affinity(void)
    32	{
    33	}
    34	#endif
    35	
  > 36	int nr_irqs = NR_IRQS;
    37	EXPORT_SYMBOL_GPL(nr_irqs);
    38	
    39	#ifdef CONFIG_SPARSE_IRQ
    40	
    41	static struct irq_desc irq_desc_init = {
    42		.status		= IRQ_DISABLED,
    43		.handle_irq	= handle_bad_irq,
    44		.depth		= 1,
    45		.lock		= __RAW_SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
    46	};
    47	
    48	void __ref init_kstat_irqs(struct irq_desc *desc, int node, int nr)
    49	{
    50		void *ptr;
    51	
    52		ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs),
    53				   GFP_ATOMIC, node);
    54	
    55		/*
    56		 * don't overwite if can not get new one
    57		 * init_copy_kstat_irqs() could still use old one
    58		 */
    59		if (ptr) {
    60			printk(KERN_DEBUG "  alloc kstat_irqs on node %d\n", node);
    61			desc->kstat_irqs = ptr;
    62		}
    63	}
    64	
    65	static void init_one_irq_desc(int irq, struct irq_desc *desc, int node)
    66	{
    67		memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
    68	
    69		raw_spin_lock_init(&desc->lock);
    70		desc->irq_data.irq = irq;
    71	#ifdef CONFIG_SMP
    72		desc->irq_data.node = node;
    73	#endif
    74		lockdep_set_class(&desc->lock, &irq_desc_lock_class);
    75		init_kstat_irqs(desc, node, nr_cpu_ids);
    76		if (!desc->kstat_irqs) {
    77			printk(KERN_ERR "can not alloc kstat_irqs\n");
    78			BUG_ON(1);
    79		}
    80		if (!alloc_desc_masks(desc, node, false)) {
    81			printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
    82			BUG_ON(1);
    83		}
    84		init_desc_masks(desc);
    85		arch_init_chip_data(desc, node);
    86	}
    87	
    88	/*
    89	 * Protect the sparse_irqs:
    90	 */
    91	DEFINE_RAW_SPINLOCK(sparse_irq_lock);
    92	
    93	static RADIX_TREE(irq_desc_tree, GFP_ATOMIC);
    94	
    95	static void set_irq_desc(unsigned int irq, struct irq_desc *desc)
    96	{
    97		radix_tree_insert(&irq_desc_tree, irq, desc);
    98	}
    99	
   100	struct irq_desc *irq_to_desc(unsigned int irq)
   101	{
   102		return radix_tree_lookup(&irq_desc_tree, irq);
   103	}
   104	
   105	void replace_irq_desc(unsigned int irq, struct irq_desc *desc)
   106	{
   107		void **ptr;
   108	
   109		ptr = radix_tree_lookup_slot(&irq_desc_tree, irq);
   110		if (ptr)
   111			radix_tree_replace_slot(ptr, desc);
   112	}
   113	
   114	static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = {
   115		[0 ... NR_IRQS_LEGACY-1] = {
   116			.status		= IRQ_DISABLED,
   117			.handle_irq	= handle_bad_irq,
   118			.depth		= 1,
   119			.lock		= __RAW_SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
   120		}
   121	};
   122	
   123	static unsigned int *kstat_irqs_legacy;
   124	
   125	int __init early_irq_init(void)
   126	{
   127		struct irq_desc *desc;
   128		int legacy_count;
   129		int node;
   130		int i;
   131	
   132		init_irq_default_affinity();
   133	
   134		 /* initialize nr_irqs based on nr_cpu_ids */
   135		arch_probe_nr_irqs();
   136		printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs);
   137	
   138		desc = irq_desc_legacy;
   139		legacy_count = ARRAY_SIZE(irq_desc_legacy);
   140		node = first_online_node;
   141	
   142		/* allocate based on nr_cpu_ids */
   143		kstat_irqs_legacy = kzalloc_node(NR_IRQS_LEGACY * nr_cpu_ids *
   144						  sizeof(int), GFP_NOWAIT, node);
   145	
   146		irq_desc_init.irq_data.chip = &no_irq_chip;
   147	
   148		for (i = 0; i < legacy_count; i++) {
   149			desc[i].irq_data.irq = i;
   150			desc[i].irq_data.chip = &no_irq_chip;
   151	#ifdef CONFIG_SMP
   152			desc[i].irq_data.node = node;
   153	#endif
   154			desc[i].kstat_irqs = kstat_irqs_legacy + i * nr_cpu_ids;
   155			lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
   156			alloc_desc_masks(&desc[i], node, true);
   157			init_desc_masks(&desc[i]);
   158			set_irq_desc(i, &desc[i]);
   159		}
   160	
   161		return arch_early_irq_init();
   162	}
   163	
   164	struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node)
   165	{
   166		struct irq_desc *desc;
   167		unsigned long flags;
   168	
   169		if (irq >= nr_irqs) {
   170			WARN(1, "irq (%d) >= nr_irqs (%d) in irq_to_desc_alloc\n",
   171				irq, nr_irqs);
   172			return NULL;
   173		}
   174	
   175		desc = irq_to_desc(irq);
   176		if (desc)
   177			return desc;
   178	
   179		raw_spin_lock_irqsave(&sparse_irq_lock, flags);
   180	
   181		/* We have to check it to avoid races with another CPU */
   182		desc = irq_to_desc(irq);
   183		if (desc)
   184			goto out_unlock;
   185	
   186		desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
   187	
   188		printk(KERN_DEBUG "  alloc irq_desc for %d on node %d\n", irq, node);
   189		if (!desc) {
   190			printk(KERN_ERR "can not alloc irq_desc\n");
   191			BUG_ON(1);
   192		}
   193		init_one_irq_desc(irq, desc, node);
   194	
   195		set_irq_desc(irq, desc);
   196	
   197	out_unlock:
   198		raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
   199	
   200		return desc;
   201	}
   202	
   203	#else /* !CONFIG_SPARSE_IRQ */
   204	
   205	struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
 > 206		[0 ... NR_IRQS-1] = {
   207			.status		= IRQ_DISABLED,
   208			.handle_irq	= handle_bad_irq,
   209			.depth		= 1,

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

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 3461 bytes --]

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

* Re: kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
  2016-02-27 23:59 kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds kbuild test robot
@ 2016-02-28  9:32 ` Thomas Gleixner
  2016-02-28  9:52   ` Geert Uytterhoeven
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Gleixner @ 2016-02-28  9:32 UTC (permalink / raw)
  To: kbuild test robot; +Cc: kbuild-all, LKML, Ingo Molnar, Geert Uytterhoeven

On Sun, 28 Feb 2016, kbuild test robot wrote:
> Hi Thomas,
> 
> FYI, the error/warning still remains.
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   691429e13dfaf5b0994b07cc166db41bd608ee3d
> commit: 3795de236d67a05994a1a12759db9d4dd9ffc42c genirq: Distangle kernel/irq/handle.c
> date:   5 years ago
> config: m68k-alldefconfig (attached as .config)
> reproduce:
>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         git checkout 3795de236d67a05994a1a12759db9d4dd9ffc42c
>         # save the attached .config to linux build tree
>         make.cross ARCH=m68k 

Again. This commit is just moving code into seperate files without changing
the code. So it's not a new wreckage.
 
> All errors (new ones prefixed by >>):
> 
>    In file included from include/linux/irqnr.h:10:0,
>                     from include/linux/irq.h:22,
>                     from kernel/irq/irqdesc.c:10:
>    arch/m68k/include/asm/irq.h:25:17: error: expected identifier or '(' before numeric constant
>     #define NR_IRQS 0
>                     ^

NR_IRQS = 0 and CONFIG_SPARSE_IRQ=n is bogus. That alldefconfig of m68k is
broken. Cc'ed m68 folks

Thanks,

	tglx

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

* Re: kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
  2016-02-28  9:32 ` Thomas Gleixner
@ 2016-02-28  9:52   ` Geert Uytterhoeven
  2016-02-28 10:33     ` Thomas Gleixner
  0 siblings, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2016-02-28  9:52 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: kbuild test robot, kbuild-all, LKML, Ingo Molnar

On Sun, Feb 28, 2016 at 10:32 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Sun, 28 Feb 2016, kbuild test robot wrote:
>> FYI, the error/warning still remains.
>>
>> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>> head:   691429e13dfaf5b0994b07cc166db41bd608ee3d
>> commit: 3795de236d67a05994a1a12759db9d4dd9ffc42c genirq: Distangle kernel/irq/handle.c
>> date:   5 years ago
>> config: m68k-alldefconfig (attached as .config)
>> reproduce:
>>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>>         chmod +x ~/bin/make.cross
>>         git checkout 3795de236d67a05994a1a12759db9d4dd9ffc42c
>>         # save the attached .config to linux build tree
>>         make.cross ARCH=m68k
>
> Again. This commit is just moving code into seperate files without changing
> the code. So it's not a new wreckage.
>
>> All errors (new ones prefixed by >>):
>>
>>    In file included from include/linux/irqnr.h:10:0,
>>                     from include/linux/irq.h:22,
>>                     from kernel/irq/irqdesc.c:10:
>>    arch/m68k/include/asm/irq.h:25:17: error: expected identifier or '(' before numeric constant
>>     #define NR_IRQS 0
>>                     ^
>
> NR_IRQS = 0 and CONFIG_SPARSE_IRQ=n is bogus. That alldefconfig of m68k is
> broken. Cc'ed m68 folks

No idea where this "alldefconfig" is coming from (it contains "2.6.36-rc5").
Is this an MMU=y allnoconfig?
It doesn't enable any platforms, which is not supported, and thus it isn't
known how many interrupts are needed.

BTW, I have a local fix to change NR_IRQS to 1 in that case, but that's
far from sufficient to build an MMU=y allnoconfig kernel.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
  2016-02-28  9:52   ` Geert Uytterhoeven
@ 2016-02-28 10:33     ` Thomas Gleixner
  2016-02-28 10:41       ` Geert Uytterhoeven
  0 siblings, 1 reply; 12+ messages in thread
From: Thomas Gleixner @ 2016-02-28 10:33 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: kbuild test robot, kbuild-all, LKML, Ingo Molnar

On Sun, 28 Feb 2016, Geert Uytterhoeven wrote:
> On Sun, Feb 28, 2016 at 10:32 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> > On Sun, 28 Feb 2016, kbuild test robot wrote:
> >> FYI, the error/warning still remains.
> >>
> >> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> >> head:   691429e13dfaf5b0994b07cc166db41bd608ee3d
> >> commit: 3795de236d67a05994a1a12759db9d4dd9ffc42c genirq: Distangle kernel/irq/handle.c
> >> date:   5 years ago
> >> config: m68k-alldefconfig (attached as .config)
> >> reproduce:
> >>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
> >>         chmod +x ~/bin/make.cross
> >>         git checkout 3795de236d67a05994a1a12759db9d4dd9ffc42c
> >>         # save the attached .config to linux build tree
> >>         make.cross ARCH=m68k
> >
> > Again. This commit is just moving code into seperate files without changing
> > the code. So it's not a new wreckage.
> >
> >> All errors (new ones prefixed by >>):
> >>
> >>    In file included from include/linux/irqnr.h:10:0,
> >>                     from include/linux/irq.h:22,
> >>                     from kernel/irq/irqdesc.c:10:
> >>    arch/m68k/include/asm/irq.h:25:17: error: expected identifier or '(' before numeric constant
> >>     #define NR_IRQS 0
> >>                     ^
> >
> > NR_IRQS = 0 and CONFIG_SPARSE_IRQ=n is bogus. That alldefconfig of m68k is
> > broken. Cc'ed m68 folks
> 
> No idea where this "alldefconfig" is coming from (it contains "2.6.36-rc5").
> Is this an MMU=y allnoconfig?

# make alldefconfig

That's one of the targets for 68k. And yes, it has MMU=y

> It doesn't enable any platforms, which is not supported, and thus it isn't
> known how many interrupts are needed.
> 
> BTW, I have a local fix to change NR_IRQS to 1 in that case, but that's
> far from sufficient to build an MMU=y allnoconfig kernel.

Yeah. NR_IRQS=1 is lame.

Thanks,

	tglx

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

* Re: kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
  2016-02-28 10:33     ` Thomas Gleixner
@ 2016-02-28 10:41       ` Geert Uytterhoeven
  0 siblings, 0 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2016-02-28 10:41 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: kbuild test robot, kbuild-all, LKML, Ingo Molnar

On Sun, Feb 28, 2016 at 11:33 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Sun, 28 Feb 2016, Geert Uytterhoeven wrote:
>> On Sun, Feb 28, 2016 at 10:32 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
>> > On Sun, 28 Feb 2016, kbuild test robot wrote:
>> >> FYI, the error/warning still remains.
>> >>
>> >> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>> >> head:   691429e13dfaf5b0994b07cc166db41bd608ee3d
>> >> commit: 3795de236d67a05994a1a12759db9d4dd9ffc42c genirq: Distangle kernel/irq/handle.c
>> >> date:   5 years ago
>> >> config: m68k-alldefconfig (attached as .config)

>> > NR_IRQS = 0 and CONFIG_SPARSE_IRQ=n is bogus. That alldefconfig of m68k is
>> > broken. Cc'ed m68 folks
>>
>> No idea where this "alldefconfig" is coming from (it contains "2.6.36-rc5").
>> Is this an MMU=y allnoconfig?
>
> # make alldefconfig
>
> That's one of the targets for 68k. And yes, it has MMU=y

Doh, one is never too old to learn...

This is the first time someone ever complains to me about alldefconfig ;-)

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
  2016-03-13 20:29 kbuild test robot
@ 2016-03-14  7:53 ` Thomas Gleixner
  0 siblings, 0 replies; 12+ messages in thread
From: Thomas Gleixner @ 2016-03-14  7:53 UTC (permalink / raw)
  To: kbuild test robot; +Cc: kbuild-all, linux-kernel, Ingo Molnar

Fenguang,

On Mon, 14 Mar 2016, kbuild test robot wrote:

> Hi Thomas,
> 
> FYI, the error/warning still remains.

>         make.cross ARCH=m68k 

>    arch/m68k/include/asm/irq.h:25:17: error: expected identifier or '(' before numeric constant
>     #define NR_IRQS 0
>                     ^

Why do you insist on pestering me about that m86k problem? I explained you 3
times now, that it's not a genirq core issue.

Thanks,

	tglx

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

* kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
@ 2016-03-13 20:29 kbuild test robot
  2016-03-14  7:53 ` Thomas Gleixner
  0 siblings, 1 reply; 12+ messages in thread
From: kbuild test robot @ 2016-03-13 20:29 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: kbuild-all, linux-kernel, Ingo Molnar

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

Hi Thomas,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   f414ca64be4b36c30deb5b5fa25c5a8ff42ea56b
commit: 3795de236d67a05994a1a12759db9d4dd9ffc42c genirq: Distangle kernel/irq/handle.c
date:   5 years ago
config: m68k-alldefconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 3795de236d67a05994a1a12759db9d4dd9ffc42c
        # save the attached .config to linux build tree
        make.cross ARCH=m68k 

All errors (new ones prefixed by >>):

   In file included from include/linux/irqnr.h:10:0,
                    from include/linux/irq.h:22,
                    from kernel/irq/irqdesc.c:10:
   arch/m68k/include/asm/irq.h:25:17: error: expected identifier or '(' before numeric constant
    #define NR_IRQS 0
                    ^
   include/linux/irqnr.h:15:19: note: in expansion of macro 'NR_IRQS'
    #define nr_irqs   NR_IRQS
                      ^
   kernel/irq/irqdesc.c:36:5: note: in expansion of macro 'nr_irqs'
    int nr_irqs = NR_IRQS;
        ^
>> kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
     [0 ... NR_IRQS-1] = {
     ^
   kernel/irq/irqdesc.c:206:2: error: (near initialization for 'irq_desc')
   kernel/irq/irqdesc.c:208:17: error: 'handle_bad_irq' undeclared here (not in a function)
      .handle_irq = handle_bad_irq,
                    ^
   kernel/irq/irqdesc.c:211:2: warning: excess elements in array initializer
     }
     ^
   kernel/irq/irqdesc.c:211:2: warning: (near initialization for 'irq_desc')
   kernel/irq/irqdesc.c: In function 'early_irq_init':
   kernel/irq/irqdesc.c:230:28: error: 'no_irq_chip' undeclared (first use in this function)
      desc[i].irq_data.chip = &no_irq_chip;
                               ^
   kernel/irq/irqdesc.c:230:28: note: each undeclared identifier is reported only once for each function it appears in
   In file included from include/linux/irq.h:22:0,
                    from kernel/irq/irqdesc.c:10:
   kernel/irq/irqdesc.c: At top level:
   include/linux/irqnr.h:16:27: error: expected identifier or '(' before '&' token
    #define irq_to_desc(irq) (&irq_desc[irq])
                              ^
   kernel/irq/irqdesc.c:238:18: note: in expansion of macro 'irq_to_desc'
    struct irq_desc *irq_to_desc(unsigned int irq)
                     ^
   kernel/irq/irqdesc.c:254:6: error: redefinition of 'early_init_irq_lock_class'
    void early_init_irq_lock_class(void)
         ^
   In file included from include/linux/hardirq.h:8:0,
                    from arch/m68k/include/asm/system_mm.h:69,
                    from arch/m68k/include/asm/system.h:4,
                    from include/linux/list.h:8,
                    from include/linux/smp.h:11,
                    from include/linux/irq.h:12,
                    from kernel/irq/irqdesc.c:10:
   include/linux/lockdep.h:430:20: note: previous definition of 'early_init_irq_lock_class' was here
    static inline void early_init_irq_lock_class(void)
                       ^
   kernel/irq/irqdesc.c: In function 'early_init_irq_lock_class':
   kernel/irq/irqdesc.c:256:19: warning: unused variable 'desc' [-Wunused-variable]
     struct irq_desc *desc;
                      ^
   kernel/irq/irqdesc.c: At top level:
   kernel/irq/irqdesc.c:264:14: error: redefinition of 'kstat_irqs_cpu'
    unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
                 ^
   In file included from kernel/irq/irqdesc.c:14:0:
   include/linux/kernel_stat.h:59:28: note: previous definition of 'kstat_irqs_cpu' was here
    static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
                               ^

vim +206 kernel/irq/irqdesc.c

    30	#else
    31	static void __init init_irq_default_affinity(void)
    32	{
    33	}
    34	#endif
    35	
  > 36	int nr_irqs = NR_IRQS;
    37	EXPORT_SYMBOL_GPL(nr_irqs);
    38	
    39	#ifdef CONFIG_SPARSE_IRQ
    40	
    41	static struct irq_desc irq_desc_init = {
    42		.status		= IRQ_DISABLED,
    43		.handle_irq	= handle_bad_irq,
    44		.depth		= 1,
    45		.lock		= __RAW_SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
    46	};
    47	
    48	void __ref init_kstat_irqs(struct irq_desc *desc, int node, int nr)
    49	{
    50		void *ptr;
    51	
    52		ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs),
    53				   GFP_ATOMIC, node);
    54	
    55		/*
    56		 * don't overwite if can not get new one
    57		 * init_copy_kstat_irqs() could still use old one
    58		 */
    59		if (ptr) {
    60			printk(KERN_DEBUG "  alloc kstat_irqs on node %d\n", node);
    61			desc->kstat_irqs = ptr;
    62		}
    63	}
    64	
    65	static void init_one_irq_desc(int irq, struct irq_desc *desc, int node)
    66	{
    67		memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
    68	
    69		raw_spin_lock_init(&desc->lock);
    70		desc->irq_data.irq = irq;
    71	#ifdef CONFIG_SMP
    72		desc->irq_data.node = node;
    73	#endif
    74		lockdep_set_class(&desc->lock, &irq_desc_lock_class);
    75		init_kstat_irqs(desc, node, nr_cpu_ids);
    76		if (!desc->kstat_irqs) {
    77			printk(KERN_ERR "can not alloc kstat_irqs\n");
    78			BUG_ON(1);
    79		}
    80		if (!alloc_desc_masks(desc, node, false)) {
    81			printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
    82			BUG_ON(1);
    83		}
    84		init_desc_masks(desc);
    85		arch_init_chip_data(desc, node);
    86	}
    87	
    88	/*
    89	 * Protect the sparse_irqs:
    90	 */
    91	DEFINE_RAW_SPINLOCK(sparse_irq_lock);
    92	
    93	static RADIX_TREE(irq_desc_tree, GFP_ATOMIC);
    94	
    95	static void set_irq_desc(unsigned int irq, struct irq_desc *desc)
    96	{
    97		radix_tree_insert(&irq_desc_tree, irq, desc);
    98	}
    99	
   100	struct irq_desc *irq_to_desc(unsigned int irq)
   101	{
   102		return radix_tree_lookup(&irq_desc_tree, irq);
   103	}
   104	
   105	void replace_irq_desc(unsigned int irq, struct irq_desc *desc)
   106	{
   107		void **ptr;
   108	
   109		ptr = radix_tree_lookup_slot(&irq_desc_tree, irq);
   110		if (ptr)
   111			radix_tree_replace_slot(ptr, desc);
   112	}
   113	
   114	static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = {
   115		[0 ... NR_IRQS_LEGACY-1] = {
   116			.status		= IRQ_DISABLED,
   117			.handle_irq	= handle_bad_irq,
   118			.depth		= 1,
   119			.lock		= __RAW_SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
   120		}
   121	};
   122	
   123	static unsigned int *kstat_irqs_legacy;
   124	
   125	int __init early_irq_init(void)
   126	{
   127		struct irq_desc *desc;
   128		int legacy_count;
   129		int node;
   130		int i;
   131	
   132		init_irq_default_affinity();
   133	
   134		 /* initialize nr_irqs based on nr_cpu_ids */
   135		arch_probe_nr_irqs();
   136		printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs);
   137	
   138		desc = irq_desc_legacy;
   139		legacy_count = ARRAY_SIZE(irq_desc_legacy);
   140		node = first_online_node;
   141	
   142		/* allocate based on nr_cpu_ids */
   143		kstat_irqs_legacy = kzalloc_node(NR_IRQS_LEGACY * nr_cpu_ids *
   144						  sizeof(int), GFP_NOWAIT, node);
   145	
   146		irq_desc_init.irq_data.chip = &no_irq_chip;
   147	
   148		for (i = 0; i < legacy_count; i++) {
   149			desc[i].irq_data.irq = i;
   150			desc[i].irq_data.chip = &no_irq_chip;
   151	#ifdef CONFIG_SMP
   152			desc[i].irq_data.node = node;
   153	#endif
   154			desc[i].kstat_irqs = kstat_irqs_legacy + i * nr_cpu_ids;
   155			lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
   156			alloc_desc_masks(&desc[i], node, true);
   157			init_desc_masks(&desc[i]);
   158			set_irq_desc(i, &desc[i]);
   159		}
   160	
   161		return arch_early_irq_init();
   162	}
   163	
   164	struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node)
   165	{
   166		struct irq_desc *desc;
   167		unsigned long flags;
   168	
   169		if (irq >= nr_irqs) {
   170			WARN(1, "irq (%d) >= nr_irqs (%d) in irq_to_desc_alloc\n",
   171				irq, nr_irqs);
   172			return NULL;
   173		}
   174	
   175		desc = irq_to_desc(irq);
   176		if (desc)
   177			return desc;
   178	
   179		raw_spin_lock_irqsave(&sparse_irq_lock, flags);
   180	
   181		/* We have to check it to avoid races with another CPU */
   182		desc = irq_to_desc(irq);
   183		if (desc)
   184			goto out_unlock;
   185	
   186		desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
   187	
   188		printk(KERN_DEBUG "  alloc irq_desc for %d on node %d\n", irq, node);
   189		if (!desc) {
   190			printk(KERN_ERR "can not alloc irq_desc\n");
   191			BUG_ON(1);
   192		}
   193		init_one_irq_desc(irq, desc, node);
   194	
   195		set_irq_desc(irq, desc);
   196	
   197	out_unlock:
   198		raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
   199	
   200		return desc;
   201	}
   202	
   203	#else /* !CONFIG_SPARSE_IRQ */
   204	
   205	struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
 > 206		[0 ... NR_IRQS-1] = {
   207			.status		= IRQ_DISABLED,
   208			.handle_irq	= handle_bad_irq,
   209			.depth		= 1,

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

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 3461 bytes --]

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

* Re: kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
  2016-03-08  9:21   ` Ingo Molnar
@ 2016-03-08 10:09     ` Geert Uytterhoeven
  0 siblings, 0 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2016-03-08 10:09 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: kbuild test robot, Thomas Gleixner, kbuild-all, linux-kernel,
	Ingo Molnar

Hi Ingo,

On Tue, Mar 8, 2016 at 10:21 AM, Ingo Molnar <mingo@kernel.org> wrote:
>> Same comment as before: thou shall not compile kernels for m68k without
>> selecting any platform support.
>
> That should be enforced at the Kconfig level.

I'm fully aware of that ;-)

Unfortunately it's not trivial.
How do you enforce that at least one option from a list of options is enabled?

M68k (with MMU) supports three distinct classes of machines:
  1. Coldfire (with Coldfire MMU)
  2. Sun-3 (with Sun-3 MMU)
  3. Rest (with classic Motorola MMU)

Class 3 contains multiple machine types (cfr. top of arch/m68k/Kconfig.machine)
and at least one of them must be selected.
So far everything I tried conflicted with enforcing the 3 distinct classes.

For nommu, it's simpler, as you can typically support a single platform only,
due to the different platforms (usually) having RAM at different addresses.

Suggestions are welcome....

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
  2016-03-08  8:44 ` Geert Uytterhoeven
@ 2016-03-08  9:21   ` Ingo Molnar
  2016-03-08 10:09     ` Geert Uytterhoeven
  0 siblings, 1 reply; 12+ messages in thread
From: Ingo Molnar @ 2016-03-08  9:21 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: kbuild test robot, Thomas Gleixner, kbuild-all, linux-kernel,
	Ingo Molnar


* Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> On Tue, Mar 8, 2016 at 9:38 AM, kbuild test robot
> <fengguang.wu@intel.com> wrote:
> > FYI, the error/warning still remains.
> >
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   e2857b8f11a289ed2b61d18d0665e05c1053c446
> > commit: 3795de236d67a05994a1a12759db9d4dd9ffc42c genirq: Distangle kernel/irq/handle.c
> > date:   5 years ago
> > config: m68k-alldefconfig (attached as .config)
> > reproduce:
> >         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         git checkout 3795de236d67a05994a1a12759db9d4dd9ffc42c
> >         # save the attached .config to linux build tree
> >         make.cross ARCH=m68k
> >
> > All errors (new ones prefixed by >>):
> >
> >    In file included from include/linux/irqnr.h:10:0,
> >                     from include/linux/irq.h:22,
> >                     from kernel/irq/irqdesc.c:10:
> >    arch/m68k/include/asm/irq.h:25:17: error: expected identifier or '(' before numeric constant
> >     #define NR_IRQS 0
> >                     ^
> >    include/linux/irqnr.h:15:19: note: in expansion of macro 'NR_IRQS'
> >     #define nr_irqs   NR_IRQS
> >                       ^
> >    kernel/irq/irqdesc.c:36:5: note: in expansion of macro 'nr_irqs'
> >     int nr_irqs = NR_IRQS;
> >         ^
> >>> kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
> >      [0 ... NR_IRQS-1] = {
> >      ^
> 
> Same comment as before: thou shall not compile kernels for m68k without
> selecting any platform support.

That should be enforced at the Kconfig level.

Thanks,

	Ingo

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

* Re: kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
  2016-03-08  8:38 kbuild test robot
  2016-03-08  8:44 ` Geert Uytterhoeven
@ 2016-03-08  9:08 ` Thomas Gleixner
  1 sibling, 0 replies; 12+ messages in thread
From: Thomas Gleixner @ 2016-03-08  9:08 UTC (permalink / raw)
  To: kbuild test robot; +Cc: kbuild-all, linux-kernel, Ingo Molnar

On Tue, 8 Mar 2016, kbuild test robot wrote:

> Hi Thomas,
> 
> FYI, the error/warning still remains.
> 
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   e2857b8f11a289ed2b61d18d0665e05c1053c446
> commit: 3795de236d67a05994a1a12759db9d4dd9ffc42c genirq: Distangle kernel/irq/handle.c
> date:   5 years ago
> config: m68k-alldefconfig (attached as .config)
> reproduce:
>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         git checkout 3795de236d67a05994a1a12759db9d4dd9ffc42c
>         # save the attached .config to linux build tree
>         make.cross ARCH=m68k 
> 
> All errors (new ones prefixed by >>):
> 
>    In file included from include/linux/irqnr.h:10:0,
>                     from include/linux/irq.h:22,
>                     from kernel/irq/irqdesc.c:10:
>    arch/m68k/include/asm/irq.h:25:17: error: expected identifier or '(' before numeric constant
>     #define NR_IRQS 0

As I explained before. That's not a genirq issue. It's broken in m68k and
Geert already knows about it.

Thanks,

	tglx

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

* Re: kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
  2016-03-08  8:38 kbuild test robot
@ 2016-03-08  8:44 ` Geert Uytterhoeven
  2016-03-08  9:21   ` Ingo Molnar
  2016-03-08  9:08 ` Thomas Gleixner
  1 sibling, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2016-03-08  8:44 UTC (permalink / raw)
  To: kbuild test robot; +Cc: Thomas Gleixner, kbuild-all, linux-kernel, Ingo Molnar

On Tue, Mar 8, 2016 at 9:38 AM, kbuild test robot
<fengguang.wu@intel.com> wrote:
> FYI, the error/warning still remains.
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   e2857b8f11a289ed2b61d18d0665e05c1053c446
> commit: 3795de236d67a05994a1a12759db9d4dd9ffc42c genirq: Distangle kernel/irq/handle.c
> date:   5 years ago
> config: m68k-alldefconfig (attached as .config)
> reproduce:
>         wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         git checkout 3795de236d67a05994a1a12759db9d4dd9ffc42c
>         # save the attached .config to linux build tree
>         make.cross ARCH=m68k
>
> All errors (new ones prefixed by >>):
>
>    In file included from include/linux/irqnr.h:10:0,
>                     from include/linux/irq.h:22,
>                     from kernel/irq/irqdesc.c:10:
>    arch/m68k/include/asm/irq.h:25:17: error: expected identifier or '(' before numeric constant
>     #define NR_IRQS 0
>                     ^
>    include/linux/irqnr.h:15:19: note: in expansion of macro 'NR_IRQS'
>     #define nr_irqs   NR_IRQS
>                       ^
>    kernel/irq/irqdesc.c:36:5: note: in expansion of macro 'nr_irqs'
>     int nr_irqs = NR_IRQS;
>         ^
>>> kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
>      [0 ... NR_IRQS-1] = {
>      ^

Same comment as before: thou shall not compile kernels for m68k without
selecting any platform support.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
@ 2016-03-08  8:38 kbuild test robot
  2016-03-08  8:44 ` Geert Uytterhoeven
  2016-03-08  9:08 ` Thomas Gleixner
  0 siblings, 2 replies; 12+ messages in thread
From: kbuild test robot @ 2016-03-08  8:38 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: kbuild-all, linux-kernel, Ingo Molnar

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

Hi Thomas,

FYI, the error/warning still remains.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   e2857b8f11a289ed2b61d18d0665e05c1053c446
commit: 3795de236d67a05994a1a12759db9d4dd9ffc42c genirq: Distangle kernel/irq/handle.c
date:   5 years ago
config: m68k-alldefconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 3795de236d67a05994a1a12759db9d4dd9ffc42c
        # save the attached .config to linux build tree
        make.cross ARCH=m68k 

All errors (new ones prefixed by >>):

   In file included from include/linux/irqnr.h:10:0,
                    from include/linux/irq.h:22,
                    from kernel/irq/irqdesc.c:10:
   arch/m68k/include/asm/irq.h:25:17: error: expected identifier or '(' before numeric constant
    #define NR_IRQS 0
                    ^
   include/linux/irqnr.h:15:19: note: in expansion of macro 'NR_IRQS'
    #define nr_irqs   NR_IRQS
                      ^
   kernel/irq/irqdesc.c:36:5: note: in expansion of macro 'nr_irqs'
    int nr_irqs = NR_IRQS;
        ^
>> kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds
     [0 ... NR_IRQS-1] = {
     ^
   kernel/irq/irqdesc.c:206:2: error: (near initialization for 'irq_desc')
   kernel/irq/irqdesc.c:208:17: error: 'handle_bad_irq' undeclared here (not in a function)
      .handle_irq = handle_bad_irq,
                    ^
   kernel/irq/irqdesc.c:211:2: warning: excess elements in array initializer
     }
     ^
   kernel/irq/irqdesc.c:211:2: warning: (near initialization for 'irq_desc')
   kernel/irq/irqdesc.c: In function 'early_irq_init':
   kernel/irq/irqdesc.c:230:28: error: 'no_irq_chip' undeclared (first use in this function)
      desc[i].irq_data.chip = &no_irq_chip;
                               ^
   kernel/irq/irqdesc.c:230:28: note: each undeclared identifier is reported only once for each function it appears in
   In file included from include/linux/irq.h:22:0,
                    from kernel/irq/irqdesc.c:10:
   kernel/irq/irqdesc.c: At top level:
   include/linux/irqnr.h:16:27: error: expected identifier or '(' before '&' token
    #define irq_to_desc(irq) (&irq_desc[irq])
                              ^
   kernel/irq/irqdesc.c:238:18: note: in expansion of macro 'irq_to_desc'
    struct irq_desc *irq_to_desc(unsigned int irq)
                     ^
   kernel/irq/irqdesc.c:254:6: error: redefinition of 'early_init_irq_lock_class'
    void early_init_irq_lock_class(void)
         ^
   In file included from include/linux/hardirq.h:8:0,
                    from arch/m68k/include/asm/system_mm.h:69,
                    from arch/m68k/include/asm/system.h:4,
                    from include/linux/list.h:8,
                    from include/linux/smp.h:11,
                    from include/linux/irq.h:12,
                    from kernel/irq/irqdesc.c:10:
   include/linux/lockdep.h:430:20: note: previous definition of 'early_init_irq_lock_class' was here
    static inline void early_init_irq_lock_class(void)
                       ^
   kernel/irq/irqdesc.c: In function 'early_init_irq_lock_class':
   kernel/irq/irqdesc.c:256:19: warning: unused variable 'desc' [-Wunused-variable]
     struct irq_desc *desc;
                      ^
   kernel/irq/irqdesc.c: At top level:
   kernel/irq/irqdesc.c:264:14: error: redefinition of 'kstat_irqs_cpu'
    unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
                 ^
   In file included from kernel/irq/irqdesc.c:14:0:
   include/linux/kernel_stat.h:59:28: note: previous definition of 'kstat_irqs_cpu' was here
    static inline unsigned int kstat_irqs_cpu(unsigned int irq, int cpu)
                               ^

vim +206 kernel/irq/irqdesc.c

    30	#else
    31	static void __init init_irq_default_affinity(void)
    32	{
    33	}
    34	#endif
    35	
  > 36	int nr_irqs = NR_IRQS;
    37	EXPORT_SYMBOL_GPL(nr_irqs);
    38	
    39	#ifdef CONFIG_SPARSE_IRQ
    40	
    41	static struct irq_desc irq_desc_init = {
    42		.status		= IRQ_DISABLED,
    43		.handle_irq	= handle_bad_irq,
    44		.depth		= 1,
    45		.lock		= __RAW_SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
    46	};
    47	
    48	void __ref init_kstat_irqs(struct irq_desc *desc, int node, int nr)
    49	{
    50		void *ptr;
    51	
    52		ptr = kzalloc_node(nr * sizeof(*desc->kstat_irqs),
    53				   GFP_ATOMIC, node);
    54	
    55		/*
    56		 * don't overwite if can not get new one
    57		 * init_copy_kstat_irqs() could still use old one
    58		 */
    59		if (ptr) {
    60			printk(KERN_DEBUG "  alloc kstat_irqs on node %d\n", node);
    61			desc->kstat_irqs = ptr;
    62		}
    63	}
    64	
    65	static void init_one_irq_desc(int irq, struct irq_desc *desc, int node)
    66	{
    67		memcpy(desc, &irq_desc_init, sizeof(struct irq_desc));
    68	
    69		raw_spin_lock_init(&desc->lock);
    70		desc->irq_data.irq = irq;
    71	#ifdef CONFIG_SMP
    72		desc->irq_data.node = node;
    73	#endif
    74		lockdep_set_class(&desc->lock, &irq_desc_lock_class);
    75		init_kstat_irqs(desc, node, nr_cpu_ids);
    76		if (!desc->kstat_irqs) {
    77			printk(KERN_ERR "can not alloc kstat_irqs\n");
    78			BUG_ON(1);
    79		}
    80		if (!alloc_desc_masks(desc, node, false)) {
    81			printk(KERN_ERR "can not alloc irq_desc cpumasks\n");
    82			BUG_ON(1);
    83		}
    84		init_desc_masks(desc);
    85		arch_init_chip_data(desc, node);
    86	}
    87	
    88	/*
    89	 * Protect the sparse_irqs:
    90	 */
    91	DEFINE_RAW_SPINLOCK(sparse_irq_lock);
    92	
    93	static RADIX_TREE(irq_desc_tree, GFP_ATOMIC);
    94	
    95	static void set_irq_desc(unsigned int irq, struct irq_desc *desc)
    96	{
    97		radix_tree_insert(&irq_desc_tree, irq, desc);
    98	}
    99	
   100	struct irq_desc *irq_to_desc(unsigned int irq)
   101	{
   102		return radix_tree_lookup(&irq_desc_tree, irq);
   103	}
   104	
   105	void replace_irq_desc(unsigned int irq, struct irq_desc *desc)
   106	{
   107		void **ptr;
   108	
   109		ptr = radix_tree_lookup_slot(&irq_desc_tree, irq);
   110		if (ptr)
   111			radix_tree_replace_slot(ptr, desc);
   112	}
   113	
   114	static struct irq_desc irq_desc_legacy[NR_IRQS_LEGACY] __cacheline_aligned_in_smp = {
   115		[0 ... NR_IRQS_LEGACY-1] = {
   116			.status		= IRQ_DISABLED,
   117			.handle_irq	= handle_bad_irq,
   118			.depth		= 1,
   119			.lock		= __RAW_SPIN_LOCK_UNLOCKED(irq_desc_init.lock),
   120		}
   121	};
   122	
   123	static unsigned int *kstat_irqs_legacy;
   124	
   125	int __init early_irq_init(void)
   126	{
   127		struct irq_desc *desc;
   128		int legacy_count;
   129		int node;
   130		int i;
   131	
   132		init_irq_default_affinity();
   133	
   134		 /* initialize nr_irqs based on nr_cpu_ids */
   135		arch_probe_nr_irqs();
   136		printk(KERN_INFO "NR_IRQS:%d nr_irqs:%d\n", NR_IRQS, nr_irqs);
   137	
   138		desc = irq_desc_legacy;
   139		legacy_count = ARRAY_SIZE(irq_desc_legacy);
   140		node = first_online_node;
   141	
   142		/* allocate based on nr_cpu_ids */
   143		kstat_irqs_legacy = kzalloc_node(NR_IRQS_LEGACY * nr_cpu_ids *
   144						  sizeof(int), GFP_NOWAIT, node);
   145	
   146		irq_desc_init.irq_data.chip = &no_irq_chip;
   147	
   148		for (i = 0; i < legacy_count; i++) {
   149			desc[i].irq_data.irq = i;
   150			desc[i].irq_data.chip = &no_irq_chip;
   151	#ifdef CONFIG_SMP
   152			desc[i].irq_data.node = node;
   153	#endif
   154			desc[i].kstat_irqs = kstat_irqs_legacy + i * nr_cpu_ids;
   155			lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
   156			alloc_desc_masks(&desc[i], node, true);
   157			init_desc_masks(&desc[i]);
   158			set_irq_desc(i, &desc[i]);
   159		}
   160	
   161		return arch_early_irq_init();
   162	}
   163	
   164	struct irq_desc * __ref irq_to_desc_alloc_node(unsigned int irq, int node)
   165	{
   166		struct irq_desc *desc;
   167		unsigned long flags;
   168	
   169		if (irq >= nr_irqs) {
   170			WARN(1, "irq (%d) >= nr_irqs (%d) in irq_to_desc_alloc\n",
   171				irq, nr_irqs);
   172			return NULL;
   173		}
   174	
   175		desc = irq_to_desc(irq);
   176		if (desc)
   177			return desc;
   178	
   179		raw_spin_lock_irqsave(&sparse_irq_lock, flags);
   180	
   181		/* We have to check it to avoid races with another CPU */
   182		desc = irq_to_desc(irq);
   183		if (desc)
   184			goto out_unlock;
   185	
   186		desc = kzalloc_node(sizeof(*desc), GFP_ATOMIC, node);
   187	
   188		printk(KERN_DEBUG "  alloc irq_desc for %d on node %d\n", irq, node);
   189		if (!desc) {
   190			printk(KERN_ERR "can not alloc irq_desc\n");
   191			BUG_ON(1);
   192		}
   193		init_one_irq_desc(irq, desc, node);
   194	
   195		set_irq_desc(irq, desc);
   196	
   197	out_unlock:
   198		raw_spin_unlock_irqrestore(&sparse_irq_lock, flags);
   199	
   200		return desc;
   201	}
   202	
   203	#else /* !CONFIG_SPARSE_IRQ */
   204	
   205	struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
 > 206		[0 ... NR_IRQS-1] = {
   207			.status		= IRQ_DISABLED,
   208			.handle_irq	= handle_bad_irq,
   209			.depth		= 1,

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

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 3460 bytes --]

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

end of thread, other threads:[~2016-03-14  7:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-27 23:59 kernel/irq/irqdesc.c:206:2: error: array index in initializer exceeds array bounds kbuild test robot
2016-02-28  9:32 ` Thomas Gleixner
2016-02-28  9:52   ` Geert Uytterhoeven
2016-02-28 10:33     ` Thomas Gleixner
2016-02-28 10:41       ` Geert Uytterhoeven
2016-03-08  8:38 kbuild test robot
2016-03-08  8:44 ` Geert Uytterhoeven
2016-03-08  9:21   ` Ingo Molnar
2016-03-08 10:09     ` Geert Uytterhoeven
2016-03-08  9:08 ` Thomas Gleixner
2016-03-13 20:29 kbuild test robot
2016-03-14  7:53 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®