mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Thomas Gleixner <tglx@linutronix.de>,
	LKML <linux-kernel@vger.kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>, Peter Anvin <hpa@zytor.com>,
	Tony Luck <tony.luck@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Chris Metcalf <cmetcalf@tilera.com>,
	Fenghua Yu <fenghua.yu@intel.com>
Subject: Re: [patch 03/32] genirq: Provide generic hwirq allocation facility
Date: Thu, 08 May 2014 13:07:38 +0100	[thread overview]
Message-ID: <20140508120738.B70FDC40D85@trevor.secretlab.ca> (raw)
In-Reply-To: <20140507154334.208629358@linutronix.de>

On Wed, 07 May 2014 15:44:05 -0000, Thomas Gleixner <tglx@linutronix.de> wrote:
> Not really the solution to the problem, but at least it confines the
> mess in the core code and allows to get rid of the create/destroy_irq
> variants from hell, i.e. 3 implementations with different semantics
> plus the x86 specific variants __create_irqs and create_irq_nr
> which have been invented in another circle of hell.
> 
> x86 : x86 should be converted to irq domains and I'm deliberately
>       making it impossible to do the multi-vector MSI support by
>       adding more crap to the current mess. It's not that hard to do
>       and I'm really tired of the trainwrecks which have been invented
>       by baindaid engineering so far. Any attempt to do multi-vector
>       MSI or ioapic hotplug without converting to irq domains is NAKed
>       hereby.
> 
> tile: Might use irq domains as well, but it has a very limited
>       interrupt space, so handling it via this functionality might be
>       the right thing to do even in the long run.
> 
> ia64: That's an hopeless case, as I doubt that anyone has the stomach
>       to rewrite the homebrewn dynamic allocation facilities. I stared
>       at it for a couple of hours and gave up. The create/destroy_irq
>       mess could be made private to itanic right away if there
>       wouldn't be the iommu/dmar driver being shared with x86. So to
>       do that I'm going to add a separate ia64 specific implementation
>       later in order not to deep-six itanic right away.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: x86@kernel.org
> Cc: Chris Metcalf <cmetcalf@tilera.com>
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: Fenghua Yu <fenghua.yu@intel.com>
> 
> ---
>  include/linux/irq.h  |   15 +++++++++++++++
>  kernel/irq/Kconfig   |    5 +++++
>  kernel/irq/irqdesc.c |   51 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 71 insertions(+)
> 
> Index: tip/include/linux/irq.h
> ===================================================================
> --- tip.orig/include/linux/irq.h
> +++ tip/include/linux/irq.h
> @@ -637,6 +637,21 @@ static inline int irq_reserve_irq(unsign
>  	return irq_reserve_irqs(irq, 1);
>  }
>  
> +#ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
> +unsigned int irq_alloc_hwirqs(int cnt, int node);
> +static inline unsigned int irq_alloc_hwirq(int node)
> +{
> +	return irq_alloc_hwirqs(1, node);
> +}
> +void irq_free_hwirqs(unsigned int from, int cnt);
> +static inline void irq_free_hwirq(unsigned int irq)
> +{
> +	return irq_free_hwirqs(irq, 1);
> +}
> +int arch_setup_hwirq(unsigned int irq, int node);
> +void arch_teardown_hwirq(unsigned int irq);
> +#endif
> +
>  #ifndef irq_reg_writel
>  # define irq_reg_writel(val, addr)	writel(val, addr)
>  #endif
> Index: tip/kernel/irq/Kconfig
> ===================================================================
> --- tip.orig/kernel/irq/Kconfig
> +++ tip/kernel/irq/Kconfig
> @@ -17,6 +17,11 @@ config GENERIC_IRQ_SHOW
>  config GENERIC_IRQ_SHOW_LEVEL
>         bool
>  
> +# Facility to allocate an hardware interrupt. This is legacy support
> +# and should not be used in new code. Use irq domains instead.
> +config GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
> +       bool
> +
>  # Support for delayed migration from interrupt context
>  config GENERIC_PENDING_IRQ
>  	bool
> Index: tip/kernel/irq/irqdesc.c
> ===================================================================
> --- tip.orig/kernel/irq/irqdesc.c
> +++ tip/kernel/irq/irqdesc.c
> @@ -396,6 +396,57 @@ err:
>  }
>  EXPORT_SYMBOL_GPL(__irq_alloc_descs);
>  
> +#ifdef CONFIG_GENERIC_IRQ_LEGACY_ALLOC_HWIRQ
> +/**
> + * irq_alloc_hwirqs - Allocate an irq descriptor and initialize the hardware
> + * @cnt:	number of interrupts to allocate
> + * @node:	node on which to allocate
> + *
> + * Returns an interrupt number > 0 or 0, if the allocation fails.
> + */
> +unsigned int irq_alloc_hwirqs(int cnt, int node)
> +{
> +	int i, irq = __irq_alloc_descs(-1, 0, cnt, node, NULL);
> +
> +	if (irq < 0)
> +		return 0;
> +
> +	for (i = irq; cnt > 0; i++, cnt--) {
> +		if (arch_setup_hwirq(i, node))
> +			goto err;
> +		irq_clear_status_flags(i, _IRQ_NOREQUEST);
> +	}
> +	return irq;
> +
> +err:
> +	for (i--; i >= irq; i--) {
> +		irq_set_status_flags(i, _IRQ_NOREQUEST | _IRQ_NOPROBE);
> +		arch_teardown_hwirq(i);
> +	}
> +	irq_free_descs(irq, cnt);
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(irq_alloc_hwirqs);

Okay, so regarding this and irq_domains, I think the functionality
overlaps and irq_domain conversion wouldn't directly use this API. I
could see two ways that it would be wired up in an irq_domain
conversion...

1) use an irq_domain to represent the root of the interrupt tree and be
responsible for all of the hardware irqs. Child interrupt controllers
would allocate a hwirq from the root irq_domain and program itself
accordingly. This approach would either not use this API, or make it
entirely internal to the root irq_domain.

2) Use this API as the root of the interrupt tree and make first level
of child interrupt controllers use this API to allocate HWIRQs to use
for their irq outputs.

Most of the platforms using irq_domain now fall in the first category,
which I think makes the most sense. Any platform like x86 that has
multiple hwirq vectors and the option of per-cpu vectors would be best
to keep all of that detail in one place. We could add a cpumask variant
to the irqdomain APIs, and add a stock implementation of an allocator
that can intelligently allocate when cpumasks are used.

g.

> +
> +/**
> + * irq_free_hwirqs - Free irq descriptor and cleanup the hardware
> + * @from:	Free from irq number
> + * @cnt:	number of interrupts to free
> + *
> + */
> +void irq_free_hwirqs(unsigned int from, int cnt)
> +{
> +	int i;
> +
> +	for (i = from; cnt > 0; i++, cnt--) {
> +		irq_set_status_flags(i, _IRQ_NOREQUEST | _IRQ_NOPROBE);
> +		arch_teardown_hwirq(i);
> +	}
> +	irq_free_descs(from, cnt);
> +}
> +EXPORT_SYMBOL_GPL(irq_free_hwirqs);
> +#endif
> +
>  /**
>   * irq_reserve_irqs - mark irqs allocated
>   * @from:	mark from irq number
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


  parent reply	other threads:[~2014-05-08 12:07 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-07 15:44 [patch 00/32] genirq: Another round of tree wide cleanups Thomas Gleixner
2014-05-07 15:44 ` [patch 01/32] arm: iop13xx: Use sparse irqs for MSI Thomas Gleixner
2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 02/32] mips: Kill pointless destroy_irq() Thomas Gleixner
2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 03/32] genirq: Provide generic hwirq allocation facility Thomas Gleixner
2014-05-07 20:37   ` Chris Metcalf
2014-05-07 23:15     ` Thomas Gleixner
2014-05-08 10:22       ` Thomas Gleixner
2014-05-13 16:59         ` Thomas Gleixner
2014-05-13 17:48           ` Luck, Tony
2014-05-14 17:57       ` Chris Metcalf
2014-05-14 23:57         ` Thomas Gleixner
2014-05-08 12:07   ` Grant Likely [this message]
2014-05-08 13:12     ` Thomas Gleixner
2014-05-14 17:44   ` Chris Metcalf
2014-05-14 23:47     ` Thomas Gleixner
2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 04/32] x86: Implement arch_setup/teardown_hwirq() Thomas Gleixner
2014-05-16 13:31   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 06/32] x86: hpet: Use irq_alloc/free_hwirq() Thomas Gleixner
2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 05/32] x86: irq_remapping: " Thomas Gleixner
2014-05-14  9:32   ` Joerg Roedel
2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 07/32] x86: uv: " Thomas Gleixner
2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 08/32] x86: htirq: Use irq_alloc/free_irq() Thomas Gleixner
2014-05-07 16:03   ` Bjorn Helgaas
2014-05-07 16:30     ` Thomas Gleixner
2014-05-16 13:32   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 09/32] x86: ioapic: Use irq_alloc/free_hwirq() Thomas Gleixner
2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 11/32] iommu: dmar: Fix return value check of create_irq() Thomas Gleixner
2014-05-16 13:33   ` [tip:irq/core] iommu: smar: Fix return value check of create_irq( ) tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 10/32] x86: Get rid of get_nr_irqs_gsi() Thomas Gleixner
2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 13/32] ia64: Remove unused check_irq_used() Thomas Gleixner
2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 12/32] iommu: dmar: Provide arch specific irq allocation Thomas Gleixner
2014-05-16 13:33   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 14/32] x86: Remove create/dstroy_irq() Thomas Gleixner
2014-05-16 13:34   ` [tip:irq/core] x86: Remove create/destroy_irq() tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 16/32] tile: usb: Use irq_alloc/free_hwirq Thomas Gleixner
2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 15/32] tile: Implement irq_alloc/free_hwirq() for migration Thomas Gleixner
2014-05-14 17:48   ` Chris Metcalf
     [not found]   ` <5373AC00.7090507@tilera.com>
2014-05-14 23:50     ` Thomas Gleixner
2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 17/32] tile: net: Use irq_alloc/free_hwirq Thomas Gleixner
2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 19/32] tile: hvc: " Thomas Gleixner
2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 18/32] tile: serial: " Thomas Gleixner
2014-05-16 13:34   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 20/32] tile: pci: Use irq_alloc/free_hwirq() Thomas Gleixner
2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 21/32] tile: Use SPARSE_IRQ Thomas Gleixner
2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 22/32] genirq: Make create/destroy_irq() ia64 private Thomas Gleixner
2014-05-16 13:35   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 23/32] x86, irq: Remove pointless irq_reserve_irqs() call Thomas Gleixner
2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 24/32] sh: intc: Remove pointless irq_reserve_irqs() invocation Thomas Gleixner
2014-05-11  0:53   ` Simon Horman
2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 25/32] s390: pci: Check return value of alloc_irq_desc() proper Thomas Gleixner
2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 26/32] s390: Remove pointless arch_show_interrupts() Thomas Gleixner
2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 27/32] s390: Avoid call to irq_reserve_irqs() Thomas Gleixner
2014-05-16 13:36   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 29/32] genirq: Remove irq_reserve_irq[s] Thomas Gleixner
2014-05-08 12:14   ` Grant Likely
2014-05-08 12:54     ` Thomas Gleixner
2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 28/32] genirq: Replace reserve_irqs in core code Thomas Gleixner
2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 30/32] genirq: Replace dynamic_irq_init/cleanup Thomas Gleixner
2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 31/32] ia64: Use irq_init_desc Thomas Gleixner
2014-05-07 20:06   ` Luck, Tony
2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-07 15:44 ` [patch 32/32] genirq: Remove dynamic_irq mess Thomas Gleixner
2014-05-16 13:37   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-05-08 12:17 ` [patch 00/32] genirq: Another round of tree wide cleanups Grant Likely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140508120738.B70FDC40D85@trevor.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=cmetcalf@tilera.com \
    --cc=fenghua.yu@intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®